@edifice.io/react 2.6.8 → 2.6.9-chore-tiptap-v3.20261013175230

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/editor.js +2 -0
  2. package/dist/homepage.js +2 -1
  3. package/dist/modules/editor/components/BubbleMenuEditImage/BubbleMenuEditImage.js +97 -90
  4. package/dist/modules/editor/components/BubbleMenuEditInformationPane/BubbleMenuEditInformationPane.js +111 -95
  5. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.Typography.js +3 -3
  6. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.js +6 -4
  7. package/dist/modules/editor/components/Toolbar/LinkToolbar.FloatingOptions.js +12 -0
  8. package/dist/modules/editor/components/Toolbar/LinkToolbar.js +5 -4
  9. package/dist/modules/editor/components/Toolbar/TableToolbar.js +11 -5
  10. package/dist/modules/editor/hooks/index.d.ts +1 -0
  11. package/dist/modules/editor/hooks/useCommentEditor.d.ts +1 -1
  12. package/dist/modules/editor/hooks/useCommentEditor.js +12 -4
  13. package/dist/modules/editor/hooks/useEditorState.d.ts +20 -0
  14. package/dist/modules/editor/hooks/useEditorState.js +16 -0
  15. package/dist/modules/editor/hooks/useTipTapEditor.d.ts +1 -1
  16. package/dist/modules/editor/hooks/useTipTapEditor.js +64 -24
  17. package/dist/modules/homepage/components/Communities/Communities.d.ts +2 -1
  18. package/dist/modules/homepage/components/Communities/Communities.js +14 -13
  19. package/dist/modules/homepage/components/Communities/CommunitiesContainer.d.ts +1 -1
  20. package/dist/modules/homepage/components/Communities/CommunitiesContainer.js +9 -5
  21. package/dist/modules/homepage/components/Communities/CommunitiesSkeleton.js +4 -7
  22. package/dist/modules/homepage/components/Communities/useCommunities.d.ts +4 -1
  23. package/dist/modules/homepage/components/Communities/useCommunities.js +8 -3
  24. package/dist/modules/homepage/components/HomeCard/HomeCardHeader.js +2 -2
  25. package/dist/modules/multimedia/MediaLibrary/MediaLibrary.d.ts +2 -0
  26. package/dist/modules/multimedia/MediaLibrary/MediaLibrary.js +2 -0
  27. package/dist/modules/multimedia/MediaLibrary/MediaLibraryContext.d.ts +4 -0
  28. package/dist/modules/multimedia/MediaLibrary/innertabs/Upload.js +2 -1
  29. package/dist/modules/multimedia/MediaLibrary/innertabs/Workspace.js +3 -0
  30. package/dist/node_modules/.pnpm/@tiptap_extension-floating-menu@3.32.0_@floating-ui_dom@1.6.0_@tiptap_core@3.32.0_@tiptap_pm@3.32.0__@tiptap_pm@3.32.0/node_modules/@tiptap/extension-floating-menu/dist/index.js +159 -0
  31. package/dist/node_modules/.pnpm/@tiptap_react@3.32.0_@floating-ui_dom@1.6.0_@tiptap_core@3.32.0_@tiptap_pm@3.32.0__@tiptap_pm_6inmb43gajy4fnlwtngbwkv7um/node_modules/@tiptap/react/dist/menus/index.js +341 -0
  32. package/dist/node_modules/.pnpm/prosemirror-model@1.25.12/node_modules/prosemirror-model/dist/index.js +419 -0
  33. package/dist/node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.js +489 -0
  34. package/dist/node_modules/.pnpm/prosemirror-transform@1.12.2/node_modules/prosemirror-transform/dist/index.js +607 -0
  35. package/package.json +35 -43
  36. package/dist/modules/editor/components/Toolbar/LinkToolbar.TippyOptions.d.ts +0 -2
  37. package/dist/modules/editor/components/Toolbar/LinkToolbar.TippyOptions.js +0 -8
