@milkdown/crepe 7.11.1 → 7.12.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 (191) hide show
  1. package/lib/cjs/builder/builder.js +107 -0
  2. package/lib/cjs/builder/builder.js.map +1 -0
  3. package/lib/cjs/{index-CtTpZYVe.js → feature/block-edit/index.js} +165 -61
  4. package/lib/cjs/feature/block-edit/index.js.map +1 -0
  5. package/lib/cjs/feature/code-mirror/index.js +161 -0
  6. package/lib/cjs/feature/code-mirror/index.js.map +1 -0
  7. package/lib/cjs/feature/cursor/index.js +57 -0
  8. package/lib/cjs/feature/cursor/index.js.map +1 -0
  9. package/lib/cjs/feature/image-block/index.js +123 -0
  10. package/lib/cjs/feature/image-block/index.js.map +1 -0
  11. package/lib/cjs/{index-2icTTGim.js → feature/latex/index.js} +111 -24
  12. package/lib/cjs/feature/latex/index.js.map +1 -0
  13. package/lib/cjs/feature/link-tooltip/index.js +124 -0
  14. package/lib/cjs/feature/link-tooltip/index.js.map +1 -0
  15. package/lib/cjs/{index-Dw6lXgs6.js → feature/list-item/index.js} +39 -8
  16. package/lib/cjs/feature/list-item/index.js.map +1 -0
  17. package/lib/cjs/{index-B91KhPew.js → feature/placeholder/index.js} +46 -6
  18. package/lib/cjs/feature/placeholder/index.js.map +1 -0
  19. package/lib/cjs/{index-DEs_IHHy.js → feature/table/index.js} +78 -16
  20. package/lib/cjs/feature/table/index.js.map +1 -0
  21. package/lib/cjs/{index-k3lGvKiX.js → feature/toolbar/index.js} +133 -31
  22. package/lib/cjs/feature/toolbar/index.js.map +1 -0
  23. package/lib/cjs/index/index.js +2464 -0
  24. package/lib/cjs/index/index.js.map +1 -0
  25. package/lib/esm/builder/builder.js +105 -0
  26. package/lib/esm/builder/builder.js.map +1 -0
  27. package/lib/esm/{index-BEe1TpeS.js → feature/block-edit/index.js} +161 -57
  28. package/lib/esm/feature/block-edit/index.js.map +1 -0
  29. package/lib/esm/feature/code-mirror/index.js +159 -0
  30. package/lib/esm/feature/code-mirror/index.js.map +1 -0
  31. package/lib/esm/feature/cursor/index.js +55 -0
  32. package/lib/esm/feature/cursor/index.js.map +1 -0
  33. package/lib/esm/feature/image-block/index.js +121 -0
  34. package/lib/esm/feature/image-block/index.js.map +1 -0
  35. package/lib/esm/{index-ZGfGszIQ.js → feature/latex/index.js} +107 -20
  36. package/lib/esm/feature/latex/index.js.map +1 -0
  37. package/lib/esm/feature/link-tooltip/index.js +122 -0
  38. package/lib/esm/feature/link-tooltip/index.js.map +1 -0
  39. package/lib/esm/{index-E8UgFLeN.js → feature/list-item/index.js} +39 -8
  40. package/lib/esm/feature/list-item/index.js.map +1 -0
  41. package/lib/esm/{index-BCvtgOeI.js → feature/placeholder/index.js} +45 -5
  42. package/lib/esm/feature/placeholder/index.js.map +1 -0
  43. package/lib/esm/{index-CwMVnVeI.js → feature/table/index.js} +78 -16
  44. package/lib/esm/feature/table/index.js.map +1 -0
  45. package/lib/esm/{index-CTBg0aec.js → feature/toolbar/index.js} +128 -26
  46. package/lib/esm/feature/toolbar/index.js.map +1 -0
  47. package/lib/esm/index/index.js +2458 -0
  48. package/lib/esm/index/index.js.map +1 -0
  49. package/lib/tsconfig.tsbuildinfo +1 -1
  50. package/lib/types/builder.d.ts +2 -0
  51. package/lib/types/builder.d.ts.map +1 -0
  52. package/lib/types/core/builder.d.ts +23 -0
  53. package/lib/types/core/builder.d.ts.map +1 -0
  54. package/lib/types/core/crepe.d.ts +4 -15
  55. package/lib/types/core/crepe.d.ts.map +1 -1
  56. package/lib/types/core/index.d.ts +2 -1
  57. package/lib/types/core/index.d.ts.map +1 -1
  58. package/lib/types/core/slice.d.ts +6 -4
  59. package/lib/types/core/slice.d.ts.map +1 -1
  60. package/lib/types/default-config/index.d.ts +3 -0
  61. package/lib/types/default-config/index.d.ts.map +1 -0
  62. package/lib/types/feature/block-edit/handle/component.d.ts +2 -3
  63. package/lib/types/feature/block-edit/handle/component.d.ts.map +1 -1
  64. package/lib/types/feature/block-edit/index.d.ts +20 -20
  65. package/lib/types/feature/block-edit/index.d.ts.map +1 -1
  66. package/lib/types/feature/code-mirror/index.d.ts +7 -7
  67. package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
  68. package/lib/types/feature/cursor/index.d.ts +1 -1
  69. package/lib/types/feature/cursor/index.d.ts.map +1 -1
  70. package/lib/types/feature/image-block/index.d.ts +9 -9
  71. package/lib/types/feature/image-block/index.d.ts.map +1 -1
  72. package/lib/types/feature/index.d.ts +2 -4
  73. package/lib/types/feature/index.d.ts.map +1 -1
  74. package/lib/types/feature/latex/index.d.ts +3 -3
  75. package/lib/types/feature/latex/index.d.ts.map +1 -1
  76. package/lib/types/feature/link-tooltip/index.d.ts +6 -6
  77. package/lib/types/feature/link-tooltip/index.d.ts.map +1 -1
  78. package/lib/types/feature/list-item/index.d.ts +5 -5
  79. package/lib/types/feature/list-item/index.d.ts.map +1 -1
  80. package/lib/types/feature/loader.d.ts +4 -0
  81. package/lib/types/feature/loader.d.ts.map +1 -0
  82. package/lib/types/feature/placeholder/index.d.ts +2 -2
  83. package/lib/types/feature/placeholder/index.d.ts.map +1 -1
  84. package/lib/types/feature/shared.d.ts +1 -2
  85. package/lib/types/feature/shared.d.ts.map +1 -1
  86. package/lib/types/feature/table/index.d.ts +11 -11
  87. package/lib/types/feature/table/index.d.ts.map +1 -1
  88. package/lib/types/feature/toolbar/index.d.ts +8 -8
  89. package/lib/types/feature/toolbar/index.d.ts.map +1 -1
  90. package/lib/types/icons/index.d.ts +1 -0
  91. package/lib/types/icons/index.d.ts.map +1 -1
  92. package/lib/types/index.d.ts +1 -1
  93. package/lib/types/index.d.ts.map +1 -1
  94. package/lib/types/utils/index.d.ts +0 -1
  95. package/lib/types/utils/index.d.ts.map +1 -1
  96. package/package.json +60 -3
  97. package/src/builder.ts +1 -0
  98. package/src/core/builder.ts +143 -0
  99. package/src/core/crepe.ts +14 -130
  100. package/src/core/index.ts +2 -1
  101. package/src/core/slice.ts +37 -8
  102. package/src/default-config/index.ts +25 -0
  103. package/src/feature/block-edit/handle/component.tsx +6 -8
  104. package/src/feature/block-edit/handle/index.ts +2 -2
  105. package/src/feature/block-edit/index.ts +23 -20
  106. package/src/feature/block-edit/menu/config.ts +19 -19
  107. package/src/feature/code-mirror/index.ts +32 -28
  108. package/src/feature/cursor/index.ts +10 -6
  109. package/src/feature/image-block/index.ts +19 -16
  110. package/src/feature/index.ts +2 -53
  111. package/src/feature/latex/index.ts +8 -10
  112. package/src/feature/latex/inline-tooltip/component.tsx +1 -1
  113. package/src/feature/link-tooltip/index.ts +13 -10
  114. package/src/feature/list-item/index.ts +11 -8
  115. package/src/feature/loader.ts +52 -0
  116. package/src/feature/placeholder/index.ts +5 -2
  117. package/src/feature/shared.ts +1 -3
  118. package/src/feature/table/index.ts +23 -23
  119. package/src/feature/toolbar/component.tsx +9 -9
  120. package/src/feature/toolbar/index.ts +14 -11
  121. package/src/icons/index.ts +1 -0
  122. package/src/index.ts +1 -1
  123. package/src/utils/index.ts +0 -8
  124. package/lib/cjs/confirm-CNveM9QH.js +0 -26
  125. package/lib/cjs/confirm-CNveM9QH.js.map +0 -1
  126. package/lib/cjs/edit-BUtBJHpV.js +0 -24
  127. package/lib/cjs/edit-BUtBJHpV.js.map +0 -1
  128. package/lib/cjs/functions-BAY51plB.js +0 -39
  129. package/lib/cjs/functions-BAY51plB.js.map +0 -1
  130. package/lib/cjs/image-BXLkOVnO.js +0 -24
  131. package/lib/cjs/image-BXLkOVnO.js.map +0 -1
  132. package/lib/cjs/index-2icTTGim.js.map +0 -1
  133. package/lib/cjs/index-B91KhPew.js.map +0 -1
  134. package/lib/cjs/index-BsrJn8Jp.js +0 -41
  135. package/lib/cjs/index-BsrJn8Jp.js.map +0 -1
  136. package/lib/cjs/index-C2CAbC2F.js +0 -26
  137. package/lib/cjs/index-C2CAbC2F.js.map +0 -1
  138. package/lib/cjs/index-CtTpZYVe.js.map +0 -1
  139. package/lib/cjs/index-DEs_IHHy.js.map +0 -1
  140. package/lib/cjs/index-DLIudQKW.js +0 -126
  141. package/lib/cjs/index-DLIudQKW.js.map +0 -1
  142. package/lib/cjs/index-Dw6lXgs6.js.map +0 -1
  143. package/lib/cjs/index-k3lGvKiX.js.map +0 -1
  144. package/lib/cjs/index-urTgNBfI.js +0 -202
  145. package/lib/cjs/index-urTgNBfI.js.map +0 -1
  146. package/lib/cjs/index-xbwf60wt.js +0 -15
  147. package/lib/cjs/index-xbwf60wt.js.map +0 -1
  148. package/lib/cjs/index-xbxqAqH2.js +0 -52
  149. package/lib/cjs/index-xbxqAqH2.js.map +0 -1
  150. package/lib/cjs/index.js +0 -20
  151. package/lib/cjs/index.js.map +0 -1
  152. package/lib/cjs/inline-latex-D0G71cGk.js +0 -54
  153. package/lib/cjs/inline-latex-D0G71cGk.js.map +0 -1
  154. package/lib/cjs/plus-XLomtlXf.js +0 -24
  155. package/lib/cjs/plus-XLomtlXf.js.map +0 -1
  156. package/lib/cjs/remove-Ba-ypwBf.js +0 -17
  157. package/lib/cjs/remove-Ba-ypwBf.js.map +0 -1
  158. package/lib/esm/confirm-DtE-HkVd.js +0 -24
  159. package/lib/esm/confirm-DtE-HkVd.js.map +0 -1
  160. package/lib/esm/edit-D--t_JAb.js +0 -22
  161. package/lib/esm/edit-D--t_JAb.js.map +0 -1
  162. package/lib/esm/functions-DlJPkGmE.js +0 -36
  163. package/lib/esm/functions-DlJPkGmE.js.map +0 -1
  164. package/lib/esm/image-DoB1o1sl.js +0 -22
  165. package/lib/esm/image-DoB1o1sl.js.map +0 -1
  166. package/lib/esm/index-BCvtgOeI.js.map +0 -1
  167. package/lib/esm/index-BEe1TpeS.js.map +0 -1
  168. package/lib/esm/index-BPG8iO8t.js +0 -12
  169. package/lib/esm/index-BPG8iO8t.js.map +0 -1
  170. package/lib/esm/index-BUBXHhHG.js +0 -39
  171. package/lib/esm/index-BUBXHhHG.js.map +0 -1
  172. package/lib/esm/index-Bvz1Yyiz.js +0 -24
  173. package/lib/esm/index-Bvz1Yyiz.js.map +0 -1
  174. package/lib/esm/index-C1aVAv1l.js +0 -124
  175. package/lib/esm/index-C1aVAv1l.js.map +0 -1
  176. package/lib/esm/index-CTBg0aec.js.map +0 -1
  177. package/lib/esm/index-ChR5Qhyf.js +0 -50
  178. package/lib/esm/index-ChR5Qhyf.js.map +0 -1
  179. package/lib/esm/index-CshFzSt2.js +0 -197
  180. package/lib/esm/index-CshFzSt2.js.map +0 -1
  181. package/lib/esm/index-CwMVnVeI.js.map +0 -1
  182. package/lib/esm/index-E8UgFLeN.js.map +0 -1
  183. package/lib/esm/index-ZGfGszIQ.js.map +0 -1
  184. package/lib/esm/index.js +0 -12
  185. package/lib/esm/index.js.map +0 -1
  186. package/lib/esm/inline-latex-C9IGAXXQ.js +0 -51
  187. package/lib/esm/inline-latex-C9IGAXXQ.js.map +0 -1
  188. package/lib/esm/plus-lrX0Q75O.js +0 -22
  189. package/lib/esm/plus-lrX0Q75O.js.map +0 -1
  190. package/lib/esm/remove-D3g0Cd6_.js +0 -15
  191. package/lib/esm/remove-D3g0Cd6_.js.map +0 -1
