@pixerate/editor 0.14.3 → 0.15.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.
- package/dist/agent/index.cjs +28 -220
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +1 -1
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +5 -154
- package/dist/agent/index.js.map +1 -1
- package/dist/canvas/index.cjs +113 -377
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +2 -2
- package/dist/canvas/index.d.ts +2 -2
- package/dist/canvas/index.js +18 -208
- package/dist/canvas/index.js.map +1 -1
- package/dist/chunk-33UVEDOS.cjs +233 -0
- package/dist/chunk-33UVEDOS.cjs.map +1 -0
- package/dist/chunk-7FWEWE6T.js +1888 -0
- package/dist/chunk-7FWEWE6T.js.map +1 -0
- package/dist/chunk-BYCOFZAA.js +514 -0
- package/dist/chunk-BYCOFZAA.js.map +1 -0
- package/dist/chunk-CYKQLDYH.cjs +1290 -0
- package/dist/chunk-CYKQLDYH.cjs.map +1 -0
- package/dist/chunk-GLSIZKOX.js +17 -0
- package/dist/chunk-GLSIZKOX.js.map +1 -0
- package/dist/chunk-GWHJVZPI.js +233 -0
- package/dist/chunk-GWHJVZPI.js.map +1 -0
- package/dist/chunk-LDES3EOS.cjs +1888 -0
- package/dist/chunk-LDES3EOS.cjs.map +1 -0
- package/dist/chunk-MPPXH7U5.cjs +336 -0
- package/dist/chunk-MPPXH7U5.cjs.map +1 -0
- package/dist/chunk-NNJRJJSC.js +1290 -0
- package/dist/chunk-NNJRJJSC.js.map +1 -0
- package/dist/chunk-O7LOPQMH.js +336 -0
- package/dist/chunk-O7LOPQMH.js.map +1 -0
- package/dist/chunk-SEDR75VH.cjs +17 -0
- package/dist/chunk-SEDR75VH.cjs.map +1 -0
- package/dist/chunk-SHWP2A43.cjs +514 -0
- package/dist/chunk-SHWP2A43.cjs.map +1 -0
- package/dist/chunk-VHZCXHS4.js +222 -0
- package/dist/chunk-VHZCXHS4.js.map +1 -0
- package/dist/chunk-WADCJ7A7.cjs +222 -0
- package/dist/chunk-WADCJ7A7.cjs.map +1 -0
- package/dist/extensions/index.cjs +25 -1920
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.js +22 -1868
- package/dist/extensions/index.js.map +1 -1
- package/dist/grammar/index.cjs +44 -387
- package/dist/grammar/index.cjs.map +1 -1
- package/dist/grammar/index.js +23 -321
- package/dist/grammar/index.js.map +1 -1
- package/dist/history/index.cjs +6 -257
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.js +4 -227
- package/dist/history/index.js.map +1 -1
- package/dist/image-editor/index.cjs +63 -106
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/index.cjs +324 -7232
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -4
- package/dist/index.d.ts +0 -4
- package/dist/index.js +258 -7007
- package/dist/index.js.map +1 -1
- package/dist/serializers/index.cjs +28 -558
- package/dist/serializers/index.cjs.map +1 -1
- package/dist/serializers/index.js +16 -496
- package/dist/serializers/index.js.map +1 -1
- package/dist/spreadsheet/index.cjs +21 -1319
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.js +14 -1274
- package/dist/spreadsheet/index.js.map +1 -1
- package/dist/{types-lGtRobRV.d.cts → types-DC8b2TsA.d.cts} +1 -1
- package/dist/{types-lGtRobRV.d.ts → types-DC8b2TsA.d.ts} +1 -1
- package/package.json +1 -1
|
@@ -1,1937 +1,42 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
29
2
|
|
|
30
|
-
// src/extensions/index.ts
|
|
31
|
-
var extensions_exports = {};
|
|
32
|
-
__export(extensions_exports, {
|
|
33
|
-
ColorHighlighter: () => ColorHighlighter,
|
|
34
|
-
FontSize: () => FontSize,
|
|
35
|
-
GradientText: () => GradientText,
|
|
36
|
-
Image: () => Image2,
|
|
37
|
-
LoadingNode: () => LoadingNode,
|
|
38
|
-
Markdown: () => Markdown2,
|
|
39
|
-
Mention: () => Mention,
|
|
40
|
-
SlashCommands: () => SlashCommands,
|
|
41
|
-
SmilieReplacer: () => SmilieReplacer,
|
|
42
|
-
TemplateSuggestions: () => TemplateSuggestions,
|
|
43
|
-
createMentionExtension: () => createMentionExtension,
|
|
44
|
-
createRichTextPreset: () => createRichTextPreset,
|
|
45
|
-
findHexColors: () => findHexColors,
|
|
46
|
-
handleImageInsertion: () => handleImageInsertion,
|
|
47
|
-
imagePastePluginKey: () => imagePastePluginKey,
|
|
48
|
-
insertImageNode: () => insertImageNode,
|
|
49
|
-
removeImageNode: () => removeImageNode,
|
|
50
|
-
updateImageSrc: () => updateImageSrc
|
|
51
|
-
});
|
|
52
|
-
module.exports = __toCommonJS(extensions_exports);
|
|
53
3
|
|
|
54
|
-
// src/extensions/gradient-text.ts
|
|
55
|
-
var import_core = require("@tiptap/core");
|
|
56
|
-
var import_state = require("@tiptap/pm/state");
|
|
57
|
-
var import_view = require("@tiptap/pm/view");
|
|
58
4
|
|
|
59
|
-
// src/grammar/tokens.ts
|
|
60
|
-
var TEMPLATE_REGEX = /{{\s*([^}]+?)\s*}}/g;
|
|
61
|
-
var VARIABLE_REGEX = /(?<!\{)\{([^{}]+)\}(?!\})/g;
|
|
62
|
-
var INSTRUCTION_REGEX = /__(.+?)__/g;
|
|
63
5
|
|
|
64
|
-
// src/extensions/gradient-text.ts
|
|
65
|
-
var createGradientDecorations = (doc, options) => {
|
|
66
|
-
const decorations = [];
|
|
67
|
-
const speed = options.speed ?? 1;
|
|
68
|
-
const jsonVarSet = options.jsonVariables ? options.jsonVariables instanceof Set ? options.jsonVariables : new Set(options.jsonVariables) : null;
|
|
69
|
-
doc.descendants((node, pos) => {
|
|
70
|
-
if (node.isText) {
|
|
71
|
-
const text = node.text || "";
|
|
72
|
-
let match;
|
|
73
|
-
const tmplRegex = new RegExp(TEMPLATE_REGEX.source, TEMPLATE_REGEX.flags);
|
|
74
|
-
while ((match = tmplRegex.exec(text)) !== null) {
|
|
75
|
-
const templateName = match[1].trim();
|
|
76
|
-
const colors = options.templateColorMap?.get(templateName);
|
|
77
|
-
if (colors) {
|
|
78
|
-
const start = pos + match.index;
|
|
79
|
-
const end = start + match[0].length;
|
|
80
|
-
const { from: colorFrom, to: colorTo } = colors;
|
|
81
|
-
const style = `--bg-size: ${speed * 300}%; --color-from: ${colorFrom}; --color-to: ${colorTo}; caret-color: #111 !important; background-image: linear-gradient(to right, ${colorFrom}, ${colorTo}, ${colorFrom}); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;`;
|
|
82
|
-
decorations.push(
|
|
83
|
-
import_view.Decoration.inline(start, end, {
|
|
84
|
-
class: "inline animate-gradient bg-gradient-to-r from-[var(--color-from)] via-[var(--color-to)] to-[var(--color-from)] bg-[length:var(--bg-size)_100%] bg-clip-text text-transparent border border-(--color-to)/20 px-1 py-0.5 rounded-sm cursor-pointer",
|
|
85
|
-
style,
|
|
86
|
-
"data-template": templateName
|
|
87
|
-
})
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
const instRegex = new RegExp(
|
|
92
|
-
INSTRUCTION_REGEX.source,
|
|
93
|
-
INSTRUCTION_REGEX.flags
|
|
94
|
-
);
|
|
95
|
-
while ((match = instRegex.exec(text)) !== null) {
|
|
96
|
-
const content = match[1].trim();
|
|
97
|
-
const colors = options.templateColorMap?.get(content) || {
|
|
98
|
-
from: "#ffaa40",
|
|
99
|
-
to: "#9c40ff"
|
|
100
|
-
};
|
|
101
|
-
const start = pos + match.index;
|
|
102
|
-
const end = start + match[0].length;
|
|
103
|
-
const { from: colorFrom, to: colorTo } = colors;
|
|
104
|
-
const style = `--bg-size: ${speed * 300}%; --color-from: ${colorFrom}; --color-to: ${colorTo}; caret-color: #111 !important; background-image: linear-gradient(to right, #fb7185, #8b5cf6, #fb7185); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;`;
|
|
105
|
-
decorations.push(
|
|
106
|
-
import_view.Decoration.inline(start, end, {
|
|
107
|
-
class: "italic animate-gradient bg-gradient-to-r from-rose-400 from-50% to-violet-500 to-50% bg-size-[200%_100%] bg-clip-text text-transparent inline-flex items-baseline gap-0.5",
|
|
108
|
-
style
|
|
109
|
-
})
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
const varRegex = new RegExp(
|
|
113
|
-
VARIABLE_REGEX.source,
|
|
114
|
-
VARIABLE_REGEX.flags
|
|
115
|
-
);
|
|
116
|
-
while ((match = varRegex.exec(text)) !== null) {
|
|
117
|
-
const variableName = match[1].trim();
|
|
118
|
-
const start = pos + match.index;
|
|
119
|
-
const end = start + match[0].length;
|
|
120
|
-
const isJsonVar = jsonVarSet?.has(variableName);
|
|
121
|
-
decorations.push(
|
|
122
|
-
import_view.Decoration.inline(start, end, {
|
|
123
|
-
class: isJsonVar ? "bg-violet-400/40 border-b-4 border-rose-300 dark:border-rose-800 inline-flex items-baseline px-1 py-0 text-foreground/80 gap-0.5 rounded-xs" : "bg-rose-400/40 border-b-4 border-violet-300 dark:border-violet-800 inline-flex items-baseline px-1 py-0 text-foreground/80 gap-0.5 rounded-xs",
|
|
124
|
-
"data-variable": variableName
|
|
125
|
-
})
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
return decorations;
|
|
131
|
-
};
|
|
132
|
-
var GradientText = import_core.Mark.create({
|
|
133
|
-
name: "gradientText",
|
|
134
|
-
addOptions() {
|
|
135
|
-
return {
|
|
136
|
-
templateColorMap: /* @__PURE__ */ new Map(),
|
|
137
|
-
speed: 1,
|
|
138
|
-
jsonVariables: void 0,
|
|
139
|
-
onTemplateClick: void 0
|
|
140
|
-
};
|
|
141
|
-
},
|
|
142
|
-
renderHTML({ HTMLAttributes }) {
|
|
143
|
-
const defaultColors = {
|
|
144
|
-
from: "#ffaa40",
|
|
145
|
-
to: "#9c40ff"
|
|
146
|
-
};
|
|
147
|
-
const speed = this.options.speed ?? 1;
|
|
148
|
-
const style = `--bg-size: ${speed * 300}%; --color-from: ${defaultColors.from}; --color-to: ${defaultColors.to}; caret-color: #111 !important;`;
|
|
149
|
-
return [
|
|
150
|
-
"span",
|
|
151
|
-
{
|
|
152
|
-
class: "inline animate-gradient bg-gradient-to-r from-[var(--color-from)] via-[var(--color-to)] to-[var(--color-from)] bg-[length:var(--bg-size)_100%] bg-clip-text text-transparent",
|
|
153
|
-
style,
|
|
154
|
-
...HTMLAttributes
|
|
155
|
-
},
|
|
156
|
-
0
|
|
157
|
-
];
|
|
158
|
-
},
|
|
159
|
-
parseHTML() {
|
|
160
|
-
return [
|
|
161
|
-
{
|
|
162
|
-
tag: "span",
|
|
163
|
-
getAttrs: (node) => node.classList.contains("animate-gradient") && node.classList.contains("bg-clip-text") && null
|
|
164
|
-
}
|
|
165
|
-
];
|
|
166
|
-
},
|
|
167
|
-
addProseMirrorPlugins() {
|
|
168
|
-
const markOptions = this.options;
|
|
169
|
-
return [
|
|
170
|
-
new import_state.Plugin({
|
|
171
|
-
state: {
|
|
172
|
-
init(_, { doc }) {
|
|
173
|
-
return import_view.DecorationSet.create(
|
|
174
|
-
doc,
|
|
175
|
-
createGradientDecorations(doc, markOptions)
|
|
176
|
-
);
|
|
177
|
-
},
|
|
178
|
-
apply(tr, value) {
|
|
179
|
-
const newDoc = tr.doc;
|
|
180
|
-
if (tr.docChanged) {
|
|
181
|
-
return import_view.DecorationSet.create(
|
|
182
|
-
newDoc,
|
|
183
|
-
createGradientDecorations(newDoc, markOptions)
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
return value.map(tr.mapping, newDoc);
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
props: {
|
|
190
|
-
decorations(state) {
|
|
191
|
-
return this.getState(state);
|
|
192
|
-
},
|
|
193
|
-
handleClickOn(view, pos, _node, _nodePos, event) {
|
|
194
|
-
const decorationSet = this.getState(
|
|
195
|
-
view.state
|
|
196
|
-
);
|
|
197
|
-
const decorations = decorationSet.find(pos, pos + 1);
|
|
198
|
-
for (const decoration of decorations) {
|
|
199
|
-
const decorationWithAttrs = decoration;
|
|
200
|
-
const templateName = decorationWithAttrs.type?.attrs?.["data-template"];
|
|
201
|
-
if (templateName) {
|
|
202
|
-
if (markOptions.onTemplateClick) {
|
|
203
|
-
markOptions.onTemplateClick(templateName, event);
|
|
204
|
-
}
|
|
205
|
-
if (typeof window !== "undefined") {
|
|
206
|
-
window.dispatchEvent(
|
|
207
|
-
new CustomEvent("show-gradient-popover", {
|
|
208
|
-
detail: {
|
|
209
|
-
templateName,
|
|
210
|
-
target: event.target
|
|
211
|
-
}
|
|
212
|
-
})
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
return true;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
})
|
|
222
|
-
];
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
6
|
|
|
226
|
-
// src/extensions/slash-commands.ts
|
|
227
|
-
var import_core2 = require("@tiptap/core");
|
|
228
|
-
var import_state2 = require("@tiptap/pm/state");
|
|
229
|
-
var SlashCommands = import_core2.Extension.create({
|
|
230
|
-
name: "slashCommands",
|
|
231
|
-
addOptions() {
|
|
232
|
-
return {
|
|
233
|
-
trigger: "/",
|
|
234
|
-
onMatch: void 0,
|
|
235
|
-
onClear: void 0,
|
|
236
|
-
containerId: void 0
|
|
237
|
-
};
|
|
238
|
-
},
|
|
239
|
-
addProseMirrorPlugins() {
|
|
240
|
-
const opts = this.options;
|
|
241
|
-
return [
|
|
242
|
-
new import_state2.Plugin({
|
|
243
|
-
view() {
|
|
244
|
-
return {
|
|
245
|
-
update(view) {
|
|
246
|
-
const { state } = view;
|
|
247
|
-
const { selection } = state;
|
|
248
|
-
const { $from } = selection;
|
|
249
|
-
if (!$from.parent.isTextblock) {
|
|
250
|
-
opts.onClear?.();
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
const textBeforeCursor = $from.parent.textBetween(
|
|
254
|
-
0,
|
|
255
|
-
$from.parentOffset
|
|
256
|
-
);
|
|
257
|
-
const slashMatch = textBeforeCursor.match(
|
|
258
|
-
/(?:^|\s)\/([a-zA-Z0-9_-]*)$/
|
|
259
|
-
);
|
|
260
|
-
if (slashMatch) {
|
|
261
|
-
const matchIndex = slashMatch.index ?? 0;
|
|
262
|
-
const offsetInParent = matchIndex + (slashMatch[0].startsWith(" ") ? 1 : 0);
|
|
263
|
-
const matchFrom = $from.start() + offsetInParent;
|
|
264
|
-
const matchTo = $from.pos;
|
|
265
|
-
const coords = view.coordsAtPos($from.pos);
|
|
266
|
-
let relativeCoords = {
|
|
267
|
-
top: coords.top,
|
|
268
|
-
left: coords.left,
|
|
269
|
-
bottom: coords.bottom,
|
|
270
|
-
right: coords.right
|
|
271
|
-
};
|
|
272
|
-
if (opts.containerId && typeof document !== "undefined") {
|
|
273
|
-
const container = document.getElementById(opts.containerId);
|
|
274
|
-
if (container) {
|
|
275
|
-
const rect = container.getBoundingClientRect();
|
|
276
|
-
relativeCoords = {
|
|
277
|
-
top: coords.bottom - rect.top + 5,
|
|
278
|
-
left: coords.left - rect.left,
|
|
279
|
-
bottom: coords.bottom - rect.top,
|
|
280
|
-
right: coords.right - rect.left
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
opts.onMatch?.({
|
|
285
|
-
match: slashMatch,
|
|
286
|
-
query: slashMatch[1] || "",
|
|
287
|
-
from: matchFrom,
|
|
288
|
-
to: matchTo,
|
|
289
|
-
coords: relativeCoords
|
|
290
|
-
});
|
|
291
|
-
} else {
|
|
292
|
-
opts.onClear?.();
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
})
|
|
298
|
-
];
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
7
|
|
|
302
|
-
// src/extensions/template-suggestions.ts
|
|
303
|
-
var import_core3 = require("@tiptap/core");
|
|
304
|
-
var import_suggestion = __toESM(require("@tiptap/suggestion"), 1);
|
|
305
|
-
var TemplateSuggestions = import_core3.Extension.create({
|
|
306
|
-
name: "templateSuggestions",
|
|
307
|
-
addOptions() {
|
|
308
|
-
return {
|
|
309
|
-
templates: [],
|
|
310
|
-
char: "{{",
|
|
311
|
-
onSuggestion: void 0
|
|
312
|
-
};
|
|
313
|
-
},
|
|
314
|
-
addProseMirrorPlugins() {
|
|
315
|
-
const opts = this.options;
|
|
316
|
-
const suggestionConfig = {
|
|
317
|
-
char: opts.char || "{{",
|
|
318
|
-
items: ({ query }) => {
|
|
319
|
-
const lower = query.toLowerCase();
|
|
320
|
-
return (opts.templates || []).filter(
|
|
321
|
-
(t) => t.name.toLowerCase().includes(lower)
|
|
322
|
-
);
|
|
323
|
-
},
|
|
324
|
-
command: ({ editor, range, props }) => {
|
|
325
|
-
editor.chain().focus().deleteRange(range).insertContent(`{{${props.name}}}`).run();
|
|
326
|
-
},
|
|
327
|
-
render: () => {
|
|
328
|
-
return {
|
|
329
|
-
onStart: (props) => {
|
|
330
|
-
opts.onSuggestion?.(props);
|
|
331
|
-
},
|
|
332
|
-
onUpdate: (props) => {
|
|
333
|
-
opts.onSuggestion?.(props);
|
|
334
|
-
},
|
|
335
|
-
onExit: () => {
|
|
336
|
-
opts.onSuggestion?.({
|
|
337
|
-
query: "",
|
|
338
|
-
range: { from: 0, to: 0 },
|
|
339
|
-
items: [],
|
|
340
|
-
command: () => {
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
const SuggestionFn = typeof import_suggestion.default === "function" ? import_suggestion.default : import_suggestion.default?.default || import_suggestion.default?.Suggestion;
|
|
348
|
-
return [
|
|
349
|
-
SuggestionFn({
|
|
350
|
-
editor: this.editor,
|
|
351
|
-
...suggestionConfig
|
|
352
|
-
})
|
|
353
|
-
];
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
8
|
|
|
357
|
-
// src/extensions/loading-node.ts
|
|
358
|
-
var import_core4 = require("@tiptap/core");
|
|
359
|
-
var LoadingNode = import_core4.Node.create({
|
|
360
|
-
name: "loadingNode",
|
|
361
|
-
group: "inline",
|
|
362
|
-
inline: true,
|
|
363
|
-
selectable: true,
|
|
364
|
-
atom: true,
|
|
365
|
-
addAttributes() {
|
|
366
|
-
return {
|
|
367
|
-
id: {
|
|
368
|
-
default: null,
|
|
369
|
-
parseHTML: (element) => element.getAttribute("data-id"),
|
|
370
|
-
renderHTML: (attributes) => {
|
|
371
|
-
if (!attributes.id) return {};
|
|
372
|
-
return { "data-id": attributes.id };
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
},
|
|
377
|
-
parseHTML() {
|
|
378
|
-
return [
|
|
379
|
-
{
|
|
380
|
-
tag: 'span[data-type="loading"]'
|
|
381
|
-
}
|
|
382
|
-
];
|
|
383
|
-
},
|
|
384
|
-
renderHTML({ HTMLAttributes }) {
|
|
385
|
-
return [
|
|
386
|
-
"span",
|
|
387
|
-
(0, import_core4.mergeAttributes)(HTMLAttributes, {
|
|
388
|
-
"data-type": "loading",
|
|
389
|
-
class: "inline-flex items-center px-1.5 py-0.5 text-xs text-muted-foreground animate-pulse"
|
|
390
|
-
}),
|
|
391
|
-
"\u23F3"
|
|
392
|
-
];
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
9
|
|
|
396
|
-
// src/extensions/SmilieReplacer.ts
|
|
397
|
-
var import_core5 = require("@tiptap/core");
|
|
398
|
-
var SmilieReplacer = import_core5.Extension.create({
|
|
399
|
-
name: "smilieReplacer",
|
|
400
|
-
addInputRules() {
|
|
401
|
-
return [
|
|
402
|
-
(0, import_core5.textInputRule)({ find: /-___- $/, replace: "\u{1F611} " }),
|
|
403
|
-
(0, import_core5.textInputRule)({ find: /:'-\) $/, replace: "\u{1F602} " }),
|
|
404
|
-
(0, import_core5.textInputRule)({ find: /':-\) $/, replace: "\u{1F605} " }),
|
|
405
|
-
(0, import_core5.textInputRule)({ find: /':-D $/, replace: "\u{1F605} " }),
|
|
406
|
-
(0, import_core5.textInputRule)({ find: />:-\) $/, replace: "\u{1F606} " }),
|
|
407
|
-
(0, import_core5.textInputRule)({ find: /-__- $/, replace: "\u{1F611} " }),
|
|
408
|
-
(0, import_core5.textInputRule)({ find: /':-\( $/, replace: "\u{1F613} " }),
|
|
409
|
-
(0, import_core5.textInputRule)({ find: /:'-\( $/, replace: "\u{1F622} " }),
|
|
410
|
-
(0, import_core5.textInputRule)({ find: />:-\( $/, replace: "\u{1F620} " }),
|
|
411
|
-
(0, import_core5.textInputRule)({ find: /O:-\) $/, replace: "\u{1F607} " }),
|
|
412
|
-
(0, import_core5.textInputRule)({ find: /:'\) $/, replace: "\u{1F602} " }),
|
|
413
|
-
(0, import_core5.textInputRule)({ find: /:-D $/, replace: "\u{1F603} " }),
|
|
414
|
-
(0, import_core5.textInputRule)({ find: /':\) $/, replace: "\u{1F605} " }),
|
|
415
|
-
(0, import_core5.textInputRule)({ find: /;-\) $/, replace: "\u{1F609} " }),
|
|
416
|
-
(0, import_core5.textInputRule)({ find: /B-\) $/, replace: "\u{1F60E} " }),
|
|
417
|
-
(0, import_core5.textInputRule)({ find: /:-\* $/, replace: "\u{1F618} " }),
|
|
418
|
-
(0, import_core5.textInputRule)({ find: /:-\) $/, replace: "\u{1F642} " }),
|
|
419
|
-
(0, import_core5.textInputRule)({ find: /-_- $/, replace: "\u{1F611} " }),
|
|
420
|
-
(0, import_core5.textInputRule)({ find: /:-O $/, replace: "\u{1F62E} " }),
|
|
421
|
-
(0, import_core5.textInputRule)({ find: /:-P $/, replace: "\u{1F61B} " }),
|
|
422
|
-
(0, import_core5.textInputRule)({ find: /:-p $/, replace: "\u{1F61B} " }),
|
|
423
|
-
(0, import_core5.textInputRule)({ find: /:-\/ $/, replace: "\u{1F615} " }),
|
|
424
|
-
(0, import_core5.textInputRule)({ find: /:-\( $/, replace: "\u{1F61E} " }),
|
|
425
|
-
(0, import_core5.textInputRule)({ find: /:'\( $/, replace: "\u{1F622} " }),
|
|
426
|
-
(0, import_core5.textInputRule)({ find: /:D $/, replace: "\u{1F603} " }),
|
|
427
|
-
(0, import_core5.textInputRule)({ find: /=D $/, replace: "\u{1F603} " }),
|
|
428
|
-
(0, import_core5.textInputRule)({ find: /;\) $/, replace: "\u{1F609} " }),
|
|
429
|
-
(0, import_core5.textInputRule)({ find: /B\) $/, replace: "\u{1F60E} " }),
|
|
430
|
-
(0, import_core5.textInputRule)({ find: /:\) $/, replace: "\u{1F642} " }),
|
|
431
|
-
(0, import_core5.textInputRule)({ find: /=\) $/, replace: "\u{1F642} " }),
|
|
432
|
-
(0, import_core5.textInputRule)({ find: /:O $/, replace: "\u{1F62E} " }),
|
|
433
|
-
(0, import_core5.textInputRule)({ find: /:P $/, replace: "\u{1F61B} " }),
|
|
434
|
-
(0, import_core5.textInputRule)({ find: /:p $/, replace: "\u{1F61B} " }),
|
|
435
|
-
(0, import_core5.textInputRule)({ find: /:\/ $/, replace: "\u{1F615} " }),
|
|
436
|
-
(0, import_core5.textInputRule)({ find: /:\( $/, replace: "\u{1F61E} " }),
|
|
437
|
-
(0, import_core5.textInputRule)({ find: /<3 $/, replace: "\u2764\uFE0F " }),
|
|
438
|
-
(0, import_core5.textInputRule)({ find: /<\/3 $/, replace: "\u{1F494} " }),
|
|
439
|
-
(0, import_core5.textInputRule)({ find: /\/shrug $/, replace: "\xAF\\_(\u30C4)_/\xAF " })
|
|
440
|
-
];
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
10
|
|
|
444
|
-
// src/extensions/ColorHighlighter.ts
|
|
445
|
-
var import_core6 = require("@tiptap/core");
|
|
446
|
-
var import_state3 = require("@tiptap/pm/state");
|
|
447
|
-
var import_view2 = require("@tiptap/pm/view");
|
|
448
|
-
function findHexColors(doc) {
|
|
449
|
-
const hexColorRegex = /(#[0-9a-fA-F]{3,8})\b/g;
|
|
450
|
-
const decorations = [];
|
|
451
|
-
doc.descendants((node, position) => {
|
|
452
|
-
if (!node.text) return;
|
|
453
|
-
let match;
|
|
454
|
-
while ((match = hexColorRegex.exec(node.text)) !== null) {
|
|
455
|
-
const color = match[0];
|
|
456
|
-
const from = position + match.index;
|
|
457
|
-
const to = from + color.length;
|
|
458
|
-
decorations.push(
|
|
459
|
-
import_view2.Decoration.inline(from, to, {
|
|
460
|
-
class: "color-highlight px-1 py-0.5 rounded text-xs font-mono border",
|
|
461
|
-
style: `--color: ${color}; background-color: ${color}20; border-color: ${color}; color: ${color};`
|
|
462
|
-
})
|
|
463
|
-
);
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
return import_view2.DecorationSet.create(doc, decorations);
|
|
467
|
-
}
|
|
468
|
-
var ColorHighlighter = import_core6.Extension.create({
|
|
469
|
-
name: "colorHighlighter",
|
|
470
|
-
addProseMirrorPlugins() {
|
|
471
|
-
return [
|
|
472
|
-
new import_state3.Plugin({
|
|
473
|
-
state: {
|
|
474
|
-
init(_, { doc }) {
|
|
475
|
-
return findHexColors(doc);
|
|
476
|
-
},
|
|
477
|
-
apply(transaction, oldState) {
|
|
478
|
-
return transaction.docChanged ? findHexColors(transaction.doc) : oldState;
|
|
479
|
-
}
|
|
480
|
-
},
|
|
481
|
-
props: {
|
|
482
|
-
decorations(state) {
|
|
483
|
-
return this.getState(state);
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
})
|
|
487
|
-
];
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
11
|
|
|
491
|
-
// src/extensions/FontSize.ts
|
|
492
|
-
var import_core7 = require("@tiptap/core");
|
|
493
|
-
var import_extension_text_style = require("@tiptap/extension-text-style");
|
|
494
|
-
var FontSize = import_core7.Extension.create({
|
|
495
|
-
name: "fontSize",
|
|
496
|
-
addOptions() {
|
|
497
|
-
return {
|
|
498
|
-
types: ["textStyle"]
|
|
499
|
-
};
|
|
500
|
-
},
|
|
501
|
-
addGlobalAttributes() {
|
|
502
|
-
return [
|
|
503
|
-
{
|
|
504
|
-
types: this.options.types,
|
|
505
|
-
attributes: {
|
|
506
|
-
fontSize: {
|
|
507
|
-
default: null,
|
|
508
|
-
parseHTML: (element) => element.style.fontSize.replace(/['"]+/g, ""),
|
|
509
|
-
renderHTML: (attributes) => {
|
|
510
|
-
if (!attributes.fontSize) {
|
|
511
|
-
return {};
|
|
512
|
-
}
|
|
513
|
-
return {
|
|
514
|
-
style: `font-size: ${attributes.fontSize}`
|
|
515
|
-
};
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
];
|
|
521
|
-
},
|
|
522
|
-
addCommands() {
|
|
523
|
-
return {
|
|
524
|
-
setFontSize: (fontSize) => ({ chain }) => chain().setMark("textStyle", { fontSize }).run(),
|
|
525
|
-
unsetFontSize: () => ({ chain }) => chain().setMark("textStyle", { fontSize: null }).removeEmptyTextStyle().run()
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
12
|
|
|
530
|
-
// src/extensions/rich-text-preset.ts
|
|
531
|
-
var import_core9 = require("@tiptap/core");
|
|
532
|
-
var _StarterKit = __toESM(require("@tiptap/starter-kit"), 1);
|
|
533
|
-
var _Color = __toESM(require("@tiptap/extension-color"), 1);
|
|
534
|
-
var _Highlight = __toESM(require("@tiptap/extension-highlight"), 1);
|
|
535
|
-
var _Link = __toESM(require("@tiptap/extension-link"), 1);
|
|
536
|
-
var _TaskList = __toESM(require("@tiptap/extension-task-list"), 1);
|
|
537
|
-
var _TaskItem = __toESM(require("@tiptap/extension-task-item"), 1);
|
|
538
|
-
var _TextAlign = __toESM(require("@tiptap/extension-text-align"), 1);
|
|
539
|
-
var _TextStyle = __toESM(require("@tiptap/extension-text-style"), 1);
|
|
540
|
-
var _Typography = __toESM(require("@tiptap/extension-typography"), 1);
|
|
541
|
-
var _Underline = __toESM(require("@tiptap/extension-underline"), 1);
|
|
542
|
-
var _Placeholder = __toESM(require("@tiptap/extension-placeholder"), 1);
|
|
543
|
-
var _CharacterCount = __toESM(require("@tiptap/extension-character-count"), 1);
|
|
544
13
|
|
|
545
|
-
// src/extensions/mention.ts
|
|
546
|
-
var import_extension_mention = require("@tiptap/extension-mention");
|
|
547
|
-
var BaseMention = import_extension_mention.Mention || import_extension_mention.Mention?.default?.default || import_extension_mention.Mention?.default || import_extension_mention.Mention;
|
|
548
|
-
var Mention = BaseMention.extend({
|
|
549
|
-
addAttributes() {
|
|
550
|
-
return {
|
|
551
|
-
...this.parent?.(),
|
|
552
|
-
type: {
|
|
553
|
-
default: null,
|
|
554
|
-
parseHTML: (element) => element.getAttribute("data-type-name") || element.getAttribute("data-entity-type"),
|
|
555
|
-
renderHTML: (attributes) => {
|
|
556
|
-
if (!attributes.type) return {};
|
|
557
|
-
return { "data-type-name": attributes.type };
|
|
558
|
-
}
|
|
559
|
-
},
|
|
560
|
-
avatarUrl: {
|
|
561
|
-
default: null,
|
|
562
|
-
parseHTML: (element) => element.getAttribute("data-avatar-url"),
|
|
563
|
-
renderHTML: (attributes) => {
|
|
564
|
-
if (!attributes.avatarUrl) return {};
|
|
565
|
-
return { "data-avatar-url": attributes.avatarUrl };
|
|
566
|
-
}
|
|
567
|
-
},
|
|
568
|
-
color: {
|
|
569
|
-
default: null,
|
|
570
|
-
parseHTML: (element) => element.getAttribute("data-color"),
|
|
571
|
-
renderHTML: (attributes) => {
|
|
572
|
-
if (!attributes.color) return {};
|
|
573
|
-
return { "data-color": attributes.color };
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
};
|
|
577
|
-
}
|
|
578
|
-
});
|
|
579
|
-
function createMentionExtension(options = {}) {
|
|
580
|
-
const { HTMLAttributes = {}, ...rest } = options;
|
|
581
|
-
return Mention.configure({
|
|
582
|
-
HTMLAttributes: {
|
|
583
|
-
class: "pixerate-mention-node",
|
|
584
|
-
...HTMLAttributes
|
|
585
|
-
},
|
|
586
|
-
...rest
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
14
|
|
|
590
|
-
// ../../node_modules/.pnpm/tiptap-markdown@0.8.10_@tiptap+core@2.27.3_@tiptap+pm@2.27.3_/node_modules/tiptap-markdown/dist/tiptap-markdown.es.js
|
|
591
|
-
var import_core8 = require("@tiptap/core");
|
|
592
|
-
var import_prosemirror_markdown = require("prosemirror-markdown");
|
|
593
|
-
var import_markdown_it = __toESM(require("markdown-it"), 1);
|
|
594
|
-
var import_model = require("@tiptap/pm/model");
|
|
595
|
-
var import_markdown_it_task_lists = __toESM(require("markdown-it-task-lists"), 1);
|
|
596
|
-
var import_state4 = require("@tiptap/pm/state");
|
|
597
|
-
var __defProp2 = Object.defineProperty;
|
|
598
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
599
|
-
var __publicField = (obj, key, value) => {
|
|
600
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
601
|
-
return value;
|
|
602
|
-
};
|
|
603
|
-
var MarkdownTightLists = import_core8.Extension.create({
|
|
604
|
-
name: "markdownTightLists",
|
|
605
|
-
addOptions: () => ({
|
|
606
|
-
tight: true,
|
|
607
|
-
tightClass: "tight",
|
|
608
|
-
listTypes: ["bulletList", "orderedList"]
|
|
609
|
-
}),
|
|
610
|
-
addGlobalAttributes() {
|
|
611
|
-
return [{
|
|
612
|
-
types: this.options.listTypes,
|
|
613
|
-
attributes: {
|
|
614
|
-
tight: {
|
|
615
|
-
default: this.options.tight,
|
|
616
|
-
parseHTML: (element) => element.getAttribute("data-tight") === "true" || !element.querySelector("p"),
|
|
617
|
-
renderHTML: (attributes) => ({
|
|
618
|
-
class: attributes.tight ? this.options.tightClass : null,
|
|
619
|
-
"data-tight": attributes.tight ? "true" : null
|
|
620
|
-
})
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
}];
|
|
624
|
-
},
|
|
625
|
-
addCommands() {
|
|
626
|
-
var _this = this;
|
|
627
|
-
return {
|
|
628
|
-
toggleTight: function() {
|
|
629
|
-
let tight = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null;
|
|
630
|
-
return (_ref) => {
|
|
631
|
-
let {
|
|
632
|
-
editor,
|
|
633
|
-
commands
|
|
634
|
-
} = _ref;
|
|
635
|
-
function toggleTight(name) {
|
|
636
|
-
if (!editor.isActive(name)) {
|
|
637
|
-
return false;
|
|
638
|
-
}
|
|
639
|
-
const attrs = editor.getAttributes(name);
|
|
640
|
-
return commands.updateAttributes(name, {
|
|
641
|
-
tight: tight !== null && tight !== void 0 ? tight : !(attrs !== null && attrs !== void 0 && attrs.tight)
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
return _this.options.listTypes.some((name) => toggleTight(name));
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
};
|
|
648
|
-
}
|
|
649
|
-
});
|
|
650
|
-
var md = (0, import_markdown_it.default)();
|
|
651
|
-
function scanDelims(text, pos) {
|
|
652
|
-
md.inline.State.prototype.scanDelims.call({
|
|
653
|
-
src: text,
|
|
654
|
-
posMax: text.length
|
|
655
|
-
});
|
|
656
|
-
const state = new md.inline.State(text, null, null, []);
|
|
657
|
-
return state.scanDelims(pos, true);
|
|
658
|
-
}
|
|
659
|
-
function shiftDelim(text, delim, start, offset) {
|
|
660
|
-
let res = text.substring(0, start) + text.substring(start + delim.length);
|
|
661
|
-
res = res.substring(0, start + offset) + delim + res.substring(start + offset);
|
|
662
|
-
return res;
|
|
663
|
-
}
|
|
664
|
-
function trimStart(text, delim, from, to) {
|
|
665
|
-
let pos = from, res = text;
|
|
666
|
-
while (pos < to) {
|
|
667
|
-
if (scanDelims(res, pos).can_open) {
|
|
668
|
-
break;
|
|
669
|
-
}
|
|
670
|
-
res = shiftDelim(res, delim, pos, 1);
|
|
671
|
-
pos++;
|
|
672
|
-
}
|
|
673
|
-
return {
|
|
674
|
-
text: res,
|
|
675
|
-
from: pos,
|
|
676
|
-
to
|
|
677
|
-
};
|
|
678
|
-
}
|
|
679
|
-
function trimEnd(text, delim, from, to) {
|
|
680
|
-
let pos = to, res = text;
|
|
681
|
-
while (pos > from) {
|
|
682
|
-
if (scanDelims(res, pos).can_close) {
|
|
683
|
-
break;
|
|
684
|
-
}
|
|
685
|
-
res = shiftDelim(res, delim, pos, -1);
|
|
686
|
-
pos--;
|
|
687
|
-
}
|
|
688
|
-
return {
|
|
689
|
-
text: res,
|
|
690
|
-
from,
|
|
691
|
-
to: pos
|
|
692
|
-
};
|
|
693
|
-
}
|
|
694
|
-
function trimInline(text, delim, from, to) {
|
|
695
|
-
let state = {
|
|
696
|
-
text,
|
|
697
|
-
from,
|
|
698
|
-
to
|
|
699
|
-
};
|
|
700
|
-
state = trimStart(state.text, delim, state.from, state.to);
|
|
701
|
-
state = trimEnd(state.text, delim, state.from, state.to);
|
|
702
|
-
if (state.to - state.from < delim.length + 1) {
|
|
703
|
-
state.text = state.text.substring(0, state.from) + state.text.substring(state.to + delim.length);
|
|
704
|
-
}
|
|
705
|
-
return state.text;
|
|
706
|
-
}
|
|
707
|
-
var MarkdownSerializerState = class extends import_prosemirror_markdown.MarkdownSerializerState {
|
|
708
|
-
constructor(nodes, marks, options) {
|
|
709
|
-
super(nodes, marks, options !== null && options !== void 0 ? options : {});
|
|
710
|
-
__publicField(this, "inTable", false);
|
|
711
|
-
this.inlines = [];
|
|
712
|
-
}
|
|
713
|
-
render(node, parent, index) {
|
|
714
|
-
super.render(node, parent, index);
|
|
715
|
-
const top = this.inlines[this.inlines.length - 1];
|
|
716
|
-
if (top !== null && top !== void 0 && top.start && top !== null && top !== void 0 && top.end) {
|
|
717
|
-
const {
|
|
718
|
-
delimiter,
|
|
719
|
-
start,
|
|
720
|
-
end
|
|
721
|
-
} = this.normalizeInline(top);
|
|
722
|
-
this.out = trimInline(this.out, delimiter, start, end);
|
|
723
|
-
this.inlines.pop();
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
markString(mark, open, parent, index) {
|
|
727
|
-
const info = this.marks[mark.type.name];
|
|
728
|
-
if (info.expelEnclosingWhitespace) {
|
|
729
|
-
if (open) {
|
|
730
|
-
this.inlines.push({
|
|
731
|
-
start: this.out.length,
|
|
732
|
-
delimiter: info.open
|
|
733
|
-
});
|
|
734
|
-
} else {
|
|
735
|
-
const top = this.inlines.pop();
|
|
736
|
-
this.inlines.push({
|
|
737
|
-
...top,
|
|
738
|
-
end: this.out.length
|
|
739
|
-
});
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
return super.markString(mark, open, parent, index);
|
|
743
|
-
}
|
|
744
|
-
normalizeInline(inline) {
|
|
745
|
-
let {
|
|
746
|
-
start,
|
|
747
|
-
end
|
|
748
|
-
} = inline;
|
|
749
|
-
while (this.out.charAt(start).match(/\s/)) {
|
|
750
|
-
start++;
|
|
751
|
-
}
|
|
752
|
-
return {
|
|
753
|
-
...inline,
|
|
754
|
-
start
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
|
-
};
|
|
758
|
-
var HTMLMark = import_core8.Mark.create({
|
|
759
|
-
name: "markdownHTMLMark",
|
|
760
|
-
/**
|
|
761
|
-
* @return {{markdown: MarkdownMarkSpec}}
|
|
762
|
-
*/
|
|
763
|
-
addStorage() {
|
|
764
|
-
return {
|
|
765
|
-
markdown: {
|
|
766
|
-
serialize: {
|
|
767
|
-
open(state, mark) {
|
|
768
|
-
var _getMarkTags$, _getMarkTags;
|
|
769
|
-
if (!this.editor.storage.markdown.options.html) {
|
|
770
|
-
console.warn(`Tiptap Markdown: "${mark.type.name}" mark is only available in html mode`);
|
|
771
|
-
return "";
|
|
772
|
-
}
|
|
773
|
-
return (_getMarkTags$ = (_getMarkTags = getMarkTags(mark)) === null || _getMarkTags === void 0 ? void 0 : _getMarkTags[0]) !== null && _getMarkTags$ !== void 0 ? _getMarkTags$ : "";
|
|
774
|
-
},
|
|
775
|
-
close(state, mark) {
|
|
776
|
-
var _getMarkTags$2, _getMarkTags2;
|
|
777
|
-
if (!this.editor.storage.markdown.options.html) {
|
|
778
|
-
return "";
|
|
779
|
-
}
|
|
780
|
-
return (_getMarkTags$2 = (_getMarkTags2 = getMarkTags(mark)) === null || _getMarkTags2 === void 0 ? void 0 : _getMarkTags2[1]) !== null && _getMarkTags$2 !== void 0 ? _getMarkTags$2 : "";
|
|
781
|
-
}
|
|
782
|
-
},
|
|
783
|
-
parse: {
|
|
784
|
-
// handled by markdown-it
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
};
|
|
788
|
-
}
|
|
789
|
-
});
|
|
790
|
-
function getMarkTags(mark) {
|
|
791
|
-
const schema = mark.type.schema;
|
|
792
|
-
const node = schema.text(" ", [mark]);
|
|
793
|
-
const html = (0, import_core8.getHTMLFromFragment)(import_model.Fragment.from(node), schema);
|
|
794
|
-
const match = html.match(/^(<.*?>) (<\/.*?>)$/);
|
|
795
|
-
return match ? [match[1], match[2]] : null;
|
|
796
|
-
}
|
|
797
|
-
function elementFromString(value) {
|
|
798
|
-
const wrappedValue = `<body>${value}</body>`;
|
|
799
|
-
return new window.DOMParser().parseFromString(wrappedValue, "text/html").body;
|
|
800
|
-
}
|
|
801
|
-
function escapeHTML(value) {
|
|
802
|
-
return value === null || value === void 0 ? void 0 : value.replace(/</g, "<").replace(/>/g, ">");
|
|
803
|
-
}
|
|
804
|
-
function extractElement(node) {
|
|
805
|
-
const parent = node.parentElement;
|
|
806
|
-
const prepend = parent.cloneNode();
|
|
807
|
-
while (parent.firstChild && parent.firstChild !== node) {
|
|
808
|
-
prepend.appendChild(parent.firstChild);
|
|
809
|
-
}
|
|
810
|
-
if (prepend.childNodes.length > 0) {
|
|
811
|
-
parent.parentElement.insertBefore(prepend, parent);
|
|
812
|
-
}
|
|
813
|
-
parent.parentElement.insertBefore(node, parent);
|
|
814
|
-
if (parent.childNodes.length === 0) {
|
|
815
|
-
parent.remove();
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
function unwrapElement(node) {
|
|
819
|
-
const parent = node.parentNode;
|
|
820
|
-
while (node.firstChild)
|
|
821
|
-
parent.insertBefore(node.firstChild, node);
|
|
822
|
-
parent.removeChild(node);
|
|
823
|
-
}
|
|
824
|
-
var HTMLNode = import_core8.Node.create({
|
|
825
|
-
name: "markdownHTMLNode",
|
|
826
|
-
addStorage() {
|
|
827
|
-
return {
|
|
828
|
-
markdown: {
|
|
829
|
-
serialize(state, node, parent) {
|
|
830
|
-
if (this.editor.storage.markdown.options.html) {
|
|
831
|
-
state.write(serializeHTML(node, parent));
|
|
832
|
-
} else {
|
|
833
|
-
console.warn(`Tiptap Markdown: "${node.type.name}" node is only available in html mode`);
|
|
834
|
-
state.write(`[${node.type.name}]`);
|
|
835
|
-
}
|
|
836
|
-
if (node.isBlock) {
|
|
837
|
-
state.closeBlock(node);
|
|
838
|
-
}
|
|
839
|
-
},
|
|
840
|
-
parse: {
|
|
841
|
-
// handled by markdown-it
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
};
|
|
845
|
-
}
|
|
846
|
-
});
|
|
847
|
-
function serializeHTML(node, parent) {
|
|
848
|
-
const schema = node.type.schema;
|
|
849
|
-
const html = (0, import_core8.getHTMLFromFragment)(import_model.Fragment.from(node), schema);
|
|
850
|
-
if (node.isBlock && (parent instanceof import_model.Fragment || parent.type.name === schema.topNodeType.name)) {
|
|
851
|
-
return formatBlock(html);
|
|
852
|
-
}
|
|
853
|
-
return html;
|
|
854
|
-
}
|
|
855
|
-
function formatBlock(html) {
|
|
856
|
-
const dom = elementFromString(html);
|
|
857
|
-
const element = dom.firstElementChild;
|
|
858
|
-
element.innerHTML = element.innerHTML.trim() ? `
|
|
859
|
-
${element.innerHTML}
|
|
860
|
-
` : `
|
|
861
|
-
`;
|
|
862
|
-
return element.outerHTML;
|
|
863
|
-
}
|
|
864
|
-
var Blockquote = import_core8.Node.create({
|
|
865
|
-
name: "blockquote"
|
|
866
|
-
});
|
|
867
|
-
var Blockquote$1 = Blockquote.extend({
|
|
868
|
-
/**
|
|
869
|
-
* @return {{markdown: MarkdownNodeSpec}}
|
|
870
|
-
*/
|
|
871
|
-
addStorage() {
|
|
872
|
-
return {
|
|
873
|
-
markdown: {
|
|
874
|
-
serialize: import_prosemirror_markdown.defaultMarkdownSerializer.nodes.blockquote,
|
|
875
|
-
parse: {
|
|
876
|
-
// handled by markdown-it
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
};
|
|
880
|
-
}
|
|
881
|
-
});
|
|
882
|
-
var BulletList = import_core8.Node.create({
|
|
883
|
-
name: "bulletList"
|
|
884
|
-
});
|
|
885
|
-
var BulletList$1 = BulletList.extend({
|
|
886
|
-
/**
|
|
887
|
-
* @return {{markdown: MarkdownNodeSpec}}
|
|
888
|
-
*/
|
|
889
|
-
addStorage() {
|
|
890
|
-
return {
|
|
891
|
-
markdown: {
|
|
892
|
-
serialize(state, node) {
|
|
893
|
-
return state.renderList(node, " ", () => (this.editor.storage.markdown.options.bulletListMarker || "-") + " ");
|
|
894
|
-
},
|
|
895
|
-
parse: {
|
|
896
|
-
// handled by markdown-it
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
};
|
|
900
|
-
}
|
|
901
|
-
});
|
|
902
|
-
var CodeBlock = import_core8.Node.create({
|
|
903
|
-
name: "codeBlock"
|
|
904
|
-
});
|
|
905
|
-
var CodeBlock$1 = CodeBlock.extend({
|
|
906
|
-
/**
|
|
907
|
-
* @return {{markdown: MarkdownNodeSpec}}
|
|
908
|
-
*/
|
|
909
|
-
addStorage() {
|
|
910
|
-
return {
|
|
911
|
-
markdown: {
|
|
912
|
-
serialize(state, node) {
|
|
913
|
-
state.write("```" + (node.attrs.language || "") + "\n");
|
|
914
|
-
state.text(node.textContent, false);
|
|
915
|
-
state.ensureNewLine();
|
|
916
|
-
state.write("```");
|
|
917
|
-
state.closeBlock(node);
|
|
918
|
-
},
|
|
919
|
-
parse: {
|
|
920
|
-
setup(markdownit2) {
|
|
921
|
-
var _this$options$languag;
|
|
922
|
-
markdownit2.set({
|
|
923
|
-
langPrefix: (_this$options$languag = this.options.languageClassPrefix) !== null && _this$options$languag !== void 0 ? _this$options$languag : "language-"
|
|
924
|
-
});
|
|
925
|
-
},
|
|
926
|
-
updateDOM(element) {
|
|
927
|
-
element.innerHTML = element.innerHTML.replace(/\n<\/code><\/pre>/g, "</code></pre>");
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
};
|
|
932
|
-
}
|
|
933
|
-
});
|
|
934
|
-
var HardBreak = import_core8.Node.create({
|
|
935
|
-
name: "hardBreak"
|
|
936
|
-
});
|
|
937
|
-
var HardBreak$1 = HardBreak.extend({
|
|
938
|
-
/**
|
|
939
|
-
* @return {{markdown: MarkdownNodeSpec}}
|
|
940
|
-
*/
|
|
941
|
-
addStorage() {
|
|
942
|
-
return {
|
|
943
|
-
markdown: {
|
|
944
|
-
serialize(state, node, parent, index) {
|
|
945
|
-
for (let i = index + 1; i < parent.childCount; i++)
|
|
946
|
-
if (parent.child(i).type != node.type) {
|
|
947
|
-
state.write(state.inTable ? HTMLNode.storage.markdown.serialize.call(this, state, node, parent) : "\\\n");
|
|
948
|
-
return;
|
|
949
|
-
}
|
|
950
|
-
},
|
|
951
|
-
parse: {
|
|
952
|
-
// handled by markdown-it
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
};
|
|
956
|
-
}
|
|
957
|
-
});
|
|
958
|
-
var Heading = import_core8.Node.create({
|
|
959
|
-
name: "heading"
|
|
960
|
-
});
|
|
961
|
-
var Heading$1 = Heading.extend({
|
|
962
|
-
/**
|
|
963
|
-
* @return {{markdown: MarkdownNodeSpec}}
|
|
964
|
-
*/
|
|
965
|
-
addStorage() {
|
|
966
|
-
return {
|
|
967
|
-
markdown: {
|
|
968
|
-
serialize: import_prosemirror_markdown.defaultMarkdownSerializer.nodes.heading,
|
|
969
|
-
parse: {
|
|
970
|
-
// handled by markdown-it
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
};
|
|
974
|
-
}
|
|
975
|
-
});
|
|
976
|
-
var HorizontalRule = import_core8.Node.create({
|
|
977
|
-
name: "horizontalRule"
|
|
978
|
-
});
|
|
979
|
-
var HorizontalRule$1 = HorizontalRule.extend({
|
|
980
|
-
/**
|
|
981
|
-
* @return {{markdown: MarkdownNodeSpec}}
|
|
982
|
-
*/
|
|
983
|
-
addStorage() {
|
|
984
|
-
return {
|
|
985
|
-
markdown: {
|
|
986
|
-
serialize: import_prosemirror_markdown.defaultMarkdownSerializer.nodes.horizontal_rule,
|
|
987
|
-
parse: {
|
|
988
|
-
// handled by markdown-it
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
};
|
|
992
|
-
}
|
|
993
|
-
});
|
|
994
|
-
var Image = import_core8.Node.create({
|
|
995
|
-
name: "image"
|
|
996
|
-
});
|
|
997
|
-
var Image$1 = Image.extend({
|
|
998
|
-
/**
|
|
999
|
-
* @return {{markdown: MarkdownNodeSpec}}
|
|
1000
|
-
*/
|
|
1001
|
-
addStorage() {
|
|
1002
|
-
return {
|
|
1003
|
-
markdown: {
|
|
1004
|
-
serialize: import_prosemirror_markdown.defaultMarkdownSerializer.nodes.image,
|
|
1005
|
-
parse: {
|
|
1006
|
-
// handled by markdown-it
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
};
|
|
1010
|
-
}
|
|
1011
|
-
});
|
|
1012
|
-
var ListItem = import_core8.Node.create({
|
|
1013
|
-
name: "listItem"
|
|
1014
|
-
});
|
|
1015
|
-
var ListItem$1 = ListItem.extend({
|
|
1016
|
-
/**
|
|
1017
|
-
* @return {{markdown: MarkdownNodeSpec}}
|
|
1018
|
-
*/
|
|
1019
|
-
addStorage() {
|
|
1020
|
-
return {
|
|
1021
|
-
markdown: {
|
|
1022
|
-
serialize: import_prosemirror_markdown.defaultMarkdownSerializer.nodes.list_item,
|
|
1023
|
-
parse: {
|
|
1024
|
-
// handled by markdown-it
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
};
|
|
1028
|
-
}
|
|
1029
|
-
});
|
|
1030
|
-
var OrderedList = import_core8.Node.create({
|
|
1031
|
-
name: "orderedList"
|
|
1032
|
-
});
|
|
1033
|
-
function findIndexOfAdjacentNode(node, parent, index) {
|
|
1034
|
-
let i = 0;
|
|
1035
|
-
for (; index - i > 0; i++) {
|
|
1036
|
-
if (parent.child(index - i - 1).type.name !== node.type.name) {
|
|
1037
|
-
break;
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
return i;
|
|
1041
|
-
}
|
|
1042
|
-
var OrderedList$1 = OrderedList.extend({
|
|
1043
|
-
/**
|
|
1044
|
-
* @return {{markdown: MarkdownNodeSpec}}
|
|
1045
|
-
*/
|
|
1046
|
-
addStorage() {
|
|
1047
|
-
return {
|
|
1048
|
-
markdown: {
|
|
1049
|
-
serialize(state, node, parent, index) {
|
|
1050
|
-
const start = node.attrs.start || 1;
|
|
1051
|
-
const maxW = String(start + node.childCount - 1).length;
|
|
1052
|
-
const space = state.repeat(" ", maxW + 2);
|
|
1053
|
-
const adjacentIndex = findIndexOfAdjacentNode(node, parent, index);
|
|
1054
|
-
const separator = adjacentIndex % 2 ? ") " : ". ";
|
|
1055
|
-
state.renderList(node, space, (i) => {
|
|
1056
|
-
const nStr = String(start + i);
|
|
1057
|
-
return state.repeat(" ", maxW - nStr.length) + nStr + separator;
|
|
1058
|
-
});
|
|
1059
|
-
},
|
|
1060
|
-
parse: {
|
|
1061
|
-
// handled by markdown-it
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
};
|
|
1065
|
-
}
|
|
1066
|
-
});
|
|
1067
|
-
var Paragraph = import_core8.Node.create({
|
|
1068
|
-
name: "paragraph"
|
|
1069
|
-
});
|
|
1070
|
-
var Paragraph$1 = Paragraph.extend({
|
|
1071
|
-
/**
|
|
1072
|
-
* @return {{markdown: MarkdownNodeSpec}}
|
|
1073
|
-
*/
|
|
1074
|
-
addStorage() {
|
|
1075
|
-
return {
|
|
1076
|
-
markdown: {
|
|
1077
|
-
serialize: import_prosemirror_markdown.defaultMarkdownSerializer.nodes.paragraph,
|
|
1078
|
-
parse: {
|
|
1079
|
-
// handled by markdown-it
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
};
|
|
1083
|
-
}
|
|
1084
|
-
});
|
|
1085
|
-
function childNodes(node) {
|
|
1086
|
-
var _node$content$content, _node$content;
|
|
1087
|
-
return (_node$content$content = node === null || node === void 0 || (_node$content = node.content) === null || _node$content === void 0 ? void 0 : _node$content.content) !== null && _node$content$content !== void 0 ? _node$content$content : [];
|
|
1088
|
-
}
|
|
1089
|
-
var Table = import_core8.Node.create({
|
|
1090
|
-
name: "table"
|
|
1091
|
-
});
|
|
1092
|
-
var Table$1 = Table.extend({
|
|
1093
|
-
/**
|
|
1094
|
-
* @return {{markdown: MarkdownNodeSpec}}
|
|
1095
|
-
*/
|
|
1096
|
-
addStorage() {
|
|
1097
|
-
return {
|
|
1098
|
-
markdown: {
|
|
1099
|
-
serialize(state, node, parent) {
|
|
1100
|
-
if (!isMarkdownSerializable(node)) {
|
|
1101
|
-
HTMLNode.storage.markdown.serialize.call(this, state, node, parent);
|
|
1102
|
-
return;
|
|
1103
|
-
}
|
|
1104
|
-
state.inTable = true;
|
|
1105
|
-
node.forEach((row, p, i) => {
|
|
1106
|
-
state.write("| ");
|
|
1107
|
-
row.forEach((col, p2, j) => {
|
|
1108
|
-
if (j) {
|
|
1109
|
-
state.write(" | ");
|
|
1110
|
-
}
|
|
1111
|
-
const cellContent = col.firstChild;
|
|
1112
|
-
if (cellContent.textContent.trim()) {
|
|
1113
|
-
state.renderInline(cellContent);
|
|
1114
|
-
}
|
|
1115
|
-
});
|
|
1116
|
-
state.write(" |");
|
|
1117
|
-
state.ensureNewLine();
|
|
1118
|
-
if (!i) {
|
|
1119
|
-
const delimiterRow = Array.from({
|
|
1120
|
-
length: row.childCount
|
|
1121
|
-
}).map(() => "---").join(" | ");
|
|
1122
|
-
state.write(`| ${delimiterRow} |`);
|
|
1123
|
-
state.ensureNewLine();
|
|
1124
|
-
}
|
|
1125
|
-
});
|
|
1126
|
-
state.closeBlock(node);
|
|
1127
|
-
state.inTable = false;
|
|
1128
|
-
},
|
|
1129
|
-
parse: {
|
|
1130
|
-
// handled by markdown-it
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
};
|
|
1134
|
-
}
|
|
1135
|
-
});
|
|
1136
|
-
function hasSpan(node) {
|
|
1137
|
-
return node.attrs.colspan > 1 || node.attrs.rowspan > 1;
|
|
1138
|
-
}
|
|
1139
|
-
function isMarkdownSerializable(node) {
|
|
1140
|
-
const rows = childNodes(node);
|
|
1141
|
-
const firstRow = rows[0];
|
|
1142
|
-
const bodyRows = rows.slice(1);
|
|
1143
|
-
if (childNodes(firstRow).some((cell) => cell.type.name !== "tableHeader" || hasSpan(cell) || cell.childCount > 1)) {
|
|
1144
|
-
return false;
|
|
1145
|
-
}
|
|
1146
|
-
if (bodyRows.some((row) => childNodes(row).some((cell) => cell.type.name === "tableHeader" || hasSpan(cell) || cell.childCount > 1))) {
|
|
1147
|
-
return false;
|
|
1148
|
-
}
|
|
1149
|
-
return true;
|
|
1150
|
-
}
|
|
1151
|
-
var TaskItem = import_core8.Node.create({
|
|
1152
|
-
name: "taskItem"
|
|
1153
|
-
});
|
|
1154
|
-
var TaskItem$1 = TaskItem.extend({
|
|
1155
|
-
/**
|
|
1156
|
-
* @return {{markdown: MarkdownNodeSpec}}
|
|
1157
|
-
*/
|
|
1158
|
-
addStorage() {
|
|
1159
|
-
return {
|
|
1160
|
-
markdown: {
|
|
1161
|
-
serialize(state, node) {
|
|
1162
|
-
const check = node.attrs.checked ? "[x]" : "[ ]";
|
|
1163
|
-
state.write(`${check} `);
|
|
1164
|
-
state.renderContent(node);
|
|
1165
|
-
},
|
|
1166
|
-
parse: {
|
|
1167
|
-
updateDOM(element) {
|
|
1168
|
-
[...element.querySelectorAll(".task-list-item")].forEach((item) => {
|
|
1169
|
-
const input = item.querySelector("input");
|
|
1170
|
-
item.setAttribute("data-type", "taskItem");
|
|
1171
|
-
if (input) {
|
|
1172
|
-
item.setAttribute("data-checked", input.checked);
|
|
1173
|
-
input.remove();
|
|
1174
|
-
}
|
|
1175
|
-
});
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
};
|
|
1180
|
-
}
|
|
1181
|
-
});
|
|
1182
|
-
var TaskList = import_core8.Node.create({
|
|
1183
|
-
name: "taskList"
|
|
1184
|
-
});
|
|
1185
|
-
var TaskList$1 = TaskList.extend({
|
|
1186
|
-
/**
|
|
1187
|
-
* @return {{markdown: MarkdownNodeSpec}}
|
|
1188
|
-
*/
|
|
1189
|
-
addStorage() {
|
|
1190
|
-
return {
|
|
1191
|
-
markdown: {
|
|
1192
|
-
serialize: BulletList$1.storage.markdown.serialize,
|
|
1193
|
-
parse: {
|
|
1194
|
-
setup(markdownit2) {
|
|
1195
|
-
markdownit2.use(import_markdown_it_task_lists.default);
|
|
1196
|
-
},
|
|
1197
|
-
updateDOM(element) {
|
|
1198
|
-
[...element.querySelectorAll(".contains-task-list")].forEach((list) => {
|
|
1199
|
-
list.setAttribute("data-type", "taskList");
|
|
1200
|
-
});
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
};
|
|
1205
|
-
}
|
|
1206
|
-
});
|
|
1207
|
-
var Text = import_core8.Node.create({
|
|
1208
|
-
name: "text"
|
|
1209
|
-
});
|
|
1210
|
-
var Text$1 = Text.extend({
|
|
1211
|
-
/**
|
|
1212
|
-
* @return {{markdown: MarkdownNodeSpec}}
|
|
1213
|
-
*/
|
|
1214
|
-
addStorage() {
|
|
1215
|
-
return {
|
|
1216
|
-
markdown: {
|
|
1217
|
-
serialize(state, node) {
|
|
1218
|
-
state.text(escapeHTML(node.text));
|
|
1219
|
-
},
|
|
1220
|
-
parse: {
|
|
1221
|
-
// handled by markdown-it
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
};
|
|
1225
|
-
}
|
|
1226
|
-
});
|
|
1227
|
-
var Bold = import_core8.Mark.create({
|
|
1228
|
-
name: "bold"
|
|
1229
|
-
});
|
|
1230
|
-
var Bold$1 = Bold.extend({
|
|
1231
|
-
/**
|
|
1232
|
-
* @return {{markdown: MarkdownMarkSpec}}
|
|
1233
|
-
*/
|
|
1234
|
-
addStorage() {
|
|
1235
|
-
return {
|
|
1236
|
-
markdown: {
|
|
1237
|
-
serialize: import_prosemirror_markdown.defaultMarkdownSerializer.marks.strong,
|
|
1238
|
-
parse: {
|
|
1239
|
-
// handled by markdown-it
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
};
|
|
1243
|
-
}
|
|
1244
|
-
});
|
|
1245
|
-
var Code = import_core8.Mark.create({
|
|
1246
|
-
name: "code"
|
|
1247
|
-
});
|
|
1248
|
-
var Code$1 = Code.extend({
|
|
1249
|
-
/**
|
|
1250
|
-
* @return {{markdown: MarkdownMarkSpec}}
|
|
1251
|
-
*/
|
|
1252
|
-
addStorage() {
|
|
1253
|
-
return {
|
|
1254
|
-
markdown: {
|
|
1255
|
-
serialize: import_prosemirror_markdown.defaultMarkdownSerializer.marks.code,
|
|
1256
|
-
parse: {
|
|
1257
|
-
// handled by markdown-it
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
};
|
|
1261
|
-
}
|
|
1262
|
-
});
|
|
1263
|
-
var Italic = import_core8.Mark.create({
|
|
1264
|
-
name: "italic"
|
|
1265
|
-
});
|
|
1266
|
-
var Italic$1 = Italic.extend({
|
|
1267
|
-
/**
|
|
1268
|
-
* @return {{markdown: MarkdownMarkSpec}}
|
|
1269
|
-
*/
|
|
1270
|
-
addStorage() {
|
|
1271
|
-
return {
|
|
1272
|
-
markdown: {
|
|
1273
|
-
serialize: import_prosemirror_markdown.defaultMarkdownSerializer.marks.em,
|
|
1274
|
-
parse: {
|
|
1275
|
-
// handled by markdown-it
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
};
|
|
1279
|
-
}
|
|
1280
|
-
});
|
|
1281
|
-
var Link = import_core8.Mark.create({
|
|
1282
|
-
name: "link"
|
|
1283
|
-
});
|
|
1284
|
-
var Link$1 = Link.extend({
|
|
1285
|
-
/**
|
|
1286
|
-
* @return {{markdown: MarkdownMarkSpec}}
|
|
1287
|
-
*/
|
|
1288
|
-
addStorage() {
|
|
1289
|
-
return {
|
|
1290
|
-
markdown: {
|
|
1291
|
-
serialize: import_prosemirror_markdown.defaultMarkdownSerializer.marks.link,
|
|
1292
|
-
parse: {
|
|
1293
|
-
// handled by markdown-it
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
};
|
|
1297
|
-
}
|
|
1298
|
-
});
|
|
1299
|
-
var Strike = import_core8.Mark.create({
|
|
1300
|
-
name: "strike"
|
|
1301
|
-
});
|
|
1302
|
-
var Strike$1 = Strike.extend({
|
|
1303
|
-
/**
|
|
1304
|
-
* @return {{markdown: MarkdownMarkSpec}}
|
|
1305
|
-
*/
|
|
1306
|
-
addStorage() {
|
|
1307
|
-
return {
|
|
1308
|
-
markdown: {
|
|
1309
|
-
serialize: {
|
|
1310
|
-
open: "~~",
|
|
1311
|
-
close: "~~",
|
|
1312
|
-
expelEnclosingWhitespace: true
|
|
1313
|
-
},
|
|
1314
|
-
parse: {
|
|
1315
|
-
// handled by markdown-it
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
|
-
};
|
|
1319
|
-
}
|
|
1320
|
-
});
|
|
1321
|
-
var markdownExtensions = [Blockquote$1, BulletList$1, CodeBlock$1, HardBreak$1, Heading$1, HorizontalRule$1, HTMLNode, Image$1, ListItem$1, OrderedList$1, Paragraph$1, Table$1, TaskItem$1, TaskList$1, Text$1, Bold$1, Code$1, HTMLMark, Italic$1, Link$1, Strike$1];
|
|
1322
|
-
function getMarkdownSpec(extension) {
|
|
1323
|
-
var _extension$storage, _markdownExtensions$f;
|
|
1324
|
-
const markdownSpec = (_extension$storage = extension.storage) === null || _extension$storage === void 0 ? void 0 : _extension$storage.markdown;
|
|
1325
|
-
const defaultMarkdownSpec = (_markdownExtensions$f = markdownExtensions.find((e) => e.name === extension.name)) === null || _markdownExtensions$f === void 0 ? void 0 : _markdownExtensions$f.storage.markdown;
|
|
1326
|
-
if (markdownSpec || defaultMarkdownSpec) {
|
|
1327
|
-
return {
|
|
1328
|
-
...defaultMarkdownSpec,
|
|
1329
|
-
...markdownSpec
|
|
1330
|
-
};
|
|
1331
|
-
}
|
|
1332
|
-
return null;
|
|
1333
|
-
}
|
|
1334
|
-
var MarkdownSerializer = class {
|
|
1335
|
-
constructor(editor) {
|
|
1336
|
-
__publicField(this, "editor", null);
|
|
1337
|
-
this.editor = editor;
|
|
1338
|
-
}
|
|
1339
|
-
serialize(content) {
|
|
1340
|
-
const state = new MarkdownSerializerState(this.nodes, this.marks, {
|
|
1341
|
-
hardBreakNodeName: HardBreak$1.name
|
|
1342
|
-
});
|
|
1343
|
-
state.renderContent(content);
|
|
1344
|
-
return state.out;
|
|
1345
|
-
}
|
|
1346
|
-
get nodes() {
|
|
1347
|
-
var _this$editor$extensio;
|
|
1348
|
-
return {
|
|
1349
|
-
...Object.fromEntries(Object.keys(this.editor.schema.nodes).map((name) => [name, this.serializeNode(HTMLNode)])),
|
|
1350
|
-
...Object.fromEntries((_this$editor$extensio = this.editor.extensionManager.extensions.filter((extension) => extension.type === "node" && this.serializeNode(extension)).map((extension) => [extension.name, this.serializeNode(extension)])) !== null && _this$editor$extensio !== void 0 ? _this$editor$extensio : [])
|
|
1351
|
-
};
|
|
1352
|
-
}
|
|
1353
|
-
get marks() {
|
|
1354
|
-
var _this$editor$extensio2;
|
|
1355
|
-
return {
|
|
1356
|
-
...Object.fromEntries(Object.keys(this.editor.schema.marks).map((name) => [name, this.serializeMark(HTMLMark)])),
|
|
1357
|
-
...Object.fromEntries((_this$editor$extensio2 = this.editor.extensionManager.extensions.filter((extension) => extension.type === "mark" && this.serializeMark(extension)).map((extension) => [extension.name, this.serializeMark(extension)])) !== null && _this$editor$extensio2 !== void 0 ? _this$editor$extensio2 : [])
|
|
1358
|
-
};
|
|
1359
|
-
}
|
|
1360
|
-
serializeNode(node) {
|
|
1361
|
-
var _getMarkdownSpec;
|
|
1362
|
-
return (_getMarkdownSpec = getMarkdownSpec(node)) === null || _getMarkdownSpec === void 0 || (_getMarkdownSpec = _getMarkdownSpec.serialize) === null || _getMarkdownSpec === void 0 ? void 0 : _getMarkdownSpec.bind({
|
|
1363
|
-
editor: this.editor,
|
|
1364
|
-
options: node.options
|
|
1365
|
-
});
|
|
1366
|
-
}
|
|
1367
|
-
serializeMark(mark) {
|
|
1368
|
-
var _getMarkdownSpec2;
|
|
1369
|
-
const serialize = (_getMarkdownSpec2 = getMarkdownSpec(mark)) === null || _getMarkdownSpec2 === void 0 ? void 0 : _getMarkdownSpec2.serialize;
|
|
1370
|
-
return serialize ? {
|
|
1371
|
-
...serialize,
|
|
1372
|
-
open: typeof serialize.open === "function" ? serialize.open.bind({
|
|
1373
|
-
editor: this.editor,
|
|
1374
|
-
options: mark.options
|
|
1375
|
-
}) : serialize.open,
|
|
1376
|
-
close: typeof serialize.close === "function" ? serialize.close.bind({
|
|
1377
|
-
editor: this.editor,
|
|
1378
|
-
options: mark.options
|
|
1379
|
-
}) : serialize.close
|
|
1380
|
-
} : null;
|
|
1381
|
-
}
|
|
1382
|
-
};
|
|
1383
|
-
var MarkdownParser = class {
|
|
1384
|
-
constructor(editor, _ref) {
|
|
1385
|
-
__publicField(this, "editor", null);
|
|
1386
|
-
__publicField(this, "md", null);
|
|
1387
|
-
let {
|
|
1388
|
-
html,
|
|
1389
|
-
linkify,
|
|
1390
|
-
breaks
|
|
1391
|
-
} = _ref;
|
|
1392
|
-
this.editor = editor;
|
|
1393
|
-
this.md = this.withPatchedRenderer((0, import_markdown_it.default)({
|
|
1394
|
-
html,
|
|
1395
|
-
linkify,
|
|
1396
|
-
breaks
|
|
1397
|
-
}));
|
|
1398
|
-
}
|
|
1399
|
-
parse(content) {
|
|
1400
|
-
let {
|
|
1401
|
-
inline
|
|
1402
|
-
} = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1403
|
-
if (typeof content === "string") {
|
|
1404
|
-
this.editor.extensionManager.extensions.forEach((extension) => {
|
|
1405
|
-
var _getMarkdownSpec;
|
|
1406
|
-
return (_getMarkdownSpec = getMarkdownSpec(extension)) === null || _getMarkdownSpec === void 0 || (_getMarkdownSpec = _getMarkdownSpec.parse) === null || _getMarkdownSpec === void 0 || (_getMarkdownSpec = _getMarkdownSpec.setup) === null || _getMarkdownSpec === void 0 ? void 0 : _getMarkdownSpec.call({
|
|
1407
|
-
editor: this.editor,
|
|
1408
|
-
options: extension.options
|
|
1409
|
-
}, this.md);
|
|
1410
|
-
});
|
|
1411
|
-
const renderedHTML = this.md.render(content);
|
|
1412
|
-
const element = elementFromString(renderedHTML);
|
|
1413
|
-
this.editor.extensionManager.extensions.forEach((extension) => {
|
|
1414
|
-
var _getMarkdownSpec2;
|
|
1415
|
-
return (_getMarkdownSpec2 = getMarkdownSpec(extension)) === null || _getMarkdownSpec2 === void 0 || (_getMarkdownSpec2 = _getMarkdownSpec2.parse) === null || _getMarkdownSpec2 === void 0 || (_getMarkdownSpec2 = _getMarkdownSpec2.updateDOM) === null || _getMarkdownSpec2 === void 0 ? void 0 : _getMarkdownSpec2.call({
|
|
1416
|
-
editor: this.editor,
|
|
1417
|
-
options: extension.options
|
|
1418
|
-
}, element);
|
|
1419
|
-
});
|
|
1420
|
-
this.normalizeDOM(element, {
|
|
1421
|
-
inline,
|
|
1422
|
-
content
|
|
1423
|
-
});
|
|
1424
|
-
return element.innerHTML;
|
|
1425
|
-
}
|
|
1426
|
-
return content;
|
|
1427
|
-
}
|
|
1428
|
-
normalizeDOM(node, _ref2) {
|
|
1429
|
-
let {
|
|
1430
|
-
inline,
|
|
1431
|
-
content
|
|
1432
|
-
} = _ref2;
|
|
1433
|
-
this.normalizeBlocks(node);
|
|
1434
|
-
node.querySelectorAll("*").forEach((el) => {
|
|
1435
|
-
var _el$nextSibling;
|
|
1436
|
-
if (((_el$nextSibling = el.nextSibling) === null || _el$nextSibling === void 0 ? void 0 : _el$nextSibling.nodeType) === Node.TEXT_NODE && !el.closest("pre")) {
|
|
1437
|
-
el.nextSibling.textContent = el.nextSibling.textContent.replace(/^\n/, "");
|
|
1438
|
-
}
|
|
1439
|
-
});
|
|
1440
|
-
if (inline) {
|
|
1441
|
-
this.normalizeInline(node, content);
|
|
1442
|
-
}
|
|
1443
|
-
return node;
|
|
1444
|
-
}
|
|
1445
|
-
normalizeBlocks(node) {
|
|
1446
|
-
const blocks = Object.values(this.editor.schema.nodes).filter((node2) => node2.isBlock);
|
|
1447
|
-
const selector = blocks.map((block) => {
|
|
1448
|
-
var _block$spec$parseDOM;
|
|
1449
|
-
return (_block$spec$parseDOM = block.spec.parseDOM) === null || _block$spec$parseDOM === void 0 ? void 0 : _block$spec$parseDOM.map((spec) => spec.tag);
|
|
1450
|
-
}).flat().filter(Boolean).join(",");
|
|
1451
|
-
if (!selector) {
|
|
1452
|
-
return;
|
|
1453
|
-
}
|
|
1454
|
-
[...node.querySelectorAll(selector)].forEach((el) => {
|
|
1455
|
-
if (el.parentElement.matches("p")) {
|
|
1456
|
-
extractElement(el);
|
|
1457
|
-
}
|
|
1458
|
-
});
|
|
1459
|
-
}
|
|
1460
|
-
normalizeInline(node, content) {
|
|
1461
|
-
var _node$firstElementChi;
|
|
1462
|
-
if ((_node$firstElementChi = node.firstElementChild) !== null && _node$firstElementChi !== void 0 && _node$firstElementChi.matches("p")) {
|
|
1463
|
-
var _content$match$, _content$match, _content$match$2, _content$match2;
|
|
1464
|
-
const firstParagraph = node.firstElementChild;
|
|
1465
|
-
const {
|
|
1466
|
-
nextElementSibling
|
|
1467
|
-
} = firstParagraph;
|
|
1468
|
-
const startSpaces = (_content$match$ = (_content$match = content.match(/^\s+/)) === null || _content$match === void 0 ? void 0 : _content$match[0]) !== null && _content$match$ !== void 0 ? _content$match$ : "";
|
|
1469
|
-
const endSpaces = !nextElementSibling ? (_content$match$2 = (_content$match2 = content.match(/\s+$/)) === null || _content$match2 === void 0 ? void 0 : _content$match2[0]) !== null && _content$match$2 !== void 0 ? _content$match$2 : "" : "";
|
|
1470
|
-
if (content.match(/^\n\n/)) {
|
|
1471
|
-
firstParagraph.innerHTML = `${firstParagraph.innerHTML}${endSpaces}`;
|
|
1472
|
-
return;
|
|
1473
|
-
}
|
|
1474
|
-
unwrapElement(firstParagraph);
|
|
1475
|
-
node.innerHTML = `${startSpaces}${node.innerHTML}${endSpaces}`;
|
|
1476
|
-
}
|
|
1477
|
-
}
|
|
1478
|
-
/**
|
|
1479
|
-
* @param {markdownit} md
|
|
1480
|
-
*/
|
|
1481
|
-
withPatchedRenderer(md2) {
|
|
1482
|
-
const withoutNewLine = (renderer) => function() {
|
|
1483
|
-
const rendered = renderer(...arguments);
|
|
1484
|
-
if (rendered === "\n") {
|
|
1485
|
-
return rendered;
|
|
1486
|
-
}
|
|
1487
|
-
if (rendered[rendered.length - 1] === "\n") {
|
|
1488
|
-
return rendered.slice(0, -1);
|
|
1489
|
-
}
|
|
1490
|
-
return rendered;
|
|
1491
|
-
};
|
|
1492
|
-
md2.renderer.rules.hardbreak = withoutNewLine(md2.renderer.rules.hardbreak);
|
|
1493
|
-
md2.renderer.rules.softbreak = withoutNewLine(md2.renderer.rules.softbreak);
|
|
1494
|
-
md2.renderer.rules.fence = withoutNewLine(md2.renderer.rules.fence);
|
|
1495
|
-
md2.renderer.rules.code_block = withoutNewLine(md2.renderer.rules.code_block);
|
|
1496
|
-
md2.renderer.renderToken = withoutNewLine(md2.renderer.renderToken.bind(md2.renderer));
|
|
1497
|
-
return md2;
|
|
1498
|
-
}
|
|
1499
|
-
};
|
|
1500
|
-
var MarkdownClipboard = import_core8.Extension.create({
|
|
1501
|
-
name: "markdownClipboard",
|
|
1502
|
-
addOptions() {
|
|
1503
|
-
return {
|
|
1504
|
-
transformPastedText: false,
|
|
1505
|
-
transformCopiedText: false
|
|
1506
|
-
};
|
|
1507
|
-
},
|
|
1508
|
-
addProseMirrorPlugins() {
|
|
1509
|
-
return [new import_state4.Plugin({
|
|
1510
|
-
key: new import_state4.PluginKey("markdownClipboard"),
|
|
1511
|
-
props: {
|
|
1512
|
-
clipboardTextParser: (text, context, plainText) => {
|
|
1513
|
-
if (plainText || !this.options.transformPastedText) {
|
|
1514
|
-
return null;
|
|
1515
|
-
}
|
|
1516
|
-
const parsed = this.editor.storage.markdown.parser.parse(text, {
|
|
1517
|
-
inline: true
|
|
1518
|
-
});
|
|
1519
|
-
return import_model.DOMParser.fromSchema(this.editor.schema).parseSlice(elementFromString(parsed), {
|
|
1520
|
-
preserveWhitespace: true,
|
|
1521
|
-
context
|
|
1522
|
-
});
|
|
1523
|
-
},
|
|
1524
|
-
/**
|
|
1525
|
-
* @param {import('prosemirror-model').Slice} slice
|
|
1526
|
-
*/
|
|
1527
|
-
clipboardTextSerializer: (slice) => {
|
|
1528
|
-
if (!this.options.transformCopiedText) {
|
|
1529
|
-
return null;
|
|
1530
|
-
}
|
|
1531
|
-
return this.editor.storage.markdown.serializer.serialize(slice.content);
|
|
1532
|
-
}
|
|
1533
|
-
}
|
|
1534
|
-
})];
|
|
1535
|
-
}
|
|
1536
|
-
});
|
|
1537
|
-
var Markdown = import_core8.Extension.create({
|
|
1538
|
-
name: "markdown",
|
|
1539
|
-
priority: 50,
|
|
1540
|
-
addOptions() {
|
|
1541
|
-
return {
|
|
1542
|
-
html: true,
|
|
1543
|
-
tightLists: true,
|
|
1544
|
-
tightListClass: "tight",
|
|
1545
|
-
bulletListMarker: "-",
|
|
1546
|
-
linkify: false,
|
|
1547
|
-
breaks: false,
|
|
1548
|
-
transformPastedText: false,
|
|
1549
|
-
transformCopiedText: false
|
|
1550
|
-
};
|
|
1551
|
-
},
|
|
1552
|
-
addCommands() {
|
|
1553
|
-
const commands = import_core8.extensions.Commands.config.addCommands();
|
|
1554
|
-
return {
|
|
1555
|
-
setContent: (content, emitUpdate, parseOptions) => (props) => {
|
|
1556
|
-
return commands.setContent(props.editor.storage.markdown.parser.parse(content), emitUpdate, parseOptions)(props);
|
|
1557
|
-
},
|
|
1558
|
-
insertContentAt: (range, content, options) => (props) => {
|
|
1559
|
-
return commands.insertContentAt(range, props.editor.storage.markdown.parser.parse(content, {
|
|
1560
|
-
inline: true
|
|
1561
|
-
}), options)(props);
|
|
1562
|
-
}
|
|
1563
|
-
};
|
|
1564
|
-
},
|
|
1565
|
-
onBeforeCreate() {
|
|
1566
|
-
this.editor.storage.markdown = {
|
|
1567
|
-
options: {
|
|
1568
|
-
...this.options
|
|
1569
|
-
},
|
|
1570
|
-
parser: new MarkdownParser(this.editor, this.options),
|
|
1571
|
-
serializer: new MarkdownSerializer(this.editor),
|
|
1572
|
-
getMarkdown: () => {
|
|
1573
|
-
return this.editor.storage.markdown.serializer.serialize(this.editor.state.doc);
|
|
1574
|
-
}
|
|
1575
|
-
};
|
|
1576
|
-
this.editor.options.initialContent = this.editor.options.content;
|
|
1577
|
-
this.editor.options.content = this.editor.storage.markdown.parser.parse(this.editor.options.content);
|
|
1578
|
-
},
|
|
1579
|
-
onCreate() {
|
|
1580
|
-
this.editor.options.content = this.editor.options.initialContent;
|
|
1581
|
-
delete this.editor.options.initialContent;
|
|
1582
|
-
},
|
|
1583
|
-
addStorage() {
|
|
1584
|
-
return {
|
|
1585
|
-
/// storage will be defined in onBeforeCreate() to prevent initial object overriding
|
|
1586
|
-
};
|
|
1587
|
-
},
|
|
1588
|
-
addExtensions() {
|
|
1589
|
-
return [MarkdownTightLists.configure({
|
|
1590
|
-
tight: this.options.tightLists,
|
|
1591
|
-
tightClass: this.options.tightListClass
|
|
1592
|
-
}), MarkdownClipboard.configure({
|
|
1593
|
-
transformPastedText: this.options.transformPastedText,
|
|
1594
|
-
transformCopiedText: this.options.transformCopiedText
|
|
1595
|
-
})];
|
|
1596
|
-
}
|
|
1597
|
-
});
|
|
1598
15
|
|
|
1599
|
-
// src/extensions/markdown.ts
|
|
1600
|
-
var resolveExt = (mod, name) => mod?.[name] || mod?.default?.[name] || mod?.default?.default || mod?.default || mod;
|
|
1601
|
-
var Markdown2 = resolveExt(Markdown, "Markdown");
|
|
1602
16
|
|
|
1603
|
-
// src/extensions/image.ts
|
|
1604
|
-
var _Image = __toESM(require("@tiptap/extension-image"), 1);
|
|
1605
|
-
var import_state5 = require("@tiptap/pm/state");
|
|
1606
|
-
var resolveExt2 = (mod, name) => mod?.[name] || mod?.default?.[name] || mod?.default?.default || mod?.default || mod;
|
|
1607
|
-
var BaseImage = resolveExt2(_Image, "Image");
|
|
1608
|
-
var imagePastePluginKey = new import_state5.PluginKey("imagePasteHandler");
|
|
1609
|
-
function insertImageNode(view, src, alt) {
|
|
1610
|
-
const { schema } = view.state;
|
|
1611
|
-
const imageType = schema.nodes.image;
|
|
1612
|
-
if (!imageType) return;
|
|
1613
|
-
const node = imageType.create({ src, alt: alt || "" });
|
|
1614
|
-
const tr = view.state.tr.replaceSelectionWith(node);
|
|
1615
|
-
view.dispatch(tr);
|
|
1616
|
-
}
|
|
1617
|
-
function updateImageSrc(view, oldSrc, newSrc) {
|
|
1618
|
-
const { doc } = view.state;
|
|
1619
|
-
let foundPos = null;
|
|
1620
|
-
let foundAttrs = null;
|
|
1621
|
-
doc.descendants((node, pos) => {
|
|
1622
|
-
if (node.type.name === "image" && node.attrs.src === oldSrc) {
|
|
1623
|
-
foundPos = pos;
|
|
1624
|
-
foundAttrs = node.attrs;
|
|
1625
|
-
return false;
|
|
1626
|
-
}
|
|
1627
|
-
});
|
|
1628
|
-
if (foundPos !== null && foundAttrs) {
|
|
1629
|
-
const tr = view.state.tr.setNodeMarkup(foundPos, void 0, {
|
|
1630
|
-
...foundAttrs,
|
|
1631
|
-
src: newSrc
|
|
1632
|
-
});
|
|
1633
|
-
view.dispatch(tr);
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1636
|
-
function removeImageNode(view, src) {
|
|
1637
|
-
const { doc } = view.state;
|
|
1638
|
-
let foundPos = null;
|
|
1639
|
-
let nodeSize = 0;
|
|
1640
|
-
doc.descendants((node, pos) => {
|
|
1641
|
-
if (node.type.name === "image" && node.attrs.src === src) {
|
|
1642
|
-
foundPos = pos;
|
|
1643
|
-
nodeSize = node.nodeSize;
|
|
1644
|
-
return false;
|
|
1645
|
-
}
|
|
1646
|
-
});
|
|
1647
|
-
if (foundPos !== null) {
|
|
1648
|
-
const tr = view.state.tr.delete(foundPos, foundPos + nodeSize);
|
|
1649
|
-
view.dispatch(tr);
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
|
-
function handleImageInsertion(view, file, options) {
|
|
1653
|
-
if (typeof options.upload === "function") {
|
|
1654
|
-
const hasObjectUrl = typeof URL !== "undefined" && typeof URL.createObjectURL === "function";
|
|
1655
|
-
const tempUrl = hasObjectUrl ? URL.createObjectURL(file) : null;
|
|
1656
|
-
if (tempUrl) {
|
|
1657
|
-
insertImageNode(view, tempUrl, file.name);
|
|
1658
|
-
}
|
|
1659
|
-
Promise.resolve(options.upload(file)).then((uploadedUrl) => {
|
|
1660
|
-
if (!uploadedUrl) {
|
|
1661
|
-
throw new Error("Upload handler returned empty URL");
|
|
1662
|
-
}
|
|
1663
|
-
if (tempUrl) {
|
|
1664
|
-
updateImageSrc(view, tempUrl, uploadedUrl);
|
|
1665
|
-
if (typeof URL.revokeObjectURL === "function") {
|
|
1666
|
-
URL.revokeObjectURL(tempUrl);
|
|
1667
|
-
}
|
|
1668
|
-
} else {
|
|
1669
|
-
insertImageNode(view, uploadedUrl, file.name);
|
|
1670
|
-
}
|
|
1671
|
-
}).catch((err) => {
|
|
1672
|
-
const error = err instanceof Error ? err : new Error(String(err));
|
|
1673
|
-
console.error("Failed to upload pasted image:", error);
|
|
1674
|
-
if (tempUrl) {
|
|
1675
|
-
removeImageNode(view, tempUrl);
|
|
1676
|
-
if (typeof URL.revokeObjectURL === "function") {
|
|
1677
|
-
URL.revokeObjectURL(tempUrl);
|
|
1678
|
-
}
|
|
1679
|
-
}
|
|
1680
|
-
if (typeof options.onUploadError === "function") {
|
|
1681
|
-
options.onUploadError(error, file);
|
|
1682
|
-
}
|
|
1683
|
-
});
|
|
1684
|
-
} else if (options.allowBase64 !== false) {
|
|
1685
|
-
const maxBase64Size = options.maxBase64Size ?? 65536;
|
|
1686
|
-
if (file.size > maxBase64Size) {
|
|
1687
|
-
const err = new Error(
|
|
1688
|
-
`Image size (${Math.round(file.size / 1024)}KB) exceeds maxBase64Size (${Math.round(
|
|
1689
|
-
maxBase64Size / 1024
|
|
1690
|
-
)}KB). Provide an upload handler to support large images.`
|
|
1691
|
-
);
|
|
1692
|
-
console.warn(`[Editor] ${err.message}`);
|
|
1693
|
-
if (typeof options.onUploadError === "function") {
|
|
1694
|
-
options.onUploadError(err, file);
|
|
1695
|
-
}
|
|
1696
|
-
return;
|
|
1697
|
-
}
|
|
1698
|
-
if (typeof FileReader !== "undefined") {
|
|
1699
|
-
const reader = new FileReader();
|
|
1700
|
-
reader.onload = () => {
|
|
1701
|
-
const src = reader.result;
|
|
1702
|
-
if (src) {
|
|
1703
|
-
insertImageNode(view, src, file.name);
|
|
1704
|
-
}
|
|
1705
|
-
};
|
|
1706
|
-
reader.readAsDataURL(file);
|
|
1707
|
-
}
|
|
1708
|
-
}
|
|
1709
|
-
}
|
|
1710
|
-
var Image2 = BaseImage.extend({
|
|
1711
|
-
addOptions() {
|
|
1712
|
-
return {
|
|
1713
|
-
...this.parent?.(),
|
|
1714
|
-
allowBase64: true,
|
|
1715
|
-
maxBase64Size: 65536,
|
|
1716
|
-
enablePaste: true,
|
|
1717
|
-
enableDrop: true,
|
|
1718
|
-
upload: void 0,
|
|
1719
|
-
onUploadError: void 0,
|
|
1720
|
-
HTMLAttributes: {
|
|
1721
|
-
class: "rounded-md max-w-full h-auto my-2"
|
|
1722
|
-
}
|
|
1723
|
-
};
|
|
1724
|
-
},
|
|
1725
|
-
addProseMirrorPlugins() {
|
|
1726
|
-
const parentPlugins = this.parent?.() || [];
|
|
1727
|
-
const options = this.options;
|
|
1728
|
-
if (!options.enablePaste && !options.enableDrop) {
|
|
1729
|
-
return parentPlugins;
|
|
1730
|
-
}
|
|
1731
|
-
const pastePlugin = new import_state5.Plugin({
|
|
1732
|
-
key: imagePastePluginKey,
|
|
1733
|
-
props: {
|
|
1734
|
-
handlePaste(view, event) {
|
|
1735
|
-
if (!options.enablePaste) return false;
|
|
1736
|
-
const items = Array.from(event.clipboardData?.items || []);
|
|
1737
|
-
const imageItems = items.filter(
|
|
1738
|
-
(item) => item.kind === "file" && item.type.startsWith("image/")
|
|
1739
|
-
);
|
|
1740
|
-
if (imageItems.length === 0) return false;
|
|
1741
|
-
event.preventDefault();
|
|
1742
|
-
for (const item of imageItems) {
|
|
1743
|
-
const file = item.getAsFile();
|
|
1744
|
-
if (!file) continue;
|
|
1745
|
-
handleImageInsertion(view, file, options);
|
|
1746
|
-
}
|
|
1747
|
-
return true;
|
|
1748
|
-
},
|
|
1749
|
-
handleDrop(view, event) {
|
|
1750
|
-
if (!options.enableDrop) return false;
|
|
1751
|
-
const files = Array.from(event.dataTransfer?.files || []);
|
|
1752
|
-
const imageFiles = files.filter((f) => f.type.startsWith("image/"));
|
|
1753
|
-
if (imageFiles.length === 0) return false;
|
|
1754
|
-
event.preventDefault();
|
|
1755
|
-
for (const file of imageFiles) {
|
|
1756
|
-
handleImageInsertion(view, file, options);
|
|
1757
|
-
}
|
|
1758
|
-
return true;
|
|
1759
|
-
}
|
|
1760
|
-
}
|
|
1761
|
-
});
|
|
1762
|
-
return [...parentPlugins, pastePlugin];
|
|
1763
|
-
}
|
|
1764
|
-
});
|
|
1765
17
|
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
var
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
StarterKit.configure({
|
|
1791
|
-
orderedList: {
|
|
1792
|
-
HTMLAttributes: {
|
|
1793
|
-
class: "list-decimal pl-4"
|
|
1794
|
-
}
|
|
1795
|
-
},
|
|
1796
|
-
bulletList: {
|
|
1797
|
-
HTMLAttributes: {
|
|
1798
|
-
class: "list-disc pl-4"
|
|
1799
|
-
}
|
|
1800
|
-
},
|
|
1801
|
-
heading: {
|
|
1802
|
-
levels: headingLevels,
|
|
1803
|
-
HTMLAttributes: {
|
|
1804
|
-
class: "font-bold tracking-tight"
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
}),
|
|
1808
|
-
TextStyle,
|
|
1809
|
-
Color,
|
|
1810
|
-
Highlight.configure({ multicolor: true }),
|
|
1811
|
-
Underline,
|
|
1812
|
-
Typography,
|
|
1813
|
-
TextAlign.configure({
|
|
1814
|
-
types: ["heading", "paragraph"]
|
|
1815
|
-
}),
|
|
1816
|
-
Link2.extend({
|
|
1817
|
-
addInputRules() {
|
|
1818
|
-
return [
|
|
1819
|
-
(0, import_core9.markInputRule)({
|
|
1820
|
-
find: /(?:^|\s)\[([^\]]+)\]\(([^)]+)\)$/,
|
|
1821
|
-
type: this.type,
|
|
1822
|
-
getAttributes: (match) => ({
|
|
1823
|
-
href: match[2]
|
|
1824
|
-
})
|
|
1825
|
-
})
|
|
1826
|
-
];
|
|
1827
|
-
}
|
|
1828
|
-
}).configure({
|
|
1829
|
-
openOnClick: openLinksOnClick,
|
|
1830
|
-
autolink: true,
|
|
1831
|
-
defaultProtocol: "https",
|
|
1832
|
-
protocols: ["file", "vscode", "cursor"],
|
|
1833
|
-
HTMLAttributes: {
|
|
1834
|
-
target: "_blank",
|
|
1835
|
-
rel: "noopener noreferrer",
|
|
1836
|
-
class: "text-blue-500 underline underline-offset-2"
|
|
1837
|
-
}
|
|
1838
|
-
}),
|
|
1839
|
-
TaskList2,
|
|
1840
|
-
TaskItem2.extend({
|
|
1841
|
-
addInputRules() {
|
|
1842
|
-
return [
|
|
1843
|
-
(0, import_core9.wrappingInputRule)({
|
|
1844
|
-
find: /^\s*(\[([ |x])?\])\s$/i,
|
|
1845
|
-
type: this.type,
|
|
1846
|
-
getAttributes: (match) => ({
|
|
1847
|
-
checked: match[2]?.toLowerCase() === "x"
|
|
1848
|
-
})
|
|
1849
|
-
})
|
|
1850
|
-
];
|
|
1851
|
-
}
|
|
1852
|
-
}).configure({
|
|
1853
|
-
nested: true
|
|
1854
|
-
}),
|
|
1855
|
-
FontSize,
|
|
1856
|
-
Placeholder.configure({
|
|
1857
|
-
emptyEditorClass: "is-empty",
|
|
1858
|
-
placeholder: typeof placeholder === "function" ? placeholder : () => placeholder
|
|
1859
|
-
})
|
|
1860
|
-
];
|
|
1861
|
-
if (characterLimit) {
|
|
1862
|
-
extensions2.push(
|
|
1863
|
-
CharacterCount.configure({
|
|
1864
|
-
limit: characterLimit
|
|
1865
|
-
})
|
|
1866
|
-
);
|
|
1867
|
-
}
|
|
1868
|
-
if (enableSmilies) {
|
|
1869
|
-
extensions2.push(SmilieReplacer);
|
|
1870
|
-
}
|
|
1871
|
-
if (enableColorHighlighter) {
|
|
1872
|
-
extensions2.push(ColorHighlighter);
|
|
1873
|
-
}
|
|
1874
|
-
if (options.mention) {
|
|
1875
|
-
const mentionConfig = typeof options.mention === "object" ? options.mention : {};
|
|
1876
|
-
extensions2.push(
|
|
1877
|
-
Mention.configure({
|
|
1878
|
-
HTMLAttributes: {
|
|
1879
|
-
class: "pixerate-mention-node",
|
|
1880
|
-
...mentionConfig.HTMLAttributes || {}
|
|
1881
|
-
},
|
|
1882
|
-
...mentionConfig
|
|
1883
|
-
})
|
|
1884
|
-
);
|
|
1885
|
-
}
|
|
1886
|
-
if (options.markdown) {
|
|
1887
|
-
const markdownConfig = typeof options.markdown === "object" ? options.markdown : {};
|
|
1888
|
-
extensions2.push(
|
|
1889
|
-
Markdown2.configure({
|
|
1890
|
-
html: true,
|
|
1891
|
-
tightLists: true,
|
|
1892
|
-
tightListClass: "tight",
|
|
1893
|
-
bulletListMarker: "-",
|
|
1894
|
-
linkify: true,
|
|
1895
|
-
breaks: true,
|
|
1896
|
-
transformPastedText: true,
|
|
1897
|
-
transformCopiedText: true,
|
|
1898
|
-
...markdownConfig
|
|
1899
|
-
})
|
|
1900
|
-
);
|
|
1901
|
-
}
|
|
1902
|
-
if (options.image !== false) {
|
|
1903
|
-
const imageConfig = typeof options.image === "object" ? options.image : {};
|
|
1904
|
-
extensions2.push(
|
|
1905
|
-
Image2.configure({
|
|
1906
|
-
HTMLAttributes: {
|
|
1907
|
-
class: "rounded-md max-w-full h-auto my-2",
|
|
1908
|
-
...imageConfig.HTMLAttributes || {}
|
|
1909
|
-
},
|
|
1910
|
-
...imageConfig
|
|
1911
|
-
})
|
|
1912
|
-
);
|
|
1913
|
-
}
|
|
1914
|
-
return extensions2;
|
|
1915
|
-
}
|
|
1916
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
1917
|
-
0 && (module.exports = {
|
|
1918
|
-
ColorHighlighter,
|
|
1919
|
-
FontSize,
|
|
1920
|
-
GradientText,
|
|
1921
|
-
Image,
|
|
1922
|
-
LoadingNode,
|
|
1923
|
-
Markdown,
|
|
1924
|
-
Mention,
|
|
1925
|
-
SlashCommands,
|
|
1926
|
-
SmilieReplacer,
|
|
1927
|
-
TemplateSuggestions,
|
|
1928
|
-
createMentionExtension,
|
|
1929
|
-
createRichTextPreset,
|
|
1930
|
-
findHexColors,
|
|
1931
|
-
handleImageInsertion,
|
|
1932
|
-
imagePastePluginKey,
|
|
1933
|
-
insertImageNode,
|
|
1934
|
-
removeImageNode,
|
|
1935
|
-
updateImageSrc
|
|
1936
|
-
});
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
var _chunkLDES3EOScjs = require('../chunk-LDES3EOS.cjs');
|
|
21
|
+
require('../chunk-SEDR75VH.cjs');
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
exports.ColorHighlighter = _chunkLDES3EOScjs.ColorHighlighter; exports.FontSize = _chunkLDES3EOScjs.FontSize; exports.GradientText = _chunkLDES3EOScjs.GradientText; exports.Image = _chunkLDES3EOScjs.Image; exports.LoadingNode = _chunkLDES3EOScjs.LoadingNode; exports.Markdown = _chunkLDES3EOScjs.Markdown; exports.Mention = _chunkLDES3EOScjs.Mention; exports.SlashCommands = _chunkLDES3EOScjs.SlashCommands; exports.SmilieReplacer = _chunkLDES3EOScjs.SmilieReplacer; exports.TemplateSuggestions = _chunkLDES3EOScjs.TemplateSuggestions; exports.createMentionExtension = _chunkLDES3EOScjs.createMentionExtension; exports.createRichTextPreset = _chunkLDES3EOScjs.createRichTextPreset; exports.findHexColors = _chunkLDES3EOScjs.findHexColors; exports.handleImageInsertion = _chunkLDES3EOScjs.handleImageInsertion; exports.imagePastePluginKey = _chunkLDES3EOScjs.imagePastePluginKey; exports.insertImageNode = _chunkLDES3EOScjs.insertImageNode; exports.removeImageNode = _chunkLDES3EOScjs.removeImageNode; exports.updateImageSrc = _chunkLDES3EOScjs.updateImageSrc;
|
|
1937
42
|
//# sourceMappingURL=index.cjs.map
|