@lax-wp/editor 0.4.13 → 0.4.15-beta.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.
Files changed (160) hide show
  1. package/README.md +25 -0
  2. package/dist/api/audit.d.ts +79 -0
  3. package/dist/api/derivedRulebook.d.ts +470 -0
  4. package/dist/api/documentVersions.d.ts +519 -0
  5. package/dist/api/effectiveRules.d.ts +372 -0
  6. package/dist/api/methodology.d.ts +62 -0
  7. package/dist/api/playbook.d.ts +604 -0
  8. package/dist/api/promotions.d.ts +1432 -0
  9. package/dist/api/r1.d.ts +1097 -0
  10. package/dist/api/r1.fixtures.d.ts +111 -0
  11. package/dist/api/redlineJobs.d.ts +377 -0
  12. package/dist/api/redlineStream.d.ts +2979 -0
  13. package/dist/api/redlines.d.ts +504 -0
  14. package/dist/api/regsync.d.ts +2355 -0
  15. package/dist/api/ruleAuthoring.d.ts +305 -0
  16. package/dist/api/ruleBuilder.d.ts +1009 -0
  17. package/dist/api/ruleOverrides.d.ts +31 -0
  18. package/dist/api/ruleStats.d.ts +84 -0
  19. package/dist/api/rulesCatalog.d.ts +234 -0
  20. package/dist/api/versions.d.ts +76 -0
  21. package/dist/api/workspace.d.ts +41 -0
  22. package/dist/components/EditorSidebar.d.ts +4 -1
  23. package/dist/components/audit/AuditView.d.ts +8 -0
  24. package/dist/components/capturededits/AddAsRuleModal.d.ts +8 -0
  25. package/dist/components/capturededits/CapturedEditCard.d.ts +15 -0
  26. package/dist/components/capturededits/CapturedEditsTray.d.ts +4 -0
  27. package/dist/components/capturededits/capturedEditIntent.d.ts +23 -0
  28. package/dist/components/common/EscDropdown.d.ts +2 -0
  29. package/dist/components/compliance/MethodologyPanel.d.ts +14 -0
  30. package/dist/components/compliance/RegSyncPanel.d.ts +18 -0
  31. package/dist/components/compliance/index.d.ts +8 -0
  32. package/dist/components/compliance/primitives.d.ts +41 -0
  33. package/dist/components/documents/DocumentVersionHistory.d.ts +12 -0
  34. package/dist/components/documents/documentDiff.d.ts +68 -0
  35. package/dist/components/documents/index.d.ts +4 -0
  36. package/dist/components/flowdown/FlowdownPanel.d.ts +28 -0
  37. package/dist/components/flowdown/FlowdownRowCard.d.ts +27 -0
  38. package/dist/components/flowdown/flowdownModel.d.ts +150 -0
  39. package/dist/components/history/PlaybookVersionHistory.d.ts +10 -0
  40. package/dist/components/history/versionDiff.d.ts +14 -0
  41. package/dist/components/playbook/AllPlaybooksView.d.ts +41 -0
  42. package/dist/components/playbook/DerivedRulebookView.d.ts +9 -0
  43. package/dist/components/playbook/DraftedRulePreview.d.ts +17 -0
  44. package/dist/components/playbook/EffectiveRulesView.d.ts +11 -0
  45. package/dist/components/playbook/NewRuleDrawer.d.ts +11 -0
  46. package/dist/components/playbook/PlaybookCard.d.ts +13 -0
  47. package/dist/components/playbook/PlaybookPage.d.ts +29 -0
  48. package/dist/components/playbook/PlaybookPanel.d.ts +73 -0
  49. package/dist/components/playbook/PromotionSuggestions.d.ts +1 -0
  50. package/dist/components/playbook/ReprioritizeDialog.d.ts +16 -0
  51. package/dist/components/playbook/RuleDetail.d.ts +27 -0
  52. package/dist/components/playbook/RuleEditorFields.d.ts +42 -0
  53. package/dist/components/playbook/RuleEditorModal.d.ts +27 -0
  54. package/dist/components/playbook/RulePerformancePanel.d.ts +4 -0
  55. package/dist/components/playbook/RuleRow.d.ts +26 -0
  56. package/dist/components/playbook/ThisDocumentView.d.ts +45 -0
  57. package/dist/components/playbook/ViewTabs.d.ts +8 -0
  58. package/dist/components/playbook/index.d.ts +14 -0
  59. package/dist/components/playbook/predicateSummary.d.ts +10 -0
  60. package/dist/components/playbook/primitives.d.ts +82 -0
  61. package/dist/components/playbook/useFocusTrap.d.ts +6 -0
  62. package/dist/components/playbook/usePlaybookData.d.ts +161 -0
  63. package/dist/components/playbook/usePlaybookLabel.d.ts +18 -0
  64. package/dist/components/r1/ApprovalPanel.d.ts +10 -0
  65. package/dist/components/r1/CandidateRuleCard.d.ts +8 -0
  66. package/dist/components/r1/ExecSummaryPanel.d.ts +23 -0
  67. package/dist/components/r1/PrimeUploadPanel.d.ts +8 -0
  68. package/dist/components/r1/ReviewStartControls.d.ts +24 -0
  69. package/dist/components/r1/ReviewSummaryTab.d.ts +38 -0
  70. package/dist/components/r1/index.d.ts +13 -0
  71. package/dist/components/r1/primitives.d.ts +59 -0
  72. package/dist/components/redline/AiReviewPanel.d.ts +194 -0
  73. package/dist/components/redline/RedlineHoverCard.d.ts +13 -0
  74. package/dist/components/redline/RedlineItem.d.ts +12 -0
  75. package/dist/components/redline/ReviewCard.d.ts +49 -0
  76. package/dist/components/redline/index.d.ts +6 -0
  77. package/dist/components/redline/reviewItems.d.ts +49 -0
  78. package/dist/components/redline/reviewPrefs.d.ts +18 -0
  79. package/dist/components/redline/useRunScopedCards.d.ts +16 -0
  80. package/dist/components/rulebuilder/AuthorForms.d.ts +28 -0
  81. package/dist/components/rulebuilder/CandidateQueue.d.ts +21 -0
  82. package/dist/components/rulebuilder/DraftPane.d.ts +12 -0
  83. package/dist/components/rulebuilder/RuleBuilderPanel.d.ts +6 -0
  84. package/dist/components/rulebuilder/RuleCard.d.ts +16 -0
  85. package/dist/components/rulebuilder/TestBench.d.ts +10 -0
  86. package/dist/components/rulebuilder/VocabularyPanel.d.ts +26 -0
  87. package/dist/components/rulebuilder/index.d.ts +13 -0
  88. package/dist/components/rulebuilder/primitives.d.ts +54 -0
  89. package/dist/components/rulebuilder/useRuleBuilder.d.ts +291 -0
  90. package/dist/components/sidebar/ExpandableSidebar.d.ts +2 -0
  91. package/dist/components/sidebar/WorkspaceRetentionPanel.d.ts +18 -0
  92. package/dist/components/sidebar/content/TrackChangesContent.d.ts +8 -0
  93. package/dist/components/sidebar/content/anonymization-page/PIIAnonymization.d.ts +1 -1
  94. package/dist/components/sidebar/content/anonymization-page/PiiIdleView.d.ts +12 -0
  95. package/dist/components/sidebar/content/anonymization-page/PiiRecoveryView.d.ts +16 -0
  96. package/dist/components/sidebar/content/anonymization-page/PiiSummaryView.d.ts +34 -0
  97. package/dist/components/sidebar/content/anonymization-page/PiiUnavailableView.d.ts +1 -0
  98. package/dist/components/sidebar/content/anonymization-page/RestoreConfirmDialog.d.ts +9 -0
  99. package/dist/components/sidebar/content/anonymization-page/anonymizationUtils.d.ts +38 -17
  100. package/dist/components/sidebar/content/anonymization-page/piiVault.d.ts +18 -0
  101. package/dist/components/sidebar/content/index.d.ts +0 -1
  102. package/dist/components/toolbar/AutocompletionToggle.d.ts +1 -0
  103. package/dist/components/trackChanges/TrackChangesCards.d.ts +1 -0
  104. package/dist/components/trackChanges/index.d.ts +2 -0
  105. package/dist/components/trackChanges/utils.d.ts +5 -0
  106. package/dist/config/EditorConfig.d.ts +197 -73
  107. package/dist/constants/Extensions.d.ts +12 -0
  108. package/dist/constants/playbook.d.ts +108 -0
  109. package/dist/contexts/CapturedEditsContext.d.ts +56 -0
  110. package/dist/contexts/EditorShellContext.d.ts +4 -1
  111. package/dist/editor.css +1 -1
  112. package/dist/extensions/AnonymizedText.d.ts +31 -2
  113. package/dist/extensions/VariableText.d.ts +20 -0
  114. package/dist/extensions/index.d.ts +1 -1
  115. package/dist/extensions/plugins/CapturedEditsPlugin.d.ts +90 -0
  116. package/dist/extensions/plugins/MarkHighlightPlugin.d.ts +0 -1
  117. package/dist/extensions/plugins/RedlinePlugin.d.ts +9 -0
  118. package/dist/extensions/redline/changeTypes.d.ts +70 -0
  119. package/dist/extensions/redline/constants.d.ts +25 -0
  120. package/dist/extensions/redline/engine/blockNodes.d.ts +31 -0
  121. package/dist/extensions/redline/engine/clipboard.d.ts +16 -0
  122. package/dist/extensions/redline/engine/deletion.d.ts +34 -0
  123. package/dist/extensions/redline/engine/formatSplit.d.ts +16 -0
  124. package/dist/extensions/redline/engine/insertion.d.ts +26 -0
  125. package/dist/extensions/redline/engine/predicates.d.ts +73 -0
  126. package/dist/extensions/redline/engine/textReplace.d.ts +19 -0
  127. package/dist/extensions/redline/id.d.ts +7 -0
  128. package/dist/extensions/redline/index.d.ts +36 -0
  129. package/dist/extensions/redline/plugin.d.ts +34 -0
  130. package/dist/extensions/redline/query/scan.d.ts +52 -0
  131. package/dist/extensions/redline/review/applyChange.d.ts +25 -0
  132. package/dist/extensions/redline/review/index.d.ts +1 -0
  133. package/dist/extensions/redline/review/nodeResolvers.d.ts +29 -0
  134. package/dist/extensions/redline/review/pairedNodes.d.ts +38 -0
  135. package/dist/extensions/redline/review/structuralRevert.d.ts +20 -0
  136. package/dist/extensions/redline/review/textResolver.d.ts +9 -0
  137. package/dist/extensions/redline/schema/marks.d.ts +65 -0
  138. package/dist/extensions/redline/schema/shared.d.ts +34 -0
  139. package/dist/extensions/redline/session.d.ts +71 -0
  140. package/dist/extensions/redline/types.d.ts +24 -0
  141. package/dist/extensions/trackedChanges/TrackedChanges.d.ts +64 -0
  142. package/dist/extensions/trackedChanges/constants.d.ts +34 -0
  143. package/dist/extensions/trackedChanges/engine.d.ts +32 -0
  144. package/dist/extensions/trackedChanges/index.d.ts +13 -0
  145. package/dist/extensions/trackedChanges/marks.d.ts +20 -0
  146. package/dist/extensions/trackedChanges/normalize.d.ts +2 -0
  147. package/dist/extensions/trackedChanges/plugin.d.ts +32 -0
  148. package/dist/extensions/trackedChanges/query.d.ts +3 -0
  149. package/dist/extensions/trackedChanges/review.d.ts +34 -0
  150. package/dist/extensions/trackedChanges/types.d.ts +72 -0
  151. package/dist/extensions/trackedChanges/utils.d.ts +20 -0
  152. package/dist/hooks/useMediaQuery.d.ts +2 -0
  153. package/dist/hooks/useRedlineHover.d.ts +17 -0
  154. package/dist/hooks/useRedlineReview.d.ts +83 -0
  155. package/dist/index.d.ts +46 -0
  156. package/dist/index.es.js +38491 -22189
  157. package/dist/index.umd.js +224 -125
  158. package/dist/utils/cdts.d.ts +37 -0
  159. package/dist/utils/groundingAdapter.d.ts +36 -0
  160. package/package.json +39 -33