@@ -1,202 +0,0 @@
1
- 'use strict';
2
-
3
- var core = require('@milkdown/kit/core');
4
- var clipboard = require('@milkdown/kit/plugin/clipboard');
5
- var history = require('@milkdown/kit/plugin/history');
6
- var indent = require('@milkdown/kit/plugin/indent');
7
- var listener = require('@milkdown/kit/plugin/listener');
8
- var trailing = require('@milkdown/kit/plugin/trailing');
9
- var commonmark = require('@milkdown/kit/preset/commonmark');
10
- var gfm = require('@milkdown/kit/preset/gfm');
11
- var utils = require('@milkdown/kit/utils');
12
- var ctx = require('@milkdown/kit/ctx');
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
- return CrepeFeature2;
26
- })(CrepeFeature || {});
27
- const defaultFeatures = {
28
- ["cursor" /* Cursor */]: true,
29
- ["list-item" /* ListItem */]: true,
30
- ["link-tooltip" /* LinkTooltip */]: true,
31
- ["image-block" /* ImageBlock */]: true,
32
- ["block-edit" /* BlockEdit */]: true,
33
- ["placeholder" /* Placeholder */]: true,
34
- ["toolbar" /* Toolbar */]: true,
35
- ["code-mirror" /* CodeMirror */]: true,
36
- ["table" /* Table */]: true,
37
- ["latex" /* Latex */]: true
38
- };
39
- async function loadFeature(feature, editor, config) {
40
- switch (feature) {
41
- case "code-mirror" /* CodeMirror */: {
42
- const { defineFeature } = await Promise.resolve().then(function () { return require('./index-DLIudQKW.js'); });
43
- return defineFeature(editor, config);
44
- }
45
- case "list-item" /* ListItem */: {
46
- const { defineFeature } = await Promise.resolve().then(function () { return require('./index-Dw6lXgs6.js'); });
47
- return defineFeature(editor, config);
48
- }
49
- case "link-tooltip" /* LinkTooltip */: {
50
- const { defineFeature } = await Promise.resolve().then(function () { return require('./index-BsrJn8Jp.js'); });
51
- return defineFeature(editor, config);
52
- }
53
- case "image-block" /* ImageBlock */: {
54
- const { defineFeature } = await Promise.resolve().then(function () { return require('./index-xbxqAqH2.js'); });
55
- return defineFeature(editor, config);
56
- }
57
- case "cursor" /* Cursor */: {
58
- const { defineFeature } = await Promise.resolve().then(function () { return require('./index-C2CAbC2F.js'); });
59
- return defineFeature(editor, config);
60
- }
61
- case "block-edit" /* BlockEdit */: {
62
- const { defineFeature } = await Promise.resolve().then(function () { return require('./index-CtTpZYVe.js'); });
63
- return defineFeature(editor, config);
64
- }
65
- case "placeholder" /* Placeholder */: {
66
- const { defineFeature } = await Promise.resolve().then(function () { return require('./index-B91KhPew.js'); });
67
- return defineFeature(editor, config);
68
- }
69
- case "toolbar" /* Toolbar */: {
70
- const { defineFeature } = await Promise.resolve().then(function () { return require('./index-k3lGvKiX.js'); });
71
- return defineFeature(editor, config);
72
- }
73
- case "table" /* Table */: {
74
- const { defineFeature } = await Promise.resolve().then(function () { return require('./index-DEs_IHHy.js'); });
75
- return defineFeature(editor, config);
76
- }
77
- case "latex" /* Latex */: {
78
- const { defineFeature } = await Promise.resolve().then(function () { return require('./index-2icTTGim.js'); });
79
- return defineFeature(editor, config);
80
- }
81
- }
82
- }
83
-
84
- const FeaturesCtx = ctx.createSlice([], "FeaturesCtx");
85
- const crepeCtx = ctx.createSlice({}, "CrepeCtx");
86
- function configureFeatures(features) {
87
- return (ctx) => {
88
- ctx.inject(FeaturesCtx, features);
89
- };
90
- }
91
-
92
- var __typeError = (msg) => {
93
- throw TypeError(msg);
94
- };
95
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
96
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
97
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
98
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
99
- var _editor, _initPromise, _rootElement, _editable;
100
- class Crepe {
101
- /// The constructor of the crepe editor.
102
- /// You can pass configs to the editor to configure the editor.
103
- /// Calling the constructor will not create the editor, you need to call `create` to create the editor.
104
- constructor({
105
- root,
106
- features = {},
107
- featureConfigs = {},
108
- defaultValue = ""
109
- }) {
110
- /// @internal
111
- __privateAdd(this, _editor);
112
- /// @internal
113
- __privateAdd(this, _initPromise);
114
- /// @internal
115
- __privateAdd(this, _rootElement);
116
- /// @internal
117
- __privateAdd(this, _editable, true);
118
- /// Create the editor.
119
- this.create = async () => {
120
- await __privateGet(this, _initPromise);
121
- return __privateGet(this, _editor).create();
122
- };
123
- /// Destroy the editor.
124
- this.destroy = async () => {
125
- await __privateGet(this, _initPromise);
126
- return __privateGet(this, _editor).destroy();
127
- };
128
- /// Set the readonly mode of the editor.
129
- this.setReadonly = (value) => {
130
- __privateSet(this, _editable, !value);
131
- __privateGet(this, _editor).action((ctx) => {
132
- if (__privateGet(this, _editor).status === core.EditorStatus.Created) {
133
- const view = ctx.get(core.editorViewCtx);
134
- view.setProps({
135
- editable: () => !value
136
- });
137
- }
138
- });
139
- return this;
140
- };
141
- /// Get the markdown content of the editor.
142
- this.getMarkdown = () => {
143
- return __privateGet(this, _editor).action(utils.getMarkdown());
144
- };
145
- /// Register event listeners.
146
- this.on = (fn) => {
147
- if (__privateGet(this, _editor).status !== core.EditorStatus.Created) {
148
- __privateGet(this, _editor).config((ctx) => {
149
- const listener2 = ctx.get(listener.listenerCtx);
150
- fn(listener2);
151
- });
152
- return this;
153
- }
154
- __privateGet(this, _editor).action((ctx) => {
155
- const listener2 = ctx.get(listener.listenerCtx);
156
- fn(listener2);
157
- });
158
- return this;
159
- };
160
- var _a;
161
- const enabledFeatures = Object.entries({
162
- ...defaultFeatures,
163
- ...features
164
- }).filter(([, enabled]) => enabled).map(([feature]) => feature);
165
- __privateSet(this, _rootElement, (_a = typeof root === "string" ? document.querySelector(root) : root) != null ? _a : document.body);
166
- __privateSet(this, _editor, core.Editor.make().config((ctx) => {
167
- ctx.inject(crepeCtx, this);
168
- }).config(configureFeatures(enabledFeatures)).config((ctx) => {
169
- ctx.set(core.rootCtx, __privateGet(this, _rootElement));
170
- ctx.set(core.defaultValueCtx, defaultValue);
171
- ctx.set(core.editorViewOptionsCtx, {
172
- editable: () => __privateGet(this, _editable)
173
- });
174
- ctx.update(indent.indentConfig.key, (value) => ({
175
- ...value,
176
- size: 4
177
- }));
178
- }).use(commonmark.commonmark).use(listener.listener).use(history.history).use(indent.indent).use(trailing.trailing).use(clipboard.clipboard).use(gfm.gfm));
179
- const promiseList = [];
180
- enabledFeatures.forEach((feature) => {
181
- const config = featureConfigs[feature];
182
- promiseList.push(loadFeature(feature, __privateGet(this, _editor), config));
183
- });
184
- __privateSet(this, _initPromise, Promise.all(promiseList));
185
- }
186
- /// Get the milkdown editor instance.
187
- get editor() {
188
- return __privateGet(this, _editor);
189
- }
190
- }
191
- _editor = new WeakMap();
192
- _initPromise = new WeakMap();
193
- _rootElement = new WeakMap();
194
- _editable = new WeakMap();
195
- /// This is an alias for the `CrepeFeature` enum.
196
- Crepe.Feature = CrepeFeature;
197
-
198
- exports.Crepe = Crepe;
199
- exports.CrepeFeature = CrepeFeature;
200
- exports.FeaturesCtx = FeaturesCtx;
201
- exports.crepeCtx = crepeCtx;
202
- //# sourceMappingURL=index-urTgNBfI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-urTgNBfI.js","sources":["../../src/feature/index.ts","../../src/core/slice.ts","../../src/core/crepe.ts"],"sourcesContent":["import type { Editor } from '@milkdown/kit/core'\n\nimport 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\nexport async function loadFeature(\n feature: CrepeFeature,\n editor: Editor,\n config?: never\n) {\n switch (feature) {\n case CrepeFeature.CodeMirror: {\n const { defineFeature } = await import('./code-mirror')\n return defineFeature(editor, config)\n }\n case CrepeFeature.ListItem: {\n const { defineFeature } = await import('./list-item')\n return defineFeature(editor, config)\n }\n case CrepeFeature.LinkTooltip: {\n const { defineFeature } = await import('./link-tooltip')\n return defineFeature(editor, config)\n }\n case CrepeFeature.ImageBlock: {\n const { defineFeature } = await import('./image-block')\n return defineFeature(editor, config)\n }\n case CrepeFeature.Cursor: {\n const { defineFeature } = await import('./cursor')\n return defineFeature(editor, config)\n }\n case CrepeFeature.BlockEdit: {\n const { defineFeature } = await import('./block-edit')\n return defineFeature(editor, config)\n }\n case CrepeFeature.Placeholder: {\n const { defineFeature } = await import('./placeholder')\n return defineFeature(editor, config)\n }\n case CrepeFeature.Toolbar: {\n const { defineFeature } = await import('./toolbar')\n return defineFeature(editor, config)\n }\n case CrepeFeature.Table: {\n const { defineFeature } = await import('./table')\n return defineFeature(editor, config)\n }\n case CrepeFeature.Latex: {\n const { defineFeature } = await import('./latex')\n return defineFeature(editor, config)\n }\n }\n}\n","import type { Ctx } from '@milkdown/kit/ctx'\n\nimport { createSlice } from '@milkdown/kit/ctx'\n\nimport type { CrepeFeature } from '../feature'\nimport type { Crepe } from './crepe'\n\nexport const FeaturesCtx = createSlice([] as CrepeFeature[], 'FeaturesCtx')\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 = ctx.get(crepeCtx)\n/// crepe.setReadonly(true)\n/// }\n/// }\n/// ```\nexport const crepeCtx = createSlice({} as Crepe, 'CrepeCtx')\n\nexport function configureFeatures(features: CrepeFeature[]) {\n return (ctx: Ctx) => {\n ctx.inject(FeaturesCtx, features)\n }\n}\n","import type { DefaultValue } from '@milkdown/kit/core'\nimport type { ListenerManager } from '@milkdown/kit/plugin/listener'\n\nimport {\n Editor,\n EditorStatus,\n defaultValueCtx,\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 { listener, listenerCtx } 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 { CrepeFeatureConfig } from '../feature'\n\nimport { CrepeFeature, defaultFeatures, loadFeature } from '../feature'\nimport { configureFeatures, crepeCtx } from './slice'\n\n/// The crepe editor configuration.\nexport interface CrepeConfig {\n /// Enable/disable specific features.\n features?: Partial<Record<CrepeFeature, boolean>>\n\n /// Configure individual features.\n featureConfigs?: CrepeFeatureConfig\n\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 editor class.\nexport class Crepe {\n /// This is an alias for the `CrepeFeature` enum.\n static Feature = CrepeFeature\n\n /// @internal\n readonly #editor: Editor\n\n /// @internal\n readonly #initPromise: Promise<unknown>\n\n /// @internal\n readonly #rootElement: Node\n\n /// @internal\n #editable = true\n\n /// The constructor of the crepe editor.\n /// You can pass configs to the editor to configure the editor.\n /// Calling the constructor will not create the editor, you need to call `create` to create the editor.\n constructor({\n root,\n features = {},\n featureConfigs = {},\n defaultValue = '',\n }: CrepeConfig) {\n const enabledFeatures = Object.entries({\n ...defaultFeatures,\n ...features,\n })\n .filter(([, enabled]) => enabled)\n .map(([feature]) => feature as CrepeFeature)\n\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 })\n .config(configureFeatures(enabledFeatures))\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 const promiseList: Promise<unknown>[] = []\n\n enabledFeatures.forEach((feature) => {\n const config = (featureConfigs as Partial<Record<CrepeFeature, never>>)[\n feature\n ]\n promiseList.push(loadFeature(feature, this.#editor, config))\n })\n\n this.#initPromise = Promise.all(promiseList)\n }\n\n /// Create the editor.\n create = async () => {\n await this.#initPromise\n return this.#editor.create()\n }\n\n /// Destroy the editor.\n destroy = async () => {\n await this.#initPromise\n return this.#editor.destroy()\n }\n\n /// Get the milkdown editor instance.\n get editor(): Editor {\n return this.#editor\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","commonmark","history","indent","trailing","clipboard","gfm"],"mappings":";;;;;;;;;;;;;AAgBY,IAAA,YAAA,qBAAAA,aAAL,KAAA;AAEL,EAAAA,cAAA,YAAa,CAAA,GAAA,aAAA;AAGb,EAAAA,cAAA,UAAW,CAAA,GAAA,WAAA;AAGX,EAAAA,cAAA,aAAc,CAAA,GAAA,cAAA;AAGd,EAAAA,cAAA,QAAS,CAAA,GAAA,QAAA;AAGT,EAAAA,cAAA,YAAa,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AAA;AACnC,MAAM,MAAA,MAAA,GAAU,eACd,OACF,CAAA;AACA,MAAA,WAAA,CAAY,KAAK,WAAY,CAAA,OAAA,EAAS,YAAK,CAAA,IAAA,EAAA,OAAA,CAAA,EAAS,MAAM,CAAC,CAAA;AAAA,KAC5D,CAAA;AAED,IAAK,YAAA,CAAA,IAAA,EAAA,YAAA,EAAe,OAAQ,CAAA,GAAA,CAAI,WAAW,CAAA,CAAA;AAAA;AAC7C;AAAA,EAeA,IAAI,MAAiB,GAAA;AACnB,IAAA,OAAO,YAAK,CAAA,IAAA,EAAA,OAAA,CAAA;AAAA;AAqChB;AArHW,OAAA,GAAA,IAAA,OAAA,EAAA;AAGA,YAAA,GAAA,IAAA,OAAA,EAAA;AAGA,YAAA,GAAA,IAAA,OAAA,EAAA;AAGT,SAAA,GAAA,IAAA,OAAA,EAAA;AAAA;AAdW,KAAA,CAEJ,OAAU,GAAA,YAAA;;;;;;;"}
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- function isInCodeBlock(selection) {
4
- const type = selection.$from.parent.type;
5
- return type.name === "code_block";
6
- }
7
- function isInList(selection) {
8
- var _a;
9
- const type = (_a = selection.$from.node(selection.$from.depth - 1)) == null ? void 0 : _a.type;
10
- return (type == null ? void 0 : type.name) === "list_item";
11
- }
12
-
13
- exports.isInCodeBlock = isInCodeBlock;
14
- exports.isInList = isInList;
15
- //# sourceMappingURL=index-xbwf60wt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-xbwf60wt.js","sources":["../../src/utils/index.ts"],"sourcesContent":["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\nexport function defIfNotExists(\n tagName: string,\n element: CustomElementConstructor\n) {\n if (customElements.get(tagName) == null)\n customElements.define(tagName, element)\n}\n"],"names":[],"mappings":";;AAEO,SAAS,cAAc,SAAsB,EAAA;AAClD,EAAM,MAAA,IAAA,GAAO,SAAU,CAAA,KAAA,CAAM,MAAO,CAAA,IAAA;AACpC,EAAA,OAAO,KAAK,IAAS,KAAA,YAAA;AACvB;AAEO,SAAS,SAAS,SAAsB,EAAA;AAP/C,EAAA,IAAA,EAAA;AAQE,EAAM,MAAA,IAAA,GAAA,CAAO,eAAU,KAAM,CAAA,IAAA,CAAK,UAAU,KAAM,CAAA,KAAA,GAAQ,CAAC,CAAA,KAA9C,IAAiD,GAAA,MAAA,GAAA,EAAA,CAAA,IAAA;AAC9D,EAAA,OAAA,CAAO,6BAAM,IAAS,MAAA,WAAA;AACxB;;;;;"}
@@ -1,52 +0,0 @@
1
- 'use strict';
2
-
3
- var imageBlock = require('@milkdown/kit/component/image-block');
4
- var imageInline = require('@milkdown/kit/component/image-inline');
5
- var confirm = require('./confirm-CNveM9QH.js');
6
- var image = require('./image-BXLkOVnO.js');
7
-
8
- const captionIcon = `
9
- <svg
10
- xmlns="http://www.w3.org/2000/svg"
11
- width="32"
12
- height="32"
13
- viewBox="0 0 24 24"
14
- >
15
- <path
16
- fill="currentColor"
17
- 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"
18
- />
19
- </svg>
20
- `;
21
-
22
- const defineFeature = (editor, config) => {
23
- editor.config((ctx) => {
24
- ctx.update(imageInline.inlineImageConfig.key, (value) => {
25
- var _a, _b, _c, _d, _e, _f;
26
- return {
27
- uploadButton: (_a = config == null ? void 0 : config.inlineUploadButton) != null ? _a : () => "Upload",
28
- imageIcon: (_b = config == null ? void 0 : config.inlineImageIcon) != null ? _b : () => image.imageIcon,
29
- confirmButton: (_c = config == null ? void 0 : config.inlineConfirmButton) != null ? _c : () => confirm.confirmIcon,
30
- uploadPlaceholderText: (_d = config == null ? void 0 : config.inlineUploadPlaceholderText) != null ? _d : "or paste link",
31
- onUpload: (_f = (_e = config == null ? void 0 : config.inlineOnUpload) != null ? _e : config == null ? void 0 : config.onUpload) != null ? _f : value.onUpload,
32
- proxyDomURL: config == null ? void 0 : config.proxyDomURL
33
- };
34
- });
35
- ctx.update(imageBlock.imageBlockConfig.key, (value) => {
36
- var _a, _b, _c, _d, _e, _f, _g, _h;
37
- return {
38
- uploadButton: (_a = config == null ? void 0 : config.blockUploadButton) != null ? _a : () => "Upload file",
39
- imageIcon: (_b = config == null ? void 0 : config.blockImageIcon) != null ? _b : () => image.imageIcon,
40
- captionIcon: (_c = config == null ? void 0 : config.blockCaptionIcon) != null ? _c : () => captionIcon,
41
- confirmButton: (_d = config == null ? void 0 : config.blockConfirmButton) != null ? _d : () => "Confirm",
42
- captionPlaceholderText: (_e = config == null ? void 0 : config.blockCaptionPlaceholderText) != null ? _e : "Write Image Caption",
43
- uploadPlaceholderText: (_f = config == null ? void 0 : config.blockUploadPlaceholderText) != null ? _f : "or paste link",
44
- onUpload: (_h = (_g = config == null ? void 0 : config.blockOnUpload) != null ? _g : config == null ? void 0 : config.onUpload) != null ? _h : value.onUpload,
45
- proxyDomURL: config == null ? void 0 : config.proxyDomURL
46
- };
47
- });
48
- }).use(imageBlock.imageBlockComponent).use(imageInline.imageInlineComponent);
49
- };
50
-
51
- exports.defineFeature = defineFeature;
52
- //# sourceMappingURL=index-xbxqAqH2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-xbxqAqH2.js","sources":["../../src/icons/caption.ts","../../src/feature/image-block/index.ts"],"sourcesContent":["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","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, Icon } from '../shared'\n\nimport { captionIcon, imageIcon, confirmIcon } from '../../icons'\n\ninterface ImageBlockConfig {\n onUpload: (file: File) => Promise<string>\n proxyDomURL: (url: string) => Promise<string> | string\n\n inlineImageIcon: Icon\n inlineConfirmButton: Icon\n inlineUploadButton: Icon\n inlineUploadPlaceholderText: string\n inlineOnUpload: (file: File) => Promise<string>\n\n blockImageIcon: Icon\n blockConfirmButton: Icon\n blockCaptionIcon: Icon\n blockUploadButton: Icon\n blockCaptionPlaceholderText: string\n blockUploadPlaceholderText: string\n blockOnUpload: (file: File) => Promise<string>\n}\n\nexport type ImageBlockFeatureConfig = Partial<ImageBlockConfig>\n\nexport const defineFeature: DefineFeature<ImageBlockFeatureConfig> = (\n editor,\n config\n) => {\n editor\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":["inlineImageConfig","imageIcon","confirmIcon","imageBlockConfig","imageBlockComponent","imageInlineComponent"],"mappings":";;;;;;;AAAO,MAAM,WAAc,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACkCd,MAAA,aAAA,GAAwD,CACnE,MAAA,EACA,MACG,KAAA;AACH,EACG,MAAA,CAAA,MAAA,CAAO,CAAC,GAAQ,KAAA;AACf,IAAA,GAAA,CAAI,MAAO,CAAAA,6BAAA,CAAkB,GAAK,EAAA,CAAC,KAAO,KAAA;AAxChD,MAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AAwCoD,MAAA,OAAA;AAAA,QAC5C,YAAc,EAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,kBAAR,KAAA,IAAA,GAAA,EAAA,GAA+B,MAAM,QAAA;AAAA,QACnD,SAAW,EAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,eAAR,KAAA,IAAA,GAAA,EAAA,GAA4B,MAAMC,eAAA;AAAA,QAC7C,aAAe,EAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,mBAAR,KAAA,IAAA,GAAA,EAAA,GAAgC,MAAMC,mBAAA;AAAA,QACrD,qBAAA,EAAA,CACE,EAAQ,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,2BAAA,KAAR,IAAuC,GAAA,EAAA,GAAA,eAAA;AAAA,QACzC,WAAU,EA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EAAQ,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,0BAAA,KAAR,IAAsC,GAAA,EAAA,GAAA,eAAA;AAAA,QACxC,WAAU,EAAQ,GAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,aAAA,KAAR,YAAyB,MAAQ,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,QAAA,KAAjC,YAA6C,KAAM,CAAA,QAAA;AAAA,QAC7D,aAAa,MAAQ,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA;AAAA,OACvB;AAAA,KAAE,CAAA;AAAA,GACH,CACA,CAAA,GAAA,CAAIG,8BAAmB,CAAA,CACvB,IAAIC,gCAAoB,CAAA;AAC7B;;;;"}
package/lib/cjs/index.js DELETED
@@ -1,20 +0,0 @@
1
- 'use strict';
2
-
3
- var index = require('./index-urTgNBfI.js');
4
- require('@milkdown/kit/core');
5
- require('@milkdown/kit/plugin/clipboard');
6
- require('@milkdown/kit/plugin/history');
7
- require('@milkdown/kit/plugin/indent');
8
- require('@milkdown/kit/plugin/listener');
9
- require('@milkdown/kit/plugin/trailing');
10
- require('@milkdown/kit/preset/commonmark');
11
- require('@milkdown/kit/preset/gfm');
12
- require('@milkdown/kit/utils');
13
- require('@milkdown/kit/ctx');
14
-
15
-
16
-
17
- exports.Crepe = index.Crepe;
18
- exports.CrepeFeature = index.CrepeFeature;
19
- exports.crepeCtx = index.crepeCtx;
20
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
@@ -1,54 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('@milkdown/kit/utils');
4
- var katex = require('katex');
5
-
6
- const mathInlineId = "math_inline";
7
- const mathInlineSchema = utils.$nodeSchema(mathInlineId, () => ({
8
- group: "inline",
9
- inline: true,
10
- draggable: true,
11
- atom: true,
12
- attrs: {
13
- value: {
14
- default: ""
15
- }
16
- },
17
- parseDOM: [
18
- {
19
- tag: `span[data-type="${mathInlineId}"]`,
20
- getAttrs: (dom) => {
21
- var _a;
22
- return {
23
- value: (_a = dom.dataset.value) != null ? _a : ""
24
- };
25
- }
26
- }
27
- ],
28
- toDOM: (node) => {
29
- const code = node.attrs.value;
30
- const dom = document.createElement("span");
31
- dom.dataset.type = mathInlineId;
32
- dom.dataset.value = code;
33
- katex.render(code, dom, {
34
- throwOnError: false
35
- });
36
- return dom;
37
- },
38
- parseMarkdown: {
39
- match: (node) => node.type === "inlineMath",
40
- runner: (state, node, type) => {
41
- state.addNode(type, { value: node.value });
42
- }
43
- },
44
- toMarkdown: {
45
- match: (node) => node.type.name === mathInlineId,
46
- runner: (state, node) => {
47
- state.addNode("inlineMath", void 0, node.attrs.value);
48
- }
49
- }
50
- }));
51
-
52
- exports.mathInlineId = mathInlineId;
53
- exports.mathInlineSchema = mathInlineSchema;
54
- //# sourceMappingURL=inline-latex-D0G71cGk.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inline-latex-D0G71cGk.js","sources":["../../src/feature/latex/inline-latex.ts"],"sourcesContent":["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"],"names":["$nodeSchema"],"mappings":";;;;;AAGO,MAAM,YAAe,GAAA;AAQf,MAAA,gBAAA,GAAmBA,iBAAY,CAAA,YAAA,EAAc,OAAO;AAAA,EAC/D,KAAO,EAAA,QAAA;AAAA,EACP,MAAQ,EAAA,IAAA;AAAA,EACR,SAAW,EAAA,IAAA;AAAA,EACX,IAAM,EAAA,IAAA;AAAA,EACN,KAAO,EAAA;AAAA,IACL,KAAO,EAAA;AAAA,MACL,OAAS,EAAA;AAAA;AACX,GACF;AAAA,EACA,QAAU,EAAA;AAAA,IACR;AAAA,MACE,GAAA,EAAK,mBAAmB,YAAY,CAAA,EAAA,CAAA;AAAA,MACpC,QAAA,EAAU,CAAC,GAAQ,KAAA;AAxBzB,QAAA,IAAA,EAAA;AAyBQ,QAAO,OAAA;AAAA,UACL,KAAQ,EAAA,CAAA,EAAA,GAAA,GAAA,CAAoB,OAAQ,CAAA,KAAA,KAA5B,IAAqC,GAAA,EAAA,GAAA;AAAA,SAC/C;AAAA;AACF;AACF,GACF;AAAA,EACA,KAAA,EAAO,CAAC,IAAS,KAAA;AACf,IAAM,MAAA,IAAA,GAAe,KAAK,KAAM,CAAA,KAAA;AAChC,IAAM,MAAA,GAAA,GAAM,QAAS,CAAA,aAAA,CAAc,MAAM,CAAA;AACzC,IAAA,GAAA,CAAI,QAAQ,IAAO,GAAA,YAAA;AACnB,IAAA,GAAA,CAAI,QAAQ,KAAQ,GAAA,IAAA;AACpB,IAAM,KAAA,CAAA,MAAA,CAAO,MAAM,GAAK,EAAA;AAAA,MACtB,YAAc,EAAA;AAAA,KACf,CAAA;AAED,IAAO,OAAA,GAAA;AAAA,GACT;AAAA,EACA,aAAe,EAAA;AAAA,IACb,KAAO,EAAA,CAAC,IAAS,KAAA,IAAA,CAAK,IAAS,KAAA,YAAA;AAAA,IAC/B,MAAQ,EAAA,CAAC,KAAO,EAAA,IAAA,EAAM,IAAS,KAAA;AAC7B,MAAA,KAAA,CAAM,QAAQ,IAAM,EAAA,EAAE,KAAO,EAAA,IAAA,CAAK,OAAiB,CAAA;AAAA;AACrD,GACF;AAAA,EACA,UAAY,EAAA;AAAA,IACV,KAAO,EAAA,CAAC,IAAS,KAAA,IAAA,CAAK,KAAK,IAAS,KAAA,YAAA;AAAA,IACpC,MAAA,EAAQ,CAAC,KAAA,EAAO,IAAS,KAAA;AACvB,MAAA,KAAA,CAAM,OAAQ,CAAA,YAAA,EAAc,MAAW,EAAA,IAAA,CAAK,MAAM,KAAK,CAAA;AAAA;AACzD;AAEJ,CAAE,CAAA;;;;;"}
@@ -1,24 +0,0 @@
1
- 'use strict';
2
-
3
- const plusIcon = `
4
- <svg
5
- xmlns="http://www.w3.org/2000/svg"
6
- width="24"
7
- height="24"
8
- viewBox="0 0 24 24"
9
- >
10
- <g clip-path="url(#clip0_971_7676)">
11
- <path
12
- 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"
13
- />
14
- </g>
15
- <defs>
16
- <clipPath id="clip0_971_7676">
17
- <rect width="24" height="24" />
18
- </clipPath>
19
- </defs>
20
- </svg>
21
- `;
22
-
23
- exports.plusIcon = plusIcon;
24
- //# sourceMappingURL=plus-XLomtlXf.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plus-XLomtlXf.js","sources":["../../src/icons/plus.ts"],"sourcesContent":["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"],"names":[],"mappings":";;AAAO,MAAM,QAAW,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;"}
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- const removeIcon = `
4
- <svg
5
- xmlns="http://www.w3.org/2000/svg"
6
- width="24"
7
- height="24"
8
- viewBox="0 0 24 24"
9
- >
10
- <path
11
- 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"
12
- />
13
- </svg>
14
- `;
15
-
16
- exports.removeIcon = removeIcon;
17
- //# sourceMappingURL=remove-Ba-ypwBf.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remove-Ba-ypwBf.js","sources":["../../src/icons/remove.ts"],"sourcesContent":["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"],"names":[],"mappings":";;AAAO,MAAM,UAAa,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;"}
@@ -1,24 +0,0 @@
1
- const confirmIcon = `
2
- <svg
3
- xmlns="http://www.w3.org/2000/svg"
4
- width="24"
5
- height="24"
6
- viewBox="0 0 24 24"
7
- fill="none"
8
- >
9
- <g clip-path="url(#clip0_1013_1606)">
10
- <path
11
- 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"
12
- fill="#817567"
13
- />
14
- </g>
15
- <defs>
16
- <clipPath id="clip0_1013_1606">
17
- <rect width="24" height="24" />
18
- </clipPath>
19
- </defs>
20
- </svg>
21
- `;
22
-
23
- export { confirmIcon as c };
24
- //# sourceMappingURL=confirm-DtE-HkVd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"confirm-DtE-HkVd.js","sources":["../../src/icons/confirm.ts"],"sourcesContent":["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"],"names":[],"mappings":"AAAO,MAAM,WAAc,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;"}
@@ -1,22 +0,0 @@
1
- const editIcon = `
2
- <svg
3
- xmlns="http://www.w3.org/2000/svg"
4
- width="24"
5
- height="24"
6
- viewBox="0 0 24 24"
7
- >
8
- <g clip-path="url(#clip0_1013_1585)">
9
- <path
10
- 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"
11
- />
12
- </g>
13
- <defs>
14
- <clipPath id="clip0_1013_1585">
15
- <rect width="24" height="24" />
16
- </clipPath>
17
- </defs>
18
- </svg>
19
- `;
20
-
21
- export { editIcon as e };
22
- //# sourceMappingURL=edit-D--t_JAb.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"edit-D--t_JAb.js","sources":["../../src/icons/edit.ts"],"sourcesContent":["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"],"names":[],"mappings":"AAAO,MAAM,QAAW,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;"}
@@ -1,36 +0,0 @@
1
- const codeIcon = `
2
- <svg
3
- xmlns="http://www.w3.org/2000/svg"
4
- width="24"
5
- height="24"
6
- viewBox="0 0 24 24"
7
- >
8
- <g clip-path="url(#clip0_977_8081)">
9
- <path
10
- d="M9.4 16.6L4.8 12L9.4 7.4L8 6L2 12L8 18L9.4 16.6ZM14.6 16.6L19.2 12L14.6 7.4L16 6L22 12L16 18L14.6 16.6Z"
11
- />
12
- </g>
13
- <defs>
14
- <clipPath id="clip0_977_8081">
15
- <rect width="24" height="24" />
16
- </clipPath>
17
- </defs>
18
- </svg>
19
- `;
20
-
21
- const functionsIcon = `
22
- <svg
23
- xmlns="http://www.w3.org/2000/svg"
24
- width="32"
25
- height="32"
26
- viewBox="0 0 24 24"
27
- >
28
- <path
29
- fill="currentColor"
30
- d="M7 19v-.808L13.096 12L7 5.808V5h10v1.25H9.102L14.727 12l-5.625 5.77H17V19z"
31
- />
32
- </svg>
33
- `;
34
-
35
- export { codeIcon as c, functionsIcon as f };
36
- //# sourceMappingURL=functions-DlJPkGmE.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"functions-DlJPkGmE.js","sources":["../../src/icons/code.ts","../../src/icons/functions.ts"],"sourcesContent":["export const codeIcon = `\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_8081)\">\n <path\n d=\"M9.4 16.6L4.8 12L9.4 7.4L8 6L2 12L8 18L9.4 16.6ZM14.6 16.6L19.2 12L14.6 7.4L16 6L22 12L16 18L14.6 16.6Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_977_8081\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const functionsIcon = `\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=\"M7 19v-.808L13.096 12L7 5.808V5h10v1.25H9.102L14.727 12l-5.625 5.77H17V19z\"\n />\n </svg>\n`\n"],"names":[],"mappings":"AAAO,MAAM,QAAW,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;ACAjB,MAAM,aAAgB,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;"}
@@ -1,22 +0,0 @@
1
- const imageIcon = `
2
- <svg
3
- xmlns="http://www.w3.org/2000/svg"
4
- width="24"
5
- height="24"
6
- viewBox="0 0 24 24"
7
- >
8
- <g clip-path="url(#clip0_977_8075)">
9
- <path
10
- 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"
11
- />
12
- </g>
13
- <defs>
14
- <clipPath id="clip0_977_8075">
15
- <rect width="24" height="24" />
16
- </clipPath>
17
- </defs>
18
- </svg>
19
- `;
20
-
21
- export { imageIcon as i };
22
- //# sourceMappingURL=image-DoB1o1sl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image-DoB1o1sl.js","sources":["../../src/icons/image.ts"],"sourcesContent":["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"],"names":[],"mappings":"AAAO,MAAM,SAAY,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-BCvtgOeI.js","sources":["../../src/feature/placeholder/index.ts"],"sourcesContent":["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 { isInCodeBlock, isInList } from '../../utils'\n\nfunction isDocEmpty(doc: Node) {\n return doc.childCount <= 1 && !doc.firstChild?.content.size\n}\n\nfunction createPlaceholderDecoration(\n state: EditorState,\n placeholderText: string\n): Decoration | null {\n const { selection } = state\n if (!selection.empty) return null\n\n const $pos = selection.$anchor\n const node = $pos.parent\n if (node.content.size > 0) return null\n\n const inTable = findParent((node) => node.type.name === 'table')($pos)\n if (inTable) return null\n\n const before = $pos.before()\n\n return Decoration.node(before, before + node.nodeSize, {\n class: 'crepe-placeholder',\n 'data-placeholder': placeholderText,\n })\n}\n\ninterface PlaceholderConfig {\n text: string\n mode: 'doc' | 'block'\n}\n\nexport type PlaceHolderFeatureConfig = Partial<PlaceholderConfig>\n\nexport const placeholderConfig = $ctx(\n {\n text: 'Please enter...',\n mode: 'block',\n } as PlaceholderConfig,\n 'placeholderConfigCtx'\n)\n\nexport const placeholderPlugin = $prose((ctx) => {\n return new Plugin({\n key: new PluginKey('CREPE_PLACEHOLDER'),\n props: {\n decorations: (state) => {\n const config = ctx.get(placeholderConfig.key)\n if (config.mode === 'doc' && !isDocEmpty(state.doc)) return null\n\n if (isInCodeBlock(state.selection) || isInList(state.selection))\n return null\n\n const placeholderText = config.text ?? 'Please enter...'\n const deco = createPlaceholderDecoration(state, placeholderText)\n if (!deco) return null\n\n return DecorationSet.create(state.doc, [deco])\n },\n },\n })\n})\n\nexport const defineFeature: DefineFeature<PlaceHolderFeatureConfig> = (\n editor,\n config\n) => {\n editor\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":["node"],"mappings":";;;;;;AAYA,SAAS,WAAW,GAAW,EAAA;AAZ/B,EAAA,IAAA,EAAA;AAaE,EAAA,OAAO,IAAI,UAAc,IAAA,CAAA,IAAK,GAAC,EAAI,GAAA,GAAA,CAAA,UAAA,KAAJ,mBAAgB,OAAQ,CAAA,IAAA,CAAA;AACzD;AAEA,SAAS,2BAAA,CACP,OACA,eACmB,EAAA;AACnB,EAAM,MAAA,EAAE,WAAc,GAAA,KAAA;AACtB,EAAI,IAAA,CAAC,SAAU,CAAA,KAAA,EAAc,OAAA,IAAA;AAE7B,EAAA,MAAM,OAAO,SAAU,CAAA,OAAA;AACvB,EAAA,MAAM,OAAO,IAAK,CAAA,MAAA;AAClB,EAAA,IAAI,IAAK,CAAA,OAAA,CAAQ,IAAO,GAAA,CAAA,EAAU,OAAA,IAAA;AAElC,EAAM,MAAA,OAAA,GAAU,WAAW,CAACA,KAAAA,KAASA,MAAK,IAAK,CAAA,IAAA,KAAS,OAAO,CAAA,CAAE,IAAI,CAAA;AACrE,EAAA,IAAI,SAAgB,OAAA,IAAA;AAEp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