fix(creator-studio): respect line breaks when deleting blocks
This commit is contained in:
1 parent
561378312f
commit
b497eb4a59
3 files changed
+99
-15
No files matched your search
@@ -154,14 +154,26 @@ export function hydrateBlocks(html: string): string {
|
||||
container.innerHTML = html;
|
||||
|
||||
container.querySelectorAll('pre').forEach((pre) => hydrateCodeBlock(pre));
|
||||
container.querySelectorAll('p').forEach((paragraph) => {
|
||||
const match = paragraph.textContent?.trim().match(/^\[jio_math display="1"\]([\s\S]*?)\[\/jio_math\]$/);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
const formula = match[1];
|
||||
const span = document.createElement('span');
|
||||
span.className = 'jio-math jio-math--block';
|
||||
span.setAttribute('data-jio-math-source', formula);
|
||||
span.setAttribute('data-jio-math-display', '1');
|
||||
span.setAttribute('contenteditable', 'false');
|
||||
span.innerHTML = typeset(formula);
|
||||
paragraph.replaceChildren(span);
|
||||
});
|
||||
|
||||
return container.innerHTML
|
||||
.replace(
|
||||
/\[jio_math display="([01])"\]([\s\S]*?)\[\/jio_math\]/g,
|
||||
(_match, display: string, formula: string) =>
|
||||
display === '0'
|
||||
? `<span class="jio-math" data-jio-math-source="${escapeAttr(formula)}" data-jio-math-display="0" contenteditable="false">${typeset(formula)}</span>`
|
||||
: `<p><span class="jio-math jio-math--block" data-jio-math-source="${escapeAttr(formula)}" data-jio-math-display="1" contenteditable="false">${typeset(formula)}</span></p>`
|
||||
/\[jio_math display="0"\]([\s\S]*?)\[\/jio_math\]/g,
|
||||
(_match, formula: string) =>
|
||||
`<span class="jio-math" data-jio-math-source="${escapeAttr(formula)}" data-jio-math-display="0" contenteditable="false">${typeset(formula)}</span>`
|
||||
)
|
||||
.replace(
|
||||
/\[jio_footnote\]([\s\S]*?)\[\/jio_footnote\]/g,
|
||||
|
||||
Reference in new issue
Block a user