Correct line ends

pull/383/head
Viktor Vaczi 4 years ago
parent b1cea637cb
commit 676b673c94
  1. 3
      prose/markdownParser.js
  2. 16
      prose/markdownSerializer.js
  3. 2
      prose/prose.js
  4. 3
      prose/schema.js
  5. 8
      static/js/prose.bundle.js

@ -34,7 +34,7 @@ export const writeAsMarkdownParser = new MarkdownParser(
alt: tok.children?.[0].content || null, alt: tok.children?.[0].content || null,
}), }),
}, },
// hardbreak: { node: "hard_break" }, hardbreak: { node: "hard_break" },
em: { mark: "em" }, em: { mark: "em" },
strong: { mark: "strong" }, strong: { mark: "strong" },
@ -49,7 +49,6 @@ export const writeAsMarkdownParser = new MarkdownParser(
html_block: { html_block: {
node: "readmore", node: "readmore",
getAttrs(token) { getAttrs(token) {
console.log({ token });
// TODO: Give different attributes depending on the token content // TODO: Give different attributes depending on the token content
return {}; return {};
}, },

@ -29,7 +29,7 @@ function isPlainURL(link, parent, index, side) {
export const writeAsMarkdownSerializer = new MarkdownSerializer( export const writeAsMarkdownSerializer = new MarkdownSerializer(
{ {
readmore(state, node) { readmore(state, node) {
state.write("<!--more-->"); state.write("<!--more-->\n");
state.closeBlock(node); state.closeBlock(node);
}, },
// blockquote(state, node) { // blockquote(state, node) {
@ -78,13 +78,13 @@ export const writeAsMarkdownSerializer = new MarkdownSerializer(
})`, })`,
); );
}, },
// hard_break(state, node, parent, index) { hard_break(state, node, parent, index) {
// for (let i = index + 1; i < parent.childCount; i += 1) for (let i = index + 1; i < parent.childCount; i += 1)
// if (parent.child(i).type !== node.type) { if (parent.child(i).type !== node.type) {
// state.write("\\\n"); state.write("\n");
// return; return;
// } }
// }, },
text(state, node) { text(state, node) {
state.text(node.text || ""); state.text(node.text || "");
}, },

@ -58,8 +58,8 @@ class ProseMirrorView {
dispatchTransaction(transaction) { dispatchTransaction(transaction) {
// console.log('saving to '+window.draftKey) // console.log('saving to '+window.draftKey)
const newContent = writeAsMarkdownSerializer.serialize(transaction.doc) const newContent = writeAsMarkdownSerializer.serialize(transaction.doc)
console.log({newContent})
$content.value = newContent $content.value = newContent
console.log({ newContent })
localStorage.setItem(window.draftKey, function () { localStorage.setItem(window.draftKey, function () {
let draft = ""; let draft = "";
if ($title.value != null && $title.value !== "") { if ($title.value != null && $title.value !== "") {

@ -4,7 +4,6 @@ import { Schema } from "prosemirror-model";
export const writeFreelySchema = new Schema({ export const writeFreelySchema = new Schema({
nodes: schema.spec.nodes.remove("blockquote") nodes: schema.spec.nodes.remove("blockquote")
.remove("horizontal_rule") .remove("horizontal_rule")
.remove("hard_break")
.addToEnd("readmore", { .addToEnd("readmore", {
inline: false, inline: false,
content: "", content: "",
@ -15,5 +14,3 @@ export const writeFreelySchema = new Schema({
}), }),
marks: schema.spec.marks, marks: schema.spec.marks,
}); });
console.log({ writeFreelySchema })

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save