@milkdown/crepe 7.19.1 → 7.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/lib/cjs/builder.js +43 -1
  2. package/lib/cjs/builder.js.map +1 -1
  3. package/lib/cjs/feature/block-edit/index.js +8 -2
  4. package/lib/cjs/feature/block-edit/index.js.map +1 -1
  5. package/lib/cjs/feature/code-mirror/index.js +1 -0
  6. package/lib/cjs/feature/code-mirror/index.js.map +1 -1
  7. package/lib/cjs/feature/cursor/index.js +1 -0
  8. package/lib/cjs/feature/cursor/index.js.map +1 -1
  9. package/lib/cjs/feature/image-block/index.js +4 -1
  10. package/lib/cjs/feature/image-block/index.js.map +1 -1
  11. package/lib/cjs/feature/latex/index.js +5 -0
  12. package/lib/cjs/feature/latex/index.js.map +1 -1
  13. package/lib/cjs/feature/link-tooltip/index.js +1 -0
  14. package/lib/cjs/feature/link-tooltip/index.js.map +1 -1
  15. package/lib/cjs/feature/list-item/index.js +1 -0
  16. package/lib/cjs/feature/list-item/index.js.map +1 -1
  17. package/lib/cjs/feature/placeholder/index.js +1 -0
  18. package/lib/cjs/feature/placeholder/index.js.map +1 -1
  19. package/lib/cjs/feature/table/index.js +1 -0
  20. package/lib/cjs/feature/table/index.js.map +1 -1
  21. package/lib/cjs/feature/toolbar/index.js +9 -2
  22. package/lib/cjs/feature/toolbar/index.js.map +1 -1
  23. package/lib/cjs/feature/top-bar/index.js +790 -0
  24. package/lib/cjs/feature/top-bar/index.js.map +1 -0
  25. package/lib/cjs/index.js +630 -142
  26. package/lib/cjs/index.js.map +1 -1
  27. package/lib/esm/builder.js +43 -1
  28. package/lib/esm/builder.js.map +1 -1
  29. package/lib/esm/feature/block-edit/index.js +8 -2
  30. package/lib/esm/feature/block-edit/index.js.map +1 -1
  31. package/lib/esm/feature/code-mirror/index.js +1 -0
  32. package/lib/esm/feature/code-mirror/index.js.map +1 -1
  33. package/lib/esm/feature/cursor/index.js +1 -0
  34. package/lib/esm/feature/cursor/index.js.map +1 -1
  35. package/lib/esm/feature/image-block/index.js +4 -1
  36. package/lib/esm/feature/image-block/index.js.map +1 -1
  37. package/lib/esm/feature/latex/index.js +5 -0
  38. package/lib/esm/feature/latex/index.js.map +1 -1
  39. package/lib/esm/feature/link-tooltip/index.js +1 -0
  40. package/lib/esm/feature/link-tooltip/index.js.map +1 -1
  41. package/lib/esm/feature/list-item/index.js +1 -0
  42. package/lib/esm/feature/list-item/index.js.map +1 -1
  43. package/lib/esm/feature/placeholder/index.js +1 -0
  44. package/lib/esm/feature/placeholder/index.js.map +1 -1
  45. package/lib/esm/feature/table/index.js +1 -0
  46. package/lib/esm/feature/table/index.js.map +1 -1
  47. package/lib/esm/feature/toolbar/index.js +9 -2
  48. package/lib/esm/feature/toolbar/index.js.map +1 -1
  49. package/lib/esm/feature/top-bar/index.js +788 -0
  50. package/lib/esm/feature/top-bar/index.js.map +1 -0
  51. package/lib/esm/index.js +631 -143
  52. package/lib/esm/index.js.map +1 -1
  53. package/lib/theme/common/style.css +1 -0
  54. package/lib/theme/common/top-bar.css +152 -0
  55. package/lib/tsconfig.tsbuildinfo +1 -1
  56. package/lib/types/core/builder.d.ts +2 -1
  57. package/lib/types/core/builder.d.ts.map +1 -1
  58. package/lib/types/feature/block-edit/handle/component.d.ts.map +1 -1
  59. package/lib/types/feature/block-edit/menu/component.d.ts.map +1 -1
  60. package/lib/types/feature/image-block/index.d.ts +2 -0
  61. package/lib/types/feature/image-block/index.d.ts.map +1 -1
  62. package/lib/types/feature/index.d.ts +4 -1
  63. package/lib/types/feature/index.d.ts.map +1 -1
  64. package/lib/types/feature/latex/inline-tooltip/component.d.ts.map +1 -1
  65. package/lib/types/feature/loader.d.ts.map +1 -1
  66. package/lib/types/feature/toolbar/component.d.ts.map +1 -1
  67. package/lib/types/feature/toolbar/config.d.ts +1 -1
  68. package/lib/types/feature/top-bar/component.d.ts +11 -0
  69. package/lib/types/feature/top-bar/component.d.ts.map +1 -0
  70. package/lib/types/feature/top-bar/config.d.ts +34 -0
  71. package/lib/types/feature/top-bar/config.d.ts.map +1 -0
  72. package/lib/types/feature/top-bar/index.d.ts +26 -0
  73. package/lib/types/feature/top-bar/index.d.ts.map +1 -0
  74. package/lib/types/icons/code-block.d.ts +2 -0
  75. package/lib/types/icons/code-block.d.ts.map +1 -0
  76. package/lib/types/icons/index.d.ts +1 -0
  77. package/lib/types/icons/index.d.ts.map +1 -1
  78. package/lib/types/utils/group-builder.d.ts +1 -1
  79. package/lib/types/utils/group-builder.d.ts.map +1 -1
  80. package/lib/types/utils/keep-alive.d.ts +2 -0
  81. package/lib/types/utils/keep-alive.d.ts.map +1 -0
  82. package/package.json +18 -13
  83. package/src/core/builder.ts +39 -2
  84. package/src/feature/block-edit/handle/component.tsx +3 -2
  85. package/src/feature/block-edit/menu/component.tsx +3 -2
  86. package/src/feature/block-edit/menu/config.ts +1 -1
  87. package/src/feature/image-block/index.ts +4 -0
  88. package/src/feature/index.ts +6 -0
  89. package/src/feature/latex/inline-tooltip/component.tsx +4 -2
  90. package/src/feature/loader.ts +4 -0
  91. package/src/feature/toolbar/component.tsx +7 -5
  92. package/src/feature/top-bar/component.tsx +198 -0
  93. package/src/feature/top-bar/config.ts +367 -0
  94. package/src/feature/top-bar/index.ts +113 -0
  95. package/src/icons/code-block.ts +12 -0
  96. package/src/icons/index.ts +1 -0
  97. package/src/theme/common/style.css +1 -0
  98. package/src/theme/common/top-bar.css +156 -0
  99. package/src/utils/group-builder.ts +1 -1
  100. package/src/utils/keep-alive.ts +3 -0
