@caspeco/casper-ui-library 9.10.0 → 9.11.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/components/rich-text-editor/boolean-control.js +1 -1
- package/dist/components/rich-text-editor/rich-text-editor-control.js +1 -1
- package/dist/components/rich-text-editor/rich-text-editor.js +1 -1
- package/dist/components/rich-text-editor/use-rich-text-editor.js +1 -1
- package/dist/components/table/table-header-dropdown.d.ts.map +1 -1
- package/dist/components/table/table-header-dropdown.js +68 -66
- package/dist/node_modules/@tanstack/react-virtual/dist/esm/index.js +83 -31
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.js +411 -226
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/lazy-measurements.js +33 -0
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.js +29 -28
- package/dist/node_modules/@tiptap/core/dist/index.js +251 -90
- package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js +3 -1
- package/dist/node_modules/@tiptap/extension-code-block/dist/index.js +3 -1
- package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js +3 -1
- package/dist/node_modules/@tiptap/extension-heading/dist/index.js +5 -1
- package/dist/node_modules/@tiptap/extension-link/dist/index.js +36 -8
- package/dist/node_modules/@tiptap/extension-list/dist/index.js +13 -2
- package/dist/node_modules/@tiptap/extensions/dist/index.js +236 -229
- package/dist/{node_modules → packages/casper-ui-library/node_modules}/@tiptap/react/dist/index.js +12 -7
- package/package.json +13 -13
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Extension as
|
|
2
|
-
import { PluginKey as
|
|
3
|
-
import { dropCursor as
|
|
4
|
-
import { DecorationSet as
|
|
5
|
-
import { gapCursor as
|
|
6
|
-
import { history as
|
|
7
|
-
|
|
1
|
+
import { Extension as p, callOrReturn as x, getExtensionField as O, isNodeSelection as _, isNodeEmpty as T } from "../../core/dist/index.js";
|
|
2
|
+
import { PluginKey as P, Plugin as C } from "../../../prosemirror-state/dist/index.js";
|
|
3
|
+
import { dropCursor as D } from "../../../prosemirror-dropcursor/dist/index.js";
|
|
4
|
+
import { DecorationSet as w, Decoration as b } from "../../../prosemirror-view/dist/index.js";
|
|
5
|
+
import { gapCursor as L } from "../../../prosemirror-gapcursor/dist/index.js";
|
|
6
|
+
import { history as k, redo as B, undo as F } from "../../../prosemirror-history/dist/index.js";
|
|
7
|
+
p.create({
|
|
8
8
|
name: "characterCount",
|
|
9
9
|
addOptions() {
|
|
10
10
|
return {
|
|
@@ -25,56 +25,56 @@ h.create({
|
|
|
25
25
|
this.storage.characters = (e) => {
|
|
26
26
|
const t = e?.node || this.editor.state.doc;
|
|
27
27
|
if ((e?.mode || this.options.mode) === "textSize") {
|
|
28
|
-
const
|
|
29
|
-
return this.options.textCounter(
|
|
28
|
+
const o = t.textBetween(0, t.content.size, void 0, " ");
|
|
29
|
+
return this.options.textCounter(o);
|
|
30
30
|
}
|
|
31
31
|
return t.nodeSize;
|
|
32
32
|
}, this.storage.words = (e) => {
|
|
33
|
-
const t = e?.node || this.editor.state.doc,
|
|
34
|
-
return this.options.wordCounter(
|
|
33
|
+
const t = e?.node || this.editor.state.doc, n = t.textBetween(0, t.content.size, " ", " ");
|
|
34
|
+
return this.options.wordCounter(n);
|
|
35
35
|
};
|
|
36
36
|
},
|
|
37
37
|
addProseMirrorPlugins() {
|
|
38
38
|
let e = !1;
|
|
39
39
|
return [
|
|
40
40
|
new C({
|
|
41
|
-
key: new
|
|
42
|
-
appendTransaction: (t,
|
|
41
|
+
key: new P("characterCount"),
|
|
42
|
+
appendTransaction: (t, n, o) => {
|
|
43
43
|
if (e)
|
|
44
44
|
return;
|
|
45
|
-
const r = this.options.limit,
|
|
46
|
-
if (r == null || r === 0 ||
|
|
45
|
+
const r = this.options.limit, i = this.options.autoTrim;
|
|
46
|
+
if (r == null || r === 0 || i === !1) {
|
|
47
47
|
e = !0;
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
const
|
|
50
|
+
const a = this.storage.characters({ node: o.doc });
|
|
51
|
+
if (a > r) {
|
|
52
|
+
const l = a - r, s = 0, d = l;
|
|
53
53
|
console.warn(
|
|
54
54
|
`[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`
|
|
55
55
|
);
|
|
56
|
-
const
|
|
57
|
-
return e = !0,
|
|
56
|
+
const c = o.tr.deleteRange(s, d);
|
|
57
|
+
return e = !0, c;
|
|
58
58
|
}
|
|
59
59
|
e = !0;
|
|
60
60
|
},
|
|
61
|
-
filterTransaction: (t,
|
|
62
|
-
const
|
|
63
|
-
if (!t.docChanged ||
|
|
61
|
+
filterTransaction: (t, n) => {
|
|
62
|
+
const o = this.options.limit;
|
|
63
|
+
if (!t.docChanged || o === 0 || o === null || o === void 0)
|
|
64
64
|
return !0;
|
|
65
|
-
const r = this.storage.characters({ node:
|
|
66
|
-
if (
|
|
65
|
+
const r = this.storage.characters({ node: n.doc }), i = this.storage.characters({ node: t.doc });
|
|
66
|
+
if (i <= o || r > o && i > o && i <= r)
|
|
67
67
|
return !0;
|
|
68
|
-
if (r >
|
|
68
|
+
if (r > o && i > o && i > r || !t.getMeta("paste"))
|
|
69
69
|
return !1;
|
|
70
|
-
const
|
|
71
|
-
return t.deleteRange(
|
|
70
|
+
const l = t.selection.$head.pos, s = i - o, d = l - s, c = l;
|
|
71
|
+
return t.deleteRange(d, c), !(this.storage.characters({ node: t.doc }) > o);
|
|
72
72
|
}
|
|
73
73
|
})
|
|
74
74
|
];
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
|
-
var
|
|
77
|
+
var et = p.create({
|
|
78
78
|
name: "dropCursor",
|
|
79
79
|
addOptions() {
|
|
80
80
|
return {
|
|
@@ -84,10 +84,10 @@ var V = h.create({
|
|
|
84
84
|
};
|
|
85
85
|
},
|
|
86
86
|
addProseMirrorPlugins() {
|
|
87
|
-
return [
|
|
87
|
+
return [D(this.options)];
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
|
-
|
|
90
|
+
p.create({
|
|
91
91
|
name: "focus",
|
|
92
92
|
addOptions() {
|
|
93
93
|
return {
|
|
@@ -98,137 +98,238 @@ h.create({
|
|
|
98
98
|
addProseMirrorPlugins() {
|
|
99
99
|
return [
|
|
100
100
|
new C({
|
|
101
|
-
key: new
|
|
101
|
+
key: new P("focus"),
|
|
102
102
|
props: {
|
|
103
103
|
decorations: ({ doc: e, selection: t }) => {
|
|
104
|
-
const { isEditable:
|
|
105
|
-
if (!
|
|
106
|
-
return
|
|
107
|
-
let
|
|
108
|
-
this.options.mode === "deepest" && e.descendants((
|
|
109
|
-
if (
|
|
104
|
+
const { isEditable: n, isFocused: o } = this.editor, { anchor: r } = t, i = [];
|
|
105
|
+
if (!n || !o)
|
|
106
|
+
return w.create(e, []);
|
|
107
|
+
let a = 0;
|
|
108
|
+
this.options.mode === "deepest" && e.descendants((s, d) => {
|
|
109
|
+
if (s.isText)
|
|
110
110
|
return;
|
|
111
|
-
if (!(r >=
|
|
111
|
+
if (!(r >= d && r <= d + s.nodeSize - 1))
|
|
112
112
|
return !1;
|
|
113
|
-
|
|
113
|
+
a += 1;
|
|
114
114
|
});
|
|
115
|
-
let
|
|
116
|
-
return e.descendants((
|
|
117
|
-
if (
|
|
115
|
+
let l = 0;
|
|
116
|
+
return e.descendants((s, d) => {
|
|
117
|
+
if (s.isText || !(r >= d && r <= d + s.nodeSize - 1))
|
|
118
118
|
return !1;
|
|
119
|
-
if (
|
|
119
|
+
if (l += 1, this.options.mode === "deepest" && a - l > 0 || this.options.mode === "shallowest" && l > 1)
|
|
120
120
|
return this.options.mode === "deepest";
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
i.push(
|
|
122
|
+
b.node(d, d + s.nodeSize, {
|
|
123
123
|
class: this.options.className
|
|
124
124
|
})
|
|
125
125
|
);
|
|
126
|
-
}),
|
|
126
|
+
}), w.create(e, i);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
})
|
|
130
130
|
];
|
|
131
131
|
}
|
|
132
132
|
});
|
|
133
|
-
var
|
|
133
|
+
var ot = p.create({
|
|
134
134
|
name: "gapCursor",
|
|
135
135
|
addProseMirrorPlugins() {
|
|
136
|
-
return [
|
|
136
|
+
return [L()];
|
|
137
137
|
},
|
|
138
138
|
extendNodeSchema(e) {
|
|
139
139
|
var t;
|
|
140
|
-
const
|
|
140
|
+
const n = {
|
|
141
141
|
name: e.name,
|
|
142
142
|
options: e.options,
|
|
143
143
|
storage: e.storage
|
|
144
144
|
};
|
|
145
145
|
return {
|
|
146
|
-
allowGapCursor: (t =
|
|
146
|
+
allowGapCursor: (t = x(O(e, "allowGapCursor", n))) != null ? t : null
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
|
-
});
|
|
150
|
-
function
|
|
149
|
+
}), M = "placeholder", y = new P("tiptap__placeholder"), A = 200;
|
|
150
|
+
function N(e) {
|
|
151
151
|
const {
|
|
152
152
|
editor: t,
|
|
153
|
-
placeholder:
|
|
154
|
-
dataAttribute:
|
|
153
|
+
placeholder: n,
|
|
154
|
+
dataAttribute: o,
|
|
155
155
|
pos: r,
|
|
156
|
-
node:
|
|
157
|
-
isEmptyDoc:
|
|
158
|
-
hasAnchor:
|
|
159
|
-
classes: { emptyNode:
|
|
160
|
-
} = e,
|
|
161
|
-
return
|
|
162
|
-
class:
|
|
163
|
-
[
|
|
156
|
+
node: i,
|
|
157
|
+
isEmptyDoc: a,
|
|
158
|
+
hasAnchor: l,
|
|
159
|
+
classes: { emptyNode: s, emptyEditor: d }
|
|
160
|
+
} = e, c = [s];
|
|
161
|
+
return a && c.push(d), b.node(r, r + i.nodeSize, {
|
|
162
|
+
class: c.join(" "),
|
|
163
|
+
[o]: typeof n == "function" ? n({
|
|
164
164
|
editor: t,
|
|
165
|
-
node:
|
|
165
|
+
node: i,
|
|
166
166
|
pos: r,
|
|
167
|
-
hasAnchor:
|
|
168
|
-
}) :
|
|
167
|
+
hasAnchor: l
|
|
168
|
+
}) : n
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
|
-
function
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
function I({
|
|
172
|
+
editor: e,
|
|
173
|
+
options: t,
|
|
174
|
+
dataAttribute: n,
|
|
175
|
+
doc: o,
|
|
176
|
+
selection: r
|
|
177
|
+
}) {
|
|
178
|
+
var i, a;
|
|
179
|
+
if (!(e.isEditable || !t.showOnlyWhenEditable))
|
|
180
|
+
return null;
|
|
181
|
+
const { anchor: s } = r, d = [], c = e.isEmpty, f = {
|
|
182
|
+
emptyEditor: t.emptyEditorClass,
|
|
183
|
+
emptyNode: t.emptyNodeClass
|
|
184
|
+
};
|
|
185
|
+
if (t.showOnlyCurrent && !t.includeChildren) {
|
|
186
|
+
const u = o.resolve(s), m = u.depth > 0 ? u.node(1) : u.nodeAfter, g = u.depth > 0 ? u.before(1) : s;
|
|
187
|
+
if (m && m.type.isTextblock && T(m)) {
|
|
188
|
+
const h = s >= g && s <= g + m.nodeSize;
|
|
189
|
+
d.push(
|
|
190
|
+
N({
|
|
191
|
+
editor: e,
|
|
192
|
+
isEmptyDoc: c,
|
|
193
|
+
dataAttribute: n,
|
|
194
|
+
hasAnchor: h,
|
|
195
|
+
placeholder: t.placeholder,
|
|
196
|
+
classes: f,
|
|
197
|
+
node: m,
|
|
198
|
+
pos: g
|
|
199
|
+
})
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
const u = y.getState(e.state), m = (i = u?.topPos) != null ? i : 0, g = (a = u?.bottomPos) != null ? a : o.content.size;
|
|
204
|
+
o.nodesBetween(m, g, (h, v) => {
|
|
205
|
+
const E = s >= v && s <= v + h.nodeSize, R = !h.isLeaf && T(h);
|
|
206
|
+
return h.type.isTextblock && (E || !t.showOnlyCurrent) && R && d.push(
|
|
207
|
+
N({
|
|
208
|
+
editor: e,
|
|
209
|
+
isEmptyDoc: c,
|
|
210
|
+
dataAttribute: n,
|
|
211
|
+
hasAnchor: E,
|
|
212
|
+
placeholder: t.placeholder,
|
|
213
|
+
classes: f,
|
|
214
|
+
node: h,
|
|
215
|
+
pos: v
|
|
216
|
+
})
|
|
217
|
+
), t.includeChildren;
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
return w.create(o, d);
|
|
221
|
+
}
|
|
222
|
+
function $(e) {
|
|
223
|
+
return e.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
|
|
224
|
+
}
|
|
225
|
+
function V(e) {
|
|
226
|
+
const t = getComputedStyle(e), n = `${t.overflow} ${t.overflowY} ${t.overflowX}`;
|
|
227
|
+
return /auto|scroll|overlay/.test(n);
|
|
174
228
|
}
|
|
175
|
-
function
|
|
229
|
+
function G(e) {
|
|
176
230
|
let t = e;
|
|
177
231
|
for (; t; ) {
|
|
178
|
-
if (
|
|
232
|
+
if (V(t))
|
|
179
233
|
return t;
|
|
180
|
-
const
|
|
181
|
-
if (!
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
184
|
-
t =
|
|
234
|
+
const n = t.parentElement;
|
|
235
|
+
if (!n) {
|
|
236
|
+
const o = t.getRootNode();
|
|
237
|
+
if (o instanceof ShadowRoot) {
|
|
238
|
+
t = o.host;
|
|
185
239
|
continue;
|
|
186
240
|
}
|
|
187
241
|
return window;
|
|
188
242
|
}
|
|
189
|
-
t =
|
|
243
|
+
t = n;
|
|
190
244
|
}
|
|
191
245
|
return window;
|
|
192
246
|
}
|
|
193
|
-
function
|
|
247
|
+
function U(e) {
|
|
194
248
|
return e === window ? { top: 0, bottom: window.innerHeight } : e.getBoundingClientRect();
|
|
195
249
|
}
|
|
196
|
-
function
|
|
250
|
+
function W({
|
|
197
251
|
doc: e,
|
|
198
252
|
view: t,
|
|
199
|
-
scrollContainer:
|
|
253
|
+
scrollContainer: n
|
|
200
254
|
}) {
|
|
201
|
-
const
|
|
202
|
-
if (
|
|
255
|
+
const o = t.dom.getBoundingClientRect(), r = n ? U(n) : { top: 0, bottom: window.innerHeight }, i = Math.max(o.top, r.top) - A, a = Math.min(o.bottom, r.bottom) + A;
|
|
256
|
+
if (i >= a)
|
|
203
257
|
return { top: 0, bottom: e.content.size };
|
|
204
|
-
const
|
|
258
|
+
const s = getComputedStyle(t.dom).direction === "rtl" ? Math.max(o.right - 2, o.left + 2) : o.left + 2, d = t.posAtCoords({ left: s, top: i + 2 }), c = t.posAtCoords({ left: s, top: a - 2 });
|
|
205
259
|
return {
|
|
206
|
-
top:
|
|
207
|
-
bottom:
|
|
260
|
+
top: d ? d.pos : 0,
|
|
261
|
+
bottom: c ? c.pos : e.content.size
|
|
208
262
|
};
|
|
209
263
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
264
|
+
var q = {
|
|
265
|
+
/**
|
|
266
|
+
* Initialises the viewport state with no known positions.
|
|
267
|
+
* @returns The initial viewport state.
|
|
268
|
+
*/
|
|
269
|
+
init() {
|
|
270
|
+
return { topPos: null, bottomPos: null };
|
|
271
|
+
},
|
|
272
|
+
/**
|
|
273
|
+
* Updates the viewport state from incoming transactions.
|
|
274
|
+
* @param tr - The transaction being applied.
|
|
275
|
+
* @param prev - The previous viewport state.
|
|
276
|
+
* @returns The next viewport state.
|
|
277
|
+
*/
|
|
278
|
+
apply(e, t) {
|
|
279
|
+
const n = e.getMeta(y);
|
|
280
|
+
return n?.positions ? { topPos: n.positions.top, bottomPos: n.positions.bottom } : e.docChanged ? {
|
|
281
|
+
topPos: t.topPos !== null ? e.mapping.map(t.topPos) : null,
|
|
282
|
+
bottomPos: t.bottomPos !== null ? e.mapping.map(t.bottomPos) : null
|
|
283
|
+
} : t;
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
function K(e) {
|
|
287
|
+
const t = G(e.dom), n = () => {
|
|
288
|
+
const l = W({
|
|
289
|
+
view: e,
|
|
290
|
+
doc: e.state.doc,
|
|
291
|
+
scrollContainer: t
|
|
292
|
+
}), s = y.getState(e.state);
|
|
293
|
+
if (s?.topPos === l.top && s?.bottomPos === l.bottom)
|
|
294
|
+
return;
|
|
295
|
+
const d = e.state.tr.setMeta(y, { positions: l });
|
|
296
|
+
e.dispatch(d);
|
|
297
|
+
};
|
|
298
|
+
let o = null, r = 0;
|
|
299
|
+
const i = 150, a = () => {
|
|
300
|
+
o === null && (o = requestAnimationFrame(() => {
|
|
214
301
|
o = null;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
302
|
+
const l = performance.now();
|
|
303
|
+
l - r >= i ? (r = l, n()) : a();
|
|
304
|
+
}));
|
|
305
|
+
};
|
|
306
|
+
return t.addEventListener("scroll", a, { passive: !0 }), n(), {
|
|
307
|
+
update(l, s) {
|
|
308
|
+
e.state.doc.content.size !== s.doc.content.size && a();
|
|
309
|
+
},
|
|
310
|
+
destroy: () => {
|
|
311
|
+
o !== null && cancelAnimationFrame(o), t.removeEventListener("scroll", a);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
219
314
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return
|
|
315
|
+
function j({ editor: e, options: t }) {
|
|
316
|
+
const n = t.dataAttribute ? `data-${$(t.dataAttribute)}` : `data-${M}`;
|
|
317
|
+
return new C({
|
|
318
|
+
key: y,
|
|
319
|
+
state: q,
|
|
320
|
+
view: K,
|
|
321
|
+
props: {
|
|
322
|
+
decorations: ({ doc: o, selection: r }) => I({ editor: e, options: t, dataAttribute: n, doc: o, selection: r })
|
|
323
|
+
}
|
|
324
|
+
});
|
|
223
325
|
}
|
|
224
|
-
|
|
225
|
-
h.create({
|
|
326
|
+
p.create({
|
|
226
327
|
name: "placeholder",
|
|
227
328
|
addOptions() {
|
|
228
329
|
return {
|
|
229
330
|
emptyEditorClass: "is-editor-empty",
|
|
230
331
|
emptyNodeClass: "is-empty",
|
|
231
|
-
dataAttribute:
|
|
332
|
+
dataAttribute: M,
|
|
232
333
|
placeholder: "Write something …",
|
|
233
334
|
showOnlyWhenEditable: !0,
|
|
234
335
|
showOnlyCurrent: !0,
|
|
@@ -236,108 +337,10 @@ h.create({
|
|
|
236
337
|
};
|
|
237
338
|
},
|
|
238
339
|
addProseMirrorPlugins() {
|
|
239
|
-
|
|
240
|
-
return [
|
|
241
|
-
new C({
|
|
242
|
-
state: {
|
|
243
|
-
init() {
|
|
244
|
-
return {
|
|
245
|
-
// null means "no viewport info yet" — decoration callback falls
|
|
246
|
-
// back to full document scan until the scroll handler fires.
|
|
247
|
-
topPos: null,
|
|
248
|
-
bottomPos: null
|
|
249
|
-
};
|
|
250
|
-
},
|
|
251
|
-
apply(t, o) {
|
|
252
|
-
const n = t.getMeta(g);
|
|
253
|
-
return n?.positions ? {
|
|
254
|
-
topPos: n.positions.top,
|
|
255
|
-
bottomPos: n.positions.bottom
|
|
256
|
-
} : t.docChanged ? {
|
|
257
|
-
topPos: o.topPos !== null ? t.mapping.map(o.topPos) : null,
|
|
258
|
-
bottomPos: o.bottomPos !== null ? t.mapping.map(o.bottomPos) : null
|
|
259
|
-
} : o;
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
key: g,
|
|
263
|
-
view(t) {
|
|
264
|
-
const o = B(t.dom), n = () => {
|
|
265
|
-
const d = F({
|
|
266
|
-
view: t,
|
|
267
|
-
doc: t.state.doc,
|
|
268
|
-
scrollContainer: o
|
|
269
|
-
}), a = g.getState(t.state);
|
|
270
|
-
if (a.topPos === d.top && a.bottomPos === d.bottom)
|
|
271
|
-
return;
|
|
272
|
-
const c = t.state.tr.setMeta(g, { positions: d }).setMeta("tiptap__viewportUpdate", !0);
|
|
273
|
-
t.dispatch(c);
|
|
274
|
-
}, { call: r, cancel: s } = U(n, 250), i = o;
|
|
275
|
-
return i.addEventListener("scroll", r, { passive: !0 }), n(), {
|
|
276
|
-
update(d, a) {
|
|
277
|
-
t.state.doc.content.size !== a.doc.content.size && n();
|
|
278
|
-
},
|
|
279
|
-
destroy: () => {
|
|
280
|
-
s(), i.removeEventListener("scroll", r);
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
},
|
|
284
|
-
props: {
|
|
285
|
-
decorations: ({ doc: t, selection: o }) => {
|
|
286
|
-
var n, r;
|
|
287
|
-
if (!(this.editor.isEditable || !this.options.showOnlyWhenEditable))
|
|
288
|
-
return null;
|
|
289
|
-
const { anchor: i } = o, d = [], a = this.editor.isEmpty;
|
|
290
|
-
if (this.options.showOnlyCurrent && !this.options.includeChildren) {
|
|
291
|
-
const l = t.resolve(i);
|
|
292
|
-
if (l.depth > 0) {
|
|
293
|
-
const u = l.node(1), m = l.before(1);
|
|
294
|
-
if (u.type.isTextblock && v(u)) {
|
|
295
|
-
const p = i >= m && i <= m + u.nodeSize, f = S({
|
|
296
|
-
node: u,
|
|
297
|
-
dataAttribute: e,
|
|
298
|
-
hasAnchor: p,
|
|
299
|
-
placeholder: this.options.placeholder,
|
|
300
|
-
classes: {
|
|
301
|
-
emptyEditor: this.options.emptyEditorClass,
|
|
302
|
-
emptyNode: this.options.emptyNodeClass
|
|
303
|
-
},
|
|
304
|
-
editor: this.editor,
|
|
305
|
-
isEmptyDoc: a,
|
|
306
|
-
pos: l.before(1)
|
|
307
|
-
});
|
|
308
|
-
d.push(f);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
} else {
|
|
312
|
-
const l = g.getState(this.editor.state), u = (n = l.topPos) != null ? n : 0, m = (r = l.bottomPos) != null ? r : t.content.size;
|
|
313
|
-
t.nodesBetween(u, m, (p, f) => {
|
|
314
|
-
const b = i >= f && i <= f + p.nodeSize, z = !p.isLeaf && v(p);
|
|
315
|
-
if (!p.type.isTextblock)
|
|
316
|
-
return this.options.includeChildren;
|
|
317
|
-
if ((b || !this.options.showOnlyCurrent) && z) {
|
|
318
|
-
const N = S({
|
|
319
|
-
classes: { emptyEditor: this.options.emptyEditorClass, emptyNode: this.options.emptyNodeClass },
|
|
320
|
-
editor: this.editor,
|
|
321
|
-
isEmptyDoc: a,
|
|
322
|
-
dataAttribute: e,
|
|
323
|
-
hasAnchor: b,
|
|
324
|
-
placeholder: this.options.placeholder,
|
|
325
|
-
node: p,
|
|
326
|
-
pos: f
|
|
327
|
-
});
|
|
328
|
-
d.push(N);
|
|
329
|
-
}
|
|
330
|
-
return this.options.includeChildren;
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
return P.create(t, d);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
})
|
|
337
|
-
];
|
|
340
|
+
return [j({ editor: this.editor, options: this.options })];
|
|
338
341
|
}
|
|
339
342
|
});
|
|
340
|
-
|
|
343
|
+
p.create({
|
|
341
344
|
name: "selection",
|
|
342
345
|
addOptions() {
|
|
343
346
|
return {
|
|
@@ -348,11 +351,11 @@ h.create({
|
|
|
348
351
|
const { editor: e, options: t } = this;
|
|
349
352
|
return [
|
|
350
353
|
new C({
|
|
351
|
-
key: new
|
|
354
|
+
key: new P("selection"),
|
|
352
355
|
props: {
|
|
353
|
-
decorations(
|
|
354
|
-
return
|
|
355
|
-
|
|
356
|
+
decorations(n) {
|
|
357
|
+
return n.selection.empty || e.isFocused || !e.isEditable || _(n.selection) || e.view.dragging ? null : w.create(n.doc, [
|
|
358
|
+
b.inline(n.selection.from, n.selection.to, {
|
|
356
359
|
class: t.className
|
|
357
360
|
})
|
|
358
361
|
]);
|
|
@@ -362,11 +365,14 @@ h.create({
|
|
|
362
365
|
];
|
|
363
366
|
}
|
|
364
367
|
});
|
|
365
|
-
var
|
|
366
|
-
function
|
|
368
|
+
var H = "skipTrailingNode";
|
|
369
|
+
function z({
|
|
370
|
+
types: e,
|
|
371
|
+
node: t
|
|
372
|
+
}) {
|
|
367
373
|
return t && Array.isArray(e) && e.includes(t.type) || t?.type === e;
|
|
368
374
|
}
|
|
369
|
-
var
|
|
375
|
+
var nt = p.create({
|
|
370
376
|
name: "trailingNode",
|
|
371
377
|
addOptions() {
|
|
372
378
|
return {
|
|
@@ -376,31 +382,31 @@ var Z = h.create({
|
|
|
376
382
|
},
|
|
377
383
|
addProseMirrorPlugins() {
|
|
378
384
|
var e;
|
|
379
|
-
const t = new
|
|
385
|
+
const t = new P(this.name), n = this.options.node || ((e = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : e.name) || "paragraph", o = Object.entries(this.editor.schema.nodes).map(([, r]) => r).filter((r) => (this.options.notAfter || []).concat(n).includes(r.name));
|
|
380
386
|
return [
|
|
381
387
|
new C({
|
|
382
388
|
key: t,
|
|
383
|
-
appendTransaction: (r,
|
|
384
|
-
const { doc:
|
|
385
|
-
if (!r.some((
|
|
386
|
-
return
|
|
389
|
+
appendTransaction: (r, i, a) => {
|
|
390
|
+
const { doc: l, tr: s, schema: d } = a, c = t.getState(a), f = l.content.size, S = d.nodes[n];
|
|
391
|
+
if (!r.some((u) => u.getMeta(H)) && c)
|
|
392
|
+
return s.insert(f, S.create());
|
|
387
393
|
},
|
|
388
394
|
state: {
|
|
389
|
-
init: (r,
|
|
390
|
-
const
|
|
391
|
-
return !
|
|
395
|
+
init: (r, i) => {
|
|
396
|
+
const a = i.tr.doc.lastChild;
|
|
397
|
+
return !z({ node: a, types: o });
|
|
392
398
|
},
|
|
393
|
-
apply: (r,
|
|
399
|
+
apply: (r, i) => {
|
|
394
400
|
if (!r.docChanged || r.getMeta("__uniqueIDTransaction"))
|
|
395
|
-
return
|
|
396
|
-
const
|
|
397
|
-
return !
|
|
401
|
+
return i;
|
|
402
|
+
const a = r.doc.lastChild;
|
|
403
|
+
return !z({ node: a, types: o });
|
|
398
404
|
}
|
|
399
405
|
}
|
|
400
406
|
})
|
|
401
407
|
];
|
|
402
408
|
}
|
|
403
|
-
}),
|
|
409
|
+
}), rt = p.create({
|
|
404
410
|
name: "undoRedo",
|
|
405
411
|
addOptions() {
|
|
406
412
|
return {
|
|
@@ -410,12 +416,12 @@ var Z = h.create({
|
|
|
410
416
|
},
|
|
411
417
|
addCommands() {
|
|
412
418
|
return {
|
|
413
|
-
undo: () => ({ state: e, dispatch: t }) =>
|
|
414
|
-
redo: () => ({ state: e, dispatch: t }) =>
|
|
419
|
+
undo: () => ({ state: e, dispatch: t }) => F(e, t),
|
|
420
|
+
redo: () => ({ state: e, dispatch: t }) => B(e, t)
|
|
415
421
|
};
|
|
416
422
|
},
|
|
417
423
|
addProseMirrorPlugins() {
|
|
418
|
-
return [
|
|
424
|
+
return [k(this.options)];
|
|
419
425
|
},
|
|
420
426
|
addKeyboardShortcuts() {
|
|
421
427
|
return {
|
|
@@ -429,11 +435,12 @@ var Z = h.create({
|
|
|
429
435
|
}
|
|
430
436
|
});
|
|
431
437
|
export {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
438
|
+
M as DEFAULT_DATA_ATTRIBUTE,
|
|
439
|
+
et as Dropcursor,
|
|
440
|
+
ot as Gapcursor,
|
|
441
|
+
y as PLUGIN_KEY,
|
|
442
|
+
nt as TrailingNode,
|
|
443
|
+
rt as UndoRedo,
|
|
444
|
+
$ as preparePlaceholderAttribute,
|
|
445
|
+
H as skipTrailingNodeMeta
|
|
439
446
|
};
|