@edifice.io/react 2.5.22 → 2.5.23-chore-tiptap-v3.20260930150159
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/AppIcon/AppIcon.js +4 -1
- package/dist/components/Avatar/Avatar.d.ts +2 -2
- package/dist/components/Avatar/Avatar.js +2 -1
- package/dist/components/BetaSwitch/BetaSwitch.d.ts +13 -0
- package/dist/components/BetaSwitch/BetaSwitch.js +27 -0
- package/dist/components/BetaSwitch/index.d.ts +1 -0
- package/dist/components/ButtonBeta/ButtonBeta.d.ts +47 -0
- package/dist/components/ButtonBeta/ButtonBeta.js +34 -0
- package/dist/components/ButtonBeta/index.d.ts +2 -0
- package/dist/components/Dropdown/DropdownTrigger.d.ts +1 -1
- package/dist/components/Flex/Flex.js +5 -1
- package/dist/components/Logo/index.d.ts +1 -1
- package/dist/components/LogoBeta/LogoBeta.d.ts +7 -0
- package/dist/components/LogoBeta/LogoBeta.js +14 -0
- package/dist/components/LogoBeta/index.d.ts +2 -0
- package/dist/components/MediaViewer/MediaViewer.d.ts +1 -1
- package/dist/components/MediaViewer/MediaWrapper.d.ts +1 -1
- package/dist/components/PageLayout/PageLayout.d.ts +45 -0
- package/dist/components/PageLayout/PageLayout.js +94 -0
- package/dist/components/PageLayout/PageLayoutContext.d.ts +14 -0
- package/dist/components/PageLayout/PageLayoutContext.js +8 -0
- package/dist/components/PageLayout/components/PageLayoutBreadcrumb.d.ts +9 -0
- package/dist/components/PageLayout/components/PageLayoutBreadcrumb.js +10 -0
- package/dist/components/PageLayout/components/PageLayoutContent.d.ts +9 -0
- package/dist/components/PageLayout/components/PageLayoutContent.js +18 -0
- package/dist/components/PageLayout/components/PageLayoutHeader.d.ts +10 -0
- package/dist/components/PageLayout/components/PageLayoutHeader.js +18 -0
- package/dist/components/PageLayout/components/PageLayoutOverlay.d.ts +15 -0
- package/dist/components/PageLayout/components/PageLayoutOverlay.js +51 -0
- package/dist/components/PageLayout/components/PageLayoutSidebarLeft.d.ts +9 -0
- package/dist/components/PageLayout/components/PageLayoutSidebarLeft.js +18 -0
- package/dist/components/PageLayout/components/PageLayoutSidebarRight.d.ts +9 -0
- package/dist/components/PageLayout/components/PageLayoutSidebarRight.js +18 -0
- package/dist/components/PageLayout/hook/useOverlay.d.ts +5 -0
- package/dist/components/PageLayout/hook/useOverlay.js +15 -0
- package/dist/components/PageLayout/index.d.ts +4 -0
- package/dist/components/PageLayout/store/overlayStore.d.ts +15 -0
- package/dist/components/PageLayout/store/overlayStore.js +12 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/editor.js +2 -0
- package/dist/homepage.js +34 -0
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/useEdificeIcons/useEdificeIcons.js +10 -9
- package/dist/hooks/useScreeb/index.d.ts +1 -1
- package/dist/icons-nav.js +38 -28
- package/dist/index.js +215 -202
- package/dist/modules/editor/components/BubbleMenuEditImage/BubbleMenuEditImage.js +97 -90
- package/dist/modules/editor/components/BubbleMenuEditInformationPane/BubbleMenuEditInformationPane.js +111 -95
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.js +3 -2
- package/dist/modules/editor/components/Toolbar/LinkToolbar.FloatingOptions.js +12 -0
- package/dist/modules/editor/components/Toolbar/LinkToolbar.js +5 -4
- package/dist/modules/editor/components/Toolbar/TableToolbar.js +10 -5
- package/dist/modules/editor/hooks/index.d.ts +1 -0
- package/dist/modules/editor/hooks/useCommentEditor.d.ts +1 -1
- package/dist/modules/editor/hooks/useCommentEditor.js +1 -1
- package/dist/modules/editor/hooks/useEditorState.d.ts +20 -0
- package/dist/modules/editor/hooks/useEditorState.js +16 -0
- package/dist/modules/editor/hooks/useTipTapEditor.d.ts +1 -1
- package/dist/modules/editor/hooks/useTipTapEditor.js +4 -8
- package/dist/modules/homepage/components/Favorites/Favorites.d.ts +6 -0
- package/dist/modules/homepage/components/Favorites/Favorites.js +28 -0
- package/dist/modules/homepage/components/Favorites/FavoritesContainer.d.ts +4 -0
- package/dist/modules/homepage/components/Favorites/FavoritesContainer.js +10 -0
- package/dist/modules/homepage/components/Favorites/index.d.ts +2 -0
- package/dist/modules/homepage/components/Header/Header.d.ts +9 -0
- package/dist/modules/homepage/components/Header/Header.js +80 -0
- package/dist/modules/homepage/components/Header/index.d.ts +2 -0
- package/dist/modules/homepage/components/HomeCard/HomeCard.d.ts +37 -0
- package/dist/modules/homepage/components/HomeCard/HomeCard.js +17 -0
- package/dist/modules/homepage/components/HomeCard/HomeCardContent.d.ts +7 -0
- package/dist/modules/homepage/components/HomeCard/HomeCardContent.js +10 -0
- package/dist/modules/homepage/components/HomeCard/HomeCardHeader.d.ts +18 -0
- package/dist/modules/homepage/components/HomeCard/HomeCardHeader.js +22 -0
- package/dist/modules/homepage/components/HomeCard/index.d.ts +4 -0
- package/dist/modules/homepage/components/LastInfos/LastInfos.d.ts +49 -0
- package/dist/modules/homepage/components/LastInfos/LastInfos.js +58 -0
- package/dist/modules/homepage/components/LastInfos/LastInfosContainer.d.ts +4 -0
- package/dist/modules/homepage/components/LastInfos/LastInfosContainer.js +37 -0
- package/dist/modules/homepage/components/LastInfos/LastInfosList.d.ts +13 -0
- package/dist/modules/homepage/components/LastInfos/LastInfosList.js +31 -0
- package/dist/modules/homepage/components/LastInfos/index.d.ts +4 -0
- package/dist/modules/homepage/components/LastInfos/useLastInfos.d.ts +18 -0
- package/dist/modules/homepage/components/LastInfos/useLastInfos.js +25 -0
- package/dist/modules/homepage/components/MessageFlashList/MessageFlash.d.ts +12 -0
- package/dist/modules/homepage/components/MessageFlashList/MessageFlash.js +65 -0
- package/dist/modules/homepage/components/MessageFlashList/MessageFlashList.d.ts +12 -0
- package/dist/modules/homepage/components/MessageFlashList/MessageFlashList.js +10 -0
- package/dist/modules/homepage/components/MessageFlashList/MessageFlashListContainer.d.ts +5 -0
- package/dist/modules/homepage/components/MessageFlashList/MessageFlashListContainer.js +14 -0
- package/dist/modules/homepage/components/MessageFlashList/hooks/useMessageFlashList.d.ts +16 -0
- package/dist/modules/homepage/components/MessageFlashList/hooks/useMessageFlashList.js +19 -0
- package/dist/modules/homepage/components/MessageFlashList/index.d.ts +4 -0
- package/dist/modules/homepage/components/MessageFlashList/services/api/index.d.ts +4 -0
- package/dist/modules/homepage/components/MessageFlashList/services/api/index.js +5 -0
- package/dist/modules/homepage/components/MessageFlashList/services/api/messagesFlashService.d.ts +20 -0
- package/dist/modules/homepage/components/MessageFlashList/services/api/messagesFlashService.js +21 -0
- package/dist/modules/homepage/components/MessageFlashList/services/queries/messagesFlash.d.ts +13 -0
- package/dist/modules/homepage/components/MessageFlashList/services/queries/messagesFlash.js +31 -0
- package/dist/modules/homepage/components/Notifications/Notification.d.ts +20 -0
- package/dist/modules/homepage/components/Notifications/Notification.js +16 -0
- package/dist/modules/homepage/components/Notifications/NotificationList.d.ts +18 -0
- package/dist/modules/homepage/components/Notifications/NotificationList.js +44 -0
- package/dist/modules/homepage/components/Notifications/NotificationListContainer.d.ts +9 -0
- package/dist/modules/homepage/components/Notifications/NotificationListContainer.js +20 -0
- package/dist/modules/homepage/components/Notifications/NotificationListSkeleton.d.ts +5 -0
- package/dist/modules/homepage/components/Notifications/NotificationListSkeleton.js +17 -0
- package/dist/modules/homepage/components/Notifications/NotificationSkeleton.d.ts +3 -0
- package/dist/modules/homepage/components/Notifications/NotificationSkeleton.js +19 -0
- package/dist/modules/homepage/components/Notifications/components/NotificationItem.d.ts +24 -0
- package/dist/modules/homepage/components/Notifications/components/NotificationItem.js +28 -0
- package/dist/modules/homepage/components/Notifications/components/NotificationResource.d.ts +15 -0
- package/dist/modules/homepage/components/Notifications/components/NotificationResource.js +19 -0
- package/dist/modules/homepage/components/Notifications/components/SystemNotification.d.ts +15 -0
- package/dist/modules/homepage/components/Notifications/components/SystemNotification.js +20 -0
- package/dist/modules/homepage/components/Notifications/components/UserNotification.d.ts +15 -0
- package/dist/modules/homepage/components/Notifications/components/UserNotification.js +25 -0
- package/dist/modules/homepage/components/Notifications/components/notificationAdapter.d.ts +27 -0
- package/dist/modules/homepage/components/Notifications/components/notificationAdapter.js +53 -0
- package/dist/modules/homepage/components/Notifications/hooks/useNotificationList.d.ts +20 -0
- package/dist/modules/homepage/components/Notifications/hooks/useNotificationList.js +26 -0
- package/dist/modules/homepage/components/Notifications/index.d.ts +6 -0
- package/dist/modules/homepage/components/Notifications/services/api/index.d.ts +4 -0
- package/dist/modules/homepage/components/Notifications/services/api/index.js +5 -0
- package/dist/modules/homepage/components/Notifications/services/api/notificationService.d.ts +15 -0
- package/dist/modules/homepage/components/Notifications/services/api/notificationService.js +22 -0
- package/dist/modules/homepage/components/Notifications/services/queries/notification.d.ts +20 -0
- package/dist/modules/homepage/components/Notifications/services/queries/notification.js +40 -0
- package/dist/modules/homepage/components/SchoolSpace/SchoolSpace.d.ts +15 -0
- package/dist/modules/homepage/components/SchoolSpace/SchoolSpace.js +29 -0
- package/dist/modules/homepage/components/SchoolSpace/SchoolSpaceContainer.d.ts +4 -0
- package/dist/modules/homepage/components/SchoolSpace/SchoolSpaceContainer.js +13 -0
- package/dist/modules/homepage/components/SchoolSpace/index.d.ts +3 -0
- package/dist/modules/homepage/components/SchoolSpace/useUserSchools.d.ts +6 -0
- package/dist/modules/homepage/components/SchoolSpace/useUserSchools.js +39 -0
- package/dist/modules/homepage/components/UserSpace/UserSpace.d.ts +13 -0
- package/dist/modules/homepage/components/UserSpace/UserSpace.js +28 -0
- package/dist/modules/homepage/components/UserSpace/UserSpaceContainer.d.ts +7 -0
- package/dist/modules/homepage/components/UserSpace/UserSpaceContainer.js +19 -0
- package/dist/modules/homepage/components/UserSpace/index.d.ts +3 -0
- package/dist/modules/homepage/components/index.d.ts +8 -0
- package/dist/modules/homepage/hooks/useWidget.d.ts +6 -0
- package/dist/modules/homepage/hooks/useWidget.js +83 -0
- package/dist/modules/homepage/hooks/useWidgetPreferences.d.ts +6 -0
- package/dist/modules/homepage/hooks/useWidgetPreferences.js +34 -0
- package/dist/modules/homepage/index.d.ts +1 -0
- package/dist/modules/icons/components/nav/IconCommunitiesBeta.d.ts +7 -0
- package/dist/modules/icons/components/nav/IconCommunitiesBeta.js +18 -0
- package/dist/modules/icons/components/nav/IconHomeBeta.d.ts +7 -0
- package/dist/modules/icons/components/nav/IconHomeBeta.js +13 -0
- package/dist/modules/icons/components/{IconStarFavorite.d.ts → nav/IconMessagesBeta.d.ts} +2 -2
- package/dist/modules/icons/components/nav/IconMessagesBeta.js +18 -0
- package/dist/modules/icons/components/nav/IconMyAppsBeta.d.ts +7 -0
- package/dist/modules/icons/components/nav/IconMyAppsBeta.js +13 -0
- package/dist/modules/icons/components/nav/IconNotificationBeta.d.ts +7 -0
- package/dist/modules/icons/components/nav/IconNotificationBeta.js +14 -0
- package/dist/modules/icons/components/nav/index.d.ts +5 -0
- package/dist/modules/modals/OnboardingModal/index.d.ts +1 -1
- package/dist/node_modules/.pnpm/@tiptap_extension-floating-menu@3.31.3_@floating-ui_dom@1.6.0_@tiptap_core@3.10.2_@tiptap_pm@3.10.2__@tiptap_pm@3.10.2/node_modules/@tiptap/extension-floating-menu/dist/index.js +159 -0
- package/dist/node_modules/.pnpm/@tiptap_react@3.10.2_@floating-ui_dom@1.6.0_@tiptap_core@3.10.2_@tiptap_pm@3.10.2__@tiptap_pm_dubv75vojf3t6hpx6vhaocpyzq/node_modules/@tiptap/react/dist/menus/index.js +89 -0
- package/dist/node_modules/.pnpm/prosemirror-model@1.25.12/node_modules/prosemirror-model/dist/index.js +419 -0
- package/dist/node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.js +489 -0
- package/dist/node_modules/.pnpm/prosemirror-transform@1.12.2/node_modules/prosemirror-transform/dist/index.js +607 -0
- package/dist/providers/EdificeClientProvider/EdificeClientProvider.d.ts +0 -7
- package/dist/utilities/create-selectors/createSelectors.d.ts +10 -0
- package/dist/utilities/create-selectors/createSelectors.js +11 -0
- package/package.json +47 -49
- package/dist/modules/editor/components/Toolbar/LinkToolbar.TippyOptions.d.ts +0 -2
- package/dist/modules/editor/components/Toolbar/LinkToolbar.TippyOptions.js +0 -8
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
function findDiffStart(a, b, pos) {
|
|
2
|
+
for (let i = 0; ; i++) {
|
|
3
|
+
if (i == a.childCount || i == b.childCount)
|
|
4
|
+
return a.childCount == b.childCount ? null : pos;
|
|
5
|
+
let childA = a.child(i), childB = b.child(i);
|
|
6
|
+
if (childA == childB) {
|
|
7
|
+
pos += childA.nodeSize;
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
if (!childA.sameMarkup(childB))
|
|
11
|
+
return pos;
|
|
12
|
+
if (childA.isText && childA.text != childB.text) {
|
|
13
|
+
let tA = childA.text, tB = childB.text, j = 0;
|
|
14
|
+
for (; tA[j] == tB[j]; j++)
|
|
15
|
+
pos++;
|
|
16
|
+
return j && j < tA.length && j < tB.length && surrogateHigh(tA.charCodeAt(j - 1)) && surrogateLow(tA.charCodeAt(j)) && pos--, pos;
|
|
17
|
+
}
|
|
18
|
+
if (childA.content.size || childB.content.size) {
|
|
19
|
+
let inner = findDiffStart(childA.content, childB.content, pos + 1);
|
|
20
|
+
if (inner != null)
|
|
21
|
+
return inner;
|
|
22
|
+
}
|
|
23
|
+
pos += childA.nodeSize;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function findDiffEnd(a, b, posA, posB) {
|
|
27
|
+
for (let iA = a.childCount, iB = b.childCount; ; ) {
|
|
28
|
+
if (iA == 0 || iB == 0)
|
|
29
|
+
return iA == iB ? null : { a: posA, b: posB };
|
|
30
|
+
let childA = a.child(--iA), childB = b.child(--iB), size = childA.nodeSize;
|
|
31
|
+
if (childA == childB) {
|
|
32
|
+
posA -= size, posB -= size;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (!childA.sameMarkup(childB))
|
|
36
|
+
return { a: posA, b: posB };
|
|
37
|
+
if (childA.isText && childA.text != childB.text) {
|
|
38
|
+
let tA = childA.text, tB = childB.text, iA2 = tA.length, iB2 = tB.length;
|
|
39
|
+
for (; iA2 > 0 && iB2 > 0 && tA[iA2 - 1] == tB[iB2 - 1]; )
|
|
40
|
+
iA2--, iB2--, posA--, posB--;
|
|
41
|
+
return iA2 && iB2 && iA2 < tA.length && surrogateHigh(tA.charCodeAt(iA2 - 1)) && surrogateLow(tA.charCodeAt(iA2)) && (posA++, posB++), { a: posA, b: posB };
|
|
42
|
+
}
|
|
43
|
+
if (childA.content.size || childB.content.size) {
|
|
44
|
+
let inner = findDiffEnd(childA.content, childB.content, posA - 1, posB - 1);
|
|
45
|
+
if (inner)
|
|
46
|
+
return inner;
|
|
47
|
+
}
|
|
48
|
+
posA -= size, posB -= size;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function surrogateLow(ch) {
|
|
52
|
+
return ch >= 56320 && ch < 57344;
|
|
53
|
+
}
|
|
54
|
+
function surrogateHigh(ch) {
|
|
55
|
+
return ch >= 55296 && ch < 56320;
|
|
56
|
+
}
|
|
57
|
+
class Fragment {
|
|
58
|
+
/**
|
|
59
|
+
@internal
|
|
60
|
+
*/
|
|
61
|
+
constructor(content, size) {
|
|
62
|
+
if (this.content = content, this.size = size || 0, size == null)
|
|
63
|
+
for (let i = 0; i < content.length; i++)
|
|
64
|
+
this.size += content[i].nodeSize;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
Invoke a callback for all descendant nodes between the given two
|
|
68
|
+
positions (relative to start of this fragment). Doesn't descend
|
|
69
|
+
into a node when the callback returns `false`.
|
|
70
|
+
*/
|
|
71
|
+
nodesBetween(from, to, f, nodeStart = 0, parent) {
|
|
72
|
+
for (let i = 0, pos = 0; pos < to; i++) {
|
|
73
|
+
let child = this.content[i], end = pos + child.nodeSize;
|
|
74
|
+
if (end > from && f(child, nodeStart + pos, parent || null, i) !== !1 && child.content.size) {
|
|
75
|
+
let start = pos + 1;
|
|
76
|
+
child.nodesBetween(Math.max(0, from - start), Math.min(child.content.size, to - start), f, nodeStart + start);
|
|
77
|
+
}
|
|
78
|
+
pos = end;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
Call the given callback for every descendant node. `pos` will be
|
|
83
|
+
relative to the start of the fragment. The callback may return
|
|
84
|
+
`false` to prevent traversal of a given node's children.
|
|
85
|
+
*/
|
|
86
|
+
descendants(f) {
|
|
87
|
+
this.nodesBetween(0, this.size, f);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
Extract the text between `from` and `to`. See the same method on
|
|
91
|
+
[`Node`](https://prosemirror.net/docs/ref/#model.Node.textBetween).
|
|
92
|
+
*/
|
|
93
|
+
textBetween(from, to, blockSeparator, leafText) {
|
|
94
|
+
let text = "", first = !0;
|
|
95
|
+
return this.nodesBetween(from, to, (node, pos) => {
|
|
96
|
+
let nodeText = node.isText ? node.text.slice(Math.max(from, pos) - pos, to - pos) : node.isLeaf ? leafText ? typeof leafText == "function" ? leafText(node) : leafText : node.type.spec.leafText ? node.type.spec.leafText(node) : "" : "";
|
|
97
|
+
node.isBlock && (node.isLeaf && nodeText || node.isTextblock) && blockSeparator && (first ? first = !1 : text += blockSeparator), text += nodeText;
|
|
98
|
+
}, 0), text;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
Create a new fragment containing the combined content of this
|
|
102
|
+
fragment and the other.
|
|
103
|
+
*/
|
|
104
|
+
append(other) {
|
|
105
|
+
if (!other.size)
|
|
106
|
+
return this;
|
|
107
|
+
if (!this.size)
|
|
108
|
+
return other;
|
|
109
|
+
let last = this.lastChild, first = other.firstChild, content = this.content.slice(), i = 0;
|
|
110
|
+
for (last.isText && last.sameMarkup(first) && (content[content.length - 1] = last.withText(last.text + first.text), i = 1); i < other.content.length; i++)
|
|
111
|
+
content.push(other.content[i]);
|
|
112
|
+
return new Fragment(content, this.size + other.size);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
Cut out the sub-fragment between the two given positions.
|
|
116
|
+
*/
|
|
117
|
+
cut(from, to = this.size) {
|
|
118
|
+
if (from == 0 && to == this.size)
|
|
119
|
+
return this;
|
|
120
|
+
let result = [], size = 0;
|
|
121
|
+
if (to > from)
|
|
122
|
+
for (let i = 0, pos = 0; pos < to; i++) {
|
|
123
|
+
let child = this.content[i], end = pos + child.nodeSize;
|
|
124
|
+
end > from && ((pos < from || end > to) && (child.isText ? child = child.cut(Math.max(0, from - pos), Math.min(child.text.length, to - pos)) : child = child.cut(Math.max(0, from - pos - 1), Math.min(child.content.size, to - pos - 1))), result.push(child), size += child.nodeSize), pos = end;
|
|
125
|
+
}
|
|
126
|
+
return new Fragment(result, size);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
@internal
|
|
130
|
+
*/
|
|
131
|
+
cutByIndex(from, to) {
|
|
132
|
+
return from == to ? Fragment.empty : from == 0 && to == this.content.length ? this : new Fragment(this.content.slice(from, to));
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
Create a new fragment in which the node at the given index is
|
|
136
|
+
replaced by the given node.
|
|
137
|
+
*/
|
|
138
|
+
replaceChild(index, node) {
|
|
139
|
+
let current = this.content[index];
|
|
140
|
+
if (current == node)
|
|
141
|
+
return this;
|
|
142
|
+
let copy = this.content.slice(), size = this.size + node.nodeSize - current.nodeSize;
|
|
143
|
+
return copy[index] = node, new Fragment(copy, size);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
Create a new fragment by prepending the given node to this
|
|
147
|
+
fragment.
|
|
148
|
+
*/
|
|
149
|
+
addToStart(node) {
|
|
150
|
+
return new Fragment([node].concat(this.content), this.size + node.nodeSize);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
Create a new fragment by appending the given node to this
|
|
154
|
+
fragment.
|
|
155
|
+
*/
|
|
156
|
+
addToEnd(node) {
|
|
157
|
+
return new Fragment(this.content.concat(node), this.size + node.nodeSize);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
Compare this fragment to another one.
|
|
161
|
+
*/
|
|
162
|
+
eq(other) {
|
|
163
|
+
if (this.content.length != other.content.length)
|
|
164
|
+
return !1;
|
|
165
|
+
for (let i = 0; i < this.content.length; i++)
|
|
166
|
+
if (!this.content[i].eq(other.content[i]))
|
|
167
|
+
return !1;
|
|
168
|
+
return !0;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
The first child of the fragment, or `null` if it is empty.
|
|
172
|
+
*/
|
|
173
|
+
get firstChild() {
|
|
174
|
+
return this.content.length ? this.content[0] : null;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
The last child of the fragment, or `null` if it is empty.
|
|
178
|
+
*/
|
|
179
|
+
get lastChild() {
|
|
180
|
+
return this.content.length ? this.content[this.content.length - 1] : null;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
The number of child nodes in this fragment.
|
|
184
|
+
*/
|
|
185
|
+
get childCount() {
|
|
186
|
+
return this.content.length;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
Get the child node at the given index. Raise an error when the
|
|
190
|
+
index is out of range.
|
|
191
|
+
*/
|
|
192
|
+
child(index) {
|
|
193
|
+
let found2 = this.content[index];
|
|
194
|
+
if (!found2)
|
|
195
|
+
throw new RangeError("Index " + index + " out of range for " + this);
|
|
196
|
+
return found2;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
Get the child node at the given index, if it exists.
|
|
200
|
+
*/
|
|
201
|
+
maybeChild(index) {
|
|
202
|
+
return this.content[index] || null;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
Call `f` for every child node, passing the node, its offset
|
|
206
|
+
into this parent node, and its index.
|
|
207
|
+
*/
|
|
208
|
+
forEach(f) {
|
|
209
|
+
for (let i = 0, p = 0; i < this.content.length; i++) {
|
|
210
|
+
let child = this.content[i];
|
|
211
|
+
f(child, p, i), p += child.nodeSize;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
Find the first position at which this fragment and another
|
|
216
|
+
fragment differ, or `null` if they are the same.
|
|
217
|
+
*/
|
|
218
|
+
findDiffStart(other, pos = 0) {
|
|
219
|
+
return findDiffStart(this, other, pos);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
Find the first position, searching from the end, at which this
|
|
223
|
+
fragment and the given fragment differ, or `null` if they are
|
|
224
|
+
the same. Since this position will not be the same in both
|
|
225
|
+
nodes, an object with two separate positions is returned.
|
|
226
|
+
*/
|
|
227
|
+
findDiffEnd(other, pos = this.size, otherPos = other.size) {
|
|
228
|
+
return findDiffEnd(this, other, pos, otherPos);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
Find the index and inner offset corresponding to a given relative
|
|
232
|
+
position in this fragment. The result object will be reused
|
|
233
|
+
(overwritten) the next time the function is called. @internal
|
|
234
|
+
*/
|
|
235
|
+
findIndex(pos) {
|
|
236
|
+
if (pos == 0)
|
|
237
|
+
return retIndex(0, pos);
|
|
238
|
+
if (pos == this.size)
|
|
239
|
+
return retIndex(this.content.length, pos);
|
|
240
|
+
if (pos > this.size || pos < 0)
|
|
241
|
+
throw new RangeError(`Position ${pos} outside of fragment (${this})`);
|
|
242
|
+
for (let i = 0, curPos = 0; ; i++) {
|
|
243
|
+
let cur = this.child(i), end = curPos + cur.nodeSize;
|
|
244
|
+
if (end >= pos)
|
|
245
|
+
return end == pos ? retIndex(i + 1, end) : retIndex(i, curPos);
|
|
246
|
+
curPos = end;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
Return a debugging string that describes this fragment.
|
|
251
|
+
*/
|
|
252
|
+
toString() {
|
|
253
|
+
return "<" + this.toStringInner() + ">";
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
@internal
|
|
257
|
+
*/
|
|
258
|
+
toStringInner() {
|
|
259
|
+
return this.content.join(", ");
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
Create a JSON-serializeable representation of this fragment.
|
|
263
|
+
*/
|
|
264
|
+
toJSON() {
|
|
265
|
+
return this.content.length ? this.content.map((n) => n.toJSON()) : null;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
Deserialize a fragment from its JSON representation.
|
|
269
|
+
*/
|
|
270
|
+
static fromJSON(schema, value) {
|
|
271
|
+
if (!value)
|
|
272
|
+
return Fragment.empty;
|
|
273
|
+
if (!Array.isArray(value))
|
|
274
|
+
throw new RangeError("Invalid input for Fragment.fromJSON");
|
|
275
|
+
return Fragment.fromArray(value.map(schema.nodeFromJSON));
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
Build a fragment from an array of nodes. Ensures that adjacent
|
|
279
|
+
text nodes with the same marks are joined together.
|
|
280
|
+
*/
|
|
281
|
+
static fromArray(array) {
|
|
282
|
+
if (!array.length)
|
|
283
|
+
return Fragment.empty;
|
|
284
|
+
let joined, size = 0;
|
|
285
|
+
for (let i = 0; i < array.length; i++) {
|
|
286
|
+
let node = array[i];
|
|
287
|
+
size += node.nodeSize, i && node.isText && array[i - 1].sameMarkup(node) ? (joined || (joined = array.slice(0, i)), joined[joined.length - 1] = node.withText(joined[joined.length - 1].text + node.text)) : joined && joined.push(node);
|
|
288
|
+
}
|
|
289
|
+
return new Fragment(joined || array, size);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
Create a fragment from something that can be interpreted as a
|
|
293
|
+
set of nodes. For `null`, it returns the empty fragment. For a
|
|
294
|
+
fragment, the fragment itself. For a node or array of nodes, a
|
|
295
|
+
fragment containing those nodes.
|
|
296
|
+
*/
|
|
297
|
+
static from(nodes) {
|
|
298
|
+
if (!nodes)
|
|
299
|
+
return Fragment.empty;
|
|
300
|
+
if (nodes instanceof Fragment)
|
|
301
|
+
return nodes;
|
|
302
|
+
if (Array.isArray(nodes))
|
|
303
|
+
return this.fromArray(nodes);
|
|
304
|
+
if (nodes.attrs)
|
|
305
|
+
return new Fragment([nodes], nodes.nodeSize);
|
|
306
|
+
throw new RangeError("Can not convert " + nodes + " to a Fragment" + (nodes.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
Fragment.empty = new Fragment([], 0);
|
|
310
|
+
const found = { index: 0, offset: 0 };
|
|
311
|
+
function retIndex(index, offset) {
|
|
312
|
+
return found.index = index, found.offset = offset, found;
|
|
313
|
+
}
|
|
314
|
+
class ReplaceError extends Error {
|
|
315
|
+
}
|
|
316
|
+
class Slice {
|
|
317
|
+
/**
|
|
318
|
+
Create a slice. When specifying a non-zero open depth, you must
|
|
319
|
+
make sure that there are nodes of at least that depth at the
|
|
320
|
+
appropriate side of the fragment—i.e. if the fragment is an
|
|
321
|
+
empty paragraph node, `openStart` and `openEnd` can't be greater
|
|
322
|
+
than 1.
|
|
323
|
+
|
|
324
|
+
It is not necessary for the content of open nodes to conform to
|
|
325
|
+
the schema's content constraints, though it should be a valid
|
|
326
|
+
start/end/middle for such a node, depending on which sides are
|
|
327
|
+
open.
|
|
328
|
+
*/
|
|
329
|
+
constructor(content, openStart, openEnd) {
|
|
330
|
+
this.content = content, this.openStart = openStart, this.openEnd = openEnd;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
The size this slice would add when inserted into a document.
|
|
334
|
+
*/
|
|
335
|
+
get size() {
|
|
336
|
+
return this.content.size - this.openStart - this.openEnd;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
@internal
|
|
340
|
+
*/
|
|
341
|
+
insertAt(pos, fragment) {
|
|
342
|
+
let content = insertInto(this.content, pos + this.openStart, fragment, this.openStart + 1, this.openEnd + 1);
|
|
343
|
+
return content && new Slice(content, this.openStart, this.openEnd);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
@internal
|
|
347
|
+
*/
|
|
348
|
+
removeBetween(from, to) {
|
|
349
|
+
return new Slice(removeRange(this.content, from + this.openStart, to + this.openStart), this.openStart, this.openEnd);
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
Tests whether this slice is equal to another slice.
|
|
353
|
+
*/
|
|
354
|
+
eq(other) {
|
|
355
|
+
return this.content.eq(other.content) && this.openStart == other.openStart && this.openEnd == other.openEnd;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
@internal
|
|
359
|
+
*/
|
|
360
|
+
toString() {
|
|
361
|
+
return this.content + "(" + this.openStart + "," + this.openEnd + ")";
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
Convert a slice to a JSON-serializable representation.
|
|
365
|
+
*/
|
|
366
|
+
toJSON() {
|
|
367
|
+
if (!this.content.size)
|
|
368
|
+
return null;
|
|
369
|
+
let json = { content: this.content.toJSON() };
|
|
370
|
+
return this.openStart > 0 && (json.openStart = this.openStart), this.openEnd > 0 && (json.openEnd = this.openEnd), json;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
Deserialize a slice from its JSON representation.
|
|
374
|
+
*/
|
|
375
|
+
static fromJSON(schema, json) {
|
|
376
|
+
if (!json)
|
|
377
|
+
return Slice.empty;
|
|
378
|
+
let openStart = json.openStart || 0, openEnd = json.openEnd || 0;
|
|
379
|
+
if (typeof openStart != "number" || typeof openEnd != "number")
|
|
380
|
+
throw new RangeError("Invalid input for Slice.fromJSON");
|
|
381
|
+
return new Slice(Fragment.fromJSON(schema, json.content), openStart, openEnd);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
Create a slice from a fragment by taking the maximum possible
|
|
385
|
+
open value on both side of the fragment.
|
|
386
|
+
*/
|
|
387
|
+
static maxOpen(fragment, openIsolating = !0) {
|
|
388
|
+
let openStart = 0, openEnd = 0;
|
|
389
|
+
for (let n = fragment.firstChild; n && !n.isLeaf && (openIsolating || !n.type.spec.isolating); n = n.firstChild)
|
|
390
|
+
openStart++;
|
|
391
|
+
for (let n = fragment.lastChild; n && !n.isLeaf && (openIsolating || !n.type.spec.isolating); n = n.lastChild)
|
|
392
|
+
openEnd++;
|
|
393
|
+
return new Slice(fragment, openStart, openEnd);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
Slice.empty = new Slice(Fragment.empty, 0, 0);
|
|
397
|
+
function removeRange(content, from, to) {
|
|
398
|
+
let { index, offset } = content.findIndex(from), child = content.maybeChild(index), { index: indexTo, offset: offsetTo } = content.findIndex(to);
|
|
399
|
+
if (offset == from || child.isText) {
|
|
400
|
+
if (offsetTo != to && !content.child(indexTo).isText)
|
|
401
|
+
throw new RangeError("Removing non-flat range");
|
|
402
|
+
return content.cut(0, from).append(content.cut(to));
|
|
403
|
+
}
|
|
404
|
+
if (index != indexTo)
|
|
405
|
+
throw new RangeError("Removing non-flat range");
|
|
406
|
+
return content.replaceChild(index, child.copy(removeRange(child.content, from - offset - 1, to - offset - 1)));
|
|
407
|
+
}
|
|
408
|
+
function insertInto(content, dist, insert, openStart, openEnd, parent) {
|
|
409
|
+
let { index, offset } = content.findIndex(dist), child = content.maybeChild(index);
|
|
410
|
+
if (offset == dist || child.isText)
|
|
411
|
+
return parent && openStart <= 0 && openEnd <= 0 && !parent.canReplace(index, index, insert) ? null : content.cut(0, dist).append(insert).append(content.cut(dist));
|
|
412
|
+
let inner = insertInto(child.content, dist - offset - 1, insert, index == 0 ? openStart - 1 : 0, index == content.childCount - 1 ? openEnd - 1 : 0, child);
|
|
413
|
+
return inner && content.replaceChild(index, child.copy(inner));
|
|
414
|
+
}
|
|
415
|
+
export {
|
|
416
|
+
Fragment,
|
|
417
|
+
ReplaceError,
|
|
418
|
+
Slice
|
|
419
|
+
};
|