UNPKG

prosemirror-remark

Version:
1,462 lines (1,349 loc) 190 kB
import * as __WEBPACK_EXTERNAL_MODULE_prosemirror_unified_0a343064__ from "prosemirror-unified"; import * as __WEBPACK_EXTERNAL_MODULE_remark_parse_76724963__ from "remark-parse"; import * as __WEBPACK_EXTERNAL_MODULE_remark_stringify_a28ae2a6__ from "remark-stringify"; import * as __WEBPACK_EXTERNAL_MODULE_prosemirror_commands_5e270ab3__ from "prosemirror-commands"; import * as __WEBPACK_EXTERNAL_MODULE_prosemirror_inputrules_847ff8d2__ from "prosemirror-inputrules"; import * as __WEBPACK_EXTERNAL_MODULE_prosemirror_state_1d692759__ from "prosemirror-state"; import * as __WEBPACK_EXTERNAL_MODULE_prosemirror_schema_list_6ac4a27c__ from "prosemirror-schema-list"; /******/ // The require scope /******/ var __webpack_require__ = {}; /******/ /************************************************************************/ /******/ /* webpack/runtime/define property getters */ /******/ (() => { /******/ // define getter functions for harmony exports /******/ __webpack_require__.d = (exports, definition) => { /******/ for(var key in definition) { /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); /******/ } /******/ } /******/ }; /******/ })(); /******/ /******/ /* webpack/runtime/hasOwnProperty shorthand */ /******/ (() => { /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) /******/ })(); /******/ /************************************************************************/ var __webpack_exports__ = {}; // EXPORTS __webpack_require__.d(__webpack_exports__, { xT: () => (/* reexport */ BlockquoteExtension), ll: () => (/* reexport */ BoldExtension), j5: () => (/* reexport */ BreakExtension), US: () => (/* reexport */ CodeBlockExtension), rb: () => (/* reexport */ DefinitionExtension), Qh: () => (/* reexport */ ExtendedAutolinkExtension), Om: () => (/* reexport */ GFMExtension), oq: () => (/* reexport */ HeadingExtension), SY: () => (/* reexport */ HorizontalRuleExtension), zS: () => (/* reexport */ ImageExtension), OO: () => (/* reexport */ ImageReferenceExtension), eX: () => (/* reexport */ InlineCodeExtension), A6: () => (/* reexport */ ItalicExtension), O$: () => (/* reexport */ LinkExtension), lt: () => (/* reexport */ LinkReferenceExtension), vs: () => (/* reexport */ ListItemExtension), Db: () => (/* reexport */ MarkdownExtension), XS: () => (/* reexport */ OrderedListExtension), yV: () => (/* reexport */ ParagraphExtension), sY: () => (/* reexport */ RootExtension), zd: () => (/* reexport */ StrikethroughExtension), uG: () => (/* reexport */ TaskListItemExtension), r2: () => (/* reexport */ TextExtension), Mv: () => (/* reexport */ UnorderedListExtension) }); ;// CONCATENATED MODULE: external "prosemirror-unified" var x = (y) => { var x = {}; __webpack_require__.d(x, y); return x } var y = (x) => (() => (x)) const external_prosemirror_unified_namespaceObject = x({ ["Extension"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_unified_0a343064__.Extension), ["MarkExtension"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_unified_0a343064__.MarkExtension), ["MarkInputRule"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_unified_0a343064__.MarkInputRule), ["NodeExtension"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_unified_0a343064__.NodeExtension), ["createProseMirrorNode"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_unified_0a343064__.createProseMirrorNode) }); ;// CONCATENATED MODULE: external "remark-parse" var external_remark_parse_x = (y) => { var x = {}; __webpack_require__.d(x, y); return x } var external_remark_parse_y = (x) => (() => (x)) const external_remark_parse_namespaceObject = external_remark_parse_x({ ["default"]: () => (__WEBPACK_EXTERNAL_MODULE_remark_parse_76724963__["default"]) }); ;// CONCATENATED MODULE: external "remark-stringify" var external_remark_stringify_x = (y) => { var x = {}; __webpack_require__.d(x, y); return x } var external_remark_stringify_y = (x) => (() => (x)) const external_remark_stringify_namespaceObject = external_remark_stringify_x({ ["default"]: () => (__WEBPACK_EXTERNAL_MODULE_remark_stringify_a28ae2a6__["default"]) }); ;// CONCATENATED MODULE: external "prosemirror-commands" var external_prosemirror_commands_x = (y) => { var x = {}; __webpack_require__.d(x, y); return x } var external_prosemirror_commands_y = (x) => (() => (x)) const external_prosemirror_commands_namespaceObject = external_prosemirror_commands_x({ ["chainCommands"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_commands_5e270ab3__.chainCommands), ["exitCode"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_commands_5e270ab3__.exitCode), ["setBlockType"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_commands_5e270ab3__.setBlockType), ["toggleMark"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_commands_5e270ab3__.toggleMark), ["wrapIn"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_commands_5e270ab3__.wrapIn) }); ;// CONCATENATED MODULE: external "prosemirror-inputrules" var external_prosemirror_inputrules_x = (y) => { var x = {}; __webpack_require__.d(x, y); return x } var external_prosemirror_inputrules_y = (x) => (() => (x)) const external_prosemirror_inputrules_namespaceObject = external_prosemirror_inputrules_x({ ["InputRule"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_inputrules_847ff8d2__.InputRule), ["textblockTypeInputRule"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_inputrules_847ff8d2__.textblockTypeInputRule), ["wrappingInputRule"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_inputrules_847ff8d2__.wrappingInputRule) }); ;// CONCATENATED MODULE: ./src/syntax-extensions/BlockquoteExtension.ts /** * @public */ class BlockquoteExtension extends external_prosemirror_unified_namespaceObject.NodeExtension { proseMirrorInputRules(proseMirrorSchema) { return [ (0,external_prosemirror_inputrules_namespaceObject.wrappingInputRule)(/^\s{0,3}>\s$/u, proseMirrorSchema.nodes[this.proseMirrorNodeName()]), ]; } proseMirrorKeymap(proseMirrorSchema) { return { "Mod->": (0,external_prosemirror_commands_namespaceObject.wrapIn)(proseMirrorSchema.nodes[this.proseMirrorNodeName()]), }; } proseMirrorNodeName() { return "blockquote"; } proseMirrorNodeSpec() { return { content: "block+", group: "block", parseDOM: [{ tag: "blockquote" }], toDOM() { return ["blockquote", 0]; }, }; } proseMirrorNodeToUnistNodes(_node, convertedChildren) { return [ { children: convertedChildren, type: this.unistNodeName(), }, ]; } unistNodeName() { return "blockquote"; } unistNodeToProseMirrorNodes(_node, proseMirrorSchema, convertedChildren) { return (0,external_prosemirror_unified_namespaceObject.createProseMirrorNode)(this.proseMirrorNodeName(), proseMirrorSchema, convertedChildren); } } ;// CONCATENATED MODULE: ./src/syntax-extensions/BoldExtension.ts /** * @public */ class BoldExtension extends external_prosemirror_unified_namespaceObject.MarkExtension { processConvertedUnistNode(convertedNode) { return { children: [convertedNode], type: this.unistNodeName() }; } proseMirrorInputRules(proseMirrorSchema) { return [ new external_prosemirror_unified_namespaceObject.MarkInputRule(/\*\*([^\s](?:.*[^\s])?)\*\*([\s\S])$/u, proseMirrorSchema.marks[this.proseMirrorMarkName()]), new external_prosemirror_unified_namespaceObject.MarkInputRule(/__([^\s](?:.*[^\s])?)__([\s\S])$/u, proseMirrorSchema.marks[this.proseMirrorMarkName()]), ]; } proseMirrorKeymap(proseMirrorSchema) { const markType = proseMirrorSchema.marks[this.proseMirrorMarkName()]; return { "Mod-b": (0,external_prosemirror_commands_namespaceObject.toggleMark)(markType), "Mod-B": (0,external_prosemirror_commands_namespaceObject.toggleMark)(markType), }; } proseMirrorMarkName() { return "strong"; } proseMirrorMarkSpec() { return { parseDOM: [ { tag: "b" }, { tag: "strong" }, { getAttrs: (value) => /^(bold(er)?|[5-9]\d{2,})$/u.test(value) && null, style: "font-weight", }, ], toDOM() { return ["strong"]; }, }; } unistNodeName() { return "strong"; } unistNodeToProseMirrorNodes(_node, proseMirrorSchema, convertedChildren) { return convertedChildren.map((child) => child.mark(child.marks.concat([ proseMirrorSchema.marks[this.proseMirrorMarkName()].create(), ]))); } } ;// CONCATENATED MODULE: ./src/syntax-extensions/BreakExtension.ts /** * @public */ class BreakExtension extends external_prosemirror_unified_namespaceObject.NodeExtension { proseMirrorKeymap(proseMirrorSchema) { const command = (0,external_prosemirror_commands_namespaceObject.chainCommands)(external_prosemirror_commands_namespaceObject.exitCode, (state, dispatch) => { if (dispatch) { dispatch(state.tr .replaceSelectionWith(proseMirrorSchema.nodes[this.proseMirrorNodeName()].create()) .scrollIntoView()); } return true; }); const isMac = typeof navigator !== "undefined" ? /Mac|iP(hone|[oa]d)/u.test(navigator.platform) // eslint-disable-line @typescript-eslint/no-deprecated -- In the tested systems, it will be defined : false; return Object.assign({ "Mod-Enter": command, "Shift-Enter": command }, (isMac && { "Ctrl-Enter": command })); } proseMirrorNodeName() { return "hard_break"; } proseMirrorNodeSpec() { return { group: "inline", inline: true, parseDOM: [{ tag: "br" }], selectable: false, toDOM() { return ["br"]; }, }; } proseMirrorNodeToUnistNodes() { return [{ type: this.unistNodeName() }]; } unistNodeName() { return "break"; } unistNodeToProseMirrorNodes(_node, proseMirrorSchema, convertedChildren) { return (0,external_prosemirror_unified_namespaceObject.createProseMirrorNode)(this.proseMirrorNodeName(), proseMirrorSchema, convertedChildren); } } ;// CONCATENATED MODULE: external "prosemirror-state" var external_prosemirror_state_x = (y) => { var x = {}; __webpack_require__.d(x, y); return x } var external_prosemirror_state_y = (x) => (() => (x)) const external_prosemirror_state_namespaceObject = external_prosemirror_state_x({ ["Selection"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_state_1d692759__.Selection) }); ;// CONCATENATED MODULE: ./src/syntax-extensions/TextExtension.ts /** * @public */ class TextExtension extends external_prosemirror_unified_namespaceObject.NodeExtension { proseMirrorNodeName() { return "text"; } proseMirrorNodeSpec() { return { group: "inline", }; } proseMirrorNodeToUnistNodes(node) { var _a; return [{ type: this.unistNodeName(), value: (_a = node.text) !== null && _a !== void 0 ? _a : "" }]; } unistNodeName() { return "text"; } unistNodeToProseMirrorNodes(node, proseMirrorSchema) { return [proseMirrorSchema.text(node.value)]; } } ;// CONCATENATED MODULE: ./src/syntax-extensions/CodeBlockExtension.ts /** * @public */ class CodeBlockExtension extends external_prosemirror_unified_namespaceObject.NodeExtension { static liftOutOfCodeBlock() { return (state, dispatch) => { const { $from, $to } = state.selection; if ( // Mustn't be a complex selection !$from.sameParent($to) || // Must be in a code block $from.parent.type.name !== "code_block" || // Must be at the end of the code block $from.parentOffset !== $from.parent.content.size || // There must already be a preceding empty line !$from.parent.textBetween(0, $from.parentOffset).endsWith("\n\n")) { return false; } if (dispatch) { const tr = state.tr; dispatch(tr // Delete the preceding empty line .deleteRange($from.pos - 2, $from.pos) // Insert empty paragraph .insert($from.pos - 1, tr.doc.type.schema.nodes["paragraph"].create()) // Put the cursor into the empty paragraph .setSelection(external_prosemirror_state_namespaceObject.Selection.near(tr.doc.resolve($from.pos), 1)) .scrollIntoView()); } return true; }; } dependencies() { return [new TextExtension()]; } proseMirrorInputRules(proseMirrorSchema) { return [ (0,external_prosemirror_inputrules_namespaceObject.textblockTypeInputRule)(/^\s{0,3}```$/u, proseMirrorSchema.nodes[this.proseMirrorNodeName()]), (0,external_prosemirror_inputrules_namespaceObject.textblockTypeInputRule)(/^\s{4}$/u, proseMirrorSchema.nodes[this.proseMirrorNodeName()]), ]; } proseMirrorKeymap(proseMirrorSchema) { return { Enter: CodeBlockExtension.liftOutOfCodeBlock(), "Shift-Mod-\\": (0,external_prosemirror_commands_namespaceObject.setBlockType)(proseMirrorSchema.nodes[this.proseMirrorNodeName()]), }; } proseMirrorNodeName() { return "code_block"; } proseMirrorNodeSpec() { return { code: true, content: "text*", defining: true, group: "block", marks: "", parseDOM: [{ preserveWhitespace: "full", tag: "pre" }], toDOM() { return ["pre", ["code", 0]]; }, }; } proseMirrorNodeToUnistNodes(_node, convertedChildren) { return [ { type: this.unistNodeName(), value: convertedChildren.map((child) => child.value).join(""), }, ]; } unistNodeName() { return "code"; } unistNodeToProseMirrorNodes(node, proseMirrorSchema) { return (0,external_prosemirror_unified_namespaceObject.createProseMirrorNode)(this.proseMirrorNodeName(), proseMirrorSchema, [proseMirrorSchema.text(node.value)]); } } ;// CONCATENATED MODULE: ./src/syntax-extensions/DefinitionExtension.ts /** * @public */ class DefinitionExtension extends external_prosemirror_unified_namespaceObject.NodeExtension { proseMirrorNodeName() { return null; } proseMirrorNodeSpec() { return null; } proseMirrorNodeToUnistNodes() { return []; } unistNodeName() { return "definition"; } unistNodeToProseMirrorNodes(node, _proseMirrorSchema, _convertedChildren, context) { if (context.DefinitionExtension === undefined) { context.DefinitionExtension = { definitions: {} }; } context.DefinitionExtension.definitions[node.identifier] = { title: node.title, url: node.url, }; return []; } } ;// CONCATENATED MODULE: ./src/syntax-extensions/ParagraphExtension.ts /** * @public */ class ParagraphExtension extends external_prosemirror_unified_namespaceObject.NodeExtension { proseMirrorNodeName() { return "paragraph"; } proseMirrorNodeSpec() { return { content: "inline*", group: "block", parseDOM: [{ tag: "p" }], toDOM() { return ["p", 0]; }, }; } proseMirrorNodeToUnistNodes(_node, convertedChildren) { return [{ children: convertedChildren, type: this.unistNodeName() }]; } unistNodeName() { return "paragraph"; } unistNodeToProseMirrorNodes(_node, proseMirrorSchema, convertedChildren) { return (0,external_prosemirror_unified_namespaceObject.createProseMirrorNode)(this.proseMirrorNodeName(), proseMirrorSchema, convertedChildren); } } ;// CONCATENATED MODULE: ./src/syntax-extensions/HeadingExtension.ts /** * @public */ class HeadingExtension extends external_prosemirror_unified_namespaceObject.NodeExtension { static headingLevelCommandBuilder(proseMirrorSchema, levelUpdate, onlyAtStart) { return (state, dispatch, view) => { if (onlyAtStart && !HeadingExtension.isAtStart(state, view)) { return false; } const { $anchor } = state.selection; const headingNode = $anchor.parent; if (headingNode.type.name !== "heading") { return false; } const newHeadingLevel = headingNode.attrs["level"] + levelUpdate; if (newHeadingLevel < 0 || newHeadingLevel > 6) { return false; } if (dispatch === undefined) { return true; } const headingPosition = $anchor.before($anchor.depth); if (newHeadingLevel > 0) { dispatch(state.tr.setNodeMarkup(headingPosition, undefined, { level: newHeadingLevel, })); } else { dispatch(state.tr.setNodeMarkup(headingPosition, proseMirrorSchema.nodes["paragraph"])); } return true; }; } static isAtStart(state, view) { if (!state.selection.empty) { return false; } if (view !== undefined) { return view.endOfTextblock("backward", state); } return state.selection.$anchor.parentOffset > 0; } dependencies() { return [new ParagraphExtension(), new TextExtension()]; } proseMirrorInputRules(proseMirrorSchema) { return [ (0,external_prosemirror_inputrules_namespaceObject.textblockTypeInputRule)(/^\s{0,3}(#{1,6})\s$/u, proseMirrorSchema.nodes[this.proseMirrorNodeName()], (match) => ({ level: match[1].length })), ]; } proseMirrorKeymap(proseMirrorSchema) { const keymap = { // eslint-disable-next-line @typescript-eslint/naming-convention -- This is a key "#": HeadingExtension.headingLevelCommandBuilder(proseMirrorSchema, +1, true), Backspace: HeadingExtension.headingLevelCommandBuilder(proseMirrorSchema, -1, true), "Shift-Tab": HeadingExtension.headingLevelCommandBuilder(proseMirrorSchema, -1, false), Tab: HeadingExtension.headingLevelCommandBuilder(proseMirrorSchema, +1, false), }; for (let i = 1; i <= 6; i++) { keymap[`Shift-Mod-${i.toString()}`] = (0,external_prosemirror_commands_namespaceObject.setBlockType)(proseMirrorSchema.nodes[this.proseMirrorNodeName()], { level: i }); } return keymap; } proseMirrorNodeName() { return "heading"; } proseMirrorNodeSpec() { return { attrs: { level: { default: 1 } }, content: "text*", defining: true, group: "block", parseDOM: [ { attrs: { level: 1 }, tag: "h1" }, { attrs: { level: 2 }, tag: "h2" }, { attrs: { level: 3 }, tag: "h3" }, { attrs: { level: 4 }, tag: "h4" }, { attrs: { level: 5 }, tag: "h5" }, { attrs: { level: 6 }, tag: "h6" }, ], toDOM(node) { return [`h${node.attrs["level"].toString()}`, 0]; }, }; } proseMirrorNodeToUnistNodes(node, convertedChildren) { return [ { children: convertedChildren, depth: node.attrs["level"], type: this.unistNodeName(), }, ]; } unistNodeName() { return "heading"; } unistNodeToProseMirrorNodes(node, proseMirrorSchema, convertedChildren) { return (0,external_prosemirror_unified_namespaceObject.createProseMirrorNode)(this.proseMirrorNodeName(), proseMirrorSchema, convertedChildren, { level: node.depth, }); } } ;// CONCATENATED MODULE: ./src/syntax-extensions/HorizontalRuleExtension.ts /** * @public */ class HorizontalRuleExtension extends external_prosemirror_unified_namespaceObject.NodeExtension { proseMirrorInputRules(proseMirrorSchema) { return [ new external_prosemirror_inputrules_namespaceObject.InputRule(/^\s{0,3}(?:\*\*\*|---|___)\n$/u, (state, _, start, end) => state.tr.replaceWith(start, end, (0,external_prosemirror_unified_namespaceObject.createProseMirrorNode)(this.proseMirrorNodeName(), proseMirrorSchema, []))), ]; } proseMirrorKeymap(proseMirrorSchema) { return { "Mod-_": (state, dispatch) => { if (dispatch) { dispatch(state.tr .replaceSelectionWith(proseMirrorSchema.nodes[this.proseMirrorNodeName()].create()) .scrollIntoView()); } return true; }, }; } proseMirrorNodeName() { return "horizontal_rule"; } proseMirrorNodeSpec() { return { group: "block", parseDOM: [{ tag: "hr" }], toDOM() { return ["div", ["hr"]]; }, }; } proseMirrorNodeToUnistNodes() { return [ { type: this.unistNodeName(), }, ]; } unistNodeName() { return "thematicBreak"; } unistNodeToProseMirrorNodes(_node, proseMirrorSchema, convertedChildren) { return (0,external_prosemirror_unified_namespaceObject.createProseMirrorNode)(this.proseMirrorNodeName(), proseMirrorSchema, convertedChildren); } } ;// CONCATENATED MODULE: ./src/syntax-extensions/ImageExtension.ts /** * @public */ class ImageExtension extends external_prosemirror_unified_namespaceObject.NodeExtension { dependencies() { return [new ParagraphExtension()]; } proseMirrorNodeName() { return "image"; } proseMirrorNodeSpec() { return { attrs: { alt: { default: null }, src: {}, title: { default: null }, }, draggable: true, group: "inline", inline: true, parseDOM: [ { getAttrs(dom) { return { alt: dom.getAttribute("alt"), src: dom.getAttribute("src"), title: dom.getAttribute("title"), }; }, tag: "img[src]", }, ], toDOM(node) { return ["img", node.attrs]; }, }; } proseMirrorNodeToUnistNodes(node) { return [ Object.assign(Object.assign({ type: this.unistNodeName(), url: node.attrs["src"] }, (node.attrs["alt"] !== null && { alt: node.attrs["alt"] })), (node.attrs["title"] !== null && { title: node.attrs["title"], })), ]; } unistNodeName() { return "image"; } unistNodeToProseMirrorNodes(node, proseMirrorSchema, convertedChildren) { return (0,external_prosemirror_unified_namespaceObject.createProseMirrorNode)(this.proseMirrorNodeName(), proseMirrorSchema, convertedChildren, { alt: node.alt, src: node.url, title: node.title, }); } } ;// CONCATENATED MODULE: ./src/syntax-extensions/ImageReferenceExtension.ts /** * @public */ class ImageReferenceExtension extends external_prosemirror_unified_namespaceObject.NodeExtension { dependencies() { return [new DefinitionExtension(), new ImageExtension()]; } postUnistToProseMirrorHook(context) { if (context.ImageReferenceExtension === undefined || context.DefinitionExtension === undefined) { return; } for (const id in context.ImageReferenceExtension.proseMirrorNodes) { if (!(id in context.DefinitionExtension.definitions)) { continue; } const definition = context.DefinitionExtension.definitions[id]; const attrs = context.ImageReferenceExtension.proseMirrorNodes[id] .attrs; attrs["src"] = definition.url; if (definition.title !== undefined) { attrs["title"] = definition.title; } } } proseMirrorNodeName() { return null; } proseMirrorNodeSpec() { return null; } proseMirrorNodeToUnistNodes() { return []; } unistNodeName() { return "imageReference"; } unistNodeToProseMirrorNodes(node, proseMirrorSchema, convertedChildren, context) { const proseMirrorNode = proseMirrorSchema.nodes["image"].createAndFill({ alt: node.alt, src: "", title: node.label }, convertedChildren); if (proseMirrorNode === null) { return []; } if (context.ImageReferenceExtension === undefined) { context.ImageReferenceExtension = { proseMirrorNodes: {} }; } context.ImageReferenceExtension.proseMirrorNodes[node.identifier] = proseMirrorNode; return [proseMirrorNode]; } } ;// CONCATENATED MODULE: ./src/syntax-extensions/InlineCodeExtension.ts /** * @public */ class InlineCodeExtension extends external_prosemirror_unified_namespaceObject.MarkExtension { processConvertedUnistNode(convertedNode) { return { type: this.unistNodeName(), value: convertedNode.value }; } proseMirrorInputRules(proseMirrorSchema) { return [ new external_prosemirror_unified_namespaceObject.MarkInputRule(/`([^\s](?:.*[^\s])?)`([\s\S])$/u, proseMirrorSchema.marks[this.proseMirrorMarkName()]), ]; } proseMirrorKeymap(proseMirrorSchema) { const markType = proseMirrorSchema.marks[this.proseMirrorMarkName()]; return { "Ctrl-`": (0,external_prosemirror_commands_namespaceObject.toggleMark)(markType), }; } proseMirrorMarkName() { return "code"; } proseMirrorMarkSpec() { return { inclusive: false, parseDOM: [{ tag: "code" }], toDOM() { return ["code"]; }, }; } unistNodeName() { return "inlineCode"; } unistNodeToProseMirrorNodes(node, proseMirrorSchema) { return [ proseMirrorSchema .text(node.value) .mark([proseMirrorSchema.marks[this.proseMirrorMarkName()].create()]), ]; } } ;// CONCATENATED MODULE: ./src/syntax-extensions/ItalicExtension.ts /** * @public */ class ItalicExtension extends external_prosemirror_unified_namespaceObject.MarkExtension { processConvertedUnistNode(convertedNode) { return { children: [convertedNode], type: this.unistNodeName() }; } proseMirrorInputRules(proseMirrorSchema) { return [ new external_prosemirror_unified_namespaceObject.MarkInputRule(/(?<!\*)\*([^\s*](?:.*[^\s])?)\*([^*])$/u, proseMirrorSchema.marks[this.proseMirrorMarkName()]), new external_prosemirror_unified_namespaceObject.MarkInputRule(/(?<!_)_([^\s_](?:.*[^\s])?)_([^_])$/u, proseMirrorSchema.marks[this.proseMirrorMarkName()]), ]; } proseMirrorKeymap(proseMirrorSchema) { const markType = proseMirrorSchema.marks[this.proseMirrorMarkName()]; return { "Mod-i": (0,external_prosemirror_commands_namespaceObject.toggleMark)(markType), "Mod-I": (0,external_prosemirror_commands_namespaceObject.toggleMark)(markType), }; } proseMirrorMarkName() { return "em"; } proseMirrorMarkSpec() { return { parseDOM: [ { tag: "i" }, { tag: "em" }, { getAttrs: (value) => value === "italic" && null, style: "font-style", }, ], toDOM() { return ["em"]; }, }; } unistNodeName() { return "emphasis"; } unistNodeToProseMirrorNodes(_node, proseMirrorSchema, convertedChildren) { return convertedChildren.map((child) => child.mark(child.marks.concat([ proseMirrorSchema.marks[this.proseMirrorMarkName()].create(), ]))); } } ;// CONCATENATED MODULE: ./src/syntax-extensions/LinkExtension.ts /** * @public */ class LinkExtension extends external_prosemirror_unified_namespaceObject.MarkExtension { processConvertedUnistNode(convertedNode, originalMark) { return Object.assign(Object.assign({ type: this.unistNodeName(), url: originalMark.attrs["href"] }, (originalMark.attrs["title"] !== null && { title: originalMark.attrs["title"], })), { children: [convertedNode] }); } proseMirrorMarkName() { return "link"; } proseMirrorMarkSpec() { return { attrs: { href: {}, title: { default: null } }, inclusive: false, parseDOM: [ { getAttrs(dom) { return { href: dom.getAttribute("href"), title: dom.getAttribute("title"), }; }, tag: "a[href]", }, ], toDOM(node) { return ["a", node.attrs]; }, }; } unistNodeName() { return "link"; } unistNodeToProseMirrorNodes(node, proseMirrorSchema, convertedChildren) { return convertedChildren.map((child) => child.mark(child.marks.concat([ proseMirrorSchema.marks[this.proseMirrorMarkName()].create({ href: node.url, title: node.title, }), ]))); } } ;// CONCATENATED MODULE: ./src/syntax-extensions/LinkReferenceExtension.ts /** * @public */ class LinkReferenceExtension extends external_prosemirror_unified_namespaceObject.MarkExtension { dependencies() { return [new DefinitionExtension(), new LinkExtension()]; } postUnistToProseMirrorHook(context) { if (context.LinkReferenceExtension === undefined || context.DefinitionExtension === undefined) { return; } for (const id in context.LinkReferenceExtension.marks) { if (!(id in context.DefinitionExtension.definitions)) { continue; } const definition = context.DefinitionExtension.definitions[id]; const attrs = context.LinkReferenceExtension.marks[id].attrs; attrs["href"] = definition.url; if (definition.title !== undefined) { attrs["title"] = definition.title; } } } processConvertedUnistNode(convertedNode) { return convertedNode; } proseMirrorMarkName() { return null; } proseMirrorMarkSpec() { return null; } unistNodeName() { return "linkReference"; } unistNodeToProseMirrorNodes(node, proseMirrorSchema, convertedChildren, context) { const mark = proseMirrorSchema.marks["link"].create({ href: null, title: null, }); if (context.LinkReferenceExtension === undefined) { context.LinkReferenceExtension = { marks: {} }; } context.LinkReferenceExtension.marks[node.identifier] = mark; return convertedChildren.map((child) => child.mark(child.marks.concat([mark]))); } } ;// CONCATENATED MODULE: external "prosemirror-schema-list" var external_prosemirror_schema_list_x = (y) => { var x = {}; __webpack_require__.d(x, y); return x } var external_prosemirror_schema_list_y = (x) => (() => (x)) const external_prosemirror_schema_list_namespaceObject = external_prosemirror_schema_list_x({ ["liftListItem"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_schema_list_6ac4a27c__.liftListItem), ["sinkListItem"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_schema_list_6ac4a27c__.sinkListItem), ["splitListItem"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_schema_list_6ac4a27c__.splitListItem), ["wrapInList"]: () => (__WEBPACK_EXTERNAL_MODULE_prosemirror_schema_list_6ac4a27c__.wrapInList) }); ;// CONCATENATED MODULE: ./src/syntax-extensions/ListItemExtension.ts /** * @public */ class ListItemExtension extends external_prosemirror_unified_namespaceObject.NodeExtension { proseMirrorKeymap(proseMirrorSchema) { const nodeType = proseMirrorSchema.nodes[this.proseMirrorNodeName()]; return { Enter: (0,external_prosemirror_schema_list_namespaceObject.splitListItem)(nodeType), "Shift-Tab": (0,external_prosemirror_schema_list_namespaceObject.liftListItem)(nodeType), Tab: (0,external_prosemirror_schema_list_namespaceObject.sinkListItem)(nodeType), }; } proseMirrorNodeName() { return "regular_list_item"; } proseMirrorNodeSpec() { return { content: "paragraph block*", defining: true, group: "list_item", parseDOM: [{ tag: "li" }], toDOM() { return ["li", 0]; }, }; } proseMirrorNodeToUnistNodes(_node, convertedChildren) { return [ { children: convertedChildren, type: this.unistNodeName(), }, ]; } unistNodeName() { return "listItem"; } unistNodeToProseMirrorNodes(_node, proseMirrorSchema, convertedChildren) { return (0,external_prosemirror_unified_namespaceObject.createProseMirrorNode)(this.proseMirrorNodeName(), proseMirrorSchema, convertedChildren); } unistToProseMirrorTest(node) { return (node.type === this.unistNodeName() && (!("checked" in node) || typeof node.checked !== "boolean")); } } ;// CONCATENATED MODULE: ./src/syntax-extensions/OrderedListExtension.ts /** * @public */ class OrderedListExtension extends external_prosemirror_unified_namespaceObject.NodeExtension { dependencies() { return [new ListItemExtension()]; } proseMirrorInputRules(proseMirrorSchema) { return [ (0,external_prosemirror_inputrules_namespaceObject.wrappingInputRule)(/^\s{0,3}(\d+)\.\s$/u, proseMirrorSchema.nodes[this.proseMirrorNodeName()], (match) => ({ start: +match[1] }), (match, node) => node.childCount + node.attrs["start"] === +match[1]), ]; } proseMirrorKeymap(proseMirrorSchema) { return { "Shift-Mod-9": (0,external_prosemirror_schema_list_namespaceObject.wrapInList)(proseMirrorSchema.nodes[this.proseMirrorNodeName()]), }; } proseMirrorNodeName() { return "ordered_list"; } proseMirrorNodeSpec() { return { attrs: { spread: { default: false }, start: { default: 1 } }, content: "list_item+", group: "block", parseDOM: [ { getAttrs(dom) { const start = dom.getAttribute("start"); return { spread: dom.getAttribute("data-spread") === "true", start: start !== null ? parseInt(start, 10) : 1, }; }, tag: "ol", }, ], toDOM(node) { return [ "ol", { "data-spread": node.attrs["spread"], start: node.attrs["start"], }, 0, ]; }, }; } proseMirrorNodeToUnistNodes(node, convertedChildren) { const spread = node.attrs["spread"]; return [ { children: convertedChildren.map((child) => { child.spread = spread; return child; }), ordered: true, spread, start: node.attrs["start"], type: this.unistNodeName(), }, ]; } unistNodeName() { return "list"; } unistNodeToProseMirrorNodes(node, proseMirrorSchema, convertedChildren) { var _a; return (0,external_prosemirror_unified_namespaceObject.createProseMirrorNode)(this.proseMirrorNodeName(), proseMirrorSchema, convertedChildren, { spread: node.spread, start: (_a = node.start) !== null && _a !== void 0 ? _a : 1, }); } unistToProseMirrorTest(node) { return (node.type === this.unistNodeName() && node.ordered === true); } } ;// CONCATENATED MODULE: ./src/syntax-extensions/RootExtension.ts /** * @public */ class RootExtension extends external_prosemirror_unified_namespaceObject.NodeExtension { proseMirrorNodeName() { return "doc"; } proseMirrorNodeSpec() { return { content: "block+" }; } proseMirrorNodeToUnistNodes(_node, convertedChildren) { return [{ children: convertedChildren, type: this.unistNodeName() }]; } unistNodeName() { return "root"; } unistNodeToProseMirrorNodes(_node, proseMirrorSchema, convertedChildren) { return (0,external_prosemirror_unified_namespaceObject.createProseMirrorNode)(this.proseMirrorNodeName(), proseMirrorSchema, convertedChildren); } } ;// CONCATENATED MODULE: ./src/syntax-extensions/UnorderedListExtension.ts /** * @public */ class UnorderedListExtension extends external_prosemirror_unified_namespaceObject.NodeExtension { dependencies() { return [new ListItemExtension()]; } proseMirrorInputRules(proseMirrorSchema) { return [ (0,external_prosemirror_inputrules_namespaceObject.wrappingInputRule)(/^\s{0,3}([-+*])\s$/u, proseMirrorSchema.nodes[this.proseMirrorNodeName()]), ]; } proseMirrorKeymap(proseMirrorSchema) { return { "Shift-Mod-8": (0,external_prosemirror_schema_list_namespaceObject.wrapInList)(proseMirrorSchema.nodes[this.proseMirrorNodeName()]), }; } proseMirrorNodeName() { return "bullet_list"; } proseMirrorNodeSpec() { return { attrs: { spread: { default: false } }, content: "list_item+", group: "block", parseDOM: [ { getAttrs(dom) { return { spread: dom.getAttribute("data-spread") === "true", }; }, tag: "ul", }, ], toDOM(node) { return ["ul", { "data-spread": node.attrs["spread"] }, 0]; }, }; } proseMirrorNodeToUnistNodes(node, convertedChildren) { const spread = node.attrs["spread"]; return [ { children: convertedChildren.map((child) => { child.spread = spread; return child; }), ordered: false, spread, type: this.unistNodeName(), }, ]; } unistNodeName() { return "list"; } unistNodeToProseMirrorNodes(node, proseMirrorSchema, convertedChildren) { return (0,external_prosemirror_unified_namespaceObject.createProseMirrorNode)(this.proseMirrorNodeName(), proseMirrorSchema, convertedChildren, { spread: node.spread, }); } unistToProseMirrorTest(node) { return (node.type === this.unistNodeName() && node.ordered !== true); } } ;// CONCATENATED MODULE: ./src/MarkdownExtension.ts /** * @public */ class MarkdownExtension extends external_prosemirror_unified_namespaceObject.Extension { dependencies() { return [ // ParagraphExtension needs to be first so that it is the default block. new ParagraphExtension(), new BlockquoteExtension(), new BoldExtension(), new BreakExtension(), new CodeBlockExtension(), new DefinitionExtension(), new HeadingExtension(), new HorizontalRuleExtension(), new ImageExtension(), new ImageReferenceExtension(), new InlineCodeExtension(), new ItalicExtension(), new LinkExtension(), new LinkReferenceExtension(), new ListItemExtension(), new OrderedListExtension(), new RootExtension(), new TextExtension(), new UnorderedListExtension(), ]; } unifiedInitializationHook(processor) { return processor.use(external_remark_parse_namespaceObject["default"]).use(external_remark_stringify_namespaceObject["default"], { fences: true, listItemIndent: "one", resourceLink: true, rule: "-", }); } } ;// CONCATENATED MODULE: ./node_modules/ccount/index.js /** * Count how often a character (or substring) is used in a string. * * @param {string} value * Value to search in. * @param {string} character * Character (or substring) to look for. * @return {number} * Number of times `character` occurred in `value`. */ function ccount(value, character) { const source = String(value) if (typeof character !== 'string') { throw new TypeError('Expected character') } let count = 0 let index = source.indexOf(character) while (index !== -1) { count++ index = source.indexOf(character, index + character.length) } return count } ;// CONCATENATED MODULE: ./node_modules/devlop/lib/default.js function deprecate(fn) { return fn } function equal() {} function ok() {} function unreachable() {} ;// CONCATENATED MODULE: ./node_modules/micromark-util-character/index.js /** * @typedef {import('micromark-util-types').Code} Code */ /** * Check whether the character code represents an ASCII alpha (`a` through `z`, * case insensitive). * * An **ASCII alpha** is an ASCII upper alpha or ASCII lower alpha. * * An **ASCII upper alpha** is a character in the inclusive range U+0041 (`A`) * to U+005A (`Z`). * * An **ASCII lower alpha** is a character in the inclusive range U+0061 (`a`) * to U+007A (`z`). * * @param code * Code. * @returns {boolean} * Whether it matches. */ const asciiAlpha = regexCheck(/[A-Za-z]/); /** * Check whether the character code represents an ASCII alphanumeric (`a` * through `z`, case insensitive, or `0` through `9`). * * An **ASCII alphanumeric** is an ASCII digit (see `asciiDigit`) or ASCII alpha * (see `asciiAlpha`). * * @param code * Code. * @returns {boolean} * Whether it matches. */ const asciiAlphanumeric = regexCheck(/[\dA-Za-z]/); /** * Check whether the character code represents an ASCII atext. * * atext is an ASCII alphanumeric (see `asciiAlphanumeric`), or a character in * the inclusive ranges U+0023 NUMBER SIGN (`#`) to U+0027 APOSTROPHE (`'`), * U+002A ASTERISK (`*`), U+002B PLUS SIGN (`+`), U+002D DASH (`-`), U+002F * SLASH (`/`), U+003D EQUALS TO (`=`), U+003F QUESTION MARK (`?`), U+005E * CARET (`^`) to U+0060 GRAVE ACCENT (`` ` ``), or U+007B LEFT CURLY BRACE * (`{`) to U+007E TILDE (`~`). * * See: * **\[RFC5322]**: * [Internet Message Format](https://tools.ietf.org/html/rfc5322). * P. Resnick. * IETF. * * @param code * Code. * @returns {boolean} * Whether it matches. */ const asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/); /** * Check whether a character code is an ASCII control character. * * An **ASCII control** is a character in the inclusive range U+0000 NULL (NUL) * to U+001F (US), or U+007F (DEL). * * @param {Code} code * Code. * @returns {boolean} * Whether it matches. */ function asciiControl(code) { return ( // Special whitespace codes (which have negative values), C0 and Control // character DEL code !== null && (code < 32 || code === 127) ); } /** * Check whether the character code represents an ASCII digit (`0` through `9`). * * An **ASCII digit** is a character in the inclusive range U+0030 (`0`) to * U+0039 (`9`). * * @param code * Code. * @returns {boolean} * Whether it matches. */ const asciiDigit = regexCheck(/\d/); /** * Check whether the character code represents an ASCII hex digit (`a` through * `f`, case insensitive, or `0` through `9`). * * An **ASCII hex digit** is an ASCII digit (see `asciiDigit`), ASCII upper hex * digit, or an ASCII lower hex digit. * * An **ASCII upper hex digit** is a character in the inclusive range U+0041 * (`A`) to U+0046 (`F`). * * An **ASCII lower hex digit** is a character in the inclusive range U+0061 * (`a`) to U+0066 (`f`). * * @param code * Code. * @returns {boolean} * Whether it matches. */ const asciiHexDigit = regexCheck(/[\dA-Fa-f]/); /** * Check whether the character code represents ASCII punctuation. * * An **ASCII punctuation** is a character in the inclusive ranges U+0021 * EXCLAMATION MARK (`!`) to U+002F SLASH (`/`), U+003A COLON (`:`) to U+0040 AT * SIGN (`@`), U+005B LEFT SQUARE BRACKET (`[`) to U+0060 GRAVE ACCENT * (`` ` ``), or U+007B LEFT CURLY BRACE (`{`) to U+007E TILDE (`~`). * * @param code * Code. * @returns {boolean} * Whether it matches. */ const asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/); /** * Check whether a character code is a markdown line ending. * * A **markdown line ending** is the virtual characters M-0003 CARRIAGE RETURN * LINE FEED (CRLF), M-0004 LINE FEED (LF) and M-0005 CARRIAGE RETURN (CR). * * In micromark, the actual character U+000A LINE FEED (LF) and U+000D CARRIAGE * RETURN (CR) are replaced by these virtual characters depending on whether * they occurred together. * * @param {Code} code * Code. * @returns {boolean} * Whether it matches. */ function markdownLineEnding(code) { return code !== null && code < -2; } /** * Check whether a character code is a markdown line ending (see * `markdownLineEnding`) or markdown space (see `markdownSpace`). * * @param {Code} code * Code. * @returns {boolean} * Whether it matches. */ function markdownLineEndingOrSpace(code) { return code !== null && (code < 0 || code === 32); } /** * Check whether a character code is a markdown space. * * A **markdown space** is the concrete character U+0020 SPACE (SP) and the * virtual characters M-0001 VIRTUAL SPACE (VS) and M-0002 HORIZONTAL TAB (HT). * * In micromark, the actual character U+0009 CHARACTER TABULATION (HT) is * replaced by one M-0002 HORIZONTAL TAB (HT) and between 0 and 3 M-0001 VIRTUAL * SPACE (VS) characters, depending on the column at which the tab occurred. * * @param {Code} code * Code. * @returns {boolean} * Whether it matches. */ function markdownSpace(code) { return code === -2 || code === -1 || code === 32; } // Size note: removing ASCII from the regex and using `asciiPunctuation` here // In fact adds to the bundle size. /** * Check whether the character code represents Unicode punctuation. * * A **Unicode punctuation** is a character in the Unicode `Pc` (Punctuation, * Connector), `Pd` (Punctuation, Dash), `Pe` (Punctuation, Close), `Pf` * (Punctuation, Final quote), `Pi` (Punctuation, Initial quote), `Po` * (Punctuation, Other), or `Ps` (Punctuation, Open) categories, or an ASCII * punctuation (see `asciiPunctuation`). * * See: * **\[UNICODE]**: * [The Unicode Standard](https://www.unicode.org/versions/). * Unicode Consortium. * * @param code * Code. * @returns * Whether it matches. */ const unicodePunctuation = regexCheck(/\p{P}|\p{S}/u); /** * Check whether the character code represents Unicode whitespace. * * Note that this does handle micromark specific markdown whitespace characters. * See `markdownLineEndingOrSpace` to check that. * * A **Unicode whitespace** is a character in the Unicode `Zs` (Separator, * Space) category, or U+0009 CHARACTER TABULATION (HT), U+000A LINE FEED (LF), * U+000C (FF), or U+000D CARRIAGE RETURN (CR) (**\[UNICODE]**). * * See: * **\[UNICODE]**: * [The Unicode Standard](https://www.unicode.org/versions/). * Unicode Consortium. * * @param code * Code. * @returns * Whether it matches. */ const unicodeWhitespace = regexCheck(/\s/); /** * Create a code check from a regex. * * @param {RegExp} regex * @returns {(code: Code) => boolean} */ function regexCheck(regex) { return check; /** * Check whether a code matches the bound regex. * * @param {Code} code * Character code. * @returns {boolean} * Whether the character code matches the bound regex. */ function check(code) { return code !== null && code > -1 && regex.test(String.fromCharCode(code)); } } ;// CONCATENATED MODULE: ./node_module