@kumwe/studio-rich-text 0.1.0-alpha.6 → 0.1.0-beta.2
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/README.md +19 -5
- package/THIRD_PARTY_NOTICES.md +19 -0
- package/dist/first-party-tools.d.ts +173 -0
- package/dist/first-party-tools.d.ts.map +1 -0
- package/dist/first-party-tools.js +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -564
- package/dist/markdown.d.ts +14 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +12 -0
- package/dist/profiles.d.ts +19 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +1 -0
- package/dist/safe-html.d.ts +16 -0
- package/dist/safe-html.d.ts.map +1 -0
- package/dist/safe-html.js +1 -0
- package/dist/strict-csp-surface.d.ts +10 -0
- package/dist/strict-csp-surface.d.ts.map +1 -0
- package/dist/strict-csp-surface.js +1 -0
- package/dist/studio-rich-text-editor.d.ts +55 -0
- package/dist/studio-rich-text-editor.d.ts.map +1 -0
- package/dist/studio-rich-text-editor.js +1 -0
- package/package.json +7 -6
- package/third-party-licenses/codex-notifier-1.1.2.txt +21 -0
- package/third-party-licenses/codex-tooltip-1.0.6.txt +7 -0
- package/third-party-licenses/editorjs__caret-1.1.0.txt +21 -0
- package/third-party-licenses/editorjs__dom-1.1.0.txt +21 -0
- package/third-party-licenses/editorjs__editorjs-2.31.6.txt +190 -0
- package/third-party-licenses/editorjs__helpers-1.2.2.txt +21 -0
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
# `@kumwe/studio-rich-text`
|
|
2
2
|
|
|
3
|
-
Status:
|
|
3
|
+
Status: governed beta development, not an RC or production-supported release. The exact coordinated version
|
|
4
|
+
is in the workspace `studio-release.json`; gate claims still require the evidence ledger.
|
|
4
5
|
|
|
5
|
-
A bounded
|
|
6
|
-
|
|
6
|
+
A bounded Studio-owned rich-text authoring boundary backed internally by Editor.js `2.31.6`. It supplies a
|
|
7
|
+
deliberate Studio tool profile for structured-content leaf fields; it is not a second page-layout model.
|
|
8
|
+
Consumers use `StudioRichTextEditorFactory`, named Studio profiles, and canonical
|
|
9
|
+
`StudioRichTextDocument` values. Editor.js output and plugin configuration are deliberately not public API or
|
|
10
|
+
persisted state.
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
Editor.js remains the private default surface. Strict style-CSP/Trusted-Types hosts can instead pass
|
|
13
|
+
Studio's `StudioStrictCspRichTextSurfaceAdapter` to the factory, or select the corresponding Studio
|
|
14
|
+
registry policy through `@kumwe/studio`. The sink-free surface retains the same first-party structured
|
|
15
|
+
blocks, semantic inline formatting, read-only rules, and canonical JSON; it does not inject styles or
|
|
16
|
+
write HTML strings.
|
|
17
|
+
|
|
18
|
+
The package also provides deterministic Markdown import/export and policy-sanitized HTML import.
|
|
19
|
+
HTML import can only narrow the fixed portable tag ceiling; it never persists HTML, event handlers,
|
|
20
|
+
styles, URLs, scripts, or editor-native data. Dynamic host bindings are displayed read-only.
|
|
21
|
+
|
|
22
|
+
Hosts remain responsible for authoritative validation and for rendering canonical JSON with their
|
|
23
|
+
own escaping server-side presenter.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
<!-- Generated by scripts/generate-third-party-notices.mjs. Do not edit by hand. -->
|
|
4
|
+
|
|
5
|
+
Package: `@kumwe/studio-rich-text`
|
|
6
|
+
|
|
7
|
+
Production closure SHA-256: `7b581c7b8fcb6a7436a017215ef59840857990b2ae30d9d798c3e81d04b2750b`
|
|
8
|
+
|
|
9
|
+
The following packages are present in this package's lock-derived production dependency closure.
|
|
10
|
+
They retain their own copyright and license terms.
|
|
11
|
+
|
|
12
|
+
| Package | Version | Declared license | License text SHA-256 | Evidence source |
|
|
13
|
+
| --- | --- | --- | --- | --- |
|
|
14
|
+
| @editorjs/caret | 1.1.0 | MIT | [`5955c6e9d1de490608d7a41b4cfff00e769867ddb5fac2999b8efc874500e3a1`](third-party-licenses/editorjs__caret-1.1.0.txt) | [curated upstream source](https://github.com/editor-js/utils/blob/023b992f3ed56d32f7a907914e851d3cfdf78036/LICENSE) |
|
|
15
|
+
| @editorjs/dom | 1.1.0 | MIT | [`5955c6e9d1de490608d7a41b4cfff00e769867ddb5fac2999b8efc874500e3a1`](third-party-licenses/editorjs__dom-1.1.0.txt) | [curated upstream source](https://github.com/editor-js/utils/blob/023b992f3ed56d32f7a907914e851d3cfdf78036/LICENSE) |
|
|
16
|
+
| @editorjs/editorjs | 2.31.6 | Apache-2.0 | [`b946f387bbb7de6843c0db34f87a8956f229d220b3bf81b16b8425788cacf3ed`](third-party-licenses/editorjs__editorjs-2.31.6.txt) | [curated upstream source](https://github.com/codex-team/editor.js/blob/v2.31.6/LICENSE) |
|
|
17
|
+
| @editorjs/helpers | 1.2.2 | MIT | [`5955c6e9d1de490608d7a41b4cfff00e769867ddb5fac2999b8efc874500e3a1`](third-party-licenses/editorjs__helpers-1.2.2.txt) | [curated upstream source](https://github.com/editor-js/utils/blob/023b992f3ed56d32f7a907914e851d3cfdf78036/LICENSE) |
|
|
18
|
+
| codex-notifier | 1.1.2 | MIT | [`698022d282ae51ef05451e18cda80381aa74c6a8bb19b4ee4565b1926d36e08a`](third-party-licenses/codex-notifier-1.1.2.txt) | [curated upstream source](https://github.com/codex-team/js-notifier/blob/d000792c90bbde682d438b3554f3b9c8f6ddcb95/LICENSE) |
|
|
19
|
+
| codex-tooltip | 1.0.6 | MIT | [`4350bad7723eb798e1b61d8bb006dbdba611d64257b711f81bc9dc737e82b69f`](third-party-licenses/codex-tooltip-1.0.6.txt) | [curated upstream source](https://github.com/codex-team/codex.tooltips/blob/c1d3798621189ede6aaa66765acd5901b5310275/LICENSE) |
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { StudioRichTextDocument, StudioRichTextNode } from './index.js';
|
|
2
|
+
export type StudioEditorJsToolName = 'callout' | 'checklist' | 'code' | 'delimiter' | 'header' | 'list' | 'paragraph' | 'quote' | 'table';
|
|
3
|
+
export declare const STUDIO_EDITOR_JS_TOOL_NAMES: readonly StudioEditorJsToolName[];
|
|
4
|
+
export interface StudioEditorJsBlock {
|
|
5
|
+
data: {
|
|
6
|
+
node: StudioRichTextNode;
|
|
7
|
+
};
|
|
8
|
+
type: StudioEditorJsToolName;
|
|
9
|
+
}
|
|
10
|
+
interface ToolOptions {
|
|
11
|
+
data?: {
|
|
12
|
+
node?: StudioRichTextNode;
|
|
13
|
+
};
|
|
14
|
+
readOnly?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface ToolClass {
|
|
17
|
+
new (options: ToolOptions): {
|
|
18
|
+
render(): HTMLElement;
|
|
19
|
+
save(): {
|
|
20
|
+
node: StudioRichTextNode;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
readonly isReadOnlySupported: boolean;
|
|
24
|
+
readonly toolbox: {
|
|
25
|
+
icon: string;
|
|
26
|
+
title: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export declare function studioEditorJsTools(): Readonly<Record<StudioEditorJsToolName, ToolClass>>;
|
|
30
|
+
export declare function toStudioEditorJsBlocks(document: StudioRichTextDocument): StudioEditorJsBlock[];
|
|
31
|
+
export declare function fromStudioEditorJsBlocks(value: unknown): StudioRichTextDocument;
|
|
32
|
+
declare abstract class InlineToolBase {
|
|
33
|
+
static readonly isReadOnlySupported: boolean;
|
|
34
|
+
protected readonly node: StudioRichTextNode;
|
|
35
|
+
protected readonly readOnly: boolean;
|
|
36
|
+
protected field?: HTMLElement;
|
|
37
|
+
constructor(options: ToolOptions, fallback: StudioRichTextNode);
|
|
38
|
+
protected renderInline(label: string, content: readonly StudioRichTextNode[]): HTMLElement;
|
|
39
|
+
protected saveInline(original: readonly StudioRichTextNode[]): StudioRichTextNode[];
|
|
40
|
+
abstract render(): HTMLElement;
|
|
41
|
+
abstract save(): {
|
|
42
|
+
node: StudioRichTextNode;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export declare class StudioParagraphTool extends InlineToolBase {
|
|
46
|
+
static readonly isReadOnlySupported: boolean;
|
|
47
|
+
static readonly toolbox: {
|
|
48
|
+
readonly icon: "¶";
|
|
49
|
+
readonly title: "Paragraph";
|
|
50
|
+
};
|
|
51
|
+
constructor(options: ToolOptions);
|
|
52
|
+
render(): HTMLElement;
|
|
53
|
+
save(): {
|
|
54
|
+
node: StudioRichTextNode;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export declare class StudioHeaderTool extends InlineToolBase {
|
|
58
|
+
#private;
|
|
59
|
+
static readonly isReadOnlySupported: boolean;
|
|
60
|
+
static readonly toolbox: {
|
|
61
|
+
readonly icon: "H";
|
|
62
|
+
readonly title: "Heading";
|
|
63
|
+
};
|
|
64
|
+
constructor(options: ToolOptions);
|
|
65
|
+
render(): HTMLElement;
|
|
66
|
+
save(): {
|
|
67
|
+
node: StudioRichTextNode;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export declare class StudioQuoteTool extends InlineToolBase {
|
|
71
|
+
static readonly isReadOnlySupported: boolean;
|
|
72
|
+
static readonly toolbox: {
|
|
73
|
+
readonly icon: "“";
|
|
74
|
+
readonly title: "Quote";
|
|
75
|
+
};
|
|
76
|
+
constructor(options: ToolOptions);
|
|
77
|
+
render(): HTMLElement;
|
|
78
|
+
save(): {
|
|
79
|
+
node: StudioRichTextNode;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export declare class StudioDelimiterTool {
|
|
83
|
+
static readonly isReadOnlySupported: boolean;
|
|
84
|
+
static readonly toolbox: {
|
|
85
|
+
readonly icon: "—";
|
|
86
|
+
readonly title: "Separator";
|
|
87
|
+
};
|
|
88
|
+
render(): HTMLElement;
|
|
89
|
+
save(): {
|
|
90
|
+
node: StudioRichTextNode;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export declare class StudioCalloutTool extends InlineToolBase {
|
|
94
|
+
#private;
|
|
95
|
+
static readonly isReadOnlySupported: boolean;
|
|
96
|
+
static readonly toolbox: {
|
|
97
|
+
readonly icon: "!";
|
|
98
|
+
readonly title: "Callout";
|
|
99
|
+
};
|
|
100
|
+
constructor(options: ToolOptions);
|
|
101
|
+
render(): HTMLElement;
|
|
102
|
+
save(): {
|
|
103
|
+
node: StudioRichTextNode;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export declare class StudioCodeTool {
|
|
107
|
+
#private;
|
|
108
|
+
static readonly isReadOnlySupported: boolean;
|
|
109
|
+
static readonly toolbox: {
|
|
110
|
+
readonly icon: "</>";
|
|
111
|
+
readonly title: "Code";
|
|
112
|
+
};
|
|
113
|
+
constructor(options: ToolOptions);
|
|
114
|
+
render(): HTMLElement;
|
|
115
|
+
save(): {
|
|
116
|
+
node: StudioRichTextNode;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
export declare class StudioListTool {
|
|
120
|
+
#private;
|
|
121
|
+
static readonly isReadOnlySupported: boolean;
|
|
122
|
+
static readonly toolbox: {
|
|
123
|
+
readonly icon: "•";
|
|
124
|
+
readonly title: "List";
|
|
125
|
+
};
|
|
126
|
+
constructor(options: ToolOptions);
|
|
127
|
+
render(): HTMLElement;
|
|
128
|
+
save(): {
|
|
129
|
+
node: StudioRichTextNode;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
export declare class StudioChecklistTool {
|
|
133
|
+
#private;
|
|
134
|
+
static readonly isReadOnlySupported: boolean;
|
|
135
|
+
static readonly toolbox: {
|
|
136
|
+
readonly icon: "☑";
|
|
137
|
+
readonly title: "Checklist";
|
|
138
|
+
};
|
|
139
|
+
constructor(options: ToolOptions);
|
|
140
|
+
render(): HTMLElement;
|
|
141
|
+
save(): {
|
|
142
|
+
node: StudioRichTextNode;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
export declare class StudioTableTool {
|
|
146
|
+
#private;
|
|
147
|
+
static readonly isReadOnlySupported: boolean;
|
|
148
|
+
static readonly toolbox: {
|
|
149
|
+
readonly icon: "▦";
|
|
150
|
+
readonly title: "Table";
|
|
151
|
+
};
|
|
152
|
+
constructor(options: ToolOptions);
|
|
153
|
+
render(): HTMLElement;
|
|
154
|
+
save(): {
|
|
155
|
+
node: StudioRichTextNode;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/** Editor.js inline tool for a bounded semantic highlight tone. */
|
|
159
|
+
export declare class StudioMarkerTool {
|
|
160
|
+
#private;
|
|
161
|
+
static readonly isInline: boolean;
|
|
162
|
+
static readonly sanitize: {
|
|
163
|
+
readonly mark: {
|
|
164
|
+
readonly 'data-studio-tone': true;
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
checkState(selection: Selection): boolean;
|
|
168
|
+
render(): HTMLElement;
|
|
169
|
+
renderActions(): HTMLElement;
|
|
170
|
+
surround(range: Range): void;
|
|
171
|
+
}
|
|
172
|
+
export {};
|
|
173
|
+
//# sourceMappingURL=first-party-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"first-party-tools.d.ts","sourceRoot":"","sources":["../src/first-party-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAsB,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEjG,MAAM,MAAM,sBAAsB,GAC9B,SAAS,GACT,WAAW,GACX,MAAM,GACN,WAAW,GACX,QAAQ,GACR,MAAM,GACN,WAAW,GACX,OAAO,GACP,OAAO,CAAC;AAEZ,eAAO,MAAM,2BAA2B,EAAE,SAAS,sBAAsB,EAU9D,CAAC;AAEZ,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE;QAAE,IAAI,EAAE,kBAAkB,CAAA;KAAE,CAAC;IACnC,IAAI,EAAE,sBAAsB,CAAC;CAC9B;AAED,UAAU,WAAW;IACnB,IAAI,CAAC,EAAE;QAAE,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A;KAAE;CAY5C;AAYD,qBAAa,cAAc;;IACzB,gBAAuB,mBAAmB,EAAE,OAAO,CAAQ;IAC3D,gBAAuB,OAAO;;;MAAyC;gBAMpD,OAAO,EAAE,WAAW;IAYhC,MAAM,IAAI,WAAW;IAMrB,IAAI,IAAI;QAAE,IAAI,EAAE,kBAAkB,CAAA;KAAE;CA0L5C;AASD,qBAAa,mBAAmB;;IAC9B,gBAAuB,mBAAmB,EAAE,OAAO,CAAQ;IAC3D,gBAAuB,OAAO;;;MAA8C;gBAOzD,OAAO,EAAE,WAAW;IA4BhC,MAAM,IAAI,WAAW;IAMrB,IAAI,IAAI;QAAE,IAAI,EAAE,kBAAkB,CAAA;KAAE;CAkG5C;AAED,qBAAa,eAAe;;IAC1B,gBAAuB,mBAAmB,EAAE,OAAO,CAAQ;IAC3D,gBAAuB,OAAO;;;MAA0C;gBASrD,OAAO,EAAE,WAAW;IA6BhC,MAAM,IAAI,WAAW;IAMrB,IAAI,IAAI;QAAE,IAAI,EAAE,kBAAkB,CAAA;KAAE;CAoG5C;AAOD,mEAAmE;AACnE,qBAAa,gBAAgB;;IAC3B,gBAAuB,QAAQ,EAAE,OAAO,CAAQ;IAChD,gBAAuB,QAAQ;;;;MAAmD;IAI3E,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO;IAOzC,MAAM,IAAI,WAAW;IAUrB,aAAa,IAAI,WAAW;IAa5B,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;CAcpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const STUDIO_EDITOR_JS_TOOL_NAMES=Object.freeze([`callout`,`checklist`,`code`,`delimiter`,`header`,`list`,`paragraph`,`quote`,`table`]);export function studioEditorJsTools(){return Object.freeze({callout:StudioCalloutTool,checklist:StudioChecklistTool,code:StudioCodeTool,delimiter:StudioDelimiterTool,header:StudioHeaderTool,list:StudioListTool,paragraph:StudioParagraphTool,quote:StudioQuoteTool,table:StudioTableTool})}export function toStudioEditorJsBlocks(e){return e.content.map(e=>({data:{node:structuredClone(e)},type:i(e)}))}export function fromStudioEditorJsBlocks(t){if(!A(t)||!Array.isArray(t.blocks))throw TypeError(`Editor surface returned an invalid block collection.`);let n=t.blocks.map((t,n)=>{if(!A(t)||!STUDIO_EDITOR_JS_TOOL_NAMES.includes(t.type)||!A(t.data)||!A(t.data.node))throw TypeError(`Editor block ${n} is not a Studio first-party block.`);let r=structuredClone(t.data.node);if(i(r)!==t.type)throw TypeError(`Editor block ${n} has a mismatched Studio node type.`);return r});return{content:n.length>0?n:[{type:`paragraph`}],type:`doc`}}function i(e){switch(e.type){case`heading`:return`header`;case`blockquote`:return`quote`;case`horizontalRule`:return`delimiter`;case`bulletList`:case`orderedList`:return`list`;case`checklist`:return`checklist`;case`table`:return`table`;case`callout`:return`callout`;case`codeBlock`:return`code`;case`paragraph`:return`paragraph`;default:throw TypeError(`Node type "${e.type}" has no first-party Editor.js tool.`)}}class a{static isReadOnlySupported=!0;node;readOnly;field;constructor(e,t){this.node=structuredClone(e.data?.node??t),this.readOnly=e.readOnly===!0}renderInline(e,t){let n=document.createElement(`div`);n.className=`studio-rich-text-field`,n.contentEditable=this.readOnly?`false`:`true`,n.setAttribute(`aria-label`,e),n.setAttribute(`role`,`textbox`),n.setAttribute(`aria-multiline`,`true`),n.spellcheck=!0;for(let e of t)c(n,e);return n.addEventListener(`paste`,m),this.field=n,n}saveInline(e){return this.field===void 0?structuredClone([...e]):d(e,u(this.field))}}export class StudioParagraphTool extends a{static isReadOnlySupported=!0;static toolbox={icon:`¶`,title:`Paragraph`};constructor(e){super(e,{type:`paragraph`})}render(){return this.renderInline(`Paragraph`,this.node.content??[])}save(){let e=structuredClone(this.node),t=this.saveInline(e.content??[]);return w(e.content??[],t)||(e.content=t),{node:e}}}export class StudioHeaderTool extends a{static isReadOnlySupported=!0;static toolbox={icon:`H`,title:`Heading`};#level;constructor(e){super(e,{attrs:{level:2},type:`heading`})}render(){let e=T(`Heading`),t=document.createElement(`select`),n=this.node.attrs?.level===3||this.node.attrs?.level===4?this.node.attrs.level:2;t.setAttribute(`aria-label`,`Heading level`),t.disabled=this.readOnly;for(let e of[2,3,4]){let r=document.createElement(`option`);r.value=String(e),r.textContent=`Heading ${e}`,r.selected=n===e,t.append(r)}return t.value=String(n),this.#level=t,e.append(t,this.renderInline(`Heading text`,this.node.content??[])),e}save(){let e=structuredClone(this.node),t=Number(this.#level?.value??this.node.attrs?.level??2);t!==Number(this.node.attrs?.level??2)&&(e.attrs={level:t});let n=this.saveInline(e.content??[]);return w(e.content??[],n)||(e.content=n),{node:e}}}export class StudioQuoteTool extends a{static isReadOnlySupported=!0;static toolbox={icon:`“`,title:`Quote`};constructor(e){super(e,{content:[{type:`paragraph`}],type:`blockquote`})}render(){return this.renderInline(`Quotation`,x(this.node.content??[]))}save(){let e=structuredClone(this.node),t=x(e.content??[]);return e.content=S(e.content??[],this.saveInline(t)),{node:e}}}export class StudioDelimiterTool{static isReadOnlySupported=!0;static toolbox={icon:`—`,title:`Separator`};render(){let e=document.createElement(`hr`);return e.setAttribute(`aria-label`,`Separator`),e}save(){return{node:{type:`horizontalRule`}}}}export class StudioCalloutTool extends a{static isReadOnlySupported=!0;static toolbox={icon:`!`,title:`Callout`};#tone;constructor(e){super(e,{attrs:{tone:`info`},content:[{type:`paragraph`}],type:`callout`})}render(){let e=T(`Callout`);return this.#tone=D(`Callout tone`,[`info`,`success`,`warning`,`danger`],j(this.node.attrs?.tone,`info`),this.readOnly),e.append(this.#tone,this.renderInline(`Callout text`,x(this.node.content??[]))),e}save(){let e=structuredClone(this.node);e.attrs={tone:this.#tone?.value??`info`};let t=x(e.content??[]);return e.content=S(e.content??[],this.saveInline(t)),{node:e}}}export class StudioCodeTool{static isReadOnlySupported=!0;static toolbox={icon:`</>`,title:`Code`};#node;#readOnly;#language;#source;constructor(e){this.#node=structuredClone(e.data?.node??{attrs:{language:`text`},text:``,type:`codeBlock`}),this.#readOnly=e.readOnly===!0}render(){let e=T(`Code sample`);return this.#language=E(`Code language`,j(this.#node.attrs?.language,`text`),this.#readOnly),this.#language.pattern=`[A-Za-z0-9][A-Za-z0-9+_.#-]{0,63}`,this.#language.maxLength=64,this.#source=document.createElement(`textarea`),this.#source.setAttribute(`aria-label`,`Inert code source`),this.#source.disabled=this.#readOnly,this.#source.rows=8,this.#source.value=this.#node.text??``,e.append(this.#language,this.#source),e}save(){let e=this.#language?.value.trim()??`text`;return{node:{attrs:{language:/^[A-Za-z0-9][A-Za-z0-9+_.#-]{0,63}$/u.test(e)?e:`text`},text:this.#source?.value??``,type:`codeBlock`}}}}export class StudioListTool{static isReadOnlySupported=!0;static toolbox={icon:`•`,title:`List`};#readOnly;#node;#rows;#root;constructor(e){let t=structuredClone(e.data?.node??{content:[{content:[{type:`paragraph`}],type:`listItem`}],type:`bulletList`});this.#node=t,this.#readOnly=e.readOnly===!0,this.#rows=h(t)}render(){return this.#root=T(`List`),this.#renderRows(),this.#root}save(){return this.#syncRows(),{node:structuredClone(this.#node)}}#renderRows(){let e=this.#root;if(e===void 0)return;e.replaceChildren();let t=D(`List style`,[`bullet`,`ordered`],this.#node.type===`orderedList`?`ordered`:`bullet`,this.#readOnly);if(t.addEventListener(`change`,()=>{this.#syncRows();let e=t.value===`ordered`,n=g(this.#node);this.#node.type=e?`orderedList`:`bulletList`,e&&n!==1?this.#node.attrs={start:n}:delete this.#node.attrs,this.#renderRows()}),e.append(t),this.#node.type===`orderedList`){let t=E(`Ordered list start`,String(g(this.#node)),this.#readOnly);t.type=`number`,t.min=`1`,t.max=`1000000`,t.addEventListener(`change`,()=>{let e=Math.max(1,Math.min(1e6,Number(t.value)||1));e!==g(this.#node)&&(e===1?delete this.#node.attrs:this.#node.attrs={start:e})}),e.append(t)}this.#rows=h(this.#node);let n=document.createElement(`ol`);n.setAttribute(`aria-label`,`List items`);for(let[e,t]of this.#rows.entries()){let r=document.createElement(`li`);r.dataset.index=String(e),r.dataset.studioDepth=String(t.depth),r.setAttribute(`aria-level`,String(t.depth+1));let i=C(`List item ${e+1}`,t.editableBlock.content??[],this.#readOnly);i.dataset.listText=String(e),r.append(i),this.#readOnly||r.append(O(`Move item up`,()=>this.#move(e,-1),!_(t,-1)),O(`Move item down`,()=>this.#move(e,1),!_(t,1)),O(`Indent item`,()=>this.#indent(e),!v(t)),O(`Outdent item`,()=>this.#outdent(e),t.ownerItem===void 0),O(`Remove item`,()=>this.#remove(e),!y(t,this.#node))),n.append(r)}e.append(n),this.#readOnly||e.append(O(`Add list item`,()=>this.#add()))}#syncRows(){for(let e of this.#root?.querySelectorAll(`[data-list-text]`)??[]){let t=Number(e.dataset.listText),n=this.#rows[t];if(n===void 0)continue;let r=d(n.editableBlock.content??[],u(e));n.syntheticEditable?r.length>0&&(n.editableBlock.content=r,n.item.content=[n.editableBlock,...n.item.content??[]],n.syntheticEditable=!1):w(n.editableBlock.content??[],r)||(n.editableBlock.content=r)}}#add(){this.#syncRows(),this.#rows.length<500&&(this.#node.content=[...this.#node.content??[],{content:[{type:`paragraph`}],type:`listItem`}]),this.#renderRows()}#indent(e){this.#syncRows();let t=this.#rows[e];if(t===void 0||!v(t))return;let n=t.parentList.content??[],r=n.indexOf(t.item),i=n[r-1];if(i===void 0)return;n.splice(r,1);let a=i.content?.at(-1),o=a?.type===t.parentList.type?a:{...t.parentList.type===`orderedList`&&t.parentList.attrs!==void 0?{attrs:structuredClone(t.parentList.attrs)}:{},content:[],type:t.parentList.type};o!==a&&(i.content=[...i.content??[],o]),o.content=[...o.content??[],t.item],this.#renderRows()}#outdent(e){this.#syncRows();let t=this.#rows[e];if(t?.ownerItem===void 0||t.parentListParent===void 0)return;let n=t.parentList.content??[],r=n.indexOf(t.item);if(r<0)return;let i=n.splice(r+1);n.splice(r,1),i.length>0&&(t.item.content=[...t.item.content??[],{...t.parentList.type===`orderedList`&&t.parentList.attrs!==void 0?{attrs:structuredClone(t.parentList.attrs)}:{},content:i,type:t.parentList.type}]),n.length===0&&b(t.ownerItem,t.parentList);let a=t.parentListParent.content??[],o=a.indexOf(t.ownerItem);o<0||(a.splice(o+1,0,t.item),this.#renderRows())}#move(e,t){this.#syncRows();let n=this.#rows[e];if(n===void 0||!_(n,t))return;let r=n.parentList.content??[],i=r.indexOf(n.item),[a]=r.splice(i,1);a!==void 0&&r.splice(i+t,0,a),this.#renderRows()}#remove(e){this.#syncRows();let t=this.#rows[e];if(t===void 0||!y(t,this.#node))return;let n=t.parentList.content??[],r=n.indexOf(t.item);r<0||(n.splice(r,1),n.length===0&&t.ownerItem!==void 0&&b(t.ownerItem,t.parentList),this.#renderRows())}}export class StudioChecklistTool{static isReadOnlySupported=!0;static toolbox={icon:`☑`,title:`Checklist`};#readOnly;#initialRows;#node;#root;#rows;constructor(e){this.#readOnly=e.readOnly===!0,this.#node=structuredClone(e.data?.node??{content:[{attrs:{checked:!1,level:0},type:`checklistItem`}],type:`checklist`});let t=this.#node.content??[];this.#rows=t.length>0?t.map(e=>({checked:e.attrs?.checked===!0,content:structuredClone(e.content??[]),contentPresent:e.content!==void 0,depth:Number(e.attrs?.level??0)})):[{checked:!1,content:[],contentPresent:!1,depth:0}],this.#initialRows=structuredClone(this.#rows)}render(){return this.#root=T(`Checklist`),this.#renderRows(),this.#root}save(){return this.#syncRows(),w(this.#rows,this.#initialRows)?{node:structuredClone(this.#node)}:{node:{content:this.#rows.map(e=>({attrs:{checked:e.checked,level:e.depth},...e.contentPresent||e.content.length>0?{content:structuredClone(e.content)}:{},type:`checklistItem`})),type:`checklist`}}}#renderRows(){let e=this.#root;if(e!==void 0){e.replaceChildren();for(let[t,n]of this.#rows.entries()){let r=T(`Checklist item ${t+1}`);r.dataset.studioDepth=String(n.depth),r.setAttribute(`aria-level`,String(n.depth+1));let i=document.createElement(`input`);i.type=`checkbox`,i.checked=n.checked,i.disabled=this.#readOnly,i.dataset.checkState=String(t),i.setAttribute(`aria-label`,`Checklist item ${t+1} complete`);let a=C(`Checklist item ${t+1}`,n.content,this.#readOnly);a.dataset.checkText=String(t),a.addEventListener(`input`,()=>{n.contentPresent=!0}),r.append(i,a),this.#readOnly||r.append(O(`Move item up`,()=>this.#move(t,-1),t===0),O(`Move item down`,()=>this.#move(t,1),t===this.#rows.length-1),O(`Indent item`,()=>this.#indent(t,1),n.depth>=4||t===0),O(`Outdent item`,()=>this.#indent(t,-1),n.depth===0),O(`Remove item`,()=>this.#remove(t),this.#rows.length===1)),e.append(r)}this.#readOnly||e.append(O(`Add checklist item`,()=>this.#add()))}}#syncRows(){for(let e of this.#root?.querySelectorAll(`[data-check-text]`)??[]){let t=this.#rows[Number(e.dataset.checkText)];t!==void 0&&(t.content=d(t.content,u(e)))}for(let e of this.#root?.querySelectorAll(`[data-check-state]`)??[]){let t=this.#rows[Number(e.dataset.checkState)];t!==void 0&&(t.checked=e.checked)}}#add(){this.#syncRows(),this.#rows.length<500&&this.#rows.push({checked:!1,content:[],contentPresent:!1,depth:0}),this.#renderRows()}#indent(e,t){this.#syncRows();let n=this.#rows[e];n!==void 0&&(n.depth=Math.max(0,Math.min(4,n.depth+t))),this.#renderRows()}#move(e,t){this.#syncRows();let n=e+t;if(n>=0&&n<this.#rows.length){let[t]=this.#rows.splice(e,1);t!==void 0&&this.#rows.splice(n,0,t)}this.#renderRows()}#remove(e){this.#syncRows(),this.#rows.length>1&&this.#rows.splice(e,1),this.#renderRows()}}export class StudioTableTool{static isReadOnlySupported=!0;static toolbox={icon:`▦`,title:`Table`};#readOnly;#initialCells;#initialHeader;#node;#cells;#header;#root;constructor(e){this.#readOnly=e.readOnly===!0,this.#node=structuredClone(e.data?.node??{attrs:{header:!1},content:[{content:[{type:`tableCell`},{type:`tableCell`}],type:`tableRow`},{content:[{type:`tableCell`},{type:`tableCell`}],type:`tableRow`}],type:`table`}),this.#header=this.#node.attrs?.header===!0,this.#cells=(this.#node.content??[]).map(e=>(e.content??[]).map(e=>({content:structuredClone(e.content??[]),contentPresent:e.content!==void 0}))),this.#initialHeader=this.#header,this.#initialCells=structuredClone(this.#cells)}render(){return this.#root=T(`Table`),this.#renderTable(),this.#root}save(){return this.#syncCells(),this.#header===this.#initialHeader&&w(this.#cells,this.#initialCells)?{node:structuredClone(this.#node)}:{node:{attrs:{header:this.#header},content:this.#cells.map(e=>({content:e.map(e=>({...e.contentPresent||e.content.length>0?{content:structuredClone(e.content)}:{},type:`tableCell`})),type:`tableRow`})),type:`table`}}}#renderTable(){let e=this.#root;if(e===void 0)return;e.replaceChildren();let t=document.createElement(`input`);t.type=`checkbox`,t.checked=this.#header,t.disabled=this.#readOnly,t.setAttribute(`aria-label`,`Use first row as table header`),t.addEventListener(`change`,()=>{this.#header=t.checked}),e.append(t);let n=document.createElement(`table`);n.setAttribute(`aria-label`,`Table data`);for(let[e,t]of this.#cells.entries()){let r=document.createElement(`tr`);for(let[n,i]of t.entries()){let t=document.createElement(e===0&&this.#header?`th`:`td`),a=C(`Row ${e+1}, column ${n+1}`,i.content,this.#readOnly);a.dataset.tableCell=`${e}:${n}`,a.addEventListener(`input`,()=>{i.contentPresent=!0}),t.append(a),r.append(t)}n.append(r)}e.append(n),this.#readOnly||e.append(O(`Add table row`,()=>this.#resize(1,0),this.#cells.length>=200),O(`Remove table row`,()=>this.#resize(-1,0),this.#cells.length<=1),O(`Add table column`,()=>this.#resize(0,1),(this.#cells[0]?.length??0)>=50),O(`Remove table column`,()=>this.#resize(0,-1),(this.#cells[0]?.length??0)<=1))}#resize(e,t){if(this.#syncCells(),e>0&&this.#cells.length<200&&this.#cells.push(Array.from({length:this.#cells[0]?.length??1},()=>({content:[],contentPresent:!1}))),e<0&&this.#cells.length>1&&this.#cells.pop(),t>0&&(this.#cells[0]?.length??0)<50)for(let e of this.#cells)e.push({content:[],contentPresent:!1});if(t<0&&(this.#cells[0]?.length??0)>1)for(let e of this.#cells)e.pop();this.#renderTable()}#syncCells(){for(let e of this.#root?.querySelectorAll(`[data-table-cell]`)??[]){let[t,n]=(e.dataset.tableCell??``).split(`:`).map(Number),r=t===void 0?void 0:this.#cells[t],i=n===void 0?void 0:r?.[n];i!==void 0&&(i.content=d(i.content,u(e)))}}}export class StudioMarkerTool{static isInline=!0;static sanitize={mark:{"data-studio-tone":!0}};#button;#tone=`accent`;checkState(e){let t=k(e.anchorNode)!==void 0;return this.#button?.setAttribute(`aria-pressed`,String(t)),t}render(){let e=document.createElement(`button`);return e.type=`button`,e.textContent=`Highlight`,e.setAttribute(`aria-label`,`Toggle semantic highlight`),e.setAttribute(`aria-pressed`,`false`),this.#button=e,e}renderActions(){let e=D(`Highlight tone`,[`accent`,`info`,`success`,`warning`,`danger`],this.#tone,!1);return e.addEventListener(`change`,()=>{this.#tone=e.value}),e}surround(e){let t=k(e.commonAncestorContainer);if(t!==void 0){let e=t.parentNode;for(;t.firstChild!==null;)e?.insertBefore(t.firstChild,t);t.remove();return}if(e.collapsed)return;let n=document.createElement(`mark`);n.dataset.studioTone=this.#tone,n.append(e.extractContents()),e.insertNode(n)}}function c(e,t){if(t.type===`hardBreak`){e.appendChild(document.createElement(`br`));return}if(t.type!==`text`||(t.text??``).length===0)return;let n=document.createTextNode(t.text??``);for(let e of[...t.marks??[]].reverse()){let t=document.createElement(l(e));e.type===`highlight`&&(t.dataset.studioTone=j(e.attrs?.tone,`accent`)),t.append(n),n=t}e.appendChild(n)}function l(e){return e.type===`bold`?`strong`:e.type===`italic`?`em`:e.type===`strike`?`s`:e.type===`code`?`code`:`mark`}function u(e){let t=[],n=(e,r)=>{if(e.nodeType===Node.TEXT_NODE){let n=e.nodeValue??``;n.length>0&&t.push({...r.length>0?{marks:r}:{},text:n,type:`text`});return}if(!(e instanceof Element))return;if(e.localName===`br`){t.push({type:`hardBreak`});return}let i=[...r],a=p(e);a!==void 0&&!i.some(e=>e.type===a.type)&&(a.type===`code`?i.splice(0,i.length,a):i.some(e=>e.type===`code`)||i.push(a));for(let t of e.childNodes)n(t,i)};for(let t of e.childNodes)n(t,[]);return t}function d(e,t){return w(f(e),f(t))?structuredClone([...e]):t}function f(e){let t=[];for(let n of e){if(n.type===`hardBreak`){t.push({kind:`hard-break`});continue}if(n.type!==`text`)continue;let e=(n.marks??[]).map(e=>{if(e.type!==`highlight`)return e.type;let t=e.attrs?.tone;return`${e.type}:${typeof t==`string`?t:``}`}).sort(),r=t.at(-1);r?.kind===`text`&&w(r.marks,e)?r.text+=n.text??``:t.push({kind:`text`,marks:e,text:n.text??``})}return t}function p(e){if(e.localName===`strong`||e.localName===`b`)return{type:`bold`};if(e.localName===`em`||e.localName===`i`)return{type:`italic`};if(e.localName===`s`||e.localName===`del`)return{type:`strike`};if(e.localName===`code`)return{type:`code`};if(e.localName===`mark`){let t=e.getAttribute(`data-studio-tone`);return{attrs:{tone:[`accent`,`danger`,`info`,`success`,`warning`].includes(t??``)?t??`accent`:`accent`},type:`highlight`}}}function m(e){e.preventDefault();let t=e.clipboardData?.getData(`text/plain`)??``,n=globalThis.getSelection();if(n===null||n.rangeCount===0)return;let r=n.getRangeAt(0);r.deleteContents(),r.insertNode(document.createTextNode(t.slice(0,25e4))),r.collapse(!1)}function h(e,t=0,n,r){let i=[];for(let a of e.content??[]){let o=(a.content??[]).find(e=>e.type===`paragraph`||e.type===`heading`),s=o??{type:`paragraph`};i.push({depth:t,editableBlock:s,item:a,...n===void 0?{}:{ownerItem:n},parentList:e,...r===void 0?{}:{parentListParent:r},syntheticEditable:o===void 0});for(let n of a.content??[])(n.type===`bulletList`||n.type===`orderedList`)&&i.push(...h(n,t+1,a,e))}return i}function g(e){let t=Number(e.attrs?.start??1);return Number.isSafeInteger(t)&&t>=1&&t<=1e6?t:1}function _(e,t){let n=e.parentList.content??[],r=n.indexOf(e.item);return r>=0&&r+t>=0&&r+t<n.length}function v(e){return e.depth>=4?!1:(e.parentList.content??[]).indexOf(e.item)>0}function y(e,t){return e.parentList!==t||(t.content?.length??0)>1}function b(e,t){e.content=(e.content??[]).filter(e=>e!==t)}function x(e){return e.find(e=>e.type===`paragraph`||e.type===`heading`)?.content??[]}function S(e,t){let n=structuredClone([...e]),r=n.findIndex(e=>e.type===`paragraph`||e.type===`heading`);if(r<0)return t.length>0&&n.unshift({content:structuredClone([...t]),type:`paragraph`}),n;let i=n[r];return i!==void 0&&!w(i.content??[],t)&&(i.content=structuredClone([...t])),n}function C(e,t,n){let r=document.createElement(`div`);r.className=`studio-rich-text-field`,r.contentEditable=n?`false`:`true`,r.setAttribute(`aria-label`,e),r.setAttribute(`aria-multiline`,`true`),r.setAttribute(`role`,`textbox`),r.spellcheck=!0;for(let e of t)c(r,e);return r.addEventListener(`paste`,m),r}function w(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>w(e,t[n]));if(!A(e)||!A(t))return!1;let n=Object.keys(e).sort(),r=Object.keys(t).sort();return n.length===r.length&&n.every((n,i)=>n===r[i]&&w(e[n],t[n]))}function T(e){let t=document.createElement(`div`);return t.setAttribute(`aria-label`,e),t.setAttribute(`role`,`group`),t}function E(e,t,n){let r=document.createElement(`input`);return r.type=`text`,r.setAttribute(`aria-label`,e),r.disabled=n,r.value=t,r}function D(e,t,n,r){let i=document.createElement(`select`);i.setAttribute(`aria-label`,e),i.disabled=r;for(let e of t){let t=document.createElement(`option`);t.value=e,t.textContent=e,t.selected=e===n,i.append(t)}return i.value=n,i}function O(e,t,n=!1){let r=document.createElement(`button`);return r.type=`button`,r.textContent=e,r.setAttribute(`aria-label`,e),r.disabled=n,r.addEventListener(`click`,t),r}function k(e){let t=e instanceof HTMLElement?e:e?.parentElement;for(;t!=null;){if(t.localName===`mark`)return t;t=t.parentElement??void 0}}function A(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function j(e,t){return typeof e==`string`?e:t}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type { Extensions } from '@tiptap/core';
|
|
2
1
|
import type { JsonObject } from '@kumwe/studio-protocol';
|
|
2
|
+
export { EditorJsRichTextEditorFactory, StudioRichTextEditorFactory, type StudioRichTextEditor, type StudioRichTextEditorChange, type StudioRichTextEditorOptions, type StudioRichTextSurface, type StudioRichTextSurfaceAdapter, type StudioRichTextSurfaceOptions, } from './studio-rich-text-editor.js';
|
|
3
|
+
export { StudioStrictCspRichTextSurfaceAdapter } from './strict-csp-surface.js';
|
|
4
|
+
export { exportStudioMarkdown, importStudioMarkdown, type StudioMarkdownOptions, } from './markdown.js';
|
|
5
|
+
export { importSafeHtml, STUDIO_SAFE_HTML_POLICY, type SafeHtmlImportPolicy } from './safe-html.js';
|
|
6
|
+
export { DOCUMENTATION_RICH_TEXT_PROFILE, MARKETING_RICH_TEXT_PROFILE, PORTABLE_RICH_TEXT_PROFILE, resolveContainerRichTextProfile, resolveRichTextProfile, type StudioRichTextContainerType, type StudioRichTextProfileId, } from './profiles.js';
|
|
3
7
|
export interface StudioRichTextMark {
|
|
4
8
|
attrs?: JsonObject;
|
|
5
9
|
type: string;
|
|
@@ -15,9 +19,6 @@ export interface StudioRichTextDocument extends StudioRichTextNode {
|
|
|
15
19
|
content: StudioRichTextNode[];
|
|
16
20
|
type: 'doc';
|
|
17
21
|
}
|
|
18
|
-
export interface StudioRichTextOptions {
|
|
19
|
-
headingLevels?: readonly (1 | 2 | 3 | 4 | 5 | 6)[];
|
|
20
|
-
}
|
|
21
22
|
export interface RichTextSpanProjection {
|
|
22
23
|
end: number;
|
|
23
24
|
marks: string[];
|
|
@@ -55,7 +56,6 @@ export interface StudioRichTextProfile {
|
|
|
55
56
|
}
|
|
56
57
|
export declare const DEFAULT_RICH_TEXT_ATTRIBUTE_LIMITS: Readonly<StudioRichTextAttributeLimits>;
|
|
57
58
|
export declare const DEFAULT_RICH_TEXT_PROFILE: Readonly<StudioRichTextProfile>;
|
|
58
|
-
export declare function createStudioRichTextExtensions(options?: StudioRichTextOptions): Extensions;
|
|
59
59
|
export declare function parseRichTextDocument(value: unknown, profile?: Readonly<StudioRichTextProfile>): StudioRichTextDocument;
|
|
60
60
|
export declare function isRichTextDocumentEmpty(document: StudioRichTextDocument): boolean;
|
|
61
61
|
export declare function projectRichText(document: StudioRichTextDocument): RichTextBlockProjection[];
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,wBAAwB,CAAC;AAEpE,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,GAClC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,qCAAqC,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,qBAAqB,GAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACpG,OAAO,EACL,+BAA+B,EAC/B,2BAA2B,EAC3B,0BAA0B,EAC1B,+BAA+B,EAC/B,sBAAsB,EACtB,KAAK,2BAA2B,EAChC,KAAK,uBAAuB,GAC7B,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd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