@krainovsd/markdown-editor 0.4.0 → 0.4.3
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/cjs/{index-Dj0jRUGF.js → index-BZIT2oN2.js} +51 -47
- package/lib/cjs/index-BZIT2oN2.js.map +1 -0
- package/lib/cjs/{index-CXENq_0E.js → index-s-eevZJW.js} +2 -2
- package/lib/cjs/{index-CXENq_0E.js.map → index-s-eevZJW.js.map} +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/esm/extensions/auto-completes/custom/tag-auto-complete.js.map +1 -1
- package/lib/esm/extensions/init-extensions.js +2 -2
- package/lib/esm/extensions/init-extensions.js.map +1 -1
- package/lib/esm/extensions/keymaps/init-key-map.js +3 -9
- package/lib/esm/extensions/keymaps/init-key-map.js.map +1 -1
- package/lib/esm/extensions/listeners/get-change-event.js +3 -3
- package/lib/esm/extensions/listeners/get-change-event.js.map +1 -1
- package/lib/esm/extensions/listeners/get-focus-event.js +3 -3
- package/lib/esm/extensions/listeners/get-focus-event.js.map +1 -1
- package/lib/esm/extensions/markdown/blockquote/blockquote-decoration.js +1 -1
- package/lib/esm/extensions/markdown/blockquote/blockquote-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/bold/bold-decoration.js +1 -1
- package/lib/esm/extensions/markdown/code/code-decoration.js +3 -3
- package/lib/esm/extensions/markdown/code/code-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/header/header-decoration.js +1 -1
- package/lib/esm/extensions/markdown/image/image-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/image/image-widget.js +2 -1
- package/lib/esm/extensions/markdown/image/image-widget.js.map +1 -1
- package/lib/esm/extensions/markdown/italic/italic-decoration.js +2 -2
- package/lib/esm/extensions/markdown/italic/italic-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/link/link-decoration.js +1 -1
- package/lib/esm/extensions/markdown/link/link-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/link/link-widget.js +5 -2
- package/lib/esm/extensions/markdown/link/link-widget.js.map +1 -1
- package/lib/esm/extensions/markdown/list/list-decoration.js +1 -1
- package/lib/esm/extensions/markdown/list/list-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/markdown-decoration.js +2 -2
- package/lib/esm/extensions/markdown/markdown-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/mention/mention-decoration.js +1 -1
- package/lib/esm/extensions/markdown/mention/mention-parser.js.map +1 -1
- package/lib/esm/extensions/markdown/strike-through/strike-through-decoration.js +1 -1
- package/lib/esm/extensions/markdown/styles.module.scss.js +2 -2
- package/lib/esm/extensions/markdown/todo/todo-decoration.js +1 -1
- package/lib/esm/extensions/markdown/todo/todo-decoration.js.map +1 -1
- package/lib/esm/extensions/settings/init-settings.js +2 -2
- package/lib/esm/extensions/settings/init-settings.js.map +1 -1
- package/lib/esm/extensions/theme/themes/get-dark-theme.js +3 -2
- package/lib/esm/extensions/theme/themes/get-dark-theme.js.map +1 -1
- package/lib/esm/extensions/theme/themes/get-highlight-template.js +4 -1
- package/lib/esm/extensions/theme/themes/get-highlight-template.js.map +1 -1
- package/lib/esm/extensions/theme/themes/get-light-theme.js +3 -2
- package/lib/esm/extensions/theme/themes/get-light-theme.js.map +1 -1
- package/lib/esm/extensions/theme/themes/get-theme-template.js +3 -0
- package/lib/esm/extensions/theme/themes/get-theme-template.js.map +1 -1
- package/lib/esm/lib/utils/overlap-mark.js +5 -2
- package/lib/esm/lib/utils/overlap-mark.js.map +1 -1
- package/lib/esm/module/Editor/Editor.js +2 -6
- package/lib/esm/module/Editor/Editor.js.map +1 -1
- package/lib/esm/module/Editor/lib/init-editor-provider.js +2 -3
- package/lib/esm/module/Editor/lib/init-editor-provider.js.map +1 -1
- package/lib/esm/module/Editor/lib/init-editor.js +1 -1
- package/lib/esm/module/Editor/lib/init-editor.js.map +1 -1
- package/lib/esm/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/package.json +18 -29
- package/lib/cjs/index-Dj0jRUGF.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-decoration.js","sources":["../../../../src/extensions/markdown/markdown-decoration.ts"],"sourcesContent":["import { syntaxTree } from \"@codemirror/language\";\nimport { type Range } from \"@codemirror/state\";\nimport {\n Decoration,\n type DecorationSet,\n type EditorView,\n ViewPlugin,\n type ViewUpdate,\n} from \"@codemirror/view\";\nimport { saveDispatch } from \"@/lib/utils\";\nimport { blockquoteDecorationPlugin } from \"./blockquote\";\nimport { boldDecorationPlugin } from \"./bold\";\nimport { codeDecorationPlugin } from \"./code\";\nimport { headerDecorationPlugin } from \"./header\";\nimport { horizontalDecorationPlugin } from \"./horizontal\";\nimport { imageDecorationPlugin } from \"./image/image-decoration\";\nimport { italicDecorationPlugin } from \"./italic\";\nimport { autoLinkDecorationPlugin, linkDecorationPlugin } from \"./link\";\nimport { listDecorationPlugin } from \"./list\";\nimport type {\n DecorationPlugin,\n GetDecorationFunction,\n GetSelectionDecorationFunction,\n MarkdownDecorationSettings,\n} from \"./markdown-types\";\nimport { mentionDecorationPlugin } from \"./mention/mention-decoration\";\nimport { strikeThroughDecorationPlugin } from \"./strike-through\";\nimport { todoDecorationPlugin } from \"./todo\";\n\nconst decorationPlugins: DecorationPlugin[] = [\n blockquoteDecorationPlugin,\n boldDecorationPlugin,\n codeDecorationPlugin,\n headerDecorationPlugin,\n horizontalDecorationPlugin,\n imageDecorationPlugin,\n italicDecorationPlugin,\n linkDecorationPlugin,\n listDecorationPlugin,\n autoLinkDecorationPlugin,\n mentionDecorationPlugin,\n strikeThroughDecorationPlugin,\n todoDecorationPlugin,\n];\n\nlet decorationFunctions: GetDecorationFunction[] = [];\nlet selectionDecorationFunctions: GetSelectionDecorationFunction[] = [];\n\nfor (const plugin of decorationPlugins) {\n if (plugin.decorations) decorationFunctions = decorationFunctions.concat(plugin.decorations);\n if (plugin.selectionDecorations)\n selectionDecorationFunctions = selectionDecorationFunctions.concat(plugin.selectionDecorations);\n}\n\nconst SKIP_MARKS = new Set([\n \"Document\",\n \"Paragraph\",\n \"EmphasisMark\",\n \"Blockquote\",\n \"StrikethroughMark\",\n \"BulletList\",\n \"OrderedList\",\n \"ListItem\",\n \"LinkMark\",\n \"URL\",\n \"CodeMark\",\n \"CodeInfo\",\n \"CodeText\",\n \"HeaderMark\",\n \"TaskMarker\",\n]);\n\nfunction createDecorationsGetter(settings: MarkdownDecorationSettings) {\n let markdownDecorationsCache: Range<Decoration>[] = [];\n let markdownSelectionDecorationsCache: Range<Decoration>[] = [];\n\n function getDecorations(view: EditorView, isChanged: boolean, mouseReleased: boolean) {\n const processDecorations = isChanged;\n const processSelectionDecorations = isChanged || mouseReleased;\n const decorations: Range<Decoration>[] = processDecorations ? [] : markdownDecorationsCache;\n const selectionDecorations: Range<Decoration>[] = processSelectionDecorations\n ? []\n : markdownSelectionDecorationsCache;\n\n const contentEditable = view.contentDOM.getAttribute(\"contenteditable\");\n const isReadonly = !contentEditable || contentEditable === \"false\";\n\n for (const { from: fromVisible, to: toVisible } of view.visibleRanges) {\n syntaxTree(view.state).iterate({\n from: fromVisible,\n to: toVisible,\n enter: (node) => {\n if (SKIP_MARKS.has(node.name)) return;\n /** Decoration by change content */\n if (processDecorations)\n decorationFunctions.forEach((
|
|
1
|
+
{"version":3,"file":"markdown-decoration.js","sources":["../../../../src/extensions/markdown/markdown-decoration.ts"],"sourcesContent":["import { syntaxTree } from \"@codemirror/language\";\nimport { type Range } from \"@codemirror/state\";\nimport {\n Decoration,\n type DecorationSet,\n type EditorView,\n ViewPlugin,\n type ViewUpdate,\n} from \"@codemirror/view\";\nimport { saveDispatch } from \"@/lib/utils\";\nimport { blockquoteDecorationPlugin } from \"./blockquote\";\nimport { boldDecorationPlugin } from \"./bold\";\nimport { codeDecorationPlugin } from \"./code\";\nimport { headerDecorationPlugin } from \"./header\";\nimport { horizontalDecorationPlugin } from \"./horizontal\";\nimport { imageDecorationPlugin } from \"./image/image-decoration\";\nimport { italicDecorationPlugin } from \"./italic\";\nimport { autoLinkDecorationPlugin, linkDecorationPlugin } from \"./link\";\nimport { listDecorationPlugin } from \"./list\";\nimport type {\n DecorationPlugin,\n GetDecorationFunction,\n GetSelectionDecorationFunction,\n MarkdownDecorationSettings,\n} from \"./markdown-types\";\nimport { mentionDecorationPlugin } from \"./mention/mention-decoration\";\nimport { strikeThroughDecorationPlugin } from \"./strike-through\";\nimport { todoDecorationPlugin } from \"./todo\";\n\nconst decorationPlugins: DecorationPlugin[] = [\n blockquoteDecorationPlugin,\n boldDecorationPlugin,\n codeDecorationPlugin,\n headerDecorationPlugin,\n horizontalDecorationPlugin,\n imageDecorationPlugin,\n italicDecorationPlugin,\n linkDecorationPlugin,\n listDecorationPlugin,\n autoLinkDecorationPlugin,\n mentionDecorationPlugin,\n strikeThroughDecorationPlugin,\n todoDecorationPlugin,\n];\n\nlet decorationFunctions: GetDecorationFunction[] = [];\nlet selectionDecorationFunctions: GetSelectionDecorationFunction[] = [];\n\nfor (const plugin of decorationPlugins) {\n if (plugin.decorations) decorationFunctions = decorationFunctions.concat(plugin.decorations);\n if (plugin.selectionDecorations)\n selectionDecorationFunctions = selectionDecorationFunctions.concat(plugin.selectionDecorations);\n}\n\nconst SKIP_MARKS = new Set([\n \"Document\",\n \"Paragraph\",\n \"EmphasisMark\",\n \"Blockquote\",\n \"StrikethroughMark\",\n \"BulletList\",\n \"OrderedList\",\n \"ListItem\",\n \"LinkMark\",\n \"URL\",\n \"CodeMark\",\n \"CodeInfo\",\n \"CodeText\",\n \"HeaderMark\",\n \"TaskMarker\",\n]);\n\nfunction createDecorationsGetter(settings: MarkdownDecorationSettings) {\n let markdownDecorationsCache: Range<Decoration>[] = [];\n let markdownSelectionDecorationsCache: Range<Decoration>[] = [];\n\n function getDecorations(view: EditorView, isChanged: boolean, mouseReleased: boolean) {\n const processDecorations = isChanged;\n const processSelectionDecorations = isChanged || mouseReleased;\n const decorations: Range<Decoration>[] = processDecorations ? [] : markdownDecorationsCache;\n const selectionDecorations: Range<Decoration>[] = processSelectionDecorations\n ? []\n : markdownSelectionDecorationsCache;\n\n const contentEditable = view.contentDOM.getAttribute(\"contenteditable\");\n const isReadonly = !contentEditable || contentEditable === \"false\";\n\n for (const { from: fromVisible, to: toVisible } of view.visibleRanges) {\n syntaxTree(view.state).iterate({\n from: fromVisible,\n to: toVisible,\n enter: (node) => {\n if (SKIP_MARKS.has(node.name)) return;\n /** Decoration by change content */\n if (processDecorations)\n decorationFunctions.forEach((funk) => funk({ decorations, node, view, settings }));\n\n /** Decoration by selection content */\n if (processSelectionDecorations)\n selectionDecorationFunctions.forEach((funk) =>\n funk({\n decorations: selectionDecorations,\n node,\n view,\n forceActive: isReadonly,\n settings,\n }),\n );\n },\n });\n }\n\n if (processDecorations) {\n markdownDecorationsCache = decorations;\n }\n if (processSelectionDecorations) {\n markdownSelectionDecorationsCache = selectionDecorations;\n }\n\n return Decoration.set([...decorations, ...selectionDecorations], true);\n }\n\n return getDecorations;\n}\n\nexport const markdownDecorationPlugin = (settings: MarkdownDecorationSettings) => {\n return ViewPlugin.fromClass(\n class DecorationMarkdown {\n decorations: DecorationSet;\n\n mouseReleased: boolean = true;\n\n dom: HTMLElement;\n\n view: EditorView;\n\n decorationGetter: (\n view: EditorView,\n isChanged: boolean,\n mouseReleased: boolean,\n ) => DecorationSet;\n\n constructor(view: EditorView) {\n this.decorationGetter = createDecorationsGetter(settings);\n this.decorations = this.decorationGetter(view, true, this.mouseReleased);\n this.dom = view.dom;\n this.view = view;\n document.addEventListener(\"mousedown\", this.onMouseDown.bind(this));\n document.addEventListener(\"mouseup\", this.onMouseUp.bind(this));\n }\n\n update(update: ViewUpdate) {\n const isDocumentChanged =\n update.docChanged ||\n update.viewportChanged ||\n syntaxTree(update.startState) != syntaxTree(update.state);\n this.decorations = this.decorationGetter(\n update.view,\n isDocumentChanged,\n this.mouseReleased,\n );\n }\n\n destroy() {\n document.removeEventListener(\"mousedown\", this.onMouseDown.bind(this));\n document.removeEventListener(\"mouseup\", this.onMouseUp.bind(this));\n }\n\n onMouseDown(this: DecorationMarkdown) {\n this.mouseReleased = false;\n }\n\n onMouseUp(this: DecorationMarkdown) {\n this.mouseReleased = true;\n if (this.view.state.selection.ranges[0].from !== this.view.state.selection.ranges[0].to) {\n saveDispatch(() => {\n this.view.dispatch(this.view.state.update({}));\n });\n }\n }\n },\n {\n decorations: (plugin) => plugin.decorations,\n },\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,MAAM,iBAAiB,GAAuB;IAC5C,0BAA0B;IAC1B,oBAAoB;IACpB,oBAAoB;IACpB,sBAAsB;IACtB,0BAA0B;IAC1B,qBAAqB;IACrB,sBAAsB;IACtB,oBAAoB;IACpB,oBAAoB;IACpB,wBAAwB;IACxB,uBAAuB;IACvB,6BAA6B;IAC7B,oBAAoB;CACrB;AAED,IAAI,mBAAmB,GAA4B,EAAE;AACrD,IAAI,4BAA4B,GAAqC,EAAE;AAEvE,KAAK,MAAM,MAAM,IAAI,iBAAiB,EAAE;IACtC,IAAI,MAAM,CAAC,WAAW;QAAE,mBAAmB,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;IAC5F,IAAI,MAAM,CAAC,oBAAoB;QAC7B,4BAA4B,GAAG,4BAA4B,CAAC,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC;AACnG;AAEA,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,UAAU;IACV,WAAW;IACX,cAAc;IACd,YAAY;IACZ,mBAAmB;IACnB,YAAY;IACZ,aAAa;IACb,UAAU;IACV,UAAU;IACV,KAAK;IACL,UAAU;IACV,UAAU;IACV,UAAU;IACV,YAAY;IACZ,YAAY;AACb,CAAA,CAAC;AAEF,SAAS,uBAAuB,CAAC,QAAoC,EAAA;IACnE,IAAI,wBAAwB,GAAwB,EAAE;IACtD,IAAI,iCAAiC,GAAw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AAiB,EACjB,IAAI,CAAC,aAAa,CACnB;;QAGH,OAAO,GAAA;AACL,YAAA,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACtE,YAAA,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;QAGpE,WAAW,GAAA;AACT,YAAA,IAAI,CAAC,aAAa,GAAG,KAAK;;QAG5B,SAAS,GAAA;AACP,YAAA,IAAI,CAAC,aAAa,GAAG,IAAI;AACzB,YAAA,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;gBACvF,YAAY,CAAC,MAAK;AAChB,oBAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAChD,iBAAC,CAAC;;;KAGP,EACD;QACE,WAAW,EAAE,CAAC,MAAM,KAAK,MAAM,CAAC,WAAW;AAC5C,KAAA,CACF;AACH;;;;"}
|
|
@@ -4,7 +4,7 @@ import '../../compartments/index.js';
|
|
|
4
4
|
import '@codemirror/language';
|
|
5
5
|
import '@lezer/highlight';
|
|
6
6
|
import { CLASSES } from '../../theme/theme-constants.js';
|
|
7
|
-
import {
|
|
7
|
+
import { getHideDecoration, getMarkDecoration } from '../../../lib/utils/get-decoration.js';
|
|
8
8
|
import { isInRange } from '../../../lib/utils/is-in-range.js';
|
|
9
9
|
import styles from '../styles.module.scss.js';
|
|
10
10
|
import { NAME_OF_MENTION } from './mention-constants.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mention-parser.js","sources":["../../../../../src/extensions/markdown/mention/mention-parser.ts"],"sourcesContent":["import type { MarkdownConfig } from \"@lezer/markdown\";\nimport {\n CODE_OF_LINE_BREAK,\n CODE_OF_SPACE,\n CODE_OF_START_MENTION,\n NAME_OF_MENTION,\n} from \"./mention-constants\";\n\nexport const mentionParser: MarkdownConfig = {\n defineNodes: [{ name: NAME_OF_MENTION }],\n parseInline: [\n {\n name: NAME_OF_MENTION,\n parse(cx, code, pos) {\n if (code != CODE_OF_START_MENTION) return -1;\n const nextCode = cx.char(pos + 1);\n if (nextCode === -1 || nextCode === CODE_OF_SPACE || nextCode === CODE_OF_LINE_BREAK)\n return -1;\n\n let end: number = pos + 1;\n for (let i = pos + 1; i < cx.end; i++) {\n const nextCode = cx.char(i);\n if (nextCode === -1 || nextCode === CODE_OF_SPACE || nextCode === CODE_OF_LINE_BREAK)\n break;\n end++;\n }\n\n return cx.addElement(cx.elt(NAME_OF_MENTION, pos, end));\n },\n },\n ],\n};\n"],"names":[],"mappings":";;AAQa,MAAA,aAAa,GAAmB;AAC3C,IAAA,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;AACxC,IAAA,WAAW,EAAE;AACX,QAAA;AACE,YAAA,IAAI,EAAE,eAAe;AACrB,YAAA,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,EAAA;gBACjB,IAAI,IAAI,IAAI,qBAAqB;oBAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"mention-parser.js","sources":["../../../../../src/extensions/markdown/mention/mention-parser.ts"],"sourcesContent":["import type { MarkdownConfig } from \"@lezer/markdown\";\nimport {\n CODE_OF_LINE_BREAK,\n CODE_OF_SPACE,\n CODE_OF_START_MENTION,\n NAME_OF_MENTION,\n} from \"./mention-constants\";\n\nexport const mentionParser: MarkdownConfig = {\n defineNodes: [{ name: NAME_OF_MENTION }],\n parseInline: [\n {\n name: NAME_OF_MENTION,\n parse(cx, code, pos) {\n if (code != CODE_OF_START_MENTION) return -1;\n const nextCode = cx.char(pos + 1);\n if (nextCode === -1 || nextCode === CODE_OF_SPACE || nextCode === CODE_OF_LINE_BREAK)\n return -1;\n\n let end: number = pos + 1;\n for (let i = pos + 1; i < cx.end; i++) {\n const nextCode = cx.char(i);\n if (nextCode === -1 || nextCode === CODE_OF_SPACE || nextCode === CODE_OF_LINE_BREAK)\n break;\n end++;\n }\n\n return cx.addElement(cx.elt(NAME_OF_MENTION, pos, end));\n },\n },\n ],\n};\n"],"names":[],"mappings":";;AAQa,MAAA,aAAa,GAAmB;AAC3C,IAAA,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;AACxC,IAAA,WAAW,EAAE;AACX,QAAA;AACE,YAAA,IAAI,EAAE,eAAe;AACrB,YAAA,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,EAAA;gBACjB,IAAI,IAAI,IAAI,qBAAqB;oBAAE,OAAO,EAAE;gBAC5C,MAAM,QAAQ,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;gBACjC,IAAI,QAAQ,KAAK,EAAE,IAAI,QAAQ,KAAK,aAAa,IAAI,QAAQ,KAAK,kBAAkB;oBAClF,OAAO,EAAE;AAEX,gBAAA,IAAI,GAAG,GAAW,GAAG,GAAG,CAAC;AACzB,gBAAA,KAAK,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;oBACrC,MAAM,QAAQ,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;oBAC3B,IAAI,QAAQ,KAAK,EAAE,IAAI,QAAQ,KAAK,aAAa,IAAI,QAAQ,KAAK,kBAAkB;wBAClF;AACF,oBAAA,GAAG,EAAE;;AAGP,gBAAA,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,eAAe,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;aACxD;AACF,SAAA;AACF,KAAA;;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getHideDecoration, getMarkDecoration } from '../../../lib/utils/get-decoration.js';
|
|
2
2
|
import { isInRange } from '../../../lib/utils/is-in-range.js';
|
|
3
3
|
import styles from '../styles.module.scss.js';
|
|
4
4
|
import { NAME_OF_STRIKE_THROUGH } from './strike-through-constants.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styleInject from '../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js';
|
|
2
2
|
|
|
3
|
-
var css_248z = "._header_XFwV5{font-weight:700}._header_XFwV5._level_1_-KPph{font-size:2em}._header_XFwV5._level_2_ecHlB{font-size:1.8em}._header_XFwV5._level_3_SYcVr{font-size:1.6em}._header_XFwV5._level_4_V3o5m{font-size:1.4em}._header_XFwV5._level_5_I7eVk{font-size:1.3em}._header_XFwV5._level_6_A3lbK{font-size:1.2em}._bold_I8DT-{font-weight:700}._italic_72qBe{font-style:italic}._blockquote_Xq6O4{border-left:3px solid;margin-left:5px}._blockquote__inner_mjT0h{margin-left:1px;padding-left:5px;position:relative}._blockquote__inner_mjT0h:before{border-left:3px solid;content:\"\";height:140%;left:0;position:absolute;top:-3px}._blockquote__inner-deep_s6tNj{margin-left:5px}._strike-through_U64jP{text-decoration:line-through}._list_MHIjT._common_0GdDi{position:relative;visibility:hidden}._list_MHIjT._common_0GdDi:after{border-radius:100%;content:\"\";height:5px;left:0;position:absolute;top:50%;transform:translateY(-50%);visibility:visible;width:5px}._link_7U9wl{text-decoration:none;text-decoration:underline}._link__label_dHGGf{font-size:12px;position:relative;top:-4px}._image_KmBM8{display:inline-flex}._code__line_m3IiO{padding:5px;position:relative}.
|
|
4
|
-
const styles = {"header":"_header_XFwV5","level_1":"_level_1_-KPph","level_2":"_level_2_ecHlB","level_3":"_level_3_SYcVr","level_4":"_level_4_V3o5m","level_5":"_level_5_I7eVk","level_6":"_level_6_A3lbK","bold":"_bold_I8DT-","italic":"_italic_72qBe","blockquote":"_blockquote_Xq6O4","blockquote__inner":"_blockquote__inner_mjT0h","blockquote__inner-deep":"_blockquote__inner-deep_s6tNj","strike-through":"_strike-through_U64jP","list":"_list_MHIjT","common":"_common_0GdDi","link":"_link_7U9wl","link__label":"_link__label_dHGGf","image":"_image_KmBM8","code__line":"_code__line_m3IiO","
|
|
3
|
+
var css_248z = "._header_XFwV5{font-weight:700}._header_XFwV5._level_1_-KPph{font-size:2em}._header_XFwV5._level_2_ecHlB{font-size:1.8em}._header_XFwV5._level_3_SYcVr{font-size:1.6em}._header_XFwV5._level_4_V3o5m{font-size:1.4em}._header_XFwV5._level_5_I7eVk{font-size:1.3em}._header_XFwV5._level_6_A3lbK{font-size:1.2em}._bold_I8DT-{font-weight:700}._italic_72qBe{font-style:italic}._blockquote_Xq6O4{border-left:3px solid;margin-left:5px}._blockquote__inner_mjT0h{margin-left:1px;padding-left:5px;position:relative}._blockquote__inner_mjT0h:before{border-left:3px solid;content:\"\";height:140%;left:0;position:absolute;top:-3px}._blockquote__inner-deep_s6tNj{margin-left:5px}._strike-through_U64jP{text-decoration:line-through}._list_MHIjT._common_0GdDi{position:relative;visibility:hidden}._list_MHIjT._common_0GdDi:after{border-radius:100%;content:\"\";height:5px;left:0;position:absolute;top:50%;transform:translateY(-50%);visibility:visible;width:5px}._link_7U9wl{text-decoration:none;text-decoration:underline}._link__label_dHGGf{font-size:12px;position:relative;top:-4px}._image_KmBM8{display:inline-flex}._code__line_m3IiO{padding:5px;position:relative}._code__button_WwYE-{background-color:transparent;border:none;border-radius:4px;box-shadow:none;cursor:pointer;min-width:30px;outline:none;padding:4px 10px;position:absolute;right:5px;top:5px;transition:all .3s ease;z-index:1}._code__button_WwYE-._pending_fgHgD:before{animation:_loading-btn--fade-in_8z5an .33s ease,_loading-btn--rotation_QaopN .66s linear 0s infinite;border:2px solid hsla(0,0%,100%,.33);border-radius:50%;border-top-color:#000;content:\"\";display:inline-block;height:10.5px;left:50%;position:absolute;top:50%;width:10.5px}._code__button_WwYE-._success_kUPnO:after{animation:_loading-btn--fade-in_8z5an .6s ease;border-color:currentcolor;border-style:solid;border-width:0 0 1px 1px;content:\"\";display:inline-block;height:7px;left:50%;position:absolute;top:50%;transform:translate(-50%,-75%) rotate(-45deg);width:11px}._code__button_WwYE-._fail_cOpap:after,._code__button_WwYE-._fail_cOpap:before{content:\" \";height:13px;left:50%;position:absolute;top:50%;width:1px}._code__button_WwYE-._fail_cOpap:before{transform:translate(-50%,-50%) rotate(45deg)}._code__button_WwYE-._fail_cOpap:after{transform:translate(-50%,-50%) rotate(-45deg)}@keyframes _loading-btn--fade-in_8z5an{0%{opacity:0}to{opacity:1}}@keyframes _loading-btn--rotation_QaopN{0%{transform:translate(-50%,-50%) rotate(0deg)}to{transform:translate(-50%,-50%) rotate(1turn)}}._code__span_iSCmj{opacity:1;transition:opacity .3s ease}._code__span_iSCmj._hide_uqpax{opacity:0}._code__block_JehA4{padding:1px 5px}._code__block_line_U7lcQ{border-left:1px solid;margin-left:5px}._horizontal_J1jU-{border-bottom:1px solid;margin:0 5px;position:relative;width:calc(100% - 10px)}._todo_m6MIP{align-items:flex-end;display:inline-flex;height:100%;padding-left:3px;padding-right:3px}._todo_m6MIP>input{margin:0}._todo__checked_kemjy{text-decoration:line-through}._mention_cpzik{font-weight:700}";
|
|
4
|
+
const styles = {"header":"_header_XFwV5","level_1":"_level_1_-KPph","level_2":"_level_2_ecHlB","level_3":"_level_3_SYcVr","level_4":"_level_4_V3o5m","level_5":"_level_5_I7eVk","level_6":"_level_6_A3lbK","bold":"_bold_I8DT-","italic":"_italic_72qBe","blockquote":"_blockquote_Xq6O4","blockquote__inner":"_blockquote__inner_mjT0h","blockquote__inner-deep":"_blockquote__inner-deep_s6tNj","strike-through":"_strike-through_U64jP","list":"_list_MHIjT","common":"_common_0GdDi","link":"_link_7U9wl","link__label":"_link__label_dHGGf","image":"_image_KmBM8","code__line":"_code__line_m3IiO","code__button":"_code__button_WwYE-","pending":"_pending_fgHgD","loading-btn--fade-in":"_loading-btn--fade-in_8z5an","loading-btn--rotation":"_loading-btn--rotation_QaopN","success":"_success_kUPnO","fail":"_fail_cOpap","code__span":"_code__span_iSCmj","hide":"_hide_uqpax","code__block":"_code__block_JehA4","code__block_line":"_code__block_line_U7lcQ","horizontal":"_horizontal_J1jU-","todo":"_todo_m6MIP","todo__checked":"_todo__checked_kemjy","mention":"_mention_cpzik"};
|
|
5
5
|
styleInject(css_248z);
|
|
6
6
|
|
|
7
7
|
export { styles as default };
|
|
@@ -10,7 +10,7 @@ function getTodoSelectionDecoration({ decorations, node, view, forceActive, }) {
|
|
|
10
10
|
const prevSibling = node.node.prevSibling;
|
|
11
11
|
if (!prevSibling || prevSibling.name !== NAME_OF_LIST_MARK)
|
|
12
12
|
return;
|
|
13
|
-
const isChecked = LIST_OF_TODO_MARKS.has(view.state.doc.sliceString(node.from + 1, node.from + 2).codePointAt(0)
|
|
13
|
+
const isChecked = LIST_OF_TODO_MARKS.has(view.state.doc.sliceString(node.from + 1, node.from + 2).codePointAt(0) ?? 0);
|
|
14
14
|
if (forceActive ||
|
|
15
15
|
!view.hasFocus ||
|
|
16
16
|
!isInRange(view.state.selection.ranges, [prevSibling.from, node.from + 3])) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"todo-decoration.js","sources":["../../../../../src/extensions/markdown/todo/todo-decoration.ts"],"sourcesContent":["import { utils } from \"@/lib\";\nimport type { DecorationPlugin, GetSelectionDecorationOptions } from \"../markdown-types\";\nimport styles from \"../styles.module.scss\";\nimport { LIST_OF_TODO_MARKS, NAME_OF_LIST_MARK, NAME_OF_TODO } from \"./todo-constants\";\nimport { TodoWidget } from \"./todo-widget\";\n\nfunction getTodoSelectionDecoration({\n decorations,\n node,\n view,\n forceActive,\n}: GetSelectionDecorationOptions) {\n if (node.name !== NAME_OF_TODO) return;\n\n const prevSibling = node.node.prevSibling;\n if (!prevSibling || prevSibling.name !== NAME_OF_LIST_MARK) return;\n\n const isChecked = LIST_OF_TODO_MARKS.has(\n view.state.doc.sliceString(node.from + 1, node.from + 2).codePointAt(0)
|
|
1
|
+
{"version":3,"file":"todo-decoration.js","sources":["../../../../../src/extensions/markdown/todo/todo-decoration.ts"],"sourcesContent":["import { utils } from \"@/lib\";\nimport type { DecorationPlugin, GetSelectionDecorationOptions } from \"../markdown-types\";\nimport styles from \"../styles.module.scss\";\nimport { LIST_OF_TODO_MARKS, NAME_OF_LIST_MARK, NAME_OF_TODO } from \"./todo-constants\";\nimport { TodoWidget } from \"./todo-widget\";\n\nfunction getTodoSelectionDecoration({\n decorations,\n node,\n view,\n forceActive,\n}: GetSelectionDecorationOptions) {\n if (node.name !== NAME_OF_TODO) return;\n\n const prevSibling = node.node.prevSibling;\n if (!prevSibling || prevSibling.name !== NAME_OF_LIST_MARK) return;\n\n const isChecked = LIST_OF_TODO_MARKS.has(\n view.state.doc.sliceString(node.from + 1, node.from + 2).codePointAt(0) ?? 0,\n );\n\n if (\n forceActive ||\n !view.hasFocus ||\n !utils.isInRange(view.state.selection.ranges, [prevSibling.from, node.from + 3])\n ) {\n decorations.push(\n utils.getReplaceDecoration({\n range: [node.from, node.from + 3],\n widget: new TodoWidget(isChecked, node.from + 1),\n }),\n );\n }\n\n if (isChecked) {\n const line = view.lineBlockAt(node.from);\n\n if (\n forceActive ||\n !view.hasFocus ||\n !utils.isInRange(view.state.selection.ranges, [line.from, line.to])\n )\n decorations.push(\n utils.getMarkDecoration({ style: styles.todo__checked, range: [node.from + 4, node.to] }),\n );\n }\n}\n\nexport const todoDecorationPlugin: DecorationPlugin = {\n selectionDecorations: [getTodoSelectionDecoration],\n};\n"],"names":["utils.isInRange","utils.getReplaceDecoration","utils.getMarkDecoration"],"mappings":";;;;;;AAMA,SAAS,0BAA0B,CAAC,EAClC,WAAW,EACX,IAAI,EACJ,IAAI,EACJ,WAAW,GACmB,EAAA;AAC9B,IAAA,IAAI,IAAI,CAAC,IAAI,KA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AAG,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAC1F;;AAEP;AAEa,MAAA,oBAAoB,GAAqB;IACpD,oBAAoB,EAAE,CAAC,0BAA0B,CAAC;;;;;"}
|
|
@@ -3,7 +3,7 @@ import '@codemirror/state';
|
|
|
3
3
|
import { drawSelection, EditorView } from '@codemirror/view';
|
|
4
4
|
import { ReadonlyCompartment, VimModeCompartment } from '../compartments/index.js';
|
|
5
5
|
|
|
6
|
-
async function
|
|
6
|
+
async function initSettings({ readonly, vimMode, }) {
|
|
7
7
|
let vimExtension = [];
|
|
8
8
|
if (vimMode) {
|
|
9
9
|
const { vim } = await import('@replit/codemirror-vim');
|
|
@@ -16,5 +16,5 @@ async function InitSettings({ readonly, vimMode, }) {
|
|
|
16
16
|
];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export {
|
|
19
|
+
export { initSettings };
|
|
20
20
|
//# sourceMappingURL=init-settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-settings.js","sources":["../../../../src/extensions/settings/init-settings.ts"],"sourcesContent":["import { history } from \"@codemirror/commands\";\nimport { type Extension } from \"@codemirror/state\";\nimport { EditorView, drawSelection } from \"@codemirror/view\";\nimport { ReadonlyCompartment, VimModeCompartment } from \"../compartments\";\n\nexport type InitSettingsOptions = {\n readonly?: boolean;\n vimMode?: boolean;\n};\n\nexport async function
|
|
1
|
+
{"version":3,"file":"init-settings.js","sources":["../../../../src/extensions/settings/init-settings.ts"],"sourcesContent":["import { history } from \"@codemirror/commands\";\nimport { type Extension } from \"@codemirror/state\";\nimport { EditorView, drawSelection } from \"@codemirror/view\";\nimport { ReadonlyCompartment, VimModeCompartment } from \"../compartments\";\n\nexport type InitSettingsOptions = {\n readonly?: boolean;\n vimMode?: boolean;\n};\n\nexport async function initSettings({\n readonly,\n vimMode,\n}: InitSettingsOptions): Promise<Extension[]> {\n let vimExtension: Extension = [];\n if (vimMode) {\n const { vim } = await import(\"@replit/codemirror-vim\");\n vimExtension = [vim({ status: true }), drawSelection()];\n }\n\n return [\n ReadonlyCompartment.of(EditorView.editable.of(!readonly)),\n VimModeCompartment.of(vimExtension),\n history(),\n ];\n}\n"],"names":[],"mappings":";;;;;AAUO,eAAe,YAAY,CAAC,EACjC,QAAQ,EACR,OAAO,GACa,EAAA;IACpB,IAAI,YAAY,GAAc,EAAE;IAChC,IAAI,OAAO,EAAE;QACX,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,OAAO,wBAAwB,CAAC;AACtD,QAAA,YAAY,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC;;IAGzD,OAAO;AACL,QAAA,mBAAmB,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;AACzD,QAAA,kBAAkB,CAAC,EAAE,CAAC,YAAY,CAAC;AACnC,QAAA,OAAO,EAAE;KACV;AACH;;;;"}
|
|
@@ -24,6 +24,7 @@ const THEME_CONFIG = {
|
|
|
24
24
|
codeColor: "#DDDDDD",
|
|
25
25
|
color: "#DDDDDD",
|
|
26
26
|
fontFamily: "Montserrat",
|
|
27
|
+
codeFontFamily: "Consolas",
|
|
27
28
|
horizontalColor: "#DDDDDD",
|
|
28
29
|
linkColor: "#8A5CF5",
|
|
29
30
|
mentionColor: "#8A5CF5",
|
|
@@ -33,8 +34,8 @@ const THEME_CONFIG = {
|
|
|
33
34
|
codeBlockBackground: "#24292e",
|
|
34
35
|
};
|
|
35
36
|
function getDarkTheme({ dark }) {
|
|
36
|
-
const highlightConfig = { ...HIGHLIGHT_CONFIG, ...(dark?.highlightConfig
|
|
37
|
-
const themeConfig = { ...THEME_CONFIG, ...(dark?.themeConfig
|
|
37
|
+
const highlightConfig = { ...HIGHLIGHT_CONFIG, ...(dark?.highlightConfig ?? {}) };
|
|
38
|
+
const themeConfig = { ...THEME_CONFIG, ...(dark?.themeConfig ?? {}) };
|
|
38
39
|
return [getThemeTemplate(true, themeConfig), getHighlightTemplate(highlightConfig)];
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-dark-theme.js","sources":["../../../../../src/extensions/theme/themes/get-dark-theme.ts"],"sourcesContent":["import { type HighlightConfig, type InitThemeOptions, type ThemeConfig } from \"../theme-types\";\nimport { getHighlightTemplate } from \"./get-highlight-template\";\nimport { getThemeTemplate } from \"./get-theme-template\";\n\nconst HIGHLIGHT_CONFIG: Required<HighlightConfig> = {\n keyword: \"#f97583\",\n variable: \"#ffab70\",\n function: \"#79b8ff\",\n string: \"#9ecbff\",\n constant: \"#79b8ff\",\n type: \"#79b8ff\",\n class: \"#b392f0\",\n number: \"#79b8ff\",\n comment: \"#6a737d\",\n heading: \"#79b8ff\",\n invalid: \"#f97583\",\n regexp: \"#9ecbff\",\n};\n\nconst THEME_CONFIG: Required<ThemeConfig> = {\n background: \"#2E3235\",\n blockquoteColor: \"#8A5CF5\", // #6A8695\n codeBackground: \"#24292e\",\n codeButtonBackground: \"#434C54FF\",\n codeButtonColor: \"#DDDDDD\",\n codeColor: \"#DDDDDD\",\n color: \"#DDDDDD\",\n fontFamily: \"Montserrat\",\n horizontalColor: \"#DDDDDD\",\n linkColor: \"#8A5CF5\",\n mentionColor: \"#8A5CF5\",\n vimSelection: \"#1A1919FF\",\n vimSelectionFocused: \"#2E4B4BFF\",\n codeBlockBorderColor: \"#7b7e81\",\n codeBlockBackground: \"#24292e\",\n};\n\nexport function getDarkTheme({ dark }: InitThemeOptions) {\n const highlightConfig = { ...HIGHLIGHT_CONFIG, ...(dark?.highlightConfig
|
|
1
|
+
{"version":3,"file":"get-dark-theme.js","sources":["../../../../../src/extensions/theme/themes/get-dark-theme.ts"],"sourcesContent":["import { type HighlightConfig, type InitThemeOptions, type ThemeConfig } from \"../theme-types\";\nimport { getHighlightTemplate } from \"./get-highlight-template\";\nimport { getThemeTemplate } from \"./get-theme-template\";\n\nconst HIGHLIGHT_CONFIG: Required<HighlightConfig> = {\n keyword: \"#f97583\",\n variable: \"#ffab70\",\n function: \"#79b8ff\",\n string: \"#9ecbff\",\n constant: \"#79b8ff\",\n type: \"#79b8ff\",\n class: \"#b392f0\",\n number: \"#79b8ff\",\n comment: \"#6a737d\",\n heading: \"#79b8ff\",\n invalid: \"#f97583\",\n regexp: \"#9ecbff\",\n};\n\nconst THEME_CONFIG: Required<ThemeConfig> = {\n background: \"#2E3235\",\n blockquoteColor: \"#8A5CF5\", // #6A8695\n codeBackground: \"#24292e\",\n codeButtonBackground: \"#434C54FF\",\n codeButtonColor: \"#DDDDDD\",\n codeColor: \"#DDDDDD\",\n color: \"#DDDDDD\",\n fontFamily: \"Montserrat\",\n codeFontFamily: \"Consolas\",\n horizontalColor: \"#DDDDDD\",\n linkColor: \"#8A5CF5\",\n mentionColor: \"#8A5CF5\",\n vimSelection: \"#1A1919FF\",\n vimSelectionFocused: \"#2E4B4BFF\",\n codeBlockBorderColor: \"#7b7e81\",\n codeBlockBackground: \"#24292e\",\n};\n\nexport function getDarkTheme({ dark }: InitThemeOptions) {\n const highlightConfig = { ...HIGHLIGHT_CONFIG, ...(dark?.highlightConfig ?? {}) };\n const themeConfig = { ...THEME_CONFIG, ...(dark?.themeConfig ?? {}) };\n\n return [getThemeTemplate(true, themeConfig), getHighlightTemplate(highlightConfig)];\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,gBAAgB,GAA8B;AAClD,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,QAAQ,EAAE,SAAS;AACnB,IAAA,QAAQ,EAAE,SAAS;AACnB,IAAA,MAAM,EAAE,SAAS;AACjB,IAAA,QAAQ,EAAE,SAAS;AACnB,IAAA,IAAI,EAAE,SAAS;AACf,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,MAAM,EAAE,SAAS;AACjB,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,MAAM,EAAE,SAAS;CAClB;AAED,MAAM,YAAY,GAA0B;AAC1C,IAAA,UAAU,EAAE,SAAS;IACrB,eAAe,EAAE,SAAS;AAC1B,IAAA,cAAc,EAAE,SAAS;AACzB,IAAA,oBAAoB,EAAE,WAAW;AACjC,IAAA,eAAe,EAAE,SAAS;AAC1B,IAAA,SAAS,EAAE,SAAS;AACpB,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,UAAU,EAAE,YAAY;AACxB,IAAA,cAAc,EAAE,UAAU;AAC1B,IAAA,eAAe,EAAE,SAAS;AAC1B,IAAA,SAAS,EAAE,SAAS;AACpB,IAAA,YAAY,EAAE,SAAS;AACvB,IAAA,YAAY,EAAE,WAAW;AACzB,IAAA,mBAAmB,EAAE,WAAW;AAChC,IAAA,oBAAoB,EAAE,SAAS;AAC/B,IAAA,mBAAmB,EAAE,SAAS;CAC/B;AAEe,SAAA,YAAY,CAAC,EAAE,IAAI,EAAoB,EAAA;AACrD,IAAA,MAAM,eAAe,GAAG,EAAE,GAAG,gBAAgB,EAAE,IAAI,IAAI,EAAE,eAAe,IAAI,EAAE,CAAC,EAAE;AACjF,IAAA,MAAM,WAAW,GAAG,EAAE,GAAG,YAAY,EAAE,IAAI,IAAI,EAAE,WAAW,IAAI,EAAE,CAAC,EAAE;AAErE,IAAA,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,oBAAoB,CAAC,eAAe,CAAC,CAAC;AACrF;;;;"}
|
|
@@ -15,7 +15,10 @@ function getHighlightTemplate(config) {
|
|
|
15
15
|
color: config.string,
|
|
16
16
|
},
|
|
17
17
|
{ tag: [tags.function(tags.variableName), tags.labelName], color: config.function },
|
|
18
|
-
{
|
|
18
|
+
{
|
|
19
|
+
tag: [tags.color, tags.constant(tags.name), tags.standard(tags.name)],
|
|
20
|
+
color: config.constant,
|
|
21
|
+
},
|
|
19
22
|
{ tag: [tags.definition(tags.name), tags.separator], color: config.variable },
|
|
20
23
|
{ tag: [tags.className], color: config.class },
|
|
21
24
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-highlight-template.js","sources":["../../../../../src/extensions/theme/themes/get-highlight-template.ts"],"sourcesContent":["import { HighlightStyle, syntaxHighlighting } from \"@codemirror/language\";\nimport { tags
|
|
1
|
+
{"version":3,"file":"get-highlight-template.js","sources":["../../../../../src/extensions/theme/themes/get-highlight-template.ts"],"sourcesContent":["import { HighlightStyle, syntaxHighlighting } from \"@codemirror/language\";\nimport { tags } from \"@lezer/highlight\";\nimport type { HighlightConfig } from \"../theme-types\";\n\n/**\n * t.processingInstruction, t.meta - # () []\n * t.url, t.link - links\n */\n\nexport function getHighlightTemplate(config: Required<HighlightConfig>) {\n return syntaxHighlighting(\n HighlightStyle.define([\n { tag: tags.keyword, color: config.keyword },\n { tag: [tags.name, tags.deleted, tags.character, tags.macroName], color: config.variable },\n { tag: [tags.propertyName], color: config.function },\n {\n tag: [tags.string, tags.inserted, tags.special(tags.string)],\n color: config.string,\n },\n { tag: [tags.function(tags.variableName), tags.labelName], color: config.function },\n {\n tag: [tags.color, tags.constant(tags.name), tags.standard(tags.name)],\n color: config.constant,\n },\n { tag: [tags.definition(tags.name), tags.separator], color: config.variable },\n { tag: [tags.className], color: config.class },\n {\n tag: [tags.number, tags.changed, tags.annotation, tags.modifier, tags.self, tags.namespace],\n color: config.number,\n },\n { tag: [tags.typeName], color: config.type, fontStyle: config.type },\n { tag: [tags.operator, tags.operatorKeyword], color: config.keyword },\n { tag: [tags.escape, tags.regexp], color: config.regexp },\n { tag: [tags.comment], color: config.comment },\n { tag: [tags.atom, tags.bool, tags.special(tags.variableName)], color: config.variable },\n { tag: tags.invalid, color: config.invalid },\n ]),\n );\n}\n"],"names":[],"mappings":";;;AAIA;;;AAGG;AAEG,SAAU,oBAAoB,CAAC,MAAiC,EAAA;AACpE,IAAA,OAAO,kBAAkB,CACvB,cAAc,CAA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I,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YAC3F,KAAK,EAAE,MAAM,CAAC,MAAM;AACrB,SAAA;AACD,QAAA,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE;AACpE,QAAA,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE;AACrE,QAAA,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;AACzD,QAAA,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE;QAC9C,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE;QACxF,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE;AAC7C,KAAA,CAAC,CACH;AACH;;;;"}
|
|
@@ -24,6 +24,7 @@ const THEME_CONFIG = {
|
|
|
24
24
|
codeColor: "#000000",
|
|
25
25
|
color: "#000000",
|
|
26
26
|
fontFamily: "Montserrat",
|
|
27
|
+
codeFontFamily: "Consolas",
|
|
27
28
|
horizontalColor: "#000000",
|
|
28
29
|
linkColor: "#8A5CF5",
|
|
29
30
|
mentionColor: "#8A5CF5",
|
|
@@ -33,8 +34,8 @@ const THEME_CONFIG = {
|
|
|
33
34
|
codeBlockBorderColor: "##CCCCCDFF",
|
|
34
35
|
};
|
|
35
36
|
function getLightTheme({ light }) {
|
|
36
|
-
const highlightConfig = { ...HIGHLIGHT_CONFIG, ...(light?.highlightConfig
|
|
37
|
-
const themeConfig = { ...THEME_CONFIG, ...(light?.themeConfig
|
|
37
|
+
const highlightConfig = { ...HIGHLIGHT_CONFIG, ...(light?.highlightConfig ?? {}) };
|
|
38
|
+
const themeConfig = { ...THEME_CONFIG, ...(light?.themeConfig ?? {}) };
|
|
38
39
|
return [getThemeTemplate(false, themeConfig), getHighlightTemplate(highlightConfig)];
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-light-theme.js","sources":["../../../../../src/extensions/theme/themes/get-light-theme.ts"],"sourcesContent":["import { type HighlightConfig, type InitThemeOptions, type ThemeConfig } from \"../theme-types\";\nimport { getHighlightTemplate } from \"./get-highlight-template\";\nimport { getThemeTemplate } from \"./get-theme-template\";\n\nconst HIGHLIGHT_CONFIG: Required<HighlightConfig> = {\n keyword: \"#9854f1\",\n variable: \"#3760bf\",\n function: \"#2e7de9\",\n string: \"#587539\",\n constant: \"#9854f1\",\n type: \"#07879d\",\n class: \"#3760bf\",\n number: \"#b15c00\",\n comment: \"#9da3c2\",\n heading: \"#006a83\",\n invalid: \"#ff3e64\",\n regexp: \"#2e5857\",\n};\n\nconst THEME_CONFIG: Required<ThemeConfig> = {\n background: \"transparent\",\n blockquoteColor: \"#8A5CF5\", // #6A8695\n codeBackground: \"#e1e2e7\",\n codeButtonBackground: \"#CCCCCDFF\",\n codeButtonColor: \"#000000\",\n codeColor: \"#000000\",\n color: \"#000000\",\n fontFamily: \"Montserrat\",\n horizontalColor: \"#000000\",\n linkColor: \"#8A5CF5\",\n mentionColor: \"#8A5CF5\",\n vimSelection: \"#d9d9d9\",\n vimSelectionFocused: \"#d7d4f0\",\n codeBlockBackground: \"#e1e2e7\",\n codeBlockBorderColor: \"##CCCCCDFF\",\n};\n\nexport function getLightTheme({ light }: InitThemeOptions) {\n const highlightConfig = { ...HIGHLIGHT_CONFIG, ...(light?.highlightConfig
|
|
1
|
+
{"version":3,"file":"get-light-theme.js","sources":["../../../../../src/extensions/theme/themes/get-light-theme.ts"],"sourcesContent":["import { type HighlightConfig, type InitThemeOptions, type ThemeConfig } from \"../theme-types\";\nimport { getHighlightTemplate } from \"./get-highlight-template\";\nimport { getThemeTemplate } from \"./get-theme-template\";\n\nconst HIGHLIGHT_CONFIG: Required<HighlightConfig> = {\n keyword: \"#9854f1\",\n variable: \"#3760bf\",\n function: \"#2e7de9\",\n string: \"#587539\",\n constant: \"#9854f1\",\n type: \"#07879d\",\n class: \"#3760bf\",\n number: \"#b15c00\",\n comment: \"#9da3c2\",\n heading: \"#006a83\",\n invalid: \"#ff3e64\",\n regexp: \"#2e5857\",\n};\n\nconst THEME_CONFIG: Required<ThemeConfig> = {\n background: \"transparent\",\n blockquoteColor: \"#8A5CF5\", // #6A8695\n codeBackground: \"#e1e2e7\",\n codeButtonBackground: \"#CCCCCDFF\",\n codeButtonColor: \"#000000\",\n codeColor: \"#000000\",\n color: \"#000000\",\n fontFamily: \"Montserrat\",\n codeFontFamily: \"Consolas\",\n horizontalColor: \"#000000\",\n linkColor: \"#8A5CF5\",\n mentionColor: \"#8A5CF5\",\n vimSelection: \"#d9d9d9\",\n vimSelectionFocused: \"#d7d4f0\",\n codeBlockBackground: \"#e1e2e7\",\n codeBlockBorderColor: \"##CCCCCDFF\",\n};\n\nexport function getLightTheme({ light }: InitThemeOptions) {\n const highlightConfig = { ...HIGHLIGHT_CONFIG, ...(light?.highlightConfig ?? {}) };\n const themeConfig = { ...THEME_CONFIG, ...(light?.themeConfig ?? {}) };\n\n return [getThemeTemplate(false, themeConfig), getHighlightTemplate(highlightConfig)];\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,gBAAgB,GAA8B;AAClD,IAAA,OAAO,E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AACtF;;;;"}
|
|
@@ -28,6 +28,9 @@ function getThemeTemplate(dark, config) {
|
|
|
28
28
|
background: config.codeBackground,
|
|
29
29
|
color: config.codeColor,
|
|
30
30
|
},
|
|
31
|
+
[`div.${CLASSES.code}`]: {
|
|
32
|
+
fontFamily: config.codeFontFamily,
|
|
33
|
+
},
|
|
31
34
|
[`.${CLASSES.horizontal}`]: {
|
|
32
35
|
borderBottomColor: config.horizontalColor,
|
|
33
36
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-theme-template.js","sources":["../../../../../src/extensions/theme/themes/get-theme-template.ts"],"sourcesContent":["import { EditorView } from \"@codemirror/view\";\nimport { CLASSES } from \"../theme-constants\";\nimport type { ThemeConfig } from \"../theme-types\";\n\nexport function getThemeTemplate(dark: boolean, config: Required<ThemeConfig>) {\n return EditorView.theme(\n {\n \"&\": {\n color: config.color,\n backgroundColor: config.background,\n },\n \".cm-content\": {\n fontFamily: config.fontFamily || \"Montserrat\",\n },\n \"&.cm-focused > .cm-scroller > .cm-selectionLayer > .cm-selectionBackground\": {\n background: config.vimSelectionFocused,\n },\n \"& .cm-selectionBackground\": {\n background: config.vimSelection,\n },\n \"&.cm-editor.cm-focused\": { outline: \"none\" },\n \"&.cm-editor\": {\n height: \"100%\",\n width: \"100%\",\n },\n [`.${CLASSES.listCommon}:after`]: {\n background: config.color,\n },\n [`.${CLASSES.code}`]: {\n background: config.codeBackground,\n color: config.codeColor,\n },\n [`.${CLASSES.horizontal}`]: {\n borderBottomColor: config.horizontalColor,\n },\n [`.${CLASSES.link}`]: {\n color: config.linkColor,\n },\n [`.${CLASSES.blockquote}`]: {\n borderLeftColor: config.blockquoteColor,\n },\n [`.${CLASSES.blockquoteInner}:before`]: {\n borderLeftColor: config.blockquoteColor,\n },\n [`.${CLASSES.codeButton}`]: {\n color: config.codeButtonColor,\n },\n [`.${CLASSES.codeButton}:hover`]: {\n background: config.codeButtonBackground,\n },\n [`.${CLASSES.codeButtonSuccess}:after`]: {\n borderColor: config.codeButtonColor,\n },\n [`.${CLASSES.codeButtonFail}:after`]: {\n background: config.codeButtonColor,\n },\n [`.${CLASSES.codeButtonFail}:before`]: {\n background: config.codeButtonColor,\n },\n [`.${CLASSES.codeButtonPending}:before`]: {\n borderColor: config.codeBackground,\n borderTopColor: config.codeButtonColor,\n },\n [`.${CLASSES.mention}`]: {\n color: config.mentionColor,\n },\n [`.${CLASSES.codeBlockLine}`]: {\n borderColor: config.codeBlockBorderColor,\n },\n [`.${CLASSES.codeBlock}`]: {\n background: config.codeBlockBackground,\n },\n },\n { dark },\n );\n}\n"],"names":[],"mappings":";;;AAIgB,SAAA,gBAAgB,CAAC,IAAa,EAAE,MAA6B,EAAA;IAC3E,OAAO,UAAU,CAAC,KAAK,CACrB;AACE,QAAA,GAAG,EAAE;YACH,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,eAAe,EAAE,MAAM,CAAC,UAAU;AACnC,SAAA;AACD,QAAA,aAAa,EAAE;AACb,YAAA,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,YAAY;AAC9C,SAAA;AACD,QAAA,4EAA4E,EAAE;YAC5E,UAAU,EAAE,MAAM,CAAC,mBAAmB;AACvC,SAAA;AACD,QAAA,2BAA2B,EAAE;YAC3B,UAAU,EAAE,MAAM,CAAC,YAAY;AAChC,SAAA;AACD,QAAA,wBAAwB,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;AAC7C,QAAA,aAAa,EAAE;AACb,YAAA,MAAM,EAAE,MAAM;AACd,YAAA,KAAK,EAAE,MAAM;AACd,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,UAAU,CAAA,MAAA,CAAQ,GAAG;YAChC,UAAU,EAAE,MAAM,CAAC,KAAK;AACzB,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,IAAI,CAAA,CAAE,GAAG;YACpB,UAAU,EAAE,MAAM,CAAC,cAAc;YACjC,KAAK,EAAE,MAAM,CAAC,SAAS;AACx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vB,KAAK,EAAE,MAAM,CAAC,YAAY;AAC3B,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,aAAa,CAAA,CAAE,GAAG;YAC7B,WAAW,EAAE,MAAM,CAAC,oBAAoB;AACzC,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,SAAS,CAAA,CAAE,GAAG;YACzB,UAAU,EAAE,MAAM,CAAC,mBAAmB;AACvC,SAAA;AACF,KAAA,EACD,EAAE,IAAI,EAAE,CACT;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"get-theme-template.js","sources":["../../../../../src/extensions/theme/themes/get-theme-template.ts"],"sourcesContent":["import { EditorView } from \"@codemirror/view\";\nimport { CLASSES } from \"../theme-constants\";\nimport type { ThemeConfig } from \"../theme-types\";\n\nexport function getThemeTemplate(dark: boolean, config: Required<ThemeConfig>) {\n return EditorView.theme(\n {\n \"&\": {\n color: config.color,\n backgroundColor: config.background,\n },\n \".cm-content\": {\n fontFamily: config.fontFamily || \"Montserrat\",\n },\n \"&.cm-focused > .cm-scroller > .cm-selectionLayer > .cm-selectionBackground\": {\n background: config.vimSelectionFocused,\n },\n \"& .cm-selectionBackground\": {\n background: config.vimSelection,\n },\n \"&.cm-editor.cm-focused\": { outline: \"none\" },\n \"&.cm-editor\": {\n height: \"100%\",\n width: \"100%\",\n },\n [`.${CLASSES.listCommon}:after`]: {\n background: config.color,\n },\n [`.${CLASSES.code}`]: {\n background: config.codeBackground,\n color: config.codeColor,\n },\n [`div.${CLASSES.code}`]: {\n fontFamily: config.codeFontFamily,\n },\n [`.${CLASSES.horizontal}`]: {\n borderBottomColor: config.horizontalColor,\n },\n [`.${CLASSES.link}`]: {\n color: config.linkColor,\n },\n [`.${CLASSES.blockquote}`]: {\n borderLeftColor: config.blockquoteColor,\n },\n [`.${CLASSES.blockquoteInner}:before`]: {\n borderLeftColor: config.blockquoteColor,\n },\n [`.${CLASSES.codeButton}`]: {\n color: config.codeButtonColor,\n },\n [`.${CLASSES.codeButton}:hover`]: {\n background: config.codeButtonBackground,\n },\n [`.${CLASSES.codeButtonSuccess}:after`]: {\n borderColor: config.codeButtonColor,\n },\n [`.${CLASSES.codeButtonFail}:after`]: {\n background: config.codeButtonColor,\n },\n [`.${CLASSES.codeButtonFail}:before`]: {\n background: config.codeButtonColor,\n },\n [`.${CLASSES.codeButtonPending}:before`]: {\n borderColor: config.codeBackground,\n borderTopColor: config.codeButtonColor,\n },\n [`.${CLASSES.mention}`]: {\n color: config.mentionColor,\n },\n [`.${CLASSES.codeBlockLine}`]: {\n borderColor: config.codeBlockBorderColor,\n },\n [`.${CLASSES.codeBlock}`]: {\n background: config.codeBlockBackground,\n },\n },\n { dark },\n );\n}\n"],"names":[],"mappings":";;;AAIgB,SAAA,gBAAgB,CAAC,IAAa,EAAE,MAA6B,EAAA;IAC3E,OAAO,UAAU,CAAC,KAAK,CACrB;AACE,QAAA,GAAG,EAAE;YACH,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,eAAe,EAAE,MAAM,CAAC,UAAU;AACnC,SAAA;AACD,QAAA,aAAa,EAAE;AACb,YAAA,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,YAAY;AAC9C,SAAA;AACD,QAAA,4EAA4E,EAAE;YAC5E,UAAU,EAAE,MAAM,CAAC,mBAAmB;AACvC,SAAA;AACD,QAAA,2BAA2B,EAAE;YAC3B,UAAU,EAAE,MAAM,CAAC,YAAY;AAChC,SAAA;AACD,QAAA,wBAAwB,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;AAC7C,QAAA,aAAa,EAAE;AACb,YAAA,MAAM,EAAE,MAAM;AACd,YAAA,KAAK,EAAE,MAAM;AACd,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,UAAU,CAAA,MAAA,CAAQ,GAAG;YAChC,UAAU,EAAE,MAAM,CAAC,KAAK;AACzB,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,IAAI,CAAA,CAAE,GAAG;YACpB,UAAU,EAAE,MA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AAA,CAAS,GAAG;YACxC,WAAW,EAAE,MAAM,CAAC,cAAc;YAClC,cAAc,EAAE,MAAM,CAAC,eAAe;AACvC,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,OAAO,CAAA,CAAE,GAAG;YACvB,KAAK,EAAE,MAAM,CAAC,YAAY;AAC3B,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,aAAa,CAAA,CAAE,GAAG;YAC7B,WAAW,EAAE,MAAM,CAAC,oBAAoB;AACzC,SAAA;AACD,QAAA,CAAC,IAAI,OAAO,CAAC,SAAS,CAAA,CAAE,GAAG;YACzB,UAAU,EAAE,MAAM,CAAC,mBAAmB;AACvC,SAAA;AACF,KAAA,EACD,EAAE,IAAI,EAAE,CACT;AACH;;;;"}
|
|
@@ -26,6 +26,7 @@ function overlapMark({ marks, shift, state, requireMatched }) {
|
|
|
26
26
|
originalText: text.substring(shiftBeforeOuter, text.length - shiftAfterOuter),
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
+
// eslint-disable-next-line max-params
|
|
29
30
|
function findMarkIndex(text, marks, requireMatched, direction = "right") {
|
|
30
31
|
if (text.length === 0)
|
|
31
32
|
return -1;
|
|
@@ -53,8 +54,10 @@ function findMarkIndex(text, marks, requireMatched, direction = "right") {
|
|
|
53
54
|
const posMin = pos - minRequired;
|
|
54
55
|
const posMax = pos - matched;
|
|
55
56
|
// console.log({ posMin, posMax, pos, minRequired, maxRequired, direction, matched });
|
|
57
|
+
// eslint-disable-next-line max-depth
|
|
56
58
|
if (direction === "right" && posMin > start)
|
|
57
59
|
start = posMin;
|
|
60
|
+
// eslint-disable-next-line max-depth
|
|
58
61
|
if (direction === "left" && (posMax < start || start === -1))
|
|
59
62
|
start = posMax;
|
|
60
63
|
}
|
|
@@ -114,7 +117,7 @@ function processShiftContent(state, shift, marks) {
|
|
|
114
117
|
if (initialText.length > 1)
|
|
115
118
|
while (pos < initialText.length) {
|
|
116
119
|
// eslint-disable-next-line no-loop-func -- https://eslint.org/docs/latest/rules/no-loop-func#known-limitations
|
|
117
|
-
if (marks.some((
|
|
120
|
+
if (marks.some((mark) => mark === initialText.codePointAt(pos)))
|
|
118
121
|
shiftBeforeInner++;
|
|
119
122
|
else
|
|
120
123
|
break;
|
|
@@ -126,7 +129,7 @@ function processShiftContent(state, shift, marks) {
|
|
|
126
129
|
if (initialText.length > 1 || shiftBeforeInner > 0)
|
|
127
130
|
while (pos > -1) {
|
|
128
131
|
// eslint-disable-next-line no-loop-func -- https://eslint.org/docs/latest/rules/no-loop-func#known-limitations
|
|
129
|
-
if (marks.some((
|
|
132
|
+
if (marks.some((mark) => mark === initialTextWithoutBeforeShift.codePointAt(pos)))
|
|
130
133
|
shiftAfterInner++;
|
|
131
134
|
else
|
|
132
135
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlap-mark.js","sources":["../../../../src/lib/utils/overlap-mark.ts"],"sourcesContent":["import type { EditorState } from \"@codemirror/state\";\n\ntype OverlapMarkOptions = {\n state: EditorState;\n shift: number;\n marks: (number | undefined)[];\n requireMatched: number[];\n};\n\nexport function overlapMark({ marks, shift, state, requireMatched }: OverlapMarkOptions) {\n const { from, to, shiftAfterInner, shiftAfterOuter, shiftBeforeInner, shiftBeforeOuter, text } =\n processShiftContent(state, shift, marks);\n\n const startIndex = findMarkIndex(\n text.substring(0, shiftBeforeInner + shiftBeforeOuter),\n marks,\n requireMatched,\n \"right\",\n );\n const endIndex = findMarkIndex(\n text.substring(text.length - shiftAfterInner - shiftAfterOuter),\n marks,\n requireMatched,\n \"left\",\n );\n\n const start = ~startIndex ? from - shiftBeforeOuter + startIndex : -1;\n const end = ~endIndex ? to - shiftAfterInner + endIndex : -1;\n\n // console.log({\n // from,\n // to,\n // shiftAfterInner,\n // shiftAfterOuter,\n // shiftBeforeInner,\n // shiftBeforeOuter,\n // text,\n // textStart: text.substring(0, shiftBeforeInner + shiftBeforeOuter),\n // textEnd: text.substring(text.length - shiftAfterInner - shiftAfterOuter),\n // startIndex,\n // endIndex,\n // end,\n // start,\n // });\n\n return {\n start,\n end,\n marked: Boolean(~start || ~end),\n originalText: text.substring(shiftBeforeOuter, text.length - shiftAfterOuter),\n };\n}\n\nfunction findMarkIndex(\n text: string,\n marks: (number | undefined)[],\n requireMatched: number[],\n direction: \"right\" | \"left\" = \"right\",\n) {\n if (text.length === 0) return -1;\n\n const maxRequired = Math.max(...requireMatched);\n const minRequired = Math.min(...requireMatched);\n\n let pos = 0;\n let matched = 0;\n let start = -1;\n\n for (const mark of marks) {\n if (!mark) continue;\n\n while (pos < text.length) {\n if (text.codePointAt(pos) === mark) matched++;\n else {\n if (\n // eslint-disable-next-line no-loop-func -- https://eslint.org/docs/latest/rules/no-loop-func#known-limitations\n requireMatched.some((rm) => rm === matched) &&\n ((direction === \"right\" && pos - matched > start) ||\n (direction === \"left\" && (pos - matched < start || start === -1)))\n ) {\n start = direction === \"right\" ? pos - minRequired : pos - matched;\n // console.log({ pos, matched, start, minRequired, maxRequired, direction });\n } else if (maxRequired < matched) {\n const posMin = pos - minRequired;\n const posMax = pos - matched;\n\n // console.log({ posMin, posMax, pos, minRequired, maxRequired, direction, matched });\n\n if (direction === \"right\" && posMin > start) start = posMin;\n if (direction === \"left\" && (posMax < start || start === -1)) start = posMax;\n }\n matched = 0;\n }\n pos++;\n }\n\n if (\n // eslint-disable-next-line no-loop-func -- https://eslint.org/docs/latest/rules/no-loop-func#known-limitations\n requireMatched.some((rm) => rm === matched) &&\n ((direction === \"right\" && pos - matched > start) ||\n (direction === \"left\" && (pos - matched < start || start === -1)))\n ) {\n start = direction === \"right\" ? pos - minRequired : pos - matched;\n // console.log({ pos, matched, start, minRequired, maxRequired, direction });\n } else if (maxRequired < matched) {\n const posMin = pos - minRequired;\n const posMax = pos - matched;\n\n // console.log({ posMin, posMax, pos, minRequired, maxRequired, direction, matched });\n\n if (direction === \"right\" && posMin > start) start = posMin;\n if (direction === \"left\" && (posMax < start || start === -1)) start = posMax;\n }\n\n pos = 0;\n matched = 0;\n }\n\n return start;\n}\n\nfunction processShiftContent(state: EditorState, shift: number, marks: (number | undefined)[]) {\n const { from, to } = state.selection.ranges[0];\n const linePoint = state.lineBreak.codePointAt(0);\n let pos = 0;\n\n /** processing outer shifts */\n const initialTextBefore = state.sliceDoc(from - shift, from);\n let shiftBeforeOuter = 0;\n pos = initialTextBefore.length - 1;\n\n while (pos > -1) {\n if (initialTextBefore.codePointAt(pos) === linePoint) break;\n shiftBeforeOuter++;\n pos--;\n }\n\n const initialTextAfter = state.sliceDoc(to, to + shift);\n let shiftAfterOuter = 0;\n pos = 0;\n\n while (pos < initialTextAfter.length) {\n if (initialTextAfter.codePointAt(pos) === linePoint) break;\n shiftAfterOuter++;\n pos++;\n }\n\n /** processing inner shifts */\n const initialText = state.sliceDoc(from, to);\n let shiftBeforeInner = 0;\n pos = 0;\n\n if (initialText.length > 1)\n while (pos < initialText.length) {\n // eslint-disable-next-line no-loop-func -- https://eslint.org/docs/latest/rules/no-loop-func#known-limitations\n if (marks.some((m) => m === initialText.codePointAt(pos))) shiftBeforeInner++;\n else break;\n\n pos++;\n }\n\n const initialTextWithoutBeforeShift = initialText.substring(shiftBeforeInner + 1);\n let shiftAfterInner = 0;\n pos = initialTextWithoutBeforeShift.length - 1;\n\n if (initialText.length > 1 || shiftBeforeInner > 0)\n while (pos > -1) {\n // eslint-disable-next-line no-loop-func -- https://eslint.org/docs/latest/rules/no-loop-func#known-limitations\n if (marks.some((m) => m === initialTextWithoutBeforeShift.codePointAt(pos)))\n shiftAfterInner++;\n else break;\n\n pos--;\n }\n\n const text = state.sliceDoc(from - shiftBeforeOuter, to + shiftAfterOuter);\n\n return {\n from,\n to,\n shiftBeforeOuter,\n shiftBeforeInner,\n shiftAfterOuter,\n shiftAfterInner,\n text,\n };\n}\n"],"names":[],"mappings":"AASM,SAAU,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAsB,EAAA;IACrF,MAAM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M,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,GAAG,gBAAgB,EAAE,EAAE,GAAG,eAAe,CAAC;IAE1E,OAAO;QACL,IAAI;QACJ,EAAE;QACF,gBAAgB;QAChB,gBAAgB;QAChB,eAAe;QACf,eAAe;QACf,IAAI;KACL;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"overlap-mark.js","sources":["../../../../src/lib/utils/overlap-mark.ts"],"sourcesContent":["import type { EditorState } from \"@codemirror/state\";\n\ntype OverlapMarkOptions = {\n state: EditorState;\n shift: number;\n marks: (number | undefined)[];\n requireMatched: number[];\n};\n\nexport function overlapMark({ marks, shift, state, requireMatched }: OverlapMarkOptions) {\n const { from, to, shiftAfterInner, shiftAfterOuter, shiftBeforeInner, shiftBeforeOuter, text } =\n processShiftContent(state, shift, marks);\n\n const startIndex = findMarkIndex(\n text.substring(0, shiftBeforeInner + shiftBeforeOuter),\n marks,\n requireMatched,\n \"right\",\n );\n const endIndex = findMarkIndex(\n text.substring(text.length - shiftAfterInner - shiftAfterOuter),\n marks,\n requireMatched,\n \"left\",\n );\n\n const start = ~startIndex ? from - shiftBeforeOuter + startIndex : -1;\n const end = ~endIndex ? to - shiftAfterInner + endIndex : -1;\n\n // console.log({\n // from,\n // to,\n // shiftAfterInner,\n // shiftAfterOuter,\n // shiftBeforeInner,\n // shiftBeforeOuter,\n // text,\n // textStart: text.substring(0, shiftBeforeInner + shiftBeforeOuter),\n // textEnd: text.substring(text.length - shiftAfterInner - shiftAfterOuter),\n // startIndex,\n // endIndex,\n // end,\n // start,\n // });\n\n return {\n start,\n end,\n marked: Boolean(~start || ~end),\n originalText: text.substring(shiftBeforeOuter, text.length - shiftAfterOuter),\n };\n}\n\n// eslint-disable-next-line max-params\nfunction findMarkIndex(\n text: string,\n marks: (number | undefined)[],\n requireMatched: number[],\n direction: \"right\" | \"left\" = \"right\",\n) {\n if (text.length === 0) return -1;\n\n const maxRequired = Math.max(...requireMatched);\n const minRequired = Math.min(...requireMatched);\n\n let pos = 0;\n let matched = 0;\n let start = -1;\n\n for (const mark of marks) {\n if (!mark) continue;\n\n while (pos < text.length) {\n if (text.codePointAt(pos) === mark) matched++;\n else {\n if (\n // eslint-disable-next-line no-loop-func -- https://eslint.org/docs/latest/rules/no-loop-func#known-limitations\n requireMatched.some((rm) => rm === matched) &&\n ((direction === \"right\" && pos - matched > start) ||\n (direction === \"left\" && (pos - matched < start || start === -1)))\n ) {\n start = direction === \"right\" ? pos - minRequired : pos - matched;\n // console.log({ pos, matched, start, minRequired, maxRequired, direction });\n } else if (maxRequired < matched) {\n const posMin = pos - minRequired;\n const posMax = pos - matched;\n\n // console.log({ posMin, posMax, pos, minRequired, maxRequired, direction, matched });\n\n // eslint-disable-next-line max-depth\n if (direction === \"right\" && posMin > start) start = posMin;\n // eslint-disable-next-line max-depth\n if (direction === \"left\" && (posMax < start || start === -1)) start = posMax;\n }\n matched = 0;\n }\n pos++;\n }\n\n if (\n // eslint-disable-next-line no-loop-func -- https://eslint.org/docs/latest/rules/no-loop-func#known-limitations\n requireMatched.some((rm) => rm === matched) &&\n ((direction === \"right\" && pos - matched > start) ||\n (direction === \"left\" && (pos - matched < start || start === -1)))\n ) {\n start = direction === \"right\" ? pos - minRequired : pos - matched;\n // console.log({ pos, matched, start, minRequired, maxRequired, direction });\n } else if (maxRequired < matched) {\n const posMin = pos - minRequired;\n const posMax = pos - matched;\n\n // console.log({ posMin, posMax, pos, minRequired, maxRequired, direction, matched });\n\n if (direction === \"right\" && posMin > start) start = posMin;\n if (direction === \"left\" && (posMax < start || start === -1)) start = posMax;\n }\n\n pos = 0;\n matched = 0;\n }\n\n return start;\n}\n\nfunction processShiftContent(state: EditorState, shift: number, marks: (number | undefined)[]) {\n const { from, to } = state.selection.ranges[0];\n const linePoint = state.lineBreak.codePointAt(0);\n let pos = 0;\n\n /** processing outer shifts */\n const initialTextBefore = state.sliceDoc(from - shift, from);\n let shiftBeforeOuter = 0;\n pos = initialTextBefore.length - 1;\n\n while (pos > -1) {\n if (initialTextBefore.codePointAt(pos) === linePoint) break;\n shiftBeforeOuter++;\n pos--;\n }\n\n const initialTextAfter = state.sliceDoc(to, to + shift);\n let shiftAfterOuter = 0;\n pos = 0;\n\n while (pos < initialTextAfter.length) {\n if (initialTextAfter.codePointAt(pos) === linePoint) break;\n shiftAfterOuter++;\n pos++;\n }\n\n /** processing inner shifts */\n const initialText = state.sliceDoc(from, to);\n let shiftBeforeInner = 0;\n pos = 0;\n\n if (initialText.length > 1)\n while (pos < initialText.length) {\n // eslint-disable-next-line no-loop-func -- https://eslint.org/docs/latest/rules/no-loop-func#known-limitations\n if (marks.some((mark) => mark === initialText.codePointAt(pos))) shiftBeforeInner++;\n else break;\n\n pos++;\n }\n\n const initialTextWithoutBeforeShift = initialText.substring(shiftBeforeInner + 1);\n let shiftAfterInner = 0;\n pos = initialTextWithoutBeforeShift.length - 1;\n\n if (initialText.length > 1 || shiftBeforeInner > 0)\n while (pos > -1) {\n // eslint-disable-next-line no-loop-func -- https://eslint.org/docs/latest/rules/no-loop-func#known-limitations\n if (marks.some((mark) => mark === initialTextWithoutBeforeShift.codePointAt(pos)))\n shiftAfterInner++;\n else break;\n\n pos--;\n }\n\n const text = state.sliceDoc(from - shiftBeforeOuter, to + shiftAfterOuter);\n\n return {\n from,\n to,\n shiftBeforeOuter,\n shiftBeforeInner,\n shiftAfterOuter,\n shiftAfterInner,\n text,\n };\n}\n"],"names":[],"mappings":"AASM,SAAU,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAsB,EAAA;IACrF,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,IAAI,EAAE,GAC5F,mBAAmB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;IAE1C,MAAM,UAAU,GAAG,aAAa,CAC9B,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,gBAAgB,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
87
|
? getDarkTheme({
|
|
88
88
|
dark: this.arguments.dark,
|
|
89
|
-
light: this.arguments.light
|
|
90
|
-
theme,
|
|
91
|
-
})
|
|
89
|
+
light: this.arguments.light})
|
|
92
90
|
: getLightTheme({
|
|
93
91
|
dark: this.arguments.dark,
|
|
94
|
-
light: this.arguments.light,
|
|
95
|
-
theme,
|
|
96
|
-
})),
|
|
92
|
+
light: this.arguments.light})),
|
|
97
93
|
});
|
|
98
94
|
});
|
|
99
95
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Editor.js","sources":["../../../../src/module/Editor/Editor.ts"],"sourcesContent":["import { EditorView, drawSelection } from \"@codemirror/view\";\nimport type { WebsocketProvider } from \"y-websocket\";\nimport type { Text } from \"yjs\";\nimport {\n type EditorTheme,\n ReadonlyCompartment,\n ThemeCompartment,\n VimModeCompartment,\n getDarkTheme,\n getLightTheme,\n} from \"@/extensions\";\nimport { saveDispatch } from \"@/lib/utils\";\nimport { type EditorArguments } from \"./Editor.types\";\nimport { initEditor } from \"./lib\";\n\nexport class Editor {\n view: EditorView | undefined;\n\n provider: WebsocketProvider | undefined;\n\n arguments: EditorArguments;\n\n yText: Text | undefined;\n\n constructor(options: EditorArguments) {\n void initEditor(options).then((editor) => {\n this.view = editor.view;\n this.provider = editor.provider;\n this.yText = editor.multiCursorText;\n });\n\n this.arguments = options;\n }\n\n focus = () => {\n if (!this.view) return;\n\n this.view.focus();\n };\n\n getContent = () => {\n if (!this.view) return;\n\n return this.view.state.doc.toString();\n };\n\n setContent = (content: string, position?: number) => {\n if (!this.view) return;\n\n if (position == undefined) {\n const cursor = this.view.state.selection.main.head;\n position = cursor;\n }\n\n const transaction = this.view.state.update({\n changes: {\n from: position,\n insert: content,\n },\n });\n saveDispatch(() => {\n if (!this.view) return;\n\n this.view.dispatch(transaction);\n });\n };\n\n replaceContent = (content: string) => {\n // if (!this.yText) return;\n\n // this.yText.delete(0, this.yText.length);\n // this.yText.insert(0, content);\n\n // return;\n\n if (!this.view) return;\n\n const transaction = this.view.state.update({\n changes: { from: 0, to: this.view.state.doc.length, insert: content },\n });\n saveDispatch(() => {\n if (!this.view) return;\n\n this.view.dispatch(transaction);\n });\n };\n\n setReadonly = (readonly: boolean) => {\n saveDispatch(() => {\n if (!this.view) return;\n this.view.dispatch({\n effects: ReadonlyCompartment.reconfigure(EditorView.editable.of(!readonly)),\n });\n });\n };\n\n setTheme = (theme?: EditorTheme) => {\n saveDispatch(() => {\n if (!this.view) return;\n this.view.dispatch({\n effects: ThemeCompartment.reconfigure(\n theme === \"dark\"\n ? getDarkTheme({\n dark: this.arguments.dark,\n light: this.arguments.light,\n theme,\n })\n : getLightTheme({\n dark: this.arguments.dark,\n light: this.arguments.light,\n theme,\n }),\n ),\n });\n });\n };\n\n setVimMode = async (mode: boolean) => {\n if (!this.view) return;\n\n const { vim } = await import(\"@replit/codemirror-vim\");\n\n saveDispatch(() => {\n if (!this.view) return;\n this.view.dispatch({\n effects: VimModeCompartment.reconfigure(\n mode ? [vim({ status: true }), drawSelection()] : [],\n ),\n });\n });\n };\n\n setUserProvider = (name: string = \"Anonymous\", color: string = \"#000000\") => {\n if (!this.provider) return;\n\n this.provider.awareness.setLocalStateField(\"user\", { name, color });\n };\n\n destroy = () => {\n saveDispatch(() => {\n if (!this.view) return;\n this.view.destroy();\n });\n saveDispatch(() => {\n if (this.provider) this.provider.destroy();\n });\n };\n}\n\nexport type EditorInterface = typeof Editor;\n"],"names":[],"mappings":";;;;;;;;;;;;;MAea,MAAM,CAAA;AACjB,IAAA,IAAI;AAEJ,IAAA,QAAQ;AAER,IAAA,SAAS;AAET,IAAA,KAAK;AAEL,IAAA,WAAA,CAAY,OAAwB,EAAA;QAClC,KAAK,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAI;AACvC,YAAA,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI;AACvB,YAAA,IAAI,CAAC,QAAQ,GAAG,MAAM,C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E,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE;AACtE,SAAA,CAAC;QACF,YAAY,CAAC,MAAK;YAChB,IAAI,CAAC,IAAI,CAAC,IAAI;gBAAE;AAEhB,YAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;AACjC,SAAC,CAAC;AACJ,KAAC;AAED,IAAA,WAAW,GAAG,CAAC,QAAiB,KAAI;QAClC,YAAY,CAAC,MAAK;YAChB,IAAI,CAAC,IAAI,CAAC,IAAI;gBAAE;AAChB,YAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;AACjB,gBAAA,OAAO,EAAE,mBAAmB,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;AAC5E,aAAA,CAAC;AACJ,SAAC,CAAC;AACJ,KAAC;AAED,IAAA,QAAQ,GAAG,CAAC,KAAmB,KAAI;QACjC,YAAY,CAAC,MAAK;YAChB,IAAI,CAAC,IAAI,CAAC,IAAI;gBAAE;AAChB,YAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;AACjB,gBAAA,OAAO,EAAE,gBAAgB,CAAC,WAAW,CACnC,KAAK,KAAK;sBACN,YAAY,CAAC;AACX,wBAAA,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI;AACzB,wBAAA,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"Editor.js","sources":["../../../../src/module/Editor/Editor.ts"],"sourcesContent":["import { EditorView, drawSelection } from \"@codemirror/view\";\nimport type { WebsocketProvider } from \"y-websocket\";\nimport type { Text } from \"yjs\";\nimport {\n type EditorTheme,\n ReadonlyCompartment,\n ThemeCompartment,\n VimModeCompartment,\n getDarkTheme,\n getLightTheme,\n} from \"@/extensions\";\nimport { saveDispatch } from \"@/lib/utils\";\nimport { type EditorArguments } from \"./Editor.types\";\nimport { initEditor } from \"./lib\";\n\nexport class Editor {\n view: EditorView | undefined;\n\n provider: WebsocketProvider | undefined;\n\n arguments: EditorArguments;\n\n yText: Text | undefined;\n\n constructor(options: EditorArguments) {\n void initEditor(options).then((editor) => {\n this.view = editor.view;\n this.provider = editor.provider;\n this.yText = editor.multiCursorText;\n });\n\n this.arguments = options;\n }\n\n focus = () => {\n if (!this.view) return;\n\n this.view.focus();\n };\n\n getContent = () => {\n if (!this.view) return;\n\n return this.view.state.doc.toString();\n };\n\n setContent = (content: string, position?: number) => {\n if (!this.view) return;\n\n if (position == undefined) {\n const cursor = this.view.state.selection.main.head;\n position = cursor;\n }\n\n const transaction = this.view.state.update({\n changes: {\n from: position,\n insert: content,\n },\n });\n saveDispatch(() => {\n if (!this.view) return;\n\n this.view.dispatch(transaction);\n });\n };\n\n replaceContent = (content: string) => {\n // if (!this.yText) return;\n\n // this.yText.delete(0, this.yText.length);\n // this.yText.insert(0, content);\n\n // return;\n\n if (!this.view) return;\n\n const transaction = this.view.state.update({\n changes: { from: 0, to: this.view.state.doc.length, insert: content },\n });\n saveDispatch(() => {\n if (!this.view) return;\n\n this.view.dispatch(transaction);\n });\n };\n\n setReadonly = (readonly: boolean) => {\n saveDispatch(() => {\n if (!this.view) return;\n this.view.dispatch({\n effects: ReadonlyCompartment.reconfigure(EditorView.editable.of(!readonly)),\n });\n });\n };\n\n setTheme = (theme?: EditorTheme) => {\n saveDispatch(() => {\n if (!this.view) return;\n this.view.dispatch({\n effects: ThemeCompartment.reconfigure(\n theme === \"dark\"\n ? getDarkTheme({\n dark: this.arguments.dark,\n light: this.arguments.light,\n theme,\n })\n : getLightTheme({\n dark: this.arguments.dark,\n light: this.arguments.light,\n theme,\n }),\n ),\n });\n });\n };\n\n setVimMode = async (mode: boolean) => {\n if (!this.view) return;\n\n const { vim } = await import(\"@replit/codemirror-vim\");\n\n saveDispatch(() => {\n if (!this.view) return;\n this.view.dispatch({\n effects: VimModeCompartment.reconfigure(\n mode ? [vim({ status: true }), drawSelection()] : [],\n ),\n });\n });\n };\n\n setUserProvider = (name: string = \"Anonymous\", color: string = \"#000000\") => {\n if (!this.provider) return;\n\n this.provider.awareness.setLocalStateField(\"user\", { name, color });\n };\n\n destroy = () => {\n saveDispatch(() => {\n if (!this.view) return;\n this.view.destroy();\n });\n saveDispatch(() => {\n if (this.provider) this.provider.destroy();\n });\n };\n}\n\nexport type EditorInterface = typeof Editor;\n"],"names":[],"mappings":";;;;;;;;;;;;;MAea,MAAM,CAAA;AACjB,IAAA,IAAI;AAEJ,IAAA,QAAQ;AAER,IAAA,SAAS;AAET,IAAA,KAAK;AAEL,IAAA,WAAA,CAAY,OAAwB,EAAA;QAClC,KAAK,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAI;AACvC,YAAA,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI;AACvB,YAAA,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ;AAC/B,YAAA,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,eAAe;AACrC,SAAC,CAAC;AAEF,QAAA,IAAI,CAAC,SAAS,GAAG,OAAO;;IAG1B,KAAK,GAAG,MAAK;QACX,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE;AAEhB,QAAA,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;AACnB,KAAC;IAED,UAAU,GAAG,MAAK;QAChB,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE;QAEhB,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE;AACvC,KAAC;AAED,IAAA,UAAU,GAAG,CAAC,OAAe,EAAE,QAAiB,KAAI;QAClD,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE;AAEhB,QAAA,IAAI,QAAQ,IAAI,SAAS,EAAE;AACzB,YAAA,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS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AAO,GAAG,MAAK;QACb,YAAY,CAAC,MAAK;YAChB,IAAI,CAAC,IAAI,CAAC,IAAI;gBAAE;AAChB,YAAA,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;AACrB,SAAC,CAAC;QACF,YAAY,CAAC,MAAK;YAChB,IAAI,IAAI,CAAC,QAAQ;AAAE,gBAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;AAC5C,SAAC,CAAC;AACJ,KAAC;AACF;;;;"}
|
|
@@ -3,8 +3,7 @@ async function initEditorProvider({ roomId, url, userName = "Anonymous", userCol
|
|
|
3
3
|
const { WebsocketProvider } = await import('y-websocket');
|
|
4
4
|
const multiCursorDocument = new Doc();
|
|
5
5
|
const multiCursorText = multiCursorDocument.getText(roomId);
|
|
6
|
-
if (!userColor
|
|
7
|
-
// eslint-disable-next-line no-console
|
|
6
|
+
if (!userColor?.startsWith?.("#")) {
|
|
8
7
|
console.warn("user color must be hex!");
|
|
9
8
|
userColor = "#30bced";
|
|
10
9
|
}
|
|
@@ -19,7 +18,7 @@ async function initEditorProvider({ roomId, url, userName = "Anonymous", userCol
|
|
|
19
18
|
provider.on("status", (event) => {
|
|
20
19
|
onStartProvider(event?.status);
|
|
21
20
|
});
|
|
22
|
-
if (provider
|
|
21
|
+
if (provider)
|
|
23
22
|
provider.on("sync", (isSynced) => {
|
|
24
23
|
if (isSynced && !multiCursorText.length && initialText) {
|
|
25
24
|
multiCursorText.insert(0, initialText);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-editor-provider.js","sources":["../../../../../src/module/Editor/lib/init-editor-provider.ts"],"sourcesContent":["import type { MultiCursorOptions } from \"../Editor.types\";\n\ntype InitEditorProviderOptions = {\n initialText?: string;\n} & MultiCursorOptions;\n\nexport async function initEditorProvider({\n roomId,\n url,\n userName = \"Anonymous\",\n userColor,\n initialText,\n onStartProvider,\n}: InitEditorProviderOptions) {\n const { Doc } = await import(\"yjs\");\n const { WebsocketProvider } = await import(\"y-websocket\");\n\n const multiCursorDocument = new Doc();\n const multiCursorText = multiCursorDocument.getText(roomId);\n\n if (!userColor
|
|
1
|
+
{"version":3,"file":"init-editor-provider.js","sources":["../../../../../src/module/Editor/lib/init-editor-provider.ts"],"sourcesContent":["import type { MultiCursorOptions } from \"../Editor.types\";\n\ntype InitEditorProviderOptions = {\n initialText?: string;\n} & MultiCursorOptions;\n\nexport async function initEditorProvider({\n roomId,\n url,\n userName = \"Anonymous\",\n userColor,\n initialText,\n onStartProvider,\n}: InitEditorProviderOptions) {\n const { Doc } = await import(\"yjs\");\n const { WebsocketProvider } = await import(\"y-websocket\");\n\n const multiCursorDocument = new Doc();\n const multiCursorText = multiCursorDocument.getText(roomId);\n\n if (!userColor?.startsWith?.(\"#\")) {\n console.warn(\"user color must be hex!\");\n userColor = \"#30bced\";\n }\n const userColorLight = `${userColor.substring(0, 7)}33`;\n\n const provider = new WebsocketProvider(url, roomId, multiCursorDocument);\n provider.awareness.setLocalStateField(\"user\", {\n name: userName,\n color: userColor,\n colorLight: userColorLight,\n });\n\n if (onStartProvider)\n provider.on(\"status\", (event: { status: string }) => {\n onStartProvider(event?.status);\n });\n\n if (provider)\n provider.on(\"sync\", (isSynced: boolean) => {\n if (isSynced && !multiCursorText.length && initialText) {\n multiCursorText.insert(0, initialText);\n }\n });\n\n return { provider, multiCursorText };\n}\n"],"names":[],"mappings":"AAMO,eAAe,kBAAkB,CAAC,EACvC,MAAM,EACN,GAAG,EACH,QAAQ,GAAG,WAAW,EACtB,SAAS,EACT,WAAW,EACX,eAAe,GACW,EAAA;IAC1B,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,OAAO,KAAK,CAAC;IACnC,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,OAAO,aAAa,CAAC;AAEzD,IAAA,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAE;IACrC,MAAM,eAAe,GAAG,mBAAmB,CAAC,OAAO,CAAC,MAAM,CAAC;IAE3D,IAAI,CAAC,SAAS,EAAE,UAAU,GAAG,GAAG,CAAC,EAAE;AACjC,QAAA,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC;QACvC,SAAS,GAAG,SAAS;;AAEvB,IAAA,MAAM,cAAc,GAAG,CAAG,EAAA,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA,EAAA,CAAI;IAEvD,MAAM,QAAQ,GAAG,IAAI,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,mBAAmB,CAAC;AACxE,IAAA,QAAQ,CAAC,SAAS,CAAC,kBAAkB,CAAC,MAAM,EAAE;AAC5C,QAAA,IAAI,EAAE,QAAQ;AACd,QAAA,KAAK,EAAE,SAAS;AAChB,QAAA,UAAU,EAAE,cAAc;AAC3B,KAAA,CAAC;AAEF,IAAA,IAAI,eAAe;QACjB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAyB,KAAI;AAClD,YAAA,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC;AAChC,SAAC,CAAC;AAEJ,IAAA,IAAI,QAAQ;QACV,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,QAAiB,KAAI;YACxC,IAAI,QAAQ,IAAI,CAAC,eAAe,CAAC,MAAM,IAAI,WAAW,EAAE;AACtD,gBAAA,eAAe,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC;;AAE1C,SAAC,CAAC;AAEJ,IAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE;AACtC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-editor.js","sources":["../../../../../src/module/Editor/lib/init-editor.ts"],"sourcesContent":["import { EditorView } from \"@codemirror/view\";\nimport { type WebsocketProvider } from \"y-websocket\";\nimport type { Text } from \"yjs\";\nimport type { EditorArguments } from \"../Editor.types\";\nimport { initEditorProvider } from \"./init-editor-provider\";\nimport { initEditorState } from \"./init-editor-state\";\n\nexport async function initEditor({ multiCursor, root, initialText, ...rest }: EditorArguments) {\n let provider: WebsocketProvider | undefined;\n let multiCursorText: Text | undefined;\n\n if (multiCursor) {\n const editorProvider = await initEditorProvider({ ...multiCursor, initialText });\n provider = editorProvider.provider;\n multiCursorText = editorProvider.multiCursorText;\n }\n\n const state = await initEditorState({\n ...rest,\n text: initialText
|
|
1
|
+
{"version":3,"file":"init-editor.js","sources":["../../../../../src/module/Editor/lib/init-editor.ts"],"sourcesContent":["import { EditorView } from \"@codemirror/view\";\nimport { type WebsocketProvider } from \"y-websocket\";\nimport type { Text } from \"yjs\";\nimport type { EditorArguments } from \"../Editor.types\";\nimport { initEditorProvider } from \"./init-editor-provider\";\nimport { initEditorState } from \"./init-editor-state\";\n\nexport async function initEditor({ multiCursor, root, initialText, ...rest }: EditorArguments) {\n let provider: WebsocketProvider | undefined;\n let multiCursorText: Text | undefined;\n\n if (multiCursor) {\n const editorProvider = await initEditorProvider({ ...multiCursor, initialText });\n provider = editorProvider.provider;\n multiCursorText = editorProvider.multiCursorText;\n }\n\n const state = await initEditorState({\n ...rest,\n text: initialText ?? \"\",\n provider,\n multiCursorText,\n });\n const view = new EditorView({\n state,\n parent: root,\n });\n\n return { view, provider, multiCursorText };\n}\n"],"names":[],"mappings":";;;;;AAOO,eAAe,UAAU,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,IAAI,EAAmB,EAAA;AAC3F,IAAA,IAAI,QAAuC;AAC3C,IAAA,IAAI,eAAiC;IAErC,IAAI,WAAW,EAAE;AACf,QAAA,MAAM,cAAc,GAAG,MAAM,kBAAkB,CAAC,EAAE,GAAG,WAAW,EAAE,WAAW,EAAE,CAAC;AAChF,QAAA,QAAQ,GAAG,cAAc,CAAC,QAAQ;AAClC,QAAA,eAAe,GAAG,cAAc,CAAC,eAAe;;AAGlD,IAAA,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC;AAClC,QAAA,GAAG,IAAI;QACP,IAAI,EAAE,WAAW,IAAI,EAAE;QACvB,QAAQ;QACR,eAAe;AAChB,KAAA,CAAC;AACF,IAAA,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC;QAC1B,KAAK;AACL,QAAA,MAAM,EAAE,IAAI;AACb,KAAA,CAAC;AAEF,IAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE;AAC5C;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style-inject.es.js","sources":["../../../../../../../../../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n"],"names":[],"mappings":"AAAA,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;AAC/B,EAAE,KAAK,GAAG,KAAK,
|
|
1
|
+
{"version":3,"file":"style-inject.es.js","sources":["../../../../../../../../../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n"],"names":[],"mappings":"AAAA,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;AAC/B,EAAE,KAAK,GAAG,KAAK,MAAM,GAAG,GAAG,GAAG,EAAE;AAChC,EAAE,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ;;AAE7B,EAAE,IAAY,OAAO,QAAQ,KAAK,WAAW,EAAE,EAAE,OAAO;;AAExD,EAAE,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtE,EAAE,IAAI,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;AAC7C,EAAE,KAAK,CAAC,IAAI,GAAG,UAAU;;AAEzB,EAAE,IAAI,QAAQ,KAAK,KAAK,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;AACzB,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC;AAC/C,KAAK,MAAM;AACX,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;AAC7B;AACA,GAAG,MAAM;AACT,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;AAC3B;;AAEA,EAAE,IAAI,KAAK,CAAC,UAAU,EAAE;AACxB,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG;AAClC,GAAG,MAAM;AACT,IAAI,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;AACnD;AACA;;;;","x_google_ignoreList":[0]}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EditorView, KeyBinding, ViewUpdate, Decoration } from '@codemirror/view';
|
|
2
2
|
import { WebsocketProvider } from 'y-websocket';
|
|
3
3
|
import { Text } from 'yjs';
|
|
4
4
|
import { autocompletion } from '@codemirror/autocomplete';
|
|
@@ -25,6 +25,7 @@ type ThemeConfig = {
|
|
|
25
25
|
fontFamily?: string;
|
|
26
26
|
color?: string;
|
|
27
27
|
background?: string;
|
|
28
|
+
codeFontFamily?: string;
|
|
28
29
|
codeBackground?: string;
|
|
29
30
|
codeColor?: string;
|
|
30
31
|
codeButtonColor?: string;
|