@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
@@ -1,53 +1,40 @@
1
1
  import type { Editor } from "@tiptap/react";
2
2
  import { type TEditorMode } from "@/constants";
3
3
  import type { InsertTableUsingDataProps, TableColumn } from "@/types/extensions/Table";
4
- import type { PlaceholderFormat } from "@/constants/sidebar";
5
- import type { DetectionConfig as SidebarDetectionConfig } from "@/constants/sidebar";
6
- /** Single detection enable/disable (matches API response). */
7
- export interface PiiDetectionItem {
8
- id: string;
9
- enabled: boolean;
10
- }
11
- /** PII anonymization detection config (from parent / API). */
12
- export interface PiiDetectionConfig {
13
- /** List of detection types (Names, Emails, etc.). Defaults to DETECTION_CONFIGS when not provided. */
14
- detectionConfigs?: SidebarDetectionConfig[];
15
- /** Which detection configs are enabled (id + enabled). Matches API shape. */
16
- detections?: PiiDetectionItem[];
17
- placeholderFormat?: PlaceholderFormat;
18
- highlightChanges?: boolean;
19
- }
20
- /** One anonymization entry: the variable name + the original value it replaced. */
21
- export interface AnonymizedDataItem {
22
- anonymizedVariable: string;
23
- value: string;
24
- }
4
+ import type { CdtsScope } from "@/utils/cdts";
5
+ import type { ReviewResponseLike } from "@/utils/groundingAdapter";
6
+ import type { PlaybookApiConfig } from "@/api/playbook";
7
+ import type { ReviewItem } from "@/components/redline/AiReviewPanel";
8
+ import type { FlowdownFlagInput, FlowdownInsertionInput } from "@/components/flowdown/flowdownModel";
9
+ import type { ScopeWarningPayload } from "@/api/redlineStream";
10
+ import type { StreamSummaryCounters as ReviewSummaryCounters } from "@/components/r1/ReviewSummaryTab";
25
11
  /**
26
- * A single entity row in the `tags` map returned by the scan API.
27
- * Every key except `"count"` is a placeholder → original-value pair.
28
- * e.g. { "[PERSON_A_NAME]": "Elon Reeve Musk", "count": 1 }
12
+ * Host-implemented PII API over the backend proxy:
13
+ * anonymize POST /v1/pii/anonymize {document_id, doc}
14
+ * getTags → GET /v1/pii/tags/{document_id} (vault recovery)
15
+ *
16
+ * Errors must reject with `{status?, code?}` (e.g. api/pii.ts's PiiApiError)
17
+ * so the panel can map 409 pii_already_anonymized / 422 pii_redaction_error /
18
+ * 503 pii_unavailable / 404 route-absent.
29
19
  */
30
- export type ApiTagEntry = Record<string, string | number>;
20
+ export interface PiiAnonymizationApi {
21
+ anonymize(documentId: string, doc: Record<string, unknown>): Promise<{
22
+ doc: Record<string, unknown>;
23
+ tags: Record<string, string>;
24
+ entity_count: number;
25
+ }>;
26
+ getTags(documentId: string): Promise<{
27
+ tags: Record<string, string>;
28
+ }>;
29
+ }
31
30
  /**
32
- * Typed shape of the JSON returned by the scan API.
33
- * Pass this as the resolved value of `onScanDocument`.
31
+ * PII panel host config. Absent (or missing `api` / `documentId`) → the
32
+ * panel renders its "unavailable" state. No other fields — placeholder
33
+ * format is hardcoded server-side and per-entity selection is gone.
34
34
  */