@@ -0,0 +1,34 @@
1
+ import type { Attribute } from '@tiptap/core';
2
+ export interface RedlineBaseAttributes {
3
+ id: string;
4
+ userId: string;
5
+ userName: string;
6
+ timestamp: string;
7
+ }
8
+ export interface RedlineExtendedAttributes extends RedlineBaseAttributes {
9
+ formatChanges?: string;
10
+ linkData?: string;
11
+ }
12
+ export declare const createRedlineBaseAttributes: (includeExtendedFields?: boolean) => Record<string, Attribute>;
13
+ export declare const getRedlineInsertionPresentation: (htmlAttributes: Record<string, unknown>, baseClassName: string, regularColor: string) => {
14
+ title?: string | undefined;
15
+ style: string;
16
+ className: string;
17
+ };
18
+ export declare const createRedlineMarkCommands: <TAttributes>(markName: string) => {
19
+ setMarkCommand: (attributes: TAttributes) => ({ commands }: {
20
+ commands: {
21
+ setMark: (name: string, attrs: TAttributes) => boolean;
22
+ };
23
+ }) => boolean;
24
+ toggleMarkCommand: (attributes: TAttributes) => ({ commands }: {
25
+ commands: {
26
+ toggleMark: (name: string, attrs: TAttributes) => boolean;
27
+ };
28
+ }) => boolean;
29
+ unsetMarkCommand: () => ({ commands }: {
30
+ commands: {
31
+ unsetMark: (name: string) => boolean;
32
+ };
33
+ }) => boolean;
34
+ };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Redline session state (change-tracking.md M1/M2 — engine context).
3
+ *
4
+ * The tracking engine spans several cooperating ProseMirror plugins (keymap,
5
+ * input props, appendTransaction trackers) that must agree on batch identity
6
+ * within one synchronous editing gesture:
7
+ *
8
+ * - paste batch — one mark id per paste so text + dividers + images pasted
9
+ * together appear as a single panel card,
10
+ * - deletion batch — one mark id per Backspace/Delete gesture so dividers
11
+ * removed together with text share the text's card,
12
+ * - typing session — cross-block grouping (Docs model): typing + Enter +
13
+ * typing stays one card until the cursor navigates away,
14
+ * - pending list format — a list toggled on an EMPTY paragraph has no text
15
+ * range to mark yet; the intent is parked here and merged
16
+ * into the next insertion so the panel shows
17
+ * "Add List Item" instead of plain "Add".
18
+ *
19
+ * Batches are deliberately cleared on the next macrotask (setTimeout 0):
20
+ * every appendTransaction triggered by the same gesture runs synchronously,
21
+ * so "this tick" is exactly the batch boundary.
22
+ *
23
+ * Previously this state was spread across module-level singletons
24
+ * (redlineSharedMeta.ts) and factory closures; it is now one object owned by
25
+ * the Redline extension and passed explicitly to the engine functions.
26
+ */
27
+ export interface BatchState {
28
+ activeMarkId: string | null;
29
+ activeTimestamp: string | null;
30
+ }
31
+ export interface PendingListFormat {
32
+ listOld: string | null;
33
+ listNew: string | null;
34
+ userId: string | null;
35
+ userName: string | null;
36
+ mode: 'user' | 'ai' | null;
37
+ }
38
+ export declare class RedlineSession {
39
+ /** Shared mark identity for the current paste gesture. */
40
+ readonly pasteBatch: BatchState;
41
+ /** Shared mark identity for the current keyboard-deletion gesture. */
42
+ readonly deletionBatch: BatchState;
43
+ /** Cross-block typing session (cleared on pure cursor navigation). */
44
+ typingSessionMarkId: string | null;
45
+ typingSessionUserId: string | null;
46
+ /** List activation on an empty paragraph, awaiting the first insertion. */
47
+ readonly pendingListFormat: PendingListFormat;
48
+ private pasteTimeout;
49
+ /** Opens a paste batch for the current tick; auto-clears next macrotask. */
50
+ beginPasteBatch(markId: string, timestamp: string): void;
51
+ /** Opens a deletion batch for the current tick; auto-clears next macrotask. */
52
+ beginDeletionBatch(markId: string, timestamp: string): void;
53
+ setTypingSession(markId: string, userId: string): void;
54
+ /** Called by the view plugin on pure cursor navigation (selection moved,
55
+ * doc unchanged): ends the cross-block typing session and abandons any
56
+ * pending list format the user navigated away from. */
57
+ endTypingSession(): void;
58
+ setPendingListFormat(update: PendingListFormat): void;
59
+ clearPendingListFormat(): void;
60
+ }
61
+ /**
62
+ * The shared session instance.
63
+ *
64
+ * A single module-level instance (not per-extension) mirrors the legacy
65
+ * contract exactly: tracker plugins constructed in different factories must
66
+ * observe the same batch state within a gesture. The editor is a singleton
67
+ * per package consumer, so this is safe in practice; tests that need
68
+ * isolation can call `resetRedlineSession()`.
69
+ */
70
+ export declare const redlineSession: RedlineSession;
71
+ export declare const resetRedlineSession: () => void;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Shared types for the redline (track changes) system.
3
+ */
4
+ /** Entity performing the change (user or AI). */
5
+ export interface RedlineEntity {
6
+ id: string;
7
+ name: string;
8
+ }
9
+ export type RedlineMode = 'user' | 'ai';
10
+ /** Configuration options for the Redline extension. */
11
+ export interface RedlineOptions {
12
+ isActive: boolean;
13
+ mode: RedlineMode;
14
+ currentEntity: RedlineEntity;
15
+ }
16
+ /**
17
+ * Runtime tracking context resolved per keystroke/transaction: the live
18
+ * enabled/mode toggle plus the identity to attribute changes to.
19
+ */
20
+ export interface RedlineContext {
21
+ isActive: boolean;
22
+ mode: RedlineMode;
23
+ entity: RedlineEntity;
24
+ }
@@ -0,0 +1,64 @@
1
+ import { Extension } from '@tiptap/core';
2
+ import { type TrackedChangesShared } from './plugin';
3
+ import type { Suggestion, SuggestionEventHandler, SuggestionFilter, SuggestionUserMetadata, UntrackedOperationHandler } from './types';
4
+ export interface TrackedChangesOptions {
5
+ /** Start with suggest mode on. */
6
+ enabled: boolean;
7
+ /** Author attributed on new suggestions (M9 identity binding). */
8
+ userId: string;
9
+ /** Display metadata stored with every mark (name, color…). */
10
+ userMetadata: SuggestionUserMetadata;
11
+ /** Fired on suggestion create/update/accept/reject, local and remote (M4.3). */
12
+ onSuggestionEvent?: SuggestionEventHandler;
13
+ /** Fired with the full suggestion list whenever it changes (feeds the M7 store). */
14
+ onSuggestionsChange?: (suggestions: Suggestion[]) => void;
15
+ /** Fired when an operation is blocked or passes through untracked (5.3/5.8) — show a toast. */
16
+ onUntrackedOperation?: UntrackedOperationHandler;
17
+ }
18
+ export interface TrackedChangesStorage {
19
+ enabled: boolean;
20
+ userId: string;
21
+ userMetadata: SuggestionUserMetadata;
22
+ shared: TrackedChangesShared;
23
+ /** Query API over the plugin-state index (M4). */
24
+ getSuggestions: () => Suggestion[];
25
+ on: (handler: SuggestionEventHandler) => void;
26
+ off: (handler: SuggestionEventHandler) => void;
27
+ /** @internal */
28
+ handlers: Set<SuggestionEventHandler>;
29
+ }
30
+ declare module '@tiptap/core' {
31
+ interface Commands<ReturnType> {
32
+ trackedChanges: {
33
+ /** Turn suggest mode on (M4.4). */
34
+ enableSuggesting: () => ReturnType;
35
+ /** Turn suggest mode off. */
36
+ disableSuggesting: () => ReturnType;
37
+ toggleSuggesting: () => ReturnType;
38
+ /** Bind the identity attributed on new suggestions (M5: call on auth changes). */
39
+ setSuggestionUser: (user: {
40
+ userId: string;
41
+ userMetadata?: SuggestionUserMetadata;
42
+ }) => ReturnType;
43
+ /** Accept one suggestion by id ("acceptSuggestion" is taken by AI autocompletion). */
44
+ acceptTrackedChange: (id: string) => ReturnType;
45
+ /** Reject one suggestion by id. */
46
+ rejectTrackedChange: (id: string) => ReturnType;
47
+ /** Accept every suggestion, optionally filtered by user or ids (M3.5). */
48
+ acceptAllTrackedChanges: (filter?: SuggestionFilter) => ReturnType;
49
+ /** Reject every suggestion, optionally filtered by user or ids (M3.5). */
50
+ rejectAllTrackedChanges: (filter?: SuggestionFilter) => ReturnType;
51
+ /** Move the selection to a suggestion and scroll it into view. */
52
+ goToSuggestion: (id: string) => ReturnType;
53
+ };
54
+ }
55
+ }
56
+ /**
57
+ * Tracked Changes — our own suggest-mode extension (change-tracking.md v2).
58
+ *
59
+ * Packages M0 (schema marks), M1 (tracking engine), M2 (input behavior),
60
+ * M3 (review engine) and M4 (query/events/commands) as one Tiptap extension.
61
+ * Suggestions live entirely inside the document as marks, so Yjs sync and
62
+ * persistence handle replication and storage for free (D1).
63
+ */
64
+ export declare const TrackedChanges: Extension<TrackedChangesOptions, TrackedChangesStorage>;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Tracked Changes — shared constants (see change-tracking.md, M0/M1).
3
+ */
4
+ /** Mark names (M0.1). */
5
+ export declare const INSERTION_MARK_NAME = "insertion";
6
+ export declare const DELETION_MARK_NAME = "deletion";
7
+ export declare const MODIFICATION_MARK_NAME = "modification";
8
+ export declare const SUGGESTION_MARK_NAMES: readonly ["insertion", "deletion", "modification"];
9
+ /**
10
+ * Transaction meta key. Values:
11
+ * - 'track' — a transaction the engine rewrote (never re-process)
12
+ * - 'normalize' — merge/cleanup pass from appendTransaction
13
+ * - 'resolve' — an accept/reject transaction from the review engine
14
+ */
15
+ export declare const TRACKED_CHANGES_META = "trackedChanges$";
16
+ /** Current encoding version, stamped on every mark (M0, edge case 5.7). */
17
+ export declare const SUGGESTION_SCHEMA_VERSION = 1;
18
+ /** DOM data attributes emitted by renderHTML (M0.1). */
19
+ export declare const DATA_SUGGESTION_ID = "data-suggestion-id";
20
+ export declare const DATA_SUGGESTION_USER = "data-suggestion-user";
21
+ export declare const DATA_SUGGESTION_TYPE = "data-type";
22
+ export declare const DATA_SUGGESTION_CREATED_AT = "data-suggestion-created-at";
23
+ export declare const DATA_SUGGESTION_USER_METADATA = "data-suggestion-user-metadata";
24
+ export declare const DATA_SUGGESTION_SCHEMA_VERSION = "data-suggestion-schema-version";
25
+ /** Extra attributes for the `modification` mark (M0.1). */
26
+ export declare const DATA_MODIFICATION_MARK_NAME = "data-modification-mark-name";
27
+ export declare const DATA_MODIFICATION_ACTION = "data-modification-action";
28
+ export declare const DATA_MODIFICATION_PREVIOUS_ATTRS = "data-modification-previous-attrs";
29
+ export declare const DATA_MODIFICATION_NEW_ATTRS = "data-modification-new-attrs";
30
+ /** Metas of other plugins whose transactions must never be rewritten (M1.3). */
31
+ export declare const YJS_SYNC_META = "y-sync$";
32
+ export declare const YJS_UNDO_META = "y-undo$";
33
+ export declare const PM_HISTORY_META = "history$";
34
+ export declare const COMPOSITION_META = "composition";
@@ -0,0 +1,32 @@
1
+ import type { EditorState, Transaction } from '@tiptap/pm/state';
2
+ import type { SuggestionUserMetadata, UntrackedOperationHandler } from './types';
3
+ /**
4
+ * M1 — Tracking Engine.
5
+ *
6
+ * `rewriteTransaction` receives a would-be-dispatched local transaction and
7
+ * rebuilds it per the step-rewriting semantics table in change-tracking.md so
8
+ * that nothing is ever really deleted and everything added is attributed.
9
+ * It is a pure function over (state, tr) so it is unit-testable without a view.
10
+ */
11
+ export interface TrackContext {
12
+ userId: string;
13
+ userMetadata: SuggestionUserMetadata;
14
+ /** Timestamp stamped on new suggestion marks. */
15
+ now: number;
16
+ /** Which way the caret should walk after a rewritten deletion (M2.2). */
17
+ deleteDirection?: 'backward' | 'forward';
18
+ /** Notified when an operation is blocked or passed through untracked (5.3/5.8). */
19
+ onUntracked?: UntrackedOperationHandler;
20
+ }
21
+ /**
22
+ * M1.3 — exemption guards. Transactions that must pass through untouched:
23
+ * remote Yjs sync, undo/redo, history-excluded, our own rewrites, IME
24
+ * composition (rewriting mid-composition corrupts IME input — edge case 5.1).
25
+ */
26
+ export declare function isExemptTransaction(tr: Transaction, composing?: boolean): boolean;
27
+ /**
28
+ * Rebuild `tr` as a tracked transaction. Every step's coordinates are mapped
29
+ * from its own doc into the rebuilt transaction's doc via the inverted
30
+ * original mapping composed with our own mapping (M1.5).
31
+ */
32
+ export declare function rewriteTransaction(state: EditorState, tr: Transaction, ctx: TrackContext): Transaction;
@@ -0,0 +1,13 @@
1
+ export { TrackedChanges } from './TrackedChanges';
2
+ export type { TrackedChangesOptions, TrackedChangesStorage } from './TrackedChanges';
3
+ export { InsertionMark, DeletionMark, ModificationMark } from './marks';
4
+ export { findSuggestions } from './query';
5
+ export { resolveSuggestions } from './review';
6
+ export type { ResolveAction } from './review';
7
+ export { rewriteTransaction, isExemptTransaction } from './engine';
8
+ export type { TrackContext } from './engine';
9
+ export { trackedChangesPluginKey } from './plugin';
10
+ export type { TrackedChangesPluginState } from './plugin';
11
+ export * from './types';
12
+ export { INSERTION_MARK_NAME, DELETION_MARK_NAME, MODIFICATION_MARK_NAME, TRACKED_CHANGES_META, SUGGESTION_SCHEMA_VERSION, } from './constants';
13
+ export { suggestionColorForUser } from './utils';
@@ -0,0 +1,20 @@
1
+ import { Mark } from '@tiptap/core';
2
+ /**
3
+ * `insertion` — proposed new content (M0.1).
4
+ * `inclusive: true` so continued typing at the edge extends the author's own
5
+ * insertion (edge case 5.5); the engine re-attributes other users' typing.
6
+ */
7
+ export declare const InsertionMark: Mark<any, any>;
8
+ /**
9
+ * `deletion` — content proposed for removal; it stays in the document with a
10
+ * strikethrough (M0.1). `inclusive: false` so typing at the edge never silently
11
+ * extends someone's deletion (edge case 5.5).
12
+ */
13
+ export declare const DeletionMark: Mark<any, any>;
14
+ /**
15
+ * `modification` — a proposed formatting change (Tier 2, M0.1). The real
16
+ * formatting is *not* applied until accept; the mark records exactly what to
17
+ * apply (`markName`, `action`, `previousAttrs`, `newAttrs`).
18
+ * `excludes: ''` lets several pending format changes stack on the same text.
19
+ */
20
+ export declare const ModificationMark: Mark<any, any>;
@@ -0,0 +1,2 @@
1
+ import type { EditorState, Transaction } from '@tiptap/pm/state';
2
+ export declare function createNormalizeTransaction(state: EditorState): Transaction | null;
@@ -0,0 +1,32 @@
1
+ import { Plugin, PluginKey } from '@tiptap/pm/state';
2
+ import type { ResolveMeta } from './review';
3
+ import type { Suggestion, SuggestionEvent } from './types';
4
+ /**
5
+ * M2 (input behavior) + M4.2/M4.3 (plugin-state suggestion index + events),
6
+ * as one ProseMirror plugin owned by the TrackedChanges extension.
7
+ */
8
+ export interface TrackedChangesPluginState {
9
+ suggestions: Map<string, Suggestion>;
10
+ /** Present when the last transaction was an accept/reject (M3.7). */
11
+ lastResolve: ResolveMeta | null;
12
+ /** True when the last doc change arrived via Yjs sync. */
13
+ lastChangeWasRemote: boolean;
14
+ }
15
+ export interface TrackedChangesShared {
16
+ /** Set by handleKeyDown so the engine knows which way the caret walks (M2.2). */
17
+ deleteDirection: 'backward' | 'forward' | null;
18
+ /** Selection anchor recorded at compositionstart for IME reconciliation (M2.4). */
19
+ compositionStart: number | null;
20
+ }
21
+ export interface TrackedChangesPluginDeps {
22
+ isEnabled: () => boolean;
23
+ getUser: () => {
24
+ userId: string;
25
+ userMetadata: Record<string, unknown> | null;
26
+ };
27
+ emit: (event: SuggestionEvent) => void;
28
+ onSuggestionsChange?: (suggestions: Suggestion[]) => void;
29
+ shared: TrackedChangesShared;
30
+ }
31
+ export declare const trackedChangesPluginKey: PluginKey<TrackedChangesPluginState>;
32
+ export declare function createTrackedChangesPlugin(deps: TrackedChangesPluginDeps): Plugin;
@@ -0,0 +1,3 @@
1
+ import type { Node as PMNode } from '@tiptap/pm/model';
2
+ import type { Suggestion } from './types';
3
+ export declare function findSuggestions(doc: PMNode): Suggestion[];
@@ -0,0 +1,34 @@
1
+ import type { EditorState, Transaction } from '@tiptap/pm/state';
2
+ import type { SuggestionFilter } from './types';
3
+ /**
4
+ * M3 — Review Engine. Accept/reject as pure document transforms.
5
+ *
6
+ * Accept: insertion → unmark (content becomes real); deletion → really delete;
7
+ * modification → apply the recorded change, drop the mark.
8
+ * Reject: exact inverse — insertion → delete the content; deletion → unmark;
9
+ * modification → discard (the change was never applied, so the text
10
+ * already carries `previousAttrs`).
11
+ *
12
+ * Nested/stacked truth table (M3.4) falls out of op ordering below:
13
+ * - Reject an insertion carrying a stacked deletion → the content is deleted,
14
+ * so both vanish (the substrate is gone).
15
+ * - Accept an insertion carrying a stacked deletion → only the insertion mark
16
+ * is removed; the deletion suggestion survives on now-real content.
17
+ * - Accept a deletion stacked on someone's insertion → the content is deleted;
18
+ * the insertion suggestion is consumed with it.
19
+ */
20
+ export type ResolveAction = 'accept' | 'reject';
21
+ export interface ResolveMeta {
22
+ kind: 'resolve';
23
+ action: ResolveAction;
24
+ ids: string[];
25
+ }
26
+ export interface ResolveTarget extends SuggestionFilter {
27
+ all?: boolean;
28
+ }
29
+ /**
30
+ * Resolve every suggestion matched by `target` into the provided transaction
31
+ * (M3.5: bulk operations are one transaction — one undo step, one Yjs update).
32
+ * Returns false when nothing matched.
33
+ */
34
+ export declare function resolveSuggestions(state: EditorState, tr: Transaction, target: ResolveTarget, action: ResolveAction): boolean;
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Tracked Changes — public types (change-tracking.md M4).
3
+ */
4
+ /** Suggestion type surfaced by the query API (M4.1). */
5
+ export type SuggestionType = 'add' | 'delete' | 'replace' | 'markChange';
6
+ export type SuggestionMarkKind = 'insertion' | 'deletion' | 'modification';
7
+ /** Arbitrary per-user display metadata carried on every mark (name, color, avatar…). */
8
+ export type SuggestionUserMetadata = Record<string, unknown> | null;
9
+ /** Attributes shared by all three suggestion marks (M0.1). */
10
+ export interface SuggestionMarkAttrs {
11
+ id: string | null;
12
+ userId: string | null;
13
+ createdAt: number | null;
14
+ userMetadata: SuggestionUserMetadata;
15
+ schemaVersion: number;
16
+ }
17
+ /** Extra attributes carried by the `modification` mark (M0.1). */
18
+ export interface ModificationMarkAttrs extends SuggestionMarkAttrs {
19
+ /** The formatting mark this suggestion proposes to add/remove (e.g. 'bold', 'link'). */
20
+ markName: string | null;
21
+ action: 'add' | 'remove' | null;
22
+ /** Attrs of the pre-existing same-type mark (so reject/accept can restore an exact href). */
23
+ previousAttrs: Record<string, unknown> | null;
24
+ newAttrs: Record<string, unknown> | null;
25
+ }
26
+ /** One contiguous document range carrying a suggestion mark. */
27
+ export interface SuggestionRange {
28
+ from: number;
29
+ to: number;
30
+ markKind: SuggestionMarkKind;
31
+ }
32
+ /** A suggestion as returned by the query API (M4.1). */
33
+ export interface Suggestion {
34
+ id: string;
35
+ type: SuggestionType;
36
+ userId: string | null;
37
+ userMetadata: SuggestionUserMetadata;
38
+ createdAt: number | null;
39
+ ranges: SuggestionRange[];
40
+ /** Text excluding content contributed by *nested* suggestions of other users. */
41
+ text: string;
42
+ /** The literal text of every range. */
43
+ fullText: string;
44
+ /** Present for `markChange` suggestions. */
45
+ modification?: {
46
+ markName: string | null;
47
+ action: 'add' | 'remove' | null;
48
+ previousAttrs: Record<string, unknown> | null;
49
+ newAttrs: Record<string, unknown> | null;
50
+ };
51
+ }
52
+ /** Event names emitted on the tracked-changes emitter (M4.3). */
53
+ export type SuggestionEventName = 'suggestion:create' | 'suggestion:update' | 'suggestion:accept' | 'suggestion:reject';
54
+ export interface SuggestionEvent {
55
+ name: SuggestionEventName;
56
+ suggestion: Suggestion;
57
+ /** True when the change arrived via collaboration rather than local editing. */
58
+ remote: boolean;
59
+ }
60
+ export type SuggestionEventHandler = (event: SuggestionEvent) => void;
61
+ /**
62
+ * Operations the engine cannot represent yet (Tier 2/3).
63
+ * 'block-structure' — Enter / paragraph join / block paste, blocked in suggest mode (edge case 5.3).
64
+ * 'untracked-step' — wrap/unwrap, node attrs… passed through untracked with this notice (edge case 5.8).
65
+ */
66
+ export type UntrackedOperationKind = 'block-structure' | 'untracked-step';
67
+ export type UntrackedOperationHandler = (kind: UntrackedOperationKind, detail?: string) => void;
68
+ /** Filter accepted by bulk accept/reject commands (M3.5). */
69
+ export interface SuggestionFilter {
70
+ userId?: string;
71
+ ids?: string[];
72
+ }
@@ -0,0 +1,20 @@
1
+ import type { Mark, Node as PMNode } from '@tiptap/pm/model';
2
+ /**
3
+ * UUIDv4 suggestion ids (M0.5) — counters would collide across concurrent
4
+ * offline clients and Yjs would happily merge them into one corrupted suggestion.
5
+ */
6
+ export declare function createSuggestionId(): string;
7
+ export declare function isSuggestionMark(mark: Mark): boolean;
8
+ export declare function getInsertionMark(node: PMNode): Mark | undefined;
9
+ export declare function getDeletionMark(node: PMNode): Mark | undefined;
10
+ export declare function getModificationMarks(node: PMNode): Mark[];
11
+ /** Serialize an attrs object into a DOM data attribute. */
12
+ export declare function jsonAttrToDom(value: unknown): string | null;
13
+ /** Parse a DOM data attribute back into an attrs object. */
14
+ export declare function jsonAttrFromDom(value: string | null): Record<string, unknown> | null;
15
+ /**
16
+ * Deterministic per-user hue so mark colors match across clients without
17
+ * coordination. An explicit `userMetadata.color` always wins (M8: colors are
18
+ * derived from userId, matching awareness cursors).
19
+ */
20
+ export declare function suggestionColorForUser(userId: string | null, userMetadata: Record<string, unknown> | null): string;
@@ -0,0 +1,2 @@
1
+ /** Reactive window.matchMedia — used for the REQ-V1..V3 breakpoints. */
2
+ export declare const useMediaQuery: (query: string) => boolean;
@@ -0,0 +1,17 @@
1
+ import type { Editor } from '@tiptap/react';
2
+ export interface RedlineHoverState {
3
+ hoveredMarkId: string | null;
4
+ anchorRect: DOMRect | null;
5
+ cardHandlers: {
6
+ onMouseEnter: () => void;
7
+ onMouseLeave: () => void;
8
+ };
9
+ close: () => void;
10
+ }
11
+ /**
12
+ * Detects when the mouse hovers a redline mark (`<span data-redline-id="...">`)
13
+ * in the editor document and exposes the hovered markId plus its screen anchor
14
+ * rectangle. A short close-timer bridges the gap so the pointer can travel from
15
+ * the mark onto a floating card without the card closing.
16
+ */
17
+ export declare function useRedlineHover(editor: Editor | null | undefined): RedlineHoverState;
@@ -0,0 +1,83 @@
1
+ import type { ApplyRedlineParams } from "../config/EditorConfig";
2
+ import type { ReviewMeta } from "../components/redline/reviewItems";
3
+ import type { ReviewItem } from "../components/redline/AiReviewPanel";
4
+ import { type RedlineStreamApiConfig, type RulebookInsertionEventPayload, type SummaryPayload, type UncoveredEventPayload, type RuleFatiguePayload, type FindingEventPayload, type ScopeWarningPayload } from "../api/redlineStream";
5
+ export interface UseRedlineReviewOptions {
6
+ applyRedline: (params: ApplyRedlineParams) => void;
7
+ workspaceId?: string;
8
+ api?: RedlineStreamApiConfig;
9
+ }
10
+ export interface RunReviewOptions {
11
+ documentId: string;
12
+ regimes: string[];
13
+ markupMode?: string;
14
+ /** Suppress these rule ids for THIS run only — no playbook mutation. */
15
+ disabledRuleIds?: readonly string[];
16
+ /** Exclude these playbooks (every rule they carry) for THIS run only. */
17
+ disabledPlaybookIds?: readonly string[];
18
+ /** When non-empty, ONLY these rules run. Disabled wins on intersection. */
19
+ ruleIds?: readonly string[];
20
+ /**
21
+ * R1 prime linkage: the governing prime contract's id. The backend loads
22
+ * the prime's ACTIVE derived rulebook server-side.
23
+ */
24
+ primeContractId?: string;
25
+ }
26
+ export interface UseRedlineReviewResult {
27
+ run: (doc: Record<string, unknown>, opts: RunReviewOptions) => void;
28
+ cancel: () => void;
29
+ running: boolean;
30
+ meta: Record<string, ReviewMeta>;
31
+ findings: ReviewItem[];
32
+ progress: {
33
+ clausesStarted: number;
34
+ };
35
+ summary: SummaryPayload | null;
36
+ /**
37
+ * The stream delivered BOTH a `summary` frame and a `done` frame. Either one
38
+ * missing means the review was cut short — a summary on its own must never
39
+ * be presented as a finished review. A SUCCEEDED async-fallback job also
40
+ * sets this: its single terminal result has no truncation ambiguity.
41
+ */
42
+ completed: boolean;
43
+ /** The last run was cancelled by the caller — not a truncated review. */
44
+ cancelled: boolean;
45
+ error: string | null;
46
+ /** Clauses the playbook said nothing about; null when fully covered. */
47
+ coverage: UncoveredEventPayload | null;
48
+ /** Rules the reviewer keeps rejecting — drives the escalation nudge. */
49
+ ruleFatigue: RuleFatiguePayload;
50
+ /**
51
+ * Scope warnings (`scope_warning` events, e2e-verdict-fixes contract): the
52
+ * review's substantive scope collapsed — gov indicia without the gov
53
+ * regime, low coverage ratios, or an empty rulebook. Non-empty renders a
54
+ * non-dismissable banner; at most one entry per reason.
55
+ */
56
+ scopeWarnings: ScopeWarningPayload[];
57
+ /**
58
+ * A2: lanes the backend reported as degraded (summary.lanes_degraded).
59
+ * Non-empty ⇒ this was a partial review and the UI must say so.
60
+ */
61
+ degradedLanes: string[];
62
+ /** A2: at least one mid-stream `event: error` frame arrived. */
63
+ hadStreamErrors: boolean;
64
+ /**
65
+ * Gov-baseline flowdown lane (Flowdown tab): `rulebook` flags whose
66
+ * `rule_id` is `baseline:*`, and their sibling `rulebook_insertion`
67
+ * proposals (matched by `citation.rule_id`). Kept as raw payloads — the
68
+ * ReviewItem projection drops the rule-id join key the tab needs.
69
+ */
70
+ baselineFlags: FindingEventPayload[];
71
+ baselineInsertions: RulebookInsertionEventPayload[];
72
+ /**
73
+ * The SSE transport failed and this run's results came from the polling
74
+ * fallback (`POST /v1/redline/async`). Since backend `0d94b43` the async
75
+ * path persists through the same proposeSink as SSE
76
+ * (`asyncResultsArePersisted` in src/api/redlineJobs.ts), so fallback
77
+ * suggestions ride the NORMAL materializer — editor marks with working
78
+ * accept/reject — and this flag is informational: the UI may label the run
79
+ * as delivered without live streaming.
80
+ */
81
+ usedAsyncFallback: boolean;
82
+ }
83
+ export declare function useRedlineReview(options: UseRedlineReviewOptions): UseRedlineReviewResult;
package/dist/index.d.ts CHANGED
@@ -6,3 +6,49 @@ export { default as Editor } from "./components/Editor";
6
6
  export { EditorProvider } from "./providers/EditorProvider";