@@ -1,18 +1,38 @@
1
1
  'use strict';
2
2
 
3
+ var imageBlock = require('@milkdown/kit/component/image-block');
3
4
  var core = require('@milkdown/kit/core');
4
5
  var clipboard = require('@milkdown/kit/plugin/clipboard');
5
6
  var history = require('@milkdown/kit/plugin/history');
6
7
  var indent = require('@milkdown/kit/plugin/indent');
7
8
  var listener = require('@milkdown/kit/plugin/listener');
8
9
  var trailing = require('@milkdown/kit/plugin/trailing');
10
+ var upload = require('@milkdown/kit/plugin/upload');
9
11
  var commonmark = require('@milkdown/kit/preset/commonmark');
10
12
  var gfm = require('@milkdown/kit/preset/gfm');
11
13
  var utils = require('@milkdown/kit/utils');
12
14
  var ctx = require('@milkdown/kit/ctx');
13
15
 
16
+ var CrepeFeature = /* @__PURE__ */ ((CrepeFeature2) => {
17
+ CrepeFeature2["CodeMirror"] = "code-mirror";
18
+ CrepeFeature2["ListItem"] = "list-item";
19
+ CrepeFeature2["LinkTooltip"] = "link-tooltip";
20
+ CrepeFeature2["Cursor"] = "cursor";
21
+ CrepeFeature2["ImageBlock"] = "image-block";
22
+ CrepeFeature2["BlockEdit"] = "block-edit";
23
+ CrepeFeature2["Toolbar"] = "toolbar";
24
+ CrepeFeature2["Placeholder"] = "placeholder";
25
+ CrepeFeature2["Table"] = "table";
26
+ CrepeFeature2["Latex"] = "latex";
27
+ CrepeFeature2["TopBar"] = "top-bar";
28
+ return CrepeFeature2;
29
+ })(CrepeFeature || {});
30
+
14
31
  const FeaturesCtx = ctx.createSlice([], "FeaturesCtx");
