Fix WYSIWYG editor script in Chrome <85

This uses String.replace() instead of String.replaceAll().
This commit is contained in:
Matt Baer 2021-03-03 16:38:49 -05:00
parent 583693ed8d
commit e36e39cb73
1 changed files with 2 additions and 2 deletions

View File

@ -43,7 +43,7 @@ class ProseMirrorView {
const doc = writeAsMarkdownParser.parse(
// Replace all "solo" \n's with \\\n for correct markdown parsing
// Can't use lookahead or lookbehind because it's not supported on Safari
content.replaceAll(/([^]{0,1})(\n)([^]{0,1})/g, (match, p1, p2, p3) => {
content.replace(/([^]{0,1})(\n)([^]{0,1})/g, (match, p1, p2, p3) => {
return p1 !== "\n" && p3 !== "\n" ? p1 + "\\\n" + p3 : match;
})
);
@ -76,7 +76,7 @@ class ProseMirrorView {
const newContent = writeAsMarkdownSerializer
.serialize(newState.doc)
// Replace all \\\ns ( not followed by a \n ) with \n
.replaceAll(/(\\\n)(\n{0,1})/g, (match, p1, p2) =>
.replace(/(\\\n)(\n{0,1})/g, (match, p1, p2) =>
p2 !== "\n" ? "\n" + p2 : match
);
$content.value = newContent;