Skip to content

Commit 3ad4e96

Browse files
authored
Modify renderCompactMarkdown() so that it causes no flickering/scrolling in Live Preview (#2131)
* Revert 7a2b6a1 but only for src/ui/render.ts * Fix the incorrect cursor overlapping check * Squashed commit of the following: commit f4e0bdd Author: RyotaUshio <ushio@ms.k.u-tokyo.ac.jp> Date: Sat Oct 14 06:37:10 2023 +0900 Fix typo commit 43f3be4 Author: RyotaUshio <ushio@ms.k.u-tokyo.ac.jp> Date: Sat Oct 14 06:29:01 2023 +0900 Fix formatting commit 74e45e4 Author: RyotaUshio <ushio@ms.k.u-tokyo.ac.jp> Date: Sat Oct 14 06:28:32 2023 +0900 Fix the starting position of an inline field could not obtained correctly after a document change commit 7570941 Author: RyotaUshio <ushio@ms.k.u-tokyo.ac.jp> Date: Sat Oct 14 06:07:03 2023 +0900 Fix formatting commit ba7a0a5 Author: RyotaUshio <ushio@ms.k.u-tokyo.ac.jp> Date: Sat Oct 14 06:04:27 2023 +0900 Fix the previous commit works only for the first line commit 08bcd32 Author: RyotaUshio <ushio@ms.k.u-tokyo.ac.jp> Date: Sat Oct 14 05:54:44 2023 +0900 Resolve #2101: add a click event handler to inline field widgets in live preview * Squashed commit of the following: commit 21591ff Author: RyotaUshio <ushio@ms.k.u-tokyo.ac.jp> Date: Sat Oct 14 07:41:40 2023 +0900 Fix #2107: Prevent inline fields inside a code block from being rendered in live preview * Squashed commit of the following: commit f787431 Author: RyotaUshio <ushio@ms.k.u-tokyo.ac.jp> Date: Sun Oct 29 00:41:52 2023 +0900 fix formatting commit 7205a70 Author: RyotaUshio <ushio@ms.k.u-tokyo.ac.jp> Date: Sun Oct 29 00:28:24 2023 +0900 separate the inline fields rendering option into one for reading view & one for live preview * fix the auto-scrolling/flickering issue of inline fields (#2128) and dv.paragraph not working for lists (#2099) * fix formatting --------- Co-authored-by: RyotaUshio <ushio@ms.k.u-tokyo.ac.jp>
1 parent d90d784 commit 3ad4e96

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/ui/render.ts

+27
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,33 @@ export async function renderCompactMarkdown(
1818
let paragraph = tmpContainer.querySelector(":scope > p");
1919
if (tmpContainer.childNodes.length == 1 && paragraph) {
2020
container.replaceChildren(...paragraph.childNodes);
21+
} else {
22+
/**
23+
* In most cases, the condition above will be true.
24+
* However, it is not always true, for example:
25+
* ```dataviewjs
26+
* dv.paragraph(`
27+
* - list item 1
28+
* - list item 2
29+
*
30+
* 1. list item 3
31+
* 2. list item 4
32+
* `)
33+
* ```
34+
* MarkdownRenderer.renderMarkdown will render it as:
35+
* <span>
36+
* <ul>
37+
* <li>list item 1</li>
38+
* <li>list item 2</li>
39+
* </ul>
40+
* <ol>
41+
* <li>list item 3</li>
42+
* <li>list item 4</li>
43+
* </ol>
44+
* </span>
45+
* Notice that there is no <p> tag.
46+
*/
47+
container.replaceChildren(...tmpContainer.childNodes);
2148
}
2249

2350
tmpContainer.remove();

0 commit comments

Comments
 (0)