@lofcz/platejs-suggestion 52.0.11

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.
@@ -0,0 +1 @@
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,QAAQC,QAC9CA,IAAIC,WAAW,GAAGR,KAAKS,WAAU,GACnC,CAAC,CAEUC,GAAG,GAAG;;AAGnB,MAAaC,2BAA2BT,SAA2B;CACjE,MAAMU,QAAQX,mBAAmBC,KAAK;AAEtC,KAAI,CAACU,MAAO;AAEZ,QAAOV,KAAKU;;AAGd,MAAaC,sBAAsBD,UACjCA,MAAME,QAAQ,GAAGd,KAAKS,WAAU,IAAK,GAAG;;;;ACX1C,MAAaa,oBAAoBC,KAAK,QACpC,GAAGJ,KAAKK,WAAU,GAAID;AAExB,MAAaE,mBAAmBC,QAC9BA,IAAIC,WAAW,GAAGR,KAAKK,WAAU,GAAI;AAEvC,MAAaI,qBAAqBC,SAAgB;CAChD,MAAMC,OAAiB,EAAE;AAEzBC,QAAOD,KAAKD,KAAK,CA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,cAAcF,SAAS,UAAU;IAEnC,MAAMG,cAAc;KAClB,GAAG3B;MACFP,iBAAiBiC,aAAaE,GAAG,GAAG;MACnC,GAAGN;MACHM,IAAIF,aAAaE;MACjBC,WAAWH,aAAaG;MAC1B;KACD;IAGD,MAAMC,MAAMrC,iBAAiB6B,gBAAgBM,GAAG;AAChD,WAAOD,YAAYG;AAEnB,WAAOH;;;;AAKb,QAAO3B"}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@lofcz/platejs-suggestion",
3
+ "version": "52.0.11",
4
+ "description": "Plate plugin for suggestions",
5
+ "keywords": [
6
+ "plate",
7
+ "plugin",
8
+ "slate"
9
+ ],
10
+ "homepage": "https://platejs.org",
11
+ "bugs": {
12
+ "url": "https://github.com/udecode/plate/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/lofcz/plate.git",
17
+ "directory": "packages/suggestion"
18
+ },
19
+ "license": "MIT",
20
+ "sideEffects": false,
21
+ "exports": {
22
+ ".": "./dist/index.js",
23
+ "./react": "./dist/react/index.js",
24
+ "./package.json": "./package.json"
25
+ },
26
+ "main": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "files": [
29
+ "dist/**/*"
30
+ ],
31
+ "dependencies": {
32
+ "lodash": "^4.17.21",
33
+ "react-compiler-runtime": "^1.0.0",
34
+ "@platejs/diff": "npm:@lofcz/platejs-diff@52.0.11"
35
+ },
36
+ "devDependencies": {
37
+ "@plate/scripts": "1.0.0"
38
+ },
39
+ "peerDependencies": {
40
+ "platejs": ">=52.0.11",
41
+ "react": ">=18.0.0",
42
+ "react-dom": ">=18.0.0"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "type": "module",
48
+ "module": "./dist/index.js",
49
+ "scripts": {
50
+ "brl": "plate-pkg p:brl",
51
+ "build": "plate-pkg p:build",
52
+ "build:watch": "plate-pkg p:build:watch",
53
+ "clean": "plate-pkg p:clean",
54
+ "lint": "plate-pkg p:lint",
55
+ "lint:fix": "plate-pkg p:lint:fix",
56
+ "test": "plate-pkg p:test",
57
+ "test:watch": "plate-pkg p:test:watch",
58
+ "typecheck": "plate-pkg p:typecheck"
59
+ }
60
+ }