tiptop-editor 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/helpers.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Editor } from '@tiptap/core';
2
2
  import { EditorState } from '@tiptap/pm/state';
3
- import { SlashCommandGroupCommandsProps } from './types';
3
+ import { DocumentMap, SlashCommandGroupCommandsProps, TargetedUpdate } from './types';
4
4
  import { Node } from '@tiptap/pm/model';
5
5
  export declare const isTextSelected: (editor: Editor) => boolean;
6
6
  export declare const hasTextNodeInSelection: (editor: Editor) => boolean;
@@ -38,3 +38,31 @@ export declare const getUploaderAtPos: (state: Editor["state"], pos: number) =>
38
38
  depth: number;
39
39
  node: Node;
40
40
  } | undefined;
41
+ /**
42
+ * Returns a structured snapshot of every top-level block in the editor.
43
+ * Send this to your AI model so it can reference nodes and words by index.
44
+ */
45
+ export declare const getDocumentMap: (editor: Editor) => DocumentMap;
46
+ /**
47
+ * Applies a single targeted content update.
48
+ *
49
+ * @example
50
+ * // Translate the first word of the second paragraph
51
+ * applyTargetedUpdate(editor, { nodeIndex: 1, wordIndex: 0, replacement: 'Bonjour' })
52
+ */
53
+ export declare const applyTargetedUpdate: (editor: Editor, update: TargetedUpdate) => boolean;
54
+ /**
55
+ * Applies multiple targeted updates in a single atomic ProseMirror transaction.
56
+ *
57
+ * All positions are resolved against the document state *before* any mutations,
58
+ * then applied from the bottom of the document upward so that earlier replacements
59
+ * never shift the absolute positions of later ones.
60
+ *
61
+ * @example
62
+ * // Bold-ify two specific words in one go
63
+ * applyTargetedUpdates(editor, [
64
+ * { nodeIndex: 0, wordIndex: 2, replacement: [{ type: 'text', text: 'foo', marks: [{ type: 'bold' }] }] },
65
+ * { nodeIndex: 2, wordRange: [0, 1], replacement: 'Hello world' },
66
+ * ])
67
+ */
68
+ export declare const applyTargetedUpdates: (editor: Editor, updates: TargetedUpdate[]) => boolean;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { default as TiptopEditor } from './components/editor/TiptopEditor';
2
2
  export { TiptopEditorContext, useTiptopEditor } from './components/editor/TiptopEditorContext';
3
+ export { getDocumentMap, applyTargetedUpdate, applyTargetedUpdates } from './helpers';
3
4
  export * from './types';