15
32
  const CrepeCtx = ctx.createSlice({}, "CrepeCtx");
33
+ function useCrepeFeatures(ctx) {
34
+ return ctx.use("FeaturesCtx");
35
+ }
16
36
 
17
37
  var __typeError = (msg) => {
18
38
  throw TypeError(msg);
@@ -92,7 +112,29 @@ class CrepeBuilder {
92
112
  ...value,
93
113
  size: 4
94
114
  }));
95
- }).use(commonmark.commonmark).use(listener.listener).use(history.history).use(indent.indent).use(trailing.trailing).use(clipboard.clipboard).use(gfm.gfm));
115
+ ctx.update(upload.uploadConfig.key, (prev) => ({
116
+ ...prev,
117
+ uploader: async (files, schema, ctx2) => {
118
+ const features = useCrepeFeatures(ctx2).get();
119
+ const hasImageBlock = features.includes(CrepeFeature.ImageBlock);
120
+ const nodeType = hasImageBlock ? schema.nodes["image-block"] : schema.nodes["image"];
121
+ if (!nodeType) return [];
122
+ const onUpload = hasImageBlock ? ctx2.get(imageBlock.imageBlockConfig.key).onUpload : void 0;
123
+ const images = [];
124
+ for (let i = 0; i < files.length; i++) {
125
+ const file = files.item(i);
126
+ if (file && file.type.includes("image")) images.push(file);
127
+ }
128
+ const nodes = await Promise.all(
129
+ images.map(async (file) => {
130
+ const src = onUpload ? await onUpload(file) : URL.createObjectURL(file);
131
+ return nodeType.createAndFill({ src });
132
+ })
133
+ );
134
+ return nodes;
135
+ }
136
+ }));
137
+ }).use(commonmark.commonmark).use(listener.listener).use(history.history).use(indent.indent).use(trailing.trailing).use(clipboard.clipboard).use(upload.upload).use(gfm.gfm));
96
138
  }
97
139
  /// Get the milkdown editor instance.
