From: Dan Brown Date: Fri, 14 Jan 2022 14:55:07 +0000 (+0000) Subject: Imported marks from example schema for customization X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/07c8876e22ccfc9de29abdffc4917a198e0f17d7?ds=inline Imported marks from example schema for customization --- diff --git a/TODO b/TODO new file mode 100644 index 000000000..977e71e57 --- /dev/null +++ b/TODO @@ -0,0 +1,30 @@ +- Render color picker view menu item. + +### Features + +- Tables +- Links +- Images + - Image Resizing in editor +- Drawings +- LTR/RTL control +- Fullscreen +- Paste Image Uploading +- Drag + Drop Image Uploading +- Details/Summary +- Checkbox/TODO list items +- Code blocks +- Inline Code +- Indents +- Iframe/Media +- Clear formatting +- View Code +- Attachment integration (Drag & drop) +- Template system integration. + +### Improvements + +- List type changing. +- Color picker options should have "clear" option. +- Color picker buttons should be split, with button to re-apply last selected color. +- Color picker options should change color if different instead of remove. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index df713a1b9..121589580 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,6 @@ "prosemirror-example-setup": "^1.1.2", "prosemirror-markdown": "^1.6.0", "prosemirror-model": "^1.15.0", - "prosemirror-schema-basic": "^1.1.2", "prosemirror-schema-list": "^1.1.6", "prosemirror-state": "^1.3.4", "prosemirror-view": "^1.23.2", @@ -1503,14 +1502,6 @@ "orderedmap": "^1.1.0" } }, - "node_modules/prosemirror-schema-basic": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prosemirror-schema-basic/-/prosemirror-schema-basic-1.1.2.tgz", - "integrity": "sha512-G4q8WflNsR1Q33QAV4MQO0xWrHLOJ+BQcKswGXMy626wlQj6c/1n1v4eC9ns+h2y1r/fJHZEgSZnsNhm9lbrDw==", - "dependencies": { - "prosemirror-model": "^1.2.0" - } - }, "node_modules/prosemirror-schema-list": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/prosemirror-schema-list/-/prosemirror-schema-list-1.1.6.tgz", @@ -3074,14 +3065,6 @@ "orderedmap": "^1.1.0" } }, - "prosemirror-schema-basic": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prosemirror-schema-basic/-/prosemirror-schema-basic-1.1.2.tgz", - "integrity": "sha512-G4q8WflNsR1Q33QAV4MQO0xWrHLOJ+BQcKswGXMy626wlQj6c/1n1v4eC9ns+h2y1r/fJHZEgSZnsNhm9lbrDw==", - "requires": { - "prosemirror-model": "^1.2.0" - } - }, "prosemirror-schema-list": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/prosemirror-schema-list/-/prosemirror-schema-list-1.1.6.tgz", diff --git a/package.json b/package.json index c4ea1a302..bd16a728d 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ "prosemirror-example-setup": "^1.1.2", "prosemirror-markdown": "^1.6.0", "prosemirror-model": "^1.15.0", - "prosemirror-schema-basic": "^1.1.2", "prosemirror-schema-list": "^1.1.6", "prosemirror-state": "^1.3.4", "prosemirror-view": "^1.23.2", diff --git a/resources/js/editor/schema-marks.js b/resources/js/editor/schema-marks.js index 52335fac6..c8b8da346 100644 --- a/resources/js/editor/schema-marks.js +++ b/resources/js/editor/schema-marks.js @@ -1,6 +1,55 @@ -import {schema as basicSchema} from "prosemirror-schema-basic"; +const link = { + attrs: { + href: {}, + title: {default: null} + }, + inclusive: false, + parseDOM: [{ + tag: "a[href]", getAttrs: function getAttrs(dom) { + return {href: dom.getAttribute("href"), title: dom.getAttribute("title")} + } + }], + toDOM: function toDOM(node) { + const ref = node.attrs; + const href = ref.href; + const title = ref.title; + return ["a", {href: href, title: title}, 0] + } +}; -const baseMarks = basicSchema.spec.marks; +const em = { + parseDOM: [{tag: "i"}, {tag: "em"}, {style: "font-style=italic"}], + toDOM() { + return ["em", 0] + } +}; + +const strong = { + parseDOM: [{tag: "strong"}, + // This works around a Google Docs misbehavior where + // pasted content will be inexplicably wrapped in `` + // tags with a font-weight normal. + { + tag: "b", getAttrs: function (node) { + return node.style.fontWeight != "normal" && null; + } + }, + { + style: "font-weight", getAttrs: function (value) { + return /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null; + } + }], + toDOM() { + return ["strong", 0] + } +}; + +const code = { + parseDOM: [{tag: "code"}], + toDOM() { + return ["code", 0] + } +}; const underline = { parseDOM: [{tag: "u"}, {style: "text-decoration=underline"}], @@ -60,13 +109,17 @@ const background_color = { } }; -const marks = baseMarks.append({ +const marks = { + link, + em, + strong, + code, underline, strike, superscript, subscript, text_color, background_color, -}); +}; export default marks; \ No newline at end of file