@lofcz/platejs-suggestion 52.0.11 → 52.3.6
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/index.d.ts +45 -14
- package/dist/index.js +1 -1
- package/dist/react/index.d.ts +36 -3
- package/dist/react/index.js +2 -3
- package/dist/{src-COX5sId2.js → src-CruTaHKh.js} +27 -30
- package/package.json +4 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/index.js.map +0 -1
- package/dist/src-COX5sId2.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as platejs36 from "platejs";
|
|
2
|
+
import { Descendant, EditorNodesOptions, Node, NodeEntry, OverrideEditor, PluginConfig, SetNodesOptions, SlateEditor, TElement, TInlineSuggestionData, TLocation, TNode, TRange, TSuggestionElement, TSuggestionText, TText, Text, UnknownObject, ValueOf } from "platejs";
|
|
2
3
|
import { ComputeDiffOptions } from "@platejs/diff";
|
|
3
4
|
|
|
4
5
|
//#region src/lib/BaseSuggestionPlugin.d.ts
|
|
@@ -21,7 +22,38 @@ type BaseSuggestionConfig = PluginConfig<'suggestion', {
|
|
|
21
22
|
withoutSuggestions: (fn: () => void) => void;
|
|
22
23
|
};
|
|
23
24
|
}>;
|
|
24
|
-
declare const BaseSuggestionPlugin:
|
|
25
|
+
declare const BaseSuggestionPlugin: platejs36.SlatePlugin<PluginConfig<"suggestion", {
|
|
26
|
+
currentUserId: string | null;
|
|
27
|
+
isSuggesting: boolean;
|
|
28
|
+
}, {
|
|
29
|
+
suggestion: {
|
|
30
|
+
dataList: (node: TSuggestionText) => TInlineSuggestionData[];
|
|
31
|
+
isBlockSuggestion: (node: TNode) => node is TSuggestionElement;
|
|
32
|
+
node: (options?: EditorNodesOptions & {
|
|
33
|
+
id?: string;
|
|
34
|
+
isText?: boolean;
|
|
35
|
+
}) => NodeEntry<TSuggestionElement | TSuggestionText> | undefined;
|
|
36
|
+
nodeId: (node: TElement | TSuggestionText) => string | undefined;
|
|
37
|
+
nodes: (options?: EditorNodesOptions & {
|
|
38
|
+
transient?: boolean;
|
|
39
|
+
}) => NodeEntry<TElement | TSuggestionText>[];
|
|
40
|
+
suggestionData: (node: TElement | TSuggestionText) => TInlineSuggestionData | TSuggestionElement["suggestion"] | undefined;
|
|
41
|
+
withoutSuggestions: (fn: () => void) => void;
|
|
42
|
+
};
|
|
43
|
+
} & Record<"suggestion", {
|
|
44
|
+
dataList: (node: TSuggestionText) => TInlineSuggestionData[];
|
|
45
|
+
isBlockSuggestion: (node: TNode) => node is TSuggestionElement;
|
|
46
|
+
node: (options?: EditorNodesOptions & {
|
|
47
|
+
id?: string;
|
|
48
|
+
isText?: boolean;
|
|
49
|
+
}) => NodeEntry<TSuggestionElement | TSuggestionText> | undefined;
|
|
50
|
+
nodeId: (node: TElement | TSuggestionText) => string | undefined;
|
|
51
|
+
nodes: (options?: EditorNodesOptions & {
|
|
52
|
+
transient?: boolean;
|
|
53
|
+
}) => NodeEntry<TElement | TSuggestionText>[];
|
|
54
|
+
suggestionData: (node: TElement | TSuggestionText) => TInlineSuggestionData | TSuggestionElement["suggestion"] | undefined;
|
|
55
|
+
withoutSuggestions: (fn: () => void) => void;
|
|
56
|
+
}>, {}, {}>>;
|
|
25
57
|
//#endregion
|
|
26
58
|
//#region src/lib/diffToSuggestions.d.ts
|
|
27
59
|
declare function diffToSuggestions<E extends SlateEditor>(editor: E, doc0: Descendant[], doc1: Descendant[], {
|
|
@@ -63,7 +95,7 @@ interface TSuggestion extends UnknownObject {
|
|
|
63
95
|
declare const withSuggestion: OverrideEditor<BaseSuggestionConfig>;
|
|
64
96
|
//#endregion
|
|
65
97
|
//#region src/lib/queries/findSuggestionNode.d.ts
|
|
66
|
-
declare const findInlineSuggestionNode: <E extends SlateEditor>(editor: E, options?: EditorNodesOptions<ValueOf<E>>) =>
|
|
98
|
+
declare const findInlineSuggestionNode: <E extends SlateEditor>(editor: E, options?: EditorNodesOptions<ValueOf<E>>) => platejs36.NodeEntry<TSuggestionText> | undefined;
|
|
67
99
|
//#endregion
|
|
68
100
|
//#region src/lib/queries/findSuggestionProps.d.ts
|
|
69
101
|
declare const findSuggestionProps: (editor: SlateEditor, {
|
|
@@ -115,19 +147,19 @@ declare const getSuggestionProps: (editor: SlateEditor, node: Descendant, {
|
|
|
115
147
|
suggestionUpdate?: any;
|
|
116
148
|
transient?: boolean;
|
|
117
149
|
}) => {
|
|
118
|
-
[x: string]: {
|
|
150
|
+
[x: string]: boolean | {
|
|
119
151
|
id: string;
|
|
120
152
|
createdAt: number;
|
|
121
153
|
type: string;
|
|
122
|
-
userId:
|
|
154
|
+
userId: string;
|
|
123
155
|
};
|
|
124
|
-
|
|
156
|
+
suggestion: boolean;
|
|
125
157
|
} | {
|
|
126
|
-
|
|
158
|
+
suggestion: {
|
|
127
159
|
id: string;
|
|
128
160
|
createdAt: number;
|
|
129
161
|
type: string;
|
|
130
|
-
userId:
|
|
162
|
+
userId: string;
|
|
131
163
|
};
|
|
132
164
|
};
|
|
133
165
|
//#endregion
|
|
@@ -193,7 +225,7 @@ declare const getActiveSuggestionDescriptions: (editor: SlateEditor) => TSuggest
|
|
|
193
225
|
//#endregion
|
|
194
226
|
//#region src/lib/utils/getSuggestionId.d.ts
|
|
195
227
|
declare const getSuggestionKeyId: (node: TElement | TText) => string | undefined;
|
|
196
|
-
declare const getInlineSuggestionData: (node: TElement | TText) =>
|
|
228
|
+
declare const getInlineSuggestionData: (node: TElement | TText) => TInlineSuggestionData | undefined;
|
|
197
229
|
declare const keyId2SuggestionId: (keyId: string) => string;
|
|
198
230
|
//#endregion
|
|
199
231
|
//#region src/lib/utils/getSuggestionKeys.d.ts
|
|
@@ -201,18 +233,17 @@ declare const getSuggestionKey: (id?: string) => string;
|
|
|
201
233
|
declare const isSuggestionKey: (key: string) => boolean;
|
|
202
234
|
declare const getSuggestionKeys: (node: TNode) => string[];
|
|
203
235
|
declare const getSuggestionUserIdByKey: (key?: string | null) => string | null;
|
|
204
|
-
declare const getSuggestionUserIds: (node: TNode) =>
|
|
205
|
-
declare const getSuggestionUserId: (node: TNode) =>
|
|
236
|
+
declare const getSuggestionUserIds: (node: TNode) => any[];
|
|
237
|
+
declare const getSuggestionUserId: (node: TNode) => any;
|
|
206
238
|
declare const isCurrentUserSuggestion: (editor: SlateEditor, node: TText) => boolean;
|
|
207
239
|
//#endregion
|
|
208
240
|
//#region src/lib/utils/getSuggestionNodeEntries.d.ts
|
|
209
241
|
declare const getSuggestionNodeEntries: <E extends SlateEditor>(editor: E, suggestionId: string, {
|
|
210
242
|
at,
|
|
211
243
|
...options
|
|
212
|
-
}?: EditorNodesOptions<ValueOf<E>>) =>
|
|
244
|
+
}?: EditorNodesOptions<ValueOf<E>>) => Generator<platejs36.NodeEntry<TSuggestionText>, void, undefined>;
|
|
213
245
|
//#endregion
|
|
214
246
|
//#region src/lib/utils/getTransientSuggestionKey.d.ts
|
|
215
247
|
declare const getTransientSuggestionKey: () => string;
|
|
216
248
|
//#endregion
|
|
217
|
-
export { BaseSuggestionConfig, BaseSuggestionPlugin, SkipSuggestionDeletes, SuggestionEditorProps, SuggestionUser, TResolvedSuggestion, TSuggestion, TSuggestionCommonDescription, TSuggestionDeletionDescription, TSuggestionDescription, TSuggestionInsertionDescription, TSuggestionReplacementDescription, acceptSuggestion, addMarkSuggestion, deleteFragmentSuggestion, deleteSuggestion, diffToSuggestions, findInlineSuggestionNode, findSuggestionProps, getActiveSuggestionDescriptions, getInlineSuggestionData, getSuggestionKey, getSuggestionKeyId, getSuggestionKeys, getSuggestionNodeEntries, getSuggestionProps, getSuggestionUserId, getSuggestionUserIdByKey, getSuggestionUserIds, getTransientSuggestionKey, insertFragmentSuggestion, insertTextSuggestion, isCurrentUserSuggestion, isSuggestionKey, keyId2SuggestionId, rejectSuggestion, removeMarkSuggestion, removeNodesSuggestion, setSuggestionNodes, withSuggestion };
|
|
218
|
-
//# sourceMappingURL=index.d.ts.map
|
|
249
|
+
export { BaseSuggestionConfig, BaseSuggestionPlugin, SkipSuggestionDeletes, SuggestionEditorProps, SuggestionUser, TResolvedSuggestion, TSuggestion, TSuggestionCommonDescription, TSuggestionDeletionDescription, TSuggestionDescription, TSuggestionInsertionDescription, TSuggestionReplacementDescription, acceptSuggestion, addMarkSuggestion, deleteFragmentSuggestion, deleteSuggestion, diffToSuggestions, findInlineSuggestionNode, findSuggestionProps, getActiveSuggestionDescriptions, getInlineSuggestionData, getSuggestionKey, getSuggestionKeyId, getSuggestionKeys, getSuggestionNodeEntries, getSuggestionProps, getSuggestionUserId, getSuggestionUserIdByKey, getSuggestionUserIds, getTransientSuggestionKey, insertFragmentSuggestion, insertTextSuggestion, isCurrentUserSuggestion, isSuggestionKey, keyId2SuggestionId, rejectSuggestion, removeMarkSuggestion, removeNodesSuggestion, setSuggestionNodes, withSuggestion };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as SkipSuggestionDeletes, C as getSuggestionUserIdByKey, D as getInlineSuggestionData, E as isSuggestionKey, O as getSuggestionKeyId, S as getSuggestionUserId, T as isCurrentUserSuggestion, _ as getTransientSuggestionKey, a as BaseSuggestionPlugin, b as getSuggestionKey, c as removeMarkSuggestion, d as deleteFragmentSuggestion, f as deleteSuggestion, g as findInlineSuggestionNode, h as findSuggestionProps, i as acceptSuggestion, k as keyId2SuggestionId, l as insertTextSuggestion, m as addMarkSuggestion, n as rejectSuggestion, o as withSuggestion, p as setSuggestionNodes, r as getSuggestionProps, s as removeNodesSuggestion, t as diffToSuggestions, u as insertFragmentSuggestion, v as getActiveSuggestionDescriptions, w as getSuggestionUserIds, x as getSuggestionKeys, y as getSuggestionNodeEntries } from "./src-
|
|
1
|
+
import { A as SkipSuggestionDeletes, C as getSuggestionUserIdByKey, D as getInlineSuggestionData, E as isSuggestionKey, O as getSuggestionKeyId, S as getSuggestionUserId, T as isCurrentUserSuggestion, _ as getTransientSuggestionKey, a as BaseSuggestionPlugin, b as getSuggestionKey, c as removeMarkSuggestion, d as deleteFragmentSuggestion, f as deleteSuggestion, g as findInlineSuggestionNode, h as findSuggestionProps, i as acceptSuggestion, k as keyId2SuggestionId, l as insertTextSuggestion, m as addMarkSuggestion, n as rejectSuggestion, o as withSuggestion, p as setSuggestionNodes, r as getSuggestionProps, s as removeNodesSuggestion, t as diffToSuggestions, u as insertFragmentSuggestion, v as getActiveSuggestionDescriptions, w as getSuggestionUserIds, x as getSuggestionKeys, y as getSuggestionNodeEntries } from "./src-CruTaHKh.js";
|
|
2
2
|
|
|
3
3
|
export { BaseSuggestionPlugin, SkipSuggestionDeletes, acceptSuggestion, addMarkSuggestion, deleteFragmentSuggestion, deleteSuggestion, diffToSuggestions, findInlineSuggestionNode, findSuggestionProps, getActiveSuggestionDescriptions, getInlineSuggestionData, getSuggestionKey, getSuggestionKeyId, getSuggestionKeys, getSuggestionNodeEntries, getSuggestionProps, getSuggestionUserId, getSuggestionUserIdByKey, getSuggestionUserIds, getTransientSuggestionKey, insertFragmentSuggestion, insertTextSuggestion, isCurrentUserSuggestion, isSuggestionKey, keyId2SuggestionId, rejectSuggestion, removeMarkSuggestion, removeNodesSuggestion, setSuggestionNodes, withSuggestion };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
|
+
import * as platejs0 from "platejs";
|
|
2
|
+
import * as platejs_react0 from "platejs/react";
|
|
3
|
+
|
|
1
4
|
//#region src/react/SuggestionPlugin.d.ts
|
|
2
5
|
/** @experimental Enables support for suggestions in the editor. */
|
|
3
|
-
declare const SuggestionPlugin:
|
|
6
|
+
declare const SuggestionPlugin: platejs_react0.PlatePlugin<platejs0.PluginConfig<"suggestion", {
|
|
7
|
+
currentUserId: string | null;
|
|
8
|
+
isSuggesting: boolean;
|
|
9
|
+
}, {
|
|
10
|
+
suggestion: {
|
|
11
|
+
dataList: (node: platejs0.TSuggestionText) => platejs0.TInlineSuggestionData[];
|
|
12
|
+
isBlockSuggestion: (node: platejs0.TNode) => node is platejs0.TSuggestionElement;
|
|
13
|
+
node: (options?: platejs0.EditorNodesOptions & {
|
|
14
|
+
id?: string;
|
|
15
|
+
isText?: boolean;
|
|
16
|
+
}) => platejs0.NodeEntry<platejs0.TSuggestionElement | platejs0.TSuggestionText> | undefined;
|
|
17
|
+
nodeId: (node: platejs0.TElement | platejs0.TSuggestionText) => string | undefined;
|
|
18
|
+
nodes: (options?: platejs0.EditorNodesOptions & {
|
|
19
|
+
transient?: boolean;
|
|
20
|
+
}) => platejs0.NodeEntry<platejs0.TElement | platejs0.TSuggestionText>[];
|
|
21
|
+
suggestionData: (node: platejs0.TElement | platejs0.TSuggestionText) => platejs0.TInlineSuggestionData | platejs0.TSuggestionElement["suggestion"] | undefined;
|
|
22
|
+
withoutSuggestions: (fn: () => void) => void;
|
|
23
|
+
};
|
|
24
|
+
} & Record<"suggestion", {
|
|
25
|
+
dataList: (node: platejs0.TSuggestionText) => platejs0.TInlineSuggestionData[];
|
|
26
|
+
isBlockSuggestion: (node: platejs0.TNode) => node is platejs0.TSuggestionElement;
|
|
27
|
+
node: (options?: platejs0.EditorNodesOptions & {
|
|
28
|
+
id?: string;
|
|
29
|
+
isText?: boolean;
|
|
30
|
+
}) => platejs0.NodeEntry<platejs0.TSuggestionElement | platejs0.TSuggestionText> | undefined;
|
|
31
|
+
nodeId: (node: platejs0.TElement | platejs0.TSuggestionText) => string | undefined;
|
|
32
|
+
nodes: (options?: platejs0.EditorNodesOptions & {
|
|
33
|
+
transient?: boolean;
|
|
34
|
+
}) => platejs0.NodeEntry<platejs0.TElement | platejs0.TSuggestionText>[];
|
|
35
|
+
suggestionData: (node: platejs0.TElement | platejs0.TSuggestionText) => platejs0.TInlineSuggestionData | platejs0.TSuggestionElement["suggestion"] | undefined;
|
|
36
|
+
withoutSuggestions: (fn: () => void) => void;
|
|
37
|
+
}>, {}, {}>>;
|
|
4
38
|
//#endregion
|
|
5
|
-
export { SuggestionPlugin };
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
39
|
+
export { SuggestionPlugin };
|
package/dist/react/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as BaseSuggestionPlugin } from "../src-
|
|
1
|
+
import { a as BaseSuggestionPlugin } from "../src-CruTaHKh.js";
|
|
2
2
|
import { toPlatePlugin } from "platejs/react";
|
|
3
3
|
|
|
4
4
|
//#region src/react/SuggestionPlugin.tsx
|
|
@@ -6,5 +6,4 @@ import { toPlatePlugin } from "platejs/react";
|
|
|
6
6
|
const SuggestionPlugin = toPlatePlugin(BaseSuggestionPlugin);
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
9
|
-
export { SuggestionPlugin };
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
9
|
+
export { SuggestionPlugin };
|
|
@@ -41,7 +41,7 @@ const getSuggestionKeys = (node) => {
|
|
|
41
41
|
return keys;
|
|
42
42
|
};
|
|
43
43
|
const getSuggestionUserIdByKey = (key) => isDefined(key) ? key.split(`${KEYS.suggestion}_`)[1] : null;
|
|
44
|
-
const getSuggestionUserIds = (node) => getSuggestionKeys(node).map((key) =>
|
|
44
|
+
const getSuggestionUserIds = (node) => getSuggestionKeys(node).map((key) => node[key]?.userId).filter(isDefined);
|
|
45
45
|
const getSuggestionUserId = (node) => getSuggestionUserIds(node)[0];
|
|
46
46
|
const isCurrentUserSuggestion = (editor, node) => {
|
|
47
47
|
const { currentUserId } = editor.getOptions(BaseSuggestionPlugin);
|
|
@@ -53,7 +53,7 @@ const isCurrentUserSuggestion = (editor, node) => {
|
|
|
53
53
|
const getSuggestionNodeEntries = (editor, suggestionId, { at = [], ...options } = {}) => editor.api.nodes({
|
|
54
54
|
at,
|
|
55
55
|
...options,
|
|
56
|
-
match: combineMatchOptions(editor, (n) => n
|
|
56
|
+
match: combineMatchOptions(editor, (n) => !!n[getSuggestionKey(suggestionId)], options)
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
@@ -67,30 +67,30 @@ const getActiveSuggestionDescriptions = (editor) => {
|
|
|
67
67
|
const aboveEntry = editor.getApi(BaseSuggestionPlugin).suggestion.node({ isText: true });
|
|
68
68
|
if (!aboveEntry) return [];
|
|
69
69
|
const aboveNode = aboveEntry[0];
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const nodes = Array.from(getSuggestionNodeEntries(editor,
|
|
74
|
-
const insertions = nodes.filter((node) =>
|
|
75
|
-
const deletions = nodes.filter((node) => node
|
|
70
|
+
if (!editor.getApi(BaseSuggestionPlugin).suggestion.nodeId(aboveNode)) return [];
|
|
71
|
+
return editor.getApi(BaseSuggestionPlugin).suggestion.dataList(aboveNode).map(({ id: activeSuggestionId, userId }) => {
|
|
72
|
+
const suggestionKey = getSuggestionKey(activeSuggestionId);
|
|
73
|
+
const nodes = Array.from(getSuggestionNodeEntries(editor, activeSuggestionId)).map(([node]) => node);
|
|
74
|
+
const insertions = nodes.filter((node) => node[suggestionKey]?.type === "insert");
|
|
75
|
+
const deletions = nodes.filter((node) => node[suggestionKey]?.type === "remove");
|
|
76
76
|
const insertedText = insertions.map((node) => node.text).join("");
|
|
77
77
|
const deletedText = deletions.map((node) => node.text).join("");
|
|
78
78
|
if (insertions.length > 0 && deletions.length > 0) return {
|
|
79
79
|
deletedText,
|
|
80
80
|
insertedText,
|
|
81
|
-
suggestionId,
|
|
81
|
+
suggestionId: activeSuggestionId,
|
|
82
82
|
type: "replacement",
|
|
83
83
|
userId
|
|
84
84
|
};
|
|
85
85
|
if (deletions.length > 0) return {
|
|
86
86
|
deletedText,
|
|
87
|
-
suggestionId,
|
|
87
|
+
suggestionId: activeSuggestionId,
|
|
88
88
|
type: "deletion",
|
|
89
89
|
userId
|
|
90
90
|
};
|
|
91
91
|
return {
|
|
92
92
|
insertedText,
|
|
93
|
-
suggestionId,
|
|
93
|
+
suggestionId: activeSuggestionId,
|
|
94
94
|
type: "insertion",
|
|
95
95
|
userId
|
|
96
96
|
};
|
|
@@ -129,25 +129,23 @@ const findSuggestionProps = (editor, { at, type }) => {
|
|
|
129
129
|
return defaultProps;
|
|
130
130
|
}
|
|
131
131
|
const nextPoint = editor.api.after(end);
|
|
132
|
-
if (nextPoint) {
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
if (nextPoint) entry = api.suggestion.node({
|
|
133
|
+
at: nextPoint,
|
|
134
|
+
isText: true
|
|
135
|
+
});
|
|
136
|
+
if (!entry) {
|
|
137
|
+
const prevPoint = editor.api.before(start);
|
|
138
|
+
if (prevPoint) entry = api.suggestion.node({
|
|
139
|
+
at: prevPoint,
|
|
135
140
|
isText: true
|
|
136
141
|
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const _at = prevPoint ?? at;
|
|
145
|
-
const lineBreakData = editor.api.above({ at: _at })?.[0].suggestion;
|
|
146
|
-
if (lineBreakData?.isLineBreak) return {
|
|
147
|
-
id: lineBreakData?.id ?? nanoid(),
|
|
148
|
-
createdAt: lineBreakData?.createdAt ?? Date.now()
|
|
149
|
-
};
|
|
150
|
-
}
|
|
142
|
+
const blockEntry = editor.api.block({ at: start });
|
|
143
|
+
if (!entry && blockEntry && editor.api.isStart(start, blockEntry[1])) {
|
|
144
|
+
const lineBreakData = editor.api.above({ at: prevPoint ?? start })?.[0].suggestion;
|
|
145
|
+
if (lineBreakData?.isLineBreak) return {
|
|
146
|
+
id: lineBreakData.id ?? nanoid(),
|
|
147
|
+
createdAt: lineBreakData.createdAt ?? Date.now()
|
|
148
|
+
};
|
|
151
149
|
}
|
|
152
150
|
}
|
|
153
151
|
}
|
|
@@ -910,5 +908,4 @@ function unifyAdjacentSuggestionIds(node, index, nodes, editor) {
|
|
|
910
908
|
}
|
|
911
909
|
|
|
912
910
|
//#endregion
|
|
913
|
-
export { SkipSuggestionDeletes as A, getSuggestionUserIdByKey as C, getInlineSuggestionData as D, isSuggestionKey as E, getSuggestionKeyId as O, getSuggestionUserId as S, isCurrentUserSuggestion as T, getTransientSuggestionKey as _, BaseSuggestionPlugin as a, getSuggestionKey as b, removeMarkSuggestion as c, deleteFragmentSuggestion as d, deleteSuggestion as f, findInlineSuggestionNode as g, findSuggestionProps as h, acceptSuggestion as i, keyId2SuggestionId as k, insertTextSuggestion as l, addMarkSuggestion as m, rejectSuggestion as n, withSuggestion as o, setSuggestionNodes as p, getSuggestionProps as r, removeNodesSuggestion as s, diffToSuggestions as t, insertFragmentSuggestion as u, getActiveSuggestionDescriptions as v, getSuggestionUserIds as w, getSuggestionKeys as x, getSuggestionNodeEntries as y };
|
|
914
|
-
//# sourceMappingURL=src-COX5sId2.js.map
|
|
911
|
+
export { SkipSuggestionDeletes as A, getSuggestionUserIdByKey as C, getInlineSuggestionData as D, isSuggestionKey as E, getSuggestionKeyId as O, getSuggestionUserId as S, isCurrentUserSuggestion as T, getTransientSuggestionKey as _, BaseSuggestionPlugin as a, getSuggestionKey as b, removeMarkSuggestion as c, deleteFragmentSuggestion as d, deleteSuggestion as f, findInlineSuggestionNode as g, findSuggestionProps as h, acceptSuggestion as i, keyId2SuggestionId as k, insertTextSuggestion as l, addMarkSuggestion as m, rejectSuggestion as n, withSuggestion as o, setSuggestionNodes as p, getSuggestionProps as r, removeNodesSuggestion as s, diffToSuggestions as t, insertFragmentSuggestion as u, getActiveSuggestionDescriptions as v, getSuggestionUserIds as w, getSuggestionKeys as x, getSuggestionNodeEntries as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lofcz/platejs-suggestion",
|
|
3
|
-
"version": "52.
|
|
3
|
+
"version": "52.3.6",
|
|
4
4
|
"description": "Plate plugin for suggestions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plate",
|
|
@@ -31,10 +31,11 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"lodash": "^4.17.21",
|
|
33
33
|
"react-compiler-runtime": "^1.0.0",
|
|
34
|
-
"@platejs/diff": "npm:@lofcz/platejs-diff@52.
|
|
34
|
+
"@platejs/diff": "npm:@lofcz/platejs-diff@52.3.6"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@plate/scripts": "1.0.0"
|
|
37
|
+
"@plate/scripts": "1.0.0",
|
|
38
|
+
"platejs": "npm:@lofcz/platejs@52.3.6"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"platejs": ">=52.0.11",
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/lib/BaseSuggestionPlugin.ts","../src/lib/diffToSuggestions.ts","../src/lib/types.ts","../src/lib/withSuggestion.ts","../src/lib/queries/findSuggestionNode.ts","../src/lib/queries/findSuggestionProps.ts","../src/lib/transforms/acceptSuggestion.ts","../src/lib/transforms/addMarkSuggestion.ts","../src/lib/transforms/deleteFragmentSuggestion.ts","../src/lib/transforms/deleteSuggestion.ts","../src/lib/transforms/getSuggestionProps.ts","../src/lib/transforms/insertFragmentSuggestion.ts","../src/lib/transforms/insertTextSuggestion.ts","../src/lib/transforms/rejectSuggestion.ts","../src/lib/transforms/removeMarkSuggestion.ts","../src/lib/transforms/removeNodesSuggestion.ts","../src/lib/transforms/setSuggestionNodes.ts","../src/lib/utils/SkipSuggestionDeletes.ts","../src/lib/utils/getActiveSuggestionDescriptions.ts","../src/lib/utils/getSuggestionId.ts","../src/lib/utils/getSuggestionKeys.ts","../src/lib/utils/getSuggestionNodeEntries.ts","../src/lib/utils/getTransientSuggestionKey.ts"],"sourcesContent":[],"mappings":";;;;KAoBY,oBAAA,GAAuB;;;AAAnC,CAAA,EAAA;EAWuB,UAAA,EAAA;IAAoB,QAAA,EAAA,CAAA,IAAA,EAApB,eAAoB,EAAA,GAAA,qBAAA,EAAA;IACX,iBAAA,EAAA,CAAA,IAAA,EAAA,K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AAsC,qBACzC;;;IAEiB,mBAAmB,QAAQ;;;cCRzC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/react/SuggestionPlugin.tsx"],"sourcesContent":[],"mappings":";;AAKa,cAAA,gBAAsD,EAAA,GAAA"}
|
package/dist/react/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["toPlatePlugin","BaseSuggestionPlugin","SuggestionPlugin"],"sources":["../../src/react/SuggestionPlugin.tsx"],"sourcesContent":["import { toPlatePlugin } from 'platejs/react';\n\nimport { BaseSuggestionPlugin } from '../lib/BaseSuggestionPlugin';\n\n/** @experimental Enables support for suggestions in the editor. */\nexport const SuggestionPlugin = toPlatePlugin(BaseSuggestionPlugin);\n"],"mappings":";;;;;AAKA,MAAaE,mBAAmBF,cAAcC,qBAAqB"}
|
package/dist/src-COX5sId2.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"src-COX5sId2.js","names":["Node","SlateEditor","TSuggestionText","ElementApi","KEYS","NodeApi","TextApi","BaseSuggestionPlugin","SkipSuggestionDeletes","editor","node","isText","isElement","api","isInline","string","suggestion","text","suggestionData","getApi","type","children","map","child","join","TElement","TInlineSuggestionData","TText","KEYS","getSuggestionKeyId","node","ids","Object","keys","filter","key","startsWith","suggestion","at","getInlineSuggestionData","keyId","keyId2SuggestionId","replace","SlateEditor","TNode","TText","isDefined","KEYS","BaseSuggestionPlugin","getInlineSuggestionData","getSuggestionKey","id","suggestion","isSuggestionKey","key","startsWith","getSuggestionKeys","node","keys","Object","forEach","push","getSuggestionUserIdByKey","split","getSuggestionUserIds","map","getSuggestionUserId","isCurrentUserSuggestion","editor","currentUserId","getOptions","userId","EditorNodesOptions","SlateEditor","TSuggestionText","ValueOf","combineMatchOptions","getSuggestionNodeEntries","editor","E","suggestionId","at","options","api","nodes","match","n","SlateEditor","BaseSuggestionPlugin","getSuggestionKey","getSuggestionUserIds","getSuggestionNodeEntries","TSuggestionCommonDescription","suggestionId","userId","TSuggestionDeletionDescription","deletedText","type","TSuggestionDescription","TSuggestionInsertionDescription","TSuggestionReplacementDescription","insertedText","getActiveSuggestionDescriptions","editor","aboveEntry","getApi","suggestion","node","isText","aboveNode","nodeId","userIds","map","nodes","Array","from","match","n","insertions","filter","suggestionDeletion","deletions","text","join","length","KEYS","getTransientSuggestionKey","suggestion","EditorNodesOptions","SlateEditor","TSuggestionText","ValueOf","combineMatchOptions","KEYS","TextApi","findInlineSuggestionNode","editor","E","options","api","node","match","n","isText","suggestion","NodeEntry","Point","SlateEditor","TLocation","TSuggestionElement","TSuggestionText","nanoid","BaseSuggestionPlugin","getInlineSuggestionData","isCurrentUserSuggestion","findSuggestionProps","editor","at","type","id","createdAt","defaultProps","Date","now","api","getApi","entry","suggestion","node","isText","start","end","edges","nextPoint","after","prevPoint","before","isStart","_at","lineBreak","above","lineBreakData","isLineBreak","nodeId","SlateEditor","TNode","KEYS","nanoid","TextApi","getInlineSuggestionData","getSuggestionKey","BaseSuggestionPlugin","getAddMarkProps","defaultProps","id","createdAt","Date","now","addMarkSuggestion","editor","key","value","getApi","suggestion","withoutSuggestions","match","n","isText","data","type","tf","setNodes","newProperties","userId","getOptions","currentUserId","split","SetNodesOptions","SlateEditor","TInlineSuggestionData","TSuggestionText","ElementApi","getAt","KEYS","nanoid","BaseSuggestionPlugin","getSuggestionKey","setSuggestionNodes","editor","options","createdAt","suggestionDeletion","suggestionId","at","selection","_nodeEntries","api","nodes","match","n","isElement","isInline","nodeEntries","tf","withoutNormalizing","data","id","Date","now","type","userId","getOptions","currentUserId","props","suggestion","setNodes","marks","forEach","path","Point","SlateEditor","TElement","TRange","TSuggestionElement","ElementApi","KEYS","PathApi","PointApi","TextApi","BaseSuggestionPlugin","findSuggestionProps","getInlineSuggestionData","isCurrentUserSuggestion","setSuggestionNodes","deleteSuggestion","editor","at","reverse","resId","tf","withoutNormalizing","anchor","from","focus","to","id","createdAt","type","toRef","api","pointRef","pointCurrent","selection","pointTarget","current","isAt","blocks","str","string","length","getPoint","before","after","pointNext","unit","range","unhangRange","character","entryBlock","node","block","match","n","suggestion","isText","isStart","isEmpty","removeNodes","previousAboveNode","above","isElement","isBlockSuggestion","getApi","withoutSuggestions","unsetNodes","mergeNodes","next","move","setNodes","userId","getOptions","currentUserId","equals","entryText","delete","suggestionDeletion","suggestionId","SlateEditor","deleteSuggestion","deleteFragmentSuggestion","editor","reverse","resId","tf","withoutNormalizing","selection","start","end","api","edges","collapse","edge","anchor","focus","Descendant","SlateEditor","KEYS","TextApi","BaseSuggestionPlugin","findSuggestionProps","getSuggestionKey","getSuggestionKeys","deleteFragmentSuggestion","insertFragmentSuggestion","editor","fragment","insertFragment","tf","withoutNormalizing","id","createdAt","at","selection","type","forEach","n","isText","suggestion","otherUserKeys","key","userId","getOptions","currentUserId","getApi","withoutSuggestions","SlateEditor","TSuggestionText","BaseSuggestionPlugin","findSuggestionProps","getSuggestionKey","deleteFragmentSuggestion","insertTextSuggestion","editor","text","tf","withoutNormalizing","resId","id","createdAt","at","selection","type","api","isExpanded","getApi","suggestion","withoutSuggestions","insertNodes","userId","getOptions","currentUserId","select","SlateEditor","TNode","KEYS","nanoid","TextApi","getInlineSuggestionData","getSuggestionKey","BaseSuggestionPlugin","getRemoveMarkProps","defaultProps","id","createdAt","Date","now","removeMarkSuggestion","editor","key","getApi","suggestion","withoutSuggestions","match","n","isText","data","type","tf","unsetNodes","setNodes","properties","undefined","userId","getOptions","currentUserId","NodeEntry","SlateEditor","TElement","Text","KEYS","findSuggestionProps","removeNodesSuggestion","editor","nodes","length","id","createdAt","at","selection","type","forEach","blockPath","tf","setNodes","suggestion","OverrideEditor","TSuggestionElement","ElementApi","KEYS","nanoid","TextApi","BaseSuggestionConfig","BaseSuggestionPlugin","findSuggestionProps","addMarkSuggestion","deleteFragmentSuggestion","deleteSuggestion","insertFragmentSuggestion","insertTextSuggestion","removeMarkSuggestion","removeNodesSuggestion","getInlineSuggestionData","getSuggestionKeyId","withSuggestion","api","editor","getOptions","tf","addMark","apply","deleteBackward","deleteForward","deleteFragment","insertBreak","insertFragment","insertNodes","insertText","normalizeNode","removeMark","removeNodes","transforms","key","value","isSuggesting","isExpanded","operation","unit","selection","pointTarget","before","node","above","suggestion","isLineBreak","anchor","focus","reverse","isCrossBlock","isAt","at","blocks","unsetNodes","after","direction","path","length","type","getType","p","id","createdAt","withoutMerging","setNodes","userId","currentUserId","fragment","nodes","options","nodesArray","Array","isArray","some","n","withoutSuggestions","suggestionNodes","map","Date","now","text","entry","inlineSuggestion","isElement","isInline","isText","EditorNodesOptions","NodeEntry","PluginConfig","TElement","TInlineSuggestionData","TNode","TSuggestionElement","TSuggestionText","createTSlatePlugin","ElementApi","getAt","KEYS","TextApi","getSuggestionKey","getSuggestionKeyId","getTransientSuggestionKey","withSuggestion","BaseSuggestionConfig","currentUserId","isSuggesting","suggestion","dataList","node","isBlockSuggestion","options","id","isText","nodeId","nodes","transient","suggestionData","withoutSuggestions","fn","BaseSuggestionPlugin","key","isLeaf","rules","selection","affinity","overrideEditor","extendApi","api","editor","getOption","setOption","type","Object","keys","filter","startsWith","map","isElement","isInline","rest","result","match","n","keyId","replace","at","mode","prev","SlateEditor","TSuggestionElement","TSuggestionText","ElementApi","KEYS","PathApi","TextApi","TResolvedSuggestion","BaseSuggestionPlugin","getInlineSuggestionData","getTransientSuggestionKey","acceptSuggestion","editor","description","tf","withoutNormalizing","mergeNodes","api","nodes","at","match","n","isElement","getApi","suggestion","isBlockSuggestion","suggestionElement","type","isLineBreak","id","suggestionId","reverse","forEach","path","next","unsetNodes","keyId","mode","isText","isInline","suggestionDataList","dataList","includeUpdate","some","data","d","suggestionData","removeNodes","Descendant","SlateEditor","ElementApi","KEYS","nanoid","BaseSuggestionPlugin","getSuggestionKey","getTransientSuggestionKey","getSuggestionProps","editor","node","id","createdAt","Date","now","suggestionDeletion","suggestionUpdate","transient","type","isElement","suggestionData","userId","getOptions","currentUserId","suggestion","res","SlateEditor","TSuggestionElement","TSuggestionText","TText","ElementApi","KEYS","PathApi","TextApi","TResolvedSuggestion","BaseSuggestionPlugin","getInlineSuggestionData","getSuggestionKey","getTransientSuggestionKey","rejectSuggestion","editor","description","tf","withoutNormalizing","mergeNodes","api","nodes","at","match","n","isElement","getApi","suggestion","isBlockSuggestion","suggestionElement","type","isLineBreak","id","suggestionId","reverse","forEach","path","next","unsetNodes","keyId","mode","isText","node","suggestionData","removeNodes","updateNodes","datalist","dataList","length","some","data","targetData","find","unsetProps","Object","keys","newProperties","filter","key","addProps","properties","setNodes","fromEntries","map","ComputeDiffOptions","computeDiff","Descendant","SlateEditor","ValueOf","ElementApi","KEYS","TextApi","BaseSuggestionPlugin","getSuggestionProps","getSuggestionKey","diffToSuggestions","editor","E","doc0","doc1","getDeleteProps","node","suggestionDeletion","getInsertProps","getUpdateProps","_properties","newProperties","suggestionUpdate","isInline","api","options","Partial","values","traverseNodes","nodes","map","index","isElement","children","isText","suggestion","unifyAdjacentSuggestionIds","getApi","currentNodeData","suggestionData","type","previousNode","previousData","updatedNode","id","createdAt","key"],"sources":["../src/lib/utils/SkipSuggestionDeletes.ts","../src/lib/utils/getSuggestionId.ts","../src/lib/utils/getSuggestionKeys.ts","../src/lib/utils/getSuggestionNodeEntries.ts","../src/lib/utils/getActiveSuggestionDescriptions.ts","../src/lib/utils/getTransientSuggestionKey.ts","../src/lib/queries/findSuggestionNode.ts","../src/lib/queries/findSuggestionProps.ts","../src/lib/transforms/addMarkSuggestion.ts","../src/lib/transforms/setSuggestionNodes.ts","../src/lib/transforms/deleteSuggestion.ts","../src/lib/transforms/deleteFragmentSuggestion.ts","../src/lib/transforms/insertFragmentSuggestion.ts","../src/lib/transforms/insertTextSuggestion.ts","../src/lib/transforms/removeMarkSuggestion.ts","../src/lib/transforms/removeNodesSuggestion.ts","../src/lib/withSuggestion.ts","../src/lib/BaseSuggestionPlugin.ts","../src/lib/transforms/acceptSuggestion.ts","../src/lib/transforms/getSuggestionProps.ts","../src/lib/transforms/rejectSuggestion.ts","../src/lib/diffToSuggestions.ts"],"sourcesContent":["import {\n type Node,\n type SlateEditor,\n type TSuggestionText,\n ElementApi,\n KEYS,\n NodeApi,\n TextApi,\n} from 'platejs';\n\nimport { BaseSuggestionPlugin } from '../BaseSuggestionPlugin';\n\n/**\n * Recursively extracts text content from a node tree, excluding any text marked\n * with \"remove\" suggestions. but include the text marked with \"insert\" and\n * \"update\" suggestions.\n */\nexport const SkipSuggestionDeletes = (\n editor: SlateEditor,\n node: Node\n): string => {\n if (\n TextApi.isText(node) ||\n (ElementApi.isElement(node) && editor.api.isInline(node))\n ) {\n if (ElementApi.isElement(node)) {\n return NodeApi.string(node);\n }\n if (!node[KEYS.suggestion]) return node.text;\n\n const suggestionData = editor\n .getApi(BaseSuggestionPlugin)\n .suggestion.suggestionData(node as TSuggestionText);\n\n if (suggestionData?.type === 'remove') return '';\n\n return node.text;\n }\n return node.children\n .map((child) => SkipSuggestionDeletes(editor, child))\n .join('');\n};\n","import type { TElement, TInlineSuggestionData, TText } from 'platejs';\n\nimport { KEYS } from 'platejs';\n\n// the last id is the active id\nexport const getSuggestionKeyId = (node: TElement | TText) => {\n const ids: string[] = Object.keys(node).filter((key) =>\n key.startsWith(`${KEYS.suggestion}_`)\n );\n\n return ids.at(-1);\n};\n\nexport const getInlineSuggestionData = (node: TElement | TText) => {\n const keyId = getSuggestionKeyId(node);\n\n if (!keyId) return;\n\n return node[keyId] as TInlineSuggestionData | undefined;\n};\n\nexport const keyId2SuggestionId = (keyId: string) =>\n keyId.replace(`${KEYS.suggestion}_`, '');\n","import {\n type SlateEditor,\n type TNode,\n type TText,\n isDefined,\n KEYS,\n} from 'platejs';\n\nimport { BaseSuggestionPlugin } from '../BaseSuggestionPlugin';\nimport { getInlineSuggestionData } from './getSuggestionId';\n\nexport const getSuggestionKey = (id = '0'): string =>\n `${KEYS.suggestion}_${id}`;\n\nexport const isSuggestionKey = (key: string) =>\n key.startsWith(`${KEYS.suggestion}_`);\n\nexport const getSuggestionKeys = (node: TNode) => {\n const keys: string[] = [];\n\n Object.keys(node).forEach((key) => {\n if (isSuggestionKey(key)) keys.push(key);\n });\n\n return keys;\n};\n\nexport const getSuggestionUserIdByKey = (key?: string | null) =>\n isDefined(key) ? key.split(`${KEYS.suggestion}_`)[1] : null;\n\nexport const getSuggestionUserIds = (node: TNode) =>\n getSuggestionKeys(node).map((key) => getSuggestionUserIdByKey(key) as string);\n\nexport const getSuggestionUserId = (node: TNode) =>\n getSuggestionUserIds(node)[0];\n\nexport const isCurrentUserSuggestion = (editor: SlateEditor, node: TText) => {\n const { currentUserId } = editor.getOptions(BaseSuggestionPlugin);\n\n return getInlineSuggestionData(node)?.userId === currentUserId;\n};\n","import {\n type EditorNodesOptions,\n type SlateEditor,\n type TSuggestionText,\n type ValueOf,\n combineMatchOptions,\n} from 'platejs';\n\nexport const getSuggestionNodeEntries = <E extends SlateEditor>(\n editor: E,\n suggestionId: string,\n { at = [], ...options }: EditorNodesOptions<ValueOf<E>> = {}\n) =>\n editor.api.nodes<TSuggestionText>({\n at,\n ...options,\n match: combineMatchOptions(\n editor,\n (n) => n.suggestionId === suggestionId,\n options\n ),\n });\n","import type { SlateEditor } from 'platejs';\n\nimport { BaseSuggestionPlugin } from '../BaseSuggestionPlugin';\nimport { getSuggestionKey, getSuggestionUserIds } from './getSuggestionKeys';\nimport { getSuggestionNodeEntries } from './getSuggestionNodeEntries';\n\nexport type TSuggestionCommonDescription = {\n suggestionId: string;\n userId: string;\n};\n\nexport type TSuggestionDeletionDescription = {\n deletedText: string;\n type: 'deletion';\n} & TSuggestionCommonDescription;\n\nexport type TSuggestionDescription =\n | TSuggestionDeletionDescription\n | TSuggestionInsertionDescription\n | TSuggestionReplacementDescription;\n\n// TODO: Move to ../types\nexport type TSuggestionInsertionDescription = {\n insertedText: string;\n type: 'insertion';\n} & TSuggestionCommonDescription;\n\nexport type TSuggestionReplacementDescription = {\n deletedText: string;\n insertedText: string;\n type: 'replacement';\n} & TSuggestionCommonDescription;\n\n/**\n * Get the suggestion descriptions of the selected node. A node can have\n * multiple suggestions (multiple users). Each description maps to a user\n * suggestion.\n */\nexport const getActiveSuggestionDescriptions = (\n editor: SlateEditor\n): TSuggestionDescription[] => {\n const aboveEntry = editor.getApi(BaseSuggestionPlugin).suggestion.node({\n isText: true,\n });\n\n if (!aboveEntry) return [];\n\n const aboveNode = aboveEntry[0];\n const suggestionId = editor\n .getApi(BaseSuggestionPlugin)\n .suggestion.nodeId(aboveNode);\n\n if (!suggestionId) return [];\n\n const userIds = getSuggestionUserIds(aboveNode);\n\n return userIds.map((userId) => {\n const nodes = Array.from(\n getSuggestionNodeEntries(editor, suggestionId, {\n match: (n: any) => n[getSuggestionKey(userId)],\n })\n ).map(([node]) => node);\n const insertions = nodes.filter((node) => !node.suggestionDeletion);\n const deletions = nodes.filter((node) => node.suggestionDeletion);\n const insertedText = insertions.map((node) => node.text).join('');\n const deletedText = deletions.map((node) => node.text).join('');\n\n if (insertions.length > 0 && deletions.length > 0) {\n return {\n deletedText,\n insertedText,\n suggestionId,\n type: 'replacement',\n userId,\n };\n }\n if (deletions.length > 0) {\n return {\n deletedText,\n suggestionId,\n type: 'deletion',\n userId,\n };\n }\n\n return {\n insertedText,\n suggestionId,\n type: 'insertion',\n userId,\n };\n });\n};\n","import { KEYS } from 'platejs';\n\n// do not start with suggestion_ to avoid conflict with other suggestion keys\nexport const getTransientSuggestionKey = () => `${KEYS.suggestion}Transient`;\n","import {\n type EditorNodesOptions,\n type SlateEditor,\n type TSuggestionText,\n type ValueOf,\n combineMatchOptions,\n KEYS,\n TextApi,\n} from 'platejs';\n\nexport const findInlineSuggestionNode = <E extends SlateEditor>(\n editor: E,\n options: EditorNodesOptions<ValueOf<E>> = {}\n) =>\n editor.api.node<TSuggestionText>({\n ...options,\n match: combineMatchOptions(\n editor,\n (n) => TextApi.isText(n) && (n as any)[KEYS.suggestion],\n options\n ),\n });\n","import {\n type NodeEntry,\n type Point,\n type SlateEditor,\n type TLocation,\n type TSuggestionElement,\n type TSuggestionText,\n nanoid,\n} from 'platejs';\n\nimport { BaseSuggestionPlugin } from '../BaseSuggestionPlugin';\nimport { getInlineSuggestionData, isCurrentUserSuggestion } from '../utils';\n\nexport const findSuggestionProps = (\n editor: SlateEditor,\n { at, type }: { at: TLocation; type: 'insert' | 'remove' | 'update' }\n): { id: string; createdAt: number } => {\n const defaultProps = {\n id: nanoid(),\n createdAt: Date.now(),\n };\n\n const api = editor.getApi(BaseSuggestionPlugin);\n\n let entry = api.suggestion.node({\n at,\n isText: true,\n }) as NodeEntry<TSuggestionText> | undefined;\n\n if (!entry) {\n let start: Point;\n let end: Point;\n\n try {\n [start, end] = editor.api.edges(at)!;\n } catch {\n return defaultProps;\n }\n\n const nextPoint = editor.api.after(end);\n\n if (nextPoint) {\n entry = api.suggestion.node({\n at: nextPoint,\n isText: true,\n }) as NodeEntry<TSuggestionText> | undefined;\n\n if (!entry) {\n const prevPoint = editor.api.before(start);\n\n if (prevPoint) {\n entry = api.suggestion.node({\n at: prevPoint,\n isText: true,\n }) as NodeEntry<TSuggestionText> | undefined;\n }\n // <p>111111<insert_break></p>\n // <p><cursor /></p>\n // in this case we need to find the previous parent node\n // TODO: test\n if (!entry && editor.api.isStart(start, at)) {\n const _at = prevPoint ?? at;\n\n const lineBreak = editor.api.above<TSuggestionElement>({ at: _at });\n\n const lineBreakData = lineBreak?.[0].suggestion;\n\n if (lineBreakData?.isLineBreak) {\n return {\n id: lineBreakData?.id ?? nanoid(),\n createdAt: lineBreakData?.createdAt ?? Date.now(),\n };\n }\n }\n }\n }\n }\n // same type and same user merge suggestions\n if (\n entry &&\n getInlineSuggestionData(entry[0])?.type === type &&\n isCurrentUserSuggestion(editor, entry[0])\n ) {\n return {\n id: api.suggestion.nodeId(entry[0]) ?? nanoid(),\n createdAt: getInlineSuggestionData(entry[0])?.createdAt ?? Date.now(),\n };\n }\n\n return defaultProps;\n};\n","import { type SlateEditor, type TNode, KEYS, nanoid, TextApi } from 'platejs';\n\nimport { getInlineSuggestionData, getSuggestionKey } from '../..';\nimport { BaseSuggestionPlugin } from '../BaseSuggestionPlugin';\n\nconst getAddMarkProps = () => {\n const defaultProps = {\n id: nanoid(),\n createdAt: Date.now(),\n };\n\n return defaultProps;\n};\n\nexport const addMarkSuggestion = (\n editor: SlateEditor,\n key: string,\n value: any\n) => {\n editor.getApi(BaseSuggestionPlugin).suggestion.withoutSuggestions(() => {\n const { id, createdAt } = getAddMarkProps();\n\n const match = (n: TNode) => {\n if (!TextApi.isText(n)) return false;\n // if the node is already marked as a suggestion, we don't want to remove it unless it's a removeMark suggestion\n if (n[KEYS.suggestion]) {\n const data = getInlineSuggestionData(n);\n\n if (data?.type === 'update') {\n return true;\n }\n\n return false;\n }\n\n return true;\n };\n\n editor.tf.setNodes(\n {\n [key]: value,\n [getSuggestionKey(id)]: {\n id,\n createdAt,\n newProperties: {\n [key]: value,\n },\n type: 'update',\n userId: editor.getOptions(BaseSuggestionPlugin).currentUserId,\n },\n [KEYS.suggestion]: true,\n },\n {\n match,\n split: true,\n }\n );\n });\n};\n","import {\n type SetNodesOptions,\n type SlateEditor,\n type TInlineSuggestionData,\n type TSuggestionText,\n ElementApi,\n getAt,\n KEYS,\n nanoid,\n} from 'platejs';\n\nimport { BaseSuggestionPlugin } from '../BaseSuggestionPlugin';\nimport { getSuggestionKey } from '../utils';\n\nexport const setSuggestionNodes = (\n editor: SlateEditor,\n options?: {\n createdAt?: number;\n suggestionDeletion?: boolean;\n suggestionId?: string;\n } & SetNodesOptions\n) => {\n const at = getAt(editor, options?.at) ?? editor.selection;\n\n if (!at) return;\n\n const { suggestionId = nanoid() } = options ?? {};\n\n // TODO: get all inline nodes to be set\n const _nodeEntries = editor.api.nodes({\n match: (n) => ElementApi.isElement(n) && editor.api.isInline(n),\n ...options,\n });\n const nodeEntries = [..._nodeEntries];\n\n editor.tf.withoutNormalizing(() => {\n const data: TInlineSuggestionData = {\n id: suggestionId,\n createdAt: options?.createdAt ?? Date.now(),\n type: 'remove',\n userId: editor.getOptions(BaseSuggestionPlugin).currentUserId!,\n };\n\n const props = {\n [getSuggestionKey(suggestionId)]: data,\n [KEYS.suggestion]: true,\n };\n\n editor.tf.setNodes(props, {\n at,\n marks: true,\n });\n\n nodeEntries.forEach(([, path]) => {\n editor.tf.setNodes<TSuggestionText>(props, {\n at: path,\n match: (n) => ElementApi.isElement(n) && editor.api.isInline(n),\n ...options,\n });\n });\n });\n};\n","import {\n type Point,\n type SlateEditor,\n type TElement,\n type TRange,\n type TSuggestionElement,\n ElementApi,\n KEYS,\n PathApi,\n PointApi,\n TextApi,\n} from 'platejs';\n\nimport { BaseSuggestionPlugin } from '../BaseSuggestionPlugin';\nimport { findSuggestionProps } from '../queries/';\nimport { getInlineSuggestionData, isCurrentUserSuggestion } from '../utils';\nimport { setSuggestionNodes } from './setSuggestionNodes';\n\n/**\n * Suggest deletion one character at a time until target point is reached.\n * Suggest additions are safely deleted.\n */\nexport const deleteSuggestion = (\n editor: SlateEditor,\n at: TRange,\n {\n reverse,\n }: {\n reverse?: boolean;\n } = {}\n) => {\n let resId: string | undefined;\n\n editor.tf.withoutNormalizing(() => {\n const { anchor: from, focus: to } = at;\n\n const { id, createdAt } = findSuggestionProps(editor, {\n at: from,\n type: 'remove',\n });\n\n resId = id;\n\n const toRef = editor.api.pointRef(to);\n\n let pointCurrent: Point | undefined;\n\n while (true) {\n pointCurrent = editor.selection?.anchor;\n\n if (!pointCurrent) break;\n\n const pointTarget = toRef.current;\n\n if (!pointTarget) break;\n // don't delete across blocks\n if (\n !editor.api.isAt({\n at: { anchor: pointCurrent, focus: pointTarget },\n blocks: true,\n })\n ) {\n // always 0 when across blocks\n const str = editor.api.string(\n reverse\n ? {\n anchor: pointTarget,\n focus: pointCurrent,\n }\n : {\n anchor: pointCurrent,\n focus: pointTarget,\n }\n );\n\n if (str.length === 0) break;\n }\n\n const getPoint = reverse ? editor.api.before : editor.api.after;\n\n const pointNext: Point | undefined = getPoint(pointCurrent, {\n unit: 'character',\n });\n\n if (!pointNext) break;\n\n let range: TRange = reverse\n ? {\n anchor: pointNext,\n focus: pointCurrent,\n }\n : {\n anchor: pointCurrent,\n focus: pointNext,\n };\n range = editor.api.unhangRange(range, { character: true });\n\n // if the current point is in block addition suggestion, delete block\n const entryBlock = editor.api.node<TElement>({\n at: pointCurrent,\n block: true,\n match: (n) =>\n n[KEYS.suggestion] &&\n TextApi.isText(n) &&\n getInlineSuggestionData(n)?.type === 'insert' &&\n isCurrentUserSuggestion(editor, n),\n });\n\n if (\n entryBlock &&\n editor.api.isStart(pointCurrent, entryBlock[1]) &&\n editor.api.isEmpty(entryBlock[0] as any)\n ) {\n editor.tf.removeNodes({\n at: entryBlock[1],\n });\n\n continue;\n }\n // if the range is across blocks, delete the line break\n if (editor.api.isAt({ at: range, blocks: true })) {\n const previousAboveNode = editor.api.above({ at: range.anchor });\n\n if (previousAboveNode && ElementApi.isElement(previousAboveNode[0])) {\n const isBlockSuggestion = editor\n .getApi(BaseSuggestionPlugin)\n .suggestion.isBlockSuggestion(previousAboveNode[0]);\n\n if (isBlockSuggestion) {\n const node = previousAboveNode[0] as TSuggestionElement;\n\n if (node.suggestion.type === 'insert') {\n editor\n .getApi(BaseSuggestionPlugin)\n .suggestion.withoutSuggestions(() => {\n editor.tf.unsetNodes([KEYS.suggestion], {\n at: previousAboveNode[1],\n });\n editor.tf.mergeNodes({\n at: PathApi.next(previousAboveNode[1]),\n });\n });\n }\n if (node.suggestion.type === 'remove') {\n editor.tf.move({\n reverse,\n unit: 'character',\n });\n }\n break;\n }\n\n if (!isBlockSuggestion) {\n editor.tf.setNodes(\n {\n [KEYS.suggestion]: {\n id,\n createdAt,\n type: 'remove',\n userId:\n editor.getOptions(BaseSuggestionPlugin).currentUserId!,\n },\n },\n { at: previousAboveNode[1] }\n );\n editor.tf.move({\n reverse,\n unit: 'character',\n });\n break;\n }\n }\n\n break;\n }\n // move selection if still the same\n if (PointApi.equals(pointCurrent, editor.selection!.anchor)) {\n editor.tf.move({\n reverse,\n unit: 'character',\n });\n }\n\n // if the current point is in addition suggestion, delete\n const entryText = editor.getApi(BaseSuggestionPlugin).suggestion.node({\n at: range,\n isText: true,\n match: (n) =>\n TextApi.isText(n) &&\n getInlineSuggestionData(n)?.type === 'insert' &&\n isCurrentUserSuggestion(editor, n),\n });\n\n if (entryText) {\n editor.tf.delete({ at: range, unit: 'character' });\n\n continue;\n }\n\n setSuggestionNodes(editor, {\n at: range,\n createdAt: createdAt as number,\n suggestionDeletion: true,\n suggestionId: id,\n });\n }\n });\n\n return resId;\n};\n","import type { SlateEditor } from 'platejs';\n\nimport { deleteSuggestion } from './deleteSuggestion';\n\nexport const deleteFragmentSuggestion = (\n editor: SlateEditor,\n { reverse }: { reverse?: boolean } = {}\n) => {\n let resId: string | undefined;\n\n editor.tf.withoutNormalizing(() => {\n const selection = editor.selection!;\n\n const [start, end] = editor.api.edges(selection)!;\n\n if (reverse) {\n editor.tf.collapse({ edge: 'end' });\n resId = deleteSuggestion(\n editor,\n { anchor: end, focus: start },\n { reverse: true }\n );\n } else {\n editor.tf.collapse({ edge: 'start' });\n resId = deleteSuggestion(editor, { anchor: start, focus: end });\n }\n });\n\n return resId;\n};\n","import { type Descendant, type SlateEditor, KEYS, TextApi } from 'platejs';\n\nimport { BaseSuggestionPlugin } from '../BaseSuggestionPlugin';\nimport { findSuggestionProps } from '../queries';\nimport { getSuggestionKey, getSuggestionKeys } from '../utils/index';\nimport { deleteFragmentSuggestion } from './deleteFragmentSuggestion';\n\nexport const insertFragmentSuggestion = (\n editor: SlateEditor,\n fragment: Descendant[],\n {\n insertFragment = editor.tf.insertFragment,\n }: {\n insertFragment?: (fragment: Descendant[]) => void;\n } = {}\n) => {\n editor.tf.withoutNormalizing(() => {\n deleteFragmentSuggestion(editor);\n\n const { id, createdAt } = findSuggestionProps(editor, {\n at: editor.selection!,\n type: 'insert',\n });\n\n fragment.forEach((n) => {\n if (TextApi.isText(n)) {\n if (!n[KEYS.suggestion]) {\n // Add suggestion mark\n n[KEYS.suggestion] = true;\n }\n\n // remove the other suggestion data\n const otherUserKeys = getSuggestionKeys(n);\n otherUserKeys.forEach((key) => {\n delete n[key];\n });\n\n n[getSuggestionKey(id)] = {\n id,\n createdAt,\n type: 'insert',\n userId: editor.getOptions(BaseSuggestionPlugin).currentUserId!,\n };\n } else {\n n[KEYS.suggestion] = {\n id,\n createdAt,\n type: 'insert',\n userId: editor.getOptions(BaseSuggestionPlugin).currentUserId!,\n };\n }\n });\n\n editor.getApi(BaseSuggestionPlugin).suggestion.withoutSuggestions(() => {\n insertFragment(fragment);\n });\n });\n};\n","import type { SlateEditor, TSuggestionText } from 'platejs';\n\nimport { BaseSuggestionPlugin } from '../BaseSuggestionPlugin';\nimport { findSuggestionProps } from '../queries';\nimport { getSuggestionKey } from '../utils';\nimport { deleteFragmentSuggestion } from './deleteFragmentSuggestion';\n\nexport const insertTextSuggestion = (editor: SlateEditor, text: string) => {\n editor.tf.withoutNormalizing(() => {\n let resId: string | undefined;\n const { id, createdAt } = findSuggestionProps(editor, {\n at: editor.selection!,\n type: 'insert',\n });\n\n if (editor.api.isExpanded()) {\n resId = deleteFragmentSuggestion(editor);\n }\n\n editor.getApi(BaseSuggestionPlugin).suggestion.withoutSuggestions(() => {\n editor.tf.insertNodes<TSuggestionText>(\n {\n [getSuggestionKey(resId ?? id)]: {\n id: resId ?? id,\n createdAt,\n type: 'insert',\n userId: editor.getOptions(BaseSuggestionPlugin).currentUserId!,\n },\n suggestion: true,\n text,\n },\n {\n at: editor.selection!,\n select: true,\n }\n );\n });\n });\n};\n","import { type SlateEditor, type TNode, KEYS, nanoid, TextApi } from 'platejs';\n\nimport { getInlineSuggestionData, getSuggestionKey } from '../..';\nimport { BaseSuggestionPlugin } from '../BaseSuggestionPlugin';\n\nconst getRemoveMarkProps = () => {\n const defaultProps = {\n id: nanoid(),\n createdAt: Date.now(),\n };\n\n return defaultProps;\n};\n\n// TODO remove mark when the text is already marked as a bold by suggestion\nexport const removeMarkSuggestion = (editor: SlateEditor, key: string) => {\n editor.getApi(BaseSuggestionPlugin).suggestion.withoutSuggestions(() => {\n const { id, createdAt } = getRemoveMarkProps();\n\n const match = (n: TNode) => {\n if (!TextApi.isText(n)) return false;\n // if the node is already marked as a suggestion, we don't want to remove it unless it's a removeMark suggestion\n if (n[KEYS.suggestion]) {\n const data = getInlineSuggestionData(n);\n\n if (data?.type === 'update') {\n return true;\n }\n\n return false;\n }\n\n return true;\n };\n\n editor.tf.unsetNodes(key, {\n match,\n });\n\n editor.tf.setNodes(\n {\n [getSuggestionKey(id)]: {\n id,\n createdAt,\n properties: {\n [key]: undefined,\n },\n type: 'update',\n userId: editor.getOptions(BaseSuggestionPlugin).currentUserId,\n },\n [KEYS.suggestion]: true,\n },\n {\n match,\n }\n );\n });\n};\n","import type { NodeEntry, SlateEditor, TElement, Text } from 'platejs';\n\nimport { KEYS } from 'platejs';\n\nimport { findSuggestionProps } from '../queries';\n\nexport const removeNodesSuggestion = (\n editor: SlateEditor,\n nodes: NodeEntry<TElement | Text>[]\n) => {\n if (nodes.length === 0) return;\n\n const { id, createdAt } = findSuggestionProps(editor, {\n at: editor.selection!,\n type: 'remove',\n });\n\n nodes.forEach(([, blockPath]) => {\n editor.tf.setNodes(\n {\n [KEYS.suggestion]: {\n id,\n createdAt,\n type: 'remove',\n },\n },\n { at: blockPath }\n );\n });\n};\n","import {\n type OverrideEditor,\n type TSuggestionElement,\n ElementApi,\n KEYS,\n nanoid,\n TextApi,\n} from 'platejs';\n\nimport {\n type BaseSuggestionConfig,\n BaseSuggestionPlugin,\n} from './BaseSuggestionPlugin';\nimport { findSuggestionProps } from './queries';\nimport { addMarkSuggestion } from './transforms/addMarkSuggestion';\nimport { deleteFragmentSuggestion } from './transforms/deleteFragmentSuggestion';\nimport { deleteSuggestion } from './transforms/deleteSuggestion';\nimport { insertFragmentSuggestion } from './transforms/insertFragmentSuggestion';\nimport { insertTextSuggestion } from './transforms/insertTextSuggestion';\nimport { removeMarkSuggestion } from './transforms/removeMarkSuggestion';\nimport { removeNodesSuggestion } from './transforms/removeNodesSuggestion';\nimport { getInlineSuggestionData, getSuggestionKeyId } from './utils/index';\n\nexport const withSuggestion: OverrideEditor<BaseSuggestionConfig> = ({\n api,\n editor,\n getOptions,\n tf: {\n addMark,\n apply,\n deleteBackward,\n deleteForward,\n deleteFragment,\n insertBreak,\n insertFragment,\n insertNodes,\n insertText,\n normalizeNode,\n removeMark,\n removeNodes,\n },\n}) => ({\n transforms: {\n addMark(key, value) {\n if (getOptions().isSuggesting && api.isExpanded()) {\n return addMarkSuggestion(editor, key, value);\n }\n\n return addMark(key, value);\n },\n apply(operation) {\n return apply(operation);\n },\n deleteBackward(unit) {\n const selection = editor.selection!;\n const pointTarget = editor.api.before(selection, { unit });\n\n if (getOptions().isSuggesting) {\n const node = editor.api.above<TSuggestionElement>();\n // without set suggestion when delete backward in block suggestion\n if (node?.[0][KEYS.suggestion] && !node?.[0].suggestion.isLineBreak) {\n return deleteBackward(unit);\n }\n\n if (!pointTarget) return;\n\n deleteSuggestion(\n editor,\n { anchor: selection.anchor, focus: pointTarget },\n { reverse: true }\n );\n\n return;\n }\n // remove line break when across blocks\n if (pointTarget) {\n const isCrossBlock = editor.api.isAt({\n at: { anchor: selection.anchor, focus: pointTarget },\n blocks: true,\n });\n\n if (isCrossBlock) {\n editor.tf.unsetNodes([KEYS.suggestion], {\n at: pointTarget,\n });\n }\n }\n\n deleteBackward(unit);\n },\n deleteForward(unit) {\n if (getOptions().isSuggesting) {\n const selection = editor.selection!;\n const pointTarget = editor.api.after(selection, { unit });\n\n if (!pointTarget) return;\n\n deleteSuggestion(editor, {\n anchor: selection.anchor,\n focus: pointTarget,\n });\n\n return;\n }\n\n deleteForward(unit);\n },\n\n deleteFragment(direction) {\n if (getOptions().isSuggesting) {\n deleteFragmentSuggestion(editor, { reverse: true });\n\n return;\n }\n\n deleteFragment(direction);\n },\n\n insertBreak() {\n if (getOptions().isSuggesting) {\n const [node, path] = editor.api.above()!;\n\n if (path.length > 1 || node.type !== editor.getType(KEYS.p)) {\n return insertTextSuggestion(editor, '\\n');\n }\n\n const { id, createdAt } = findSuggestionProps(editor, {\n at: editor.selection!,\n type: 'insert',\n });\n\n insertBreak();\n\n editor.tf.withoutMerging(() => {\n editor.tf.setNodes(\n {\n [KEYS.suggestion]: {\n id,\n createdAt,\n isLineBreak: true,\n type: 'insert',\n userId: editor.getOptions(BaseSuggestionPlugin).currentUserId!,\n },\n },\n { at: path }\n );\n });\n\n return;\n }\n\n insertBreak();\n },\n\n insertFragment(fragment) {\n if (getOptions().isSuggesting) {\n insertFragmentSuggestion(editor, fragment, { insertFragment });\n\n return;\n }\n\n insertFragment(fragment);\n },\n\n insertNodes(nodes, options) {\n if (getOptions().isSuggesting) {\n const nodesArray = Array.isArray(nodes) ? nodes : [nodes];\n\n // TODO: options\n if (nodesArray.some((n) => n.type === 'slash_input')) {\n api.suggestion.withoutSuggestions(() => {\n insertNodes(nodes, options);\n });\n\n return;\n }\n\n const suggestionNodes = nodesArray.map((node) => ({\n ...node,\n [KEYS.suggestion]: {\n id: nanoid(),\n createdAt: Date.now(),\n type: 'insert',\n userId: editor.getOptions(BaseSuggestionPlugin).currentUserId!,\n },\n }));\n\n return insertNodes(suggestionNodes, options);\n }\n\n return insertNodes(nodes, options);\n },\n\n insertText(text, options) {\n if (getOptions().isSuggesting) {\n const node = editor.api.above<TSuggestionElement>();\n\n if (node?.[0][KEYS.suggestion] && !node?.[0].suggestion.isLineBreak) {\n return insertText(text, options);\n }\n\n insertTextSuggestion(editor, text);\n\n return;\n }\n\n insertText(text, options);\n },\n\n normalizeNode(entry) {\n api.suggestion.withoutSuggestions(() => {\n const [node, path] = entry;\n\n const inlineSuggestion =\n (ElementApi.isElement(node) && editor.api.isInline(node)) ||\n TextApi.isText(node);\n\n if (\n node[KEYS.suggestion] && // Unset suggestion when there is no suggestion id\n inlineSuggestion &&\n !getSuggestionKeyId(node)\n ) {\n editor.tf.unsetNodes([KEYS.suggestion, 'suggestionData'], {\n at: path,\n });\n\n return;\n }\n // Unset suggestion when there is no suggestion user id\n if (\n node[KEYS.suggestion] &&\n inlineSuggestion &&\n !getInlineSuggestionData(node)?.userId\n ) {\n if (getInlineSuggestionData(node)?.type === 'remove') {\n // Unset deletions\n editor.tf.unsetNodes([KEYS.suggestion, getSuggestionKeyId(node)!], {\n at: path,\n });\n } else {\n // Remove additions\n editor.tf.removeNodes({ at: path });\n }\n\n return;\n }\n\n normalizeNode(entry);\n });\n },\n removeMark(key) {\n if (getOptions().isSuggesting && api.isExpanded()) {\n return removeMarkSuggestion(editor, key);\n }\n\n return removeMark(key);\n },\n // Remove nodes by block selection\n removeNodes(options) {\n if (getOptions().isSuggesting) {\n const nodes = [...editor.api.nodes(options)];\n\n if (nodes.some(([n]) => n.type === 'slash_input')) {\n api.suggestion.withoutSuggestions(() => {\n removeNodes(options);\n });\n\n return;\n }\n\n return removeNodesSuggestion(editor, nodes);\n }\n\n return removeNodes(options);\n },\n },\n});\n","import {\n type EditorNodesOptions,\n type NodeEntry,\n type PluginConfig,\n type TElement,\n type TInlineSuggestionData,\n type TNode,\n type TSuggestionElement,\n type TSuggestionText,\n createTSlatePlugin,\n ElementApi,\n getAt,\n KEYS,\n TextApi,\n} from 'platejs';\n\nimport { getSuggestionKey, getSuggestionKeyId } from './utils';\nimport { getTransientSuggestionKey } from './utils/getTransientSuggestionKey';\nimport { withSuggestion } from './withSuggestion';\n\nexport type BaseSuggestionConfig = PluginConfig<\n 'suggestion',\n {\n currentUserId: string | null;\n isSuggesting: boolean;\n // onAdd?: (value: WithPartial<TSuggestion, 'id' | 'userId'>) => void;\n // onRemove?: (id: string) => void;\n // onUpdate?: (id: string, value: Partial<TSuggestion>) => void;\n },\n {\n suggestion: {\n dataList: (node: TSuggestionText) => TInlineSuggestionData[];\n isBlockSuggestion: (node: TNode) => node is TSuggestionElement;\n node: (\n options?: EditorNodesOptions & { id?: string; isText?: boolean }\n ) => NodeEntry<TSuggestionElement | TSuggestionText> | undefined;\n nodeId: (node: TElement | TSuggestionText) => string | undefined;\n nodes: (\n options?: EditorNodesOptions & { transient?: boolean }\n ) => NodeEntry<TElement | TSuggestionText>[];\n suggestionData: (\n node: TElement | TSuggestionText\n ) => TInlineSuggestionData | TSuggestionElement['suggestion'] | undefined;\n withoutSuggestions: (fn: () => void) => void;\n };\n }\n>;\n\nexport const BaseSuggestionPlugin = createTSlatePlugin<BaseSuggestionConfig>({\n key: KEYS.suggestion,\n node: { isLeaf: true },\n options: {\n currentUserId: 'alice',\n isSuggesting: false,\n },\n rules: { selection: { affinity: 'outward' } },\n})\n .overrideEditor(withSuggestion)\n .extendApi<BaseSuggestionConfig['api']['suggestion']>(\n ({ api, editor, getOption, setOption, type }) => ({\n dataList: (node: TSuggestionText): TInlineSuggestionData[] =>\n Object.keys(node)\n .filter((key) => key.startsWith(`${KEYS.suggestion}_`))\n .map((key) => node[key] as TInlineSuggestionData),\n isBlockSuggestion: (node): node is TSuggestionElement =>\n ElementApi.isElement(node) &&\n !editor.api.isInline(node) &&\n 'suggestion' in node,\n node: (options = {}) => {\n const { id, isText, ...rest } = options;\n const result = editor.api.node<TSuggestionElement | TSuggestionText>({\n match: (n) => {\n if (!n[type]) return false;\n if (isText && !TextApi.isText(n)) return false;\n if (id) {\n if (TextApi.isText(n)) {\n return !!n[getSuggestionKey(id)];\n }\n if (\n ElementApi.isElement(n) &&\n api.suggestion.isBlockSuggestion(n)\n ) {\n return n.suggestion.id === id;\n }\n }\n\n return true;\n },\n ...rest,\n });\n\n return result;\n },\n nodeId: (node) => {\n if (\n TextApi.isText(node) ||\n (ElementApi.isElement(node) && editor.api.isInline(node))\n ) {\n const keyId = getSuggestionKeyId(node);\n\n if (!keyId) return;\n\n return keyId.replace(`${type}_`, '');\n }\n\n if (api.suggestion.isBlockSuggestion(node)) {\n return node.suggestion.id;\n }\n },\n nodes: (options = {}) => {\n const { transient } = options;\n\n const at = getAt(editor, options.at) ?? [];\n\n return [\n ...editor.api.nodes<TElement | TSuggestionText>({\n ...options,\n at,\n mode: 'all',\n match: (n) =>\n n[type] && (transient ? n[getTransientSuggestionKey()] : true),\n }),\n ];\n },\n suggestionData: (node) => {\n if (\n TextApi.isText(node) ||\n (ElementApi.isElement(node) && editor.api.isInline(node))\n ) {\n const keyId = getSuggestionKeyId(node);\n\n if (!keyId) return;\n\n return node[keyId] as TInlineSuggestionData | undefined;\n }\n\n if (api.suggestion.isBlockSuggestion(node)) {\n return node.suggestion;\n }\n },\n withoutSuggestions: (fn) => {\n const prev = getOption('isSuggesting');\n setOption('isSuggesting', false);\n fn();\n setOption('isSuggesting', prev);\n },\n })\n );\n","import {\n type SlateEditor,\n type TSuggestionElement,\n type TSuggestionText,\n ElementApi,\n KEYS,\n PathApi,\n TextApi,\n} from 'platejs';\n\nimport type { TResolvedSuggestion } from '../types';\n\nimport { BaseSuggestionPlugin } from '../BaseSuggestionPlugin';\nimport { getInlineSuggestionData, getTransientSuggestionKey } from '../utils';\n\nexport const acceptSuggestion = (\n editor: SlateEditor,\n description: TResolvedSuggestion\n) => {\n editor.tf.withoutNormalizing(() => {\n const mergeNodes = [\n ...editor.api.nodes({\n at: [],\n match: (n) => {\n if (!ElementApi.isElement(n)) return false;\n\n if (\n editor.getApi(BaseSuggestionPlugin).suggestion.isBlockSuggestion(n)\n ) {\n const suggestionElement = n as TSuggestionElement;\n return (\n suggestionElement.suggestion.type === 'remove' &&\n suggestionElement.suggestion.isLineBreak &&\n suggestionElement.suggestion.id === description.suggestionId\n );\n }\n\n return false;\n },\n }),\n ];\n\n mergeNodes.reverse().forEach(([, path]) => {\n editor.tf.mergeNodes({ at: PathApi.next(path) });\n });\n\n editor.tf.unsetNodes(\n [description.keyId, KEYS.suggestion, getTransientSuggestionKey()],\n {\n at: [],\n mode: 'all',\n match: (n) => {\n if (\n TextApi.isText(n) ||\n (ElementApi.isElement(n) && editor.api.isInline(n))\n ) {\n const suggestionDataList = editor\n .getApi(BaseSuggestionPlugin)\n .suggestion.dataList(n as TSuggestionText);\n const includeUpdate = suggestionDataList.some(\n (data) => data.type === 'update'\n );\n\n if (includeUpdate) {\n return suggestionDataList.some(\n (d) => d.id === description.suggestionId\n );\n }\n const suggestionData = getInlineSuggestionData(n);\n\n if (suggestionData)\n return (\n suggestionData.type === 'insert' &&\n suggestionData.id === description.suggestionId\n );\n\n return false;\n }\n if (\n ElementApi.isElement(n) &&\n editor.getApi(BaseSuggestionPlugin).suggestion.isBlockSuggestion(n)\n ) {\n const suggestionElement = n as TSuggestionElement;\n const suggestionData = suggestionElement.suggestion;\n\n if (suggestionData) {\n const isLineBreak = suggestionData.isLineBreak;\n\n if (isLineBreak)\n return suggestionData.id === description.suggestionId;\n\n return (\n suggestionData.type === 'insert' &&\n suggestionData.id === description.suggestionId\n );\n }\n }\n\n return false;\n },\n }\n );\n\n editor.tf.removeNodes({\n at: [],\n mode: 'all',\n match: (n) => {\n if (\n TextApi.isText(n) ||\n // inline elements like links\n (ElementApi.isElement(n) && editor.api.isInline(n))\n ) {\n const suggestionData = getInlineSuggestionData(n);\n\n if (suggestionData) {\n return (\n suggestionData.type === 'remove' &&\n suggestionData.id === description.suggestionId\n );\n }\n\n return false;\n }\n\n if (\n ElementApi.isElement(n) &&\n editor.getApi(BaseSuggestionPlugin).suggestion.isBlockSuggestion(n)\n ) {\n const suggestionElement = n as TSuggestionElement;\n const suggestionData = suggestionElement.suggestion;\n\n if (suggestionData) {\n const isLineBreak = suggestionData.isLineBreak;\n\n return (\n suggestionData.type === 'remove' &&\n suggestionData.id === description.suggestionId &&\n !isLineBreak\n );\n }\n }\n\n return false;\n },\n });\n });\n};\n","import type { Descendant, SlateEditor } from 'platejs';\n\nimport { ElementApi, KEYS, nanoid } from 'platejs';\n\nimport { BaseSuggestionPlugin } from '../BaseSuggestionPlugin';\nimport { getSuggestionKey, getTransientSuggestionKey } from '../utils/index';\n\nexport const getSuggestionProps = (\n editor: SlateEditor,\n node: Descendant,\n {\n id = nanoid(),\n createdAt = Date.now(),\n suggestionDeletion,\n suggestionUpdate,\n transient,\n }: {\n id?: string;\n createdAt?: number;\n suggestionDeletion?: boolean;\n suggestionUpdate?: any;\n transient?: boolean;\n } = {}\n) => {\n const type = suggestionDeletion\n ? 'remove'\n : suggestionUpdate\n ? 'update'\n : 'insert';\n\n const isElement = ElementApi.isElement(node);\n\n const suggestionData = {\n id,\n createdAt,\n type,\n userId: editor.getOptions(BaseSuggestionPlugin).currentUserId!,\n };\n\n if (isElement) {\n return {\n [KEYS.suggestion]: suggestionData,\n };\n }\n\n const res = {\n [getSuggestionKey(id)]: suggestionData,\n [KEYS.suggestion]: true,\n };\n\n if (transient) {\n res[getTransientSuggestionKey()] = true;\n }\n\n return res;\n};\n","import {\n type SlateEditor,\n type TSuggestionElement,\n type TSuggestionText,\n type TText,\n ElementApi,\n KEYS,\n PathApi,\n TextApi,\n} from 'platejs';\n\nimport type { TResolvedSuggestion } from '../types';\n\nimport { BaseSuggestionPlugin } from '../BaseSuggestionPlugin';\nimport {\n getInlineSuggestionData,\n getSuggestionKey,\n getTransientSuggestionKey,\n} from '../utils';\n\nexport const rejectSuggestion = (\n editor: SlateEditor,\n description: TResolvedSuggestion\n) => {\n editor.tf.withoutNormalizing(() => {\n const mergeNodes = [\n ...editor.api.nodes({\n at: [],\n match: (n) => {\n if (!ElementApi.isElement(n)) return false;\n\n if (\n editor.getApi(BaseSuggestionPlugin).suggestion.isBlockSuggestion(n)\n ) {\n const suggestionElement = n as TSuggestionElement;\n return (\n suggestionElement.suggestion.type === 'insert' &&\n suggestionElement.suggestion.isLineBreak &&\n suggestionElement.suggestion.id === description.suggestionId\n );\n }\n\n return false;\n },\n }),\n ];\n\n mergeNodes.reverse().forEach(([, path]) => {\n editor.tf.mergeNodes({ at: PathApi.next(path) });\n });\n\n editor.tf.unsetNodes(\n [description.keyId, KEYS.suggestion, getTransientSuggestionKey()],\n {\n at: [],\n mode: 'all',\n match: (n) => {\n if (TextApi.isText(n)) {\n const node = n as TSuggestionText;\n const suggestionData = getInlineSuggestionData(node);\n\n if (suggestionData)\n return (\n suggestionData.type === 'remove' &&\n suggestionData.id === description.suggestionId\n );\n\n return false;\n }\n if (\n ElementApi.isElement(n) &&\n editor.getApi(BaseSuggestionPlugin).suggestion.isBlockSuggestion(n)\n ) {\n const suggestionElement = n as TSuggestionElement;\n const isLineBreak = suggestionElement.suggestion.isLineBreak;\n\n if (isLineBreak)\n return (\n suggestionElement.suggestion.id === description.suggestionId\n );\n\n return (\n suggestionElement.suggestion.type === 'remove' &&\n suggestionElement.suggestion.id === description.suggestionId\n );\n }\n\n return false;\n },\n }\n );\n\n editor.tf.removeNodes({\n at: [],\n mode: 'all',\n match: (n) => {\n if (TextApi.isText(n)) {\n const node = n as TSuggestionText;\n\n const suggestionData = getInlineSuggestionData(node);\n\n if (suggestionData)\n return (\n suggestionData.type === 'insert' &&\n suggestionData.id === description.suggestionId\n );\n\n return false;\n }\n\n if (\n ElementApi.isElement(n) &&\n editor.getApi(BaseSuggestionPlugin).suggestion.isBlockSuggestion(n)\n ) {\n const suggestionElement = n as TSuggestionElement;\n return (\n suggestionElement.suggestion.type === 'insert' &&\n suggestionElement.suggestion.id === description.suggestionId &&\n !suggestionElement.suggestion.isLineBreak\n );\n }\n\n return false;\n },\n });\n\n const updateNodes = [\n ...editor.api.nodes<TText>({\n at: [],\n match: (n) => {\n if (ElementApi.isElement(n)) return false;\n if (TextApi.isText(n)) {\n const datalist = editor\n .getApi(BaseSuggestionPlugin)\n .suggestion.dataList(n as TSuggestionText);\n\n if (datalist.length > 0)\n return datalist.some(\n (data) =>\n data.type === 'update' && data.id === description.suggestionId\n );\n\n return false;\n }\n },\n }),\n ];\n\n updateNodes.forEach(([node, path]) => {\n const datalist = editor\n .getApi(BaseSuggestionPlugin)\n .suggestion.dataList(node as TSuggestionText);\n const targetData = datalist.find(\n (data) => data.type === 'update' && data.id === description.suggestionId\n );\n\n if (!targetData) return;\n if ('newProperties' in targetData) {\n const unsetProps = Object.keys(targetData.newProperties).filter(\n (key) => targetData.newProperties[key]\n );\n\n editor.tf.unsetNodes([...unsetProps], {\n at: path,\n });\n }\n if ('properties' in targetData) {\n const addProps = Object.keys(targetData.properties).filter(\n (key) => !targetData.properties[key]\n );\n\n editor.tf.setNodes(\n Object.fromEntries(addProps.map((key) => [key, true])),\n {\n at: path,\n }\n );\n }\n\n // remove targetData\n editor.tf.unsetNodes([getSuggestionKey(targetData.id)], {\n at: path,\n });\n });\n });\n};\n","import { type ComputeDiffOptions, computeDiff } from '@platejs/diff';\nimport {\n type Descendant,\n type SlateEditor,\n type ValueOf,\n ElementApi,\n KEYS,\n TextApi,\n} from 'platejs';\n\nimport { BaseSuggestionPlugin } from './BaseSuggestionPlugin';\nimport { getSuggestionProps } from './transforms';\nimport { getSuggestionKey } from './utils';\n\nexport function diffToSuggestions<E extends SlateEditor>(\n editor: E,\n doc0: Descendant[],\n doc1: Descendant[],\n {\n getDeleteProps = (node) =>\n getSuggestionProps(editor, node, {\n suggestionDeletion: true,\n }),\n getInsertProps = (node) => getSuggestionProps(editor, node),\n getUpdateProps = (node, _properties, newProperties) =>\n getSuggestionProps(editor, node, {\n suggestionUpdate: newProperties,\n }),\n isInline = editor.api.isInline,\n ...options\n }: Partial<ComputeDiffOptions> = {}\n): ValueOf<E> {\n const values = computeDiff(doc0, doc1, {\n getDeleteProps,\n getInsertProps,\n getUpdateProps,\n isInline,\n ...options,\n }) as ValueOf<E>;\n\n // Recursively traverse all nodes to process elements and their children\n const traverseNodes = (nodes: Descendant[]): Descendant[] => {\n return nodes.map((node, index) => {\n if (ElementApi.isElement(node) && 'children' in node) {\n // If the node is an element with children, recursively process its children\n return {\n ...node,\n children: traverseNodes(node.children),\n };\n }\n\n if (TextApi.isText(node) && node[KEYS.suggestion]) {\n return unifyAdjacentSuggestionIds(node, index, nodes, editor);\n }\n return node;\n });\n };\n\n return traverseNodes(values) as ValueOf<E>;\n}\n\n/**\n * Unifies the ID of adjacent insert and remove suggestions. When an insert\n * suggestion follows a remove suggestion, the insert suggestion inherits the ID\n * and creation time from the remove suggestion. This allows the UI to treat\n * them as a single suggestion for display and interaction purposes.\n */\nfunction unifyAdjacentSuggestionIds<E extends SlateEditor>(\n node: Descendant,\n index: number,\n nodes: Descendant[],\n editor: E\n): Descendant {\n const api = editor.getApi(BaseSuggestionPlugin);\n const currentNodeData = api.suggestion.suggestionData(node as any);\n\n if (currentNodeData?.type === 'insert') {\n // Get the previous node if it exists\n const previousNode = index > 0 ? nodes[index - 1] : null;\n\n if (previousNode?.[KEYS.suggestion]) {\n const previousData = api.suggestion.suggestionData(previousNode as any);\n\n if (previousData?.type === 'remove') {\n // Create a new node with the updated suggestion data\n const updatedNode = {\n ...node,\n [getSuggestionKey(previousData.id)]: {\n ...currentNodeData,\n id: previousData.id,\n createdAt: previousData.createdAt,\n },\n };\n\n // Remove the original insert suggestion key to avoid duplication\n const key = getSuggestionKey(currentNodeData.id);\n delete updatedNode[key];\n\n return updatedNode;\n }\n }\n }\n\n return node;\n}\n"],"mappings":";;;;;;;;;AAiBA,MAAaQ,yBACXC,QACAC,SACW;AACX,KACEJ,QAAQK,OAAOD,KAAK,IACnBP,WAAWS,UAAUF,KAAK,IAAID,OAAOI,IAAIC,SAASJ,KAAM,EACzD;AACA,MAAIP,WAAWS,UAAUF,KAAK,CAC5B,QAAOL,QAAQU,OAAOL,KAAK;AAE7B,MAAI,CAACA,KAAKN,KAAKY,YAAa,QAAON,KAAKO;AAMxC,MAJuBR,OACpBU,OAAOZ,qBAAqB,CAC5BS,WAAWE,eAAeR,KAAwB,EAEjCU,SAAS,SAAU,QAAO;AAE9C,SAAOV,KAAKO;;AAEd,QAAOP,KAAKW,SACTC,KAAKC,UAAUf,sBAAsBC,QAAQc,MAAM,CAAC,CACpDC,KAAK,GAAG;;;;;ACnCb,MAAaK,sBAAsBC,SAA2B;AAK5D,QAJsBE,OAAOC,KAAKH,KAAK,CAACI,QAAQ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