@@ -0,0 +1,489 @@
1
+ import { Slice, Fragment } from "../../../../prosemirror-model@1.25.12/node_modules/prosemirror-model/dist/index.js";
2
+ import { ReplaceStep, ReplaceAroundStep } from "../../../../prosemirror-transform@1.12.2/node_modules/prosemirror-transform/dist/index.js";
3
+ const classesById = /* @__PURE__ */ Object.create(null);
4
+ class Selection {
5
+ /**
6
+ Initialize a selection with the head and anchor and ranges. If no
7
+ ranges are given, constructs a single range across `$anchor` and
8
+ `$head`.
9
+ */
10
+ constructor($anchor, $head, ranges) {
11
+ this.$anchor = $anchor, this.$head = $head, this.ranges = ranges || [new SelectionRange($anchor.min($head), $anchor.max($head))];
12
+ }
13
+ /**
14
+ The selection's anchor, as an unresolved position.
15
+ */
16
+ get anchor() {
17
+ return this.$anchor.pos;
18
+ }
19
+ /**
20
+ The selection's head.
21
+ */
22
+ get head() {
23
+ return this.$head.pos;
24
+ }
25
+ /**
26
+ The lower bound of the selection's main range.
27
+ */
28
+ get from() {
29
+ return this.$from.pos;
30
+ }
31
+ /**
32
+ The upper bound of the selection's main range.
33
+ */
34
+ get to() {
35
+ return this.$to.pos;
36
+ }
37
+ /**
38
+ The resolved lower bound of the selection's main range.
39
+ */
40
+ get $from() {
41
+ return this.ranges[0].$from;
42
+ }
43
+ /**
44
+ The resolved upper bound of the selection's main range.
45
+ */
46
+ get $to() {
47
+ return this.ranges[0].$to;
48
+ }
49
+ /**
50
+ Indicates whether the selection contains any content.
51
+ */
52
+ get empty() {
53
+ let ranges = this.ranges;
54
+ for (let i = 0; i < ranges.length; i++)
55
+ if (ranges[i].$from.pos != ranges[i].$to.pos)
56
+ return !1;
57
+ return !0;
58
+ }
59
+ /**
60
+ Get the content of this selection as a slice.
61
+ */
62
+ content() {
63
+ return this.$from.doc.slice(this.from, this.to, !0);
64
+ }
65
+ /**
66
+ Replace the selection with a slice or, if no slice is given,
67
+ delete the selection. Will append to the given transaction.
68
+ */
69
+ replace(tr, content = Slice.empty) {
70
+ let lastNode = content.content.lastChild, lastParent = null;
71
+ for (let i = 0; i < content.openEnd; i++)
72
+ lastParent = lastNode, lastNode = lastNode.lastChild;
73
+ let mapFrom = tr.steps.length, ranges = this.ranges;
74
+ for (let i = 0; i < ranges.length; i++) {
75
+ let { $from, $to } = ranges[i], mapping = tr.mapping.slice(mapFrom);
76
+ tr.replaceRange(mapping.map($from.pos), mapping.map($to.pos), i ? Slice.empty : content), i == 0 && selectionToInsertionEnd(tr, mapFrom, (lastNode ? lastNode.isInline : lastParent && lastParent.isTextblock) ? -1 : 1);
77
+ }
78
+ }
79
+ /**
80
+ Replace the selection with the given node, appending the changes
81
+ to the given transaction.
82
+ */
83
+ replaceWith(tr, node) {
84
+ let mapFrom = tr.steps.length, ranges = this.ranges;
85
+ for (let i = 0; i < ranges.length; i++) {
86
+ let { $from, $to } = ranges[i], mapping = tr.mapping.slice(mapFrom), from = mapping.map($from.pos), to = mapping.map($to.pos);
87
+ i ? tr.deleteRange(from, to) : (tr.replaceRangeWith(from, to, node), selectionToInsertionEnd(tr, mapFrom, node.isInline ? -1 : 1));
88
+ }
89
+ }
90
+ /**
91
+ Find a valid cursor or leaf node selection starting at the given
92
+ position and searching back if `dir` is negative, and forward if
93
+ positive. When `textOnly` is true, only consider cursor
94
+ selections. Will return null when no valid selection position is
95
+ found.
96
+ */
97
+ static findFrom($pos, dir, textOnly = !1) {
98
+ let inner = $pos.parent.inlineContent ? new TextSelection($pos) : findSelectionIn($pos.node(0), $pos.parent, $pos.pos, $pos.index(), dir, textOnly);
99
+ if (inner)
100
+ return inner;
101
+ for (let depth = $pos.depth - 1; depth >= 0; depth--) {
102
+ let found = dir < 0 ? findSelectionIn($pos.node(0), $pos.node(depth), $pos.before(depth + 1), $pos.index(depth), dir, textOnly) : findSelectionIn($pos.node(0), $pos.node(depth), $pos.after(depth + 1), $pos.index(depth) + 1, dir, textOnly);
103
+ if (found)
104
+ return found;
105
+ }
106
+ return null;
107
+ }
108
+ /**
109
+ Find a valid cursor or leaf node selection near the given
110
+ position. Searches forward first by default, but if `bias` is
111
+ negative, it will search backwards first.
112
+ */
113
+ static near($pos, bias = 1) {
114
+ return this.findFrom($pos, bias) || this.findFrom($pos, -bias) || new AllSelection($pos.node(0));
115
+ }
116
+ /**
117
+ Find the cursor or leaf node selection closest to the start of
118
+ the given document. Will return an
119
+ [`AllSelection`](https://prosemirror.net/docs/ref/#state.AllSelection) if no valid position
120
+ exists.
121
+ */
122
+ static atStart(doc) {
123
+ return findSelectionIn(doc, doc, 0, 0, 1) || new AllSelection(doc);
124
+ }
125
+ /**
126
+ Find the cursor or leaf node selection closest to the end of the
127
+ given document.
128
+ */
129
+ static atEnd(doc) {
130
+ return findSelectionIn(doc, doc, doc.content.size, doc.childCount, -1) || new AllSelection(doc);
131
+ }
132
+ /**
133
+ Deserialize the JSON representation of a selection. Must be
134
+ implemented for custom classes (as a static class method).
135
+ */
136
+ static fromJSON(doc, json) {
137
+ if (!json || !json.type)
138
+ throw new RangeError("Invalid input for Selection.fromJSON");
139
+ let cls = classesById[json.type];
140
+ if (!cls)
141
+ throw new RangeError(`No selection type ${json.type} defined`);
142
+ return cls.fromJSON(doc, json);
143
+ }
144
+ /**
145
+ To be able to deserialize selections from JSON, custom selection
146
+ classes must register themselves with an ID string, so that they
147
+ can be disambiguated. Try to pick something that's unlikely to
148
+ clash with classes from other modules.
149
+ */
150
+ static jsonID(id, selectionClass) {
151
+ if (id in classesById)
152
+ throw new RangeError("Duplicate use of selection JSON ID " + id);
153
+ return classesById[id] = selectionClass, selectionClass.prototype.jsonID = id, selectionClass;
154
+ }
155
+ /**
156
+ Get a [bookmark](https://prosemirror.net/docs/ref/#state.SelectionBookmark) for this selection,
157
+ which is a value that can be mapped without having access to a
158
+ current document, and later resolved to a real selection for a
159
+ given document again. (This is used mostly by the history to
160
+ track and restore old selections.) The default implementation of
161
+ this method just converts the selection to a text selection and
162
+ returns the bookmark for that.
163
+ */
164
+ getBookmark() {
165
+ return TextSelection.between(this.$anchor, this.$head).getBookmark();
166
+ }
167
+ }
168
+ Selection.prototype.visible = !0;
169
+ class SelectionRange {
170
+ /**
171
+ Create a range.
172
+ */
173
+ constructor($from, $to) {
174
+ this.$from = $from, this.$to = $to;
175
+ }
176
+ }
177
+ let warnedAboutTextSelection = !1;
178
+ function checkTextSelection($pos) {
179
+ !warnedAboutTextSelection && !$pos.parent.inlineContent && (warnedAboutTextSelection = !0, console.warn("TextSelection endpoint not pointing into a node with inline content (" + $pos.parent.type.name + ")"));
180
+ }
181
+ class TextSelection extends Selection {
182
+ /**
183
+ Construct a text selection between the given points.
184
+ */
185
+ constructor($anchor, $head = $anchor) {
186
+ checkTextSelection($anchor), checkTextSelection($head), super($anchor, $head);
187
+ }
188
+ /**
189
+ Returns a resolved position if this is a cursor selection (an
190
+ empty text selection), and null otherwise.
191
+ */
192
+ get $cursor() {
193
+ return this.$anchor.pos == this.$head.pos ? this.$head : null;
194
+ }
195
+ map(doc, mapping) {
196
+ let $head = doc.resolve(mapping.map(this.head));
197
+ if (!$head.parent.inlineContent)
198
+ return Selection.near($head);
199
+ let $anchor = doc.resolve(mapping.map(this.anchor));
200
+ return new TextSelection($anchor.parent.inlineContent ? $anchor : $head, $head);
201
+ }
202
+ replace(tr, content = Slice.empty) {
203
+ if (super.replace(tr, content), content == Slice.empty) {
204
+ let marks = this.$from.marksAcross(this.$to);
205
+ marks && tr.ensureMarks(marks);
206
+ }
207
+ }
208
+ eq(other) {
209
+ return other instanceof TextSelection && other.anchor == this.anchor && other.head == this.head;
210
+ }
211
+ getBookmark() {
212
+ return new TextBookmark(this.anchor, this.head);
213
+ }
214
+ toJSON() {
215
+ return { type: "text", anchor: this.anchor, head: this.head };
216
+ }
217
+ /**
218
+ @internal
219
+ */
220
+ static fromJSON(doc, json) {
221
+ if (typeof json.anchor != "number" || typeof json.head != "number")
222
+ throw new RangeError("Invalid input for TextSelection.fromJSON");
223
+ return new TextSelection(doc.resolve(json.anchor), doc.resolve(json.head));
224
+ }
225
+ /**
226
+ Create a text selection from non-resolved positions.
227
+ */
228
+ static create(doc, anchor, head = anchor) {
229
+ let $anchor = doc.resolve(anchor);
230
+ return new this($anchor, head == anchor ? $anchor : doc.resolve(head));
231
+ }
232
+ /**
233
+ Return a text selection that spans the given positions or, if
234
+ they aren't text positions, find a text selection near them.
235
+ `bias` determines whether the method searches forward (default)
236
+ or backwards (negative number) first. Will fall back to calling
237
+ [`Selection.near`](https://prosemirror.net/docs/ref/#state.Selection^near) when the document
238
+ doesn't contain a valid text position.
239
+ */
240
+ static between($anchor, $head, bias) {
241
+ let dPos = $anchor.pos - $head.pos;
242
+ if ((!bias || dPos) && (bias = dPos >= 0 ? 1 : -1), !$head.parent.inlineContent) {
243
+ let found = Selection.findFrom($head, bias, !0) || Selection.findFrom($head, -bias, !0);
244
+ if (found)
245
+ $head = found.$head;
246
+ else
247
+ return Selection.near($head, bias);
248
+ }
249
+ return $anchor.parent.inlineContent || (dPos == 0 ? $anchor = $head : ($anchor = (Selection.findFrom($anchor, -bias, !0) || Selection.findFrom($anchor, bias, !0)).$anchor, $anchor.pos < $head.pos != dPos < 0 && ($anchor = $head))), new TextSelection($anchor, $head);
250
+ }
251
+ }
252
+ Selection.jsonID("text", TextSelection);
253
+ class TextBookmark {
254
+ constructor(anchor, head) {
255
+ this.anchor = anchor, this.head = head;
256
+ }
257
+ map(mapping) {
258
+ return new TextBookmark(mapping.map(this.anchor), mapping.map(this.head));
259
+ }
260
+ resolve(doc) {
261
+ return TextSelection.between(doc.resolve(this.anchor), doc.resolve(this.head));
262
+ }
263
+ }
264
+ class NodeSelection extends Selection {
265
+ /**
266
+ Create a node selection. Does not verify the validity of its
267
+ argument.
268
+ */
269
+ constructor($pos) {
270
+ let node = $pos.nodeAfter, $end = $pos.node(0).resolve($pos.pos + node.nodeSize);
271
+ super($pos, $end), this.node = node;
272
+ }
273
+ map(doc, mapping) {
274
+ let { deleted, pos } = mapping.mapResult(this.anchor), $pos = doc.resolve(pos);
275
+ return deleted ? Selection.near($pos) : new NodeSelection($pos);
276
+ }
277
+ content() {
278
+ return new Slice(Fragment.from(this.node), 0, 0);
279
+ }
280
+ eq(other) {
281
+ return other instanceof NodeSelection && other.anchor == this.anchor;
282
+ }
283
+ toJSON() {
284
+ return { type: "node", anchor: this.anchor };
285
+ }
286
+ getBookmark() {
287
+ return new NodeBookmark(this.anchor);
288
+ }
289
+ /**
290
+ @internal
291
+ */
292
+ static fromJSON(doc, json) {
293
+ if (typeof json.anchor != "number")
294
+ throw new RangeError("Invalid input for NodeSelection.fromJSON");
295
+ return new NodeSelection(doc.resolve(json.anchor));
296
+ }
297
+ /**
298
+ Create a node selection from non-resolved positions.
299
+ */
300
+ static create(doc, from) {
301
+ return new NodeSelection(doc.resolve(from));
302
+ }
303
+ /**
304
+ Determines whether the given node may be selected as a node
305
+ selection.
306
+ */
307
+ static isSelectable(node) {
308
+ return !node.isText && node.type.spec.selectable !== !1;
309
+ }
310
+ }
311
+ NodeSelection.prototype.visible = !1;
312
+ Selection.jsonID("node", NodeSelection);
313
+ class NodeBookmark {
314
+ constructor(anchor) {
315
+ this.anchor = anchor;
316
+ }
317
+ map(mapping) {
318
+ let { deleted, pos } = mapping.mapResult(this.anchor);
319
+ return deleted ? new TextBookmark(pos, pos) : new NodeBookmark(pos);
320
+ }
321
+ resolve(doc) {
322
+ let $pos = doc.resolve(this.anchor), node = $pos.nodeAfter;
323
+ return node && NodeSelection.isSelectable(node) ? new NodeSelection($pos) : Selection.near($pos);
324
+ }
325
+ }
326
+ class AllSelection extends Selection {
327
+ /**
328
+ Create an all-selection over the given document.
329
+ */
330
+ constructor(doc) {
331
+ super(doc.resolve(0), doc.resolve(doc.content.size));
332
+ }
333
+ replace(tr, content = Slice.empty) {
334
+ if (content == Slice.empty) {
335
+ tr.delete(0, tr.doc.content.size);
336
+ let sel = Selection.atStart(tr.doc);
337
+ sel.eq(tr.selection) || tr.setSelection(sel);
338
+ } else
339
+ super.replace(tr, content);
340
+ }
341
+ toJSON() {
342
+ return { type: "all" };
343
+ }
344
+ /**
345
+ @internal
346
+ */
347
+ static fromJSON(doc) {
348
+ return new AllSelection(doc);
349
+ }
350
+ map(doc) {
351
+ return new AllSelection(doc);
352
+ }
353
+ eq(other) {
354
+ return other instanceof AllSelection;
355
+ }
356
+ getBookmark() {
357
+ return AllBookmark;
358
+ }
359
+ }
360
+ Selection.jsonID("all", AllSelection);
361
+ const AllBookmark = {
362
+ map() {
363
+ return this;
364
+ },
365
+ resolve(doc) {
366
+ return new AllSelection(doc);
367
+ }
368
+ };
369
+ function findSelectionIn(doc, node, pos, index, dir, text = !1) {
370
+ if (node.inlineContent)
371
+ return TextSelection.create(doc, pos);
372
+ for (let i = index - (dir > 0 ? 0 : 1); dir > 0 ? i < node.childCount : i >= 0; i += dir) {
373
+ let child = node.child(i);
374
+ if (child.isAtom) {
375
+ if (!text && NodeSelection.isSelectable(child))
376
+ return NodeSelection.create(doc, pos - (dir < 0 ? child.nodeSize : 0));
377
+ } else {
378
+ let inner = findSelectionIn(doc, child, pos + dir, dir < 0 ? child.childCount : 0, dir, text);
379
+ if (inner)
380
+ return inner;
381
+ }
382
+ pos += child.nodeSize * dir;
383
+ }
384
+ return null;
385
+ }
386
+ function selectionToInsertionEnd(tr, startLen, bias) {
387
+ let last = tr.steps.length - 1;
388
+ if (last < startLen)
389
+ return;
390
+ let step = tr.steps[last];
391
+ if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep))
392
+ return;
393
+ let map = tr.mapping.maps[last], end;
394
+ map.forEach((_from, _to, _newFrom, newTo) => {
395
+ end == null && (end = newTo);
396
+ }), tr.setSelection(Selection.near(tr.doc.resolve(end), bias));
397
+ }
398
+ function bind(f, self) {
399
+ return !self || !f ? f : f.bind(self);
400
+ }
401
+ class FieldDesc {
402
+ constructor(name, desc, self) {
403
+ this.name = name, this.init = bind(desc.init, self), this.apply = bind(desc.apply, self);
404
+ }
405
+ }
406
+ new FieldDesc("doc", {
407
+ init(config) {
408
+ return config.doc || config.schema.topNodeType.createAndFill();
409
+ },
410
+ apply(tr) {
411
+ return tr.doc;
412
+ }
413
+ }), new FieldDesc("selection", {
414
+ init(config, instance) {
415
+ return config.selection || Selection.atStart(instance.doc);
416
+ },
417
+ apply(tr) {
418
+ return tr.selection;
419
+ }
420
+ }), new FieldDesc("storedMarks", {
421
+ init(config) {
422
+ return config.storedMarks || null;
423
+ },
424
+ apply(tr, _marks, _old, state) {
425
+ return state.selection.$cursor ? tr.storedMarks : null;
426
+ }
427
+ }), new FieldDesc("scrollToSelection", {
428
+ init() {
429
+ return 0;
430
+ },
431
+ apply(tr, prev) {
432
+ return tr.scrolledIntoView ? prev + 1 : prev;
433
+ }
434
+ });
435
+ function bindProps(obj, self, target) {
436
+ for (let prop in obj) {
437
+ let val = obj[prop];
438
+ val instanceof Function ? val = val.bind(self) : prop == "handleDOMEvents" && (val = bindProps(val, self, {})), target[prop] = val;
439
+ }
440
+ return target;
441
+ }
442
+ class Plugin {
443
+ /**
444
+ Create a plugin.
445
+ */
446
+ constructor(spec) {
447
+ this.spec = spec, this.props = {}, spec.props && bindProps(spec.props, this, this.props), this.key = spec.key ? spec.key.key : createKey("plugin");
448
+ }
449
+ /**
450
+ Extract the plugin's state field from an editor state.
451
+ */
452
+ getState(state) {
453
+ return state[this.key];
454
+ }
455
+ }
456
+ const keys = /* @__PURE__ */ Object.create(null);
457
+ function createKey(name) {
458
+ return name in keys ? name + "$" + ++keys[name] : (keys[name] = 0, name + "$");
459
+ }
460
+ class PluginKey {
461
+ /**
462
+ Create a plugin key.
463
+ */
464
+ constructor(name = "key") {
465
+ this.key = createKey(name);
466
+ }
467
+ /**
468
+ Get the active plugin with this key, if any, from an editor
469
+ state.
470
+ */
471
+ get(state) {
472
+ return state.config.pluginsByKey[this.key];
473
+ }
474
+ /**
475
+ Get the plugin's state from an editor state.
476
+ */
477
+ getState(state) {
478
+ return state[this.key];
479
+ }
480
+ }
481
+ export {
482
+ AllSelection,
483
+ NodeSelection,
484
+ Plugin,
485
+ PluginKey,
486
+ Selection,
487
+ SelectionRange,
488
+ TextSelection
489
+ };