@lax-wp/editor 0.3.16 → 0.3.18
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/components/sidebar/content/anonymization-page/PIIScanResults.d.ts +2 -4
- package/dist/components/sidebar/content/anonymization-page/anonymizationUtils.d.ts +11 -0
- package/dist/config/EditorConfig.d.ts +10 -2
- package/dist/extensions/AnonymizedLink.d.ts +62 -0
- package/dist/extensions/index.d.ts +1 -1
- package/dist/index.es.js +6252 -6030
- package/dist/index.umd.js +61 -61
- package/package.json +1 -1
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { type DetectionConfig } from "@/constants/sidebar";
|
|
2
|
-
import { type ScanDocumentResult } from "@/config/EditorConfig";
|
|
3
2
|
export interface PIIScanResultsProps {
|
|
4
3
|
detectionConfigs: DetectionConfig[];
|
|
5
|
-
scanResult?: ScanDocumentResult;
|
|
6
4
|
onClose?: () => void;
|
|
7
5
|
onSettings?: () => void;
|
|
8
|
-
onApply?: (selectedReplacements: string[]) => void;
|
|
6
|
+
onApply?: (selectedReplacements: string[], unselectedReplacements: string[]) => void;
|
|
9
7
|
onRevealStart?: () => void;
|
|
10
8
|
onRevealEnd?: () => void;
|
|
11
9
|
onRevertAnonymization?: () => void;
|
|
12
10
|
}
|
|
13
|
-
export declare const PIIScanResults: ({ detectionConfigs,
|
|
11
|
+
export declare const PIIScanResults: ({ detectionConfigs, onClose, onApply, onRevertAnonymization }: PIIScanResultsProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { Editor } from "@tiptap/react";
|
|
2
2
|
import type { ApiTagEntry } from "@/config/EditorConfig";
|
|
3
3
|
export declare function setShowValue(editor: Editor, showValue: boolean, filter?: Set<string>): void;
|
|
4
|
+
/**
|
|
5
|
+
* Replace `anonymizedLink` marks in the document with the editor's default
|
|
6
|
+
* `link` mark. The restored `href` is the original URL stored in
|
|
7
|
+
* `anonymizedData[0].value` (falling back to the mark's `href` attr if the
|
|
8
|
+
* value is missing). `target` / `rel` / `class` are carried over so the
|
|
9
|
+
* resulting link preserves its formatting while PII metadata is dropped.
|
|
10
|
+
*
|
|
11
|
+
* If `filter` is provided, only marks whose `anonymizedVariable` is in the
|
|
12
|
+
* set are reverted. No-op if either mark type is missing from the schema.
|
|
13
|
+
*/
|
|
14
|
+
export declare function revertAnonymizedLinksToLinks(editor: Editor, filter?: Set<string>): void;
|
|
4
15
|
export declare function revertToPlainText(editor: Editor, filter?: Set<string>): void;
|
|
5
16
|
export declare function buildTagsFromEditor(editor: Editor): Record<string, ApiTagEntry[]>;
|
|
6
17
|
export type AnonymizedVariableRevealState = 'placeholder' | 'revealed';
|
|
@@ -59,6 +59,9 @@ export interface ScanDocumentResult {
|
|
|
59
59
|
* - For `placeholderFormat === "descriptive"`, strips the `[` / `]` brackets
|
|
60
60
|
* from placeholder tokens so the chip shows e.g. `PERSON_A_NAME` not
|
|
61
61
|
* `[PERSON_A_NAME]`.
|
|
62
|
+
* - Normalises `anonymizedLink` marks: when `showValue: true`, the mark is
|
|
63
|
+
* rewritten to the standard `link` mark (using the original URL stored in
|
|
64
|
+
* `anonymizedData[0].value`) so it behaves identically to a default link.
|
|
62
65
|
*/
|
|
63
66
|
export declare function normalizeAnonymizationApiResponse(jsonContent: Record<string, unknown>, placeholderFormat?: string): Record<string, unknown>;
|
|
64
67
|
/** Payload for Save Changes (PII anonymization settings). Passed to onSaveAnonymizationSettings. */
|
|
@@ -79,6 +82,8 @@ export interface AIAutocompletionConfig {
|
|
|
79
82
|
/** Required: Custom fetch function for API calls. AI autocompletion only works when this is provided. */
|
|
80
83
|
fetchCompletion?: (text: string) => Promise<string>;
|
|
81
84
|
}
|
|
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;
|
|
82
87
|
export interface EditorConfig {
|
|
83
88
|
/** Editor mode */
|
|
84
89
|
mode?: TEditorMode;
|
|
@@ -159,8 +164,11 @@ export interface EditorConfig {
|
|
|
159
164
|
settings?: PiiDetectionConfig;
|
|
160
165
|
onSaveAnonymizationSettings?: (payload: AnonymizationSavePayload) => void;
|
|
161
166
|
onScanDocument?: (json: Record<string, unknown>) => Promise<ScanDocumentResult | void>;
|
|
162
|
-
|
|
163
|
-
|
|
167
|
+
/**
|
|
168
|
+
* Called once when the editor is ready. You receive {@link ApplyScanCompleteContent};
|
|
169
|
+
* call it after a scan/API returns to load new document JSON (normalized for anonymization) or HTML.
|
|
170
|
+
*/
|
|
171
|
+
onScanComplete?: (applyScanCompleteContent: ApplyScanCompleteContent) => void;
|
|
164
172
|
onRevertAnonymization?: () => void;
|
|
165
173
|
onAnonymizeDocument?: () => void;
|
|
166
174
|
isAnonymized?: boolean;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Mark } from '@tiptap/core';
|
|
2
|
+
import type { AnonymizedDataItem } from './AnonymizedText';
|
|
3
|
+
export interface AnonymizedLinkOptions {
|
|
4
|
+
/** HTML attributes to add to the rendered <a> element. */
|
|
5
|
+
HTMLAttributes: Record<string, unknown>;
|
|
6
|
+
/** If true, clicking a link in a non-editable view opens the href in a new tab. */
|
|
7
|
+
openOnClick: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare module '@tiptap/core' {
|
|
10
|
+
interface Commands<ReturnType> {
|
|
11
|
+
anonymizedLink: {
|
|
12
|
+
/**
|
|
13
|
+
* Set an anonymizedLink mark on the current selection.
|
|
14
|
+
*/
|
|
15
|
+
setAnonymizedLink: (attributes: {
|
|
16
|
+
href: string;
|
|
17
|
+
target?: string | null;
|
|
18
|
+
rel?: string | null;
|
|
19
|
+
class?: string | null;
|
|
20
|
+
anonymizedData?: AnonymizedDataItem[] | string | null;
|
|
21
|
+
showValue?: boolean | null;
|
|
22
|
+
}) => ReturnType;
|
|
23
|
+
/**
|
|
24
|
+
* Remove the anonymizedLink mark from the current selection.
|
|
25
|
+
*/
|
|
26
|
+
unsetAnonymizedLink: () => ReturnType;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* AnonymizedLink Mark
|
|
32
|
+
*
|
|
33
|
+
* Renders anonymized URLs as regular `<a>` elements while preserving the
|
|
34
|
+
* original value inside the mark's `anonymizedData` attribute. It mirrors the
|
|
35
|
+
* behaviour of the default Tiptap `link` mark (href / target / rel / class)
|
|
36
|
+
* and adds the PII-specific `anonymizedData` + `showValue` attributes used by
|
|
37
|
+
* the anonymization pipeline.
|
|
38
|
+
*
|
|
39
|
+
* Accepts the following JSON shape:
|
|
40
|
+
* ```json
|
|
41
|
+
* {
|
|
42
|
+
* "type": "text",
|
|
43
|
+
* "text": "arrived",
|
|
44
|
+
* "marks": [{
|
|
45
|
+
* "type": "anonymizedLink",
|
|
46
|
+
* "attrs": {
|
|
47
|
+
* "href": "https://google.com/",
|
|
48
|
+
* "target": "_blank",
|
|
49
|
+
* "rel": "noopener noreferrer nofollow",
|
|
50
|
+
* "class": null,
|
|
51
|
+
* "anonymizedData": [{ "anonymizedVariable": "URL 3", "value": "https://google.com/" }],
|
|
52
|
+
* "showValue": false
|
|
53
|
+
* }
|
|
54
|
+
* }]
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* The mark coexists with the default `link` mark: only `<a>` elements tagged
|
|
59
|
+
* with `data-anon-link` (or a `data-anon-data` payload) parse into this mark,
|
|
60
|
+
* so plain links continue to be handled by the Link extension.
|
|
61
|
+
*/
|
|
62
|
+
export declare const AnonymizedLink: Mark<AnonymizedLinkOptions, any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type EditorConfig } from "@/config/EditorConfig";
|
|
2
|
-
export declare const EditorExtensions: (config?: EditorConfig) => (import("@tiptap/core").Node<import("@tiptap/extension-list").OrderedListOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-list").TaskItemOptions, any> | import("@tiptap/core").Extension<import("@/extensions/AIAutoCompletion").AIAutocompletionOptions, any> | import("@tiptap/core").Extension<any, any> | import("@tiptap/core").Extension<import("./Indent").IndentOptions, any> | import("@tiptap/core").Node<import("./ListItemWithDepthLimit").ListItemOptions, any> | import("@tiptap/core").Extension<import("./Redline").RedlineOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableRowOptions, any> | import("@tiptap/core").Node<import("./VariableText").VariableOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-horizontal-rule").HorizontalRuleOptions, any> | import("@tiptap/core").Node<import("./CodeBlockWithToolbar").CodeBlockWithToolbarOptions, any> | import("@tiptap/core").Extension<import("./PageMargin").PageMarginOptions, any> | import("@tiptap/core").Extension<import("./PageBackground").PageBackgroundOptions, any> | import("@tiptap/core").Node<import("./PageBreak").PageBreakOptions, any> | import("@tiptap/core").Node<any, any> | import("@tiptap/core").Node<import("./CustomImageExtension").CustomImageExtensionOptions, any> | import("@tiptap/core").Node<import("./Signature").SignatureOptions, any> | import("@tiptap/core").Node<import("./AnonymizedText").AnonymizedTextOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extensions").UndoRedoOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extensions").CharacterCountOptions, import("@tiptap/extensions").CharacterCountStorage> | import("@tiptap/core").Extension<import("@tiptap/extensions").PlaceholderOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-typography").TypographyOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-style").FontSizeOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-superscript").SuperscriptExtensionOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-highlight").HighlightOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-list").TaskListOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-align").TextAlignOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-heading").HeadingOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-link").LinkOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-hard-break").HardBreakOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extensions").TrailingNodeOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-collaboration").CollaborationOptions, import("@tiptap/extension-collaboration").CollaborationStorage> | import("@tiptap/core").Extension<import("@tiptap/extension-collaboration-caret").CollaborationCaretOptions, {
|
|
2
|
+
export declare const EditorExtensions: (config?: EditorConfig) => (import("@tiptap/core").Node<import("@tiptap/extension-list").OrderedListOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-list").TaskItemOptions, any> | import("@tiptap/core").Extension<import("@/extensions/AIAutoCompletion").AIAutocompletionOptions, any> | import("@tiptap/core").Extension<any, any> | import("@tiptap/core").Extension<import("./Indent").IndentOptions, any> | import("@tiptap/core").Node<import("./ListItemWithDepthLimit").ListItemOptions, any> | import("@tiptap/core").Extension<import("./Redline").RedlineOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableRowOptions, any> | import("@tiptap/core").Node<import("./VariableText").VariableOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-horizontal-rule").HorizontalRuleOptions, any> | import("@tiptap/core").Node<import("./CodeBlockWithToolbar").CodeBlockWithToolbarOptions, any> | import("@tiptap/core").Extension<import("./PageMargin").PageMarginOptions, any> | import("@tiptap/core").Extension<import("./PageBackground").PageBackgroundOptions, any> | import("@tiptap/core").Node<import("./PageBreak").PageBreakOptions, any> | import("@tiptap/core").Node<any, any> | import("@tiptap/core").Node<import("./CustomImageExtension").CustomImageExtensionOptions, any> | import("@tiptap/core").Node<import("./Signature").SignatureOptions, any> | import("@tiptap/core").Node<import("./AnonymizedText").AnonymizedTextOptions, any> | import("@tiptap/core").Mark<import("./AnonymizedLink").AnonymizedLinkOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extensions").UndoRedoOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extensions").CharacterCountOptions, import("@tiptap/extensions").CharacterCountStorage> | import("@tiptap/core").Extension<import("@tiptap/extensions").PlaceholderOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-typography").TypographyOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-style").FontSizeOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-superscript").SuperscriptExtensionOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-highlight").HighlightOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-list").TaskListOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-align").TextAlignOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-heading").HeadingOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-link").LinkOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-hard-break").HardBreakOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extensions").TrailingNodeOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-collaboration").CollaborationOptions, import("@tiptap/extension-collaboration").CollaborationStorage> | import("@tiptap/core").Extension<import("@tiptap/extension-collaboration-caret").CollaborationCaretOptions, {
|
|
3
3
|
users: {
|
|
4
4
|
clientId: number;
|
|
5
5
|
[key: string]: any;
|