7
7
  export { useEditorProvider } from "./providers/EditorProviderContext";
8
8
  export type { EditorProviderConfig } from "./providers/EditorProviderContext";
9
+ export { PlaybookPanel } from "./components/playbook";
10
+ export type { PlaybookPanelProps, SaveAsRulePrefill } from "./components/playbook";
11
+ export { RulePerformancePanel } from "./components/playbook";
12
+ export type { RulePerformancePanelProps } from "./components/playbook";
13
+ export { CapturedEditsTray } from "./components/capturededits/CapturedEditsTray";
14
+ export type { CapturedEditsTrayProps } from "./components/capturededits/CapturedEditsTray";
15
+ export { CapturedEditsProvider, useCapturedEdits } from "./contexts/CapturedEditsContext";
16
+ export type { CapturedEdit } from "./contexts/CapturedEditsContext";
17
+ export { configurePlaybookApi } from "./api/playbook";
18
+ export type { PlaybookApiConfig, Playbook, Rule } from "./api/playbook";
19
+ export type { CdtsScope } from "./utils/cdts";
20
+ export { DerivedRulebookView, EffectiveRulesView } from "./components/playbook";
21
+ export type { DerivedRulebookViewProps, EffectiveRulesViewProps, } from "./components/playbook";
22
+ export { getEffectiveRules, getDerivedEnforcementMode, setDerivedEnforcementMode, } from "./api/effectiveRules";
23
+ export type { EffectiveRule, EffectiveRulebook, EffectiveRulesOptions, EnforcementMode, EnforcementModeRead, SupersededRule, } from "./api/effectiveRules";
24
+ export { useRedlineReview } from "./hooks/useRedlineReview";
25
+ export type { UseRedlineReviewOptions, UseRedlineReviewResult } from "./hooks/useRedlineReview";
26
+ export { configureRedlineStreamApi } from "./api/redlineStream";
27
+ export type { RedlineStreamApiConfig } from "./api/redlineStream";
28
+ export { PrimeUploadPanel, ApprovalPanel, CandidateRuleCard, ExecSummaryPanel, ReviewSummaryTab, GovConToggle, CounterpartyTypeSelector, ProvenanceBadge, ProvenanceBlock, ClassificationBadge, PositionsBlock, } from "./components/r1";
29
+ export type { PrimeUploadPanelProps, ApprovalPanelProps, CandidateRuleCardProps, ExecSummaryPanelProps, ReviewSummaryTabProps, GovConToggleProps, CounterpartyTypeSelectorProps, } from "./components/r1";
30
+ export { configureR1Api, resetR1Mock, r1Approver } from "./api/r1";
31
+ export type { R1ApiConfig, R1EvaluateExtras, CounterpartyType, DerivationJob, CandidateRule, CandidateClassification, RulebookStatus, ReviewSummary, R1Provenance, SuggestionPositions, } from "./api/r1";
32
+ export { WorkspaceRetentionPanel } from "./components/sidebar/WorkspaceRetentionPanel";
33
+ export type { WorkspaceRetentionPanelProps } from "./components/sidebar/WorkspaceRetentionPanel";
34
+ export { persistWorkspace } from "./api/workspace";
35
+ export type { WorkspacePersistResult, WorkspacePersistFailure, } from "./api/workspace";
36
+ export { RuleBuilderPanel } from "./components/rulebuilder";
37
+ export type { RuleBuilderPanelProps } from "./components/rulebuilder";
38
+ export { authorRuleFromText, authorRuleFromExamples, reviseRule, probeRuleAuthoring, } from "./api/ruleAuthoring";
39
+ export type { AuthoredRuleDraft, AuthorExample } from "./api/ruleAuthoring";
40
+ export { getPredicateCatalog, getFieldCatalog, getCdtsTaxonomy, evaluateAgainstPlaybook, ingestPlaybookDocument, } from "./api/ruleBuilder";
41
+ export type { BuilderRule, CapabilityStatus, EvaluateResult, FieldCatalogEntry, IngestResult, PredicateInfo, } from "./api/ruleBuilder";
42
+ export { DocumentVersionHistory } from "./components/documents";
43
+ export type { DocumentVersionHistoryProps } from "./components/documents";
44
+ export { configureDocumentVersionsApi } from "./api/documentVersions";
45
+ export type { DocumentVersionsApiConfig, DocumentCommit, DocumentAnnotation, DiffHunk, } from "./api/documentVersions";
46
+ export { RegSyncPanel, MethodologyPanel } from "./components/compliance";
47
+ export type { RegSyncPanelProps, MethodologyPanelProps } from "./components/compliance";
48
+ export { getRegSyncReport } from "./api/regsync";
49
+ export type { RegSyncReport, ClauseChange, ClauseSnapshot, AffectedRule } from "./api/regsync";
50
+ export { configureMethodologyApi, getMethodology } from "./api/methodology";
51
+ export type { MethodologyApiConfig, MethodologySection } from "./api/methodology";
52
+ export { listAllRules } from "./api/rulesCatalog";
53
+ export { configureRedlineJobsApi, submitAsyncReview, getRedlineJob, awaitRedlineJob, getRedlineRecord, asyncResultsArePersisted, } from "./api/redlineJobs";
54
+ export type { RedlineJobsApiConfig, RedlineJob, RedlineJobStatus, RedlineRecord, AsyncReviewRequest, } from "./api/redlineJobs";