@milkdown/crepe 7.12.1 → 7.13.1
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/feature/block-edit/index.js +248 -229
- package/lib/cjs/feature/block-edit/index.js.map +1 -1
- package/lib/cjs/feature/latex/index.js +41 -3
- package/lib/cjs/feature/latex/index.js.map +1 -1
- package/lib/cjs/feature/placeholder/index.js.map +1 -1
- package/lib/cjs/feature/toolbar/index.js +213 -160
- package/lib/cjs/feature/toolbar/index.js.map +1 -1
- package/lib/cjs/index.js +408 -390
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/feature/block-edit/index.js +250 -231
- package/lib/esm/feature/block-edit/index.js.map +1 -1
- package/lib/esm/feature/latex/index.js +42 -4
- package/lib/esm/feature/latex/index.js.map +1 -1
- package/lib/esm/feature/placeholder/index.js.map +1 -1
- package/lib/esm/feature/toolbar/index.js +217 -164
- package/lib/esm/feature/toolbar/index.js.map +1 -1
- package/lib/esm/index.js +414 -396
- package/lib/esm/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/feature/block-edit/index.d.ts +78 -38
- package/lib/types/feature/block-edit/index.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/config.d.ts +3 -2
- package/lib/types/feature/block-edit/menu/config.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/utils.d.ts +2 -24
- package/lib/types/feature/block-edit/menu/utils.d.ts.map +1 -1
- package/lib/types/feature/latex/command.d.ts +2 -0
- package/lib/types/feature/latex/command.d.ts.map +1 -0
- package/lib/types/feature/latex/index.d.ts.map +1 -1
- package/lib/types/feature/toolbar/component.d.ts +1 -1
- package/lib/types/feature/toolbar/component.d.ts.map +1 -1
- package/lib/types/feature/toolbar/config.d.ts +12 -0
- package/lib/types/feature/toolbar/config.d.ts.map +1 -0
- package/lib/types/feature/toolbar/index.d.ts +3 -0
- package/lib/types/feature/toolbar/index.d.ts.map +1 -1
- package/lib/types/utils/checker.d.ts +4 -0
- package/lib/types/utils/checker.d.ts.map +1 -0
- package/lib/types/utils/group-builder.d.ts +43 -0
- package/lib/types/utils/group-builder.d.ts.map +1 -0
- package/lib/types/utils/index.d.ts +3 -3
- package/lib/types/utils/index.d.ts.map +1 -1
- package/lib/types/utils/types.d.ts +4 -0
- package/lib/types/utils/types.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/feature/block-edit/index.ts +78 -38
- package/src/feature/block-edit/menu/config.ts +306 -240
- package/src/feature/block-edit/menu/utils.ts +1 -106
- package/src/feature/latex/command.ts +48 -0
- package/src/feature/latex/index.ts +2 -0
- package/src/feature/toolbar/component.tsx +44 -194
- package/src/feature/toolbar/config.ts +136 -0
- package/src/feature/toolbar/index.ts +3 -0
- package/src/utils/checker.ts +11 -0
- package/src/utils/group-builder.ts +68 -0
- package/src/utils/index.ts +3 -11
- package/src/utils/types.ts +9 -0
- package/lib/types/feature/block-edit/menu/group-builder.d.ts +0 -29
- package/lib/types/feature/block-edit/menu/group-builder.d.ts.map +0 -1
- package/src/feature/block-edit/menu/group-builder.ts +0 -49
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/feature/index.ts","../../../../src/icons/confirm.ts","../../../../src/feature/latex/block-latex.ts","../../../../src/feature/latex/inline-latex.ts","../../../../src/feature/latex/inline-tooltip/tooltip.ts","../../../../src/feature/latex/inline-tooltip/component.tsx","../../../../src/feature/latex/inline-tooltip/view.ts","../../../../src/feature/latex/input-rule.ts","../../../../src/feature/latex/remark.ts","../../../../src/feature/latex/index.ts"],"sourcesContent":["import { createSlice, type Ctx } from '@milkdown/kit/ctx'\n\nimport type { CrepeFeature } from '../feature'\nimport type { CrepeBuilder } from './builder'\n\n/// @internal\n/// The feature flags context.\n/// ⚠️ Most of the time, you should use `useCrepeFeatures` to get the features.\nexport const FeaturesCtx = createSlice([] as CrepeFeature[], 'FeaturesCtx')\n\n/// @internal\n/// The crepe editor context.\n/// ⚠️ Most of the time, you should use `useCrepe` to get the crepe editor instance.\nexport const CrepeCtx = createSlice({} as CrepeBuilder, 'CrepeCtx')\n\n/// The crepe editor context.\n/// You can use this context to access the crepe editor instance within Milkdown plugins.\n/// ```ts\n/// import { crepeCtx } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// return () => {\n/// const crepe = useCrepe(ctx)\n/// crepe.setReadonly(true)\n/// }\n/// }\n/// ```\nexport function useCrepe(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.get<CrepeBuilder, 'CrepeCtx'>('CrepeCtx')\n}\n\n/// Check the enabled FeatureFlags\n/// ```ts\n/// import { useCrepeFeatures } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// const features = useCrepeFeatures(ctx)\n/// if (features.get().includes(CrepeFeature.CodeMirror)) {\n/// // Do something with CodeMirror\n/// }\n/// }\nexport function useCrepeFeatures(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.use<CrepeFeature[], 'FeaturesCtx'>('FeaturesCtx')\n}\n\n/// @internal\nexport function crepeFeatureConfig(feature: CrepeFeature) {\n return (ctx: Ctx) => {\n useCrepeFeatures(ctx).update((features) => {\n if (features.includes(feature)) {\n return features\n }\n return [...features, feature]\n })\n }\n}\n","import type { BlockEditFeatureConfig } from './block-edit'\nimport type { CodeMirrorFeatureConfig } from './code-mirror'\nimport type { CursorFeatureConfig } from './cursor'\nimport type { ImageBlockFeatureConfig } from './image-block'\nimport type { LatexFeatureConfig } from './latex'\nimport type { LinkTooltipFeatureConfig } from './link-tooltip'\nimport type { ListItemFeatureConfig } from './list-item'\nimport type { PlaceholderFeatureConfig } from './placeholder'\nimport type { TableFeatureConfig } from './table'\nimport type { ToolbarFeatureConfig } from './toolbar'\n\n/// The crepe editor feature flags.\n/// Every feature is enabled by default.\n/// Every feature is a string literal type.\nexport enum CrepeFeature {\n /// Syntax highlighting and editing for code blocks with language support, theme customization, and preview capabilities.\n CodeMirror = 'code-mirror',\n\n /// Support for bullet lists, ordered lists, and todo lists with customizable icons and formatting.\n ListItem = 'list-item',\n\n /// Enhanced link editing and preview with customizable tooltips, edit/remove actions, and copy functionality.\n LinkTooltip = 'link-tooltip',\n\n /// Enhanced cursor experience with drop cursor and gap cursor for better content placement.\n Cursor = 'cursor',\n\n /// Image upload and management with resizing, captions, and support for both inline and block images.\n ImageBlock = 'image-block',\n\n /// Drag-and-drop block management and slash commands for quick content insertion and organization.\n BlockEdit = 'block-edit',\n\n /// Formatting toolbar for selected text with customizable icons and actions.\n Toolbar = 'toolbar',\n\n /// Document or block level placeholders to guide users when content is empty.\n Placeholder = 'placeholder',\n\n /// Full-featured table editing with row/column management, alignment options, and drag-and-drop functionality.\n Table = 'table',\n\n /// Mathematical formula support with both inline and block math rendering using KaTeX.\n Latex = 'latex',\n}\n\nexport interface CrepeFeatureConfig {\n [CrepeFeature.Cursor]?: CursorFeatureConfig\n [CrepeFeature.ListItem]?: ListItemFeatureConfig\n [CrepeFeature.LinkTooltip]?: LinkTooltipFeatureConfig\n [CrepeFeature.ImageBlock]?: ImageBlockFeatureConfig\n [CrepeFeature.BlockEdit]?: BlockEditFeatureConfig\n [CrepeFeature.Placeholder]?: PlaceholderFeatureConfig\n [CrepeFeature.Toolbar]?: ToolbarFeatureConfig\n [CrepeFeature.CodeMirror]?: CodeMirrorFeatureConfig\n [CrepeFeature.Table]?: TableFeatureConfig\n [CrepeFeature.Latex]?: LatexFeatureConfig\n}\n\nexport const defaultFeatures: Record<CrepeFeature, boolean> = {\n [CrepeFeature.Cursor]: true,\n [CrepeFeature.ListItem]: true,\n [CrepeFeature.LinkTooltip]: true,\n [CrepeFeature.ImageBlock]: true,\n [CrepeFeature.BlockEdit]: true,\n [CrepeFeature.Placeholder]: true,\n [CrepeFeature.Toolbar]: true,\n [CrepeFeature.CodeMirror]: true,\n [CrepeFeature.Table]: true,\n [CrepeFeature.Latex]: true,\n}\n","export const confirmIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n >\n <g clip-path=\"url(#clip0_1013_1606)\">\n <path\n d=\"M9.00012 16.1998L5.50012 12.6998C5.11012 12.3098 4.49012 12.3098 4.10012 12.6998C3.71012 13.0898 3.71012 13.7098 4.10012 14.0998L8.29012 18.2898C8.68012 18.6798 9.31012 18.6798 9.70012 18.2898L20.3001 7.69982C20.6901 7.30982 20.6901 6.68982 20.3001 6.29982C19.9101 5.90982 19.2901 5.90982 18.9001 6.29982L9.00012 16.1998Z\"\n fill=\"#817567\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1013_1606\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","import { codeBlockSchema } from '@milkdown/kit/preset/commonmark'\n\nexport const blockLatexSchema = codeBlockSchema.extendSchema((prev) => {\n return (ctx) => {\n const baseSchema = prev(ctx)\n return {\n ...baseSchema,\n toMarkdown: {\n match: baseSchema.toMarkdown.match,\n runner: (state, node) => {\n const language = node.attrs.language ?? ''\n if (language.toLowerCase() === 'latex') {\n state.addNode(\n 'math',\n undefined,\n node.content.firstChild?.text || ''\n )\n } else {\n return baseSchema.toMarkdown.runner(state, node)\n }\n },\n },\n }\n }\n})\n","import { $nodeSchema } from '@milkdown/kit/utils'\nimport katex from 'katex'\n\nexport const mathInlineId = 'math_inline'\n\n/// Schema for inline math node.\n/// Add support for:\n///\n/// ```markdown\n/// $a^2 + b^2 = c^2$\n/// ```\nexport const mathInlineSchema = $nodeSchema(mathInlineId, () => ({\n group: 'inline',\n inline: true,\n draggable: true,\n atom: true,\n attrs: {\n value: {\n default: '',\n },\n },\n parseDOM: [\n {\n tag: `span[data-type=\"${mathInlineId}\"]`,\n getAttrs: (dom) => {\n return {\n value: (dom as HTMLElement).dataset.value ?? '',\n }\n },\n },\n ],\n toDOM: (node) => {\n const code: string = node.attrs.value\n const dom = document.createElement('span')\n dom.dataset.type = mathInlineId\n dom.dataset.value = code\n katex.render(code, dom, {\n throwOnError: false,\n })\n\n return dom\n },\n parseMarkdown: {\n match: (node) => node.type === 'inlineMath',\n runner: (state, node, type) => {\n state.addNode(type, { value: node.value as string })\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === mathInlineId,\n runner: (state, node) => {\n state.addNode('inlineMath', undefined, node.attrs.value)\n },\n },\n}))\n","import { tooltipFactory } from '@milkdown/kit/plugin/tooltip'\n\nexport const inlineLatexTooltip = tooltipFactory('INLINE_LATEX')\n","import type { EditorView } from '@milkdown/kit/prose/view'\n\nimport { Icon } from '@milkdown/kit/component'\nimport { defineComponent, type ShallowRef, type VNodeRef, h } from 'vue'\n\nimport type { LatexConfig } from '..'\n\ntype LatexTooltipProps = {\n config: Partial<LatexConfig>\n innerView: ShallowRef<EditorView | null>\n updateValue: ShallowRef<() => void>\n}\n\nh\n\nexport const LatexTooltip = defineComponent<LatexTooltipProps>({\n props: {\n config: {\n type: Object,\n required: true,\n },\n innerView: {\n type: Object,\n required: true,\n },\n updateValue: {\n type: Object,\n required: true,\n },\n },\n setup(props) {\n const innerViewRef: VNodeRef = (el) => {\n if (!el || !(el instanceof HTMLElement)) return\n while (el.firstChild) {\n el.removeChild(el.firstChild)\n }\n if (props.innerView.value) {\n el.appendChild(props.innerView.value.dom)\n }\n }\n const onUpdate = (e: Event) => {\n e.preventDefault()\n props.updateValue.value()\n }\n\n return () => {\n return (\n <div class=\"container\">\n {props.innerView && <div ref={innerViewRef} />}\n <button onPointerdown={onUpdate}>\n <Icon icon={props.config.inlineEditConfirm} />\n </button>\n </div>\n )\n }\n },\n})\n","import type { Ctx } from '@milkdown/kit/ctx'\nimport type { PluginView } from '@milkdown/kit/prose/state'\n\nimport { TooltipProvider } from '@milkdown/kit/plugin/tooltip'\nimport { redo, undo } from '@milkdown/kit/prose/history'\nimport { keymap } from '@milkdown/kit/prose/keymap'\nimport { Schema } from '@milkdown/kit/prose/model'\nimport { EditorState, NodeSelection } from '@milkdown/kit/prose/state'\nimport { EditorView } from '@milkdown/kit/prose/view'\nimport { createApp, shallowRef, type App, type ShallowRef } from 'vue'\n\nimport type { LatexConfig } from '..'\n\nimport { mathInlineId } from '../inline-latex'\nimport { LatexTooltip } from './component'\n\nexport class LatexInlineTooltip implements PluginView {\n #content: HTMLElement\n #provider: TooltipProvider\n #dom: HTMLElement\n #innerView: ShallowRef<EditorView | null> = shallowRef(null)\n #updateValue: ShallowRef<() => void> = shallowRef(() => {})\n #app: App\n\n constructor(\n readonly ctx: Ctx,\n view: EditorView,\n config: Partial<LatexConfig>\n ) {\n const content = document.createElement('div')\n content.className = 'milkdown-latex-inline-edit'\n this.#content = content\n this.#app = createApp(LatexTooltip, {\n config,\n innerView: this.#innerView,\n updateValue: this.#updateValue,\n })\n this.#app.mount(content)\n this.#provider = new TooltipProvider({\n debounce: 0,\n content: this.#content,\n shouldShow: this.#shouldShow,\n offset: 10,\n floatingUIOptions: {\n placement: 'bottom',\n },\n })\n this.#provider.update(view)\n this.#dom = document.createElement('div')\n }\n\n #onHide = () => {\n if (this.#innerView.value) {\n this.#innerView.value.destroy()\n this.#innerView.value = null\n }\n }\n\n #shouldShow = (view: EditorView) => {\n const shouldShow = () => {\n const { selection, schema } = view.state\n if (selection.empty) return false\n if (!(selection instanceof NodeSelection)) return false\n const node = selection.node\n if (node.type.name !== mathInlineId) return false\n\n const textFrom = selection.from\n\n const paragraph = schema.nodes.paragraph!.create(\n null,\n schema.text(node.attrs.value)\n )\n\n const innerView = new EditorView(this.#dom, {\n state: EditorState.create({\n doc: paragraph,\n schema: new Schema({\n nodes: {\n doc: {\n content: 'block+',\n },\n paragraph: {\n content: 'inline*',\n group: 'block',\n parseDOM: [{ tag: 'p' }],\n toDOM() {\n return ['p', 0]\n },\n },\n text: {\n group: 'inline',\n },\n },\n }),\n plugins: [\n keymap({\n 'Mod-z': undo,\n 'Mod-Z': redo,\n 'Mod-y': redo,\n Enter: () => {\n this.#updateValue.value()\n return true\n },\n }),\n ],\n }),\n })\n\n this.#innerView.value = innerView\n this.#updateValue.value = () => {\n const { tr } = view.state\n tr.setNodeAttribute(textFrom, 'value', innerView.state.doc.textContent)\n view.dispatch(tr)\n requestAnimationFrame(() => {\n view.focus()\n })\n }\n return true\n }\n\n const show = shouldShow()\n if (!show) this.#onHide()\n return show\n }\n\n update = (view: EditorView, prevState?: EditorState) => {\n this.#provider.update(view, prevState)\n }\n\n destroy = () => {\n this.#app.unmount()\n this.#provider.destroy()\n this.#content.remove()\n }\n}\n","import { codeBlockSchema } from '@milkdown/kit/preset/commonmark'\nimport { nodeRule } from '@milkdown/kit/prose'\nimport { textblockTypeInputRule } from '@milkdown/kit/prose/inputrules'\nimport { $inputRule } from '@milkdown/kit/utils'\n\nimport { mathInlineSchema } from './inline-latex'\n\n/// Input rule for inline math.\n/// When you type $E=MC^2$, it will create an inline math node.\nexport const mathInlineInputRule = $inputRule((ctx) =>\n nodeRule(/(?:\\$)([^$]+)(?:\\$)$/, mathInlineSchema.type(ctx), {\n getAttr: (match) => {\n return {\n value: match[1] ?? '',\n }\n },\n })\n)\n\n/// A input rule for creating block math.\n/// For example, `$$ ` will create a code block with language javascript.\nexport const mathBlockInputRule = $inputRule((ctx) =>\n textblockTypeInputRule(/^\\$\\$[\\s\\n]$/, codeBlockSchema.type(ctx), () => ({\n language: 'LaTeX',\n }))\n)\n","import type { Node } from '@milkdown/kit/transformer'\n\nimport { $remark } from '@milkdown/kit/utils'\nimport remarkMath from 'remark-math'\nimport { visit } from 'unist-util-visit'\n\nexport const remarkMathPlugin = $remark<'remarkMath', undefined>(\n 'remarkMath',\n () => remarkMath\n)\n\nfunction visitMathBlock(ast: Node) {\n return visit(\n ast,\n 'math',\n (\n node: Node & { value: string },\n index: number,\n parent: Node & { children: Node[] }\n ) => {\n const { value } = node as Node & { value: string }\n const newNode = {\n type: 'code',\n lang: 'LaTeX',\n value,\n }\n parent.children.splice(index, 1, newNode)\n }\n )\n}\n\n/// Turn math block into code block with language LaTeX.\nexport const remarkMathBlockPlugin = $remark(\n 'remarkMathBlock',\n () => () => visitMathBlock\n)\n","import type { KatexOptions } from 'katex'\n\nimport { codeBlockConfig } from '@milkdown/kit/component/code-block'\nimport katex from 'katex'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig, useCrepeFeatures } from '../../core/slice'\nimport { CrepeFeature } from '../../feature'\nimport { confirmIcon } from '../../icons'\nimport { blockLatexSchema } from './block-latex'\nimport { mathInlineSchema } from './inline-latex'\nimport { inlineLatexTooltip } from './inline-tooltip/tooltip'\nimport { LatexInlineTooltip } from './inline-tooltip/view'\nimport { mathBlockInputRule, mathInlineInputRule } from './input-rule'\nimport { remarkMathBlockPlugin, remarkMathPlugin } from './remark'\n\nexport interface LatexConfig {\n katexOptions: KatexOptions\n inlineEditConfirm: string\n}\n\nexport type LatexFeatureConfig = Partial<LatexConfig>\n\nexport const latex: DefineFeature<LatexFeatureConfig> = (editor, config) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.Latex))\n .config((ctx) => {\n const flags = useCrepeFeatures(ctx).get()\n const isCodeMirrorEnabled = flags.includes(CrepeFeature.CodeMirror)\n if (!isCodeMirrorEnabled) {\n throw new Error('You need to enable CodeMirror to use LaTeX feature')\n }\n\n ctx.update(codeBlockConfig.key, (prev) => ({\n ...prev,\n renderPreview: (language, content) => {\n if (language.toLowerCase() === 'latex' && content.length > 0) {\n return renderLatex(content, config?.katexOptions)\n }\n const renderPreview = prev.renderPreview\n return renderPreview(language, content)\n },\n }))\n\n ctx.set(inlineLatexTooltip.key, {\n view: (view) => {\n return new LatexInlineTooltip(ctx, view, {\n inlineEditConfirm: config?.inlineEditConfirm ?? confirmIcon,\n ...config,\n })\n },\n })\n })\n .use(remarkMathPlugin)\n .use(remarkMathBlockPlugin)\n .use(mathInlineSchema)\n .use(inlineLatexTooltip)\n .use(mathInlineInputRule)\n .use(mathBlockInputRule)\n .use(blockLatexSchema)\n}\n\nfunction renderLatex(content: string, options?: KatexOptions) {\n const html = katex.renderToString(content, {\n ...options,\n throwOnError: false,\n displayMode: true,\n })\n return html\n}\n"],"names":["createSlice","CrepeFeature","codeBlockSchema","$nodeSchema","tooltipFactory","defineComponent","h","Icon","view","shallowRef","NodeSelection","EditorView","EditorState","Schema","keymap","undo","redo","createApp","TooltipProvider","$inputRule","nodeRule","textblockTypeInputRule","$remark","visit","codeBlockConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQ2BA,eAAA,CAAY,EAAC,EAAqB,aAAa;AAKlDA,eAAA,CAAY,EAAC,EAAmB,UAAU;AA2B3D,SAAS,iBAAiB,GAAU,EAAA;AAEzC,EAAO,OAAA,GAAA,CAAI,IAAmC,aAAa,CAAA;AAC7D;AAGO,SAAS,mBAAmB,OAAuB,EAAA;AACxD,EAAA,OAAO,CAAC,GAAa,KAAA;AACnB,IAAA,gBAAA,CAAiB,GAAG,CAAA,CAAE,MAAO,CAAA,CAAC,QAAa,KAAA;AACzC,MAAI,IAAA,QAAA,CAAS,QAAS,CAAA,OAAO,CAAG,EAAA;AAC9B,QAAO,OAAA,QAAA;AAAA;AAET,MAAO,OAAA,CAAC,GAAG,QAAA,EAAU,OAAO,CAAA;AAAA,KAC7B,CAAA;AAAA,GACH;AACF;;ACzCY,IAAA,YAAA,qBAAAC,aAAL,KAAA;AAEL,EAAAA,cAAA,YAAa,CAAA,GAAA,aAAA;AAGb,EAAAA,cAAA,UAAW,CAAA,GAAA,WAAA;AAGX,EAAAA,cAAA,aAAc,CAAA,GAAA,cAAA;AAGd,EAAAA,cAAA,QAAS,CAAA,GAAA,QAAA;AAGT,EAAAA,cAAA,YAAa,CAAA,GAAA,aAAA;AAGb,EAAAA,cAAA,WAAY,CAAA,GAAA,YAAA;AAGZ,EAAAA,cAAA,SAAU,CAAA,GAAA,SAAA;AAGV,EAAAA,cAAA,aAAc,CAAA,GAAA,aAAA;AAGd,EAAAA,cAAA,OAAQ,CAAA,GAAA,OAAA;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pB,GAAI,CAAA,kBAAkB,EACtB,GAAI,CAAA,mBAAmB,EACvB,GAAI,CAAA,kBAAkB,CACtB,CAAA,GAAA,CAAI,gBAAgB,CAAA;AACzB;AAEA,SAAS,WAAA,CAAY,SAAiB,OAAwB,EAAA;AAC5D,EAAM,MAAA,IAAA,GAAO,KAAM,CAAA,cAAA,CAAe,OAAS,EAAA;AAAA,IACzC,GAAG,OAAA;AAAA,IACH,YAAc,EAAA,KAAA;AAAA,IACd,WAAa,EAAA;AAAA,GACd,CAAA;AACD,EAAO,OAAA,IAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/feature/index.ts","../../../../src/icons/confirm.ts","../../../../src/feature/latex/block-latex.ts","../../../../src/feature/latex/inline-latex.ts","../../../../src/feature/latex/command.ts","../../../../src/feature/latex/inline-tooltip/tooltip.ts","../../../../src/feature/latex/inline-tooltip/component.tsx","../../../../src/feature/latex/inline-tooltip/view.ts","../../../../src/feature/latex/input-rule.ts","../../../../src/feature/latex/remark.ts","../../../../src/feature/latex/index.ts"],"sourcesContent":["import { createSlice, type Ctx } from '@milkdown/kit/ctx'\n\nimport type { CrepeFeature } from '../feature'\nimport type { CrepeBuilder } from './builder'\n\n/// @internal\n/// The feature flags context.\n/// ⚠️ Most of the time, you should use `useCrepeFeatures` to get the features.\nexport const FeaturesCtx = createSlice([] as CrepeFeature[], 'FeaturesCtx')\n\n/// @internal\n/// The crepe editor context.\n/// ⚠️ Most of the time, you should use `useCrepe` to get the crepe editor instance.\nexport const CrepeCtx = createSlice({} as CrepeBuilder, 'CrepeCtx')\n\n/// The crepe editor context.\n/// You can use this context to access the crepe editor instance within Milkdown plugins.\n/// ```ts\n/// import { crepeCtx } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// return () => {\n/// const crepe = useCrepe(ctx)\n/// crepe.setReadonly(true)\n/// }\n/// }\n/// ```\nexport function useCrepe(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.get<CrepeBuilder, 'CrepeCtx'>('CrepeCtx')\n}\n\n/// Check the enabled FeatureFlags\n/// ```ts\n/// import { useCrepeFeatures } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// const features = useCrepeFeatures(ctx)\n/// if (features.get().includes(CrepeFeature.CodeMirror)) {\n/// // Do something with CodeMirror\n/// }\n/// }\nexport function useCrepeFeatures(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.use<CrepeFeature[], 'FeaturesCtx'>('FeaturesCtx')\n}\n\n/// @internal\nexport function crepeFeatureConfig(feature: CrepeFeature) {\n return (ctx: Ctx) => {\n useCrepeFeatures(ctx).update((features) => {\n if (features.includes(feature)) {\n return features\n }\n return [...features, feature]\n })\n }\n}\n","import type { BlockEditFeatureConfig } from './block-edit'\nimport type { CodeMirrorFeatureConfig } from './code-mirror'\nimport type { CursorFeatureConfig } from './cursor'\nimport type { ImageBlockFeatureConfig } from './image-block'\nimport type { LatexFeatureConfig } from './latex'\nimport type { LinkTooltipFeatureConfig } from './link-tooltip'\nimport type { ListItemFeatureConfig } from './list-item'\nimport type { PlaceholderFeatureConfig } from './placeholder'\nimport type { TableFeatureConfig } from './table'\nimport type { ToolbarFeatureConfig } from './toolbar'\n\n/// The crepe editor feature flags.\n/// Every feature is enabled by default.\n/// Every feature is a string literal type.\nexport enum CrepeFeature {\n /// Syntax highlighting and editing for code blocks with language support, theme customization, and preview capabilities.\n CodeMirror = 'code-mirror',\n\n /// Support for bullet lists, ordered lists, and todo lists with customizable icons and formatting.\n ListItem = 'list-item',\n\n /// Enhanced link editing and preview with customizable tooltips, edit/remove actions, and copy functionality.\n LinkTooltip = 'link-tooltip',\n\n /// Enhanced cursor experience with drop cursor and gap cursor for better content placement.\n Cursor = 'cursor',\n\n /// Image upload and management with resizing, captions, and support for both inline and block images.\n ImageBlock = 'image-block',\n\n /// Drag-and-drop block management and slash commands for quick content insertion and organization.\n BlockEdit = 'block-edit',\n\n /// Formatting toolbar for selected text with customizable icons and actions.\n Toolbar = 'toolbar',\n\n /// Document or block level placeholders to guide users when content is empty.\n Placeholder = 'placeholder',\n\n /// Full-featured table editing with row/column management, alignment options, and drag-and-drop functionality.\n Table = 'table',\n\n /// Mathematical formula support with both inline and block math rendering using KaTeX.\n Latex = 'latex',\n}\n\nexport interface CrepeFeatureConfig {\n [CrepeFeature.Cursor]?: CursorFeatureConfig\n [CrepeFeature.ListItem]?: ListItemFeatureConfig\n [CrepeFeature.LinkTooltip]?: LinkTooltipFeatureConfig\n [CrepeFeature.ImageBlock]?: ImageBlockFeatureConfig\n [CrepeFeature.BlockEdit]?: BlockEditFeatureConfig\n [CrepeFeature.Placeholder]?: PlaceholderFeatureConfig\n [CrepeFeature.Toolbar]?: ToolbarFeatureConfig\n [CrepeFeature.CodeMirror]?: CodeMirrorFeatureConfig\n [CrepeFeature.Table]?: TableFeatureConfig\n [CrepeFeature.Latex]?: LatexFeatureConfig\n}\n\nexport const defaultFeatures: Record<CrepeFeature, boolean> = {\n [CrepeFeature.Cursor]: true,\n [CrepeFeature.ListItem]: true,\n [CrepeFeature.LinkTooltip]: true,\n [CrepeFeature.ImageBlock]: true,\n [CrepeFeature.BlockEdit]: true,\n [CrepeFeature.Placeholder]: true,\n [CrepeFeature.Toolbar]: true,\n [CrepeFeature.CodeMirror]: true,\n [CrepeFeature.Table]: true,\n [CrepeFeature.Latex]: true,\n}\n","export const confirmIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n >\n <g clip-path=\"url(#clip0_1013_1606)\">\n <path\n d=\"M9.00012 16.1998L5.50012 12.6998C5.11012 12.3098 4.49012 12.3098 4.10012 12.6998C3.71012 13.0898 3.71012 13.7098 4.10012 14.0998L8.29012 18.2898C8.68012 18.6798 9.31012 18.6798 9.70012 18.2898L20.3001 7.69982C20.6901 7.30982 20.6901 6.68982 20.3001 6.29982C19.9101 5.90982 19.2901 5.90982 18.9001 6.29982L9.00012 16.1998Z\"\n fill=\"#817567\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1013_1606\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","import { codeBlockSchema } from '@milkdown/kit/preset/commonmark'\n\nexport const blockLatexSchema = codeBlockSchema.extendSchema((prev) => {\n return (ctx) => {\n const baseSchema = prev(ctx)\n return {\n ...baseSchema,\n toMarkdown: {\n match: baseSchema.toMarkdown.match,\n runner: (state, node) => {\n const language = node.attrs.language ?? ''\n if (language.toLowerCase() === 'latex') {\n state.addNode(\n 'math',\n undefined,\n node.content.firstChild?.text || ''\n )\n } else {\n return baseSchema.toMarkdown.runner(state, node)\n }\n },\n },\n }\n }\n})\n","import { $nodeSchema } from '@milkdown/kit/utils'\nimport katex from 'katex'\n\nexport const mathInlineId = 'math_inline'\n\n/// Schema for inline math node.\n/// Add support for:\n///\n/// ```markdown\n/// $a^2 + b^2 = c^2$\n/// ```\nexport const mathInlineSchema = $nodeSchema(mathInlineId, () => ({\n group: 'inline',\n inline: true,\n draggable: true,\n atom: true,\n attrs: {\n value: {\n default: '',\n },\n },\n parseDOM: [\n {\n tag: `span[data-type=\"${mathInlineId}\"]`,\n getAttrs: (dom) => {\n return {\n value: (dom as HTMLElement).dataset.value ?? '',\n }\n },\n },\n ],\n toDOM: (node) => {\n const code: string = node.attrs.value\n const dom = document.createElement('span')\n dom.dataset.type = mathInlineId\n dom.dataset.value = code\n katex.render(code, dom, {\n throwOnError: false,\n })\n\n return dom\n },\n parseMarkdown: {\n match: (node) => node.type === 'inlineMath',\n runner: (state, node, type) => {\n state.addNode(type, { value: node.value as string })\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === mathInlineId,\n runner: (state, node) => {\n state.addNode('inlineMath', undefined, node.attrs.value)\n },\n },\n}))\n","import type { Node } from '@milkdown/kit/prose/model'\n\nimport { findNodeInSelection } from '@milkdown/kit/prose'\nimport { NodeSelection, TextSelection } from '@milkdown/kit/prose/state'\nimport { $command } from '@milkdown/kit/utils'\n\nimport { mathInlineSchema } from './inline-latex'\n\nexport const toggleLatexCommand = $command('ToggleLatex', (ctx) => {\n return () => (state, dispatch) => {\n const {\n hasNode: hasLatex,\n pos: latexPos,\n target: latexNode,\n } = findNodeInSelection(state, mathInlineSchema.type(ctx))\n\n const { selection, doc, tr } = state\n if (!hasLatex) {\n const text = doc.textBetween(selection.from, selection.to)\n let _tr = tr.replaceSelectionWith(\n mathInlineSchema.type(ctx).create({\n value: text,\n })\n )\n if (dispatch) {\n dispatch(\n _tr.setSelection(NodeSelection.create(_tr.doc, selection.from))\n )\n }\n return true\n }\n\n const { from, to } = selection\n if (!latexNode || latexPos < 0) return false\n\n let _tr = tr.delete(latexPos, latexPos + 1)\n const content = (latexNode as Node).attrs.value\n _tr = _tr.insertText(content, latexPos)\n if (dispatch) {\n dispatch(\n _tr.setSelection(\n TextSelection.create(_tr.doc, from, to + content.length - 1)\n )\n )\n }\n return true\n }\n})\n","import { tooltipFactory } from '@milkdown/kit/plugin/tooltip'\n\nexport const inlineLatexTooltip = tooltipFactory('INLINE_LATEX')\n","import type { EditorView } from '@milkdown/kit/prose/view'\n\nimport { Icon } from '@milkdown/kit/component'\nimport { defineComponent, type ShallowRef, type VNodeRef, h } from 'vue'\n\nimport type { LatexConfig } from '..'\n\ntype LatexTooltipProps = {\n config: Partial<LatexConfig>\n innerView: ShallowRef<EditorView | null>\n updateValue: ShallowRef<() => void>\n}\n\nh\n\nexport const LatexTooltip = defineComponent<LatexTooltipProps>({\n props: {\n config: {\n type: Object,\n required: true,\n },\n innerView: {\n type: Object,\n required: true,\n },\n updateValue: {\n type: Object,\n required: true,\n },\n },\n setup(props) {\n const innerViewRef: VNodeRef = (el) => {\n if (!el || !(el instanceof HTMLElement)) return\n while (el.firstChild) {\n el.removeChild(el.firstChild)\n }\n if (props.innerView.value) {\n el.appendChild(props.innerView.value.dom)\n }\n }\n const onUpdate = (e: Event) => {\n e.preventDefault()\n props.updateValue.value()\n }\n\n return () => {\n return (\n <div class=\"container\">\n {props.innerView && <div ref={innerViewRef} />}\n <button onPointerdown={onUpdate}>\n <Icon icon={props.config.inlineEditConfirm} />\n </button>\n </div>\n )\n }\n },\n})\n","import type { Ctx } from '@milkdown/kit/ctx'\nimport type { PluginView } from '@milkdown/kit/prose/state'\n\nimport { TooltipProvider } from '@milkdown/kit/plugin/tooltip'\nimport { redo, undo } from '@milkdown/kit/prose/history'\nimport { keymap } from '@milkdown/kit/prose/keymap'\nimport { Schema } from '@milkdown/kit/prose/model'\nimport { EditorState, NodeSelection } from '@milkdown/kit/prose/state'\nimport { EditorView } from '@milkdown/kit/prose/view'\nimport { createApp, shallowRef, type App, type ShallowRef } from 'vue'\n\nimport type { LatexConfig } from '..'\n\nimport { mathInlineId } from '../inline-latex'\nimport { LatexTooltip } from './component'\n\nexport class LatexInlineTooltip implements PluginView {\n #content: HTMLElement\n #provider: TooltipProvider\n #dom: HTMLElement\n #innerView: ShallowRef<EditorView | null> = shallowRef(null)\n #updateValue: ShallowRef<() => void> = shallowRef(() => {})\n #app: App\n\n constructor(\n readonly ctx: Ctx,\n view: EditorView,\n config: Partial<LatexConfig>\n ) {\n const content = document.createElement('div')\n content.className = 'milkdown-latex-inline-edit'\n this.#content = content\n this.#app = createApp(LatexTooltip, {\n config,\n innerView: this.#innerView,\n updateValue: this.#updateValue,\n })\n this.#app.mount(content)\n this.#provider = new TooltipProvider({\n debounce: 0,\n content: this.#content,\n shouldShow: this.#shouldShow,\n offset: 10,\n floatingUIOptions: {\n placement: 'bottom',\n },\n })\n this.#provider.update(view)\n this.#dom = document.createElement('div')\n }\n\n #onHide = () => {\n if (this.#innerView.value) {\n this.#innerView.value.destroy()\n this.#innerView.value = null\n }\n }\n\n #shouldShow = (view: EditorView) => {\n const shouldShow = () => {\n const { selection, schema } = view.state\n if (selection.empty) return false\n if (!(selection instanceof NodeSelection)) return false\n const node = selection.node\n if (node.type.name !== mathInlineId) return false\n\n const textFrom = selection.from\n\n const paragraph = schema.nodes.paragraph!.create(\n null,\n schema.text(node.attrs.value)\n )\n\n const innerView = new EditorView(this.#dom, {\n state: EditorState.create({\n doc: paragraph,\n schema: new Schema({\n nodes: {\n doc: {\n content: 'block+',\n },\n paragraph: {\n content: 'inline*',\n group: 'block',\n parseDOM: [{ tag: 'p' }],\n toDOM() {\n return ['p', 0]\n },\n },\n text: {\n group: 'inline',\n },\n },\n }),\n plugins: [\n keymap({\n 'Mod-z': undo,\n 'Mod-Z': redo,\n 'Mod-y': redo,\n Enter: () => {\n this.#updateValue.value()\n return true\n },\n }),\n ],\n }),\n })\n\n this.#innerView.value = innerView\n this.#updateValue.value = () => {\n const { tr } = view.state\n tr.setNodeAttribute(textFrom, 'value', innerView.state.doc.textContent)\n view.dispatch(tr)\n requestAnimationFrame(() => {\n view.focus()\n })\n }\n return true\n }\n\n const show = shouldShow()\n if (!show) this.#onHide()\n return show\n }\n\n update = (view: EditorView, prevState?: EditorState) => {\n this.#provider.update(view, prevState)\n }\n\n destroy = () => {\n this.#app.unmount()\n this.#provider.destroy()\n this.#content.remove()\n }\n}\n","import { codeBlockSchema } from '@milkdown/kit/preset/commonmark'\nimport { nodeRule } from '@milkdown/kit/prose'\nimport { textblockTypeInputRule } from '@milkdown/kit/prose/inputrules'\nimport { $inputRule } from '@milkdown/kit/utils'\n\nimport { mathInlineSchema } from './inline-latex'\n\n/// Input rule for inline math.\n/// When you type $E=MC^2$, it will create an inline math node.\nexport const mathInlineInputRule = $inputRule((ctx) =>\n nodeRule(/(?:\\$)([^$]+)(?:\\$)$/, mathInlineSchema.type(ctx), {\n getAttr: (match) => {\n return {\n value: match[1] ?? '',\n }\n },\n })\n)\n\n/// A input rule for creating block math.\n/// For example, `$$ ` will create a code block with language javascript.\nexport const mathBlockInputRule = $inputRule((ctx) =>\n textblockTypeInputRule(/^\\$\\$[\\s\\n]$/, codeBlockSchema.type(ctx), () => ({\n language: 'LaTeX',\n }))\n)\n","import type { Node } from '@milkdown/kit/transformer'\n\nimport { $remark } from '@milkdown/kit/utils'\nimport remarkMath from 'remark-math'\nimport { visit } from 'unist-util-visit'\n\nexport const remarkMathPlugin = $remark<'remarkMath', undefined>(\n 'remarkMath',\n () => remarkMath\n)\n\nfunction visitMathBlock(ast: Node) {\n return visit(\n ast,\n 'math',\n (\n node: Node & { value: string },\n index: number,\n parent: Node & { children: Node[] }\n ) => {\n const { value } = node as Node & { value: string }\n const newNode = {\n type: 'code',\n lang: 'LaTeX',\n value,\n }\n parent.children.splice(index, 1, newNode)\n }\n )\n}\n\n/// Turn math block into code block with language LaTeX.\nexport const remarkMathBlockPlugin = $remark(\n 'remarkMathBlock',\n () => () => visitMathBlock\n)\n","import type { KatexOptions } from 'katex'\n\nimport { codeBlockConfig } from '@milkdown/kit/component/code-block'\nimport katex from 'katex'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig, useCrepeFeatures } from '../../core/slice'\nimport { CrepeFeature } from '../../feature'\nimport { confirmIcon } from '../../icons'\nimport { blockLatexSchema } from './block-latex'\nimport { toggleLatexCommand } from './command'\nimport { mathInlineSchema } from './inline-latex'\nimport { inlineLatexTooltip } from './inline-tooltip/tooltip'\nimport { LatexInlineTooltip } from './inline-tooltip/view'\nimport { mathBlockInputRule, mathInlineInputRule } from './input-rule'\nimport { remarkMathBlockPlugin, remarkMathPlugin } from './remark'\n\nexport interface LatexConfig {\n katexOptions: KatexOptions\n inlineEditConfirm: string\n}\n\nexport type LatexFeatureConfig = Partial<LatexConfig>\n\nexport const latex: DefineFeature<LatexFeatureConfig> = (editor, config) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.Latex))\n .config((ctx) => {\n const flags = useCrepeFeatures(ctx).get()\n const isCodeMirrorEnabled = flags.includes(CrepeFeature.CodeMirror)\n if (!isCodeMirrorEnabled) {\n throw new Error('You need to enable CodeMirror to use LaTeX feature')\n }\n\n ctx.update(codeBlockConfig.key, (prev) => ({\n ...prev,\n renderPreview: (language, content) => {\n if (language.toLowerCase() === 'latex' && content.length > 0) {\n return renderLatex(content, config?.katexOptions)\n }\n const renderPreview = prev.renderPreview\n return renderPreview(language, content)\n },\n }))\n\n ctx.set(inlineLatexTooltip.key, {\n view: (view) => {\n return new LatexInlineTooltip(ctx, view, {\n inlineEditConfirm: config?.inlineEditConfirm ?? confirmIcon,\n ...config,\n })\n },\n })\n })\n .use(remarkMathPlugin)\n .use(remarkMathBlockPlugin)\n .use(mathInlineSchema)\n .use(inlineLatexTooltip)\n .use(mathInlineInputRule)\n .use(mathBlockInputRule)\n .use(blockLatexSchema)\n .use(toggleLatexCommand)\n}\n\nfunction renderLatex(content: string, options?: KatexOptions) {\n const html = katex.renderToString(content, {\n ...options,\n throwOnError: false,\n displayMode: true,\n })\n return html\n}\n"],"names":["createSlice","CrepeFeature","codeBlockSchema","$nodeSchema","$command","state","findNodeInSelection","_tr","NodeSelection","TextSelection","tooltipFactory","defineComponent","h","Icon","view","shallowRef","EditorView","EditorState","Schema","keymap","undo","redo","createApp","TooltipProvider","$inputRule","nodeRule","textblockTypeInputRule","$remark","visit","codeBlockConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQ2BA,eAAA,CAAY,EAAC,EAAqB,aAAa;AAKlDA,eAAA,CAAY,EAAC,EAAmB,UAAU;AA2B3D,SAAS,iBAAiB,GAAU,EAAA;AAEzC,EAAO,OAAA,GAAA,CAAI,IAAmC,aAAa,CAAA;AAC7D;AAGO,SAAS,mBAAmB,OAAuB,EAAA;AACxD,EAAA,OAAO,CAAC,GAAa,KAAA;AACnB,IAAA,gBAAA,CAAiB,GAAG,CAAA,CAAE,MAAO,CAAA,CAAC,QAAa,KAAA;AACzC,MAAI,IAAA,QAAA,CAAS,QAAS,CAAA,OAAO,CAAG,EAAA;AAC9B,QAAO,OAAA,QAAA;AAAA;AAET,MAAO,OAAA,CAAC,GAAG,QAAA,EAAU,OAAO,CAAA;AAAA,KAC7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AA,WAAA,CAAY,OAAS,EAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,YAAY,CAAA;AAAA;AAElD,QAAA,MAAM,gBAAgB,IAAK,CAAA,aAAA;AAC3B,QAAO,OAAA,aAAA,CAAc,UAAU,OAAO,CAAA;AAAA;AACxC,KACA,CAAA,CAAA;AAEF,IAAI,GAAA,CAAA,GAAA,CAAI,mBAAmB,GAAK,EAAA;AAAA,MAC9B,IAAA,EAAM,CAAC,IAAS,KAAA;AA/CxB,QAAA,IAAA,EAAA;AAgDU,QAAO,OAAA,IAAI,kBAAmB,CAAA,GAAA,EAAK,IAAM,EAAA;AAAA,UACvC,iBAAA,EAAA,CAAmB,EAAQ,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,iBAAA,KAAR,IAA6B,GAAA,EAAA,GAAA,WAAA;AAAA,UAChD,GAAG;AAAA,SACJ,CAAA;AAAA;AACH,KACD,CAAA;AAAA,GACF,CACA,CAAA,GAAA,CAAI,gBAAgB,CAAA,CACpB,IAAI,qBAAqB,CAAA,CACzB,GAAI,CAAA,gBAAgB,CACpB,CAAA,GAAA,CAAI,kBAAkB,CACtB,CAAA,GAAA,CAAI,mBAAmB,CAAA,CACvB,GAAI,CAAA,kBAAkB,EACtB,GAAI,CAAA,gBAAgB,CACpB,CAAA,GAAA,CAAI,kBAAkB,CAAA;AAC3B;AAEA,SAAS,WAAA,CAAY,SAAiB,OAAwB,EAAA;AAC5D,EAAM,MAAA,IAAA,GAAO,KAAM,CAAA,cAAA,CAAe,OAAS,EAAA;AAAA,IACzC,GAAG,OAAA;AAAA,IACH,YAAc,EAAA,KAAA;AAAA,IACd,WAAa,EAAA;AAAA,GACd,CAAA;AACD,EAAO,OAAA,IAAA;AACT;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/utils/index.ts","../../../../src/feature/index.ts","../../../../src/feature/placeholder/index.ts"],"sourcesContent":["import { createSlice, type Ctx } from '@milkdown/kit/ctx'\n\nimport type { CrepeFeature } from '../feature'\nimport type { CrepeBuilder } from './builder'\n\n/// @internal\n/// The feature flags context.\n/// ⚠️ Most of the time, you should use `useCrepeFeatures` to get the features.\nexport const FeaturesCtx = createSlice([] as CrepeFeature[], 'FeaturesCtx')\n\n/// @internal\n/// The crepe editor context.\n/// ⚠️ Most of the time, you should use `useCrepe` to get the crepe editor instance.\nexport const CrepeCtx = createSlice({} as CrepeBuilder, 'CrepeCtx')\n\n/// The crepe editor context.\n/// You can use this context to access the crepe editor instance within Milkdown plugins.\n/// ```ts\n/// import { crepeCtx } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// return () => {\n/// const crepe = useCrepe(ctx)\n/// crepe.setReadonly(true)\n/// }\n/// }\n/// ```\nexport function useCrepe(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.get<CrepeBuilder, 'CrepeCtx'>('CrepeCtx')\n}\n\n/// Check the enabled FeatureFlags\n/// ```ts\n/// import { useCrepeFeatures } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// const features = useCrepeFeatures(ctx)\n/// if (features.get().includes(CrepeFeature.CodeMirror)) {\n/// // Do something with CodeMirror\n/// }\n/// }\nexport function useCrepeFeatures(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.use<CrepeFeature[], 'FeaturesCtx'>('FeaturesCtx')\n}\n\n/// @internal\nexport function crepeFeatureConfig(feature: CrepeFeature) {\n return (ctx: Ctx) => {\n useCrepeFeatures(ctx).update((features) => {\n if (features.includes(feature)) {\n return features\n }\n return [...features, feature]\n })\n }\n}\n","import type { Selection } from '@milkdown/kit/prose/state'\n\nexport function isInCodeBlock(selection: Selection) {\n const type = selection.$from.parent.type\n return type.name === 'code_block'\n}\n\nexport function isInList(selection: Selection) {\n const type = selection.$from.node(selection.$from.depth - 1)?.type\n return type?.name === 'list_item'\n}\n","import type { BlockEditFeatureConfig } from './block-edit'\nimport type { CodeMirrorFeatureConfig } from './code-mirror'\nimport type { CursorFeatureConfig } from './cursor'\nimport type { ImageBlockFeatureConfig } from './image-block'\nimport type { LatexFeatureConfig } from './latex'\nimport type { LinkTooltipFeatureConfig } from './link-tooltip'\nimport type { ListItemFeatureConfig } from './list-item'\nimport type { PlaceholderFeatureConfig } from './placeholder'\nimport type { TableFeatureConfig } from './table'\nimport type { ToolbarFeatureConfig } from './toolbar'\n\n/// The crepe editor feature flags.\n/// Every feature is enabled by default.\n/// Every feature is a string literal type.\nexport enum CrepeFeature {\n /// Syntax highlighting and editing for code blocks with language support, theme customization, and preview capabilities.\n CodeMirror = 'code-mirror',\n\n /// Support for bullet lists, ordered lists, and todo lists with customizable icons and formatting.\n ListItem = 'list-item',\n\n /// Enhanced link editing and preview with customizable tooltips, edit/remove actions, and copy functionality.\n LinkTooltip = 'link-tooltip',\n\n /// Enhanced cursor experience with drop cursor and gap cursor for better content placement.\n Cursor = 'cursor',\n\n /// Image upload and management with resizing, captions, and support for both inline and block images.\n ImageBlock = 'image-block',\n\n /// Drag-and-drop block management and slash commands for quick content insertion and organization.\n BlockEdit = 'block-edit',\n\n /// Formatting toolbar for selected text with customizable icons and actions.\n Toolbar = 'toolbar',\n\n /// Document or block level placeholders to guide users when content is empty.\n Placeholder = 'placeholder',\n\n /// Full-featured table editing with row/column management, alignment options, and drag-and-drop functionality.\n Table = 'table',\n\n /// Mathematical formula support with both inline and block math rendering using KaTeX.\n Latex = 'latex',\n}\n\nexport interface CrepeFeatureConfig {\n [CrepeFeature.Cursor]?: CursorFeatureConfig\n [CrepeFeature.ListItem]?: ListItemFeatureConfig\n [CrepeFeature.LinkTooltip]?: LinkTooltipFeatureConfig\n [CrepeFeature.ImageBlock]?: ImageBlockFeatureConfig\n [CrepeFeature.BlockEdit]?: BlockEditFeatureConfig\n [CrepeFeature.Placeholder]?: PlaceholderFeatureConfig\n [CrepeFeature.Toolbar]?: ToolbarFeatureConfig\n [CrepeFeature.CodeMirror]?: CodeMirrorFeatureConfig\n [CrepeFeature.Table]?: TableFeatureConfig\n [CrepeFeature.Latex]?: LatexFeatureConfig\n}\n\nexport const defaultFeatures: Record<CrepeFeature, boolean> = {\n [CrepeFeature.Cursor]: true,\n [CrepeFeature.ListItem]: true,\n [CrepeFeature.LinkTooltip]: true,\n [CrepeFeature.ImageBlock]: true,\n [CrepeFeature.BlockEdit]: true,\n [CrepeFeature.Placeholder]: true,\n [CrepeFeature.Toolbar]: true,\n [CrepeFeature.CodeMirror]: true,\n [CrepeFeature.Table]: true,\n [CrepeFeature.Latex]: true,\n}\n","import type { Node } from '@milkdown/kit/prose/model'\nimport type { EditorState } from '@milkdown/kit/prose/state'\n\nimport { findParent } from '@milkdown/kit/prose'\nimport { Plugin, PluginKey } from '@milkdown/kit/prose/state'\nimport { Decoration, DecorationSet } from '@milkdown/kit/prose/view'\nimport { $ctx, $prose } from '@milkdown/kit/utils'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig } from '../../core/slice'\nimport { isInCodeBlock, isInList } from '../../utils'\nimport { CrepeFeature } from '../index'\n\nfunction isDocEmpty(doc: Node) {\n return doc.childCount <= 1 && !doc.firstChild?.content.size\n}\n\nfunction createPlaceholderDecoration(\n state: EditorState,\n placeholderText: string\n): Decoration | null {\n const { selection } = state\n if (!selection.empty) return null\n\n const $pos = selection.$anchor\n const node = $pos.parent\n if (node.content.size > 0) return null\n\n const inTable = findParent((node) => node.type.name === 'table')($pos)\n if (inTable) return null\n\n const before = $pos.before()\n\n return Decoration.node(before, before + node.nodeSize, {\n class: 'crepe-placeholder',\n 'data-placeholder': placeholderText,\n })\n}\n\ninterface PlaceholderConfig {\n text: string\n mode: 'doc' | 'block'\n}\n\nexport type PlaceholderFeatureConfig = Partial<PlaceholderConfig>\n\nexport const placeholderConfig = $ctx(\n {\n text: 'Please enter...',\n mode: 'block',\n } as PlaceholderConfig,\n 'placeholderConfigCtx'\n)\n\nexport const placeholderPlugin = $prose((ctx) => {\n return new Plugin({\n key: new PluginKey('CREPE_PLACEHOLDER'),\n props: {\n decorations: (state) => {\n const config = ctx.get(placeholderConfig.key)\n if (config.mode === 'doc' && !isDocEmpty(state.doc)) return null\n\n if (isInCodeBlock(state.selection) || isInList(state.selection))\n return null\n\n const placeholderText = config.text ?? 'Please enter...'\n const deco = createPlaceholderDecoration(state, placeholderText)\n if (!deco) return null\n\n return DecorationSet.create(state.doc, [deco])\n },\n },\n })\n})\n\nexport const placeholder: DefineFeature<PlaceholderFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.Placeholder))\n .config((ctx) => {\n if (config) {\n ctx.update(placeholderConfig.key, (prev) => {\n return {\n ...prev,\n ...config,\n }\n })\n }\n })\n .use(placeholderPlugin)\n .use(placeholderConfig)\n}\n"],"names":["createSlice","CrepeFeature","findParent","node","Decoration","$ctx","$prose","Plugin","PluginKey","DecorationSet"],"mappings":";;;;;;;;AAQ2BA,eAAA,CAAY,EAAC,EAAqB,aAAa;AAKlDA,eAAA,CAAY,EAAC,EAAmB,UAAU;AA2B3D,SAAS,iBAAiB,GAAU,EAAA;AAEzC,EAAO,OAAA,GAAA,CAAI,IAAmC,aAAa,CAAA;AAC7D;AAGO,SAAS,mBAAmB,OAAuB,EAAA;AACxD,EAAA,OAAO,CAAC,GAAa,KAAA;AACnB,IAAA,gBAAA,CAAiB,GAAG,CAAA,CAAE,MAAO,CAAA,CAAC,QAAa,KAAA;AACzC,MAAI,IAAA,QAAA,CAAS,QAAS,CAAA,OAAO,CAAG,EAAA;AAC9B,QAAO,OAAA,QAAA;AAAA;AAET,MAAO,OAAA,CAAC,GAAG,QAAA,EAAU,OAAO,CAAA;AAAA,KAC7B,CAAA;AAAA,GACH;AACF;;ACrDO,SAAS,cAAc,SAAsB,EAAA;AAClD,EAAM,MAAA,IAAA,GAAO,SAAU,CAAA,KAAA,CAAM,MAAO,CAAA,IA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IAAA,KAAP,IAAe,GAAA,EAAA,GAAA,iBAAA;AACvC,QAAM,MAAA,IAAA,GAAO,2BAA4B,CAAA,KAAA,EAAO,eAAe,CAAA;AAC/D,QAAI,IAAA,CAAC,MAAa,OAAA,IAAA;AAElB,QAAA,OAAOC,mBAAc,MAAO,CAAA,KAAA,CAAM,GAAK,EAAA,CAAC,IAAI,CAAC,CAAA;AAAA;AAC/C;AACF,GACD,CAAA;AACH,CAAC;AAEY,MAAA,WAAA,GAAuD,CAClE,MAAA,EACA,MACG,KAAA;AACH,EACG,MAAA,CAAA,MAAA,CAAO,mBAAmB,YAAa,CAAA,WAAW,CAAC,CACnD,CAAA,MAAA,CAAO,CAAC,GAAQ,KAAA;AACf,IAAA,IAAI,MAAQ,EAAA;AACV,MAAA,GAAA,CAAI,MAAO,CAAA,iBAAA,CAAkB,GAAK,EAAA,CAAC,IAAS,KAAA;AAC1C,QAAO,OAAA;AAAA,UACL,GAAG,IAAA;AAAA,UACH,GAAG;AAAA,SACL;AAAA,OACD,CAAA;AAAA;AACH,GACD,CACA,CAAA,GAAA,CAAI,iBAAiB,CAAA,CACrB,IAAI,iBAAiB,CAAA;AAC1B;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/utils/checker.ts","../../../../src/feature/index.ts","../../../../src/feature/placeholder/index.ts"],"sourcesContent":["import { createSlice, type Ctx } from '@milkdown/kit/ctx'\n\nimport type { CrepeFeature } from '../feature'\nimport type { CrepeBuilder } from './builder'\n\n/// @internal\n/// The feature flags context.\n/// ⚠️ Most of the time, you should use `useCrepeFeatures` to get the features.\nexport const FeaturesCtx = createSlice([] as CrepeFeature[], 'FeaturesCtx')\n\n/// @internal\n/// The crepe editor context.\n/// ⚠️ Most of the time, you should use `useCrepe` to get the crepe editor instance.\nexport const CrepeCtx = createSlice({} as CrepeBuilder, 'CrepeCtx')\n\n/// The crepe editor context.\n/// You can use this context to access the crepe editor instance within Milkdown plugins.\n/// ```ts\n/// import { crepeCtx } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// return () => {\n/// const crepe = useCrepe(ctx)\n/// crepe.setReadonly(true)\n/// }\n/// }\n/// ```\nexport function useCrepe(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.get<CrepeBuilder, 'CrepeCtx'>('CrepeCtx')\n}\n\n/// Check the enabled FeatureFlags\n/// ```ts\n/// import { useCrepeFeatures } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// const features = useCrepeFeatures(ctx)\n/// if (features.get().includes(CrepeFeature.CodeMirror)) {\n/// // Do something with CodeMirror\n/// }\n/// }\nexport function useCrepeFeatures(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.use<CrepeFeature[], 'FeaturesCtx'>('FeaturesCtx')\n}\n\n/// @internal\nexport function crepeFeatureConfig(feature: CrepeFeature) {\n return (ctx: Ctx) => {\n useCrepeFeatures(ctx).update((features) => {\n if (features.includes(feature)) {\n return features\n }\n return [...features, feature]\n })\n }\n}\n","import type { Selection } from '@milkdown/kit/prose/state'\n\nexport function isInCodeBlock(selection: Selection) {\n const type = selection.$from.parent.type\n return type.name === 'code_block'\n}\n\nexport function isInList(selection: Selection) {\n const type = selection.$from.node(selection.$from.depth - 1)?.type\n return type?.name === 'list_item'\n}\n","import type { BlockEditFeatureConfig } from './block-edit'\nimport type { CodeMirrorFeatureConfig } from './code-mirror'\nimport type { CursorFeatureConfig } from './cursor'\nimport type { ImageBlockFeatureConfig } from './image-block'\nimport type { LatexFeatureConfig } from './latex'\nimport type { LinkTooltipFeatureConfig } from './link-tooltip'\nimport type { ListItemFeatureConfig } from './list-item'\nimport type { PlaceholderFeatureConfig } from './placeholder'\nimport type { TableFeatureConfig } from './table'\nimport type { ToolbarFeatureConfig } from './toolbar'\n\n/// The crepe editor feature flags.\n/// Every feature is enabled by default.\n/// Every feature is a string literal type.\nexport enum CrepeFeature {\n /// Syntax highlighting and editing for code blocks with language support, theme customization, and preview capabilities.\n CodeMirror = 'code-mirror',\n\n /// Support for bullet lists, ordered lists, and todo lists with customizable icons and formatting.\n ListItem = 'list-item',\n\n /// Enhanced link editing and preview with customizable tooltips, edit/remove actions, and copy functionality.\n LinkTooltip = 'link-tooltip',\n\n /// Enhanced cursor experience with drop cursor and gap cursor for better content placement.\n Cursor = 'cursor',\n\n /// Image upload and management with resizing, captions, and support for both inline and block images.\n ImageBlock = 'image-block',\n\n /// Drag-and-drop block management and slash commands for quick content insertion and organization.\n BlockEdit = 'block-edit',\n\n /// Formatting toolbar for selected text with customizable icons and actions.\n Toolbar = 'toolbar',\n\n /// Document or block level placeholders to guide users when content is empty.\n Placeholder = 'placeholder',\n\n /// Full-featured table editing with row/column management, alignment options, and drag-and-drop functionality.\n Table = 'table',\n\n /// Mathematical formula support with both inline and block math rendering using KaTeX.\n Latex = 'latex',\n}\n\nexport interface CrepeFeatureConfig {\n [CrepeFeature.Cursor]?: CursorFeatureConfig\n [CrepeFeature.ListItem]?: ListItemFeatureConfig\n [CrepeFeature.LinkTooltip]?: LinkTooltipFeatureConfig\n [CrepeFeature.ImageBlock]?: ImageBlockFeatureConfig\n [CrepeFeature.BlockEdit]?: BlockEditFeatureConfig\n [CrepeFeature.Placeholder]?: PlaceholderFeatureConfig\n [CrepeFeature.Toolbar]?: ToolbarFeatureConfig\n [CrepeFeature.CodeMirror]?: CodeMirrorFeatureConfig\n [CrepeFeature.Table]?: TableFeatureConfig\n [CrepeFeature.Latex]?: LatexFeatureConfig\n}\n\nexport const defaultFeatures: Record<CrepeFeature, boolean> = {\n [CrepeFeature.Cursor]: true,\n [CrepeFeature.ListItem]: true,\n [CrepeFeature.LinkTooltip]: true,\n [CrepeFeature.ImageBlock]: true,\n [CrepeFeature.BlockEdit]: true,\n [CrepeFeature.Placeholder]: true,\n [CrepeFeature.Toolbar]: true,\n [CrepeFeature.CodeMirror]: true,\n [CrepeFeature.Table]: true,\n [CrepeFeature.Latex]: true,\n}\n","import type { Node } from '@milkdown/kit/prose/model'\nimport type { EditorState } from '@milkdown/kit/prose/state'\n\nimport { findParent } from '@milkdown/kit/prose'\nimport { Plugin, PluginKey } from '@milkdown/kit/prose/state'\nimport { Decoration, DecorationSet } from '@milkdown/kit/prose/view'\nimport { $ctx, $prose } from '@milkdown/kit/utils'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig } from '../../core/slice'\nimport { isInCodeBlock, isInList } from '../../utils'\nimport { CrepeFeature } from '../index'\n\nfunction isDocEmpty(doc: Node) {\n return doc.childCount <= 1 && !doc.firstChild?.content.size\n}\n\nfunction createPlaceholderDecoration(\n state: EditorState,\n placeholderText: string\n): Decoration | null {\n const { selection } = state\n if (!selection.empty) return null\n\n const $pos = selection.$anchor\n const node = $pos.parent\n if (node.content.size > 0) return null\n\n const inTable = findParent((node) => node.type.name === 'table')($pos)\n if (inTable) return null\n\n const before = $pos.before()\n\n return Decoration.node(before, before + node.nodeSize, {\n class: 'crepe-placeholder',\n 'data-placeholder': placeholderText,\n })\n}\n\ninterface PlaceholderConfig {\n text: string\n mode: 'doc' | 'block'\n}\n\nexport type PlaceholderFeatureConfig = Partial<PlaceholderConfig>\n\nexport const placeholderConfig = $ctx(\n {\n text: 'Please enter...',\n mode: 'block',\n } as PlaceholderConfig,\n 'placeholderConfigCtx'\n)\n\nexport const placeholderPlugin = $prose((ctx) => {\n return new Plugin({\n key: new PluginKey('CREPE_PLACEHOLDER'),\n props: {\n decorations: (state) => {\n const config = ctx.get(placeholderConfig.key)\n if (config.mode === 'doc' && !isDocEmpty(state.doc)) return null\n\n if (isInCodeBlock(state.selection) || isInList(state.selection))\n return null\n\n const placeholderText = config.text ?? 'Please enter...'\n const deco = createPlaceholderDecoration(state, placeholderText)\n if (!deco) return null\n\n return DecorationSet.create(state.doc, [deco])\n },\n },\n })\n})\n\nexport const placeholder: DefineFeature<PlaceholderFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.Placeholder))\n .config((ctx) => {\n if (config) {\n ctx.update(placeholderConfig.key, (prev) => {\n return {\n ...prev,\n ...config,\n }\n })\n }\n })\n .use(placeholderPlugin)\n .use(placeholderConfig)\n}\n"],"names":["createSlice","CrepeFeature","findParent","node","Decoration","$ctx","$prose","Plugin","PluginKey","DecorationSet"],"mappings":";;;;;;;;AAQ2BA,eAAA,CAAY,EAAC,EAAqB,aAAa;AAKlDA,eAAA,CAAY,EAAC,EAAmB,UAAU;AA2B3D,SAAS,iBAAiB,GAAU,EAAA;AAEzC,EAAO,OAAA,GAAA,CAAI,IAAmC,aAAa,CAAA;AAC7D;AAGO,SAAS,mBAAmB,OAAuB,EAAA;AACxD,EAAA,OAAO,CAAC,GAAa,KAAA;AACnB,IAAA,gBAAA,CAAiB,GAAG,CAAA,CAAE,MAAO,CAAA,CAAC,QAAa,KAAA;AACzC,MAAI,IAAA,QAAA,CAAS,QAAS,CAAA,OAAO,CAAG,EAAA;AAC9B,QAAO,OAAA,QAAA;AAAA;AAET,MAAO,OAAA,CAAC,GAAG,QAAA,EAAU,OAAO,CAAA;AAAA,KAC7B,CAAA;AAAA,GACH;AACF;;ACrDO,SAAS,cAAc,SAAsB,EAAA;AAClD,EAAM,MAAA,IAAA,GAAO,SAAU,CAAA,KAAA,CAAM,MAAO,CAAA,IAAA;AACpC,EAAA,OAAO,KAAK,IAAS,KAAA,YAAA;AACvB;AAEO,SAAS,SAAS,SAAsB,EAAA;AAP/C,EAAA,IAAA,EAAA;AAQE,EAAM,MAAA,IAAA,GAAA,CAAO,eAAU,KAAM,CAAA,IAAA,CAAK,UAAU,KAAM,CAAA,KAAA,GAAQ,CAAC,CAAA,KAA9C,IAAiD,GAAA,MAAA,GAAA,EAAA,CAAA,IAAA;AAC9D,EAAA,OAAA,CAAO,6BAAM,IAAS,MAAA,WAAA;AACxB;;ACIY,IAAA,YAAA,qBAAAC,aAAL,KAAA;AAEL,EAAAA,cAAA,YAAa,CAAA,GA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C,CACnD,CAAA,MAAA,CAAO,CAAC,GAAQ,KAAA;AACf,IAAA,IAAI,MAAQ,EAAA;AACV,MAAA,GAAA,CAAI,MAAO,CAAA,iBAAA,CAAkB,GAAK,EAAA,CAAC,IAAS,KAAA;AAC1C,QAAO,OAAA;AAAA,UACL,GAAG,IAAA;AAAA,UACH,GAAG;AAAA,SACL;AAAA,OACD,CAAA;AAAA;AACH,GACD,CACA,CAAA,GAAA,CAAI,iBAAiB,CAAA,CACrB,IAAI,iBAAiB,CAAA;AAC1B;;;;;;"}
|
|
@@ -5,11 +5,12 @@ var state = require('@milkdown/kit/prose/state');
|
|
|
5
5
|
var vue = require('vue');
|
|
6
6
|
var ctx = require('@milkdown/kit/ctx');
|
|
7
7
|
var component = require('@milkdown/kit/component');
|
|
8
|
-
var linkTooltip = require('@milkdown/kit/component/link-tooltip');
|
|
9
8
|
var core = require('@milkdown/kit/core');
|
|
9
|
+
var clsx = require('clsx');
|
|
10
|
+
var linkTooltip = require('@milkdown/kit/component/link-tooltip');
|
|
10
11
|
var commonmark = require('@milkdown/kit/preset/commonmark');
|
|
11
12
|
var gfm = require('@milkdown/kit/preset/gfm');
|
|
12
|
-
var
|
|
13
|
+
var prose = require('@milkdown/kit/prose');
|
|
13
14
|
var utils = require('@milkdown/kit/utils');
|
|
14
15
|
var katex = require('katex');
|
|
15
16
|
|
|
@@ -129,6 +130,59 @@ const functionsIcon = `
|
|
|
129
130
|
</svg>
|
|
130
131
|
`;
|
|
131
132
|
|
|
133
|
+
var __typeError$1 = (msg) => {
|
|
134
|
+
throw TypeError(msg);
|
|
135
|
+
};
|
|
136
|
+
var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
|
|
137
|
+
var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
138
|
+
var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
139
|
+
var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
|
|
140
|
+
var _groups, _getGroupInstance;
|
|
141
|
+
class GroupBuilder {
|
|
142
|
+
constructor() {
|
|
143
|
+
__privateAdd$1(this, _groups, []);
|
|
144
|
+
this.clear = () => {
|
|
145
|
+
__privateSet$1(this, _groups, []);
|
|
146
|
+
return this;
|
|
147
|
+
};
|
|
148
|
+
__privateAdd$1(this, _getGroupInstance, (group) => {
|
|
149
|
+
const groupInstance = {
|
|
150
|
+
group,
|
|
151
|
+
addItem: (key, item) => {
|
|
152
|
+
const data = { ...item, key };
|
|
153
|
+
group.items.push(data);
|
|
154
|
+
return groupInstance;
|
|
155
|
+
},
|
|
156
|
+
clear: () => {
|
|
157
|
+
group.items = [];
|
|
158
|
+
return groupInstance;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
return groupInstance;
|
|
162
|
+
});
|
|
163
|
+
this.addGroup = (key, label) => {
|
|
164
|
+
const items = [];
|
|
165
|
+
const group = {
|
|
166
|
+
key,
|
|
167
|
+
label,
|
|
168
|
+
items
|
|
169
|
+
};
|
|
170
|
+
__privateGet$1(this, _groups).push(group);
|
|
171
|
+
return __privateGet$1(this, _getGroupInstance).call(this, group);
|
|
172
|
+
};
|
|
173
|
+
this.getGroup = (key) => {
|
|
174
|
+
const group = __privateGet$1(this, _groups).find((group2) => group2.key === key);
|
|
175
|
+
if (!group) throw new Error(`Group with key ${key} not found`);
|
|
176
|
+
return __privateGet$1(this, _getGroupInstance).call(this, group);
|
|
177
|
+
};
|
|
178
|
+
this.build = () => {
|
|
179
|
+
return __privateGet$1(this, _groups);
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
_groups = new WeakMap();
|
|
184
|
+
_getGroupInstance = new WeakMap();
|
|
185
|
+
|
|
132
186
|
const mathInlineId = "math_inline";
|
|
133
187
|
const mathInlineSchema = utils.$nodeSchema(mathInlineId, () => ({
|
|
134
188
|
group: "inline",
|
|
@@ -175,6 +229,132 @@ const mathInlineSchema = utils.$nodeSchema(mathInlineId, () => ({
|
|
|
175
229
|
}
|
|
176
230
|
}));
|
|
177
231
|
|
|
232
|
+
const toggleLatexCommand = utils.$command("ToggleLatex", (ctx) => {
|
|
233
|
+
return () => (state$1, dispatch) => {
|
|
234
|
+
const {
|
|
235
|
+
hasNode: hasLatex,
|
|
236
|
+
pos: latexPos,
|
|
237
|
+
target: latexNode
|
|
238
|
+
} = prose.findNodeInSelection(state$1, mathInlineSchema.type(ctx));
|
|
239
|
+
const { selection, doc, tr } = state$1;
|
|
240
|
+
if (!hasLatex) {
|
|
241
|
+
const text = doc.textBetween(selection.from, selection.to);
|
|
242
|
+
let _tr2 = tr.replaceSelectionWith(
|
|
243
|
+
mathInlineSchema.type(ctx).create({
|
|
244
|
+
value: text
|
|
245
|
+
})
|
|
246
|
+
);
|
|
247
|
+
if (dispatch) {
|
|
248
|
+
dispatch(
|
|
249
|
+
_tr2.setSelection(state.NodeSelection.create(_tr2.doc, selection.from))
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
const { from, to } = selection;
|
|
255
|
+
if (!latexNode || latexPos < 0) return false;
|
|
256
|
+
let _tr = tr.delete(latexPos, latexPos + 1);
|
|
257
|
+
const content = latexNode.attrs.value;
|
|
258
|
+
_tr = _tr.insertText(content, latexPos);
|
|
259
|
+
if (dispatch) {
|
|
260
|
+
dispatch(
|
|
261
|
+
_tr.setSelection(
|
|
262
|
+
state.TextSelection.create(_tr.doc, from, to + content.length - 1)
|
|
263
|
+
)
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
return true;
|
|
267
|
+
};
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
function getGroups(config, ctx) {
|
|
271
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
272
|
+
const groupBuilder = new GroupBuilder();
|
|
273
|
+
groupBuilder.addGroup("formatting", "Formatting").addItem("bold", {
|
|
274
|
+
icon: (_a = config == null ? void 0 : config.boldIcon) != null ? _a : boldIcon,
|
|
275
|
+
active: (ctx2) => {
|
|
276
|
+
const commands = ctx2.get(core.commandsCtx);
|
|
277
|
+
return commands.call(commonmark.isMarkSelectedCommand.key, commonmark.strongSchema.type(ctx2));
|
|
278
|
+
},
|
|
279
|
+
onRun: (ctx2) => {
|
|
280
|
+
const commands = ctx2.get(core.commandsCtx);
|
|
281
|
+
commands.call(commonmark.toggleStrongCommand.key);
|
|
282
|
+
}
|
|
283
|
+
}).addItem("italic", {
|
|
284
|
+
icon: (_b = config == null ? void 0 : config.italicIcon) != null ? _b : italicIcon,
|
|
285
|
+
active: (ctx2) => {
|
|
286
|
+
const commands = ctx2.get(core.commandsCtx);
|
|
287
|
+
return commands.call(
|
|
288
|
+
commonmark.isMarkSelectedCommand.key,
|
|
289
|
+
commonmark.emphasisSchema.type(ctx2)
|
|
290
|
+
);
|
|
291
|
+
},
|
|
292
|
+
onRun: (ctx2) => {
|
|
293
|
+
const commands = ctx2.get(core.commandsCtx);
|
|
294
|
+
commands.call(commonmark.toggleEmphasisCommand.key);
|
|
295
|
+
}
|
|
296
|
+
}).addItem("strikethrough", {
|
|
297
|
+
icon: (_c = config == null ? void 0 : config.strikethroughIcon) != null ? _c : strikethroughIcon,
|
|
298
|
+
active: (ctx2) => {
|
|
299
|
+
const commands = ctx2.get(core.commandsCtx);
|
|
300
|
+
return commands.call(
|
|
301
|
+
commonmark.isMarkSelectedCommand.key,
|
|
302
|
+
gfm.strikethroughSchema.type(ctx2)
|
|
303
|
+
);
|
|
304
|
+
},
|
|
305
|
+
onRun: (ctx2) => {
|
|
306
|
+
const commands = ctx2.get(core.commandsCtx);
|
|
307
|
+
commands.call(gfm.toggleStrikethroughCommand.key);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
const functionGroup = groupBuilder.addGroup("function", "Function");
|
|
311
|
+
functionGroup.addItem("code", {
|
|
312
|
+
icon: (_d = config == null ? void 0 : config.codeIcon) != null ? _d : codeIcon,
|
|
313
|
+
active: (ctx2) => {
|
|
314
|
+
const commands = ctx2.get(core.commandsCtx);
|
|
315
|
+
return commands.call(
|
|
316
|
+
commonmark.isMarkSelectedCommand.key,
|
|
317
|
+
commonmark.inlineCodeSchema.type(ctx2)
|
|
318
|
+
);
|
|
319
|
+
},
|
|
320
|
+
onRun: (ctx2) => {
|
|
321
|
+
const commands = ctx2.get(core.commandsCtx);
|
|
322
|
+
commands.call(commonmark.toggleInlineCodeCommand.key);
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
const flags = ctx && useCrepeFeatures(ctx).get();
|
|
326
|
+
const isLatexEnabled = flags == null ? void 0 : flags.includes(CrepeFeature.Latex);
|
|
327
|
+
if (isLatexEnabled) {
|
|
328
|
+
functionGroup.addItem("latex", {
|
|
329
|
+
icon: (_e = config == null ? void 0 : config.latexIcon) != null ? _e : functionsIcon,
|
|
330
|
+
active: (ctx2) => {
|
|
331
|
+
const commands = ctx2.get(core.commandsCtx);
|
|
332
|
+
return commands.call(
|
|
333
|
+
commonmark.isNodeSelectedCommand.key,
|
|
334
|
+
mathInlineSchema.type(ctx2)
|
|
335
|
+
);
|
|
336
|
+
},
|
|
337
|
+
onRun: (ctx2) => {
|
|
338
|
+
const commands = ctx2.get(core.commandsCtx);
|
|
339
|
+
commands.call(toggleLatexCommand.key);
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
functionGroup.addItem("link", {
|
|
344
|
+
icon: (_f = config == null ? void 0 : config.linkIcon) != null ? _f : linkIcon,
|
|
345
|
+
active: (ctx2) => {
|
|
346
|
+
const commands = ctx2.get(core.commandsCtx);
|
|
347
|
+
return commands.call(commonmark.isMarkSelectedCommand.key, commonmark.linkSchema.type(ctx2));
|
|
348
|
+
},
|
|
349
|
+
onRun: (ctx2) => {
|
|
350
|
+
const commands = ctx2.get(core.commandsCtx);
|
|
351
|
+
commands.call(linkTooltip.toggleLinkCommand.key);
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
(_g = config == null ? void 0 : config.buildToolbar) == null ? void 0 : _g.call(config, groupBuilder);
|
|
355
|
+
return groupBuilder.build();
|
|
356
|
+
}
|
|
357
|
+
|
|
178
358
|
const Toolbar = vue.defineComponent({
|
|
179
359
|
props: {
|
|
180
360
|
ctx: {
|
|
@@ -199,169 +379,42 @@ const Toolbar = vue.defineComponent({
|
|
|
199
379
|
}
|
|
200
380
|
},
|
|
201
381
|
setup(props) {
|
|
202
|
-
const { ctx,
|
|
382
|
+
const { ctx, config } = props;
|
|
203
383
|
const onClick = (fn) => (e) => {
|
|
204
384
|
e.preventDefault();
|
|
205
385
|
ctx && fn(ctx);
|
|
206
386
|
};
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
};
|
|
215
|
-
const containsNode = (node) => {
|
|
216
|
-
const selection = props.selection.value;
|
|
217
|
-
if (!ctx || !selection) return false;
|
|
218
|
-
const { state: state$1 } = ctx.get(core.editorViewCtx);
|
|
219
|
-
if (!state$1) return false;
|
|
220
|
-
const { doc } = state$1;
|
|
221
|
-
if (selection instanceof state.NodeSelection) {
|
|
222
|
-
return selection.node.type === node;
|
|
223
|
-
}
|
|
224
|
-
const { from, to } = selection;
|
|
225
|
-
let hasNode = false;
|
|
226
|
-
doc.nodesBetween(from, to, (n) => {
|
|
227
|
-
if (n.type === node) {
|
|
228
|
-
hasNode = true;
|
|
229
|
-
return false;
|
|
230
|
-
}
|
|
231
|
-
return true;
|
|
232
|
-
});
|
|
233
|
-
return hasNode;
|
|
234
|
-
};
|
|
235
|
-
const flags = useCrepeFeatures(ctx).get();
|
|
236
|
-
const isLatexEnabled = flags == null ? void 0 : flags.includes(CrepeFeature.Latex);
|
|
237
|
-
const toggleLatex = (ctx2) => {
|
|
238
|
-
const hasLatex = containsNode(mathInlineSchema.type(ctx2));
|
|
239
|
-
const view = ctx2.get(core.editorViewCtx);
|
|
240
|
-
const { selection, doc, tr } = view.state;
|
|
241
|
-
if (!hasLatex) {
|
|
242
|
-
const text = doc.textBetween(selection.from, selection.to);
|
|
243
|
-
let _tr2 = tr.replaceSelectionWith(
|
|
244
|
-
mathInlineSchema.type(ctx2).create({
|
|
245
|
-
value: text
|
|
246
|
-
})
|
|
247
|
-
);
|
|
248
|
-
view.dispatch(
|
|
249
|
-
_tr2.setSelection(state.NodeSelection.create(_tr2.doc, selection.from))
|
|
250
|
-
);
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
const { from, to } = selection;
|
|
254
|
-
let pos = -1;
|
|
255
|
-
let node = null;
|
|
256
|
-
doc.nodesBetween(from, to, (n, p) => {
|
|
257
|
-
if (node) return false;
|
|
258
|
-
if (n.type === mathInlineSchema.type(ctx2)) {
|
|
259
|
-
pos = p;
|
|
260
|
-
node = n;
|
|
261
|
-
return false;
|
|
262
|
-
}
|
|
263
|
-
return true;
|
|
264
|
-
});
|
|
265
|
-
if (!node || pos < 0) return;
|
|
266
|
-
let _tr = tr.delete(pos, pos + 1);
|
|
267
|
-
const content = node.attrs.value;
|
|
268
|
-
_tr = _tr.insertText(content, pos);
|
|
269
|
-
view.dispatch(
|
|
270
|
-
_tr.setSelection(
|
|
271
|
-
state.TextSelection.create(_tr.doc, from, to + content.length - 1)
|
|
272
|
-
)
|
|
273
|
-
);
|
|
274
|
-
};
|
|
387
|
+
function checkActive(checker) {
|
|
388
|
+
props.selection.value;
|
|
389
|
+
const status = ctx.get(core.editorCtx).status;
|
|
390
|
+
if (status !== core.EditorStatus.Created) return false;
|
|
391
|
+
return checker(ctx);
|
|
392
|
+
}
|
|
393
|
+
const groupInfo = vue.computed(() => getGroups(config, ctx));
|
|
275
394
|
return () => {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
),
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
class:
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
onPointerdown: onClick((ctx2) => {
|
|
300
|
-
const commands = ctx2.get(core.commandsCtx);
|
|
301
|
-
commands.call(commonmark.toggleEmphasisCommand.key);
|
|
302
|
-
})
|
|
303
|
-
},
|
|
304
|
-
/* @__PURE__ */ vue.h(component.Icon, { icon: (_b = config == null ? void 0 : config.italicIcon) != null ? _b : italicIcon })
|
|
305
|
-
), /* @__PURE__ */ vue.h(
|
|
306
|
-
"button",
|
|
307
|
-
{
|
|
308
|
-
type: "button",
|
|
309
|
-
class: clsx(
|
|
310
|
-
"toolbar-item",
|
|
311
|
-
ctx && isActive(gfm.strikethroughSchema.type(ctx)) && "active"
|
|
312
|
-
),
|
|
313
|
-
onPointerdown: onClick((ctx2) => {
|
|
314
|
-
const commands = ctx2.get(core.commandsCtx);
|
|
315
|
-
commands.call(gfm.toggleStrikethroughCommand.key);
|
|
316
|
-
})
|
|
317
|
-
},
|
|
318
|
-
/* @__PURE__ */ vue.h(component.Icon, { icon: (_c = config == null ? void 0 : config.strikethroughIcon) != null ? _c : strikethroughIcon })
|
|
319
|
-
), /* @__PURE__ */ vue.h("div", { class: "divider" }), /* @__PURE__ */ vue.h(
|
|
320
|
-
"button",
|
|
321
|
-
{
|
|
322
|
-
type: "button",
|
|
323
|
-
class: clsx(
|
|
324
|
-
"toolbar-item",
|
|
325
|
-
ctx && isActive(commonmark.inlineCodeSchema.type(ctx)) && "active"
|
|
326
|
-
),
|
|
327
|
-
onPointerdown: onClick((ctx2) => {
|
|
328
|
-
const commands = ctx2.get(core.commandsCtx);
|
|
329
|
-
commands.call(commonmark.toggleInlineCodeCommand.key);
|
|
330
|
-
})
|
|
331
|
-
},
|
|
332
|
-
/* @__PURE__ */ vue.h(component.Icon, { icon: (_d = config == null ? void 0 : config.codeIcon) != null ? _d : codeIcon })
|
|
333
|
-
), isLatexEnabled && /* @__PURE__ */ vue.h(
|
|
334
|
-
"button",
|
|
335
|
-
{
|
|
336
|
-
type: "button",
|
|
337
|
-
class: clsx(
|
|
338
|
-
"toolbar-item",
|
|
339
|
-
ctx && containsNode(mathInlineSchema.type(ctx)) && "active"
|
|
340
|
-
),
|
|
341
|
-
onPointerdown: onClick(toggleLatex)
|
|
342
|
-
},
|
|
343
|
-
/* @__PURE__ */ vue.h(component.Icon, { icon: (_e = config == null ? void 0 : config.latexIcon) != null ? _e : functionsIcon })
|
|
344
|
-
), /* @__PURE__ */ vue.h(
|
|
345
|
-
"button",
|
|
346
|
-
{
|
|
347
|
-
type: "button",
|
|
348
|
-
class: clsx(
|
|
349
|
-
"toolbar-item",
|
|
350
|
-
ctx && isActive(commonmark.linkSchema.type(ctx)) && "active"
|
|
351
|
-
),
|
|
352
|
-
onPointerdown: onClick((ctx2) => {
|
|
353
|
-
const view = ctx2.get(core.editorViewCtx);
|
|
354
|
-
const { selection } = view.state;
|
|
355
|
-
if (isActive(commonmark.linkSchema.type(ctx2))) {
|
|
356
|
-
ctx2.get(linkTooltip.linkTooltipAPI.key).removeLink(selection.from, selection.to);
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
ctx2.get(linkTooltip.linkTooltipAPI.key).addLink(selection.from, selection.to);
|
|
360
|
-
hide == null ? void 0 : hide();
|
|
361
|
-
})
|
|
362
|
-
},
|
|
363
|
-
/* @__PURE__ */ vue.h(component.Icon, { icon: (_f = config == null ? void 0 : config.linkIcon) != null ? _f : linkIcon })
|
|
364
|
-
));
|
|
395
|
+
return /* @__PURE__ */ vue.h(vue.Fragment, null, groupInfo.value.map((group) => {
|
|
396
|
+
return group.items.map((item) => {
|
|
397
|
+
return /* @__PURE__ */ vue.h(
|
|
398
|
+
"button",
|
|
399
|
+
{
|
|
400
|
+
type: "button",
|
|
401
|
+
class: clsx(
|
|
402
|
+
"toolbar-item",
|
|
403
|
+
ctx && checkActive(item.active) && "active"
|
|
404
|
+
),
|
|
405
|
+
onPointerdown: onClick(item.onRun)
|
|
406
|
+
},
|
|
407
|
+
/* @__PURE__ */ vue.h(component.Icon, { icon: item.icon })
|
|
408
|
+
);
|
|
409
|
+
});
|
|
410
|
+
}).reduce((acc, curr, index) => {
|
|
411
|
+
if (index === 0) {
|
|
412
|
+
acc.push(...curr);
|
|
413
|
+
} else {
|
|
414
|
+
acc.push(/* @__PURE__ */ vue.h("div", { class: "divider" }), ...curr);
|
|
415
|
+
}
|
|
416
|
+
return acc;
|
|
417
|
+
}, []));
|
|
365
418
|
};
|
|
366
419
|
}
|
|
367
420
|
});
|