35
- export interface ScanDocumentResult {
36
- document_id?: string;
37
- /**
38
- * Anonymised TipTap JSON (uses `"anonymizedText"` inline nodes and
39
- * sometimes `"Text"` (capital-T) for plain text). Pass through
40
- * {@link normalizeAnonymizationApiResponse} before calling `setContent`.
41
- */
42
- json_content?: Record<string, unknown>;
43
- /**
44
- * Detected entities grouped by category.
45
- * `Record<categoryLabel, entity[]>` – e.g. `{ "Person": [...], "Date": [...] }`
46
- */
47
- tags?: Record<string, ApiTagEntry[]>;
48
- placeholder_format?: string;
49
- highlight_changes?: boolean;
50
- isAnalyzed?: boolean;
35
+ export interface PiiAnonymizationConfig {
36
+ documentId: string;
37
+ api: PiiAnonymizationApi;
51
38
  }
52
39
  /**
53
40
  * Convert the raw `json_content` returned by the scan API into a shape that
@@ -63,15 +50,7 @@ export interface ScanDocumentResult {
63
50
  * rewritten to the standard `link` mark (using the original URL stored in
64
51
  * `anonymizedData[0].value`) so it behaves identically to a default link.
65
52
  */
66
- export declare function normalizeAnonymizationApiResponse(jsonContent: Record<string, unknown>, placeholderFormat?: string): Record<string, unknown>;
67
- /** Payload for Save Changes (PII anonymization settings). Passed to onSaveAnonymizationSettings. */
68
- export interface AnonymizationSavePayload {
69
- document_id: string;
70
- tags: string[];
71
- placeholder_format: PlaceholderFormat;
72
- highlight_changes: boolean;
73
- json_content: Record<string, unknown>;
74
- }
53
+ export declare function normalizeAnonymizationApiResponse(jsonContent: Record<string, unknown>, placeholderFormat?: string, highlightChanges?: boolean): Record<string, unknown>;
75
54
  export interface AIAutocompletionConfig {
76
55
  /** Enable/disable AI autocompletion */
77
56
  enabled?: boolean;
@@ -82,8 +61,6 @@ export interface AIAutocompletionConfig {
82
61
  /** Required: Custom fetch function for API calls. AI autocompletion only works when this is provided. */
83
62
  fetchCompletion?: (text: string) => Promise<string>;
84
63
  }
85
- /** Pass scan/API JSON or an HTML string into the editor (used with {@link EditorConfig.onScanComplete}). */
86
- export type ApplyScanCompleteContent = (editorContent: string | Record<string, unknown>) => void;
87
64
  export type ScreenshotMimeType = 'image/png' | 'image/jpeg';
88
65
  /**
89
66
  * Screenshot options accepted by both config-driven and imperative capture APIs.
@@ -96,6 +73,65 @@ export interface ScreenshotCaptureOptions {
96
73
  /** JPEG quality from 0..1. Used only when `mimeType` is `image/jpeg`. Defaults to `0.92`. */
97
74
  quality?: number;
98
75
  }
76
+ /**
77
+ * Target for {@link ApplyRedlineParams}. Either an absolute PM position range
78
+ * ({@link from}/{@link to}) for text-range redlines, or a `nodePath` (root → …
79
+ * → child index) resolved to the node's inner text range. The live backend
80
+ * stream emits single-level paths (e.g. `[302]`); nested paths are best-effort.
81
+ */
82
+ export type RedlineTarget = {
83
+ from: number;
84
+ to: number;
85
+ } | {
86
+ nodePath: number[];
87
+ };
88
+ /**
89
+ * Imperative redline injection (FE_requests.md ask A / gap G). Applies AI
90
+ * redlines using the editor's NATIVE representations — `aiInsertion` /
91
+ * `aiDeletion` marks for text ranges, existing redline node-attrs for
92
+ * structural nodes. Transacts through `@tiptap/extension-collaboration` so the
93
+ * change replicates over Yjs. Grounding does NOT ride here — it travels on the
94
+ * Channel-2 `grounding[]` sidecar (see `groundingAdapter`).
95
+ */
96
+ export interface ApplyRedlineParams {
97
+ target: RedlineTarget;
98
+ kind: 'insert' | 'delete' | 'replace' | 'attr-change';
99
+ /** insert / replace: the proposed text carrying the aiInsertion mark. */
100
+ proposedText?: string;
101
+ /** attr-change / replace on structural nodes: prior attrs, for restore. */
102
+ previousAttrs?: Record<string, unknown>;
103
+ author: {
104
+ id: string;
105
+ name: string;
106
+ };
107
+ /** ISO-8601 → mark/attr timestamp. */
108
+ timestamp: string;
109
+ /** Shared id for multi-range / multi-node group accept-reject. */
110
+ groupId?: string;
111
+ /**
112
+ * Exact source text the redline concerns, used to narrow a `nodePath` target
113
+ * from the whole block down to that phrase. This is the backend's
114
+ * `citation.verbatim_excerpt`. Without it a `replace` addressed by nodePath
115
+ * strikes the entire block. Ignored when the target is already a range, and
116
+ * ignored when the text can't be found in the node.
117
+ */
118
+ matchText?: string;
119
+ }
120
+ /**
121
+ * Fired from the accept/reject path (FE_requests.md ask F / gap G) so the host
122
+ * can forward the decision to the audit loop. No HTTP inside the package.
123
+ */
124
+ export interface RedlineDecision {
125
+ /** The redline change that was decided on (editor-internal change shape). */
126
+ change: unknown;
127
+ decision: 'accepted' | 'rejected';
128
+ actor: {
129
+ id: string;
130
+ name: string;
131
+ };
132
+ /** ISO-8601 timestamp of the decision. */
133
+ timestamp: string;
134
+ }
99
135
  /**
100
136
  * Declarative screenshot request configuration.
101
137
  *
@@ -170,6 +206,107 @@ export interface EditorConfig {
170
206
  documentURL?: string;
171
207
  onExternalUserInvite?: (emails: string[], permission: 'view' | 'suggest') => void;
172
208
  };
209
+ /** Playbook & redlines side-panel configuration. Feeds the rail's Playbook
210
+ * panel the document's CDTS scope, the latest review response (the
211
+ * grounding[] sidecar from a redline run), and the playbook API config.
212
+ * When omitted, the panel still mounts with an empty scope. */
213
+ playbookConfig?: {
214
+ documentScope?: CdtsScope;
215
+ documentId?: string;
216
+ workspaceId?: string;
217
+ workspaceName?: string;
218
+ regimeLabels?: string[];
219
+ reviewResponse?: ReviewResponseLike | null;
220
+ api?: PlaybookApiConfig;
221
+ };
222
+ /** AI review side-rail (redesigned redline panel). When enabled, replaces the
223
+ * gutter redline cards with a fixed right-rail list of review cards
224
+ * (severity + category + rationale + playbook ref + diff + accept/reject),
225
+ * and clicking a card scrolls the document to that redline. `meta` supplies
226
+ * grounding per change (keyed by the mark's groupId / backend suggestion id). */
227
+ aiReviewPanel?: {
228
+ enabled?: boolean;
229
+ playbookName?: string;
230
+ meta?: Record<string, {
231
+ category?: 'legal' | 'operational' | 'financial' | 'grammar' | 'policy';
232
+ severity?: 'high' | 'medium' | 'low';
233
+ title?: string;
234
+ rationale?: string;
235
+ playbookRef?: string;
236
+ clause?: string;
237
+ }>;
238
+ /** Advisory findings (grammar/rulebook/irregularity lanes from the redline
239
+ * stream) — rendered below the main review list with no decision bar. */
240
+ findings?: ReviewItem[];
241
+ /** Optional "Run AI Redline" action rendered in the panel header. When
242
+ * omitted, no run button appears. `running` disables it and shows a
243
+ * progress label while a review is in flight. */
244
+ onRun?: () => void;
245
+ running?: boolean;
246
+ /**
247
+ * A2: lanes the backend reported degraded (summary.lanes_degraded). Any
248
+ * entry renders a prominent partial-review banner (dismissable only by
249
+ * acknowledging it) and a "Partial" marker in the panel header.
250
+ */
251
+ degradedLanes?: string[];
252
+ /** A2: mid-stream `event: error` frames arrived — also marks the review partial. */
253
+ hadStreamErrors?: boolean;
254
+ /**
255
+ * Scope warnings from the review stream (`scope_warning` events /
256
+ * summary.scope_warnings): the review's substantive scope collapsed.
257
+ * Any entry renders a prominent, non-dismissable banner in the panel.
258
+ */
259
+ scopeWarnings?: ScopeWarningPayload[];
260
+ /**
261
+ * C1: regime selector rendered above the run button. `selected` should
262
+ * default to every regime applicable to the document's scope; `onChange`
263
+ * feeds the next run's `regimes`.
264
+ */
265
+ regimeSelector?: {
266
+ available: string[];
267
+ selected: string[];
268
+ onChange: (next: string[]) => void;
269
+ };
270
+ /**
271
+ * "Ignore this rule" was used. `family` is the suppression key (the rule id
272
+ * with its per-finding hash stripped) — pass it in the next run's
273
+ * `disabled_rule_ids` to stop the rule firing at the source. `dismissedIds`
274
+ * are the cards dismissed right now. Without a handler the dismissal is
275
+ * session-only and the rule returns on the next run.
276
+ */
277
+ onIgnoreRule?: (family: string, dismissedIds: string[]) => void;
278
+ /**
279
+ * Flowdown determination tab (gov-baseline lane). When set, the AI review
280
+ * panel grows a "Flowdown" tab listing the review's `baseline:gov:*`
281
+ * rulebook flags paired with their sibling insertions, with per-rule
282
+ * Accept / Not-applicable determinations (PATCH /api/redlines
283
+ * dispositions). `documentId` enables re-hydration; `actorName` feeds the
284
+ * X-Actor header (localStorage `lax.flowdownActor` overrides, default
285
+ * "reviewer").
286
+ */
287
+ flowdown?: {
288
+ flags: FlowdownFlagInput[];
289
+ insertions: FlowdownInsertionInput[];
290
+ documentId?: string;
291
+ actorName?: string;
292
+ };
293
+ /**
294
+ * Executive-summary tab. When set, the AI review panel grows a "Summary"
295
+ * tab showing the run's provenance / severity / flowdown / escalation
296
+ * counts. `payload` is the stream's `summary` frame (the counters the
297
+ * panel derives from — no extra request); `complete` must be true ONLY
298
+ * when both `summary` and `done` arrived, otherwise the tab says the
299
+ * review did not complete instead of presenting partial counts as final.
300
+ * `reviewId` is re-hydration only: a completed review whose stream this
301
+ * session never saw, fetched via GET /v1/reviews/{id}/summary.
302
+ */
303
+ reviewSummary?: {
304
+ payload?: ReviewSummaryCounters | null;
305
+ complete?: boolean;
306
+ cancelled?: boolean;
307
+ reviewId?: string | null;
308
+ };
309
+ };
173
310
  /** Callback when content changes */
174
311
  onContentChange?: (editor: Editor) => void;
175
312
  /** Callback when editor is ready with helper methods */
@@ -190,7 +327,11 @@ export interface EditorConfig {
190
327
  }) => void;
