@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,16 +1,36 @@
1
+ import { imageBlockConfig } from '@milkdown/kit/component/image-block';
1
2
  import { EditorStatus, editorViewCtx, Editor, rootCtx, defaultValueCtx, editorViewOptionsCtx } from '@milkdown/kit/core';
2
3
  import { clipboard } from '@milkdown/kit/plugin/clipboard';
3
4
  import { history } from '@milkdown/kit/plugin/history';
4
5
  import { indentConfig, indent } from '@milkdown/kit/plugin/indent';
5
6
  import { listenerCtx, listener } from '@milkdown/kit/plugin/listener';
6
7
  import { trailing } from '@milkdown/kit/plugin/trailing';
8
+ import { uploadConfig, upload } from '@milkdown/kit/plugin/upload';
7
9
  import { commonmark } from '@milkdown/kit/preset/commonmark';
8
10
  import { gfm } from '@milkdown/kit/preset/gfm';
9
11
  import { getMarkdown } from '@milkdown/kit/utils';
10
12
  import { createSlice } from '@milkdown/kit/ctx';
11
13
 
14
+ var CrepeFeature = /* @__PURE__ */ ((CrepeFeature2) => {
15
+ CrepeFeature2["CodeMirror"] = "code-mirror";
16
+ CrepeFeature2["ListItem"] = "list-item";
17
+ CrepeFeature2["LinkTooltip"] = "link-tooltip";
18
+ CrepeFeature2["Cursor"] = "cursor";
19
+ CrepeFeature2["ImageBlock"] = "image-block";
20
+ CrepeFeature2["BlockEdit"] = "block-edit";
21
+ CrepeFeature2["Toolbar"] = "toolbar";
22
+ CrepeFeature2["Placeholder"] = "placeholder";
23
+ CrepeFeature2["Table"] = "table";
24
+ CrepeFeature2["Latex"] = "latex";
25
+ CrepeFeature2["TopBar"] = "top-bar";
26
+ return CrepeFeature2;
27
+ })(CrepeFeature || {});
28
+
12
29
  const FeaturesCtx = createSlice([], "FeaturesCtx");
13
30
  const CrepeCtx = createSlice({}, "CrepeCtx");
31
+ function useCrepeFeatures(ctx) {
32
+ return ctx.use("FeaturesCtx");
33
+ }
14
34
 
15
35
  var __typeError = (msg) => {
16
36
  throw TypeError(msg);
@@ -90,7 +110,29 @@ class CrepeBuilder {
90
110
  ...value,
91
111
  size: 4
92
112
  }));
93
- }).use(commonmark).use(listener).use(history).use(indent).use(trailing).use(clipboard).use(gfm));
113
+ ctx.update(uploadConfig.key, (prev) => ({
114
+ ...prev,
115
+ uploader: async (files, schema, ctx2) => {
116
+ const features = useCrepeFeatures(ctx2).get();
117
+ const hasImageBlock = features.includes(CrepeFeature.ImageBlock);
118
+ const nodeType = hasImageBlock ? schema.nodes["image-block"] : schema.nodes["image"];
119
+ if (!nodeType) return [];
120
+ const onUpload = hasImageBlock ? ctx2.get(imageBlockConfig.key).onUpload : void 0;
121
+ const images = [];
122
+ for (let i = 0; i < files.length; i++) {
123
+ const file = files.item(i);
124
+ if (file && file.type.includes("image")) images.push(file);
125
+ }
126
+ const nodes = await Promise.all(
127
+ images.map(async (file) => {
128
+ const src = onUpload ? await onUpload(file) : URL.createObjectURL(file);
129
+ return nodeType.createAndFill({ src });
130
+ })
131
+ );
132
+ return nodes;
133
+ }
134
+ }));
135
+ }).use(commonmark).use(listener).use(history).use(indent).use(trailing).use(clipboard).use(upload).use(gfm));
94
136
  }
95
137
  /// Get the milkdown editor instance.
96
138
  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":["listener"],"mappings":";;;;;;;;;;;AAQO,MAAM,WAAA,GAAc,WAAA,CAAY,EAAC,EAAqB,aAA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../../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","listener","ctx"],"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,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;AAGR,EAAAA,cAAA,QAAA,CAAA,GAAS,SAAA;AAhCC,EAAA,OAAAA,aAAAA;AAAA,CAAA,EAAA,YAAA,IAAA,EAAA,CAAA;;ACP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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;;;;"}
@@ -38,6 +38,7 @@ var CrepeFeature = /* @__PURE__ */ ((CrepeFeature2) => {
38
38
  CrepeFeature2["Placeholder"] = "placeholder";
39
39
  CrepeFeature2["Table"] = "table";
40
40
  CrepeFeature2["Latex"] = "latex";
41
+ CrepeFeature2["TopBar"] = "top-bar";
41
42
  return CrepeFeature2;
42
43
  })(CrepeFeature || {});
43
44
 
@@ -453,6 +454,9 @@ class GroupBuilder {
453
454
  _groups = new WeakMap();
454
455
  _getGroupInstance = new WeakMap();
455
456
 
457
+ function keepAlive(..._args) {
458
+ }
459
+
456
460
  function getGroups(filter, config, ctx) {
457
461
  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;
458
462
  const flags = ctx && useCrepeFeatures(ctx).get();
@@ -720,7 +724,7 @@ function getGroups(filter, config, ctx) {
720
724
  commands.call(clearTextInCurrentBlockCommand.key);
721
725
  commands.call(addBlockTypeCommand.key, {
722
726
  nodeType: codeBlock,
723
- attrs: { language: "LaTex" }
727
+ attrs: { language: "LaTeX" }
724
728
  });
725
729
  }
726
730
  });
@@ -756,6 +760,7 @@ function getGroups(filter, config, ctx) {
756
760
  };
757
761
  }
758
762
 
763
+ keepAlive(h);
759
764
  const Menu = defineComponent({
760
765
  props: {
761
766
  ctx: {
@@ -810,7 +815,7 @@ const Menu = defineComponent({
810
815
  };
811
816
  const runByIndex = (index) => {
812
817
  const item = groupInfo.value.groups.flatMap((group) => group.items).at(index);
813
- if (item && ctx) item.onRun(ctx);
818
+ if ((item == null ? void 0 : item.onRun) && ctx) item.onRun(ctx);
814
819
  hide();
815
820
  };
816
821
  const onKeydown = (e) => {
@@ -1034,6 +1039,7 @@ function isSelectionAtEndOfNode(selection) {
1034
1039
  return offset === parent.content.size;
1035
1040
  }
1036
1041
 
1042
+ keepAlive(h, Fragment);
1037
1043
  const BlockHandle = defineComponent({
1038
1044
  props: {
1039
1045
  onAdd: {