@milkdown/crepe 7.16.0 → 7.17.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/code-mirror/index.js +27 -22
- package/lib/cjs/feature/code-mirror/index.js.map +1 -1
- package/lib/cjs/feature/latex/index.js +2 -2
- package/lib/cjs/feature/latex/index.js.map +1 -1
- package/lib/cjs/index.js +29 -24
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/feature/code-mirror/index.js +27 -22
- package/lib/esm/feature/code-mirror/index.js.map +1 -1
- package/lib/esm/feature/latex/index.js +2 -2
- package/lib/esm/feature/latex/index.js.map +1 -1
- package/lib/esm/index.js +29 -24
- package/lib/esm/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/feature/code-mirror/index.d.ts +2 -15
- package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/feature/code-mirror/index.ts +6 -23
- package/src/feature/latex/index.ts +2 -2
|
@@ -150,28 +150,33 @@ const codeMirror = (editor, config = {}) => {
|
|
|
150
150
|
if (config.extensions) {
|
|
151
151
|
extensions.push(...config.extensions);
|
|
152
152
|
}
|
|
153
|
-
ctx.update(codeBlock.codeBlockConfig.key, (defaultConfig) =>
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
153
|
+
ctx.update(codeBlock.codeBlockConfig.key, (defaultConfig) => {
|
|
154
|
+
var _a;
|
|
155
|
+
return {
|
|
156
|
+
extensions,
|
|
157
|
+
languages,
|
|
158
|
+
expandIcon: config.expandIcon || chevronDownIcon,
|
|
159
|
+
searchIcon: config.searchIcon || searchIcon,
|
|
160
|
+
clearSearchIcon: config.clearSearchIcon || clearIcon,
|
|
161
|
+
searchPlaceholder: config.searchPlaceholder || "Search language",
|
|
162
|
+
copyText: config.copyText || "Copy",
|
|
163
|
+
copyIcon: config.copyIcon || copyIcon,
|
|
164
|
+
onCopy: config.onCopy || (() => {
|
|
165
|
+
}),
|
|
166
|
+
noResultText: config.noResultText || "No result",
|
|
167
|
+
renderLanguage: config.renderLanguage || defaultConfig.renderLanguage,
|
|
168
|
+
renderPreview: config.renderPreview || defaultConfig.renderPreview,
|
|
169
|
+
previewToggleButton: (previewOnlyMode) => {
|
|
170
|
+
var _a2, _b;
|
|
171
|
+
const icon = ((_a2 = config.previewToggleIcon) == null ? void 0 : _a2.call(config, previewOnlyMode)) || (previewOnlyMode ? editIcon : visibilityOffIcon);
|
|
172
|
+
const text = ((_b = config.previewToggleText) == null ? void 0 : _b.call(config, previewOnlyMode)) || (previewOnlyMode ? "Edit" : "Hide");
|
|
173
|
+
return [icon, text].map((v) => v.trim()).join(" ");
|
|
174
|
+
},
|
|
175
|
+
previewLabel: config.previewLabel || defaultConfig.previewLabel,
|
|
176
|
+
previewLoading: config.previewLoading || defaultConfig.previewLoading,
|
|
177
|
+
previewOnlyByDefault: (_a = config.previewOnlyByDefault) != null ? _a : defaultConfig.previewOnlyByDefault
|
|
178
|
+
};
|
|
179
|
+
});
|
|
175
180
|
}).use(codeBlock.codeBlockComponent);
|
|
176
181
|
};
|
|
177
182
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/icons/chevron-down.ts","../../../../src/icons/clear.ts","../../../../src/icons/copy.ts","../../../../src/icons/edit.ts","../../../../src/icons/search.ts","../../../../src/icons/visibility-off.ts","../../../../src/feature/index.ts","../../../../src/feature/code-mirror/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","export const chevronDownIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke-width=\"1.5\"\n stroke=\"currentColor\"\n class=\"w-6 h-6\"\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M19.5 8.25l-7.5 7.5-7.5-7.5\"\n />\n </svg>\n`\n","export const clearIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <g clip-path=\"url(#clip0_1098_15553)\">\n <path\n d=\"M18.3007 5.70973C17.9107 5.31973 17.2807 5.31973 16.8907 5.70973L12.0007 10.5897L7.1107 5.69973C6.7207 5.30973 6.0907 5.30973 5.7007 5.69973C5.3107 6.08973 5.3107 6.71973 5.7007 7.10973L10.5907 11.9997L5.7007 16.8897C5.3107 17.2797 5.3107 17.9097 5.7007 18.2997C6.0907 18.6897 6.7207 18.6897 7.1107 18.2997L12.0007 13.4097L16.8907 18.2997C17.2807 18.6897 17.9107 18.6897 18.3007 18.2997C18.6907 17.9097 18.6907 17.2797 18.3007 16.8897L13.4107 11.9997L18.3007 7.10973C18.6807 6.72973 18.6807 6.08973 18.3007 5.70973Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1098_15553\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const copyIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"24px\"\n viewBox=\"0 -960 960 960\"\n width=\"24px\"\n fill=\"none\"\n >\n <path\n d=\"M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z\"\n />\n </svg>\n`\n","export const editIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <g clip-path=\"url(#clip0_1013_1585)\">\n <path\n d=\"M14.06 9.02L14.98 9.94L5.92 19H5V18.08L14.06 9.02ZM17.66 3C17.41 3 17.15 3.1 16.96 3.29L15.13 5.12L18.88 8.87L20.71 7.04C21.1 6.65 21.1 6.02 20.71 5.63L18.37 3.29C18.17 3.09 17.92 3 17.66 3ZM14.06 6.19L3 17.25V21H6.75L17.81 9.94L14.06 6.19Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1013_1585\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const searchIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke-width=\"1.5\"\n stroke=\"currentColor\"\n class=\"w-6 h-6\"\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z\"\n />\n </svg>\n`\n","export const visibilityOffIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"24px\"\n viewBox=\"0 -960 960 960\"\n width=\"24px\"\n >\n <path\n d=\"m644-428-58-58q9-47-27-88t-93-32l-58-58q17-8 34.5-12t37.5-4q75 0 127.5 52.5T660-500q0 20-4 37.5T644-428Zm128 126-58-56q38-29 67.5-63.5T832-500q-50-101-143.5-160.5T480-720q-29 0-57 4t-55 12l-62-62q41-17 84-25.5t90-8.5q151 0 269 83.5T920-500q-23 59-60.5 109.5T772-302Zm20 246L624-222q-35 11-70.5 16.5T480-200q-151 0-269-83.5T40-500q21-53 53-98.5t73-81.5L56-792l56-56 736 736-56 56ZM222-624q-29 26-53 57t-41 67q50 101 143.5 160.5T480-280q20 0 39-2.5t39-5.5l-36-38q-11 3-21 4.5t-21 1.5q-75 0-127.5-52.5T300-500q0-11 1.5-21t4.5-21l-84-82Zm319 93Zm-151 75Z\"\n />\n </svg>\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 { LanguageDescription } from '@codemirror/language'\nimport type { Extension } from '@codemirror/state'\n\nimport { defaultKeymap, indentWithTab } from '@codemirror/commands'\nimport { keymap } from '@codemirror/view'\nimport {\n codeBlockComponent,\n codeBlockConfig,\n} from '@milkdown/kit/component/code-block'\nimport { basicSetup } from 'codemirror'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig } from '../../core/slice'\nimport {\n chevronDownIcon,\n clearIcon,\n copyIcon,\n editIcon,\n searchIcon,\n visibilityOffIcon,\n} from '../../icons'\nimport { CrepeFeature } from '../index'\n\ninterface CodeMirrorConfig {\n extensions: Extension[]\n languages: LanguageDescription[]\n theme: Extension\n\n expandIcon: string\n searchIcon: string\n clearSearchIcon: string\n\n searchPlaceholder: string\n copyText: string\n copyIcon: string\n onCopy: (text: string) => void\n noResultText: string\n\n renderLanguage: (language: string, selected: boolean) => string\n\n renderPreview: (\n language: string,\n content: string\n ) => string | HTMLElement | null\n\n previewToggleIcon: (previewOnlyMode: boolean) => string\n previewToggleText: (previewOnlyMode: boolean) => string\n previewLabel: string\n}\nexport type CodeMirrorFeatureConfig = Partial<CodeMirrorConfig>\n\nexport const codeMirror: DefineFeature<CodeMirrorFeatureConfig> = (\n editor,\n config = {}\n) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.CodeMirror))\n .config((ctx) => {\n const { languages = [], theme } = config\n const extensions = [\n keymap.of(defaultKeymap.concat(indentWithTab)),\n basicSetup,\n ]\n if (theme) {\n extensions.push(theme)\n }\n if (config.extensions) {\n extensions.push(...config.extensions)\n }\n\n ctx.update(codeBlockConfig.key, (defaultConfig) => ({\n extensions,\n languages,\n\n expandIcon: config.expandIcon || chevronDownIcon,\n searchIcon: config.searchIcon || searchIcon,\n clearSearchIcon: config.clearSearchIcon || clearIcon,\n searchPlaceholder: config.searchPlaceholder || 'Search language',\n copyText: config.copyText || 'Copy',\n copyIcon: config.copyIcon || copyIcon,\n onCopy: config.onCopy || (() => {}),\n noResultText: config.noResultText || 'No result',\n renderLanguage: config.renderLanguage || defaultConfig.renderLanguage,\n renderPreview: config.renderPreview || defaultConfig.renderPreview,\n previewToggleButton: (previewOnlyMode) => {\n const icon =\n config.previewToggleIcon?.(previewOnlyMode) ||\n (previewOnlyMode ? editIcon : visibilityOffIcon)\n const text =\n config.previewToggleText?.(previewOnlyMode) ||\n (previewOnlyMode ? 'Edit' : 'Hide')\n return [icon, text].map((v) => v.trim()).join(' ')\n },\n previewLabel: config.previewLabel || defaultConfig.previewLabel,\n }))\n })\n .use(codeBlockComponent)\n}\n"],"names":["createSlice","CrepeFeature","keymap","defaultKeymap","indentWithTab","basicSetup","codeBlockConfig","codeBlockComponent"],"mappings":";;;;;;;;AAQ2BA,eAAA,CAAY,EAAC,EAAqB,aAAa;AAKlDA,eAAA,CAAY,EAAC,EAAmB,UAAU;AA2B3D,SAAS,iBAAiB,GAAA,EAAU;AAEzC,EAAA,OAAO,GAAA,CAAI,IAAmC,aAAa,CAAA;AAC7D;AAGO,SAAS,mBAAmB,OAAA,EAAuB;AACxD,EAAA,OAAO,CAAC,GAAA,KAAa;AACnB,IAAA,gBAAA,CAAiB,GAAG,CAAA,CAAE,MAAA,CAAO,CAAC,QAAA,KAAa;AACzC,MAAA,IAAI,QAAA,CAAS,QAAA,CAAS,OAAO,CAAA,EAAG;AAC9B,QAAA,OAAO,QAAA;AAAA,MACT;AACA,MAAA,OAAO,CAAC,GAAG,QAAA,EAAU,OAAO,CAAA;AAAA,IAC9B,CAAC,CAAA;AAAA,EACH,CAAA;AACF;;ACvDO,MAAM,eAAA,GAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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A;AAAA,MACrD,mBAAA,EAAqB,CAAC,eAAA,KAAoB;AArFlD,QAAA,IAAA,EAAA,EAAA,EAAA;AAsFU,QAAA,MAAM,SACJ,EAAA,GAAA,MAAA,CAAO,iBAAA,KAAP,IAAA,GAAA,MAAA,GAAA,EAAA,CAAA,IAAA,CAAA,MAAA,EAA2B,eAAA,CAAA,MAC1B,kBAAkB,QAAA,GAAW,iBAAA,CAAA;AAChC,QAAA,MAAM,SACJ,EAAA,GAAA,MAAA,CAAO,iBAAA,KAAP,IAAA,GAAA,MAAA,GAAA,EAAA,CAAA,IAAA,CAAA,MAAA,EAA2B,eAAA,CAAA,MAC1B,kBAAkB,MAAA,GAAS,MAAA,CAAA;AAC9B,QAAA,OAAO,CAAC,IAAA,EAAM,IAAI,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,CAAE,IAAA,EAAM,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAAA,MACnD,CAAA;AAAA,MACA,YAAA,EAAc,MAAA,CAAO,YAAA,IAAgB,aAAA,CAAc;AAAA,KACrD,CAAE,CAAA;AAAA,EACJ,CAAC,CAAA,CACA,GAAA,CAAIC,4BAAkB,CAAA;AAC3B;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/icons/chevron-down.ts","../../../../src/icons/clear.ts","../../../../src/icons/copy.ts","../../../../src/icons/edit.ts","../../../../src/icons/search.ts","../../../../src/icons/visibility-off.ts","../../../../src/feature/index.ts","../../../../src/feature/code-mirror/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","export const chevronDownIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke-width=\"1.5\"\n stroke=\"currentColor\"\n class=\"w-6 h-6\"\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M19.5 8.25l-7.5 7.5-7.5-7.5\"\n />\n </svg>\n`\n","export const clearIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <g clip-path=\"url(#clip0_1098_15553)\">\n <path\n d=\"M18.3007 5.70973C17.9107 5.31973 17.2807 5.31973 16.8907 5.70973L12.0007 10.5897L7.1107 5.69973C6.7207 5.30973 6.0907 5.30973 5.7007 5.69973C5.3107 6.08973 5.3107 6.71973 5.7007 7.10973L10.5907 11.9997L5.7007 16.8897C5.3107 17.2797 5.3107 17.9097 5.7007 18.2997C6.0907 18.6897 6.7207 18.6897 7.1107 18.2997L12.0007 13.4097L16.8907 18.2997C17.2807 18.6897 17.9107 18.6897 18.3007 18.2997C18.6907 17.9097 18.6907 17.2797 18.3007 16.8897L13.4107 11.9997L18.3007 7.10973C18.6807 6.72973 18.6807 6.08973 18.3007 5.70973Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1098_15553\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const copyIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"24px\"\n viewBox=\"0 -960 960 960\"\n width=\"24px\"\n fill=\"none\"\n >\n <path\n d=\"M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z\"\n />\n </svg>\n`\n","export const editIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <g clip-path=\"url(#clip0_1013_1585)\">\n <path\n d=\"M14.06 9.02L14.98 9.94L5.92 19H5V18.08L14.06 9.02ZM17.66 3C17.41 3 17.15 3.1 16.96 3.29L15.13 5.12L18.88 8.87L20.71 7.04C21.1 6.65 21.1 6.02 20.71 5.63L18.37 3.29C18.17 3.09 17.92 3 17.66 3ZM14.06 6.19L3 17.25V21H6.75L17.81 9.94L14.06 6.19Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1013_1585\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const searchIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke-width=\"1.5\"\n stroke=\"currentColor\"\n class=\"w-6 h-6\"\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z\"\n />\n </svg>\n`\n","export const visibilityOffIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"24px\"\n viewBox=\"0 -960 960 960\"\n width=\"24px\"\n >\n <path\n d=\"m644-428-58-58q9-47-27-88t-93-32l-58-58q17-8 34.5-12t37.5-4q75 0 127.5 52.5T660-500q0 20-4 37.5T644-428Zm128 126-58-56q38-29 67.5-63.5T832-500q-50-101-143.5-160.5T480-720q-29 0-57 4t-55 12l-62-62q41-17 84-25.5t90-8.5q151 0 269 83.5T920-500q-23 59-60.5 109.5T772-302Zm20 246L624-222q-35 11-70.5 16.5T480-200q-151 0-269-83.5T40-500q21-53 53-98.5t73-81.5L56-792l56-56 736 736-56 56ZM222-624q-29 26-53 57t-41 67q50 101 143.5 160.5T480-280q20 0 39-2.5t39-5.5l-36-38q-11 3-21 4.5t-21 1.5q-75 0-127.5-52.5T300-500q0-11 1.5-21t4.5-21l-84-82Zm319 93Zm-151 75Z\"\n />\n </svg>\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 { Extension } from '@codemirror/state'\n\nimport { defaultKeymap, indentWithTab } from '@codemirror/commands'\nimport { keymap } from '@codemirror/view'\nimport {\n codeBlockComponent,\n codeBlockConfig,\n type CodeBlockConfig,\n} from '@milkdown/kit/component/code-block'\nimport { basicSetup } from 'codemirror'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig } from '../../core/slice'\nimport {\n chevronDownIcon,\n clearIcon,\n copyIcon,\n editIcon,\n searchIcon,\n visibilityOffIcon,\n} from '../../icons'\nimport { CrepeFeature } from '../index'\n\ninterface CodeMirrorConfig extends CodeBlockConfig {\n theme: Extension\n previewToggleIcon: (previewOnlyMode: boolean) => string\n previewToggleText: (previewOnlyMode: boolean) => string\n}\n\nexport type CodeMirrorFeatureConfig = Partial<CodeMirrorConfig>\n\nexport const codeMirror: DefineFeature<CodeMirrorFeatureConfig> = (\n editor,\n config = {}\n) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.CodeMirror))\n .config((ctx) => {\n const { languages = [], theme } = config\n const extensions = [\n keymap.of(defaultKeymap.concat(indentWithTab)),\n basicSetup,\n ]\n if (theme) {\n extensions.push(theme)\n }\n if (config.extensions) {\n extensions.push(...config.extensions)\n }\n\n ctx.update(codeBlockConfig.key, (defaultConfig) => ({\n extensions,\n languages,\n\n expandIcon: config.expandIcon || chevronDownIcon,\n searchIcon: config.searchIcon || searchIcon,\n clearSearchIcon: config.clearSearchIcon || clearIcon,\n searchPlaceholder: config.searchPlaceholder || 'Search language',\n copyText: config.copyText || 'Copy',\n copyIcon: config.copyIcon || copyIcon,\n onCopy: config.onCopy || (() => {}),\n noResultText: config.noResultText || 'No result',\n renderLanguage: config.renderLanguage || defaultConfig.renderLanguage,\n renderPreview: config.renderPreview || defaultConfig.renderPreview,\n previewToggleButton: (previewOnlyMode) => {\n const icon =\n config.previewToggleIcon?.(previewOnlyMode) ||\n (previewOnlyMode ? editIcon : visibilityOffIcon)\n const text =\n config.previewToggleText?.(previewOnlyMode) ||\n (previewOnlyMode ? 'Edit' : 'Hide')\n return [icon, text].map((v) => v.trim()).join(' ')\n },\n previewLabel: config.previewLabel || defaultConfig.previewLabel,\n previewLoading: config.previewLoading || defaultConfig.previewLoading,\n previewOnlyByDefault:\n config.previewOnlyByDefault ?? defaultConfig.previewOnlyByDefault,\n }))\n })\n .use(codeBlockComponent)\n}\n"],"names":["createSlice","CrepeFeature","keymap","defaultKeymap","indentWithTab","basicSetup","codeBlockConfig","_a","codeBlockComponent"],"mappings":";;;;;;;;AAQ2BA,eAAA,CAAY,EAAC,EAAqB,aAAa;AAKlDA,eAAA,CAAY,EAAC,EAAmB,UAAU;AA2B3D,SAAS,iBAAiB,GAAA,EAAU;AAEzC,EAAA,OAAO,GAAA,CAAI,IAAmC,aAAa,CAAA;AAC7D;AAGO,SAAS,mBAAmB,OAAA,EAAuB;AACxD,EAAA,OAAO,CAAC,GAAA,KAAa;AACnB,IAAA,gBAAA,CAAiB,GAAG,CAAA,CAAE,MAAA,CAAO,CAAC,QAAA,KAAa;AACzC,MAAA,IAAI,QAAA,CAAS,QAAA,CAAS,OAAO,CAAA,EAAG;AAC9B,QAAA,OAAO,QAAA;AAAA,MACT;AACA,MAAA,OAAO,CAAC,GAAG,QAAA,EAAU,OAAO,CAAA;AAAA,IAC9B,CAAC,CAAA;AAAA,EACH,CAAA;AACF;;ACvDO,MAAM,eAAA,GAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACAxB,MAAM,SAAA,GAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACAlB,MAAM,QAAA,GAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACAjB,MAAM,QAAA,GA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ChC,UAAA,MAAM,SACJ,EAAA,GAAA,MAAA,CAAO,iBAAA,KAAP,IAAA,GAAA,MAAA,GAAA,EAAA,CAAA,IAAA,CAAA,MAAA,EAA2B,eAAA,CAAA,MAC1B,kBAAkB,MAAA,GAAS,MAAA,CAAA;AAC9B,UAAA,OAAO,CAAC,IAAA,EAAM,IAAI,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,CAAE,IAAA,EAAM,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAAA,QACnD,CAAA;AAAA,QACA,YAAA,EAAc,MAAA,CAAO,YAAA,IAAgB,aAAA,CAAc,YAAA;AAAA,QACnD,cAAA,EAAgB,MAAA,CAAO,cAAA,IAAkB,aAAA,CAAc,cAAA;AAAA,QACvD,oBAAA,EAAA,CACE,EAAA,GAAA,MAAA,CAAO,oBAAA,KAAP,IAAA,GAAA,EAAA,GAA+B,aAAA,CAAc;AAAA,OACjD;AAAA,IAAA,CAAE,CAAA;AAAA,EACJ,CAAC,CAAA,CACA,GAAA,CAAIC,4BAAkB,CAAA;AAC3B;;;;"}
|
|
@@ -389,12 +389,12 @@ const latex = (editor, config) => {
|
|
|
389
389
|
}
|
|
390
390
|
ctx.update(codeBlock.codeBlockConfig.key, (prev) => ({
|
|
391
391
|
...prev,
|
|
392
|
-
renderPreview: (language, content) => {
|
|
392
|
+
renderPreview: (language, content, applyPreview) => {
|
|
393
393
|
if (language.toLowerCase() === "latex" && content.length > 0) {
|
|
394
394
|
return renderLatex(content, config == null ? void 0 : config.katexOptions);
|
|
395
395
|
}
|
|
396
396
|
const renderPreview = prev.renderPreview;
|
|
397
|
-
return renderPreview(language, content);
|
|
397
|
+
return renderPreview(language, content, applyPreview);
|
|
398
398
|
}
|
|
399
399
|
}));
|
|
400
400
|
ctx.set(inlineLatexTooltip.key, {
|
|
@@ -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/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,GAAA,EAAU;AAEzC,EAAA,OAAO,GAAA,CAAI,IAAmC,aAAa,CAAA;AAC7D;AAGO,SAAS,mBAAmB,OAAA,EAAuB;AACxD,EAAA,OAAO,CAAC,GAAA,KAAa;AACnB,IAAA,gBAAA,CAAiB,GAAG,CAAA,CAAE,MAAA,CAAO,CAAC,QAAA,KAAa;AACzC,MAAA,IAAI,QAAA,CAAS,QAAA,CAAS,OAAO,CAAA,EAAG;AAC9B,QAAA,OAAO,QAAA;AAAA,MACT;AACA,MAAA,OAAO,CAAC,GAAG,QAAA,EAAU,OAAO,CAAA;AAAA,IAC9B,CAAC,CAAA;AAAA,EACH,CAAA;AACF;;ACzCO,IAAK,YAAA,qBAAAC,aAAAA,KAAL;AAEL,EAAAA,cAAA,YAAA,CAAA,GAAa,aAAA;AAGb,EAAAA,cAAA,UAAA,CAAA,GAAW,WAAA;AAGX,EAAAA,cAAA,aAAA,CAAA,GAAc,cAAA;AAGd,EAAAA,cAAA,QAAA,CAAA,GAAS,QAAA;AAGT,EAAAA,cAAA,YAAA,CAAA,GAAa,aAAA;AAGb,EAAAA,cAAA,WAAA,CAAA,GAAY,YAAA;AAGZ,EAAAA,cAAA,SAAA,CAAA,GAAU,SAAA;AAGV,EAAAA,cAAA,aAAA,CAAA,GAAc,aAAA;AAGd,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AA,GAAA,CAAI,GAAA,CAAI,mBAAmB,GAAA,EAAK;AAAA,MAC9B,IAAA,EAAM,CAAC,IAAA,KAAS;AA/CxB,QAAA,IAAA,EAAA;AAgDU,QAAA,OAAO,IAAI,kBAAA,CAAmB,GAAA,EAAK,IAAA,EAAM;AAAA,UACvC,iBAAA,EAAA,CAAmB,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,iBAAA,KAAR,IAAA,GAAA,EAAA,GAA6B,WAAA;AAAA,UAChD,GAAG;AAAA,SACJ,CAAA;AAAA,MACH;AAAA,KACD,CAAA;AAAA,EACH,CAAC,CAAA,CACA,GAAA,CAAI,gBAAgB,CAAA,CACpB,IAAI,qBAAqB,CAAA,CACzB,GAAA,CAAI,gBAAgB,CAAA,CACpB,GAAA,CAAI,kBAAkB,CAAA,CACtB,GAAA,CAAI,mBAAmB,CAAA,CACvB,GAAA,CAAI,kBAAkB,EACtB,GAAA,CAAI,gBAAgB,CAAA,CACpB,GAAA,CAAI,kBAAkB,CAAA;AAC3B;AAEA,SAAS,WAAA,CAAY,SAAiB,OAAA,EAAwB;AAC5D,EAAA,MAAM,IAAA,GAAO,KAAA,CAAM,cAAA,CAAe,OAAA,EAAS;AAAA,IACzC,GAAG,OAAA;AAAA,IACH,YAAA,EAAc,KAAA;AAAA,IACd,WAAA,EAAa;AAAA,GACd,CAAA;AACD,EAAA,OAAO,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, applyPreview) => {\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, applyPreview)\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","TooltipProv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mB,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,iBAAA,KAAR,IAAA,GAAA,EAAA,GAA6B,WAAA;AAAA,UAChD,GAAG;AAAA,SACJ,CAAA;AAAA,MACH;AAAA,KACD,CAAA;AAAA,EACH,CAAC,CAAA,CACA,GAAA,CAAI,gBAAgB,CAAA,CACpB,IAAI,qBAAqB,CAAA,CACzB,GAAA,CAAI,gBAAgB,CAAA,CACpB,GAAA,CAAI,kBAAkB,CAAA,CACtB,GAAA,CAAI,mBAAmB,CAAA,CACvB,GAAA,CAAI,kBAAkB,EACtB,GAAA,CAAI,gBAAgB,CAAA,CACpB,GAAA,CAAI,kBAAkB,CAAA;AAC3B;AAEA,SAAS,WAAA,CAAY,SAAiB,OAAA,EAAwB;AAC5D,EAAA,MAAM,IAAA,GAAO,KAAA,CAAM,cAAA,CAAe,OAAA,EAAS;AAAA,IACzC,GAAG,OAAA;AAAA,IACH,YAAA,EAAc,KAAA;AAAA,IACd,WAAA,EAAa;AAAA,GACd,CAAA;AACD,EAAA,OAAO,IAAA;AACT;;;;"}
|
package/lib/cjs/index.js
CHANGED
|
@@ -1558,28 +1558,33 @@ const codeMirror = (editor, config = {}) => {
|
|
|
1558
1558
|
if (config.extensions) {
|
|
1559
1559
|
extensions.push(...config.extensions);
|
|
1560
1560
|
}
|
|
1561
|
-
ctx.update(codeBlock.codeBlockConfig.key, (defaultConfig) =>
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1561
|
+
ctx.update(codeBlock.codeBlockConfig.key, (defaultConfig) => {
|
|
1562
|
+
var _a;
|
|
1563
|
+
return {
|
|
1564
|
+
extensions,
|
|
1565
|
+
languages,
|
|
1566
|
+
expandIcon: config.expandIcon || chevronDownIcon,
|
|
1567
|
+
searchIcon: config.searchIcon || searchIcon,
|
|
1568
|
+
clearSearchIcon: config.clearSearchIcon || clearIcon,
|
|
1569
|
+
searchPlaceholder: config.searchPlaceholder || "Search language",
|
|
1570
|
+
copyText: config.copyText || "Copy",
|
|
1571
|
+
copyIcon: config.copyIcon || copyIcon,
|
|
1572
|
+
onCopy: config.onCopy || (() => {
|
|
1573
|
+
}),
|
|
1574
|
+
noResultText: config.noResultText || "No result",
|
|
1575
|
+
renderLanguage: config.renderLanguage || defaultConfig.renderLanguage,
|
|
1576
|
+
renderPreview: config.renderPreview || defaultConfig.renderPreview,
|
|
1577
|
+
previewToggleButton: (previewOnlyMode) => {
|
|
1578
|
+
var _a2, _b;
|
|
1579
|
+
const icon = ((_a2 = config.previewToggleIcon) == null ? void 0 : _a2.call(config, previewOnlyMode)) || (previewOnlyMode ? editIcon : visibilityOffIcon);
|
|
1580
|
+
const text = ((_b = config.previewToggleText) == null ? void 0 : _b.call(config, previewOnlyMode)) || (previewOnlyMode ? "Edit" : "Hide");
|
|
1581
|
+
return [icon, text].map((v) => v.trim()).join(" ");
|
|
1582
|
+
},
|
|
1583
|
+
previewLabel: config.previewLabel || defaultConfig.previewLabel,
|
|
1584
|
+
previewLoading: config.previewLoading || defaultConfig.previewLoading,
|
|
1585
|
+
previewOnlyByDefault: (_a = config.previewOnlyByDefault) != null ? _a : defaultConfig.previewOnlyByDefault
|
|
1586
|
+
};
|
|
1587
|
+
});
|
|
1583
1588
|
}).use(codeBlock.codeBlockComponent);
|
|
1584
1589
|
};
|
|
1585
1590
|
|
|
@@ -1949,12 +1954,12 @@ const latex = (editor, config) => {
|
|
|
1949
1954
|
}
|
|
1950
1955
|
ctx.update(codeBlock.codeBlockConfig.key, (prev) => ({
|
|
1951
1956
|
...prev,
|
|
1952
|
-
renderPreview: (language, content) => {
|
|
1957
|
+
renderPreview: (language, content, applyPreview) => {
|
|
1953
1958
|
if (language.toLowerCase() === "latex" && content.length > 0) {
|
|
1954
1959
|
return renderLatex(content, config == null ? void 0 : config.katexOptions);
|
|
1955
1960
|
}
|
|
1956
1961
|
const renderPreview = prev.renderPreview;
|
|
1957
|
-
return renderPreview(language, content);
|
|
1962
|
+
return renderPreview(language, content, applyPreview);
|
|
1958
1963
|
}
|
|
1959
1964
|
}));
|
|
1960
1965
|
ctx.set(inlineLatexTooltip.key, {
|