Fix WYSIWYG editor script in Chrome <85

This uses String.replace() instead of String.replaceAll().
pull/383/head
Matt Baer 4 years ago
parent 583693ed8d
commit e36e39cb73
  1. 4
      prose/prose.js

@ -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;

Loading…
Cancel
Save