191
328
  updateTableValues: () => void;
192
329
  captureScreenshot: (options?: ScreenshotCaptureOptions) => Promise<File>;
330
+ /** Inject an AI redline. See {@link ApplyRedlineParams}. */
331
+ applyRedline: (params: ApplyRedlineParams) => void;
193
332
  }) => void;
333
+ /** Fired when a redline is accepted or rejected. See {@link RedlineDecision}. */
334
+ onRedlineDecision?: (decision: RedlineDecision) => void;
194
335
  /**
195
336
  * Screenshot capture configuration.
196
337
  *
@@ -200,25 +341,8 @@ export interface EditorConfig {
200
341
  screenshot?: ScreenshotConfig;
201
342
  /** Parent container id for redline positioning */
202
343
  parentContainerId?: string;
203
- /** PII Anonymization configuration */
204
- piiAnonymization?: {
205
- settings?: PiiDetectionConfig;
206
- onSaveAnonymizationSettings?: (payload: AnonymizationSavePayload) => void;
207
- onScanDocument?: (json: Record<string, unknown>) => Promise<ScanDocumentResult | void>;
208
- /**
209
- * Called once when the editor is ready. You receive {@link ApplyScanCompleteContent};
210
- * call it after a scan/API returns to load new document JSON (normalized for anonymization) or HTML.
211
- */
212
- onScanComplete?: (applyScanCompleteContent: ApplyScanCompleteContent) => void;
213
- onCancelScan?: () => void;
214
- onRevertAnonymization?: () => void;
215
- onAnonymizeDocument?: () => void;
216
- isAnonymized?: boolean;
217
- isScanningDocument?: boolean;
218
- isAnalyzed?: boolean;
219
- isTagsLoading?: boolean;
220
- isRevertingAnonymization?: boolean;
221
- };
344
+ /** PII Anonymization configuration (see {@link PiiAnonymizationConfig}). */
345
+ piiAnonymization?: PiiAnonymizationConfig;
222
346
  /**
223
347
  * Called when the user chooses "Insert row from agreement" in the table
224
348
  * bubble menu. Receive the current row index (0-based, after the header)
@@ -18,6 +18,18 @@ export declare const PAGE_BREAK_LINE_CLASS_NAME = "editor-page-break-line";
18
18
  export declare const VARIABLE_TEXT_DATA_VARIABLE_NAME = "data-variable-name";
19
19
  export declare const VARIABLE_TEXT_DATA_VALUE = "data-value";
20
20
  export declare const VARIABLE_TEXT_CLASS_NAME = "variable-text";
21
+ export declare const VARIABLE_TEXT_DATA_IS_PII = "data-pii";
22
+ export declare const VARIABLE_TEXT_DATA_PII_CATEGORY = "data-pii-category";
23
+ export declare const VARIABLE_TEXT_DATA_PII_PLACEHOLDER = "data-pii-placeholder";
24
+ export declare const VARIABLE_TEXT_DATA_PII_SHOW_VALUE = "data-pii-show-value";
25
+ export declare const VARIABLE_TEXT_DATA_PII_HIGHLIGHT = "data-pii-highlight";
26
+ export declare const VARIABLE_TEXT_DATA_PII_FORMAT = "data-pii-format";
27
+ /**
28
+ * Also worn by a `variableText` node while its PII is masked, so a masked
29
+ * variable renders as a plain anonymized chip instead of keeping the boxed
30
+ * `.variable-text` look.
31
+ */
32
+ export declare const ANONYMIZED_TEXT_CLASS_NAME = "anonymized-text";
21
33
  export declare const VARIABLE_TABLE_TYPE = "data-table-type";