98
140
  get editor() {
@@ -1 +1 @@
1
- {"version":3,"file":"builder.js","sources":["../../src/core/slice.ts","../../src/core/builder.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 {\n type DefaultValue,\n defaultValueCtx,\n Editor,\n EditorStatus,\n editorViewCtx,\n editorViewOptionsCtx,\n rootCtx,\n} from '@milkdown/kit/core'\nimport { clipboard } from '@milkdown/kit/plugin/clipboard'\nimport { history } from '@milkdown/kit/plugin/history'\nimport { indent, indentConfig } from '@milkdown/kit/plugin/indent'\nimport {\n listener,\n listenerCtx,\n type ListenerManager,\n} from '@milkdown/kit/plugin/listener'\nimport { trailing } from '@milkdown/kit/plugin/trailing'\nimport { commonmark } from '@milkdown/kit/preset/commonmark'\nimport { gfm } from '@milkdown/kit/preset/gfm'\nimport { getMarkdown } from '@milkdown/kit/utils'\n\nimport type { CrepeFeature, CrepeFeatureConfig } from '../feature'\nimport type { DefineFeature } from '../feature/shared'\n\nimport { CrepeCtx, FeaturesCtx } from './slice'\n\n/// The crepe builder configuration.\nexport interface CrepeBuilderConfig {\n /// The root element for the editor.\n /// Supports both DOM nodes and CSS selectors,\n /// If not provided, the editor will be appended to the body.\n root?: Node | string | null\n\n /// The default value for the editor.\n defaultValue?: DefaultValue\n}\n\n/// The crepe builder class.\n/// This class allows users to manually add features to the editor.\nexport class CrepeBuilder {\n /// @internal\n readonly #editor: Editor\n\n /// @internal\n readonly #rootElement: Node\n\n /// @internal\n #editable = true\n\n /// The constructor of the crepe builder.\n /// You can pass configs to the builder to configure the editor.\n constructor({ root, defaultValue = '' }: CrepeBuilderConfig = {}) {\n this.#rootElement =\n (typeof root === 'string' ? document.querySelector(root) : root) ??\n document.body\n this.#editor = Editor.make()\n .config((ctx) => {\n ctx.inject(CrepeCtx, this)\n ctx.inject(FeaturesCtx, [])\n })\n .config((ctx) => {\n ctx.set(rootCtx, this.#rootElement)\n ctx.set(defaultValueCtx, defaultValue)\n ctx.set(editorViewOptionsCtx, {\n editable: () => this.#editable,\n })\n ctx.update(indentConfig.key, (value) => ({\n ...value,\n size: 4,\n }))\n })\n .use(commonmark)\n .use(listener)\n .use(history)\n .use(indent)\n .use(trailing)\n .use(clipboard)\n .use(gfm)\n }\n\n /// Add a feature to the editor.\n addFeature: {\n <T extends CrepeFeature>(\n feature: DefineFeature<CrepeFeatureConfig[T]>,\n config?: CrepeFeatureConfig[T]\n ): CrepeBuilder\n <C>(feature: DefineFeature<C>, config?: C): CrepeBuilder\n } = (feature: DefineFeature, config?: never) => {\n feature(this.#editor, config)\n return this\n }\n\n /// Create the editor.\n create = () => {\n return this.#editor.create()\n }\n\n /// Destroy the editor.\n destroy = () => {\n return this.#editor.destroy()\n }\n\n /// Get the milkdown editor instance.\n get editor(): Editor {\n return this.#editor\n }\n\n /// Get the readonly state of the editor.\n get readonly() {\n return !this.#editable\n }\n\n /// Set the readonly mode of the editor.\n setReadonly = (value: boolean) => {\n this.#editable = !value\n this.#editor.action((ctx) => {\n if (this.#editor.status === EditorStatus.Created) {\n const view = ctx.get(editorViewCtx)\n view.setProps({\n editable: () => !value,\n })\n }\n })\n return this\n }\n\n /// Get the markdown content of the editor.\n getMarkdown = () => {\n return this.#editor.action(getMarkdown())\n }\n\n /// Register event listeners.\n on = (fn: (api: ListenerManager) => void) => {\n if (this.#editor.status !== EditorStatus.Created) {\n this.#editor.config((ctx) => {\n const listener = ctx.get(listenerCtx)\n fn(listener)\n })\n return this\n }\n this.#editor.action((ctx) => {\n const listener = ctx.get(listenerCtx)\n fn(listener)\n })\n return this\n }\n}\n"],"names":["createSlice","EditorStatus","editorViewCtx","getMarkdown","listener","listenerCtx","Editor","rootCtx","defaultValueCtx","editorVi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AA,EACf;AAoCF;AAzGW,OAAA,GAAA,IAAA,OAAA,EAAA;AAGA,YAAA,GAAA,IAAA,OAAA,EAAA;AAGT,SAAA,GAAA,IAAA,OAAA,EAAA;;;;"}
1
+ {"version":3,"file":"builder.js","sources":["../../src/feature/index.ts","../../src/core/slice.ts","../../src/core/builder.ts"],"sourcesContent":["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'\nimport type { TopBarFeatureConfig } from './top-bar'\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 /// Fixed top toolbar with heading selector, formatting buttons, insert actions, and block commands.\n TopBar = 'top-bar',\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 [CrepeFeature.TopBar]?: TopBarFeatureConfig\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 [CrepeFeature.TopBar]: false,\n}\n","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 { imageBlockConfig } from '@milkdown/kit/component/image-block'\nimport {\n type DefaultValue,\n defaultValueCtx,\n Editor,\n EditorStatus,\n editorViewCtx,\n editorViewOptionsCtx,\n rootCtx,\n} from '@milkdown/kit/core'\nimport { clipboard } from '@milkdown/kit/plugin/clipboard'\nimport { history } from '@milkdown/kit/plugin/history'\nimport { indent, indentConfig } from '@milkdown/kit/plugin/indent'\nimport {\n listener,\n listenerCtx,\n type ListenerManager,\n} from '@milkdown/kit/plugin/listener'\nimport { trailing } from '@milkdown/kit/plugin/trailing'\nimport { upload, uploadConfig } from '@milkdown/kit/plugin/upload'\nimport { commonmark } from '@milkdown/kit/preset/commonmark'\nimport { gfm } from '@milkdown/kit/preset/gfm'\nimport { getMarkdown } from '@milkdown/kit/utils'\n\nimport type { CrepeFeatureConfig } from '../feature'\nimport type { DefineFeature } from '../feature/shared'\n\nimport { CrepeFeature } from '../feature'\nimport { CrepeCtx, FeaturesCtx, useCrepeFeatures } from './slice'\n\n/// The crepe builder configuration.\nexport interface CrepeBuilderConfig {\n /// The root element for the editor.\n /// Supports both DOM nodes and CSS selectors,\n /// If not provided, the editor will be appended to the body.\n root?: Node | string | null\n\n /// The default value for the editor.\n defaultValue?: DefaultValue\n}\n\n/// The crepe builder class.\n/// This class allows users to manually add features to the editor.\nexport class CrepeBuilder {\n /// @internal\n readonly #editor: Editor\n\n /// @internal\n readonly #rootElement: Node\n\n /// @internal\n #editable = true\n\n /// The constructor of the crepe builder.\n /// You can pass configs to the builder to configure the editor.\n constructor({ root, defaultValue = '' }: CrepeBuilderConfig = {}) {\n this.#rootElement =\n (typeof root === 'string' ? document.querySelector(root) : root) ??\n document.body\n this.#editor = Editor.make()\n .config((ctx) => {\n ctx.inject(CrepeCtx, this)\n ctx.inject(FeaturesCtx, [])\n })\n .config((ctx) => {\n ctx.set(rootCtx, this.#rootElement)\n ctx.set(defaultValueCtx, defaultValue)\n ctx.set(editorViewOptionsCtx, {\n editable: () => this.#editable,\n })\n ctx.update(indentConfig.key, (value) => ({\n ...value,\n size: 4,\n }))\n ctx.update(uploadConfig.key, (prev) => ({\n ...prev,\n uploader: async (files, schema, ctx) => {\n const features = useCrepeFeatures(ctx).get()\n const hasImageBlock = features.includes(CrepeFeature.ImageBlock)\n const nodeType = hasImageBlock\n ? schema.nodes['image-block']\n : schema.nodes['image']\n\n if (!nodeType) return []\n\n const onUpload = hasImageBlock\n ? ctx.get(imageBlockConfig.key).onUpload\n : undefined\n\n const images: File[] = []\n for (let i = 0; i < files.length; i++) {\n const file = files.item(i)\n if (file && file.type.includes('image')) images.push(file)\n }\n\n const nodes = await Promise.all(\n images.map(async (file) => {\n const src = onUpload\n ? await onUpload(file)\n : URL.createObjectURL(file)\n return nodeType.createAndFill({ src })!\n })\n )\n\n return nodes\n },\n }))\n })\n .use(commonmark)\n .use(listener)\n .use(history)\n .use(indent)\n .use(trailing)\n .use(clipboard)\n .use(upload)\n .use(gfm)\n }\n\n /// Add a feature to the editor.\n addFeature: {\n <T extends CrepeFeature>(\n feature: DefineFeature<CrepeFeatureConfig[T]>,\n config?: CrepeFeatureConfig[T]\n ): CrepeBuilder\n <C>(feature: DefineFeature<C>, config?: C): CrepeBuilder\n } = (feature: DefineFeature, config?: never) => {\n feature(this.#editor, config)\n return this\n }\n\n /// Create the editor.\n create = () => {\n return this.#editor.create()\n }\n\n /// Destroy the editor.\n destroy = () => {\n return this.#editor.destroy()\n }\n\n /// Get the milkdown editor instance.\n get editor(): Editor {\n return this.#editor\n }\n\n /// Get the readonly state of the editor.\n get readonly() {\n return !this.#editable\n }\n\n /// Set the readonly mode of the editor.\n setReadonly = (value: boolean) => {\n this.#editable = !value\n this.#editor.action((ctx) => {\n if (this.#editor.status === EditorStatus.Created) {\n const view = ctx.get(editorViewCtx)\n view.setProps({\n editable: () => !value,\n })\n }\n })\n return this\n }\n\n /// Get the markdown content of the editor.\n getMarkdown = () => {\n return this.#editor.action(getMarkdown())\n }\n\n /// Register event listeners.\n on = (fn: (api: ListenerManager) => void) => {\n if (this.#editor.status !== EditorStatus.Created) {\n this.#editor.config((ctx) => {\n const listener = ctx.get(listenerCtx)\n fn(listener)\n })\n return this\n }\n this.#editor.action((ctx) => {\n const listener = ctx.get(listenerCtx)\n fn(listener)\n })\n return this\n }\n}\n"],"names":["CrepeFeature","createSlice","EditorStatus","editorViewCtx","getMarkdown","listener","listenerCtx","Editor","rootCtx","defaultValueCtx","editorViewOptionsCtx","indentConfig","uploadConfig","ctx","imageBlockConfig","commonmark","history","indent","trailing","clipboard","upload","gfm"],"mappings":";;;;;;;;;;;;;;;AAeO,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,YA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AAIV,iBAAQ,CAAA,CACZ,GAAA,CAAIW,eAAO,CAAA,CACX,GAAA,CAAIC,aAAM,CAAA,CACV,GAAA,CAAIC,iBAAQ,CAAA,CACZ,GAAA,CAAIC,mBAAS,EACb,GAAA,CAAIC,aAAM,CAAA,CACV,GAAA,CAAIC,OAAG,CAAA,CAAA;AAAA,EACZ;AAAA;AAAA,EAyBA,IAAI,MAAA,GAAiB;AACnB,IAAA,OAAO,YAAA,CAAA,IAAA,EAAK,OAAA,CAAA;AAAA,EACd;AAAA;AAAA,EAGA,IAAI,QAAA,GAAW;AACb,IAAA,OAAO,CAAC,YAAA,CAAA,IAAA,EAAK,SAAA,CAAA;AAAA,EACf;AAoCF;AA3IW,OAAA,GAAA,IAAA,OAAA,EAAA;AAGA,YAAA,GAAA,IAAA,OAAA,EAAA;AAGT,SAAA,GAAA,IAAA,OAAA,EAAA;;;;"}
@@ -40,6 +40,7 @@ var CrepeFeature = /* @__PURE__ */ ((CrepeFeature2) => {
40
40
  CrepeFeature2["Placeholder"] = "placeholder";
41
41
  CrepeFeature2["Table"] = "table";
42
42
  CrepeFeature2["Latex"] = "latex";
43
+ CrepeFeature2["TopBar"] = "top-bar";
43
44
  return CrepeFeature2;
44
45
  })(CrepeFeature || {});
45
46
 
@@ -455,6 +456,9 @@ class GroupBuilder {
455
456
  _groups = new WeakMap();
456
457
  _getGroupInstance = new WeakMap();
457
458
 
459
+ function keepAlive(..._args) {
460
+ }
461
+
458
462
  function getGroups(filter, config, ctx) {
459
463
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb;
460
464
  const flags = ctx && useCrepeFeatures(ctx).get();
@@ -722,7 +726,7 @@ function getGroups(filter, config, ctx) {
722
726
  commands.call(commonmark.clearTextInCurrentBlockCommand.key);
723
727
  commands.call(commonmark.addBlockTypeCommand.key, {
724
728
  nodeType: codeBlock,
725
- attrs: { language: "LaTex" }
729
+ attrs: { language: "LaTeX" }
726
730
  });
727
731
  }
728
732
  });
@@ -758,6 +762,7 @@ function getGroups(filter, config, ctx) {
758
762
  };
759
763
  }
760
764
 
765
+ keepAlive(vue.h);
761
766
  const Menu = vue.defineComponent({
762
767
  props: {
763
768
  ctx: {
@@ -812,7 +817,7 @@ const Menu = vue.defineComponent({
812
817
  };
813
818
  const runByIndex = (index) => {
814
819
  const item = groupInfo.value.groups.flatMap((group) => group.items).at(index);
815
- if (item && ctx) item.onRun(ctx);
820
+ if ((item == null ? void 0 : item.onRun) && ctx) item.onRun(ctx);
816
821
  hide();
817
822
  };
818
823
  const onKeydown = (e) => {
@@ -1036,6 +1041,7 @@ function isSelectionAtEndOfNode(selection) {
1036
1041
  return offset === parent.content.size;
1037
1042
  }
1038
1043
 
1044
+ keepAlive(vue.h, vue.Fragment);
1039
1045
  const BlockHandle = vue.defineComponent({
1040
1046
  props: {
1041
1047
  onAdd: {