Просмотр исходного кода

Support horizontal rules in Classic editor

Ref T727
pull/443/head
Matt Baer 3 лет назад
Родитель
Сommit
c01fb585ba
5 измененных файлов: 9 добавлений и 5 удалений
  1. +3
    -2
      less/prose-editor.less
  2. +1
    -1
      prose/markdownParser.js
  3. +4
    -0
      prose/markdownSerializer.js
  4. +1
    -1
      prose/prose.js
  5. +0
    -1
      prose/schema.js

+ 3
- 2
less/prose-editor.less Просмотреть файл

@@ -273,16 +273,17 @@ li.ProseMirror-selectednode:after {
/* Add space around the hr to make clicking it easier */

.ProseMirror-example-setup-style hr {
padding: 2px 10px;
padding: 4px 10px;
border: none;
margin: 1em 0;
background: initial;
}

.ProseMirror-example-setup-style hr:after {
content: "";
display: block;
height: 1px;
background-color: silver;
background-color: #ccc;
line-height: 2px;
}



+ 1
- 1
prose/markdownParser.js Просмотреть файл

@@ -25,7 +25,7 @@ export const writeFreelyMarkdownParser = new MarkdownParser(
getAttrs: (tok) => ({ params: tok.info || "" }),
noCloseToken: true,
},
// hr: { node: "horizontal_rule" },
hr: { node: "horizontal_rule" },
image: {
node: "image",
getAttrs: (tok) => ({


+ 4
- 0
prose/markdownSerializer.js Просмотреть файл

@@ -47,6 +47,10 @@ export const writeFreelyMarkdownSerializer = new MarkdownSerializer(
state.renderInline(node);
state.closeBlock(node);
},
horizontal_rule: function horizontal_rule(state, node) {
state.write(node.attrs.markup || "---");
state.closeBlock(node);
},
bullet_list(state, node) {
node.attrs.tight = true;
state.renderList(node, " ", () => `${node.attrs.bullet || "*"} `);


+ 1
- 1
prose/prose.js Просмотреть файл

@@ -104,7 +104,7 @@ class ProseMirrorView {
}

get content() {
return defaultMarkdownSerializer.serialize(this.view.state.doc);
return writeFreelyMarkdownSerializer.serialize(this.view.state.doc);
}
focus() {
this.view.focus();


+ 0
- 1
prose/schema.js Просмотреть файл

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


Загрузка…
Отмена
Сохранить