@threadlabs/looma 0.43.1 → 0.44.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/components/ui-callout/ui-callout.html +4 -4
- package/components/ui-dialog/ui-dialog.html +0 -4
- package/components/ui-editor-footnote-editor/ui-editor-footnote-editor.html +4 -50
- package/components/ui-editor-footnote-editor/ui-editor-footnote-editor.js +10 -31
- package/components/ui-site-header/ui-site-header.html +1 -1
- package/dist/index.js +1 -1
- package/docs/README.md +19 -3
- package/docs/card.html +1 -1
- package/docs/catalog-view.js +11 -5
- package/docs/catalog-view.mjs +4 -3
- package/docs/catalog.json +76 -112
- package/docs/catalog.mjs +1 -1
- package/docs/customizer-render.mjs +9 -8
- package/docs/customizer.js +8 -8
- package/docs/documentation.css +2 -2
- package/docs/examples/ui-editor-footnote-editor/examples/01-note.behavior.js +9 -0
- package/docs/fonts.mjs +1 -1
- package/docs/index.mjs +1 -1
- package/docs/render.mjs +1 -1
- package/docs/site.mjs +14 -5
- package/docs/theme.mjs +96 -16
- package/editor/chunks/extensions.js +10 -0
- package/editor/extensions/footnote.d.ts +1 -0
- package/editor/footnote-editing.d.ts +16 -27
- package/package.json +2 -2
- package/styles/ui-callout.css +4 -4
- package/styles/ui-dialog.css +0 -8
- package/styles/ui-site-header.css +1 -1
- package/theme-dark.css +9 -9
- package/theme-high-contrast.css +4 -0
- package/theme-light.css +6 -6
- package/tokens.css +20 -18
- package/vanilla/UiEditorFootnoteEditor.d.ts +0 -5
- package/vanilla/UiEditorFootnoteEditor.js +20 -68
- package/vue/UiCallout.vue +4 -4
- package/vue/UiDialog.vue +0 -7
- package/vue/UiEditorFootnoteEditor.d.ts +11 -29
- package/vue/UiEditorFootnoteEditor.vue +21 -173
- package/vue/UiSiteHeader.vue +1 -1
- package/vue/chunks/UiCallout.js +1 -1
- package/vue/chunks/UiDialog.js +1 -1
- package/vue/chunks/UiEditorFootnoteEditor.js +34 -226
- package/vue/chunks/UiEditorImageToolbar.js +1 -1
- package/vue/chunks/UiEditorLinkForm.js +1 -1
- package/vue/chunks/UiSiteHeader.js +1 -1
- package/vue/chunks/compact.js +565 -0
- package/vue/components.css +321 -328
- package/vue/editor/LoomaEditor.d.ts +2 -2
- package/vue/editor/compact/index.js +1 -562
- package/vue/editor/index.js +173 -80
- package/vue/index.js +2 -2
|
@@ -395,8 +395,8 @@ export declare const LoomaEditor: import("vue").DefineComponent<import("vue").Ex
|
|
|
395
395
|
}>> & Readonly<{
|
|
396
396
|
onUpdate?: ((_value: JSONContent) => any) | undefined;
|
|
397
397
|
"onUpdate:modelValue"?: ((_value: JSONContent) => any) | undefined;
|
|
398
|
-
"onUpdate:toolbarOpen"?: ((_value: boolean) => any) | undefined;
|
|
399
398
|
onReady?: ((_editor: Editor) => any) | undefined;
|
|
399
|
+
"onUpdate:toolbarOpen"?: ((_value: boolean) => any) | undefined;
|
|
400
400
|
onSelectionAction?: ((_detail: LoomaEditorSelectionActionDetail) => any) | undefined;
|
|
401
401
|
onRangeAction?: ((_detail: LoomaEditorRangeActionDetail) => any) | undefined;
|
|
402
402
|
onUploadError?: ((_error: unknown, _file: File) => any) | undefined;
|
|
@@ -412,13 +412,13 @@ export declare const LoomaEditor: import("vue").DefineComponent<import("vue").Ex
|
|
|
412
412
|
codeLanguages: Readonly<Record<string, import("highlight.js").LanguageFn>> | null;
|
|
413
413
|
references: Readonly<Record<string, import("@threadlabs/looma/editor").LoomaReferenceDisplay>> | undefined;
|
|
414
414
|
toolbarOpen: boolean;
|
|
415
|
+
modelValue: JSONContent;
|
|
415
416
|
slashCommands: LoomaEditorSlashCommands | undefined;
|
|
416
417
|
mentionQuery: LoomaMentionQuery | undefined;
|
|
417
418
|
linkSearch: LoomaLinkSearch | undefined;
|
|
418
419
|
linkResolve: LoomaLinkResolve | undefined;
|
|
419
420
|
imageUpload: LoomaImageUploader | undefined;
|
|
420
421
|
fileUpload: LoomaFileUploader | undefined;
|
|
421
|
-
modelValue: JSONContent;
|
|
422
422
|
contentDensity: "comfortable" | "compact";
|
|
423
423
|
mentionItems: LoomaMentionItem[];
|
|
424
424
|
mentionLimit: number;
|
|
@@ -1,563 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Extension, Mark, Node, markInputRule, markPasteRule, mergeAttributes } from "@tiptap/core";
|
|
3
|
-
import { Editor as Editor$1, EditorContent } from "@tiptap/vue-3";
|
|
4
|
-
import { Plugin } from "@tiptap/pm/state";
|
|
5
|
-
import { closeHistory, history, redo, undo } from "@tiptap/pm/history";
|
|
6
|
-
//#region ../../node_modules/.pnpm/@tiptap+extension-document@2.27.2_@tiptap+core@2.27.2_@tiptap+pm@2.27.2_/node_modules/@tiptap/extension-document/dist/index.js
|
|
7
|
-
/**
|
|
8
|
-
* The default document node which represents the top level node of the editor.
|
|
9
|
-
* @see https://tiptap.dev/api/nodes/document
|
|
10
|
-
*/
|
|
11
|
-
var Document = Node.create({
|
|
12
|
-
name: "doc",
|
|
13
|
-
topNode: true,
|
|
14
|
-
content: "block+"
|
|
15
|
-
});
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region ../../node_modules/.pnpm/@tiptap+extension-paragraph@2.27.2_@tiptap+core@2.27.2_@tiptap+pm@2.27.2_/node_modules/@tiptap/extension-paragraph/dist/index.js
|
|
18
|
-
/**
|
|
19
|
-
* This extension allows you to create paragraphs.
|
|
20
|
-
* @see https://www.tiptap.dev/api/nodes/paragraph
|
|
21
|
-
*/
|
|
22
|
-
var Paragraph = Node.create({
|
|
23
|
-
name: "paragraph",
|
|
24
|
-
priority: 1e3,
|
|
25
|
-
addOptions() {
|
|
26
|
-
return { HTMLAttributes: {} };
|
|
27
|
-
},
|
|
28
|
-
group: "block",
|
|
29
|
-
content: "inline*",
|
|
30
|
-
parseHTML() {
|
|
31
|
-
return [{ tag: "p" }];
|
|
32
|
-
},
|
|
33
|
-
renderHTML({ HTMLAttributes }) {
|
|
34
|
-
return [
|
|
35
|
-
"p",
|
|
36
|
-
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
37
|
-
0
|
|
38
|
-
];
|
|
39
|
-
},
|
|
40
|
-
addCommands() {
|
|
41
|
-
return { setParagraph: () => ({ commands }) => {
|
|
42
|
-
return commands.setNode(this.name);
|
|
43
|
-
} };
|
|
44
|
-
},
|
|
45
|
-
addKeyboardShortcuts() {
|
|
46
|
-
return { "Mod-Alt-0": () => this.editor.commands.setParagraph() };
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
//#endregion
|
|
50
|
-
//#region ../../node_modules/.pnpm/@tiptap+extension-text@2.27.2_@tiptap+core@2.27.2_@tiptap+pm@2.27.2_/node_modules/@tiptap/extension-text/dist/index.js
|
|
51
|
-
/**
|
|
52
|
-
* This extension allows you to create text nodes.
|
|
53
|
-
* @see https://www.tiptap.dev/api/nodes/text
|
|
54
|
-
*/
|
|
55
|
-
var Text = Node.create({
|
|
56
|
-
name: "text",
|
|
57
|
-
group: "inline"
|
|
58
|
-
});
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region ../../node_modules/.pnpm/@tiptap+extension-bold@2.27.2_@tiptap+core@2.27.2_@tiptap+pm@2.27.2_/node_modules/@tiptap/extension-bold/dist/index.js
|
|
61
|
-
/**
|
|
62
|
-
* Matches bold text via `**` as input.
|
|
63
|
-
*/
|
|
64
|
-
var starInputRegex$1 = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/;
|
|
65
|
-
/**
|
|
66
|
-
* Matches bold text via `**` while pasting.
|
|
67
|
-
*/
|
|
68
|
-
var starPasteRegex$1 = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g;
|
|
69
|
-
/**
|
|
70
|
-
* Matches bold text via `__` as input.
|
|
71
|
-
*/
|
|
72
|
-
var underscoreInputRegex$1 = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/;
|
|
73
|
-
/**
|
|
74
|
-
* Matches bold text via `__` while pasting.
|
|
75
|
-
*/
|
|
76
|
-
var underscorePasteRegex$1 = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g;
|
|
77
|
-
/**
|
|
78
|
-
* This extension allows you to mark text as bold.
|
|
79
|
-
* @see https://tiptap.dev/api/marks/bold
|
|
80
|
-
*/
|
|
81
|
-
var Bold = Mark.create({
|
|
82
|
-
name: "bold",
|
|
83
|
-
addOptions() {
|
|
84
|
-
return { HTMLAttributes: {} };
|
|
85
|
-
},
|
|
86
|
-
parseHTML() {
|
|
87
|
-
return [
|
|
88
|
-
{ tag: "strong" },
|
|
89
|
-
{
|
|
90
|
-
tag: "b",
|
|
91
|
-
getAttrs: (node) => node.style.fontWeight !== "normal" && null
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
style: "font-weight=400",
|
|
95
|
-
clearMark: (mark) => mark.type.name === this.name
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
style: "font-weight",
|
|
99
|
-
getAttrs: (value) => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null
|
|
100
|
-
}
|
|
101
|
-
];
|
|
102
|
-
},
|
|
103
|
-
renderHTML({ HTMLAttributes }) {
|
|
104
|
-
return [
|
|
105
|
-
"strong",
|
|
106
|
-
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
107
|
-
0
|
|
108
|
-
];
|
|
109
|
-
},
|
|
110
|
-
addCommands() {
|
|
111
|
-
return {
|
|
112
|
-
setBold: () => ({ commands }) => {
|
|
113
|
-
return commands.setMark(this.name);
|
|
114
|
-
},
|
|
115
|
-
toggleBold: () => ({ commands }) => {
|
|
116
|
-
return commands.toggleMark(this.name);
|
|
117
|
-
},
|
|
118
|
-
unsetBold: () => ({ commands }) => {
|
|
119
|
-
return commands.unsetMark(this.name);
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
},
|
|
123
|
-
addKeyboardShortcuts() {
|
|
124
|
-
return {
|
|
125
|
-
"Mod-b": () => this.editor.commands.toggleBold(),
|
|
126
|
-
"Mod-B": () => this.editor.commands.toggleBold()
|
|
127
|
-
};
|
|
128
|
-
},
|
|
129
|
-
addInputRules() {
|
|
130
|
-
return [markInputRule({
|
|
131
|
-
find: starInputRegex$1,
|
|
132
|
-
type: this.type
|
|
133
|
-
}), markInputRule({
|
|
134
|
-
find: underscoreInputRegex$1,
|
|
135
|
-
type: this.type
|
|
136
|
-
})];
|
|
137
|
-
},
|
|
138
|
-
addPasteRules() {
|
|
139
|
-
return [markPasteRule({
|
|
140
|
-
find: starPasteRegex$1,
|
|
141
|
-
type: this.type
|
|
142
|
-
}), markPasteRule({
|
|
143
|
-
find: underscorePasteRegex$1,
|
|
144
|
-
type: this.type
|
|
145
|
-
})];
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
//#endregion
|
|
149
|
-
//#region ../../node_modules/.pnpm/@tiptap+extension-italic@2.27.2_@tiptap+core@2.27.2_@tiptap+pm@2.27.2_/node_modules/@tiptap/extension-italic/dist/index.js
|
|
150
|
-
/**
|
|
151
|
-
* Matches an italic to a *italic* on input.
|
|
152
|
-
*/
|
|
153
|
-
var starInputRegex = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/;
|
|
154
|
-
/**
|
|
155
|
-
* Matches an italic to a *italic* on paste.
|
|
156
|
-
*/
|
|
157
|
-
var starPasteRegex = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g;
|
|
158
|
-
/**
|
|
159
|
-
* Matches an italic to a _italic_ on input.
|
|
160
|
-
*/
|
|
161
|
-
var underscoreInputRegex = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/;
|
|
162
|
-
/**
|
|
163
|
-
* Matches an italic to a _italic_ on paste.
|
|
164
|
-
*/
|
|
165
|
-
var underscorePasteRegex = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g;
|
|
166
|
-
/**
|
|
167
|
-
* This extension allows you to create italic text.
|
|
168
|
-
* @see https://www.tiptap.dev/api/marks/italic
|
|
169
|
-
*/
|
|
170
|
-
var Italic = Mark.create({
|
|
171
|
-
name: "italic",
|
|
172
|
-
addOptions() {
|
|
173
|
-
return { HTMLAttributes: {} };
|
|
174
|
-
},
|
|
175
|
-
parseHTML() {
|
|
176
|
-
return [
|
|
177
|
-
{ tag: "em" },
|
|
178
|
-
{
|
|
179
|
-
tag: "i",
|
|
180
|
-
getAttrs: (node) => node.style.fontStyle !== "normal" && null
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
style: "font-style=normal",
|
|
184
|
-
clearMark: (mark) => mark.type.name === this.name
|
|
185
|
-
},
|
|
186
|
-
{ style: "font-style=italic" }
|
|
187
|
-
];
|
|
188
|
-
},
|
|
189
|
-
renderHTML({ HTMLAttributes }) {
|
|
190
|
-
return [
|
|
191
|
-
"em",
|
|
192
|
-
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
193
|
-
0
|
|
194
|
-
];
|
|
195
|
-
},
|
|
196
|
-
addCommands() {
|
|
197
|
-
return {
|
|
198
|
-
setItalic: () => ({ commands }) => {
|
|
199
|
-
return commands.setMark(this.name);
|
|
200
|
-
},
|
|
201
|
-
toggleItalic: () => ({ commands }) => {
|
|
202
|
-
return commands.toggleMark(this.name);
|
|
203
|
-
},
|
|
204
|
-
unsetItalic: () => ({ commands }) => {
|
|
205
|
-
return commands.unsetMark(this.name);
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
},
|
|
209
|
-
addKeyboardShortcuts() {
|
|
210
|
-
return {
|
|
211
|
-
"Mod-i": () => this.editor.commands.toggleItalic(),
|
|
212
|
-
"Mod-I": () => this.editor.commands.toggleItalic()
|
|
213
|
-
};
|
|
214
|
-
},
|
|
215
|
-
addInputRules() {
|
|
216
|
-
return [markInputRule({
|
|
217
|
-
find: starInputRegex,
|
|
218
|
-
type: this.type
|
|
219
|
-
}), markInputRule({
|
|
220
|
-
find: underscoreInputRegex,
|
|
221
|
-
type: this.type
|
|
222
|
-
})];
|
|
223
|
-
},
|
|
224
|
-
addPasteRules() {
|
|
225
|
-
return [markPasteRule({
|
|
226
|
-
find: starPasteRegex,
|
|
227
|
-
type: this.type
|
|
228
|
-
}), markPasteRule({
|
|
229
|
-
find: underscorePasteRegex,
|
|
230
|
-
type: this.type
|
|
231
|
-
})];
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
//#endregion
|
|
235
|
-
//#region ../../node_modules/.pnpm/@tiptap+extension-code@2.27.2_@tiptap+core@2.27.2_@tiptap+pm@2.27.2_/node_modules/@tiptap/extension-code/dist/index.js
|
|
236
|
-
/**
|
|
237
|
-
* Regular expressions to match inline code blocks enclosed in backticks.
|
|
238
|
-
* It matches:
|
|
239
|
-
* - An opening backtick, followed by
|
|
240
|
-
* - Any text that doesn't include a backtick (captured for marking), followed by
|
|
241
|
-
* - A closing backtick.
|
|
242
|
-
* This ensures that any text between backticks is formatted as code,
|
|
243
|
-
* regardless of the surrounding characters (exception being another backtick).
|
|
244
|
-
*/
|
|
245
|
-
var inputRegex = /(^|[^`])`([^`]+)`(?!`)/;
|
|
246
|
-
/**
|
|
247
|
-
* Matches inline code while pasting.
|
|
248
|
-
*/
|
|
249
|
-
var pasteRegex = /(^|[^`])`([^`]+)`(?!`)/g;
|
|
250
|
-
/**
|
|
251
|
-
* This extension allows you to mark text as inline code.
|
|
252
|
-
* @see https://tiptap.dev/api/marks/code
|
|
253
|
-
*/
|
|
254
|
-
var Code = Mark.create({
|
|
255
|
-
name: "code",
|
|
256
|
-
addOptions() {
|
|
257
|
-
return { HTMLAttributes: {} };
|
|
258
|
-
},
|
|
259
|
-
excludes: "_",
|
|
260
|
-
code: true,
|
|
261
|
-
exitable: true,
|
|
262
|
-
parseHTML() {
|
|
263
|
-
return [{ tag: "code" }];
|
|
264
|
-
},
|
|
265
|
-
renderHTML({ HTMLAttributes }) {
|
|
266
|
-
return [
|
|
267
|
-
"code",
|
|
268
|
-
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
269
|
-
0
|
|
270
|
-
];
|
|
271
|
-
},
|
|
272
|
-
addCommands() {
|
|
273
|
-
return {
|
|
274
|
-
setCode: () => ({ commands }) => {
|
|
275
|
-
return commands.setMark(this.name);
|
|
276
|
-
},
|
|
277
|
-
toggleCode: () => ({ commands }) => {
|
|
278
|
-
return commands.toggleMark(this.name);
|
|
279
|
-
},
|
|
280
|
-
unsetCode: () => ({ commands }) => {
|
|
281
|
-
return commands.unsetMark(this.name);
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
},
|
|
285
|
-
addKeyboardShortcuts() {
|
|
286
|
-
return { "Mod-e": () => this.editor.commands.toggleCode() };
|
|
287
|
-
},
|
|
288
|
-
addInputRules() {
|
|
289
|
-
return [markInputRule({
|
|
290
|
-
find: inputRegex,
|
|
291
|
-
type: this.type
|
|
292
|
-
})];
|
|
293
|
-
},
|
|
294
|
-
addPasteRules() {
|
|
295
|
-
return [markPasteRule({
|
|
296
|
-
find: pasteRegex,
|
|
297
|
-
type: this.type
|
|
298
|
-
})];
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
//#endregion
|
|
302
|
-
//#region ../../node_modules/.pnpm/@tiptap+extension-hard-break@2.27.2_@tiptap+core@2.27.2_@tiptap+pm@2.27.2_/node_modules/@tiptap/extension-hard-break/dist/index.js
|
|
303
|
-
/**
|
|
304
|
-
* This extension allows you to insert hard breaks.
|
|
305
|
-
* @see https://www.tiptap.dev/api/nodes/hard-break
|
|
306
|
-
*/
|
|
307
|
-
var HardBreak = Node.create({
|
|
308
|
-
name: "hardBreak",
|
|
309
|
-
addOptions() {
|
|
310
|
-
return {
|
|
311
|
-
keepMarks: true,
|
|
312
|
-
HTMLAttributes: {}
|
|
313
|
-
};
|
|
314
|
-
},
|
|
315
|
-
inline: true,
|
|
316
|
-
group: "inline",
|
|
317
|
-
selectable: false,
|
|
318
|
-
linebreakReplacement: true,
|
|
319
|
-
parseHTML() {
|
|
320
|
-
return [{ tag: "br" }];
|
|
321
|
-
},
|
|
322
|
-
renderHTML({ HTMLAttributes }) {
|
|
323
|
-
return ["br", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
|
|
324
|
-
},
|
|
325
|
-
renderText() {
|
|
326
|
-
return "\n";
|
|
327
|
-
},
|
|
328
|
-
addCommands() {
|
|
329
|
-
return { setHardBreak: () => ({ commands, chain, state, editor }) => {
|
|
330
|
-
return commands.first([() => commands.exitCode(), () => commands.command(() => {
|
|
331
|
-
const { selection, storedMarks } = state;
|
|
332
|
-
if (selection.$from.parent.type.spec.isolating) return false;
|
|
333
|
-
const { keepMarks } = this.options;
|
|
334
|
-
const { splittableMarks } = editor.extensionManager;
|
|
335
|
-
const marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();
|
|
336
|
-
return chain().insertContent({ type: this.name }).command(({ tr, dispatch }) => {
|
|
337
|
-
if (dispatch && marks && keepMarks) {
|
|
338
|
-
const filteredMarks = marks.filter((mark) => splittableMarks.includes(mark.type.name));
|
|
339
|
-
tr.ensureMarks(filteredMarks);
|
|
340
|
-
}
|
|
341
|
-
return true;
|
|
342
|
-
}).run();
|
|
343
|
-
})]);
|
|
344
|
-
} };
|
|
345
|
-
},
|
|
346
|
-
addKeyboardShortcuts() {
|
|
347
|
-
return {
|
|
348
|
-
"Mod-Enter": () => this.editor.commands.setHardBreak(),
|
|
349
|
-
"Shift-Enter": () => this.editor.commands.setHardBreak()
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
//#endregion
|
|
354
|
-
//#region ../../node_modules/.pnpm/@tiptap+extension-history@2.27.2_@tiptap+core@2.27.2_@tiptap+pm@2.27.2__@tiptap+pm@2.27.2/node_modules/@tiptap/extension-history/dist/index.js
|
|
355
|
-
/**
|
|
356
|
-
* This extension allows you to undo and redo recent changes.
|
|
357
|
-
* @see https://www.tiptap.dev/api/extensions/history
|
|
358
|
-
*
|
|
359
|
-
* **Important**: If the `@tiptap/extension-collaboration` package is used, make sure to remove
|
|
360
|
-
* the `history` extension, as it is not compatible with the `collaboration` extension.
|
|
361
|
-
*
|
|
362
|
-
* `@tiptap/extension-collaboration` uses its own history implementation.
|
|
363
|
-
*/
|
|
364
|
-
var History = Extension.create({
|
|
365
|
-
name: "history",
|
|
366
|
-
addOptions() {
|
|
367
|
-
return {
|
|
368
|
-
depth: 100,
|
|
369
|
-
newGroupDelay: 500
|
|
370
|
-
};
|
|
371
|
-
},
|
|
372
|
-
addCommands() {
|
|
373
|
-
return {
|
|
374
|
-
undo: () => ({ state, dispatch }) => {
|
|
375
|
-
return undo(state, dispatch);
|
|
376
|
-
},
|
|
377
|
-
redo: () => ({ state, dispatch }) => {
|
|
378
|
-
return redo(state, dispatch);
|
|
379
|
-
}
|
|
380
|
-
};
|
|
381
|
-
},
|
|
382
|
-
addProseMirrorPlugins() {
|
|
383
|
-
return [history(this.options)];
|
|
384
|
-
},
|
|
385
|
-
addKeyboardShortcuts() {
|
|
386
|
-
return {
|
|
387
|
-
"Mod-z": () => this.editor.commands.undo(),
|
|
388
|
-
"Shift-Mod-z": () => this.editor.commands.redo(),
|
|
389
|
-
"Mod-y": () => this.editor.commands.redo(),
|
|
390
|
-
"Mod-я": () => this.editor.commands.undo(),
|
|
391
|
-
"Shift-Mod-я": () => this.editor.commands.redo()
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
//#endregion
|
|
396
|
-
//#region src/editor/extensions/input-rule-history.ts
|
|
397
|
-
/**
|
|
398
|
-
* Keep the literal trigger in typing history before converting it. Tiptap's
|
|
399
|
-
* usual input rule consumes the final character, so simply closing history
|
|
400
|
-
* would restore an incomplete Markdown delimiter on Undo.
|
|
401
|
-
* @invariant Conversion and subsequent typing are separate history events.
|
|
402
|
-
* @lifecycle Tiptap clears its undoable input rule on typing or caret movement.
|
|
403
|
-
*/
|
|
404
|
-
var LoomaInputRuleHistory = Extension.create({
|
|
405
|
-
name: "loomaInputRuleHistory",
|
|
406
|
-
priority: 50,
|
|
407
|
-
onBeforeCreate() {
|
|
408
|
-
const props = this.editor.options.editorProps;
|
|
409
|
-
this.editor.setOptions({ editorProps: {
|
|
410
|
-
...props,
|
|
411
|
-
handleTextInput(view, from, to, text, defaultTransaction) {
|
|
412
|
-
if (props.handleTextInput?.call(props, view, from, to, text, defaultTransaction)) return true;
|
|
413
|
-
if (view.composing) return false;
|
|
414
|
-
const rules = view.state.plugins.find((plugin) => plugin.spec.isInputRules);
|
|
415
|
-
if (!rules?.props.handleTextInput) return false;
|
|
416
|
-
view.dispatch((defaultTransaction?.() ?? view.state.tr.insertText(text, from, to)).scrollIntoView());
|
|
417
|
-
const position = view.state.selection.from;
|
|
418
|
-
rules.props.handleTextInput.call(rules, view, position, position, "", defaultTransaction);
|
|
419
|
-
return true;
|
|
420
|
-
}
|
|
421
|
-
} });
|
|
422
|
-
},
|
|
423
|
-
addKeyboardShortcuts() {
|
|
424
|
-
return { Escape: () => this.editor.commands.undoInputRule() };
|
|
425
|
-
},
|
|
426
|
-
addProseMirrorPlugins() {
|
|
427
|
-
return [new Plugin({
|
|
428
|
-
filterTransaction(tr, state) {
|
|
429
|
-
if (state.plugins.some((plugin) => plugin.spec.isInputRules && tr.getMeta(plugin))) closeHistory(tr);
|
|
430
|
-
return true;
|
|
431
|
-
},
|
|
432
|
-
appendTransaction(transactions, _old, state) {
|
|
433
|
-
if (transactions.some((tr) => state.plugins.some((plugin) => plugin.spec.isInputRules && tr.getMeta(plugin)))) return closeHistory(state.tr);
|
|
434
|
-
return null;
|
|
435
|
-
}
|
|
436
|
-
})];
|
|
437
|
-
}
|
|
438
|
-
});
|
|
439
|
-
//#endregion
|
|
440
|
-
//#region src/vue/editor/compact/extensions.ts
|
|
441
|
-
/** Minimal short-form schema; additional consumer extensions are opt-in. */
|
|
442
|
-
function getCompactEditorExtensions() {
|
|
443
|
-
return [
|
|
444
|
-
Document,
|
|
445
|
-
Paragraph,
|
|
446
|
-
Text,
|
|
447
|
-
Bold,
|
|
448
|
-
Italic,
|
|
449
|
-
Code,
|
|
450
|
-
HardBreak,
|
|
451
|
-
History,
|
|
452
|
-
LoomaInputRuleHistory
|
|
453
|
-
];
|
|
454
|
-
}
|
|
455
|
-
//#endregion
|
|
456
|
-
//#region src/vue/editor/compact/index.ts
|
|
457
|
-
var emptyDocument = () => ({
|
|
458
|
-
type: "doc",
|
|
459
|
-
content: [{ type: "paragraph" }]
|
|
460
|
-
});
|
|
461
|
-
/**
|
|
462
|
-
* Toolbar-free editing for short rich text. Owns editor lifecycle and standard
|
|
463
|
-
* formatting/history shortcuts; the host owns persistence and optional extensions.
|
|
464
|
-
* Importing this entry is SSR-safe and does not load the full document editor.
|
|
465
|
-
* @ownership The component owns the editor; callers own content and extensions.
|
|
466
|
-
* @lifecycle Mount creates one editor; unmount destroys it and prop watchers.
|
|
467
|
-
* @failure Persistence failures are host-owned; the controlled document can restore input.
|
|
468
|
-
*/
|
|
469
|
-
var LoomaCompactEditor = defineComponent({
|
|
470
|
-
name: "LoomaCompactEditor",
|
|
471
|
-
inheritAttrs: false,
|
|
472
|
-
props: {
|
|
473
|
-
modelValue: {
|
|
474
|
-
type: Object,
|
|
475
|
-
default: emptyDocument
|
|
476
|
-
},
|
|
477
|
-
label: {
|
|
478
|
-
type: String,
|
|
479
|
-
default: "Message"
|
|
480
|
-
},
|
|
481
|
-
id: {
|
|
482
|
-
type: String,
|
|
483
|
-
default: ""
|
|
484
|
-
},
|
|
485
|
-
editable: {
|
|
486
|
-
type: Boolean,
|
|
487
|
-
default: true
|
|
488
|
-
},
|
|
489
|
-
extensions: {
|
|
490
|
-
type: Array,
|
|
491
|
-
default: () => []
|
|
492
|
-
}
|
|
493
|
-
},
|
|
494
|
-
emits: {
|
|
495
|
-
"update:modelValue": (_value) => true,
|
|
496
|
-
ready: (_editor) => true
|
|
497
|
-
},
|
|
498
|
-
setup(props, { attrs, emit, expose }) {
|
|
499
|
-
const editor = shallowRef();
|
|
500
|
-
onMounted(() => {
|
|
501
|
-
editor.value = new Editor$1({
|
|
502
|
-
extensions: [...getCompactEditorExtensions(), ...props.extensions],
|
|
503
|
-
content: props.modelValue,
|
|
504
|
-
editable: props.editable,
|
|
505
|
-
editorProps: { attributes: () => ({
|
|
506
|
-
role: "textbox",
|
|
507
|
-
"aria-multiline": "true",
|
|
508
|
-
"aria-label": props.label,
|
|
509
|
-
"aria-readonly": String(!props.editable),
|
|
510
|
-
id: props.id
|
|
511
|
-
}) },
|
|
512
|
-
onUpdate: ({ editor }) => emit("update:modelValue", editor.getJSON())
|
|
513
|
-
});
|
|
514
|
-
emit("ready", editor.value);
|
|
515
|
-
});
|
|
516
|
-
watch(() => props.modelValue, (value) => {
|
|
517
|
-
if (editor.value && JSON.stringify(value) !== JSON.stringify(editor.value.getJSON())) editor.value.commands.setContent(value, false);
|
|
518
|
-
}, { deep: true });
|
|
519
|
-
watch(() => [
|
|
520
|
-
props.id,
|
|
521
|
-
props.label,
|
|
522
|
-
props.editable
|
|
523
|
-
], () => editor.value?.setEditable(props.editable, false));
|
|
524
|
-
onBeforeUnmount(() => editor.value?.destroy());
|
|
525
|
-
expose({
|
|
526
|
-
focus: () => editor.value?.commands.focus(),
|
|
527
|
-
getEditor: () => editor.value
|
|
528
|
-
});
|
|
529
|
-
return () => h("div", {
|
|
530
|
-
...attrs,
|
|
531
|
-
id: void 0,
|
|
532
|
-
class: ["looma-compact-editor", attrs.class]
|
|
533
|
-
}, [editor.value ? h(EditorContent, { editor: editor.value }) : null]);
|
|
534
|
-
}
|
|
535
|
-
});
|
|
536
|
-
function renderNode(node) {
|
|
537
|
-
if (node.type === "hardBreak") return h("br");
|
|
538
|
-
if (node.type === "text") {
|
|
539
|
-
let text = node.text ?? "";
|
|
540
|
-
for (const mark of node.marks ?? []) {
|
|
541
|
-
const tag = {
|
|
542
|
-
bold: "strong",
|
|
543
|
-
italic: "em",
|
|
544
|
-
code: "code"
|
|
545
|
-
}[mark.type];
|
|
546
|
-
if (tag) text = h(tag, {}, [text]);
|
|
547
|
-
}
|
|
548
|
-
return text;
|
|
549
|
-
}
|
|
550
|
-
const children = (node.content ?? []).map(renderNode);
|
|
551
|
-
return node.type === "paragraph" ? h("p", {}, children) : children;
|
|
552
|
-
}
|
|
553
|
-
/** Renders basic compact JSON as escaped Vue nodes, including during SSR. */
|
|
554
|
-
var LoomaCompactContent = defineComponent({
|
|
555
|
-
name: "LoomaCompactContent",
|
|
556
|
-
props: { content: {
|
|
557
|
-
type: Object,
|
|
558
|
-
required: true
|
|
559
|
-
} },
|
|
560
|
-
setup: (props) => () => h("div", { class: "looma-compact-content" }, [renderNode(props.content)])
|
|
561
|
-
});
|
|
562
|
-
//#endregion
|
|
1
|
+
import { n as LoomaCompactEditor, r as getCompactEditorExtensions, t as LoomaCompactContent } from "../../chunks/compact.js";
|
|
563
2
|
export { LoomaCompactContent, LoomaCompactEditor, getCompactEditorExtensions };
|