Correct line ends
This commit is contained in:
parent
b1cea637cb
commit
676b673c94
5 changed files with 14 additions and 18 deletions
|
@ -34,7 +34,7 @@ export const writeAsMarkdownParser = new MarkdownParser(
|
|||
alt: tok.children?.[0].content || null,
|
||||
}),
|
||||
},
|
||||
// hardbreak: { node: "hard_break" },
|
||||
hardbreak: { node: "hard_break" },
|
||||
|
||||
em: { mark: "em" },
|
||||
strong: { mark: "strong" },
|
||||
|
@ -49,7 +49,6 @@ export const writeAsMarkdownParser = new MarkdownParser(
|
|||
html_block: {
|
||||
node: "readmore",
|
||||
getAttrs(token) {
|
||||
console.log({ token });
|
||||
// TODO: Give different attributes depending on the token content
|
||||
return {};
|
||||
},
|
||||
|
|
|
@ -29,7 +29,7 @@ function isPlainURL(link, parent, index, side) {
|
|||
export const writeAsMarkdownSerializer = new MarkdownSerializer(
|
||||
{
|
||||
readmore(state, node) {
|
||||
state.write("<!--more-->");
|
||||
state.write("<!--more-->\n");
|
||||
state.closeBlock(node);
|
||||
},
|
||||
// blockquote(state, node) {
|
||||
|
@ -78,13 +78,13 @@ export const writeAsMarkdownSerializer = new MarkdownSerializer(
|
|||
})`,
|
||||
);
|
||||
},
|
||||
// hard_break(state, node, parent, index) {
|
||||
// for (let i = index + 1; i < parent.childCount; i += 1)
|
||||
// if (parent.child(i).type !== node.type) {
|
||||
// state.write("\\\n");
|
||||
// return;
|
||||
// }
|
||||
// },
|
||||
hard_break(state, node, parent, index) {
|
||||
for (let i = index + 1; i < parent.childCount; i += 1)
|
||||
if (parent.child(i).type !== node.type) {
|
||||
state.write("\n");
|
||||
return;
|
||||
}
|
||||
},
|
||||
text(state, node) {
|
||||
state.text(node.text || "");
|
||||
},
|
||||
|
|
|
@ -58,8 +58,8 @@ class ProseMirrorView {
|
|||
dispatchTransaction(transaction) {
|
||||
// console.log('saving to '+window.draftKey)
|
||||
const newContent = writeAsMarkdownSerializer.serialize(transaction.doc)
|
||||
console.log({newContent})
|
||||
$content.value = newContent
|
||||
console.log({ newContent })
|
||||
localStorage.setItem(window.draftKey, function () {
|
||||
let draft = "";
|
||||
if ($title.value != null && $title.value !== "") {
|
||||
|
|
|
@ -4,7 +4,6 @@ import { Schema } from "prosemirror-model";
|
|||
export const writeFreelySchema = new Schema({
|
||||
nodes: schema.spec.nodes.remove("blockquote")
|
||||
.remove("horizontal_rule")
|
||||
.remove("hard_break")
|
||||
.addToEnd("readmore", {
|
||||
inline: false,
|
||||
content: "",
|
||||
|
@ -15,5 +14,3 @@ export const writeFreelySchema = new Schema({
|
|||
}),
|
||||
marks: schema.spec.marks,
|
||||
});
|
||||
|
||||
console.log({ writeFreelySchema })
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue