@milkdown/preset-commonmark 5.3.5 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.es.js +54 -20
- package/lib/index.es.js.map +1 -1
- package/lib/src/node/code-fence.d.ts.map +1 -1
- package/lib/src/node/heading.d.ts.map +1 -1
- package/package.json +11 -5
- package/src/node/code-fence.ts +3 -0
- package/src/node/heading.ts +67 -23
package/lib/index.es.js
CHANGED
|
@@ -18,7 +18,7 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import { createMark, createShortcut, createNode, createPlugin, AtomList } from "@milkdown/utils";
|
|
21
|
-
import { createCmdKey, createCmd, schemaCtx, themeToolCtx } from "@milkdown/core";
|
|
21
|
+
import { createCmdKey, createCmd, schemaCtx, themeToolCtx, editorViewCtx } from "@milkdown/core";
|
|
22
22
|
import { markRule, toggleMark, TextSelection, InputRule, wrappingInputRule, wrapIn, textblockTypeInputRule, setBlockType, Plugin, PluginKey, ReplaceStep, AddMarkStep, Selection, findSelectedNodeOfType, splitListItem, sinkListItem, liftListItem } from "@milkdown/prose";
|
|
23
23
|
import links from "remark-inline-links";
|
|
24
24
|
const SupportedKeys = {
|
|
@@ -456,6 +456,9 @@ const codeFence = createNode((utils, options) => {
|
|
|
456
456
|
pre {
|
|
457
457
|
font-family: ${font.code};
|
|
458
458
|
margin: 0 1.2rem !important;
|
|
459
|
+
white-space: pre;
|
|
460
|
+
overflow: auto;
|
|
461
|
+
${scrollbar("x")};
|
|
459
462
|
}
|
|
460
463
|
`;
|
|
461
464
|
});
|
|
@@ -809,27 +812,58 @@ const heading = createNode((utils) => {
|
|
|
809
812
|
[SupportedKeys.H5]: createShortcut(TurnIntoHeading, "Mod-Alt-5", 5),
|
|
810
813
|
[SupportedKeys.H6]: createShortcut(TurnIntoHeading, "Mod-Alt-6", 6)
|
|
811
814
|
},
|
|
812
|
-
prosePlugins: (type) =>
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
815
|
+
prosePlugins: (type, ctx) => {
|
|
816
|
+
let lock = false;
|
|
817
|
+
const createId = (node) => {
|
|
818
|
+
return node.textContent.replace(/[\p{P}\p{S}]/gu, "").replace(/\s/g, "").trim();
|
|
819
|
+
};
|
|
820
|
+
const walkThrough = (state, callback) => {
|
|
821
|
+
const tr = state.tr;
|
|
822
|
+
state.doc.descendants((node, pos) => {
|
|
823
|
+
if (node.type === type && !lock) {
|
|
824
|
+
if (node.textContent.trim().length === 0) {
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
const attrs = node.attrs;
|
|
828
|
+
const id22 = createId(node);
|
|
829
|
+
if (attrs.id !== id22) {
|
|
830
|
+
tr.setNodeMarkup(pos, void 0, __spreadProps(__spreadValues({}, attrs), {
|
|
831
|
+
id: id22
|
|
832
|
+
}));
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
});
|
|
836
|
+
callback(tr);
|
|
837
|
+
};
|
|
838
|
+
return [
|
|
839
|
+
new Plugin({
|
|
840
|
+
key: headingPluginKey,
|
|
841
|
+
props: {
|
|
842
|
+
handleDOMEvents: {
|
|
843
|
+
compositionstart: () => {
|
|
844
|
+
lock = true;
|
|
845
|
+
return false;
|
|
846
|
+
},
|
|
847
|
+
compositionend: () => {
|
|
848
|
+
lock = false;
|
|
849
|
+
const view = ctx.get(editorViewCtx);
|
|
850
|
+
walkThrough(view.state, (tr) => view.dispatch(tr));
|
|
851
|
+
return false;
|
|
826
852
|
}
|
|
827
|
-
}
|
|
853
|
+
}
|
|
854
|
+
},
|
|
855
|
+
appendTransaction: (transactions, _, nextState) => {
|
|
856
|
+
let tr = null;
|
|
857
|
+
if (transactions.some((transaction) => transaction.docChanged)) {
|
|
858
|
+
walkThrough(nextState, (t) => {
|
|
859
|
+
tr = t;
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
return tr;
|
|
828
863
|
}
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
]
|
|
864
|
+
})
|
|
865
|
+
];
|
|
866
|
+
}
|
|
833
867
|
};
|
|
834
868
|
});
|
|
835
869
|
const id$4 = "hr";
|
package/lib/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/supported-keys.ts","../src/mark/code-inline.ts","../src/mark/em.ts","../src/mark/link.ts","../src/mark/strong.ts","../src/mark/index.ts","../src/node/blockquote.ts","../src/node/bullet-list.ts","../src/node/code-fence.ts","../src/node/doc.ts","../src/node/hardbreak.ts","../src/node/heading.ts","../src/node/hr.ts","../src/node/image.ts","../src/node/list-item.ts","../src/node/ordered-list.ts","../src/node/paragraph.ts","../src/node/text.ts","../src/node/index.ts","../src/plugin/filter-html.ts","../src/plugin/index.ts","../src/index.ts"],"sourcesContent":["/* Copyright 2021, Milkdown by Mirone. */\nexport const SupportedKeys = {\n HardBreak: 'HardBreak',\n Blockquote: 'Blockquote',\n BulletList: 'BulletList',\n OrderedList: 'OrderedList',\n CodeFence: 'CodeFence',\n H1: 'H1',\n H2: 'H2',\n H3: 'H3',\n H4: 'H4',\n H5: 'H5',\n H6: 'H6',\n Text: 'Text',\n CodeInline: 'CodeInline',\n Em: 'Em',\n Bold: 'Bold',\n NextListItem: 'NextListItem',\n SinkListItem: 'SinkListItem',\n LiftListItem: 'LiftListItem',\n} as const;\n\nexport type SupportedKeys = typeof SupportedKeys;\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { markRule, toggleMark } from '@milkdown/prose';\nimport { createMark, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['CodeInline'];\nconst id = 'code_inline';\n\nexport const ToggleInlineCode = createCmdKey();\n\nexport const codeInline = createMark<Keys>((utils) => {\n const style = utils.getStyle(\n ({ palette, size, font }, { css }) =>\n css`\n background-color: ${palette('neutral')};\n color: ${palette('background')};\n border-radius: ${size.radius};\n font-weight: 500;\n font-family: ${font.code};\n padding: 0 0.2rem;\n `,\n );\n return {\n id,\n schema: () => ({\n priority: 100,\n code: true,\n inclusive: false,\n parseDOM: [{ tag: 'code' }],\n toDOM: (mark) => ['code', { class: utils.getClassName(mark.attrs, 'code-inline', style) }],\n parseMarkdown: {\n match: (node) => node.type === 'inlineCode',\n runner: (state, node, markType) => {\n state.openMark(markType);\n state.addText(node.value as string);\n state.closeMark(markType);\n },\n },\n toMarkdown: {\n match: (mark) => mark.type.name === id,\n runner: (state, mark, node) => {\n state.withMark(mark, 'inlineCode', node.text || '');\n },\n },\n }),\n inputRules: (markType) => [markRule(/(?:^|[^`])(`([^`]+)`)$/, markType)],\n commands: (markType) => [createCmd(ToggleInlineCode, () => toggleMark(markType))],\n shortcuts: {\n [SupportedKeys.CodeInline]: createShortcut(ToggleInlineCode, 'Mod-e'),\n },\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { markRule, toggleMark } from '@milkdown/prose';\nimport { createMark, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['Em'];\n\nconst id = 'em';\n\nexport const ToggleItalic = createCmdKey();\n\nexport const em = createMark<Keys>((utils) => ({\n id,\n schema: () => ({\n parseDOM: [\n { tag: 'i' },\n { tag: 'em' },\n { style: 'font-style', getAttrs: (value) => (value === 'italic') as false },\n ],\n toDOM: (mark) => ['em', { class: utils.getClassName(mark.attrs, id) }],\n parseMarkdown: {\n match: (node) => node.type === 'emphasis',\n runner: (state, node, markType) => {\n state.openMark(markType);\n state.next(node.children);\n state.closeMark(markType);\n },\n },\n toMarkdown: {\n match: (mark) => mark.type.name === id,\n runner: (state, mark) => {\n state.withMark(mark, 'emphasis');\n },\n },\n }),\n inputRules: (markType) => [\n markRule(/(?:^|[^_])(_([^_]+)_)$/, markType),\n markRule(/(?:^|[^*])(\\*([^*]+)\\*)$/, markType),\n ],\n commands: (markType) => [createCmd(ToggleItalic, () => toggleMark(markType))],\n shortcuts: {\n [SupportedKeys.Em]: createShortcut(ToggleItalic, 'Mod-i'),\n },\n}));\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey, schemaCtx } from '@milkdown/core';\nimport { InputRule, Node as ProseNode, TextSelection, toggleMark } from '@milkdown/prose';\nimport { createMark } from '@milkdown/utils';\n\nexport const ToggleLink = createCmdKey<string>();\nexport const ModifyLink = createCmdKey<string>();\nconst id = 'link';\nexport const link = createMark((utils) => {\n const style = utils.getStyle((themeTool, { css }) => {\n const lineColor = themeTool.palette('line');\n\n return css`\n color: ${themeTool.palette('secondary')};\n cursor: pointer;\n transition: all 0.4s ease-in-out;\n font-weight: 500;\n &:hover {\n background-color: ${lineColor};\n box-shadow: 0 0.2rem ${lineColor}, 0 -0.2rem ${lineColor};\n }\n `;\n });\n return {\n id,\n schema: () => ({\n attrs: {\n href: {},\n title: { default: null },\n },\n inclusive: false,\n parseDOM: [\n {\n tag: 'a[href]',\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) {\n throw new Error();\n }\n return { href: dom.getAttribute('href'), title: dom.getAttribute('title') };\n },\n },\n ],\n toDOM: (mark) => ['a', { ...mark.attrs, class: utils.getClassName(mark.attrs, id, style) }],\n parseMarkdown: {\n match: (node) => node.type === 'link',\n runner: (state, node, markType) => {\n const url = node.url as string;\n const title = node.title as string;\n state.openMark(markType, { href: url, title });\n state.next(node.children);\n state.closeMark(markType);\n },\n },\n toMarkdown: {\n match: (mark) => mark.type.name === id,\n runner: (state, mark) => {\n state.withMark(mark, 'link', undefined, {\n title: mark.attrs.title,\n url: mark.attrs.href,\n });\n },\n },\n }),\n commands: (markType) => [\n createCmd(ToggleLink, (href = '') => toggleMark(markType, { href })),\n createCmd(ModifyLink, (href = '') => (state, dispatch) => {\n if (!dispatch) return false;\n\n const { marks } = state.schema;\n\n let node: ProseNode | undefined;\n let pos = -1;\n const { selection } = state;\n state.doc.nodesBetween(selection.from, selection.to, (n, p) => {\n if (marks.link.isInSet(n.marks)) {\n node = n;\n pos = p;\n return false;\n }\n return;\n });\n if (!node) return false;\n\n const mark = node.marks.find(({ type }) => type === markType);\n if (!mark) return false;\n\n const start = pos;\n const end = pos + node.nodeSize;\n const { tr } = state;\n const linkMark = marks.link.create({ ...mark.attrs, href });\n dispatch(\n tr\n .removeMark(start, end, mark)\n .addMark(start, end, linkMark)\n .setSelection(new TextSelection(tr.selection.$anchor))\n .scrollIntoView(),\n );\n\n return true;\n }),\n ],\n inputRules: (markType, ctx) => [\n new InputRule(/\\[(?<text>.*?)]\\((?<href>.*?)(?=“|\\))\"?(?<title>[^\"]+)?\"?\\)/, (state, match, start, end) => {\n const [okay, text = '', href, title] = match;\n const { tr } = state;\n if (okay) {\n const content = text || 'link';\n tr.replaceWith(start, end, ctx.get(schemaCtx).text(content)).addMark(\n start,\n content.length + start,\n markType.create({ title, href }),\n );\n }\n\n return tr;\n }),\n ],\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { markRule, toggleMark } from '@milkdown/prose';\nimport { createMark, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['Bold'];\nconst id = 'strong';\nexport const ToggleBold = createCmdKey();\nexport const strong = createMark<Keys>((utils) => {\n const style = utils.getStyle(\n (_, { css }) =>\n css`\n font-weight: 600;\n `,\n );\n return {\n id,\n schema: () => ({\n parseDOM: [\n { tag: 'b' },\n { tag: 'strong' },\n { style: 'font-style', getAttrs: (value) => (value === 'bold') as false },\n ],\n toDOM: (mark) => ['strong', { class: utils.getClassName(mark.attrs, id, style) }],\n parseMarkdown: {\n match: (node) => node.type === 'strong',\n runner: (state, node, markType) => {\n state.openMark(markType);\n state.next(node.children);\n state.closeMark(markType);\n },\n },\n toMarkdown: {\n match: (mark) => mark.type.name === id,\n runner: (state, mark) => {\n state.withMark(mark, 'strong');\n },\n },\n }),\n inputRules: (markType) => [\n markRule(/(?:__)([^_]+)(?:__)$/, markType),\n markRule(/(?:\\*\\*)([^*]+)(?:\\*\\*)$/, markType),\n ],\n commands: (markType) => [createCmd(ToggleBold, () => toggleMark(markType))],\n shortcuts: {\n [SupportedKeys.Bold]: createShortcut(ToggleBold, 'Mod-b'),\n },\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { codeInline } from './code-inline';\nimport { em } from './em';\nimport { link } from './link';\nimport { strong } from './strong';\n\nexport const marks = [codeInline(), em(), strong(), link()];\n\nexport * from './code-inline';\nexport * from './em';\nexport * from './link';\nexport * from './strong';\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { wrapIn, wrappingInputRule } from '@milkdown/prose';\nimport { createNode, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['Blockquote'];\n\nconst id = 'blockquote';\n\nexport const WrapInBlockquote = createCmdKey();\n\nexport const blockquote = createNode<Keys>((utils) => {\n const style = utils.getStyle(\n (themeTool, { css }) =>\n css`\n padding-left: 1.875rem;\n line-height: 1.75rem;\n border-left: 4px solid ${themeTool.palette('primary')};\n * {\n font-size: 1rem;\n line-height: 1.5rem;\n }\n `,\n );\n\n return {\n id,\n schema: () => ({\n content: 'block+',\n group: 'block',\n defining: true,\n parseDOM: [{ tag: 'blockquote' }],\n toDOM: (node) => ['blockquote', { class: utils.getClassName(node.attrs, id, style) }, 0],\n parseMarkdown: {\n match: ({ type }) => type === id,\n runner: (state, node, type) => {\n state.openNode(type).next(node.children).closeNode();\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === id,\n runner: (state, node) => {\n state.openNode('blockquote').next(node.content).closeNode();\n },\n },\n }),\n inputRules: (nodeType) => [wrappingInputRule(/^\\s*>\\s$/, nodeType)],\n commands: (nodeType) => [createCmd(WrapInBlockquote, () => wrapIn(nodeType))],\n shortcuts: {\n [SupportedKeys.Blockquote]: createShortcut(WrapInBlockquote, 'Mod-Shift-b'),\n },\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { wrapIn, wrappingInputRule } from '@milkdown/prose';\nimport { createNode, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['BulletList'];\n\nexport const WrapInBulletList = createCmdKey();\n\nexport const bulletList = createNode<Keys>((utils) => {\n const id = 'bullet_list';\n return {\n id,\n schema: () => ({\n content: 'listItem+',\n group: 'block',\n parseDOM: [{ tag: 'ul' }],\n toDOM: (node) => {\n return ['ul', { class: utils.getClassName(node.attrs, 'bullet-list') }, 0];\n },\n parseMarkdown: {\n match: ({ type, ordered }) => type === 'list' && !ordered,\n runner: (state, node, type) => {\n state.openNode(type).next(node.children).closeNode();\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === id,\n runner: (state, node) => {\n state.openNode('list', undefined, { ordered: false }).next(node.content).closeNode();\n },\n },\n }),\n inputRules: (nodeType) => [wrappingInputRule(/^\\s*([-+*])\\s$/, nodeType)],\n commands: (nodeType) => [createCmd(WrapInBulletList, () => wrapIn(nodeType))],\n shortcuts: {\n [SupportedKeys.BulletList]: createShortcut(WrapInBulletList, 'Mod-Alt-8'),\n },\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey, themeToolCtx } from '@milkdown/core';\nimport { setBlockType, textblockTypeInputRule } from '@milkdown/prose';\nimport { createNode, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['CodeFence'];\n\nconst languageOptions = [\n '',\n 'javascript',\n 'typescript',\n 'bash',\n 'sql',\n 'json',\n 'html',\n 'css',\n 'c',\n 'cpp',\n 'java',\n 'ruby',\n 'python',\n 'go',\n 'rust',\n 'markdown',\n];\n\nexport const backtickInputRegex = /^```(?<language>[a-z]*)?[\\s\\n]$/;\nexport const tildeInputRegex = /^~~~(?<language>[a-z]*)?[\\s\\n]$/;\n\nexport const TurnIntoCodeFence = createCmdKey();\n\nconst id = 'fence';\nexport const codeFence = createNode<Keys, { languageList?: string[] }>((utils, options) => {\n const style = utils.getStyle(({ palette, mixin, size, font }, { css }) => {\n const { shadow, scrollbar, border } = mixin;\n const { lineWidth, radius } = size;\n return css`\n background-color: ${palette('background')};\n color: ${palette('neutral')};\n font-size: 0.85rem;\n padding: 1.2rem 0.4rem 1.4rem;\n border-radius: ${radius};\n font-family: ${font.typography};\n\n * {\n margin: 0;\n }\n\n .code-fence_select-wrapper {\n position: relative;\n }\n\n .code-fence_value {\n width: 10.25rem;\n box-sizing: border-box;\n border-radius: ${size.radius};\n margin: 0 1.2rem 1.2rem;\n ${border()};\n ${shadow()};\n cursor: pointer;\n background-color: ${palette('surface')};\n position: relative;\n display: flex;\n color: ${palette('neutral', 0.87)};\n letter-spacing: 0.5px;\n height: 2.625rem;\n align-items: center;\n\n & > .icon {\n width: 2.625rem;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n color: ${palette('solid', 0.87)};\n border-left: ${lineWidth} solid ${palette('line')};\n\n text-align: center;\n transition: all 0.2s ease-in-out;\n &:hover {\n background: ${palette('background')};\n color: ${palette('primary')};\n }\n }\n\n > span:first-child {\n padding-left: 1rem;\n flex: 1;\n font-weight: 500;\n }\n }\n\n .code-fence_select-option {\n list-style: none;\n line-height: 2rem;\n padding-left: 1rem;\n cursor: pointer;\n :hover {\n background: ${palette('secondary', 0.12)};\n color: ${palette('primary')};\n }\n }\n\n .code-fence_select {\n &[data-fold='true'] {\n display: none;\n }\n\n font-weight: 500;\n position: absolute;\n z-index: 1;\n top: 2.625rem;\n box-sizing: border-box;\n left: 1.2rem;\n padding: 0.5rem 0;\n max-height: 16.75rem;\n width: 10.25rem;\n ${border()};\n ${shadow()};\n background-color: ${palette('surface')};\n border-top: none;\n overflow-y: auto;\n display: flex;\n flex-direction: column;\n\n ${scrollbar('y')}\n }\n\n code {\n line-height: 1.5;\n font-family: ${font.code};\n }\n\n pre {\n font-family: ${font.code};\n margin: 0 1.2rem !important;\n }\n `;\n });\n\n return {\n id,\n schema: () => ({\n content: 'text*',\n group: 'block',\n marks: '',\n defining: true,\n code: true,\n attrs: {\n language: {\n default: '',\n },\n fold: {\n default: true,\n },\n },\n parseDOM: [\n {\n tag: 'pre',\n preserveWhitespace: 'full',\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) {\n throw new Error('Parse DOM error.');\n }\n return { language: dom.dataset.language };\n },\n },\n ],\n toDOM: (node) => {\n return [\n 'pre',\n {\n 'data-language': node.attrs.language,\n class: utils.getClassName(node.attrs, 'code-fence', style),\n },\n ['code', { spellCheck: 'false' }, 0],\n ];\n },\n parseMarkdown: {\n match: ({ type }) => type === 'code',\n runner: (state, node, type) => {\n const language = node.lang as string;\n const value = node.value as string;\n state.openNode(type, { language });\n if (value) {\n state.addText(value);\n }\n state.closeNode();\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === id,\n runner: (state, node) => {\n state.addNode('code', undefined, node.content.firstChild?.text || '', {\n lang: node.attrs.language,\n });\n },\n },\n }),\n inputRules: (nodeType) => [\n textblockTypeInputRule(backtickInputRegex, nodeType, (match) => {\n const [ok, language] = match;\n if (!ok) return;\n return { language };\n }),\n textblockTypeInputRule(tildeInputRegex, nodeType, (match) => {\n const [ok, language] = match;\n if (!ok) return;\n return { language };\n }),\n ],\n commands: (nodeType) => [createCmd(TurnIntoCodeFence, () => setBlockType(nodeType))],\n shortcuts: {\n [SupportedKeys.CodeFence]: createShortcut(TurnIntoCodeFence, 'Mod-Alt-c'),\n },\n view: (ctx) => (node, view, getPos) => {\n const container = document.createElement('div');\n const selectWrapper = document.createElement('div');\n const select = document.createElement('ul');\n const pre = document.createElement('pre');\n const code = document.createElement('code');\n\n const valueWrapper = document.createElement('div');\n valueWrapper.className = 'code-fence_value';\n const value = document.createElement('span');\n valueWrapper.appendChild(value);\n if (view.editable) {\n valueWrapper.appendChild(ctx.get(themeToolCtx).slots.icon('downArrow'));\n }\n\n select.className = 'code-fence_select';\n select.addEventListener('mousedown', (e) => {\n e.preventDefault();\n e.stopPropagation();\n\n if (!view.editable) return;\n\n const el = e.target;\n if (!(el instanceof HTMLLIElement)) return;\n const { tr } = view.state;\n\n view.dispatch(\n tr.setNodeMarkup(getPos(), undefined, {\n fold: true,\n language: el.dataset.value,\n }),\n );\n });\n valueWrapper.addEventListener('mousedown', (e) => {\n e.preventDefault();\n e.stopPropagation();\n\n if (!view.editable) return;\n const { tr } = view.state;\n\n view.dispatch(\n tr.setNodeMarkup(getPos(), undefined, {\n fold: false,\n language: container.dataset.language,\n }),\n );\n });\n document.addEventListener('mousedown', () => {\n if (!view.editable || select.dataset.fold === 'true') return;\n\n const { tr } = view.state;\n\n view.dispatch(\n tr.setNodeMarkup(getPos(), undefined, {\n fold: true,\n language: container.dataset.language,\n }),\n );\n });\n\n (options?.languageList || languageOptions).forEach((lang) => {\n const option = document.createElement('li');\n option.className = 'code-fence_select-option';\n option.innerText = lang || '--';\n select.appendChild(option);\n option.setAttribute('data-value', lang);\n });\n\n code.spellcheck = false;\n selectWrapper.className = 'code-fence_select-wrapper';\n selectWrapper.contentEditable = 'false';\n selectWrapper.append(valueWrapper);\n selectWrapper.append(select);\n pre.append(code);\n const codeContent = document.createElement('div');\n code.append(codeContent);\n codeContent.style.whiteSpace = 'inherit';\n\n container.append(selectWrapper, pre);\n container.setAttribute('class', utils.getClassName(node.attrs, 'code-fence', style));\n container.setAttribute('data-language', node.attrs.language);\n value.innerText = node.attrs.language || '--';\n select.setAttribute('data-fold', node.attrs.fold ? 'true' : 'false');\n\n return {\n dom: container,\n contentDOM: codeContent,\n update: (updatedNode) => {\n if (updatedNode.type.name !== id) return false;\n\n const lang = updatedNode.attrs.language;\n container.dataset.language = lang;\n value.innerText = lang || '--';\n select.setAttribute('data-fold', updatedNode.attrs.fold ? 'true' : 'false');\n\n return true;\n },\n };\n },\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createNode } from '@milkdown/utils';\n\nexport const doc = createNode(() => {\n return {\n id: 'doc',\n schema: () => ({\n content: 'block+',\n parseMarkdown: {\n match: ({ type }) => type === 'root',\n runner: (state, node, type) => {\n state.injectRoot(node, type);\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === 'doc',\n runner: (state, node) => {\n state.openNode('root');\n state.next(node.content);\n },\n },\n }),\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { AddMarkStep, Plugin, PluginKey, ReplaceStep } from '@milkdown/prose';\nimport { createNode, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['HardBreak'];\n\nexport const InsertHardbreak = createCmdKey();\n\nexport const hardbreak = createNode<Keys>((utils) => {\n return {\n id: 'hardbreak',\n schema: () => ({\n inline: true,\n group: 'inline',\n selectable: false,\n parseDOM: [{ tag: 'br' }],\n toDOM: (node) => ['br', { class: utils.getClassName(node.attrs, 'hardbreak') }],\n parseMarkdown: {\n match: ({ type }) => type === 'break',\n runner: (state, _, type) => {\n state.addNode(type);\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === 'hardbreak',\n runner: (state) => {\n state.addNode('break');\n },\n },\n }),\n commands: (type) => [\n createCmd(InsertHardbreak, () => (state, dispatch) => {\n dispatch?.(state.tr.setMeta('hardbreak', true).replaceSelectionWith(type.create()).scrollIntoView());\n return true;\n }),\n ],\n shortcuts: {\n [SupportedKeys.HardBreak]: createShortcut(InsertHardbreak, 'Shift-Enter'),\n },\n prosePlugins: (type) => [\n new Plugin({\n key: new PluginKey('hardbreak-marks'),\n appendTransaction: (trs, _oldState, newState) => {\n if (!trs.length) return;\n const [tr] = trs;\n\n const [step] = tr.steps;\n\n const isInsertHr = tr.getMeta('hardbreak');\n if (isInsertHr) {\n if (!(step instanceof ReplaceStep)) {\n return;\n }\n const { from } = step as unknown as { from: number };\n return newState.tr.setNodeMarkup(from, type, undefined, []);\n }\n\n const isAddMarkStep = step instanceof AddMarkStep;\n if (isAddMarkStep) {\n let _tr = newState.tr;\n const { from, to } = step as unknown as { from: number; to: number };\n newState.doc.nodesBetween(from, to, (node, pos) => {\n if (node.type === type) {\n _tr = _tr.setNodeMarkup(pos, type, undefined, []);\n }\n });\n\n return _tr;\n }\n\n return;\n },\n }),\n ],\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { Plugin, PluginKey, setBlockType, textblockTypeInputRule } from '@milkdown/prose';\nimport { createNode, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\nconst headingIndex = Array(6)\n .fill(0)\n .map((_, i) => i + 1);\n\ntype Keys =\n | SupportedKeys['H1']\n | SupportedKeys['H2']\n | SupportedKeys['H3']\n | SupportedKeys['H4']\n | SupportedKeys['H5']\n | SupportedKeys['H6'];\n\nexport const TurnIntoHeading = createCmdKey<number>();\n\nexport const headingPluginKey = new PluginKey('MILKDOWN_PLUGIN_ID');\n\nexport const heading = createNode<Keys>((utils) => {\n const id = 'heading';\n\n const style = (level: number) =>\n utils.getStyle((_, { css }) => {\n const headingMap: Record<number, string> = {\n 1: css`\n font-size: 3rem;\n line-height: 3.5rem;\n `,\n 2: css`\n font-size: 2.5rem;\n line-height: 3rem;\n `,\n 3: css`\n font-size: 2.125rem;\n line-height: 2.25rem;\n `,\n 4: css`\n font-size: 1.75rem;\n line-height: 2rem;\n `,\n 5: css`\n font-size: 1.5rem;\n line-height: 1.5rem;\n `,\n 6: css`\n font-size: 1.25rem;\n line-height: 1.25rem;\n `,\n };\n\n return css`\n ${headingMap[level] || ''}\n margin: 2.5rem 0 !important;\n font-weight: 400;\n `;\n });\n\n return {\n id,\n schema: () => ({\n content: 'inline*',\n group: 'block',\n defining: true,\n attrs: {\n id: {\n default: '',\n },\n level: {\n default: 1,\n },\n },\n parseDOM: headingIndex.map((x) => ({\n tag: `h${x}`,\n getAttrs: (node) => {\n if (!(node instanceof HTMLElement)) {\n throw new Error();\n }\n return { level: x, id: node.id };\n },\n })),\n toDOM: (node) => {\n return [\n `h${node.attrs.level}`,\n {\n id: node.attrs.id || node.textContent.split(' ').join('-').toLocaleLowerCase(),\n class: utils.getClassName(node.attrs, `heading h${node.attrs.level}`, style(node.attrs.level)),\n },\n 0,\n ];\n },\n parseMarkdown: {\n match: ({ type }) => type === id,\n runner: (state, node, type) => {\n const depth = node.depth as number;\n state.openNode(type, { level: depth });\n state.next(node.children);\n state.closeNode();\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === id,\n runner: (state, node) => {\n state.openNode('heading', undefined, { depth: node.attrs.level });\n state.next(node.content);\n state.closeNode();\n },\n },\n }),\n inputRules: (type) =>\n headingIndex.map((x) =>\n textblockTypeInputRule(new RegExp(`^(#{1,${x}})\\\\s$`), type, () => ({\n level: x,\n })),\n ),\n commands: (type) => [createCmd(TurnIntoHeading, (level = 1) => setBlockType(type, { level }))],\n shortcuts: {\n [SupportedKeys.H1]: createShortcut(TurnIntoHeading, 'Mod-Alt-1', 1),\n [SupportedKeys.H2]: createShortcut(TurnIntoHeading, 'Mod-Alt-2', 2),\n [SupportedKeys.H3]: createShortcut(TurnIntoHeading, 'Mod-Alt-3', 3),\n [SupportedKeys.H4]: createShortcut(TurnIntoHeading, 'Mod-Alt-4', 4),\n [SupportedKeys.H5]: createShortcut(TurnIntoHeading, 'Mod-Alt-5', 5),\n [SupportedKeys.H6]: createShortcut(TurnIntoHeading, 'Mod-Alt-6', 6),\n },\n prosePlugins: (type) => [\n new Plugin({\n key: headingPluginKey,\n appendTransaction: (transactions, _, nextState) => {\n const tr = nextState.tr;\n let modified = false;\n if (transactions.some((transaction) => transaction.docChanged)) {\n nextState.doc.descendants((node, pos) => {\n if (node.type === type) {\n const attrs = node.attrs;\n tr.setNodeMarkup(pos, undefined, {\n ...attrs,\n id: node.textContent.split(' ').join('-').toLocaleLowerCase(),\n });\n modified = true;\n }\n });\n }\n\n return modified ? tr : null;\n },\n }),\n ],\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey, schemaCtx } from '@milkdown/core';\nimport { InputRule, Selection } from '@milkdown/prose';\nimport { createNode } from '@milkdown/utils';\n\nconst id = 'hr';\nexport const InsertHr = createCmdKey<string>();\nexport const hr = createNode((utils) => {\n const style = utils.getStyle(\n (themeTool, { css }) => css`\n height: ${themeTool.size.lineWidth};\n background-color: ${themeTool.palette('line')};\n border-width: 0;\n `,\n );\n return {\n id,\n schema: () => ({\n group: 'block',\n parseDOM: [{ tag: 'hr' }],\n toDOM: (node) => ['hr', { class: utils.getClassName(node.attrs, id, style) }],\n parseMarkdown: {\n match: ({ type }) => type === 'thematicBreak',\n runner: (state, _, type) => {\n state.addNode(type);\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === id,\n runner: (state) => {\n state.addNode('thematicBreak');\n },\n },\n }),\n inputRules: (type) => [\n new InputRule(/^(?:---|___\\s|\\*\\*\\*\\s)$/, (state, match, start, end) => {\n const { tr } = state;\n\n if (match[0]) {\n tr.replaceWith(start - 1, end, type.create());\n }\n\n return tr;\n }),\n ],\n commands: (type, ctx) => [\n createCmd(InsertHr, () => (state, dispatch) => {\n if (!dispatch) return true;\n const { tr, selection } = state;\n const from = selection.from;\n const node = type.create();\n if (!node) {\n return true;\n }\n const _tr = tr.replaceSelectionWith(node).insert(from, ctx.get(schemaCtx).node('paragraph'));\n const sel = Selection.findFrom(_tr.doc.resolve(from), 1, true);\n if (!sel) {\n return true;\n }\n dispatch(_tr.setSelection(sel).scrollIntoView());\n return true;\n }),\n ],\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey, themeToolCtx } from '@milkdown/core';\nimport type { Icon } from '@milkdown/design-system';\nimport { findSelectedNodeOfType, InputRule } from '@milkdown/prose';\nimport { createNode } from '@milkdown/utils';\n\nexport const ModifyImage = createCmdKey<string>();\nexport const InsertImage = createCmdKey<string>();\nconst id = 'image';\nexport type ImageOptions = {\n isBlock: boolean;\n placeholder: {\n loading: string;\n empty: string;\n failed: string;\n };\n};\n\nexport const image = createNode<string, ImageOptions>((utils, options) => {\n const placeholder = {\n loading: 'Loading...',\n empty: 'Add an Image',\n failed: 'Image loads failed',\n ...(options?.placeholder ?? {}),\n };\n const isBlock = options?.isBlock ?? false;\n const containerStyle = utils.getStyle(\n (themeTool, { css }) =>\n css`\n display: inline-block;\n position: relative;\n text-align: center;\n font-size: 0;\n vertical-align: text-bottom;\n line-height: 1;\n\n ${isBlock\n ? `\n width: 100%;\n margin: 0 auto;\n `\n : ''}\n\n &.ProseMirror-selectednode::after {\n content: '';\n background: ${themeTool.palette('secondary', 0.38)};\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n\n img {\n max-width: 100%;\n height: auto;\n object-fit: contain;\n margin: 0 2px;\n }\n .icon,\n .placeholder {\n display: none;\n }\n\n &.system {\n width: 100%;\n padding: 0 2rem;\n\n img {\n width: 0;\n height: 0;\n display: none;\n }\n\n .icon,\n .placeholder {\n display: inline;\n }\n\n box-sizing: border-box;\n height: 3rem;\n background-color: ${themeTool.palette('background')};\n border-radius: ${themeTool.size.radius};\n display: inline-flex;\n gap: 2rem;\n justify-content: flex-start;\n align-items: center;\n .placeholder {\n margin: 0;\n line-height: 1;\n &::before {\n content: '';\n font-size: 0.875rem;\n color: ${themeTool.palette('neutral', 0.6)};\n }\n }\n }\n\n &.loading {\n .placeholder {\n &::before {\n content: '${placeholder.loading}';\n }\n }\n }\n\n &.empty {\n .placeholder {\n &::before {\n content: '${placeholder.empty}';\n }\n }\n }\n\n &.failed {\n .placeholder {\n &::before {\n content: '${placeholder.failed}';\n }\n }\n }\n `,\n );\n\n const style = utils.getStyle(\n (_, { css }) =>\n css`\n display: inline-block;\n margin: 0 auto;\n object-fit: contain;\n width: 100%;\n position: relative;\n height: auto;\n text-align: center;\n `,\n );\n\n return {\n id: 'image',\n schema: () => ({\n inline: true,\n group: 'inline',\n selectable: true,\n draggable: true,\n marks: '',\n atom: true,\n defining: true,\n isolating: true,\n attrs: {\n src: { default: '' },\n alt: { default: null },\n title: { default: null },\n failed: { default: false },\n loading: { default: true },\n width: { default: null },\n },\n parseDOM: [\n {\n tag: 'img[src]',\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) {\n throw new Error();\n }\n return {\n failed: dom.classList.contains('failed'),\n loading: dom.classList.contains('loading'),\n src: dom.getAttribute('src') || '',\n alt: dom.getAttribute('alt'),\n title: dom.getAttribute('title') || dom.getAttribute('alt'),\n width: dom.getAttribute('width'),\n };\n },\n },\n ],\n toDOM: (node) => {\n return [\n 'img',\n {\n ...node.attrs,\n class: utils.getClassName(\n node.attrs,\n id,\n node.attrs.failed ? 'failed' : '',\n node.attrs.loading ? 'loading' : '',\n style,\n ),\n },\n ];\n },\n parseMarkdown: {\n match: ({ type }) => type === id,\n runner: (state, node, type) => {\n const url = node.url as string;\n const alt = node.alt as string;\n const title = node.title as string;\n state.addNode(type, {\n src: url,\n alt,\n title,\n });\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === id,\n runner: (state, node) => {\n state.addNode('image', undefined, undefined, {\n title: node.attrs.title,\n url: node.attrs.src,\n alt: node.attrs.alt,\n });\n },\n },\n }),\n commands: (type) => [\n createCmd(InsertImage, (src = '') => (state, dispatch) => {\n if (!dispatch) return true;\n const { tr } = state;\n const node = type.create({ src });\n if (!node) {\n return true;\n }\n const _tr = tr.replaceSelectionWith(node);\n dispatch(_tr.scrollIntoView());\n return true;\n }),\n createCmd(ModifyImage, (src = '') => (state, dispatch) => {\n const node = findSelectedNodeOfType(state.selection, type);\n if (!node) return false;\n\n const { tr } = state;\n dispatch?.(\n tr.setNodeMarkup(node.pos, undefined, { ...node.node.attrs, loading: true, src }).scrollIntoView(),\n );\n\n return true;\n }),\n ],\n inputRules: (type) => [\n new InputRule(\n /!\\[(?<alt>.*?)]\\((?<filename>.*?)\\s*(?=\"|\\))\"?(?<title>[^\"]+)?\"?\\)/,\n (state, match, start, end) => {\n const [okay, alt, src = '', title] = match;\n const { tr } = state;\n if (okay) {\n tr.replaceWith(start, end, type.create({ src, alt, title }));\n }\n\n return tr;\n },\n ),\n ],\n view: (ctx) => (node, view, getPos) => {\n const nodeType = node.type;\n const createIcon = ctx.get(themeToolCtx).slots.icon;\n const container = document.createElement('span');\n container.className = utils.getClassName(node.attrs, id, containerStyle);\n\n const content = document.createElement('img');\n\n container.append(content);\n let icon = createIcon('image');\n const placeholder = document.createElement('span');\n placeholder.classList.add('placeholder');\n container.append(icon, placeholder);\n\n const setIcon = (name: Icon) => {\n const nextIcon = createIcon(name);\n container.replaceChild(nextIcon, icon);\n icon = nextIcon;\n };\n\n const loadImage = (src: string) => {\n container.classList.add('system', 'loading');\n setIcon('loading');\n const img = document.createElement('img');\n img.src = src;\n\n img.onerror = () => {\n const pos = getPos();\n if (!pos) return;\n\n const { tr } = view.state;\n const _tr = tr.setNodeMarkup(pos, nodeType, {\n ...node.attrs,\n src,\n loading: false,\n failed: true,\n });\n view.dispatch(_tr);\n };\n\n img.onload = () => {\n const { tr } = view.state;\n\n const pos = getPos();\n if (!pos) return;\n\n const _tr = tr.setNodeMarkup(pos, nodeType, {\n ...node.attrs,\n width: img.width,\n src,\n loading: false,\n failed: false,\n });\n view.dispatch(_tr);\n };\n };\n\n const { src, loading, title, alt, width } = node.attrs;\n content.src = src;\n content.title = title || alt;\n content.alt = alt;\n if (width) {\n content.width = width;\n }\n\n if (src.length === 0) {\n container.classList.add('system', 'empty');\n setIcon('image');\n } else if (loading) {\n loadImage(src);\n }\n\n return {\n dom: container,\n update: (updatedNode) => {\n if (updatedNode.type.name !== id) return false;\n\n const { src, alt, title, loading, failed, width } = updatedNode.attrs;\n content.src = src;\n content.alt = alt;\n content.title = title || alt;\n if (width) {\n content.width = width;\n }\n if (loading) {\n loadImage(src);\n return true;\n }\n if (failed) {\n container.classList.remove('loading', 'empty');\n container.classList.add('system', 'failed');\n setIcon('brokenImage');\n return true;\n }\n if (src.length > 0) {\n container.classList.remove('system', 'empty', 'loading');\n return true;\n }\n\n container.classList.add('system', 'empty');\n setIcon('image');\n return true;\n },\n selectNode: () => {\n container.classList.add('ProseMirror-selectednode');\n },\n deselectNode: () => {\n container.classList.remove('ProseMirror-selectednode');\n },\n };\n },\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { liftListItem, sinkListItem, splitListItem, wrappingInputRule } from '@milkdown/prose';\nimport { createNode, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['SinkListItem'] | SupportedKeys['LiftListItem'] | SupportedKeys['NextListItem'];\n\nconst id = 'list_item';\n\nexport const SplitListItem = createCmdKey();\nexport const SinkListItem = createCmdKey();\nexport const LiftListItem = createCmdKey();\n\nexport const listItem = createNode<Keys>((utils) => {\n const style = utils.getStyle(\n (themeTool, { css }) =>\n css`\n &,\n & > * {\n margin: 0.5rem 0;\n }\n\n &,\n li {\n &::marker {\n color: ${themeTool.palette('primary')};\n }\n }\n `,\n );\n\n return {\n id,\n schema: () => ({\n group: 'listItem',\n content: 'paragraph block*',\n defining: true,\n parseDOM: [{ tag: 'li' }],\n toDOM: (node) => ['li', { class: utils.getClassName(node.attrs, 'list-item', style) }, 0],\n parseMarkdown: {\n match: ({ type, checked }) => type === 'listItem' && checked === null,\n runner: (state, node, type) => {\n state.openNode(type);\n state.next(node.children);\n state.closeNode();\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === id,\n runner: (state, node) => {\n state.openNode('listItem');\n state.next(node.content);\n state.closeNode();\n },\n },\n }),\n inputRules: (nodeType) => [wrappingInputRule(/^\\s*([-+*])\\s$/, nodeType)],\n commands: (nodeType) => [\n createCmd(SplitListItem, () => splitListItem(nodeType)),\n createCmd(SinkListItem, () => sinkListItem(nodeType)),\n createCmd(LiftListItem, () => liftListItem(nodeType)),\n ],\n shortcuts: {\n [SupportedKeys.NextListItem]: createShortcut(SplitListItem, 'Enter'),\n [SupportedKeys.SinkListItem]: createShortcut(SinkListItem, 'Mod-]'),\n [SupportedKeys.LiftListItem]: createShortcut(LiftListItem, 'Mod-['),\n },\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { wrapIn, wrappingInputRule } from '@milkdown/prose';\nimport { createNode, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['OrderedList'];\n\nexport const WrapInOrderedList = createCmdKey();\n\nconst id = 'ordered_list';\nexport const orderedList = createNode<Keys>((utils) => ({\n id,\n schema: () => ({\n content: 'listItem+',\n group: 'block',\n attrs: {\n order: {\n default: 1,\n },\n },\n parseDOM: [\n {\n tag: 'ol',\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) {\n throw new Error();\n }\n return { order: dom.hasAttribute('start') ? Number(dom.getAttribute('start')) : 1 };\n },\n },\n ],\n toDOM: (node) => [\n 'ol',\n {\n ...(node.attrs.order === 1 ? {} : node.attrs.order),\n class: utils.getClassName(node.attrs, 'ordered-list'),\n },\n 0,\n ],\n parseMarkdown: {\n match: ({ type, ordered }) => type === 'list' && !!ordered,\n runner: (state, node, type) => {\n state.openNode(type).next(node.children).closeNode();\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === id,\n runner: (state, node) => {\n state.openNode('list', undefined, { ordered: true, start: 1 });\n state.next(node.content);\n state.closeNode();\n },\n },\n }),\n inputRules: (nodeType) => [\n wrappingInputRule(\n /^(\\d+)\\.\\s$/,\n nodeType,\n (match) => ({ order: Number(match[1]) }),\n (match, node) => node.childCount + node.attrs.order === Number(match[1]),\n ),\n ],\n commands: (nodeType) => [createCmd(WrapInOrderedList, () => wrapIn(nodeType))],\n shortcuts: {\n [SupportedKeys.OrderedList]: createShortcut(WrapInOrderedList, 'Mod-Alt-7'),\n },\n}));\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { setBlockType } from '@milkdown/prose';\nimport { createNode, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['Text'];\n\nexport const TurnIntoText = createCmdKey();\n\nconst id = 'paragraph';\nexport const paragraph = createNode<Keys>((utils) => {\n const style = utils.getStyle((_, { css }) => {\n return css`\n font-size: 1rem;\n line-height: 1.5;\n letter-spacing: 0.5px;\n `;\n });\n\n return {\n id,\n schema: () => ({\n content: 'inline*',\n group: 'block',\n parseDOM: [{ tag: 'p' }],\n toDOM: (node) => ['p', { class: utils.getClassName(node.attrs, id, style) }, 0],\n parseMarkdown: {\n match: (node) => node.type === 'paragraph',\n runner: (state, node, type) => {\n state.openNode(type);\n if (node.children) {\n state.next(node.children);\n } else {\n state.addText(node.value as string);\n }\n state.closeNode();\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === 'paragraph',\n runner: (state, node) => {\n state.openNode('paragraph');\n state.next(node.content);\n state.closeNode();\n },\n },\n }),\n commands: (nodeType) => [createCmd(TurnIntoText, () => setBlockType(nodeType))],\n shortcuts: {\n [SupportedKeys.Text]: createShortcut(TurnIntoText, 'Mod-Alt-0'),\n },\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createNode } from '@milkdown/utils';\n\nexport const text = createNode(() => ({\n id: 'text',\n schema: () => ({\n group: 'inline',\n parseMarkdown: {\n match: ({ type }) => type === 'text',\n runner: (state, node) => {\n state.addText(node.value as string);\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === 'text',\n runner: (state, node) => {\n state.addNode('text', undefined, node.text as string);\n },\n },\n }),\n}));\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { blockquote } from './blockquote';\nimport { bulletList } from './bullet-list';\nimport { codeFence } from './code-fence';\nimport { doc } from './doc';\nimport { hardbreak } from './hardbreak';\nimport { heading } from './heading';\nimport { hr } from './hr';\nimport { image } from './image';\nimport { listItem } from './list-item';\nimport { orderedList } from './ordered-list';\nimport { paragraph } from './paragraph';\nimport { text } from './text';\n\nexport const nodes = [\n doc(),\n paragraph(),\n hardbreak(),\n blockquote(),\n codeFence(),\n bulletList(),\n orderedList(),\n listItem(),\n heading(),\n hr(),\n image(),\n text(),\n];\n\nexport * from './blockquote';\nexport * from './bullet-list';\nexport * from './code-fence';\nexport * from './doc';\nexport * from './hardbreak';\nexport * from './heading';\nexport * from './hr';\nexport * from './image';\nexport * from './list-item';\nexport * from './ordered-list';\nexport * from './paragraph';\nexport * from './text';\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { Literal, Node, Parent } from 'unist';\n\nconst isParent = (node: Node): node is Parent => !!(node as Parent).children;\nconst isHTML = (node: Node): node is Literal<string> => node.type === 'html';\n\nfunction flatMapWithDepth(ast: Node, fn: (node: Node, index: number, parent: Node | null) => Node[]) {\n return transform(ast, 0, null)[0];\n\n function transform(node: Node, index: number, parent: Node | null) {\n if (isParent(node)) {\n const out = [];\n for (let i = 0, n = node.children.length; i < n; i++) {\n const xs = transform(node.children[i], i, node);\n if (xs) {\n for (let j = 0, m = xs.length; j < m; j++) {\n out.push(xs[j]);\n }\n }\n }\n node.children = out;\n }\n\n return fn(node, index, parent);\n }\n}\n\nexport const filterHTMLPlugin = () => {\n function transformer(tree: Node) {\n flatMapWithDepth(tree, (node) => {\n if (!isHTML(node)) {\n return [node];\n }\n\n return [];\n });\n }\n return transformer;\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createPlugin } from '@milkdown/utils';\nimport links from 'remark-inline-links';\n\nimport { filterHTMLPlugin } from './filter-html';\n\nexport const commonmarkPlugins = [\n createPlugin(() => ({\n remarkPlugins: () => [links, filterHTMLPlugin],\n }))(),\n];\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { AtomList } from '@milkdown/utils';\n\nimport { marks, ModifyLink, ToggleBold, ToggleInlineCode, ToggleItalic, ToggleLink } from './mark';\nimport {\n InsertHardbreak,\n InsertHr,\n InsertImage,\n LiftListItem,\n ModifyImage,\n nodes,\n SinkListItem,\n SplitListItem,\n TurnIntoCodeFence,\n TurnIntoHeading,\n TurnIntoText,\n WrapInBlockquote,\n WrapInBulletList,\n WrapInOrderedList,\n} from './node';\nimport { commonmarkPlugins } from './plugin';\n\nexport * from './mark';\nexport * from './node';\nexport * from './supported-keys';\n\nexport const commonmarkNodes = AtomList.create([...nodes, ...marks]);\nexport { commonmarkPlugins };\nexport const commonmark = AtomList.create([...commonmarkPlugins, ...commonmarkNodes]);\n\nexport const commands = {\n ToggleInlineCode,\n ToggleItalic,\n ToggleLink,\n ToggleBold,\n\n ModifyLink,\n ModifyImage,\n\n WrapInBlockquote,\n WrapInBulletList,\n WrapInOrderedList,\n\n TurnIntoCodeFence,\n TurnIntoHeading,\n TurnIntoText,\n\n InsertHardbreak,\n InsertHr,\n InsertImage,\n\n SplitListItem,\n SinkListItem,\n LiftListItem,\n} as const;\nexport type Commands = typeof commands;\n"],"names":["id"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;MACa,gBAAgB;AAAA,EACzB,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,WAAW;AAAA,EACX,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA;ACXlB,MAAMA,OAAK;MAEE,mBAAm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EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;ACvBJ,MAAM,WAAW,CAAC,SAA+B,CAAC,CAAE,KAAgB;AACpE,MAAM,SAAS,CAAC,SAAwC,KAAK,SAAS;AAEtE,0BAA0B,KAAW,IAAgE;SAC1F,UAAU,KAAK,GAAG,MAAM;qBAEZ,MAAY,OAAe,QAAqB;QAC3D,SAAS,OAAO;YACV,MAAM;eACH,IAAI,GAAG,IAAI,KAAK,SAAS,QAAQ,IAAI,GAAG,KAAK;cAC5C,KAAK,UAAU,KAAK,SAAS,IAAI,GAAG;YACtC,IAAI;mBACK,IAAI,GAAG,IAAI,GAAG,QAAQ,IAAI,GAAG,KAAK;gBACnC,KAAK,GAAG;AAAA;AAAA;AAAA;WAInB,WAAW;AAAA;WAGb,GAAG,MAAM,OAAO;AAAA;AAAA;MAIlB,mBAAmB,MAAM;uBACb,MAAY;qBACZ,MAAM,CAAC,SAAS;UACzB,CAAC,OAAO,OAAO;eACR,CAAC;AAAA;aAGL;AAAA;AAAA;SAGR;AAAA;MC/BE,oBAAoB;AAAA,EAC7B,aAAa;IACT,eAAe,MAAM,CAAC,OAAO;AAAA;AAAA;MCkBxB,kBAAkB,SAAS,OAAO,CAAC,GAAG,OAAO,GAAG;MAEhD,aAAa,SAAS,OAAO,CAAC,GAAG,mBAAmB,GAAG;MAEvD,WAAW;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA;;"}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/supported-keys.ts","../src/mark/code-inline.ts","../src/mark/em.ts","../src/mark/link.ts","../src/mark/strong.ts","../src/mark/index.ts","../src/node/blockquote.ts","../src/node/bullet-list.ts","../src/node/code-fence.ts","../src/node/doc.ts","../src/node/hardbreak.ts","../src/node/heading.ts","../src/node/hr.ts","../src/node/image.ts","../src/node/list-item.ts","../src/node/ordered-list.ts","../src/node/paragraph.ts","../src/node/text.ts","../src/node/index.ts","../src/plugin/filter-html.ts","../src/plugin/index.ts","../src/index.ts"],"sourcesContent":["/* Copyright 2021, Milkdown by Mirone. */\nexport const SupportedKeys = {\n HardBreak: 'HardBreak',\n Blockquote: 'Blockquote',\n BulletList: 'BulletList',\n OrderedList: 'OrderedList',\n CodeFence: 'CodeFence',\n H1: 'H1',\n H2: 'H2',\n H3: 'H3',\n H4: 'H4',\n H5: 'H5',\n H6: 'H6',\n Text: 'Text',\n CodeInline: 'CodeInline',\n Em: 'Em',\n Bold: 'Bold',\n NextListItem: 'NextListItem',\n SinkListItem: 'SinkListItem',\n LiftListItem: 'LiftListItem',\n} as const;\n\nexport type SupportedKeys = typeof SupportedKeys;\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { markRule, toggleMark } from '@milkdown/prose';\nimport { createMark, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['CodeInline'];\nconst id = 'code_inline';\n\nexport const ToggleInlineCode = createCmdKey();\n\nexport const codeInline = createMark<Keys>((utils) => {\n const style = utils.getStyle(\n ({ palette, size, font }, { css }) =>\n css`\n background-color: ${palette('neutral')};\n color: ${palette('background')};\n border-radius: ${size.radius};\n font-weight: 500;\n font-family: ${font.code};\n padding: 0 0.2rem;\n `,\n );\n return {\n id,\n schema: () => ({\n priority: 100,\n code: true,\n inclusive: false,\n parseDOM: [{ tag: 'code' }],\n toDOM: (mark) => ['code', { class: utils.getClassName(mark.attrs, 'code-inline', style) }],\n parseMarkdown: {\n match: (node) => node.type === 'inlineCode',\n runner: (state, node, markType) => {\n state.openMark(markType);\n state.addText(node.value as string);\n state.closeMark(markType);\n },\n },\n toMarkdown: {\n match: (mark) => mark.type.name === id,\n runner: (state, mark, node) => {\n state.withMark(mark, 'inlineCode', node.text || '');\n },\n },\n }),\n inputRules: (markType) => [markRule(/(?:^|[^`])(`([^`]+)`)$/, markType)],\n commands: (markType) => [createCmd(ToggleInlineCode, () => toggleMark(markType))],\n shortcuts: {\n [SupportedKeys.CodeInline]: createShortcut(ToggleInlineCode, 'Mod-e'),\n },\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { markRule, toggleMark } from '@milkdown/prose';\nimport { createMark, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['Em'];\n\nconst id = 'em';\n\nexport const ToggleItalic = createCmdKey();\n\nexport const em = createMark<Keys>((utils) => ({\n id,\n schema: () => ({\n parseDOM: [\n { tag: 'i' },\n { tag: 'em' },\n { style: 'font-style', getAttrs: (value) => (value === 'italic') as false },\n ],\n toDOM: (mark) => ['em', { class: utils.getClassName(mark.attrs, id) }],\n parseMarkdown: {\n match: (node) => node.type === 'emphasis',\n runner: (state, node, markType) => {\n state.openMark(markType);\n state.next(node.children);\n state.closeMark(markType);\n },\n },\n toMarkdown: {\n match: (mark) => mark.type.name === id,\n runner: (state, mark) => {\n state.withMark(mark, 'emphasis');\n },\n },\n }),\n inputRules: (markType) => [\n markRule(/(?:^|[^_])(_([^_]+)_)$/, markType),\n markRule(/(?:^|[^*])(\\*([^*]+)\\*)$/, markType),\n ],\n commands: (markType) => [createCmd(ToggleItalic, () => toggleMark(markType))],\n shortcuts: {\n [SupportedKeys.Em]: createShortcut(ToggleItalic, 'Mod-i'),\n },\n}));\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey, schemaCtx } from '@milkdown/core';\nimport { InputRule, Node as ProseNode, TextSelection, toggleMark } from '@milkdown/prose';\nimport { createMark } from '@milkdown/utils';\n\nexport const ToggleLink = createCmdKey<string>();\nexport const ModifyLink = createCmdKey<string>();\nconst id = 'link';\nexport const link = createMark((utils) => {\n const style = utils.getStyle((themeTool, { css }) => {\n const lineColor = themeTool.palette('line');\n\n return css`\n color: ${themeTool.palette('secondary')};\n cursor: pointer;\n transition: all 0.4s ease-in-out;\n font-weight: 500;\n &:hover {\n background-color: ${lineColor};\n box-shadow: 0 0.2rem ${lineColor}, 0 -0.2rem ${lineColor};\n }\n `;\n });\n return {\n id,\n schema: () => ({\n attrs: {\n href: {},\n title: { default: null },\n },\n inclusive: false,\n parseDOM: [\n {\n tag: 'a[href]',\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) {\n throw new Error();\n }\n return { href: dom.getAttribute('href'), title: dom.getAttribute('title') };\n },\n },\n ],\n toDOM: (mark) => ['a', { ...mark.attrs, class: utils.getClassName(mark.attrs, id, style) }],\n parseMarkdown: {\n match: (node) => node.type === 'link',\n runner: (state, node, markType) => {\n const url = node.url as string;\n const title = node.title as string;\n state.openMark(markType, { href: url, title });\n state.next(node.children);\n state.closeMark(markType);\n },\n },\n toMarkdown: {\n match: (mark) => mark.type.name === id,\n runner: (state, mark) => {\n state.withMark(mark, 'link', undefined, {\n title: mark.attrs.title,\n url: mark.attrs.href,\n });\n },\n },\n }),\n commands: (markType) => [\n createCmd(ToggleLink, (href = '') => toggleMark(markType, { href })),\n createCmd(ModifyLink, (href = '') => (state, dispatch) => {\n if (!dispatch) return false;\n\n const { marks } = state.schema;\n\n let node: ProseNode | undefined;\n let pos = -1;\n const { selection } = state;\n state.doc.nodesBetween(selection.from, selection.to, (n, p) => {\n if (marks.link.isInSet(n.marks)) {\n node = n;\n pos = p;\n return false;\n }\n return;\n });\n if (!node) return false;\n\n const mark = node.marks.find(({ type }) => type === markType);\n if (!mark) return false;\n\n const start = pos;\n const end = pos + node.nodeSize;\n const { tr } = state;\n const linkMark = marks.link.create({ ...mark.attrs, href });\n dispatch(\n tr\n .removeMark(start, end, mark)\n .addMark(start, end, linkMark)\n .setSelection(new TextSelection(tr.selection.$anchor))\n .scrollIntoView(),\n );\n\n return true;\n }),\n ],\n inputRules: (markType, ctx) => [\n new InputRule(/\\[(?<text>.*?)]\\((?<href>.*?)(?=“|\\))\"?(?<title>[^\"]+)?\"?\\)/, (state, match, start, end) => {\n const [okay, text = '', href, title] = match;\n const { tr } = state;\n if (okay) {\n const content = text || 'link';\n tr.replaceWith(start, end, ctx.get(schemaCtx).text(content)).addMark(\n start,\n content.length + start,\n markType.create({ title, href }),\n );\n }\n\n return tr;\n }),\n ],\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { markRule, toggleMark } from '@milkdown/prose';\nimport { createMark, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['Bold'];\nconst id = 'strong';\nexport const ToggleBold = createCmdKey();\nexport const strong = createMark<Keys>((utils) => {\n const style = utils.getStyle(\n (_, { css }) =>\n css`\n font-weight: 600;\n `,\n );\n return {\n id,\n schema: () => ({\n parseDOM: [\n { tag: 'b' },\n { tag: 'strong' },\n { style: 'font-style', getAttrs: (value) => (value === 'bold') as false },\n ],\n toDOM: (mark) => ['strong', { class: utils.getClassName(mark.attrs, id, style) }],\n parseMarkdown: {\n match: (node) => node.type === 'strong',\n runner: (state, node, markType) => {\n state.openMark(markType);\n state.next(node.children);\n state.closeMark(markType);\n },\n },\n toMarkdown: {\n match: (mark) => mark.type.name === id,\n runner: (state, mark) => {\n state.withMark(mark, 'strong');\n },\n },\n }),\n inputRules: (markType) => [\n markRule(/(?:__)([^_]+)(?:__)$/, markType),\n markRule(/(?:\\*\\*)([^*]+)(?:\\*\\*)$/, markType),\n ],\n commands: (markType) => [createCmd(ToggleBold, () => toggleMark(markType))],\n shortcuts: {\n [SupportedKeys.Bold]: createShortcut(ToggleBold, 'Mod-b'),\n },\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { codeInline } from './code-inline';\nimport { em } from './em';\nimport { link } from './link';\nimport { strong } from './strong';\n\nexport const marks = [codeInline(), em(), strong(), link()];\n\nexport * from './code-inline';\nexport * from './em';\nexport * from './link';\nexport * from './strong';\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { wrapIn, wrappingInputRule } from '@milkdown/prose';\nimport { createNode, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['Blockquote'];\n\nconst id = 'blockquote';\n\nexport const WrapInBlockquote = createCmdKey();\n\nexport const blockquote = createNode<Keys>((utils) => {\n const style = utils.getStyle(\n (themeTool, { css }) =>\n css`\n padding-left: 1.875rem;\n line-height: 1.75rem;\n border-left: 4px solid ${themeTool.palette('primary')};\n * {\n font-size: 1rem;\n line-height: 1.5rem;\n }\n `,\n );\n\n return {\n id,\n schema: () => ({\n content: 'block+',\n group: 'block',\n defining: true,\n parseDOM: [{ tag: 'blockquote' }],\n toDOM: (node) => ['blockquote', { class: utils.getClassName(node.attrs, id, style) }, 0],\n parseMarkdown: {\n match: ({ type }) => type === id,\n runner: (state, node, type) => {\n state.openNode(type).next(node.children).closeNode();\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === id,\n runner: (state, node) => {\n state.openNode('blockquote').next(node.content).closeNode();\n },\n },\n }),\n inputRules: (nodeType) => [wrappingInputRule(/^\\s*>\\s$/, nodeType)],\n commands: (nodeType) => [createCmd(WrapInBlockquote, () => wrapIn(nodeType))],\n shortcuts: {\n [SupportedKeys.Blockquote]: createShortcut(WrapInBlockquote, 'Mod-Shift-b'),\n },\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { wrapIn, wrappingInputRule } from '@milkdown/prose';\nimport { createNode, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['BulletList'];\n\nexport const WrapInBulletList = createCmdKey();\n\nexport const bulletList = createNode<Keys>((utils) => {\n const id = 'bullet_list';\n return {\n id,\n schema: () => ({\n content: 'listItem+',\n group: 'block',\n parseDOM: [{ tag: 'ul' }],\n toDOM: (node) => {\n return ['ul', { class: utils.getClassName(node.attrs, 'bullet-list') }, 0];\n },\n parseMarkdown: {\n match: ({ type, ordered }) => type === 'list' && !ordered,\n runner: (state, node, type) => {\n state.openNode(type).next(node.children).closeNode();\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === id,\n runner: (state, node) => {\n state.openNode('list', undefined, { ordered: false }).next(node.content).closeNode();\n },\n },\n }),\n inputRules: (nodeType) => [wrappingInputRule(/^\\s*([-+*])\\s$/, nodeType)],\n commands: (nodeType) => [createCmd(WrapInBulletList, () => wrapIn(nodeType))],\n shortcuts: {\n [SupportedKeys.BulletList]: createShortcut(WrapInBulletList, 'Mod-Alt-8'),\n },\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey, themeToolCtx } from '@milkdown/core';\nimport { setBlockType, textblockTypeInputRule } from '@milkdown/prose';\nimport { createNode, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['CodeFence'];\n\nconst languageOptions = [\n '',\n 'javascript',\n 'typescript',\n 'bash',\n 'sql',\n 'json',\n 'html',\n 'css',\n 'c',\n 'cpp',\n 'java',\n 'ruby',\n 'python',\n 'go',\n 'rust',\n 'markdown',\n];\n\nexport const backtickInputRegex = /^```(?<language>[a-z]*)?[\\s\\n]$/;\nexport const tildeInputRegex = /^~~~(?<language>[a-z]*)?[\\s\\n]$/;\n\nexport const TurnIntoCodeFence = createCmdKey();\n\nconst id = 'fence';\nexport const codeFence = createNode<Keys, { languageList?: string[] }>((utils, options) => {\n const style = utils.getStyle(({ palette, mixin, size, font }, { css }) => {\n const { shadow, scrollbar, border } = mixin;\n const { lineWidth, radius } = size;\n return css`\n background-color: ${palette('background')};\n color: ${palette('neutral')};\n font-size: 0.85rem;\n padding: 1.2rem 0.4rem 1.4rem;\n border-radius: ${radius};\n font-family: ${font.typography};\n\n * {\n margin: 0;\n }\n\n .code-fence_select-wrapper {\n position: relative;\n }\n\n .code-fence_value {\n width: 10.25rem;\n box-sizing: border-box;\n border-radius: ${size.radius};\n margin: 0 1.2rem 1.2rem;\n ${border()};\n ${shadow()};\n cursor: pointer;\n background-color: ${palette('surface')};\n position: relative;\n display: flex;\n color: ${palette('neutral', 0.87)};\n letter-spacing: 0.5px;\n height: 2.625rem;\n align-items: center;\n\n & > .icon {\n width: 2.625rem;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n color: ${palette('solid', 0.87)};\n border-left: ${lineWidth} solid ${palette('line')};\n\n text-align: center;\n transition: all 0.2s ease-in-out;\n &:hover {\n background: ${palette('background')};\n color: ${palette('primary')};\n }\n }\n\n > span:first-child {\n padding-left: 1rem;\n flex: 1;\n font-weight: 500;\n }\n }\n\n .code-fence_select-option {\n list-style: none;\n line-height: 2rem;\n padding-left: 1rem;\n cursor: pointer;\n :hover {\n background: ${palette('secondary', 0.12)};\n color: ${palette('primary')};\n }\n }\n\n .code-fence_select {\n &[data-fold='true'] {\n display: none;\n }\n\n font-weight: 500;\n position: absolute;\n z-index: 1;\n top: 2.625rem;\n box-sizing: border-box;\n left: 1.2rem;\n padding: 0.5rem 0;\n max-height: 16.75rem;\n width: 10.25rem;\n ${border()};\n ${shadow()};\n background-color: ${palette('surface')};\n border-top: none;\n overflow-y: auto;\n display: flex;\n flex-direction: column;\n\n ${scrollbar('y')}\n }\n\n code {\n line-height: 1.5;\n font-family: ${font.code};\n }\n\n pre {\n font-family: ${font.code};\n margin: 0 1.2rem !important;\n white-space: pre;\n overflow: auto;\n ${scrollbar('x')};\n }\n `;\n });\n\n return {\n id,\n schema: () => ({\n content: 'text*',\n group: 'block',\n marks: '',\n defining: true,\n code: true,\n attrs: {\n language: {\n default: '',\n },\n fold: {\n default: true,\n },\n },\n parseDOM: [\n {\n tag: 'pre',\n preserveWhitespace: 'full',\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) {\n throw new Error('Parse DOM error.');\n }\n return { language: dom.dataset.language };\n },\n },\n ],\n toDOM: (node) => {\n return [\n 'pre',\n {\n 'data-language': node.attrs.language,\n class: utils.getClassName(node.attrs, 'code-fence', style),\n },\n ['code', { spellCheck: 'false' }, 0],\n ];\n },\n parseMarkdown: {\n match: ({ type }) => type === 'code',\n runner: (state, node, type) => {\n const language = node.lang as string;\n const value = node.value as string;\n state.openNode(type, { language });\n if (value) {\n state.addText(value);\n }\n state.closeNode();\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === id,\n runner: (state, node) => {\n state.addNode('code', undefined, node.content.firstChild?.text || '', {\n lang: node.attrs.language,\n });\n },\n },\n }),\n inputRules: (nodeType) => [\n textblockTypeInputRule(backtickInputRegex, nodeType, (match) => {\n const [ok, language] = match;\n if (!ok) return;\n return { language };\n }),\n textblockTypeInputRule(tildeInputRegex, nodeType, (match) => {\n const [ok, language] = match;\n if (!ok) return;\n return { language };\n }),\n ],\n commands: (nodeType) => [createCmd(TurnIntoCodeFence, () => setBlockType(nodeType))],\n shortcuts: {\n [SupportedKeys.CodeFence]: createShortcut(TurnIntoCodeFence, 'Mod-Alt-c'),\n },\n view: (ctx) => (node, view, getPos) => {\n const container = document.createElement('div');\n const selectWrapper = document.createElement('div');\n const select = document.createElement('ul');\n const pre = document.createElement('pre');\n const code = document.createElement('code');\n\n const valueWrapper = document.createElement('div');\n valueWrapper.className = 'code-fence_value';\n const value = document.createElement('span');\n valueWrapper.appendChild(value);\n if (view.editable) {\n valueWrapper.appendChild(ctx.get(themeToolCtx).slots.icon('downArrow'));\n }\n\n select.className = 'code-fence_select';\n select.addEventListener('mousedown', (e) => {\n e.preventDefault();\n e.stopPropagation();\n\n if (!view.editable) return;\n\n const el = e.target;\n if (!(el instanceof HTMLLIElement)) return;\n const { tr } = view.state;\n\n view.dispatch(\n tr.setNodeMarkup(getPos(), undefined, {\n fold: true,\n language: el.dataset.value,\n }),\n );\n });\n valueWrapper.addEventListener('mousedown', (e) => {\n e.preventDefault();\n e.stopPropagation();\n\n if (!view.editable) return;\n const { tr } = view.state;\n\n view.dispatch(\n tr.setNodeMarkup(getPos(), undefined, {\n fold: false,\n language: container.dataset.language,\n }),\n );\n });\n document.addEventListener('mousedown', () => {\n if (!view.editable || select.dataset.fold === 'true') return;\n\n const { tr } = view.state;\n\n view.dispatch(\n tr.setNodeMarkup(getPos(), undefined, {\n fold: true,\n language: container.dataset.language,\n }),\n );\n });\n\n (options?.languageList || languageOptions).forEach((lang) => {\n const option = document.createElement('li');\n option.className = 'code-fence_select-option';\n option.innerText = lang || '--';\n select.appendChild(option);\n option.setAttribute('data-value', lang);\n });\n\n code.spellcheck = false;\n selectWrapper.className = 'code-fence_select-wrapper';\n selectWrapper.contentEditable = 'false';\n selectWrapper.append(valueWrapper);\n selectWrapper.append(select);\n pre.append(code);\n const codeContent = document.createElement('div');\n code.append(codeContent);\n codeContent.style.whiteSpace = 'inherit';\n\n container.append(selectWrapper, pre);\n container.setAttribute('class', utils.getClassName(node.attrs, 'code-fence', style));\n container.setAttribute('data-language', node.attrs.language);\n value.innerText = node.attrs.language || '--';\n select.setAttribute('data-fold', node.attrs.fold ? 'true' : 'false');\n\n return {\n dom: container,\n contentDOM: codeContent,\n update: (updatedNode) => {\n if (updatedNode.type.name !== id) return false;\n\n const lang = updatedNode.attrs.language;\n container.dataset.language = lang;\n value.innerText = lang || '--';\n select.setAttribute('data-fold', updatedNode.attrs.fold ? 'true' : 'false');\n\n return true;\n },\n };\n },\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createNode } from '@milkdown/utils';\n\nexport const doc = createNode(() => {\n return {\n id: 'doc',\n schema: () => ({\n content: 'block+',\n parseMarkdown: {\n match: ({ type }) => type === 'root',\n runner: (state, node, type) => {\n state.injectRoot(node, type);\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === 'doc',\n runner: (state, node) => {\n state.openNode('root');\n state.next(node.content);\n },\n },\n }),\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { AddMarkStep, Plugin, PluginKey, ReplaceStep } from '@milkdown/prose';\nimport { createNode, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['HardBreak'];\n\nexport const InsertHardbreak = createCmdKey();\n\nexport const hardbreak = createNode<Keys>((utils) => {\n return {\n id: 'hardbreak',\n schema: () => ({\n inline: true,\n group: 'inline',\n selectable: false,\n parseDOM: [{ tag: 'br' }],\n toDOM: (node) => ['br', { class: utils.getClassName(node.attrs, 'hardbreak') }],\n parseMarkdown: {\n match: ({ type }) => type === 'break',\n runner: (state, _, type) => {\n state.addNode(type);\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === 'hardbreak',\n runner: (state) => {\n state.addNode('break');\n },\n },\n }),\n commands: (type) => [\n createCmd(InsertHardbreak, () => (state, dispatch) => {\n dispatch?.(state.tr.setMeta('hardbreak', true).replaceSelectionWith(type.create()).scrollIntoView());\n return true;\n }),\n ],\n shortcuts: {\n [SupportedKeys.HardBreak]: createShortcut(InsertHardbreak, 'Shift-Enter'),\n },\n prosePlugins: (type) => [\n new Plugin({\n key: new PluginKey('hardbreak-marks'),\n appendTransaction: (trs, _oldState, newState) => {\n if (!trs.length) return;\n const [tr] = trs;\n\n const [step] = tr.steps;\n\n const isInsertHr = tr.getMeta('hardbreak');\n if (isInsertHr) {\n if (!(step instanceof ReplaceStep)) {\n return;\n }\n const { from } = step as unknown as { from: number };\n return newState.tr.setNodeMarkup(from, type, undefined, []);\n }\n\n const isAddMarkStep = step instanceof AddMarkStep;\n if (isAddMarkStep) {\n let _tr = newState.tr;\n const { from, to } = step as unknown as { from: number; to: number };\n newState.doc.nodesBetween(from, to, (node, pos) => {\n if (node.type === type) {\n _tr = _tr.setNodeMarkup(pos, type, undefined, []);\n }\n });\n\n return _tr;\n }\n\n return;\n },\n }),\n ],\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey, editorViewCtx } from '@milkdown/core';\nimport {\n EditorState,\n Node,\n Plugin,\n PluginKey,\n setBlockType,\n textblockTypeInputRule,\n Transaction,\n} from '@milkdown/prose';\nimport { createNode, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\nconst headingIndex = Array(6)\n .fill(0)\n .map((_, i) => i + 1);\n\ntype Keys =\n | SupportedKeys['H1']\n | SupportedKeys['H2']\n | SupportedKeys['H3']\n | SupportedKeys['H4']\n | SupportedKeys['H5']\n | SupportedKeys['H6'];\n\nexport const TurnIntoHeading = createCmdKey<number>();\n\nexport const headingPluginKey = new PluginKey('MILKDOWN_PLUGIN_ID');\n\nexport const heading = createNode<Keys>((utils) => {\n const id = 'heading';\n\n const style = (level: number) =>\n utils.getStyle((_, { css }) => {\n const headingMap: Record<number, string> = {\n 1: css`\n font-size: 3rem;\n line-height: 3.5rem;\n `,\n 2: css`\n font-size: 2.5rem;\n line-height: 3rem;\n `,\n 3: css`\n font-size: 2.125rem;\n line-height: 2.25rem;\n `,\n 4: css`\n font-size: 1.75rem;\n line-height: 2rem;\n `,\n 5: css`\n font-size: 1.5rem;\n line-height: 1.5rem;\n `,\n 6: css`\n font-size: 1.25rem;\n line-height: 1.25rem;\n `,\n };\n\n return css`\n ${headingMap[level] || ''}\n margin: 2.5rem 0 !important;\n font-weight: 400;\n `;\n });\n\n return {\n id,\n schema: () => ({\n content: 'inline*',\n group: 'block',\n defining: true,\n attrs: {\n id: {\n default: '',\n },\n level: {\n default: 1,\n },\n },\n parseDOM: headingIndex.map((x) => ({\n tag: `h${x}`,\n getAttrs: (node) => {\n if (!(node instanceof HTMLElement)) {\n throw new Error();\n }\n return { level: x, id: node.id };\n },\n })),\n toDOM: (node) => {\n return [\n `h${node.attrs.level}`,\n {\n id: node.attrs.id || node.textContent.split(' ').join('-').toLocaleLowerCase(),\n class: utils.getClassName(node.attrs, `heading h${node.attrs.level}`, style(node.attrs.level)),\n },\n 0,\n ];\n },\n parseMarkdown: {\n match: ({ type }) => type === id,\n runner: (state, node, type) => {\n const depth = node.depth as number;\n state.openNode(type, { level: depth });\n state.next(node.children);\n state.closeNode();\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === id,\n runner: (state, node) => {\n state.openNode('heading', undefined, { depth: node.attrs.level });\n state.next(node.content);\n state.closeNode();\n },\n },\n }),\n inputRules: (type) =>\n headingIndex.map((x) =>\n textblockTypeInputRule(new RegExp(`^(#{1,${x}})\\\\s$`), type, () => ({\n level: x,\n })),\n ),\n commands: (type) => [createCmd(TurnIntoHeading, (level = 1) => setBlockType(type, { level }))],\n shortcuts: {\n [SupportedKeys.H1]: createShortcut(TurnIntoHeading, 'Mod-Alt-1', 1),\n [SupportedKeys.H2]: createShortcut(TurnIntoHeading, 'Mod-Alt-2', 2),\n [SupportedKeys.H3]: createShortcut(TurnIntoHeading, 'Mod-Alt-3', 3),\n [SupportedKeys.H4]: createShortcut(TurnIntoHeading, 'Mod-Alt-4', 4),\n [SupportedKeys.H5]: createShortcut(TurnIntoHeading, 'Mod-Alt-5', 5),\n [SupportedKeys.H6]: createShortcut(TurnIntoHeading, 'Mod-Alt-6', 6),\n },\n prosePlugins: (type, ctx) => {\n let lock = false;\n const createId = (node: Node) => {\n return node.textContent\n .replace(/[\\p{P}\\p{S}]/gu, '')\n .replace(/\\s/g, '')\n .trim();\n };\n const walkThrough = (state: EditorState, callback: (tr: Transaction) => void) => {\n const tr = state.tr;\n state.doc.descendants((node, pos) => {\n if (node.type === type && !lock) {\n if (node.textContent.trim().length === 0) {\n return;\n }\n const attrs = node.attrs;\n const id = createId(node);\n\n if (attrs.id !== id) {\n tr.setNodeMarkup(pos, undefined, {\n ...attrs,\n id,\n });\n }\n }\n });\n callback(tr);\n };\n return [\n new Plugin({\n key: headingPluginKey,\n props: {\n handleDOMEvents: {\n compositionstart: () => {\n lock = true;\n return false;\n },\n compositionend: () => {\n lock = false;\n const view = ctx.get(editorViewCtx);\n walkThrough(view.state, (tr) => view.dispatch(tr));\n return false;\n },\n },\n },\n appendTransaction: (transactions, _, nextState) => {\n let tr: Transaction | null = null;\n\n if (transactions.some((transaction) => transaction.docChanged)) {\n walkThrough(nextState, (t) => {\n tr = t;\n });\n }\n\n return tr;\n },\n }),\n ];\n },\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey, schemaCtx } from '@milkdown/core';\nimport { InputRule, Selection } from '@milkdown/prose';\nimport { createNode } from '@milkdown/utils';\n\nconst id = 'hr';\nexport const InsertHr = createCmdKey<string>();\nexport const hr = createNode((utils) => {\n const style = utils.getStyle(\n (themeTool, { css }) => css`\n height: ${themeTool.size.lineWidth};\n background-color: ${themeTool.palette('line')};\n border-width: 0;\n `,\n );\n return {\n id,\n schema: () => ({\n group: 'block',\n parseDOM: [{ tag: 'hr' }],\n toDOM: (node) => ['hr', { class: utils.getClassName(node.attrs, id, style) }],\n parseMarkdown: {\n match: ({ type }) => type === 'thematicBreak',\n runner: (state, _, type) => {\n state.addNode(type);\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === id,\n runner: (state) => {\n state.addNode('thematicBreak');\n },\n },\n }),\n inputRules: (type) => [\n new InputRule(/^(?:---|___\\s|\\*\\*\\*\\s)$/, (state, match, start, end) => {\n const { tr } = state;\n\n if (match[0]) {\n tr.replaceWith(start - 1, end, type.create());\n }\n\n return tr;\n }),\n ],\n commands: (type, ctx) => [\n createCmd(InsertHr, () => (state, dispatch) => {\n if (!dispatch) return true;\n const { tr, selection } = state;\n const from = selection.from;\n const node = type.create();\n if (!node) {\n return true;\n }\n const _tr = tr.replaceSelectionWith(node).insert(from, ctx.get(schemaCtx).node('paragraph'));\n const sel = Selection.findFrom(_tr.doc.resolve(from), 1, true);\n if (!sel) {\n return true;\n }\n dispatch(_tr.setSelection(sel).scrollIntoView());\n return true;\n }),\n ],\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey, themeToolCtx } from '@milkdown/core';\nimport type { Icon } from '@milkdown/design-system';\nimport { findSelectedNodeOfType, InputRule } from '@milkdown/prose';\nimport { createNode } from '@milkdown/utils';\n\nexport const ModifyImage = createCmdKey<string>();\nexport const InsertImage = createCmdKey<string>();\nconst id = 'image';\nexport type ImageOptions = {\n isBlock: boolean;\n placeholder: {\n loading: string;\n empty: string;\n failed: string;\n };\n};\n\nexport const image = createNode<string, ImageOptions>((utils, options) => {\n const placeholder = {\n loading: 'Loading...',\n empty: 'Add an Image',\n failed: 'Image loads failed',\n ...(options?.placeholder ?? {}),\n };\n const isBlock = options?.isBlock ?? false;\n const containerStyle = utils.getStyle(\n (themeTool, { css }) =>\n css`\n display: inline-block;\n position: relative;\n text-align: center;\n font-size: 0;\n vertical-align: text-bottom;\n line-height: 1;\n\n ${isBlock\n ? `\n width: 100%;\n margin: 0 auto;\n `\n : ''}\n\n &.ProseMirror-selectednode::after {\n content: '';\n background: ${themeTool.palette('secondary', 0.38)};\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n\n img {\n max-width: 100%;\n height: auto;\n object-fit: contain;\n margin: 0 2px;\n }\n .icon,\n .placeholder {\n display: none;\n }\n\n &.system {\n width: 100%;\n padding: 0 2rem;\n\n img {\n width: 0;\n height: 0;\n display: none;\n }\n\n .icon,\n .placeholder {\n display: inline;\n }\n\n box-sizing: border-box;\n height: 3rem;\n background-color: ${themeTool.palette('background')};\n border-radius: ${themeTool.size.radius};\n display: inline-flex;\n gap: 2rem;\n justify-content: flex-start;\n align-items: center;\n .placeholder {\n margin: 0;\n line-height: 1;\n &::before {\n content: '';\n font-size: 0.875rem;\n color: ${themeTool.palette('neutral', 0.6)};\n }\n }\n }\n\n &.loading {\n .placeholder {\n &::before {\n content: '${placeholder.loading}';\n }\n }\n }\n\n &.empty {\n .placeholder {\n &::before {\n content: '${placeholder.empty}';\n }\n }\n }\n\n &.failed {\n .placeholder {\n &::before {\n content: '${placeholder.failed}';\n }\n }\n }\n `,\n );\n\n const style = utils.getStyle(\n (_, { css }) =>\n css`\n display: inline-block;\n margin: 0 auto;\n object-fit: contain;\n width: 100%;\n position: relative;\n height: auto;\n text-align: center;\n `,\n );\n\n return {\n id: 'image',\n schema: () => ({\n inline: true,\n group: 'inline',\n selectable: true,\n draggable: true,\n marks: '',\n atom: true,\n defining: true,\n isolating: true,\n attrs: {\n src: { default: '' },\n alt: { default: null },\n title: { default: null },\n failed: { default: false },\n loading: { default: true },\n width: { default: null },\n },\n parseDOM: [\n {\n tag: 'img[src]',\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) {\n throw new Error();\n }\n return {\n failed: dom.classList.contains('failed'),\n loading: dom.classList.contains('loading'),\n src: dom.getAttribute('src') || '',\n alt: dom.getAttribute('alt'),\n title: dom.getAttribute('title') || dom.getAttribute('alt'),\n width: dom.getAttribute('width'),\n };\n },\n },\n ],\n toDOM: (node) => {\n return [\n 'img',\n {\n ...node.attrs,\n class: utils.getClassName(\n node.attrs,\n id,\n node.attrs.failed ? 'failed' : '',\n node.attrs.loading ? 'loading' : '',\n style,\n ),\n },\n ];\n },\n parseMarkdown: {\n match: ({ type }) => type === id,\n runner: (state, node, type) => {\n const url = node.url as string;\n const alt = node.alt as string;\n const title = node.title as string;\n state.addNode(type, {\n src: url,\n alt,\n title,\n });\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === id,\n runner: (state, node) => {\n state.addNode('image', undefined, undefined, {\n title: node.attrs.title,\n url: node.attrs.src,\n alt: node.attrs.alt,\n });\n },\n },\n }),\n commands: (type) => [\n createCmd(InsertImage, (src = '') => (state, dispatch) => {\n if (!dispatch) return true;\n const { tr } = state;\n const node = type.create({ src });\n if (!node) {\n return true;\n }\n const _tr = tr.replaceSelectionWith(node);\n dispatch(_tr.scrollIntoView());\n return true;\n }),\n createCmd(ModifyImage, (src = '') => (state, dispatch) => {\n const node = findSelectedNodeOfType(state.selection, type);\n if (!node) return false;\n\n const { tr } = state;\n dispatch?.(\n tr.setNodeMarkup(node.pos, undefined, { ...node.node.attrs, loading: true, src }).scrollIntoView(),\n );\n\n return true;\n }),\n ],\n inputRules: (type) => [\n new InputRule(\n /!\\[(?<alt>.*?)]\\((?<filename>.*?)\\s*(?=\"|\\))\"?(?<title>[^\"]+)?\"?\\)/,\n (state, match, start, end) => {\n const [okay, alt, src = '', title] = match;\n const { tr } = state;\n if (okay) {\n tr.replaceWith(start, end, type.create({ src, alt, title }));\n }\n\n return tr;\n },\n ),\n ],\n view: (ctx) => (node, view, getPos) => {\n const nodeType = node.type;\n const createIcon = ctx.get(themeToolCtx).slots.icon;\n const container = document.createElement('span');\n container.className = utils.getClassName(node.attrs, id, containerStyle);\n\n const content = document.createElement('img');\n\n container.append(content);\n let icon = createIcon('image');\n const placeholder = document.createElement('span');\n placeholder.classList.add('placeholder');\n container.append(icon, placeholder);\n\n const setIcon = (name: Icon) => {\n const nextIcon = createIcon(name);\n container.replaceChild(nextIcon, icon);\n icon = nextIcon;\n };\n\n const loadImage = (src: string) => {\n container.classList.add('system', 'loading');\n setIcon('loading');\n const img = document.createElement('img');\n img.src = src;\n\n img.onerror = () => {\n const pos = getPos();\n if (!pos) return;\n\n const { tr } = view.state;\n const _tr = tr.setNodeMarkup(pos, nodeType, {\n ...node.attrs,\n src,\n loading: false,\n failed: true,\n });\n view.dispatch(_tr);\n };\n\n img.onload = () => {\n const { tr } = view.state;\n\n const pos = getPos();\n if (!pos) return;\n\n const _tr = tr.setNodeMarkup(pos, nodeType, {\n ...node.attrs,\n width: img.width,\n src,\n loading: false,\n failed: false,\n });\n view.dispatch(_tr);\n };\n };\n\n const { src, loading, title, alt, width } = node.attrs;\n content.src = src;\n content.title = title || alt;\n content.alt = alt;\n if (width) {\n content.width = width;\n }\n\n if (src.length === 0) {\n container.classList.add('system', 'empty');\n setIcon('image');\n } else if (loading) {\n loadImage(src);\n }\n\n return {\n dom: container,\n update: (updatedNode) => {\n if (updatedNode.type.name !== id) return false;\n\n const { src, alt, title, loading, failed, width } = updatedNode.attrs;\n content.src = src;\n content.alt = alt;\n content.title = title || alt;\n if (width) {\n content.width = width;\n }\n if (loading) {\n loadImage(src);\n return true;\n }\n if (failed) {\n container.classList.remove('loading', 'empty');\n container.classList.add('system', 'failed');\n setIcon('brokenImage');\n return true;\n }\n if (src.length > 0) {\n container.classList.remove('system', 'empty', 'loading');\n return true;\n }\n\n container.classList.add('system', 'empty');\n setIcon('image');\n return true;\n },\n selectNode: () => {\n container.classList.add('ProseMirror-selectednode');\n },\n deselectNode: () => {\n container.classList.remove('ProseMirror-selectednode');\n },\n };\n },\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { liftListItem, sinkListItem, splitListItem, wrappingInputRule } from '@milkdown/prose';\nimport { createNode, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['SinkListItem'] | SupportedKeys['LiftListItem'] | SupportedKeys['NextListItem'];\n\nconst id = 'list_item';\n\nexport const SplitListItem = createCmdKey();\nexport const SinkListItem = createCmdKey();\nexport const LiftListItem = createCmdKey();\n\nexport const listItem = createNode<Keys>((utils) => {\n const style = utils.getStyle(\n (themeTool, { css }) =>\n css`\n &,\n & > * {\n margin: 0.5rem 0;\n }\n\n &,\n li {\n &::marker {\n color: ${themeTool.palette('primary')};\n }\n }\n `,\n );\n\n return {\n id,\n schema: () => ({\n group: 'listItem',\n content: 'paragraph block*',\n defining: true,\n parseDOM: [{ tag: 'li' }],\n toDOM: (node) => ['li', { class: utils.getClassName(node.attrs, 'list-item', style) }, 0],\n parseMarkdown: {\n match: ({ type, checked }) => type === 'listItem' && checked === null,\n runner: (state, node, type) => {\n state.openNode(type);\n state.next(node.children);\n state.closeNode();\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === id,\n runner: (state, node) => {\n state.openNode('listItem');\n state.next(node.content);\n state.closeNode();\n },\n },\n }),\n inputRules: (nodeType) => [wrappingInputRule(/^\\s*([-+*])\\s$/, nodeType)],\n commands: (nodeType) => [\n createCmd(SplitListItem, () => splitListItem(nodeType)),\n createCmd(SinkListItem, () => sinkListItem(nodeType)),\n createCmd(LiftListItem, () => liftListItem(nodeType)),\n ],\n shortcuts: {\n [SupportedKeys.NextListItem]: createShortcut(SplitListItem, 'Enter'),\n [SupportedKeys.SinkListItem]: createShortcut(SinkListItem, 'Mod-]'),\n [SupportedKeys.LiftListItem]: createShortcut(LiftListItem, 'Mod-['),\n },\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { wrapIn, wrappingInputRule } from '@milkdown/prose';\nimport { createNode, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['OrderedList'];\n\nexport const WrapInOrderedList = createCmdKey();\n\nconst id = 'ordered_list';\nexport const orderedList = createNode<Keys>((utils) => ({\n id,\n schema: () => ({\n content: 'listItem+',\n group: 'block',\n attrs: {\n order: {\n default: 1,\n },\n },\n parseDOM: [\n {\n tag: 'ol',\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) {\n throw new Error();\n }\n return { order: dom.hasAttribute('start') ? Number(dom.getAttribute('start')) : 1 };\n },\n },\n ],\n toDOM: (node) => [\n 'ol',\n {\n ...(node.attrs.order === 1 ? {} : node.attrs.order),\n class: utils.getClassName(node.attrs, 'ordered-list'),\n },\n 0,\n ],\n parseMarkdown: {\n match: ({ type, ordered }) => type === 'list' && !!ordered,\n runner: (state, node, type) => {\n state.openNode(type).next(node.children).closeNode();\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === id,\n runner: (state, node) => {\n state.openNode('list', undefined, { ordered: true, start: 1 });\n state.next(node.content);\n state.closeNode();\n },\n },\n }),\n inputRules: (nodeType) => [\n wrappingInputRule(\n /^(\\d+)\\.\\s$/,\n nodeType,\n (match) => ({ order: Number(match[1]) }),\n (match, node) => node.childCount + node.attrs.order === Number(match[1]),\n ),\n ],\n commands: (nodeType) => [createCmd(WrapInOrderedList, () => wrapIn(nodeType))],\n shortcuts: {\n [SupportedKeys.OrderedList]: createShortcut(WrapInOrderedList, 'Mod-Alt-7'),\n },\n}));\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createCmd, createCmdKey } from '@milkdown/core';\nimport { setBlockType } from '@milkdown/prose';\nimport { createNode, createShortcut } from '@milkdown/utils';\n\nimport { SupportedKeys } from '../supported-keys';\n\ntype Keys = SupportedKeys['Text'];\n\nexport const TurnIntoText = createCmdKey();\n\nconst id = 'paragraph';\nexport const paragraph = createNode<Keys>((utils) => {\n const style = utils.getStyle((_, { css }) => {\n return css`\n font-size: 1rem;\n line-height: 1.5;\n letter-spacing: 0.5px;\n `;\n });\n\n return {\n id,\n schema: () => ({\n content: 'inline*',\n group: 'block',\n parseDOM: [{ tag: 'p' }],\n toDOM: (node) => ['p', { class: utils.getClassName(node.attrs, id, style) }, 0],\n parseMarkdown: {\n match: (node) => node.type === 'paragraph',\n runner: (state, node, type) => {\n state.openNode(type);\n if (node.children) {\n state.next(node.children);\n } else {\n state.addText(node.value as string);\n }\n state.closeNode();\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === 'paragraph',\n runner: (state, node) => {\n state.openNode('paragraph');\n state.next(node.content);\n state.closeNode();\n },\n },\n }),\n commands: (nodeType) => [createCmd(TurnIntoText, () => setBlockType(nodeType))],\n shortcuts: {\n [SupportedKeys.Text]: createShortcut(TurnIntoText, 'Mod-Alt-0'),\n },\n };\n});\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createNode } from '@milkdown/utils';\n\nexport const text = createNode(() => ({\n id: 'text',\n schema: () => ({\n group: 'inline',\n parseMarkdown: {\n match: ({ type }) => type === 'text',\n runner: (state, node) => {\n state.addText(node.value as string);\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === 'text',\n runner: (state, node) => {\n state.addNode('text', undefined, node.text as string);\n },\n },\n }),\n}));\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { blockquote } from './blockquote';\nimport { bulletList } from './bullet-list';\nimport { codeFence } from './code-fence';\nimport { doc } from './doc';\nimport { hardbreak } from './hardbreak';\nimport { heading } from './heading';\nimport { hr } from './hr';\nimport { image } from './image';\nimport { listItem } from './list-item';\nimport { orderedList } from './ordered-list';\nimport { paragraph } from './paragraph';\nimport { text } from './text';\n\nexport const nodes = [\n doc(),\n paragraph(),\n hardbreak(),\n blockquote(),\n codeFence(),\n bulletList(),\n orderedList(),\n listItem(),\n heading(),\n hr(),\n image(),\n text(),\n];\n\nexport * from './blockquote';\nexport * from './bullet-list';\nexport * from './code-fence';\nexport * from './doc';\nexport * from './hardbreak';\nexport * from './heading';\nexport * from './hr';\nexport * from './image';\nexport * from './list-item';\nexport * from './ordered-list';\nexport * from './paragraph';\nexport * from './text';\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { Literal, Node, Parent } from 'unist';\n\nconst isParent = (node: Node): node is Parent => !!(node as Parent).children;\nconst isHTML = (node: Node): node is Literal<string> => node.type === 'html';\n\nfunction flatMapWithDepth(ast: Node, fn: (node: Node, index: number, parent: Node | null) => Node[]) {\n return transform(ast, 0, null)[0];\n\n function transform(node: Node, index: number, parent: Node | null) {\n if (isParent(node)) {\n const out = [];\n for (let i = 0, n = node.children.length; i < n; i++) {\n const xs = transform(node.children[i], i, node);\n if (xs) {\n for (let j = 0, m = xs.length; j < m; j++) {\n out.push(xs[j]);\n }\n }\n }\n node.children = out;\n }\n\n return fn(node, index, parent);\n }\n}\n\nexport const filterHTMLPlugin = () => {\n function transformer(tree: Node) {\n flatMapWithDepth(tree, (node) => {\n if (!isHTML(node)) {\n return [node];\n }\n\n return [];\n });\n }\n return transformer;\n};\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { createPlugin } from '@milkdown/utils';\nimport links from 'remark-inline-links';\n\nimport { filterHTMLPlugin } from './filter-html';\n\nexport const commonmarkPlugins = [\n createPlugin(() => ({\n remarkPlugins: () => [links, filterHTMLPlugin],\n }))(),\n];\n","/* Copyright 2021, Milkdown by Mirone. */\nimport { AtomList } from '@milkdown/utils';\n\nimport { marks, ModifyLink, ToggleBold, ToggleInlineCode, ToggleItalic, ToggleLink } from './mark';\nimport {\n InsertHardbreak,\n InsertHr,\n InsertImage,\n LiftListItem,\n ModifyImage,\n nodes,\n SinkListItem,\n SplitListItem,\n TurnIntoCodeFence,\n TurnIntoHeading,\n TurnIntoText,\n WrapInBlockquote,\n WrapInBulletList,\n WrapInOrderedList,\n} from './node';\nimport { commonmarkPlugins } from './plugin';\n\nexport * from './mark';\nexport * from './node';\nexport * from './supported-keys';\n\nexport const commonmarkNodes = AtomList.create([...nodes, ...marks]);\nexport { commonmarkPlugins };\nexport const commonmark = AtomList.create([...commonmarkPlugins, ...commonmarkNodes]);\n\nexport const commands = {\n ToggleInlineCode,\n ToggleItalic,\n ToggleLink,\n ToggleBold,\n\n ModifyLink,\n ModifyImage,\n\n WrapInBlockquote,\n WrapInBulletList,\n WrapInOrderedList,\n\n TurnIntoCodeFence,\n TurnIntoHeading,\n TurnIntoText,\n\n InsertHardbreak,\n InsertHr,\n InsertImage,\n\n SplitListItem,\n SinkListItem,\n LiftListItem,\n} as const;\nexport type Commands = typeof commands;\n"],"names":["id"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;MACa,gBAAgB;AAAA,EACzB,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,WAAW;AAAA,EACX,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA;ACXlB,MAA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EAC7B,aAAa;IACT,eAAe,MAAM,CAAC,OAAO;AAAA;AAAA;MCkBxB,kBAAkB,SAAS,OAAO,CAAC,GAAG,OAAO,GAAG;MAEhD,aAAa,SAAS,OAAO,CAAC,GAAG,mBAAmB,GAAG;MAEvD,WAAW;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-fence.d.ts","sourceRoot":"","sources":["code-fence.ts"],"names":[],"mappings":"AA4BA,eAAO,MAAM,kBAAkB,QAAoC,CAAC;AACpE,eAAO,MAAM,eAAe,QAAoC,CAAC;AAEjE,eAAO,MAAM,iBAAiB,4CAAiB,CAAC;AAGhD,eAAO,MAAM,SAAS;;;;;;
|
|
1
|
+
{"version":3,"file":"code-fence.d.ts","sourceRoot":"","sources":["code-fence.ts"],"names":[],"mappings":"AA4BA,eAAO,MAAM,kBAAkB,QAAoC,CAAC;AACpE,eAAO,MAAM,eAAe,QAAoC,CAAC;AAEjE,eAAO,MAAM,iBAAiB,4CAAiB,CAAC;AAGhD,eAAO,MAAM,SAAS;;;;;;EA8RpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["heading.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["heading.ts"],"names":[],"mappings":"AAEA,OAAO,EAIH,SAAS,EAIZ,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAMlD,aAAK,IAAI,GACH,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,CAAC;AAE1B,eAAO,MAAM,eAAe,yCAAyB,CAAC;AAEtD,eAAO,MAAM,gBAAgB,qBAAsC,CAAC;AAEpE,eAAO,MAAM,OAAO;;;;EAqKlB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkdown/preset-commonmark",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.es.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -16,11 +16,17 @@
|
|
|
16
16
|
"markdown",
|
|
17
17
|
"commonmark"
|
|
18
18
|
],
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@milkdown/core": "5.4.0",
|
|
21
|
+
"@milkdown/prose": "5.4.0",
|
|
22
|
+
"@milkdown/design-system": "5.4.0"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@milkdown/core": "^5.4.0",
|
|
26
|
+
"@milkdown/prose": "^5.4.0"
|
|
27
|
+
},
|
|
19
28
|
"dependencies": {
|
|
20
|
-
"@milkdown/
|
|
21
|
-
"@milkdown/core": "5.3.5",
|
|
22
|
-
"@milkdown/design-system": "5.3.5",
|
|
23
|
-
"@milkdown/utils": "5.3.5",
|
|
29
|
+
"@milkdown/utils": "5.4.0",
|
|
24
30
|
"remark-inline-links": "^6.0.0",
|
|
25
31
|
"tslib": "^2.3.1"
|
|
26
32
|
},
|
package/src/node/code-fence.ts
CHANGED
package/src/node/heading.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { createCmd, createCmdKey } from '@milkdown/core';
|
|
3
|
-
import {
|
|
2
|
+
import { createCmd, createCmdKey, editorViewCtx } from '@milkdown/core';
|
|
3
|
+
import {
|
|
4
|
+
EditorState,
|
|
5
|
+
Node,
|
|
6
|
+
Plugin,
|
|
7
|
+
PluginKey,
|
|
8
|
+
setBlockType,
|
|
9
|
+
textblockTypeInputRule,
|
|
10
|
+
Transaction,
|
|
11
|
+
} from '@milkdown/prose';
|
|
4
12
|
import { createNode, createShortcut } from '@milkdown/utils';
|
|
5
13
|
|
|
6
14
|
import { SupportedKeys } from '../supported-keys';
|
|
@@ -126,28 +134,64 @@ export const heading = createNode<Keys>((utils) => {
|
|
|
126
134
|
[SupportedKeys.H5]: createShortcut(TurnIntoHeading, 'Mod-Alt-5', 5),
|
|
127
135
|
[SupportedKeys.H6]: createShortcut(TurnIntoHeading, 'Mod-Alt-6', 6),
|
|
128
136
|
},
|
|
129
|
-
prosePlugins: (type) =>
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
137
|
+
prosePlugins: (type, ctx) => {
|
|
138
|
+
let lock = false;
|
|
139
|
+
const createId = (node: Node) => {
|
|
140
|
+
return node.textContent
|
|
141
|
+
.replace(/[\p{P}\p{S}]/gu, '')
|
|
142
|
+
.replace(/\s/g, '')
|
|
143
|
+
.trim();
|
|
144
|
+
};
|
|
145
|
+
const walkThrough = (state: EditorState, callback: (tr: Transaction) => void) => {
|
|
146
|
+
const tr = state.tr;
|
|
147
|
+
state.doc.descendants((node, pos) => {
|
|
148
|
+
if (node.type === type && !lock) {
|
|
149
|
+
if (node.textContent.trim().length === 0) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const attrs = node.attrs;
|
|
153
|
+
const id = createId(node);
|
|
154
|
+
|
|
155
|
+
if (attrs.id !== id) {
|
|
156
|
+
tr.setNodeMarkup(pos, undefined, {
|
|
157
|
+
...attrs,
|
|
158
|
+
id,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
146
161
|
}
|
|
162
|
+
});
|
|
163
|
+
callback(tr);
|
|
164
|
+
};
|
|
165
|
+
return [
|
|
166
|
+
new Plugin({
|
|
167
|
+
key: headingPluginKey,
|
|
168
|
+
props: {
|
|
169
|
+
handleDOMEvents: {
|
|
170
|
+
compositionstart: () => {
|
|
171
|
+
lock = true;
|
|
172
|
+
return false;
|
|
173
|
+
},
|
|
174
|
+
compositionend: () => {
|
|
175
|
+
lock = false;
|
|
176
|
+
const view = ctx.get(editorViewCtx);
|
|
177
|
+
walkThrough(view.state, (tr) => view.dispatch(tr));
|
|
178
|
+
return false;
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
appendTransaction: (transactions, _, nextState) => {
|
|
183
|
+
let tr: Transaction | null = null;
|
|
147
184
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
185
|
+
if (transactions.some((transaction) => transaction.docChanged)) {
|
|
186
|
+
walkThrough(nextState, (t) => {
|
|
187
|
+
tr = t;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return tr;
|
|
192
|
+
},
|
|
193
|
+
}),
|
|
194
|
+
];
|
|
195
|
+
},
|
|
152
196
|
};
|
|
153
197
|
});
|