22
34
  export declare const VARIABLE_TABLE_ID = "data-table-id";
23
35
  export declare const VARIABLE_TABLE_NAME = "data-table-name";
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Playbook category / hue mappings — DESIGN-REQUIREMENTS.md REQ-T5 + REQ-T6.
3
+ *
4
+ * ONE file owns both tables:
5
+ * 1. V6 backend category → display category → hue (REQ-T5)
6
+ * 2. CDTS top-level category → playbook icon-tile hue (REQ-T6)
7
+ *
8
+ * Hues are Tailwind classes backed by the CSS variables in
9
+ * src/styles/tokens.css — never hardcode hexes in components, and never
10
+ * rotate hues decoratively (color always encodes meaning).
11
+ */
12
+ /** V6 backend categories (lax-ai-legal-editor internal/redlining/v6). */
13
+ export type V6Category = "legal" | "financial" | "grammar" | "ops" | "policy";
14
+ export declare const V6_CATEGORIES: readonly V6Category[];
15
+ /** The five display categories (fig accent families). */
16
+ export type DisplayCategory = "Language" | "Consistency & Clarity" | "Legal Terms" | "Compliance" | "Commercial Accuracy";
17
+ export declare const DISPLAY_CATEGORIES: readonly DisplayCategory[];
18
+ /** V6 category → display category (REQ-T5; the single mapping table). */
19
+ export declare const V6_TO_DISPLAY_CATEGORY: Record<V6Category, DisplayCategory>;
20
+ /** Reverse map (modal category chip-select → V6 write payloads). */
21
+ export declare const DISPLAY_TO_V6_CATEGORY: Record<DisplayCategory, V6Category>;
22
+ export interface CategoryHue {
23
+ /** Category dot / mark fill (family mid). */
24
+ dotClass: string;
25
+ /** Tinted chip background (fig 50s / dark alphas). */
26
+ tintClass: string;
27
+ /** Chip text (fig family 600s per REQ-T11). */
28
+ textClass: string;
29
+ /**
30
+ * Caption-size (<14px) text token. Differs from textClass only for
31
+ * Legal Terms: teal-600 fails the small-text floor on white (REQ-T11
32
+ * caveat), so captions use the darker --cat-legal-caption.
33
+ */
34
+ captionClass: string;
35
+ }
36
+ /** Display category → hue classes (REQ-T5: one hue = one meaning). */
37
+ export declare const CATEGORY_HUES: Record<DisplayCategory, CategoryHue>;
38
+ /** Hue lookup tolerant of unknown/extra backend categories. */
39
+ export declare const hueForV6Category: (category: string) => CategoryHue;
40
+ export declare const displayCategoryForV6: (category: string) => DisplayCategory;
41
+ export type CdtsTopLevel = "Gov" | "Legal" | "Financial" | "Ops";
42
+ export interface CdtsHue {
43
+ tileClass: string;
44
+ tintClass: string;
45
+ textClass: string;
46
+ }
47
+ export declare const CDTS_TOP_LEVEL_HUES: Record<CdtsTopLevel, CdtsHue>;
48
+ /** Case-insensitive lookup; unknown top-levels fall back to neutral Ops. */
49
+ export declare const cdtsHueForCategory: (topLevel: string | undefined) => CdtsHue;
50
+ export type V6Severity = "critical" | "high" | "medium" | "low";
51
+ export type NegotiationTier = 1 | 2 | 3;
52
+ /**
53
+ * V6 (category, severity) → tier. Mirrors the backend judgment table:
54
+ * critical → T1; high → T1 for legal/financial else T2; medium → T2; low → T3.
55
+ */
56
+ export declare const tierFor: (category: string, severity: string) => NegotiationTier;
57
+ /** Modal segmented control → default severity for write payloads. */
58
+ export declare const TIER_TO_SEVERITY: Record<NegotiationTier, V6Severity>;
59
+ /**
60
+ * Write mapping for the 3-way tier control. Four severities flow through three
61
+ * tiers, so the mapping is deliberately NOT a bijection:
62
+ * - If the selected tier equals the tier the rule's CURRENT severity already
63
+ * maps to (per tierFor), the stored severity is preserved verbatim — editing
64
+ * a rule without touching the tier control never rewrites its severity
65
+ * (this is what makes "high" survive a round-trip).
66
+ * - If the user actively changes the tier, the canonical severity for that
67
+ * tier is written: 1→critical, 2→medium, 3→low.
68
+ * "high" is therefore never destroyed here, and is *set* via the Rule
69
+ * Performance screen's Escalate action (one rung on the 4-value ladder), not
70
+ * via this control.
71
+ */
72
+ export declare const severityForTier: (tier: NegotiationTier, category: V6Category, current?: V6Severity) => V6Severity;
73
+ /** 4-value severity ladder, ascending. Escalate = +1 rung, demote = −1 rung. */
74
+ export declare const SEVERITY_LADDER: readonly V6Severity[];
75
+ export interface TierMeta {
76
+ chip: string;
77
+ label: string;
78
+ chipTextClass: string;
79
+ chipBgClass: string;
80
+ /**
81
+ * Negotiation-posture verb for the tier. Present on TIER_META (every tier
82
+ * has a posture); absent on SEVERITY_META (severity alone doesn't pick one —
83
+ * high is "walk away" for legal/financial, "negotiate" elsewhere).
84
+ */
85
+ action?: "Walk away" | "Negotiate" | "Style";
86
+ }
87
+ /** Rule-list filter: all, one negotiation tier, or "fired in this document". */
88
+ export type RuleFilter = "all" | "t1" | "t2" | "t3" | "fired";
89
+ /** Playbook-list filter: all, on this doc's chain, editable, or bundled. */
90
+ export type PlaybookFilter = "all" | "active" | "workspace" | "bundled";
91
+ /**
92
+ * REQ-R1 tier chips: tinted bg, no border — T1 red-pink, T2 amber, T3 gray.
93
+ *
94
+ * `chip` speaks the ONE severity vocabulary (the wire's critical/high/medium/
95
+ * low ladder), using each tier's canonical severity per TIER_TO_SEVERITY. The
96
+ * underlying model is still a 1/2/3 negotiation tier (`NegotiationTier`,
97
+ * `tierFor`) and the `sev-t1/t2/t3` tokens keep their names. This and
98
+ * SEVERITY_META are the ONLY places these words are defined; render
99
+ * `TIER_META[tier].chip` / `SEVERITY_META[sev].chip` rather than hardcoding.
100
+ */
101
+ export declare const TIER_META: Record<NegotiationTier, Required<TierMeta>>;
102
+ /**
103
+ * The canonical severity vocabulary: the backend wire's 4-value ladder
104
+ * rendered onto the 3-tier chip tokens (critical and high share the T1 red —
105
+ * the rail stays 3 colors per REQ-R1). Review cards, playbook rule rows and
106
+ * flowdown chips all render from this table; no other severity words exist.
107
+ */
108
+ export declare const SEVERITY_META: Record<V6Severity, TierMeta>;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * CapturedEditsContext — the in-memory store behind the Captured Edits tray.
3
+ *
4
+ * EPHEMERAL BY DESIGN: no localStorage, no server write, nothing survives the
5
+ * provider (plan: "Not doing … captured-edit persistence"). The tray states
6
+ * this in its permanent caption.
7
+ *
8
+ * Coalescing contract: `capture` upserts by `clauseKey` — repeat edits to one
9
+ * clause are ONE card; `before` is frozen at first capture; `after`,
10
+ * `editCount` and `lastEditedAt` update on every subsequent capture.
11
+ */
12
+ import { type ReactNode } from "react";
13
+ import { type CapturedEditEvent } from "@/extensions/plugins/CapturedEditsPlugin";
14
+ export interface CapturedEdit {
15
+ /** Coalescing key: one card per clause. */
16
+ clauseKey: string;
17
+ /** Lawyer-readable context: nearest heading text + section ref when derivable. */
18
+ clauseLabel: string;
19
+ /** Clause text as of document open (the plugin's baseline). */
20
+ before: string;
21
+ /** Current clause text after the human's latest edit. */
22
+ after: string;
23
+ firstCapturedAt: number;
24
+ lastEditedAt: number;
25
+ /** How many distinct capture events coalesced into this card. */
26
+ editCount: number;
27
+ /** UI-only: set after a rule is persisted from this card. */
28
+ addedRuleId?: string;
29
+ }
30
+ export type CapturedEditsAction = {
31
+ type: "capture";
32
+ edit: CapturedEditEvent;
33
+ at: number;
34
+ } | {
35
+ type: "markAdded";
36
+ clauseKey: string;
37
+ ruleId: string;
38
+ } | {
39
+ type: "dismiss";
40
+ clauseKey: string;
41
+ } | {
42
+ type: "clear";
43
+ };
44
+ /** Pure so the coalescing rules are unit-testable. */
45
+ export declare const capturedEditsReducer: (state: CapturedEdit[], action: CapturedEditsAction) => CapturedEdit[];
46
+ export interface CapturedEditsContextType {
47
+ edits: CapturedEdit[];
48
+ capture: (edit: CapturedEditEvent) => void;
49
+ markAdded: (clauseKey: string, ruleId: string) => void;
50
+ dismiss: (clauseKey: string) => void;
51
+ clear: () => void;
52
+ }
53
+ export declare const CapturedEditsProvider: ({ children }: {
54
+ children: ReactNode;
55
+ }) => import("react/jsx-runtime").JSX.Element;
56
+ export declare const useCapturedEdits: () => CapturedEditsContextType;
@@ -1,11 +1,14 @@
1
1
  import type { ReactNode } from "react";
2
2
  import type { Editor } from "@tiptap/react";
3
- import type { EditorConfig, ScreenshotCaptureOptions } from "@/config/EditorConfig";
3
+ import type { ApplyRedlineParams, EditorConfig, ScreenshotCaptureOptions } from "@/config/EditorConfig";
4
4
  export interface EditorShellContextType {
5
5
  editor: Editor;
6
6
  editorConfig: EditorConfig;
7
7
  redlineItemWidth: number;
8
8
  setRedlineItemWidth: (width: number) => void;
9
+ /** Inject an AI redline (same method handed to onEditorReady) — lets shell
10
+ * surfaces (e.g. the Flowdown tab) reuse the one apply path. */
11
+ applyRedline: (params: ApplyRedlineParams) => void;
9
12
  }
10
13
  interface EditorShellProviderProps {
11
14
  children: ReactNode;