@scrider/formatter 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -95,7 +95,7 @@ A `Shift+Enter` style line break that does **not** split the containing block. S
|
|
|
95
95
|
| HTML | `<br data-scrider-embed>` (the marker disambiguates it from the `<br>` placeholder inside an empty paragraph) |
|
|
96
96
|
| Markdown | `" \n"` by default — GFM hard break; switch to inline `<br>` via `deltaToMarkdown(delta, { softBreakStyle: 'html' })` |
|
|
97
97
|
|
|
98
|
-
`htmlToDelta` also recognises bare `<br>` between content (e.g. `<p>foo<br>bar</p>`) as a soft break, while keeping the leading / placeholder shapes (`<p><br></p>`, `<p><br>foo</p>`) as regular newlines for backward compatibility.
|
|
98
|
+
`htmlToDelta` also recognises bare `<br>` between content (e.g. `<p>foo<br>bar</p>`) as a soft break, while keeping the leading / placeholder shapes (`<p><br></p>`, `<p><br>foo</p>`) as regular newlines for backward compatibility. The explicit `data-scrider-embed` marker overrides the placeholder heuristic, so a lone `<br data-scrider-embed>` inside an otherwise empty `<p>` is still parsed as a `{ softBreak: true }` embed (since v1.3.1).
|
|
99
99
|
|
|
100
100
|
```typescript
|
|
101
101
|
import { Delta, deltaToHtml, deltaToMarkdown } from '@scrider/formatter';
|
package/dist/index.cjs
CHANGED
|
@@ -3625,7 +3625,7 @@ function htmlToDelta(html, options = {}) {
|
|
|
3625
3625
|
}
|
|
3626
3626
|
const children2 = element.childNodes;
|
|
3627
3627
|
const firstChild = children2[0];
|
|
3628
|
-
const isBrOnlyParagraph = children2.length === 1 && firstChild !== void 0 && isElement(firstChild) && firstChild.tagName.toLowerCase() === "br";
|
|
3628
|
+
const isBrOnlyParagraph = children2.length === 1 && firstChild !== void 0 && isElement(firstChild) && firstChild.tagName.toLowerCase() === "br" && !firstChild.hasAttribute("data-scrider-embed");
|
|
3629
3629
|
if (!isBrOnlyParagraph) {
|
|
3630
3630
|
processChildren(element);
|
|
3631
3631
|
}
|