@milkdown/crepe 7.15.1 → 7.15.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/feature/index.ts","../../../../src/feature/cursor/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","import {\n cursor as cursorPlugin,\n dropCursorConfig,\n} from '@milkdown/kit/plugin/cursor'\nimport { $prose } from '@milkdown/kit/utils'\nimport { createVirtualCursor } from 'prosemirror-virtual-cursor'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig } from '../../core/slice'\nimport { CrepeFeature } from '../index'\n\ninterface CursorConfig {\n color: string | false\n width: number\n virtual: boolean\n}\nexport type CursorFeatureConfig = Partial<CursorConfig>\n\nexport const cursor: DefineFeature<CursorFeatureConfig> = (editor, config) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.Cursor))\n .config((ctx) => {\n ctx.update(dropCursorConfig.key, () => ({\n class: 'crepe-drop-cursor',\n width: config?.width ?? 4,\n color: config?.color ?? false,\n }))\n })\n .use(cursorPlugin)\n\n if (config?.virtual === false) {\n return\n }\n\n const virtualCursor = createVirtualCursor()\n editor.use($prose(() => virtualCursor))\n}\n"],"names":["CrepeFeature","cursorPlugin"],"mappings":";;;;;AAQ2B,WAAA,CAAY,EAAC,EAAqB,aAAa;AAKlD,WAAA,CAAY,EAAC,EAAmB,UAAU;AA2B3D,SAAS,iBAAiB,GAAA,EAAU;AAEzC,EAAA,OAAO,GAAA,CAAI,IAAmC,aAAa,CAAA;AAC7D;AAGO,SAAS,mBAAmB,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,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,KAAA,KAAR,IAAA,GAAA,EAAA,GAAiB,CAAA;AAAA,QACxB,KAAA,EAAA,CAAO,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,KAAA,KAAR,IAAA,GAAA,EAAA,GAAiB;AAAA,OAC1B;AAAA,KAAE,CAAA;AAAA,GACH,CAAA,CACA,GAAA,CAAIC,QAAY,CAAA;AAEnB,EAAA,IAAA,CAAI,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,aAAY,KAAA,EAAO;AAC7B,IAAA;AAAA;AAGF,EAAA,MAAM,gBAAgB,mBAAA,EAAoB;AAC1C,EAAA,MAAA,CAAO,GAAA,CAAI,MAAA,CAAO,MAAM,aAAa,CAAC,CAAA;AACxC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/feature/index.ts","../../../../src/feature/cursor/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","import {\n cursor as cursorPlugin,\n dropCursorConfig,\n} from '@milkdown/kit/plugin/cursor'\nimport { $prose } from '@milkdown/kit/utils'\nimport { createVirtualCursor } from 'prosemirror-virtual-cursor'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig } from '../../core/slice'\nimport { CrepeFeature } from '../index'\n\ninterface CursorConfig {\n color: string | false\n width: number\n virtual: boolean\n}\nexport type CursorFeatureConfig = Partial<CursorConfig>\n\nexport const cursor: DefineFeature<CursorFeatureConfig> = (editor, config) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.Cursor))\n .config((ctx) => {\n ctx.update(dropCursorConfig.key, () => ({\n class: 'crepe-drop-cursor',\n width: config?.width ?? 4,\n color: config?.color ?? false,\n }))\n })\n .use(cursorPlugin)\n\n if (config?.virtual === false) {\n return\n }\n\n const virtualCursor = createVirtualCursor()\n editor.use($prose(() => virtualCursor))\n}\n"],"names":["CrepeFeature","cursorPlugin"],"mappings":";;;;;AAQ2B,WAAA,CAAY,EAAC,EAAqB,aAAa;AAKlD,WAAA,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,qBAAAA,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,EAAAA,cAAA,OAAA,CAAA,GAAQ,OAAA;AAGR,EAAAA,cAAA,OAAA,CAAA,GAAQ,OAAA;AA7BE,EAAA,OAAAA,aAAAA;AAAA,CAAA,EAAA,YAAA,IAAA,EAAA,CAAA;;ACKL,MAAM,MAAA,GAA6C,CAAC,MAAA,EAAQ,MAAA,KAAW;AAC5E,EAAA,MAAA,CACG,MAAA,CAAO,mBAAmB,YAAA,CAAa,MAAM,CAAC,CAAA,CAC9C,MAAA,CAAO,CAAC,GAAA,KAAQ;AACf,IAAA,GAAA,CAAI,MAAA,CAAO,gBAAA,CAAiB,GAAA,EAAK,MAAG;AAvB1C,MAAA,IAAA,EAAA,EAAA,EAAA;AAuB8C,MAAA,OAAA;AAAA,QACtC,KAAA,EAAO,mBAAA;AAAA,QACP,KAAA,EAAA,CAAO,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,KAAA,KAAR,IAAA,GAAA,EAAA,GAAiB,CAAA;AAAA,QACxB,KAAA,EAAA,CAAO,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,KAAA,KAAR,IAAA,GAAA,EAAA,GAAiB;AAAA,OAC1B;AAAA,IAAA,CAAE,CAAA;AAAA,EACJ,CAAC,CAAA,CACA,GAAA,CAAIC,QAAY,CAAA;AAEnB,EAAA,IAAA,CAAI,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,aAAY,KAAA,EAAO;AAC7B,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,gBAAgB,mBAAA,EAAoB;AAC1C,EAAA,MAAA,CAAO,GAAA,CAAI,MAAA,CAAO,MAAM,aAAa,CAAC,CAAA;AACxC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/icons/caption.ts","../../../../src/icons/confirm.ts","../../../../src/icons/image.ts","../../../../src/feature/index.ts","../../../../src/feature/image-block/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 captionIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"32\"\n height=\"32\"\n viewBox=\"0 0 24 24\"\n >\n <path\n fill=\"currentColor\"\n d=\"M9 22a1 1 0 0 1-1-1v-3H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6.1l-3.7 3.71c-.2.19-.45.29-.7.29zm1-6v3.08L13.08 16H20V4H4v12z\"\n />\n </svg>\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","export const imageIcon = `\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_977_8075)\">\n <path\n d=\"M19 5V19H5V5H19ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM14.14 11.86L11.14 15.73L9 13.14L6 17H18L14.14 11.86Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_977_8075\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\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 {\n imageBlockComponent,\n imageBlockConfig,\n} from '@milkdown/kit/component/image-block'\nimport {\n imageInlineComponent,\n inlineImageConfig,\n} from '@milkdown/kit/component/image-inline'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig } from '../../core/slice'\nimport { captionIcon, imageIcon, confirmIcon } from '../../icons'\nimport { CrepeFeature } from '../index'\n\ninterface ImageBlockConfig {\n onUpload: (file: File) => Promise<string>\n proxyDomURL: (url: string) => Promise<string> | string\n\n inlineImageIcon: string\n inlineConfirmButton: string\n inlineUploadButton: string\n inlineUploadPlaceholderText: string\n inlineOnUpload: (file: File) => Promise<string>\n\n blockImageIcon: string\n blockConfirmButton: string\n blockCaptionIcon: string\n blockUploadButton: string\n blockCaptionPlaceholderText: string\n blockUploadPlaceholderText: string\n blockOnUpload: (file: File) => Promise<string>\n}\n\nexport type ImageBlockFeatureConfig = Partial<ImageBlockConfig>\n\nexport const imageBlock: DefineFeature<ImageBlockFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.ImageBlock))\n .config((ctx) => {\n ctx.update(inlineImageConfig.key, (value) => ({\n uploadButton: config?.inlineUploadButton ?? 'Upload',\n imageIcon: config?.inlineImageIcon ?? imageIcon,\n confirmButton: config?.inlineConfirmButton ?? confirmIcon,\n uploadPlaceholderText:\n config?.inlineUploadPlaceholderText ?? 'or paste link',\n onUpload: config?.inlineOnUpload ?? config?.onUpload ?? value.onUpload,\n proxyDomURL: config?.proxyDomURL,\n }))\n ctx.update(imageBlockConfig.key, (value) => ({\n uploadButton: config?.blockUploadButton ?? 'Upload file',\n imageIcon: config?.blockImageIcon ?? imageIcon,\n captionIcon: config?.blockCaptionIcon ?? captionIcon,\n confirmButton: config?.blockConfirmButton ?? 'Confirm',\n captionPlaceholderText:\n config?.blockCaptionPlaceholderText ?? 'Write Image Caption',\n uploadPlaceholderText:\n config?.blockUploadPlaceholderText ?? 'or paste link',\n onUpload: config?.blockOnUpload ?? config?.onUpload ?? value.onUpload,\n proxyDomURL: config?.proxyDomURL,\n }))\n })\n .use(imageBlockComponent)\n .use(imageInlineComponent)\n}\n"],"names":["CrepeFeature"],"mappings":";;;;AAQ2B,WAAA,CAAY,EAAC,EAAqB,aAAa;AAKlD,WAAA,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;AAET,MAAA,OAAO,CAAC,GAAG,QAAA,EAAU,OAAO,CAAA;AAAA,KAC7B,CAAA;AAAA,GACH;AACF;;ACvDO,MAAM,WAAA,GAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACApB,MAAM,WAAA,GAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACApB,MAAM,SAAA,GAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACclB,IAAK,YAAA,qBAAAA,aAAAA,KAAL;AAEL,EAAAA,cAAA,YAAA,CAAA,GAAa,aAAA;AAGb,EAAAA,cAAA,UAAA,CAAA,GAAW,WAAA;AAGX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BAAA,KAAR,IAAA,GAAA,EAAA,GAAuC,qBAAA;AAAA,QACzC,qBAAA,EAAA,CACE,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,0BAAA,KAAR,IAAA,GAAA,EAAA,GAAsC,eAAA;AAAA,QACxC,WAAU,EAAA,GAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,aAAA,KAAR,YAAyB,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,QAAA,KAAjC,YAA6C,KAAA,CAAM,QAAA;AAAA,QAC7D,aAAa,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ;AAAA,OACvB;AAAA,KAAE,CAAA;AAAA,GACH,CAAA,CACA,GAAA,CAAI,mBAAmB,CAAA,CACvB,IAAI,oBAAoB,CAAA;AAC7B;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/icons/caption.ts","../../../../src/icons/confirm.ts","../../../../src/icons/image.ts","../../../../src/feature/index.ts","../../../../src/feature/image-block/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 captionIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"32\"\n height=\"32\"\n viewBox=\"0 0 24 24\"\n >\n <path\n fill=\"currentColor\"\n d=\"M9 22a1 1 0 0 1-1-1v-3H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6.1l-3.7 3.71c-.2.19-.45.29-.7.29zm1-6v3.08L13.08 16H20V4H4v12z\"\n />\n </svg>\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","export const imageIcon = `\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_977_8075)\">\n <path\n d=\"M19 5V19H5V5H19ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM14.14 11.86L11.14 15.73L9 13.14L6 17H18L14.14 11.86Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_977_8075\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\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 {\n imageBlockComponent,\n imageBlockConfig,\n} from '@milkdown/kit/component/image-block'\nimport {\n imageInlineComponent,\n inlineImageConfig,\n} from '@milkdown/kit/component/image-inline'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig } from '../../core/slice'\nimport { captionIcon, imageIcon, confirmIcon } from '../../icons'\nimport { CrepeFeature } from '../index'\n\ninterface ImageBlockConfig {\n onUpload: (file: File) => Promise<string>\n proxyDomURL: (url: string) => Promise<string> | string\n\n inlineImageIcon: string\n inlineConfirmButton: string\n inlineUploadButton: string\n inlineUploadPlaceholderText: string\n inlineOnUpload: (file: File) => Promise<string>\n\n blockImageIcon: string\n blockConfirmButton: string\n blockCaptionIcon: string\n blockUploadButton: string\n blockCaptionPlaceholderText: string\n blockUploadPlaceholderText: string\n blockOnUpload: (file: File) => Promise<string>\n}\n\nexport type ImageBlockFeatureConfig = Partial<ImageBlockConfig>\n\nexport const imageBlock: DefineFeature<ImageBlockFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.ImageBlock))\n .config((ctx) => {\n ctx.update(inlineImageConfig.key, (value) => ({\n uploadButton: config?.inlineUploadButton ?? 'Upload',\n imageIcon: config?.inlineImageIcon ?? imageIcon,\n confirmButton: config?.inlineConfirmButton ?? confirmIcon,\n uploadPlaceholderText:\n config?.inlineUploadPlaceholderText ?? 'or paste link',\n onUpload: config?.inlineOnUpload ?? config?.onUpload ?? value.onUpload,\n proxyDomURL: config?.proxyDomURL,\n }))\n ctx.update(imageBlockConfig.key, (value) => ({\n uploadButton: config?.blockUploadButton ?? 'Upload file',\n imageIcon: config?.blockImageIcon ?? imageIcon,\n captionIcon: config?.blockCaptionIcon ?? captionIcon,\n confirmButton: config?.blockConfirmButton ?? 'Confirm',\n captionPlaceholderText:\n config?.blockCaptionPlaceholderText ?? 'Write Image Caption',\n uploadPlaceholderText:\n config?.blockUploadPlaceholderText ?? 'or paste link',\n onUpload: config?.blockOnUpload ?? config?.onUpload ?? value.onUpload,\n proxyDomURL: config?.proxyDomURL,\n }))\n })\n .use(imageBlockComponent)\n .use(imageInlineComponent)\n}\n"],"names":["CrepeFeature"],"mappings":";;;;AAQ2B,WAAA,CAAY,EAAC,EAAqB,aAAa;AAKlD,WAAA,CAAY,EAAC,EAAmB,UAAU;AA2B3D,SAAS,iBAAiB,GAAA,EAAU;AAEzC,EAAA,OAAO,GAAA,CAAI,IAAmC,aAAa,CAAA;AAC7D;AAGO,SAAS,mBAAmB,OAAA,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;AAAA,QAC7D,aAAa,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ;AAAA,OACvB;AAAA,IAAA,CAAE,CAAA;AAAA,EACJ,CAAC,CAAA,CACA,GAAA,CAAI,mBAAmB,CAAA,CACvB,IAAI,oBAAoB,CAAA;AAC7B;;;;"}
@@ -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":["CrepeFeature","_tr"],"mappings":";;;;;;;;;;;;;;;;;;AAQ2B,WAAA,CAAY,EAAC,EAAqB,aAAa;AAKlD,WAAA,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;AAET,MAAA,OAAO,CAAC,GAAG,QAAA,EAAU,OAAO,CAAA;AAAA,KAC7B,CAAA;AAAA,GACH;AACF;;ACzCO,IAAK,YAAA,qBAAAA,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,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AAA,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;AACH,KACD,CAAA;AAAA,GACF,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) => {\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":["CrepeFeature","_tr"],"mappings":";;;;;;;;;;;;;;;;;;AAQ2B,WAAA,CAAY,EAAC,EAAqB,aAAa;AAKlD,WAAA,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,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D,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 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/icons/confirm.ts","../../../../src/icons/copy.ts","../../../../src/icons/edit.ts","../../../../src/icons/remove.ts","../../../../src/feature/index.ts","../../../../src/feature/link-tooltip/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 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","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 removeIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <path\n d=\"M7.30775 20.4997C6.81058 20.4997 6.385 20.3227 6.031 19.9687C5.677 19.6147 5.5 19.1892 5.5 18.692V5.99973H5.25C5.0375 5.99973 4.85942 5.92782 4.71575 5.78398C4.57192 5.64015 4.5 5.46198 4.5 5.24948C4.5 5.03682 4.57192 4.85873 4.71575 4.71523C4.85942 4.57157 5.0375 4.49973 5.25 4.49973H9C9 4.2549 9.08625 4.04624 9.25875 3.87374C9.43108 3.7014 9.63967 3.61523 9.8845 3.61523H14.1155C14.3603 3.61523 14.5689 3.7014 14.7413 3.87374C14.9138 4.04624 15 4.2549 15 4.49973H18.75C18.9625 4.49973 19.1406 4.57165 19.2843 4.71548C19.4281 4.85932 19.5 5.03748 19.5 5.24998C19.5 5.46265 19.4281 5.64073 19.2843 5.78423C19.1406 5.9279 18.9625 5.99973 18.75 5.99973H18.5V18.692C18.5 19.1892 18.323 19.6147 17.969 19.9687C17.615 20.3227 17.1894 20.4997 16.6923 20.4997H7.30775ZM17 5.99973H7V18.692C7 18.7818 7.02883 18.8556 7.0865 18.9132C7.14417 18.9709 7.21792 18.9997 7.30775 18.9997H16.6923C16.7821 18.9997 16.8558 18.9709 16.9135 18.9132C16.9712 18.8556 17 18.7818 17 18.692V5.99973ZM10.1543 16.9997C10.3668 16.9997 10.5448 16.9279 10.6885 16.7842C10.832 16.6404 10.9037 16.4622 10.9037 16.2497V8.74973C10.9037 8.53723 10.8318 8.35907 10.688 8.21523C10.5443 8.07157 10.3662 7.99973 10.1535 7.99973C9.941 7.99973 9.76292 8.07157 9.61925 8.21523C9.47575 8.35907 9.404 8.53723 9.404 8.74973V16.2497C9.404 16.4622 9.47583 16.6404 9.6195 16.7842C9.76333 16.9279 9.94158 16.9997 10.1543 16.9997ZM13.8465 16.9997C14.059 16.9997 14.2371 16.9279 14.3807 16.7842C14.5243 16.6404 14.596 16.4622 14.596 16.2497V8.74973C14.596 8.53723 14.5242 8.35907 14.3805 8.21523C14.2367 8.07157 14.0584 7.99973 13.8458 7.99973C13.6333 7.99973 13.4552 8.07157 13.3115 8.21523C13.168 8.35907 13.0962 8.53723 13.0962 8.74973V16.2497C13.0962 16.4622 13.1682 16.6404 13.312 16.7842C13.4557 16.9279 13.6338 16.9997 13.8465 16.9997Z\"\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 {\n configureLinkTooltip,\n linkTooltipConfig,\n linkTooltipPlugin,\n} from '@milkdown/kit/component/link-tooltip'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig } from '../../core/slice'\nimport { copyIcon, editIcon, removeIcon, confirmIcon } from '../../icons'\nimport { CrepeFeature } from '../index'\n\ninterface LinkTooltipConfig {\n linkIcon: string\n editButton: string\n removeButton: string\n confirmButton: string\n inputPlaceholder: string\n onCopyLink: (link: string) => void\n}\n\nexport type LinkTooltipFeatureConfig = Partial<LinkTooltipConfig>\n\nexport const linkTooltip: DefineFeature<LinkTooltipFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.LinkTooltip))\n .config(configureLinkTooltip)\n .config((ctx) => {\n ctx.update(linkTooltipConfig.key, (prev) => ({\n ...prev,\n linkIcon: config?.linkIcon ?? copyIcon,\n editButton: config?.editButton ?? editIcon,\n removeButton: config?.removeButton ?? removeIcon,\n confirmButton: config?.confirmButton ?? confirmIcon,\n inputPlaceholder: config?.inputPlaceholder ?? 'Paste link...',\n onCopyLink: config?.onCopyLink ?? (() => {}),\n }))\n })\n .use(linkTooltipPlugin)\n}\n"],"names":["CrepeFeature"],"mappings":";;;AAQ2B,WAAA,CAAY,EAAC,EAAqB,aAAa;AAKlD,WAAA,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;AAET,MAAA,OAAO,CAAC,GAAG,QAAA,EAAU,OAAO,CAAA;AAAA,KAC7B,CAAA;AAAA,GACH;AACF;;ACvDO,MAAM,WAAA,GAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACApB,MAAM,QAAA,GAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACAjB,MAAM,QAAA,GAAW;AAAA;AAAA;AA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,GAAA,MAAA,CAAQ,QAAA,KAAR,IAAA,GAAA,EAAA,GAAoB,QAAA;AAAA,QAC9B,UAAA,EAAA,CAAY,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,UAAA,KAAR,IAAA,GAAA,EAAA,GAAsB,QAAA;AAAA,QAClC,YAAA,EAAA,CAAc,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,YAAA,KAAR,IAAA,GAAA,EAAA,GAAwB,UAAA;AAAA,QACtC,aAAA,EAAA,CAAe,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,aAAA,KAAR,IAAA,GAAA,EAAA,GAAyB,WAAA;AAAA,QACxC,gBAAA,EAAA,CAAkB,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,gBAAA,KAAR,IAAA,GAAA,EAAA,GAA4B,eAAA;AAAA,QAC9C,UAAA,EAAA,CAAY,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,UAAA,KAAR,IAAA,GAAA,EAAA,GAAuB,MAAM;AAAA;AAAC,OAC5C;AAAA,KAAE,CAAA;AAAA,GACH,CAAA,CACA,GAAA,CAAI,iBAAiB,CAAA;AAC1B;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/icons/confirm.ts","../../../../src/icons/copy.ts","../../../../src/icons/edit.ts","../../../../src/icons/remove.ts","../../../../src/feature/index.ts","../../../../src/feature/link-tooltip/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 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","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 removeIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <path\n d=\"M7.30775 20.4997C6.81058 20.4997 6.385 20.3227 6.031 19.9687C5.677 19.6147 5.5 19.1892 5.5 18.692V5.99973H5.25C5.0375 5.99973 4.85942 5.92782 4.71575 5.78398C4.57192 5.64015 4.5 5.46198 4.5 5.24948C4.5 5.03682 4.57192 4.85873 4.71575 4.71523C4.85942 4.57157 5.0375 4.49973 5.25 4.49973H9C9 4.2549 9.08625 4.04624 9.25875 3.87374C9.43108 3.7014 9.63967 3.61523 9.8845 3.61523H14.1155C14.3603 3.61523 14.5689 3.7014 14.7413 3.87374C14.9138 4.04624 15 4.2549 15 4.49973H18.75C18.9625 4.49973 19.1406 4.57165 19.2843 4.71548C19.4281 4.85932 19.5 5.03748 19.5 5.24998C19.5 5.46265 19.4281 5.64073 19.2843 5.78423C19.1406 5.9279 18.9625 5.99973 18.75 5.99973H18.5V18.692C18.5 19.1892 18.323 19.6147 17.969 19.9687C17.615 20.3227 17.1894 20.4997 16.6923 20.4997H7.30775ZM17 5.99973H7V18.692C7 18.7818 7.02883 18.8556 7.0865 18.9132C7.14417 18.9709 7.21792 18.9997 7.30775 18.9997H16.6923C16.7821 18.9997 16.8558 18.9709 16.9135 18.9132C16.9712 18.8556 17 18.7818 17 18.692V5.99973ZM10.1543 16.9997C10.3668 16.9997 10.5448 16.9279 10.6885 16.7842C10.832 16.6404 10.9037 16.4622 10.9037 16.2497V8.74973C10.9037 8.53723 10.8318 8.35907 10.688 8.21523C10.5443 8.07157 10.3662 7.99973 10.1535 7.99973C9.941 7.99973 9.76292 8.07157 9.61925 8.21523C9.47575 8.35907 9.404 8.53723 9.404 8.74973V16.2497C9.404 16.4622 9.47583 16.6404 9.6195 16.7842C9.76333 16.9279 9.94158 16.9997 10.1543 16.9997ZM13.8465 16.9997C14.059 16.9997 14.2371 16.9279 14.3807 16.7842C14.5243 16.6404 14.596 16.4622 14.596 16.2497V8.74973C14.596 8.53723 14.5242 8.35907 14.3805 8.21523C14.2367 8.07157 14.0584 7.99973 13.8458 7.99973C13.6333 7.99973 13.4552 8.07157 13.3115 8.21523C13.168 8.35907 13.0962 8.53723 13.0962 8.74973V16.2497C13.0962 16.4622 13.1682 16.6404 13.312 16.7842C13.4557 16.9279 13.6338 16.9997 13.8465 16.9997Z\"\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 {\n configureLinkTooltip,\n linkTooltipConfig,\n linkTooltipPlugin,\n} from '@milkdown/kit/component/link-tooltip'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig } from '../../core/slice'\nimport { copyIcon, editIcon, removeIcon, confirmIcon } from '../../icons'\nimport { CrepeFeature } from '../index'\n\ninterface LinkTooltipConfig {\n linkIcon: string\n editButton: string\n removeButton: string\n confirmButton: string\n inputPlaceholder: string\n onCopyLink: (link: string) => void\n}\n\nexport type LinkTooltipFeatureConfig = Partial<LinkTooltipConfig>\n\nexport const linkTooltip: DefineFeature<LinkTooltipFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.LinkTooltip))\n .config(configureLinkTooltip)\n .config((ctx) => {\n ctx.update(linkTooltipConfig.key, (prev) => ({\n ...prev,\n linkIcon: config?.linkIcon ?? copyIcon,\n editButton: config?.editButton ?? editIcon,\n removeButton: config?.removeButton ?? removeIcon,\n confirmButton: config?.confirmButton ?? confirmIcon,\n inputPlaceholder: config?.inputPlaceholder ?? 'Paste link...',\n onCopyLink: config?.onCopyLink ?? (() => {}),\n }))\n })\n .use(linkTooltipPlugin)\n}\n"],"names":["CrepeFeature"],"mappings":";;;AAQ2B,WAAA,CAAY,EAAC,EAAqB,aAAa;AAKlD,WAAA,CAAY,EAAC,EAAmB,UAAU;AA2B3D,SAAS,iBAAiB,GAAA,EAAU;AAEzC,EAAA,OAAO,GAAA,CAAI,IAAmC,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,IAAA,GAAA,EAAA,GAA4B,eAAA;AAAA,QAC9C,UAAA,EAAA,CAAY,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,UAAA,KAAR,IAAA,GAAA,EAAA,GAAuB,MAAM;AAAA,QAAC;AAAA,OAC5C;AAAA,IAAA,CAAE,CAAA;AAAA,EACJ,CAAC,CAAA,CACA,GAAA,CAAI,iBAAiB,CAAA;AAC1B;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/icons/bullet.ts","../../../../src/icons/check-box-checked.ts","../../../../src/icons/check-box-unchecked.ts","../../../../src/feature/index.ts","../../../../src/feature/list-item/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 bulletIcon = `\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_952_6527)\">\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n </g>\n <defs>\n <clipPath id=\"clip0_952_6527\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const checkBoxCheckedIcon = `\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_1803_1151)\">\n <path\n d=\"M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM10.71 16.29C10.32 16.68 9.69 16.68 9.3 16.29L5.71 12.7C5.32 12.31 5.32 11.68 5.71 11.29C6.1 10.9 6.73 10.9 7.12 11.29L10 14.17L16.88 7.29C17.27 6.9 17.9 6.9 18.29 7.29C18.68 7.68 18.68 8.31 18.29 8.7L10.71 16.29Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1803_1151\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const checkBoxUncheckedIcon = `\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_1803_535)\">\n <path\n d=\"M18 19H6C5.45 19 5 18.55 5 18V6C5 5.45 5.45 5 6 5H18C18.55 5 19 5.45 19 6V18C19 18.55 18.55 19 18 19ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1803_535\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\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 { Ctx } from '@milkdown/kit/ctx'\n\nimport {\n listItemBlockComponent,\n listItemBlockConfig,\n} from '@milkdown/kit/component/list-item-block'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig } from '../../core/slice'\nimport {\n bulletIcon,\n checkBoxCheckedIcon,\n checkBoxUncheckedIcon,\n} from '../../icons'\nimport { CrepeFeature } from '../index'\n\nexport interface ListItemConfig {\n bulletIcon: string\n checkBoxCheckedIcon: string\n checkBoxUncheckedIcon: string\n}\n\nexport type ListItemFeatureConfig = Partial<ListItemConfig>\n\nfunction configureListItem(ctx: Ctx, config?: ListItemFeatureConfig) {\n ctx.set(listItemBlockConfig.key, {\n renderLabel: ({ label, listType, checked }) => {\n if (checked == null) {\n if (listType === 'bullet') return config?.bulletIcon ?? bulletIcon\n\n return label\n }\n\n if (checked) return config?.checkBoxCheckedIcon ?? checkBoxCheckedIcon\n\n return config?.checkBoxUncheckedIcon ?? checkBoxUncheckedIcon\n },\n })\n}\n\nexport const listItem: DefineFeature<ListItemFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.ListItem))\n .config((ctx) => configureListItem(ctx, config))\n .use(listItemBlockComponent)\n}\n"],"names":["CrepeFeature"],"mappings":";;;AAQ2B,WAAA,CAAY,EAAC,EAAqB,aAAa;AAKlD,WAAA,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;AAET,MAAA,OAAO,CAAC,GAAG,QAAA,EAAU,OAAO,CAAA;AAAA,KAC7B,CAAA;AAAA,GACH;AACF;;ACvDO,MAAM,UAAA,GAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACAnB,MAAM,mBAAA,GAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACA5B,MAAM,qBAAA,GAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACc9B,IAAK,YAAA,qBAAAA,aAAAA,KAAL;AAEL,EAAAA,cAAA,YAAA,CAAA,GAAa,aAAA;AAGb,EAAAA,cAAA,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ACA,MAAA,KACG;AACH,EAAA,MAAA,CACG,MAAA,CAAO,kBAAA,CAAmB,YAAA,CAAa,QAAQ,CAAC,CAAA,CAChD,MAAA,CAAO,CAAC,GAAA,KAAQ,kBAAkB,GAAA,EAAK,MAAM,CAAC,CAAA,CAC9C,IAAI,sBAAsB,CAAA;AAC/B;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/icons/bullet.ts","../../../../src/icons/check-box-checked.ts","../../../../src/icons/check-box-unchecked.ts","../../../../src/feature/index.ts","../../../../src/feature/list-item/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 bulletIcon = `\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_952_6527)\">\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n </g>\n <defs>\n <clipPath id=\"clip0_952_6527\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const checkBoxCheckedIcon = `\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_1803_1151)\">\n <path\n d=\"M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM10.71 16.29C10.32 16.68 9.69 16.68 9.3 16.29L5.71 12.7C5.32 12.31 5.32 11.68 5.71 11.29C6.1 10.9 6.73 10.9 7.12 11.29L10 14.17L16.88 7.29C17.27 6.9 17.9 6.9 18.29 7.29C18.68 7.68 18.68 8.31 18.29 8.7L10.71 16.29Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1803_1151\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const checkBoxUncheckedIcon = `\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_1803_535)\">\n <path\n d=\"M18 19H6C5.45 19 5 18.55 5 18V6C5 5.45 5.45 5 6 5H18C18.55 5 19 5.45 19 6V18C19 18.55 18.55 19 18 19ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1803_535\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\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 { Ctx } from '@milkdown/kit/ctx'\n\nimport {\n listItemBlockComponent,\n listItemBlockConfig,\n} from '@milkdown/kit/component/list-item-block'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig } from '../../core/slice'\nimport {\n bulletIcon,\n checkBoxCheckedIcon,\n checkBoxUncheckedIcon,\n} from '../../icons'\nimport { CrepeFeature } from '../index'\n\nexport interface ListItemConfig {\n bulletIcon: string\n checkBoxCheckedIcon: string\n checkBoxUncheckedIcon: string\n}\n\nexport type ListItemFeatureConfig = Partial<ListItemConfig>\n\nfunction configureListItem(ctx: Ctx, config?: ListItemFeatureConfig) {\n ctx.set(listItemBlockConfig.key, {\n renderLabel: ({ label, listType, checked }) => {\n if (checked == null) {\n if (listType === 'bullet') return config?.bulletIcon ?? bulletIcon\n\n return label\n }\n\n if (checked) return config?.checkBoxCheckedIcon ?? checkBoxCheckedIcon\n\n return config?.checkBoxUncheckedIcon ?? checkBoxUncheckedIcon\n },\n })\n}\n\nexport const listItem: DefineFeature<ListItemFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.ListItem))\n .config((ctx) => configureListItem(ctx, config))\n .use(listItemBlockComponent)\n}\n"],"names":["CrepeFeature"],"mappings":";;;AAQ2B,WAAA,CAAY,EAAC,EAAqB,aAAa;AAKlD,WAAA,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,UAAA,GAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACAnB,MAAM,mBAAA,GAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACA5B,MAAM,qBAAA,GAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACc9B,IAAK,YAAA,qBAAAA,aAAAA,KAAL;AAEL,EAAAA,cAAA,YAAA,CAAA,GAAa,aAAA;AAGb,EAAAA,cAAA,UAAA,CAAA,GAAW,WAAA;AAGX,EAAAA,cAAA,aAAA,CAAA,GAAc,cAAA;AAGd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,YAAA,CAAa,QAAQ,CAAC,CAAA,CAChD,MAAA,CAAO,CAAC,GAAA,KAAQ,kBAAkB,GAAA,EAAK,MAAM,CAAC,CAAA,CAC9C,IAAI,sBAAsB,CAAA;AAC/B;;;;"}
@@ -1 +1 @@
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, useCrepe } 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 crepe = useCrepe(ctx)\n if (crepe.readonly) return null\n\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":["CrepeFeature","node"],"mappings":";;;;;;AAQ2B,WAAA,CAAY,EAAC,EAAqB,aAAa;AAKlD,WAAA,CAAY,EAAC,EAAmB,UAAU;AAa3D,SAAS,SAAS,GAAA,EAAU;AAEjC,EAAA,OAAO,GAAA,CAAI,IAA8B,UAAU,CAAA;AACrD;AAWO,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,CAAi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AQ,SAAS,GAAG,CAAA;AAC1B,QAAA,IAAI,KAAA,CAAM,UAAU,OAAO,IAAA;AAE3B,QAAA,MAAM,MAAA,GAAS,GAAA,CAAI,GAAA,CAAI,iBAAA,CAAkB,GAAG,CAAA;AAC5C,QAAA,IAAI,MAAA,CAAO,SAAS,KAAA,IAAS,CAAC,WAAW,KAAA,CAAM,GAAG,GAAG,OAAO,IAAA;AAE5D,QAAA,IAAI,cAAc,KAAA,CAAM,SAAS,CAAA,IAAK,QAAA,CAAS,MAAM,SAAS,CAAA;AAC5D,UAAA,OAAO,IAAA;AAET,QAAA,MAAM,eAAA,GAAA,CAAkB,EAAA,GAAA,MAAA,CAAO,IAAA,KAAP,IAAA,GAAA,EAAA,GAAe,iBAAA;AACvC,QAAA,MAAM,IAAA,GAAO,2BAAA,CAA4B,KAAA,EAAO,eAAe,CAAA;AAC/D,QAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAElB,QAAA,OAAO,cAAc,MAAA,CAAO,KAAA,CAAM,GAAA,EAAK,CAAC,IAAI,CAAC,CAAA;AAAA;AAC/C;AACF,GACD,CAAA;AACH,CAAC;AAEM,MAAM,WAAA,GAAuD,CAClE,MAAA,EACA,MAAA,KACG;AACH,EAAA,MAAA,CACG,MAAA,CAAO,mBAAmB,YAAA,CAAa,WAAW,CAAC,CAAA,CACnD,MAAA,CAAO,CAAC,GAAA,KAAQ;AACf,IAAA,IAAI,MAAA,EAAQ;AACV,MAAA,GAAA,CAAI,MAAA,CAAO,iBAAA,CAAkB,GAAA,EAAK,CAAC,IAAA,KAAS;AAC1C,QAAA,OAAO;AAAA,UACL,GAAG,IAAA;AAAA,UACH,GAAG;AAAA,SACL;AAAA,OACD,CAAA;AAAA;AACH,GACD,CAAA,CACA,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, useCrepe } 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 crepe = useCrepe(ctx)\n if (crepe.readonly) return null\n\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":["CrepeFeature","node"],"mappings":";;;;;;AAQ2B,WAAA,CAAY,EAAC,EAAqB,aAAa;AAKlD,WAAA,CAAY,EAAC,EAAmB,UAAU;AAa3D,SAAS,SAAS,GAAA,EAAU;AAEjC,EAAA,OAAO,GAAA,CAAI,IAA8B,UAAU,CAAA;AACrD;AAWO,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;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M,GAAG,GAAG,OAAO,IAAA;AAE5D,QAAA,IAAI,cAAc,KAAA,CAAM,SAAS,CAAA,IAAK,QAAA,CAAS,MAAM,SAAS,CAAA;AAC5D,UAAA,OAAO,IAAA;AAET,QAAA,MAAM,eAAA,GAAA,CAAkB,EAAA,GAAA,MAAA,CAAO,IAAA,KAAP,IAAA,GAAA,EAAA,GAAe,iBAAA;AACvC,QAAA,MAAM,IAAA,GAAO,2BAAA,CAA4B,KAAA,EAAO,eAAe,CAAA;AAC/D,QAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAElB,QAAA,OAAO,cAAc,MAAA,CAAO,KAAA,CAAM,GAAA,EAAK,CAAC,IAAI,CAAC,CAAA;AAAA,MAC/C;AAAA;AACF,GACD,CAAA;AACH,CAAC;AAEM,MAAM,WAAA,GAAuD,CAClE,MAAA,EACA,MAAA,KACG;AACH,EAAA,MAAA,CACG,MAAA,CAAO,mBAAmB,YAAA,CAAa,WAAW,CAAC,CAAA,CACnD,MAAA,CAAO,CAAC,GAAA,KAAQ;AACf,IAAA,IAAI,MAAA,EAAQ;AACV,MAAA,GAAA,CAAI,MAAA,CAAO,iBAAA,CAAkB,GAAA,EAAK,CAAC,IAAA,KAAS;AAC1C,QAAA,OAAO;AAAA,UACL,GAAG,IAAA;AAAA,UACH,GAAG;AAAA,SACL;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,EACF,CAAC,CAAA,CACA,GAAA,CAAI,iBAAiB,CAAA,CACrB,IAAI,iBAAiB,CAAA;AAC1B;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/icons/align-center.ts","../../../../src/icons/align-left.ts","../../../../src/icons/align-right.ts","../../../../src/icons/drag-handle.ts","../../../../src/icons/plus.ts","../../../../src/icons/remove.ts","../../../../src/feature/index.ts","../../../../src/feature/table/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 alignCenterIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <path\n d=\"M4.25 20.5C4.0375 20.5 3.85942 20.4281 3.71575 20.2843C3.57192 20.1404 3.5 19.9622 3.5 19.7498C3.5 19.5371 3.57192 19.359 3.71575 19.2155C3.85942 19.0718 4.0375 19 4.25 19H19.75C19.9625 19 20.1406 19.0719 20.2843 19.2158C20.4281 19.3596 20.5 19.5378 20.5 19.7502C20.5 19.9629 20.4281 20.141 20.2843 20.2845C20.1406 20.4282 19.9625 20.5 19.75 20.5H4.25ZM8.25 16.625C8.0375 16.625 7.85942 16.5531 7.71575 16.4093C7.57192 16.2654 7.5 16.0872 7.5 15.8748C7.5 15.6621 7.57192 15.484 7.71575 15.3405C7.85942 15.1968 8.0375 15.125 8.25 15.125H15.75C15.9625 15.125 16.1406 15.1969 16.2843 15.3408C16.4281 15.4846 16.5 15.6628 16.5 15.8753C16.5 16.0879 16.4281 16.266 16.2843 16.4095C16.1406 16.5532 15.9625 16.625 15.75 16.625H8.25ZM4.25 12.75C4.0375 12.75 3.85942 12.6781 3.71575 12.5343C3.57192 12.3904 3.5 12.2122 3.5 11.9998C3.5 11.7871 3.57192 11.609 3.71575 11.4655C3.85942 11.3218 4.0375 11.25 4.25 11.25H19.75C19.9625 11.25 20.1406 11.3219 20.2843 11.4658C20.4281 11.6096 20.5 11.7878 20.5 12.0003C20.5 12.2129 20.4281 12.391 20.2843 12.5345C20.1406 12.6782 19.9625 12.75 19.75 12.75H4.25ZM8.25 8.875C8.0375 8.875 7.85942 8.80308 7.71575 8.65925C7.57192 8.51542 7.5 8.33725 7.5 8.12475C7.5 7.91208 7.57192 7.734 7.71575 7.5905C7.85942 7.44683 8.0375 7.375 8.25 7.375H15.75C15.9625 7.375 16.1406 7.44692 16.2843 7.59075C16.4281 7.73458 16.5 7.91275 16.5 8.12525C16.5 8.33792 16.4281 8.516 16.2843 8.6595C16.1406 8.80317 15.9625 8.875 15.75 8.875H8.25ZM4.25 5C4.0375 5 3.85942 4.92808 3.71575 4.78425C3.57192 4.64042 3.5 4.46225 3.5 4.24975C3.5 4.03708 3.57192 3.859 3.71575 3.7155C3.85942 3.57183 4.0375 3.5 4.25 3.5H19.75C19.9625 3.5 20.1406 3.57192 20.2843 3.71575C20.4281 3.85958 20.5 4.03775 20.5 4.25025C20.5 4.46292 20.4281 4.641 20.2843 4.7845C20.1406 4.92817 19.9625 5 19.75 5H4.25Z\"\n />\n </svg>\n`\n","export const alignLeftIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <path\n d=\"M4.25 20.5C4.0375 20.5 3.85942 20.4281 3.71575 20.2843C3.57192 20.1404 3.5 19.9622 3.5 19.7498C3.5 19.5371 3.57192 19.359 3.71575 19.2155C3.85942 19.0718 4.0375 19 4.25 19H19.75C19.9625 19 20.1406 19.0719 20.2843 19.2158C20.4281 19.3596 20.5 19.5378 20.5 19.7502C20.5 19.9629 20.4281 20.141 20.2843 20.2845C20.1406 20.4282 19.9625 20.5 19.75 20.5H4.25ZM4.25 16.625C4.0375 16.625 3.85942 16.5531 3.71575 16.4093C3.57192 16.2654 3.5 16.0872 3.5 15.8748C3.5 15.6621 3.57192 15.484 3.71575 15.3405C3.85942 15.1968 4.0375 15.125 4.25 15.125H13.75C13.9625 15.125 14.1406 15.1969 14.2843 15.3408C14.4281 15.4846 14.5 15.6628 14.5 15.8753C14.5 16.0879 14.4281 16.266 14.2843 16.4095C14.1406 16.5532 13.9625 16.625 13.75 16.625H4.25ZM4.25 12.75C4.0375 12.75 3.85942 12.6781 3.71575 12.5343C3.57192 12.3904 3.5 12.2122 3.5 11.9998C3.5 11.7871 3.57192 11.609 3.71575 11.4655C3.85942 11.3218 4.0375 11.25 4.25 11.25H19.75C19.9625 11.25 20.1406 11.3219 20.2843 11.4658C20.4281 11.6096 20.5 11.7878 20.5 12.0003C20.5 12.2129 20.4281 12.391 20.2843 12.5345C20.1406 12.6782 19.9625 12.75 19.75 12.75H4.25ZM4.25 8.875C4.0375 8.875 3.85942 8.80308 3.71575 8.65925C3.57192 8.51542 3.5 8.33725 3.5 8.12475C3.5 7.91208 3.57192 7.734 3.71575 7.5905C3.85942 7.44683 4.0375 7.375 4.25 7.375H13.75C13.9625 7.375 14.1406 7.44692 14.2843 7.59075C14.4281 7.73458 14.5 7.91275 14.5 8.12525C14.5 8.33792 14.4281 8.516 14.2843 8.6595C14.1406 8.80317 13.9625 8.875 13.75 8.875H4.25ZM4.25 5C4.0375 5 3.85942 4.92808 3.71575 4.78425C3.57192 4.64042 3.5 4.46225 3.5 4.24975C3.5 4.03708 3.57192 3.859 3.71575 3.7155C3.85942 3.57183 4.0375 3.5 4.25 3.5H19.75C19.9625 3.5 20.1406 3.57192 20.2843 3.71575C20.4281 3.85958 20.5 4.03775 20.5 4.25025C20.5 4.46292 20.4281 4.641 20.2843 4.7845C20.1406 4.92817 19.9625 5 19.75 5H4.25Z\"\n />\n </svg>\n`\n","export const alignRightIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <path\n d=\"M4.25 5C4.0375 5 3.85942 4.92808 3.71575 4.78425C3.57192 4.64042 3.5 4.46225 3.5 4.24975C3.5 4.03708 3.57192 3.859 3.71575 3.7155C3.85942 3.57183 4.0375 3.5 4.25 3.5H19.75C19.9625 3.5 20.1406 3.57192 20.2843 3.71575C20.4281 3.85958 20.5 4.03775 20.5 4.25025C20.5 4.46292 20.4281 4.641 20.2843 4.7845C20.1406 4.92817 19.9625 5 19.75 5H4.25ZM10.25 8.875C10.0375 8.875 9.85942 8.80308 9.71575 8.65925C9.57192 8.51542 9.5 8.33725 9.5 8.12475C9.5 7.91208 9.57192 7.734 9.71575 7.5905C9.85942 7.44683 10.0375 7.375 10.25 7.375H19.75C19.9625 7.375 20.1406 7.44692 20.2843 7.59075C20.4281 7.73458 20.5 7.91275 20.5 8.12525C20.5 8.33792 20.4281 8.516 20.2843 8.6595C20.1406 8.80317 19.9625 8.875 19.75 8.875H10.25ZM4.25 12.75C4.0375 12.75 3.85942 12.6781 3.71575 12.5343C3.57192 12.3904 3.5 12.2122 3.5 11.9998C3.5 11.7871 3.57192 11.609 3.71575 11.4655C3.85942 11.3218 4.0375 11.25 4.25 11.25H19.75C19.9625 11.25 20.1406 11.3219 20.2843 11.4658C20.4281 11.6096 20.5 11.7878 20.5 12.0003C20.5 12.2129 20.4281 12.391 20.2843 12.5345C20.1406 12.6782 19.9625 12.75 19.75 12.75H4.25ZM10.25 16.625C10.0375 16.625 9.85942 16.5531 9.71575 16.4093C9.57192 16.2654 9.5 16.0872 9.5 15.8748C9.5 15.6621 9.57192 15.484 9.71575 15.3405C9.85942 15.1968 10.0375 15.125 10.25 15.125H19.75C19.9625 15.125 20.1406 15.1969 20.2843 15.3408C20.4281 15.4846 20.5 15.6628 20.5 15.8753C20.5 16.0879 20.4281 16.266 20.2843 16.4095C20.1406 16.5532 19.9625 16.625 19.75 16.625H10.25ZM4.25 20.5C4.0375 20.5 3.85942 20.4281 3.71575 20.2843C3.57192 20.1404 3.5 19.9622 3.5 19.7498C3.5 19.5371 3.57192 19.359 3.71575 19.2155C3.85942 19.0718 4.0375 19 4.25 19H19.75C19.9625 19 20.1406 19.0719 20.2843 19.2158C20.4281 19.3596 20.5 19.5378 20.5 19.7502C20.5 19.9629 20.4281 20.141 20.2843 20.2845C20.1406 20.4282 19.9625 20.5 19.75 20.5H4.25Z\"\n />\n </svg>\n`\n","export const dragHandleIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n >\n <path\n d=\"M3.5 9.83366C3.35833 9.83366 3.23961 9.78571 3.14383 9.68983C3.04794 9.59394 3 9.47516 3 9.33349C3 9.19171 3.04794 9.07299 3.14383 8.97733C3.23961 8.88155 3.35833 8.83366 3.5 8.83366H12.5C12.6417 8.83366 12.7604 8.8816 12.8562 8.97749C12.9521 9.07338 13 9.19216 13 9.33383C13 9.4756 12.9521 9.59433 12.8562 9.68999C12.7604 9.78577 12.6417 9.83366 12.5 9.83366H3.5ZM3.5 7.16699C3.35833 7.16699 3.23961 7.11905 3.14383 7.02316C3.04794 6.92727 3 6.80849 3 6.66683C3 6.52505 3.04794 6.40633 3.14383 6.31066C3.23961 6.21488 3.35833 6.16699 3.5 6.16699H12.5C12.6417 6.16699 12.7604 6.21494 12.8562 6.31083C12.9521 6.40671 13 6.52549 13 6.66716C13 6.80894 12.9521 6.92766 12.8562 7.02333C12.7604 7.1191 12.6417 7.16699 12.5 7.16699H3.5Z\"\n />\n </svg>\n`\n","export const plusIcon = `\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_971_7676)\">\n <path\n d=\"M18 13H13V18C13 18.55 12.55 19 12 19C11.45 19 11 18.55 11 18V13H6C5.45 13 5 12.55 5 12C5 11.45 5.45 11 6 11H11V6C11 5.45 11.45 5 12 5C12.55 5 13 5.45 13 6V11H18C18.55 11 19 11.45 19 12C19 12.55 18.55 13 18 13Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_971_7676\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const removeIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <path\n d=\"M7.30775 20.4997C6.81058 20.4997 6.385 20.3227 6.031 19.9687C5.677 19.6147 5.5 19.1892 5.5 18.692V5.99973H5.25C5.0375 5.99973 4.85942 5.92782 4.71575 5.78398C4.57192 5.64015 4.5 5.46198 4.5 5.24948C4.5 5.03682 4.57192 4.85873 4.71575 4.71523C4.85942 4.57157 5.0375 4.49973 5.25 4.49973H9C9 4.2549 9.08625 4.04624 9.25875 3.87374C9.43108 3.7014 9.63967 3.61523 9.8845 3.61523H14.1155C14.3603 3.61523 14.5689 3.7014 14.7413 3.87374C14.9138 4.04624 15 4.2549 15 4.49973H18.75C18.9625 4.49973 19.1406 4.57165 19.2843 4.71548C19.4281 4.85932 19.5 5.03748 19.5 5.24998C19.5 5.46265 19.4281 5.64073 19.2843 5.78423C19.1406 5.9279 18.9625 5.99973 18.75 5.99973H18.5V18.692C18.5 19.1892 18.323 19.6147 17.969 19.9687C17.615 20.3227 17.1894 20.4997 16.6923 20.4997H7.30775ZM17 5.99973H7V18.692C7 18.7818 7.02883 18.8556 7.0865 18.9132C7.14417 18.9709 7.21792 18.9997 7.30775 18.9997H16.6923C16.7821 18.9997 16.8558 18.9709 16.9135 18.9132C16.9712 18.8556 17 18.7818 17 18.692V5.99973ZM10.1543 16.9997C10.3668 16.9997 10.5448 16.9279 10.6885 16.7842C10.832 16.6404 10.9037 16.4622 10.9037 16.2497V8.74973C10.9037 8.53723 10.8318 8.35907 10.688 8.21523C10.5443 8.07157 10.3662 7.99973 10.1535 7.99973C9.941 7.99973 9.76292 8.07157 9.61925 8.21523C9.47575 8.35907 9.404 8.53723 9.404 8.74973V16.2497C9.404 16.4622 9.47583 16.6404 9.6195 16.7842C9.76333 16.9279 9.94158 16.9997 10.1543 16.9997ZM13.8465 16.9997C14.059 16.9997 14.2371 16.9279 14.3807 16.7842C14.5243 16.6404 14.596 16.4622 14.596 16.2497V8.74973C14.596 8.53723 14.5242 8.35907 14.3805 8.21523C14.2367 8.07157 14.0584 7.99973 13.8458 7.99973C13.6333 7.99973 13.4552 8.07157 13.3115 8.21523C13.168 8.35907 13.0962 8.53723 13.0962 8.74973V16.2497C13.0962 16.4622 13.1682 16.6404 13.312 16.7842C13.4557 16.9279 13.6338 16.9997 13.8465 16.9997Z\"\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 {\n tableBlock,\n tableBlockConfig,\n} from '@milkdown/kit/component/table-block'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig } from '../../core/slice'\nimport {\n alignCenterIcon,\n alignLeftIcon,\n alignRightIcon,\n dragHandleIcon,\n plusIcon,\n removeIcon,\n} from '../../icons'\nimport { CrepeFeature } from '../index'\n\ninterface TableConfig {\n addRowIcon: string\n addColIcon: string\n deleteRowIcon: string\n deleteColIcon: string\n alignLeftIcon: string\n alignCenterIcon: string\n alignRightIcon: string\n colDragHandleIcon: string\n rowDragHandleIcon: string\n}\n\nexport type TableFeatureConfig = Partial<TableConfig>\n\nexport const table: DefineFeature<TableFeatureConfig> = (editor, config) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.Table))\n .config((ctx) => {\n ctx.update(tableBlockConfig.key, (defaultConfig) => ({\n ...defaultConfig,\n renderButton: (renderType) => {\n switch (renderType) {\n case 'add_row':\n return config?.addRowIcon ?? plusIcon\n case 'add_col':\n return config?.addColIcon ?? plusIcon\n case 'delete_row':\n return config?.deleteRowIcon ?? removeIcon\n case 'delete_col':\n return config?.deleteColIcon ?? removeIcon\n case 'align_col_left':\n return config?.alignLeftIcon ?? alignLeftIcon\n case 'align_col_center':\n return config?.alignCenterIcon ?? alignCenterIcon\n case 'align_col_right':\n return config?.alignRightIcon ?? alignRightIcon\n case 'col_drag_handle':\n return config?.colDragHandleIcon ?? dragHandleIcon\n case 'row_drag_handle':\n return config?.rowDragHandleIcon ?? dragHandleIcon\n }\n },\n }))\n })\n .use(tableBlock)\n}\n"],"names":["CrepeFeature"],"mappings":";;;AAQ2B,WAAA,CAAY,EAAC,EAAqB,aAAa;AAKlD,WAAA,CAAY,EAAC,EAAmB,UAAU;AA2B3D,SAAS,iBAAiB,GAAA,EAAU;AAEzC,EAAA,OAAO,GAAA,CA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K,YAAA;AACH,YAAA,OAAA,CAAO,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,kBAAR,IAAA,GAAA,EAAA,GAAyB,UAAA;AAAA,UAClC,KAAK,gBAAA;AACH,YAAA,OAAA,CAAO,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,kBAAR,IAAA,GAAA,EAAA,GAAyB,aAAA;AAAA,UAClC,KAAK,kBAAA;AACH,YAAA,OAAA,CAAO,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,oBAAR,IAAA,GAAA,EAAA,GAA2B,eAAA;AAAA,UACpC,KAAK,iBAAA;AACH,YAAA,OAAA,CAAO,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,mBAAR,IAAA,GAAA,EAAA,GAA0B,cAAA;AAAA,UACnC,KAAK,iBAAA;AACH,YAAA,OAAA,CAAO,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,sBAAR,IAAA,GAAA,EAAA,GAA6B,cAAA;AAAA,UACtC,KAAK,iBAAA;AACH,YAAA,OAAA,CAAO,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,sBAAR,IAAA,GAAA,EAAA,GAA6B,cAAA;AAAA;AACxC;AACF,KACF,CAAE,CAAA;AAAA,GACH,CAAA,CACA,GAAA,CAAI,UAAU,CAAA;AACnB;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/icons/align-center.ts","../../../../src/icons/align-left.ts","../../../../src/icons/align-right.ts","../../../../src/icons/drag-handle.ts","../../../../src/icons/plus.ts","../../../../src/icons/remove.ts","../../../../src/feature/index.ts","../../../../src/feature/table/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 alignCenterIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <path\n d=\"M4.25 20.5C4.0375 20.5 3.85942 20.4281 3.71575 20.2843C3.57192 20.1404 3.5 19.9622 3.5 19.7498C3.5 19.5371 3.57192 19.359 3.71575 19.2155C3.85942 19.0718 4.0375 19 4.25 19H19.75C19.9625 19 20.1406 19.0719 20.2843 19.2158C20.4281 19.3596 20.5 19.5378 20.5 19.7502C20.5 19.9629 20.4281 20.141 20.2843 20.2845C20.1406 20.4282 19.9625 20.5 19.75 20.5H4.25ZM8.25 16.625C8.0375 16.625 7.85942 16.5531 7.71575 16.4093C7.57192 16.2654 7.5 16.0872 7.5 15.8748C7.5 15.6621 7.57192 15.484 7.71575 15.3405C7.85942 15.1968 8.0375 15.125 8.25 15.125H15.75C15.9625 15.125 16.1406 15.1969 16.2843 15.3408C16.4281 15.4846 16.5 15.6628 16.5 15.8753C16.5 16.0879 16.4281 16.266 16.2843 16.4095C16.1406 16.5532 15.9625 16.625 15.75 16.625H8.25ZM4.25 12.75C4.0375 12.75 3.85942 12.6781 3.71575 12.5343C3.57192 12.3904 3.5 12.2122 3.5 11.9998C3.5 11.7871 3.57192 11.609 3.71575 11.4655C3.85942 11.3218 4.0375 11.25 4.25 11.25H19.75C19.9625 11.25 20.1406 11.3219 20.2843 11.4658C20.4281 11.6096 20.5 11.7878 20.5 12.0003C20.5 12.2129 20.4281 12.391 20.2843 12.5345C20.1406 12.6782 19.9625 12.75 19.75 12.75H4.25ZM8.25 8.875C8.0375 8.875 7.85942 8.80308 7.71575 8.65925C7.57192 8.51542 7.5 8.33725 7.5 8.12475C7.5 7.91208 7.57192 7.734 7.71575 7.5905C7.85942 7.44683 8.0375 7.375 8.25 7.375H15.75C15.9625 7.375 16.1406 7.44692 16.2843 7.59075C16.4281 7.73458 16.5 7.91275 16.5 8.12525C16.5 8.33792 16.4281 8.516 16.2843 8.6595C16.1406 8.80317 15.9625 8.875 15.75 8.875H8.25ZM4.25 5C4.0375 5 3.85942 4.92808 3.71575 4.78425C3.57192 4.64042 3.5 4.46225 3.5 4.24975C3.5 4.03708 3.57192 3.859 3.71575 3.7155C3.85942 3.57183 4.0375 3.5 4.25 3.5H19.75C19.9625 3.5 20.1406 3.57192 20.2843 3.71575C20.4281 3.85958 20.5 4.03775 20.5 4.25025C20.5 4.46292 20.4281 4.641 20.2843 4.7845C20.1406 4.92817 19.9625 5 19.75 5H4.25Z\"\n />\n </svg>\n`\n","export const alignLeftIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <path\n d=\"M4.25 20.5C4.0375 20.5 3.85942 20.4281 3.71575 20.2843C3.57192 20.1404 3.5 19.9622 3.5 19.7498C3.5 19.5371 3.57192 19.359 3.71575 19.2155C3.85942 19.0718 4.0375 19 4.25 19H19.75C19.9625 19 20.1406 19.0719 20.2843 19.2158C20.4281 19.3596 20.5 19.5378 20.5 19.7502C20.5 19.9629 20.4281 20.141 20.2843 20.2845C20.1406 20.4282 19.9625 20.5 19.75 20.5H4.25ZM4.25 16.625C4.0375 16.625 3.85942 16.5531 3.71575 16.4093C3.57192 16.2654 3.5 16.0872 3.5 15.8748C3.5 15.6621 3.57192 15.484 3.71575 15.3405C3.85942 15.1968 4.0375 15.125 4.25 15.125H13.75C13.9625 15.125 14.1406 15.1969 14.2843 15.3408C14.4281 15.4846 14.5 15.6628 14.5 15.8753C14.5 16.0879 14.4281 16.266 14.2843 16.4095C14.1406 16.5532 13.9625 16.625 13.75 16.625H4.25ZM4.25 12.75C4.0375 12.75 3.85942 12.6781 3.71575 12.5343C3.57192 12.3904 3.5 12.2122 3.5 11.9998C3.5 11.7871 3.57192 11.609 3.71575 11.4655C3.85942 11.3218 4.0375 11.25 4.25 11.25H19.75C19.9625 11.25 20.1406 11.3219 20.2843 11.4658C20.4281 11.6096 20.5 11.7878 20.5 12.0003C20.5 12.2129 20.4281 12.391 20.2843 12.5345C20.1406 12.6782 19.9625 12.75 19.75 12.75H4.25ZM4.25 8.875C4.0375 8.875 3.85942 8.80308 3.71575 8.65925C3.57192 8.51542 3.5 8.33725 3.5 8.12475C3.5 7.91208 3.57192 7.734 3.71575 7.5905C3.85942 7.44683 4.0375 7.375 4.25 7.375H13.75C13.9625 7.375 14.1406 7.44692 14.2843 7.59075C14.4281 7.73458 14.5 7.91275 14.5 8.12525C14.5 8.33792 14.4281 8.516 14.2843 8.6595C14.1406 8.80317 13.9625 8.875 13.75 8.875H4.25ZM4.25 5C4.0375 5 3.85942 4.92808 3.71575 4.78425C3.57192 4.64042 3.5 4.46225 3.5 4.24975C3.5 4.03708 3.57192 3.859 3.71575 3.7155C3.85942 3.57183 4.0375 3.5 4.25 3.5H19.75C19.9625 3.5 20.1406 3.57192 20.2843 3.71575C20.4281 3.85958 20.5 4.03775 20.5 4.25025C20.5 4.46292 20.4281 4.641 20.2843 4.7845C20.1406 4.92817 19.9625 5 19.75 5H4.25Z\"\n />\n </svg>\n`\n","export const alignRightIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <path\n d=\"M4.25 5C4.0375 5 3.85942 4.92808 3.71575 4.78425C3.57192 4.64042 3.5 4.46225 3.5 4.24975C3.5 4.03708 3.57192 3.859 3.71575 3.7155C3.85942 3.57183 4.0375 3.5 4.25 3.5H19.75C19.9625 3.5 20.1406 3.57192 20.2843 3.71575C20.4281 3.85958 20.5 4.03775 20.5 4.25025C20.5 4.46292 20.4281 4.641 20.2843 4.7845C20.1406 4.92817 19.9625 5 19.75 5H4.25ZM10.25 8.875C10.0375 8.875 9.85942 8.80308 9.71575 8.65925C9.57192 8.51542 9.5 8.33725 9.5 8.12475C9.5 7.91208 9.57192 7.734 9.71575 7.5905C9.85942 7.44683 10.0375 7.375 10.25 7.375H19.75C19.9625 7.375 20.1406 7.44692 20.2843 7.59075C20.4281 7.73458 20.5 7.91275 20.5 8.12525C20.5 8.33792 20.4281 8.516 20.2843 8.6595C20.1406 8.80317 19.9625 8.875 19.75 8.875H10.25ZM4.25 12.75C4.0375 12.75 3.85942 12.6781 3.71575 12.5343C3.57192 12.3904 3.5 12.2122 3.5 11.9998C3.5 11.7871 3.57192 11.609 3.71575 11.4655C3.85942 11.3218 4.0375 11.25 4.25 11.25H19.75C19.9625 11.25 20.1406 11.3219 20.2843 11.4658C20.4281 11.6096 20.5 11.7878 20.5 12.0003C20.5 12.2129 20.4281 12.391 20.2843 12.5345C20.1406 12.6782 19.9625 12.75 19.75 12.75H4.25ZM10.25 16.625C10.0375 16.625 9.85942 16.5531 9.71575 16.4093C9.57192 16.2654 9.5 16.0872 9.5 15.8748C9.5 15.6621 9.57192 15.484 9.71575 15.3405C9.85942 15.1968 10.0375 15.125 10.25 15.125H19.75C19.9625 15.125 20.1406 15.1969 20.2843 15.3408C20.4281 15.4846 20.5 15.6628 20.5 15.8753C20.5 16.0879 20.4281 16.266 20.2843 16.4095C20.1406 16.5532 19.9625 16.625 19.75 16.625H10.25ZM4.25 20.5C4.0375 20.5 3.85942 20.4281 3.71575 20.2843C3.57192 20.1404 3.5 19.9622 3.5 19.7498C3.5 19.5371 3.57192 19.359 3.71575 19.2155C3.85942 19.0718 4.0375 19 4.25 19H19.75C19.9625 19 20.1406 19.0719 20.2843 19.2158C20.4281 19.3596 20.5 19.5378 20.5 19.7502C20.5 19.9629 20.4281 20.141 20.2843 20.2845C20.1406 20.4282 19.9625 20.5 19.75 20.5H4.25Z\"\n />\n </svg>\n`\n","export const dragHandleIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n >\n <path\n d=\"M3.5 9.83366C3.35833 9.83366 3.23961 9.78571 3.14383 9.68983C3.04794 9.59394 3 9.47516 3 9.33349C3 9.19171 3.04794 9.07299 3.14383 8.97733C3.23961 8.88155 3.35833 8.83366 3.5 8.83366H12.5C12.6417 8.83366 12.7604 8.8816 12.8562 8.97749C12.9521 9.07338 13 9.19216 13 9.33383C13 9.4756 12.9521 9.59433 12.8562 9.68999C12.7604 9.78577 12.6417 9.83366 12.5 9.83366H3.5ZM3.5 7.16699C3.35833 7.16699 3.23961 7.11905 3.14383 7.02316C3.04794 6.92727 3 6.80849 3 6.66683C3 6.52505 3.04794 6.40633 3.14383 6.31066C3.23961 6.21488 3.35833 6.16699 3.5 6.16699H12.5C12.6417 6.16699 12.7604 6.21494 12.8562 6.31083C12.9521 6.40671 13 6.52549 13 6.66716C13 6.80894 12.9521 6.92766 12.8562 7.02333C12.7604 7.1191 12.6417 7.16699 12.5 7.16699H3.5Z\"\n />\n </svg>\n`\n","export const plusIcon = `\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_971_7676)\">\n <path\n d=\"M18 13H13V18C13 18.55 12.55 19 12 19C11.45 19 11 18.55 11 18V13H6C5.45 13 5 12.55 5 12C5 11.45 5.45 11 6 11H11V6C11 5.45 11.45 5 12 5C12.55 5 13 5.45 13 6V11H18C18.55 11 19 11.45 19 12C19 12.55 18.55 13 18 13Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_971_7676\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const removeIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <path\n d=\"M7.30775 20.4997C6.81058 20.4997 6.385 20.3227 6.031 19.9687C5.677 19.6147 5.5 19.1892 5.5 18.692V5.99973H5.25C5.0375 5.99973 4.85942 5.92782 4.71575 5.78398C4.57192 5.64015 4.5 5.46198 4.5 5.24948C4.5 5.03682 4.57192 4.85873 4.71575 4.71523C4.85942 4.57157 5.0375 4.49973 5.25 4.49973H9C9 4.2549 9.08625 4.04624 9.25875 3.87374C9.43108 3.7014 9.63967 3.61523 9.8845 3.61523H14.1155C14.3603 3.61523 14.5689 3.7014 14.7413 3.87374C14.9138 4.04624 15 4.2549 15 4.49973H18.75C18.9625 4.49973 19.1406 4.57165 19.2843 4.71548C19.4281 4.85932 19.5 5.03748 19.5 5.24998C19.5 5.46265 19.4281 5.64073 19.2843 5.78423C19.1406 5.9279 18.9625 5.99973 18.75 5.99973H18.5V18.692C18.5 19.1892 18.323 19.6147 17.969 19.9687C17.615 20.3227 17.1894 20.4997 16.6923 20.4997H7.30775ZM17 5.99973H7V18.692C7 18.7818 7.02883 18.8556 7.0865 18.9132C7.14417 18.9709 7.21792 18.9997 7.30775 18.9997H16.6923C16.7821 18.9997 16.8558 18.9709 16.9135 18.9132C16.9712 18.8556 17 18.7818 17 18.692V5.99973ZM10.1543 16.9997C10.3668 16.9997 10.5448 16.9279 10.6885 16.7842C10.832 16.6404 10.9037 16.4622 10.9037 16.2497V8.74973C10.9037 8.53723 10.8318 8.35907 10.688 8.21523C10.5443 8.07157 10.3662 7.99973 10.1535 7.99973C9.941 7.99973 9.76292 8.07157 9.61925 8.21523C9.47575 8.35907 9.404 8.53723 9.404 8.74973V16.2497C9.404 16.4622 9.47583 16.6404 9.6195 16.7842C9.76333 16.9279 9.94158 16.9997 10.1543 16.9997ZM13.8465 16.9997C14.059 16.9997 14.2371 16.9279 14.3807 16.7842C14.5243 16.6404 14.596 16.4622 14.596 16.2497V8.74973C14.596 8.53723 14.5242 8.35907 14.3805 8.21523C14.2367 8.07157 14.0584 7.99973 13.8458 7.99973C13.6333 7.99973 13.4552 8.07157 13.3115 8.21523C13.168 8.35907 13.0962 8.53723 13.0962 8.74973V16.2497C13.0962 16.4622 13.1682 16.6404 13.312 16.7842C13.4557 16.9279 13.6338 16.9997 13.8465 16.9997Z\"\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 {\n tableBlock,\n tableBlockConfig,\n} from '@milkdown/kit/component/table-block'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig } from '../../core/slice'\nimport {\n alignCenterIcon,\n alignLeftIcon,\n alignRightIcon,\n dragHandleIcon,\n plusIcon,\n removeIcon,\n} from '../../icons'\nimport { CrepeFeature } from '../index'\n\ninterface TableConfig {\n addRowIcon: string\n addColIcon: string\n deleteRowIcon: string\n deleteColIcon: string\n alignLeftIcon: string\n alignCenterIcon: string\n alignRightIcon: string\n colDragHandleIcon: string\n rowDragHandleIcon: string\n}\n\nexport type TableFeatureConfig = Partial<TableConfig>\n\nexport const table: DefineFeature<TableFeatureConfig> = (editor, config) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.Table))\n .config((ctx) => {\n ctx.update(tableBlockConfig.key, (defaultConfig) => ({\n ...defaultConfig,\n renderButton: (renderType) => {\n switch (renderType) {\n case 'add_row':\n return config?.addRowIcon ?? plusIcon\n case 'add_col':\n return config?.addColIcon ?? plusIcon\n case 'delete_row':\n return config?.deleteRowIcon ?? removeIcon\n case 'delete_col':\n return config?.deleteColIcon ?? removeIcon\n case 'align_col_left':\n return config?.alignLeftIcon ?? alignLeftIcon\n case 'align_col_center':\n return config?.alignCenterIcon ?? alignCenterIcon\n case 'align_col_right':\n return config?.alignRightIcon ?? alignRightIcon\n case 'col_drag_handle':\n return config?.colDragHandleIcon ?? dragHandleIcon\n case 'row_drag_handle':\n return config?.rowDragHandleIcon ?? dragHandleIcon\n }\n },\n }))\n })\n .use(tableBlock)\n}\n"],"names":["CrepeFeature"],"mappings":";;;AAQ2B,WAAA,CAAY,EAAC,EAAqB,aAAa;AAKlD,WAAA,CAAY,EAAC,EAAmB,UAAU;AA2B3D,SAAS,iBAAiB,GAAA,EAAU;AAEzC,EAAA,OAAO,GAAA,CAAI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