Rename ProseMirror writeAs Parser/Serializer to writeFreely

pull/443/head
Matt Baer 4 years ago
parent 47aa436caa
commit d7c9f56b40
  1. 2
      prose/markdownParser.js
  2. 2
      prose/markdownSerializer.js
  3. 8
      prose/prose.js

@ -3,7 +3,7 @@ import markdownit from "markdown-it";
import { writeFreelySchema } from "./schema";
export const writeAsMarkdownParser = new MarkdownParser(
export const writeFreelyMarkdownParser = new MarkdownParser(
writeFreelySchema,
markdownit("commonmark", { html: true }),
{

@ -26,7 +26,7 @@ function isPlainURL(link, parent, index, side) {
return !link.isInSet(next.marks);
}
export const writeAsMarkdownSerializer = new MarkdownSerializer(
export const writeFreelyMarkdownSerializer = new MarkdownSerializer(
{
readmore(state, node) {
state.write("<!--more-->\n");

@ -14,8 +14,8 @@ import { EditorState, TextSelection } from "prosemirror-state";
import { exampleSetup } from "prosemirror-example-setup";
import { keymap } from "prosemirror-keymap";
import { writeAsMarkdownParser } from "./markdownParser";
import { writeAsMarkdownSerializer } from "./markdownSerializer";
import { writeFreelyMarkdownParser } from "./markdownParser";
import { writeFreelyMarkdownSerializer } from "./markdownSerializer";
import { writeFreelySchema } from "./schema";
import { getMenu } from "./menu";
@ -40,7 +40,7 @@ class ProseMirrorView {
$title.value = title;
}
const doc = writeAsMarkdownParser.parse(
const doc = writeFreelyMarkdownParser.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.replace(/([^]{0,1})(\n)([^]{0,1})/g, (match, p1, p2, p3) => {
@ -73,7 +73,7 @@ class ProseMirrorView {
}),
dispatchTransaction(transaction) {
let newState = this.state.apply(transaction);
const newContent = writeAsMarkdownSerializer
const newContent = writeFreelyMarkdownSerializer
.serialize(newState.doc)
// Replace all \\\ns ( not followed by a \n ) with \n
.replace(/(\\\n)(\n{0,1})/g, (match, p1, p2) =>

Loading…
Cancel
Save