@dotit/editor 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +92 -0
- package/dist/DocsToolbar.d.ts +17 -0
- package/dist/IntentTextEditor.d.ts +29 -0
- package/dist/TrustBanner.d.ts +11 -0
- package/dist/VisualEditor.d.ts +17 -0
- package/dist/block-props.d.ts +25 -0
- package/dist/bridge.d.ts +14 -0
- package/dist/extensions.d.ts +17 -0
- package/dist/font-size.d.ts +11 -0
- package/dist/index.cjs +32 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.mjs +3142 -0
- package/dist/index.mjs.map +1 -0
- package/dist/keyword-styles.d.ts +18 -0
- package/dist/page-geometry.d.ts +23 -0
- package/dist/pagination.d.ts +11 -0
- package/dist/print-iframe.d.ts +1 -0
- package/dist/print.d.ts +7 -0
- package/dist/style.css +1364 -0
- package/dist/template-highlight.d.ts +13 -0
- package/dist/trust-state.d.ts +34 -0
- package/dist/types.d.ts +14 -0
- package/package.json +82 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 IntentText Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# @dotit/editor
|
|
2
|
+
|
|
3
|
+
Embeddable WYSIWYG visual editor for [IntentText](https://github.com/intenttext/IntentText) (`.it`) documents — Word-like pages, a formatting ribbon, trust banner, and WYSIWYG PDF/HTML export. Built for embedding in React apps: ERPs, portals, back offices.
|
|
4
|
+
|
|
5
|
+
The editor is a **controlled component over plain `.it` source text**: you pass the source in, you get the edited source back. Everything the user styles maps to core `.it` properties, so a document printed through `@dotit/core` (or this package's export functions) always matches what the user saw on screen.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @dotit/editor @dotit/core react react-dom
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Peer dependencies: `react >= 18`, `react-dom >= 18`.
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { useState } from "react";
|
|
19
|
+
import { IntentTextEditor, exportDocumentPDF } from "@dotit/editor";
|
|
20
|
+
import "@dotit/editor/style.css";
|
|
21
|
+
|
|
22
|
+
export function InvoiceEditor() {
|
|
23
|
+
const [source, setSource] = useState("title: Invoice INV-001\ntext: Hello");
|
|
24
|
+
return (
|
|
25
|
+
<div style={{ height: "100vh" }}>
|
|
26
|
+
<IntentTextEditor value={source} onChange={setSource} theme="corporate" />
|
|
27
|
+
<button onClick={() => exportDocumentPDF(source, "corporate")}>PDF</button>
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The editor fills its parent — give the wrapper an explicit height.
|
|
34
|
+
|
|
35
|
+
## `<IntentTextEditor />` props
|
|
36
|
+
|
|
37
|
+
| Prop | Type | Default | Description |
|
|
38
|
+
| ----------------- | --------------------------------- | ------------- | ----------- |
|
|
39
|
+
| `value` | `string` | — (required) | Current `.it` source text (controlled). |
|
|
40
|
+
| `onChange` | `(source: string) => void` | — (required) | Called with the updated `.it` source on every edit. |
|
|
41
|
+
| `theme` | `string` | `"corporate"` | Document theme id (see `builtinThemes()`). Controlled when provided — pair with `onThemeChange`. |
|
|
42
|
+
| `onThemeChange` | `(theme: string) => void` | — | Called when the user picks a theme in the ribbon. |
|
|
43
|
+
| `readOnly` | `boolean` | `false` | Force read-only. Sealed documents (`freeze:` block) are read-only automatically. |
|
|
44
|
+
| `showRibbon` | `boolean` | `true` | Show the formatting ribbon. |
|
|
45
|
+
| `showTrustBanner` | `boolean` | `true` | Show the trust status banner + document properties strip. |
|
|
46
|
+
| `onTrustAction` | `(a: "seal"\|"sign"\|"verify") => void` | — | Handle the ribbon's Trust group. The editor only reports intent — wire it to your own dialogs (e.g. core's `sealDocument` / `verifyDocument`). The group is hidden when omitted. |
|
|
47
|
+
|
|
48
|
+
## Named exports
|
|
49
|
+
|
|
50
|
+
| Export | Description |
|
|
51
|
+
| ------ | ----------- |
|
|
52
|
+
| `IntentTextEditor` | The embeddable editor component. |
|
|
53
|
+
| `exportDocumentPDF(source, theme, printMode?)` | Opens the browser print dialog (→ Save as PDF). WYSIWYG when the editor is mounted; falls back to core's `renderPrint`. `printMode`: `"normal" \| "minimal-ink"`. |
|
|
54
|
+
| `exportDocumentHTML(source, theme, printMode?)` | Downloads the print-ready HTML document. |
|
|
55
|
+
| `builtinThemes()` | Built-in theme ids for a theme picker. |
|
|
56
|
+
| `printHtmlViaIframe(html)` | Low-level: print any HTML document via a hidden iframe. |
|
|
57
|
+
| `sourceToDoc(source)` / `docToSource(json)` | The lossless `.it` ↔ editor-document bridge (TipTap JSON). |
|
|
58
|
+
| `extractTemplateVariables(source)` / `buildSampleSkeleton(vars)` | Template helpers for `{{variable}}` authoring. |
|
|
59
|
+
| `extractTrustState(parsedDoc)` | Trust lifecycle snapshot (`TrustState`): tracked / approved / signed / sealed + amendments. |
|
|
60
|
+
| `getPageGeometry(source)` / `resolvePageTokens(text, page, pages)` | Page geometry from the document's own `page:`/`header:`/`footer:` blocks. |
|
|
61
|
+
|
|
62
|
+
Types: `IntentTextEditorProps`, `TrustAction`, `PrintMode`, `TrustState`, `PageGeometry`.
|
|
63
|
+
|
|
64
|
+
## Embedding in an ERP
|
|
65
|
+
|
|
66
|
+
- **Controlled `.it` in/out.** Store the source string wherever you store documents (a DB column is fine — it's plain text). Load it into `value`, persist what `onChange` gives you. No editor-specific format ever touches your data.
|
|
67
|
+
- **Templates + merge.** Author templates with `{{variables}}` in the editor (they render as chips); merge real data server-side with `@dotit/core`'s `parseAndMerge` and print with `renderPrint` — or `@dotit/pdf` for real PDF bytes.
|
|
68
|
+
- **PDF from the UI.** Call `exportDocumentPDF(source, theme)` from your own button — it uses the user's browser print dialog and matches the on-screen pages exactly.
|
|
69
|
+
- **Trust flows.** Sealed documents lock automatically. Hook `onTrustAction` to your approval/signature flows; the editor renders `sign:`/`seal:`/`approve:` blocks as proper signature lines and chips.
|
|
70
|
+
- **Insert at caret.** Dispatch `window.dispatchEvent(new CustomEvent("it-insert-text", { detail: "{{customer.name}}" }))` to insert text at the cursor (e.g. from your own variable picker).
|
|
71
|
+
- **Styling.** All styles are scoped under `.docs-container`/`.docs-page` and ship in one stylesheet (`@dotit/editor/style.css`); the editor does not depend on host-page CSS resets. One editor instance per page is the supported setup (theme CSS is injected document-wide).
|
|
72
|
+
|
|
73
|
+
## SSR / Next.js
|
|
74
|
+
|
|
75
|
+
The editor is **browser-only** (it measures the DOM to paginate). With Next.js or any SSR framework, load it dynamically with SSR disabled:
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
"use client";
|
|
79
|
+
import dynamic from "next/dynamic";
|
|
80
|
+
import "@dotit/editor/style.css";
|
|
81
|
+
|
|
82
|
+
const IntentTextEditor = dynamic(
|
|
83
|
+
() => import("@dotit/editor").then((m) => m.IntentTextEditor),
|
|
84
|
+
{ ssr: false },
|
|
85
|
+
);
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`exportDocumentPDF` / `exportDocumentHTML` must also only be called in the browser. For server-side PDF generation use `@dotit/pdf`.
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Editor } from "@tiptap/core";
|
|
2
|
+
import type { TrustAction } from "./types";
|
|
3
|
+
interface Props {
|
|
4
|
+
editor: Editor | null;
|
|
5
|
+
isRtl?: boolean;
|
|
6
|
+
onToggleRtl?: () => void;
|
|
7
|
+
/** Current .it source — used by the export actions. */
|
|
8
|
+
content: string;
|
|
9
|
+
theme: string;
|
|
10
|
+
onThemeChange: (theme: string) => void;
|
|
11
|
+
/** Trust actions (Seal / Sign / Verify). The group is hidden when omitted. */
|
|
12
|
+
onTrustAction?: (action: TrustAction) => void;
|
|
13
|
+
/** Sealed documents are read-only — formatting groups are disabled. */
|
|
14
|
+
locked?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function DocsToolbar({ editor, isRtl, onToggleRtl, content, theme, onThemeChange, onTrustAction, locked, }: Props): import("react/jsx-runtime").JSX.Element | null;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { TrustAction } from "./types";
|
|
2
|
+
export interface IntentTextEditorProps {
|
|
3
|
+
/** Current `.it` source text (controlled). */
|
|
4
|
+
value: string;
|
|
5
|
+
/** Called with the updated `.it` source on every edit. */
|
|
6
|
+
onChange: (source: string) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Document theme id (see builtinThemes()). When provided the theme is
|
|
9
|
+
* controlled — pair it with onThemeChange so the ribbon's theme select
|
|
10
|
+
* works. When omitted the editor manages it internally (default
|
|
11
|
+
* "corporate").
|
|
12
|
+
*/
|
|
13
|
+
theme?: string;
|
|
14
|
+
/** Called when the user picks a theme in the ribbon. */
|
|
15
|
+
onThemeChange?: (theme: string) => void;
|
|
16
|
+
/** Force read-only. Sealed documents are read-only automatically. */
|
|
17
|
+
readOnly?: boolean;
|
|
18
|
+
/** Show the formatting ribbon. Default true. */
|
|
19
|
+
showRibbon?: boolean;
|
|
20
|
+
/** Show the trust status banner + document properties strip. Default true. */
|
|
21
|
+
showTrustBanner?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Handle the ribbon's Trust group (Seal / Sign / Verify). The editor only
|
|
24
|
+
* reports the intent — wire it to your own dialogs/flows (e.g. core's
|
|
25
|
+
* sealDocument / verifyDocument). The group is hidden when omitted.
|
|
26
|
+
*/
|
|
27
|
+
onTrustAction?: (action: TrustAction) => void;
|
|
28
|
+
}
|
|
29
|
+
export declare function IntentTextEditor({ value, onChange, theme, onThemeChange, readOnly, showRibbon, showTrustBanner, onTrustAction, }: IntentTextEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TrustState } from "./trust-state";
|
|
2
|
+
interface TrustBannerProps {
|
|
3
|
+
trust: TrustState;
|
|
4
|
+
/** verifyDocument().intact — null when the document is not sealed. */
|
|
5
|
+
intact: boolean | null;
|
|
6
|
+
}
|
|
7
|
+
export declare function TrustBanner({ trust, intact }: TrustBannerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
export declare function DocPropsBar({ source }: {
|
|
9
|
+
source: string;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TrustAction } from "./types";
|
|
2
|
+
interface Props {
|
|
3
|
+
value: string;
|
|
4
|
+
onChange: (source: string) => void;
|
|
5
|
+
theme: string;
|
|
6
|
+
onThemeChange: (theme: string) => void;
|
|
7
|
+
/** Force read-only (sealed documents are read-only regardless). */
|
|
8
|
+
readOnly?: boolean;
|
|
9
|
+
/** Show the formatting ribbon. Default true. */
|
|
10
|
+
showRibbon?: boolean;
|
|
11
|
+
/** Show the trust status banner + document properties strip. Default true. */
|
|
12
|
+
showTrustBanner?: boolean;
|
|
13
|
+
/** Ribbon Trust group (Seal / Sign / Verify). Group is hidden when omitted. */
|
|
14
|
+
onTrustAction?: (action: TrustAction) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function VisualEditor({ value, onChange, theme, onThemeChange, readOnly, showRibbon, showTrustBanner, onTrustAction, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Extension } from "@tiptap/core";
|
|
2
|
+
import type { Editor } from "@tiptap/core";
|
|
3
|
+
/** Core property keys managed by the paragraph-level commands. */
|
|
4
|
+
export type BlockPropKey = "leading" | "space-before" | "space-after" | "end";
|
|
5
|
+
/**
|
|
6
|
+
* Extended Paragraph: a core `text:`/prose block. Adds the four core block
|
|
7
|
+
* properties as attributes and renders the `end:` value as the second side of
|
|
8
|
+
* a flex split row (matching core's `.it-split` / `.it-split-main` CSS).
|
|
9
|
+
*/
|
|
10
|
+
export declare const ITParagraph: import("@tiptap/core").Node<import("@tiptap/extension-paragraph").ParagraphOptions, any>;
|
|
11
|
+
declare module "@tiptap/core" {
|
|
12
|
+
interface Commands<ReturnType> {
|
|
13
|
+
blockProps: {
|
|
14
|
+
/**
|
|
15
|
+
* Set (or clear, with null) a core block property on every block in the
|
|
16
|
+
* current selection that supports it. Writes through to the `.it` source
|
|
17
|
+
* via the bridge — paragraph attrs or the node's `props` JSON.
|
|
18
|
+
*/
|
|
19
|
+
setBlockProp: (key: BlockPropKey, value: string | null) => ReturnType;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export declare const BlockProps: Extension<any, any>;
|
|
24
|
+
/** Read a core block property from the first supporting block in the selection. */
|
|
25
|
+
export declare function getBlockProp(editor: Editor | null, key: BlockPropKey): string | null;
|
package/dist/bridge.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JSONContent } from "@tiptap/core";
|
|
2
|
+
/**
|
|
3
|
+
* Fidelity guard: walk a TipTap doc for mark types the serializer can't represent
|
|
4
|
+
* in `.it` (so they'd be lost on save and wouldn't print through core). Returns the
|
|
5
|
+
* sorted unique unsupported mark types. Normally empty — every toolbar mark is
|
|
6
|
+
* supported and TipTap drops unregistered marks on paste — so this catches
|
|
7
|
+
* regressions (a new mark added without a serializer) rather than everyday use.
|
|
8
|
+
*/
|
|
9
|
+
export declare function detectUnsupportedStyling(node: JSONContent): string[];
|
|
10
|
+
export declare function sourceToDoc(source: string): JSONContent;
|
|
11
|
+
/**
|
|
12
|
+
* Convert TipTap JSON back to IntentText source
|
|
13
|
+
*/
|
|
14
|
+
export declare function docToSource(doc: JSONContent): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Node } from "@tiptap/core";
|
|
2
|
+
export declare const ITTitle: Node<any, any>;
|
|
3
|
+
export declare const ITSummary: Node<any, any>;
|
|
4
|
+
export declare const ITSection: Node<any, any>;
|
|
5
|
+
export declare const ITSub: Node<any, any>;
|
|
6
|
+
export declare const ITCallout: Node<any, any>;
|
|
7
|
+
export declare const ITQuote: Node<any, any>;
|
|
8
|
+
export declare const ITCode: Node<any, any>;
|
|
9
|
+
export declare const ITDivider: Node<any, any>;
|
|
10
|
+
export declare const ITMeta: Node<any, any>;
|
|
11
|
+
export declare const ITTable: Node<any, any>;
|
|
12
|
+
export declare const ITTrust: Node<any, any>;
|
|
13
|
+
export declare const ITMetric: Node<any, any>;
|
|
14
|
+
export declare const ITStyleRule: Node<any, any>;
|
|
15
|
+
export declare const ITBreak: Node<any, any>;
|
|
16
|
+
export declare const ITGenericBlock: Node<any, any>;
|
|
17
|
+
export declare const ITComment: Node<any, any>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Extension } from "@tiptap/core";
|
|
2
|
+
import "@tiptap/extension-text-style";
|
|
3
|
+
declare module "@tiptap/core" {
|
|
4
|
+
interface Commands<ReturnType> {
|
|
5
|
+
fontSize: {
|
|
6
|
+
setFontSize: (size: string) => ReturnType;
|
|
7
|
+
unsetFontSize: () => ReturnType;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export declare const FontSize: Extension<any, any>;
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),u=require("react"),Ht=require("@tiptap/react"),ue=require("@tiptap/starter-kit"),pe=require("@tiptap/extension-placeholder"),fe=require("@tiptap/extension-underline"),ge=require("@tiptap/extension-text-style"),me=require("@tiptap/extension-color"),he=require("@tiptap/extension-highlight"),be=require("@tiptap/extension-text-align"),ye=require("@tiptap/extension-font-family"),xe=require("@tiptap/extension-subscript"),Se=require("@tiptap/extension-superscript"),x=require("@tiptap/core"),yt=require("@tiptap/pm/state"),rt=require("@tiptap/pm/view"),R=require("@dotit/core"),ke=require("@tiptap/extension-paragraph"),v=require("lucide-react"),D=t=>t&&t.__esModule?t:{default:t},we=D(ue),ve=D(pe),Te=D(fe),je=D(me),Ae=D(he),Ce=D(be),Ne=D(ye),Le=D(xe),_e=D(Se),$e=D(ke),Me=x.Extension.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize?.replace(/['"]+/g,"")||null,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),V=96/25.4,mt={A4:[210,297],A5:[148,210],A3:[297,420],Letter:[215.9,279.4],Legal:[215.9,355.6],Tabloid:[279.4,431.8]},ze=20,He=4,Re=120;function Tt(t){const e=/^(-?\d+(?:\.\d+)?)\s*(mm|cm|in|px|pt)?$/.exec(t.trim());if(!e)return null;const n=parseFloat(e[1]);switch(e[2]||"mm"){case"mm":return n*V;case"cm":return n*10*V;case"in":return n*96;case"pt":return n/72*96;case"px":return n;default:return null}}function Ee(t,e){const n=t.trim().split(/\s+/).map(Tt);if(n.some(s=>s===null)||n.length===0)return[e,e,e,e];const r=n;return r.length===1?[r[0],r[0],r[0],r[0]]:r.length===2?[r[0],r[1],r[0],r[1]]:r.length===3?[r[0],r[1],r[2],r[1]]:[r[0],r[1],r[2],r[3]]}function ht(t){let e="A4",n,r="",s="";try{const j=R.parseIntentText(t),k=j.blocks.find(T=>T.type==="page")?.properties||{};k.size&&(e=String(k.size)),n=k.margin??k.margins,r=j.blocks.find(T=>T.type==="header")?.content||String(k.header||""),s=j.blocks.find(T=>T.type==="footer")?.content||String(k.footer||"")}catch{}let l=mt.A4[0]*V,a=mt.A4[1]*V,p=!1;const c=mt[e]||mt[e.toUpperCase?.()];if(c)l=c[0]*V,a=c[1]*V;else{const j=e.trim().split(/\s+/),M=j[0]?Tt(j[0]):null;if(M&&(l=M),j[1]==="auto")p=!0,a=1/0;else{const k=j[1]?Tt(j[1]):null;k&&(a=k)}}const m=(l<=Re*V?He:ze)*V,[f,b,g,S]=n?Ee(n,m):[m,m,m,m];return{width:l,height:a,autoHeight:p,marginTop:f,marginRight:b,marginBottom:g,marginLeft:S,contentHeight:p?1/0:a-f-g,header:r,footer:s}}function Lt(t,e,n){return t.replace(/\{\{\s*page\s*\}\}/g,String(e)).replace(/\{\{\s*pages\s*\}\}/g,String(n))}const dt=new yt.PluginKey("pagination");function St(t,e,n,r){const s=Lt(e,n,r);return`<div class="docs-pb-${t}">
|
|
2
|
+
<span class="docs-pb-text">${Pe(s)}</span>
|
|
3
|
+
</div>`}function Pe(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const Be=x.Extension.create({name:"pagination",addOptions(){return{geometry:()=>({width:794,height:1122.52,autoHeight:!1,marginTop:75.59,marginRight:75.59,marginBottom:75.59,marginLeft:75.59,contentHeight:971.34,header:"",footer:""}),gap:28,onPages:void 0}},addProseMirrorPlugins(){const t=this.options;return[new yt.Plugin({key:dt,state:{init:()=>rt.DecorationSet.empty,apply(e,n){const r=e.getMeta(dt);return r||n.map(e.mapping,e.doc)}},props:{decorations(e){return dt.getState(e)}},view(e){let n=0,r="";const s=(c,m,f,b)=>{const g=document.createElement("div");return g.className="docs-page-spacer",g.contentEditable="false",g.setAttribute("data-it-spacer",""),g.style.setProperty("--pb-mx-l",`${c.marginLeft}px`),g.style.setProperty("--pb-mx-r",`${c.marginRight}px`),g.innerHTML=`
|
|
4
|
+
<div class="docs-pb-fill" style="height:${m}px"></div>
|
|
5
|
+
<div class="docs-pb-margin docs-pb-margin-bottom" style="height:${c.marginBottom}px">
|
|
6
|
+
${St("footer",c.footer,f,b)}
|
|
7
|
+
</div>
|
|
8
|
+
<div class="docs-pb-gap" style="height:${t.gap}px"></div>
|
|
9
|
+
<div class="docs-pb-margin docs-pb-margin-top" style="height:${c.marginTop}px">
|
|
10
|
+
${St("header",c.header,f+1,b)}
|
|
11
|
+
</div>`,g},l=(c,m,f,b)=>{const g=document.createElement("div");return g.className="docs-page-spacer docs-page-tail",g.contentEditable="false",g.setAttribute("data-it-spacer",""),g.style.setProperty("--pb-mx-l",`${c.marginLeft}px`),g.style.setProperty("--pb-mx-r",`${c.marginRight}px`),g.innerHTML=`
|
|
12
|
+
<div class="docs-pb-fill" style="height:${m}px"></div>
|
|
13
|
+
<div class="docs-pb-margin docs-pb-margin-bottom" style="height:${c.marginBottom}px">
|
|
14
|
+
${St("footer",c.footer,f,b)}
|
|
15
|
+
</div>`,g},a=()=>{const c=t.geometry(),m=e.dom,f=e.state.doc;if(c.autoHeight){r!=="auto"&&(r="auto",e.dispatch(e.state.tr.setMeta(dt,rt.DecorationSet.empty)),t.onPages?.(1));return}const b=m.getBoundingClientRect().top,g=Array.from(m.children),S=[];let j=0;for(const $ of g){if($.hasAttribute?.("data-it-spacer")){j+=$.offsetHeight;continue}const H=$.getBoundingClientRect();S.push({natTop:H.top-b-j,natBottom:H.bottom-b-j})}const M=[];let k=0,T=S.length?S[0].natTop:0,Z=T;for(let $=0;$<S.length&&$<f.childCount;$++){const H=S[$],tt=f.child($).nodeSize;H.natTop>T&&H.natBottom-T>c.contentHeight&&(M.push({pos:k,rest:Math.max(0,c.contentHeight-(H.natTop-T))}),T=H.natTop),Z=H.natBottom,k+=tt}const E=M.length+1,F=Math.max(0,c.contentHeight-(Z-T)),q=M.map($=>`${$.pos}:${Math.round($.rest)}`).join(",")+`|${Math.round(F)}|${E}|${c.header}|${c.footer}|${Math.round(c.contentHeight)}`;if(q===r)return;r=q;const I=M.map(($,H)=>rt.Decoration.widget($.pos,()=>s(c,$.rest,H+1,E),{side:-1,key:`pb-${H+1}-${Math.round($.rest)}`}));I.push(rt.Decoration.widget(f.content.size,()=>l(c,F,E,E),{side:1,key:`pb-tail-${E}-${Math.round(F)}`}));const X=rt.DecorationSet.create(e.state.doc,I);e.dispatch(e.state.tr.setMeta(dt,X)),t.onPages?.(E)},p=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(a)};return p(),{update:p,destroy:()=>cancelAnimationFrame(n)}}})]}}),Rt=new Set(["tip","info","warning","danger","success"]),Ie=new Set(["page","meta","font","header","footer","watermark"]),Oe=new Set(["sign","seal","approve","freeze","amend","amendment"]),Et={title:"itTitle",section:"itSection",sub:"itSub"},De={note:"text","body-text":"text"},Fe=new Set(["weight","italic","underline","strike","color","family","size","bg","valign","align","style","font","bgcolor"]);function qe(t){if(!t||t==="{}")return{};try{return typeof t=="string"?JSON.parse(t):t||{}}catch{return{}}}function B(t,e){const n=Object.entries(t).filter(([r,s])=>s!==void 0&&s!==""&&(!e||!e.has(r)));return n.length===0?"":" | "+n.map(([r,s])=>`${r}: ${s}`).join(" | ")}function jt(t){if(!t)return[];const e=t.split("\\n"),n=[];return e.forEach((r,s)=>{r&&n.push({type:"text",text:r}),s<e.length-1&&n.push({type:"hardBreak"})}),n}function We(t){switch(t.type){case"bold":return[{type:"bold"}];case"italic":return[{type:"italic"}];case"strike":return[{type:"strike"}];case"code":return[{type:"code"}];case"highlight":return[{type:"highlight"}];case"styled":{const e=t.props||{},n=[],r={};return e.weight&&e.weight!=="normal"&&n.push({type:"bold"}),e.italic==="true"&&n.push({type:"italic"}),e.underline==="true"&&n.push({type:"underline"}),e.strike==="true"&&n.push({type:"strike"}),e.color&&(r.color=e.color),e.family&&(r.fontFamily=e.family),e.size&&(r.fontSize=e.size),Object.keys(r).length&&n.push({type:"textStyle",attrs:r}),e.bg&&n.push({type:"highlight",attrs:{color:e.bg}}),e.valign==="sub"&&n.push({type:"subscript"}),e.valign==="super"&&n.push({type:"superscript"}),n.length?n:null}default:return null}}const Ge=new Set(["text","bold","italic","strike","highlight","styled"]);function Ue(t,e){if(!t||t.length===0||t.every(r=>r.type==="text")||!t.every(r=>Ge.has(r.type)))return jt(e);const n=[];for(const r of t){const s=We(r),a=(r.value??"").split("\\n");a.forEach((p,c)=>{p&&n.push(s?{type:"text",text:p,marks:s}:{type:"text",text:p}),c<a.length-1&&n.push({type:"hardBreak"})})}return n.length?n:jt(e)}function Ye(t,e){if(!e||t.length===0)return t;const n=[],r={},s=e,l=s.family??s.font,a=s.bg??s.bgcolor;return String(s.weight||"").toLowerCase()==="bold"&&n.push({type:"bold"}),(String(s.italic||"")==="true"||String(s.style||"").toLowerCase()==="italic")&&n.push({type:"italic"}),String(s.underline||"")==="true"&&n.push({type:"underline"}),String(s.strike||"")==="true"&&n.push({type:"strike"}),String(s.valign||"")==="sub"&&n.push({type:"subscript"}),String(s.valign||"")==="super"&&n.push({type:"superscript"}),s.color&&(r.color=String(s.color)),l&&(r.fontFamily=String(l)),s.size&&(r.fontSize=String(s.size)),a&&n.push({type:"highlight",attrs:{color:String(a)}}),Object.keys(r).length>0&&n.push({type:"textStyle",attrs:r}),n.length===0?t:t.map(p=>p.type==="text"?{...p,marks:[...p.marks||[],...n]}:p)}function Ut(t){const e={};for(const n of t||[])switch(n.type){case"bold":e.weight="bold";break;case"italic":e.italic="true";break;case"underline":e.underline="true";break;case"strike":e.strike="true";break;case"textStyle":n.attrs?.color&&(e.color=String(n.attrs.color)),n.attrs?.fontFamily&&(e.family=String(n.attrs.fontFamily)),n.attrs?.fontSize&&(e.size=String(n.attrs.fontSize));break;case"highlight":n.attrs?.color&&(e.bg=String(n.attrs.color));break;case"subscript":e.valign="sub";break;case"superscript":e.valign="super";break}return e}function Ke(t){if(t.type==="hardBreak")return"\\n";if(t.type!=="text")return _t(t);const e=t.text||"";if(!e)return"";const n=t.marks||[];if(!n.length)return e;const r=new Set(n.map(b=>b.type)),s=n.find(b=>b.type==="link");if(s?.attrs?.href)return`[${e}](${s.attrs.href})`;const l=n.find(b=>b.type==="textStyle")?.attrs||{},a=n.find(b=>b.type==="highlight")?.attrs||{},p=!!(l.color||l.fontFamily||l.fontSize||a.color),c=["bold","italic","strike","underline","code"].filter(b=>r.has(b)).length;if(!p&&c===1&&!r.has("underline")){if(r.has("bold"))return`*${e}*`;if(r.has("italic"))return`_${e}_`;if(r.has("strike"))return`~${e}~`;if(r.has("code"))return`\`${e}\``}if(!p&&c===0&&r.has("highlight")&&!a.color)return`^${e}^`;const m=Ut(n),f=[];return m.color&&f.push(`color: ${m.color}`),m.family&&f.push(`family: ${m.family}`),m.size&&f.push(`size: ${m.size}`),m.weight&&f.push(`weight: ${m.weight}`),m.italic==="true"&&f.push("italic: true"),m.underline&&f.push("underline: true"),m.strike&&f.push("strike: true"),m.bg&&f.push(`bg: ${m.bg}`),m.valign&&f.push(`valign: ${m.valign}`),f.length?`[${e}]{ ${f.join("; ")} }`:e}const Je=new Set(["bold","italic","underline","strike","code","highlight","textStyle","link","subscript","superscript"]);function Ve(t){const e=new Set,n=r=>{for(const s of r.marks||[])Je.has(s.type)||e.add(s.type);for(const s of r.content||[])n(s)};return n(t),[...e].sort()}function At(t){const e=t.content||[],n=t.attrs?.textAlign&&t.attrs.textAlign!=="left"?{align:String(t.attrs.textAlign)}:{};return e.length===1&&e[0].type==="text"?{text:e[0].text||"",props:{...Ut(e[0].marks),...n}}:{text:e.map(Ke).join(""),props:{...n}}}function _t(t){return t.content?t.content.map(e=>e.type==="text"?e.text||"":e.type==="hardBreak"?"\\n":_t(e)).join(""):""}function nt(t,e,n){const r=qe(t);for(const s of Fe)delete r[s];if(n)for(const s of n)delete r[s];return{...r,...e}}function $t(t){const e=t.toLowerCase();return De[e]||e}function Pt(t){if(t==="---")return"divider";const e=t.match(/^([a-zA-Z][\w-]*):/);return e?$t(e[1]):null}function ot(t){return $t(t)}function it(t,e){return!!(t===e||t==="info"&&["tip","warning","danger","success"].includes(e)||e==="info"&&["tip","warning","danger","success"].includes(t))}function Qe(t){if(!t)return{content:"",properties:{}};const e=t.split(" | ");let n=e[0]||"";const r={};for(let s=1;s<e.length;s++){const l=e[s],a=l.match(/^([a-zA-Z_][\w-]*)\s*:\s*(.*)$/);if(!a){n+=` | ${l}`;continue}r[a[1]]=a[2]}return{content:n,properties:r}}function Bt(t){if(t==="---")return{type:"divider"};const e=t.match(/^([a-zA-Z][\w-]*):\s*(.*)$/);if(!e)return null;const n=$t(e[1]),r=e[2]||"",{content:s,properties:l}=Qe(r);let a;try{a=R.parseIntentText(`text: ${s}`).blocks[0]?.inline}catch{a=void 0}return{type:n,content:s,properties:l,inline:a}}function It(t){const e=t.match(/^[-*]\s+(.*)$/);if(e)return{ordered:!1,text:e[1]};const n=t.match(/^\d+\.\s+(.*)$/);return n?{ordered:!0,text:n[1]}:null}function Ze(t){return{type:"listItem",content:[{type:"paragraph",content:jt(t)}]}}function Ct(t){if(!t.trim())return{type:"doc",content:[{type:"paragraph"}]};const e=R.parseIntentText(t),n=[];for(const a of e.blocks){const p=kt(a);p&&n.push(p)}const r=t.split(`
|
|
16
|
+
`);let s=0;const l=[];for(let a=0;a<r.length;a++){const c=r[a].trim();if(!c)continue;{const g=Pt(c);if(g&&Ie.has(g)){l.push({type:"itMeta",attrs:{raw:c}});const S=e.blocks[s]?.type;S&&it(g,ot(S))&&s++;continue}if(g&&Oe.has(g)){l.push({type:"itTrust",attrs:{raw:c,keyword:g}});const S=e.blocks[s]?.type;S&&it(g,ot(S))&&s++;continue}if(g==="metric"){l.push({type:"itMetric",attrs:{raw:c}});const S=e.blocks[s]?.type;S&&it(g,ot(S))&&s++;continue}if(g==="style"){l.push({type:"itStyleRule",attrs:{raw:c}});const S=e.blocks[s]?.type;S&&it(g,ot(S))&&s++;continue}}const m=It(c);if(m){const g=m.ordered,S=[];let j=a;for(;j<r.length;){const M=r[j].trim(),k=M?It(M):null;if(!k||k.ordered!==g)break;S.push(Ze(k.text));const T=e.blocks[s]?.type;(T==="list-item"||T==="step-item")&&s++,j++}l.push({type:g?"orderedList":"bulletList",content:S}),a=j-1;continue}if(c.startsWith("|")&&c.endsWith("|")&&(c.match(/\|/g)||[]).length>=3){const g=[];let S=a;for(;S<r.length;){const j=r[S].trim();if(!(j.startsWith("|")&&j.endsWith("|")))break;g.push(j.slice(1,-1).split("|").map(M=>M.trim())),S++}l.push({type:"itTable",attrs:{rows:JSON.stringify(g)}}),a=S-1;continue}if(c.startsWith("//")){l.push({type:"itComment",content:c.slice(2).trim()?[{type:"text",text:c.slice(2).trim()}]:[]});continue}if(c.startsWith("```"))continue;const f=Pt(c);if(f&&(f==="text"||c.includes("{{"))){const g=Bt(c);if(g){const S=kt(g);if(S&&l.push(S),s<e.blocks.length){const j=ot(e.blocks[s].type);it(f,j)&&s++}continue}}if(s<n.length&&f){const g=e.blocks[s],S=ot(g.type);if(it(f,S)){l.push(n[s]),s++;continue}}const b=Bt(c);if(b){const g=kt(b);g&&l.push(g);continue}s<n.length&&(l.push(n[s]),s++)}for(;s<n.length;)l.push(n[s]),s++;return{type:"doc",content:l.length>0?l:[{type:"paragraph"}]}}function kt(t){const{type:e,content:n,properties:r,inline:s}=t,l=n||"";let a=Ue(s,l);a=Ye(a,r);const p=r?JSON.stringify(Object.fromEntries(Object.entries(r).map(([f,b])=>[f,String(b)]))):"{}",c=r?.align?String(r.align):void 0;if(e in Et)return{type:Et[e],attrs:{props:p,...c&&{textAlign:c}},content:a.length?a:void 0};if(e==="summary")return{type:"itSummary",attrs:{props:p,...c&&{textAlign:c}},content:a.length?a:void 0};if(e==="text"||e==="body-text"){const f={};return c&&(f.textAlign=c),r?.end&&(f.end=String(r.end)),r?.leading&&(f.leading=String(r.leading)),r?.["space-before"]&&(f.spaceBefore=String(r["space-before"])),r?.["space-after"]&&(f.spaceAfter=String(r["space-after"])),{type:"paragraph",...Object.keys(f).length&&{attrs:f},content:a.length?a:void 0}}if(Rt.has(e)){const f=e==="info"?String(r?.type||"info").toLowerCase():e;return{type:"itCallout",attrs:{variant:Rt.has(f)?f:"info",props:p},content:a.length?a:void 0}}if(e==="quote")return{type:"itQuote",attrs:{by:r?.by?String(r.by):"",props:p,...c&&{textAlign:c}},content:a.length?a:void 0};if(e==="code")return{type:"itCode",attrs:{lang:r?.lang?String(r.lang):"",props:p},content:l?[{type:"text",text:l}]:void 0};if(e==="divider")return{type:"itDivider"};if(e==="break")return{type:"itBreak"};const m=r?Object.entries(r).filter(([,f])=>f!==void 0&&f!=="").map(([f,b])=>`${f}: ${b}`).join(" | "):"";return{type:"itGenericBlock",attrs:{keyword:e,properties:m,props:p},content:a.length?a:void 0}}function Yt(t){if(!t.content)return"";const e=[];for(const n of t.content)e.push(...Xe(n));return e.join(`
|
|
17
|
+
`)}function Xe(t){if(t.type==="bulletList"&&t.content)return t.content.flatMap(n=>n.content?n.content.map(r=>{const{text:s,props:l}=At(r);return`- ${s}${B(l)}`}):[]);if(t.type==="orderedList"&&t.content){let n=1;return t.content.flatMap(r=>r.content?r.content.map(s=>{const{text:l,props:a}=At(s);return`${n++}. ${l}${B(a)}`}):[])}const e=tn(t);return e!==null?[e]:[]}function tn(t){const{text:e,props:n}=At(t);switch(t.type){case"itTitle":{const r=nt(t.attrs?.props,n);return`title: ${e}${B(r)}`}case"itSummary":{const r=nt(t.attrs?.props,n);return`summary: ${e}${B(r)}`}case"itSection":{const r=nt(t.attrs?.props,n);return`section: ${e}${B(r)}`}case"itSub":{const r=nt(t.attrs?.props,n);return`sub: ${e}${B(r)}`}case"paragraph":{const r=t.attrs||{},s={};return r.end&&(s.end=String(r.end)),r.leading&&(s.leading=String(r.leading)),r.spaceBefore&&(s["space-before"]=String(r.spaceBefore)),r.spaceAfter&&(s["space-after"]=String(r.spaceAfter)),`text: ${e}${B({...s,...n})}`}case"itCallout":{const r=t.attrs?.variant||"tip",s=nt(t.attrs?.props,n,new Set(["variant"]));return r==="info"?`info: ${e}${B(s)}`:`info: ${e} | type: ${r}${B(s,new Set(["type"]))}`}case"itQuote":{const r=t.attrs?.by,s=r?` | by: ${r}`:"",l=nt(t.attrs?.props,n,new Set(["by"]));return`quote: ${e}${s}${B(l)}`}case"itCode":return`\`\`\`${t.attrs?.lang||""}
|
|
18
|
+
${_t(t)}
|
|
19
|
+
\`\`\``;case"itDivider":return"divider:";case"itTable":{let r=[];try{r=JSON.parse(t.attrs?.rows||"[]")}catch{r=[]}return r.map(s=>`| ${s.join(" | ")} |`).join(`
|
|
20
|
+
`)}case"itMeta":return t.attrs?.raw||"";case"itTrust":return t.attrs?.raw||"";case"itMetric":return t.attrs?.raw||"";case"itStyleRule":return t.attrs?.raw||"";case"itBreak":return"break:";case"itComment":return e?`// ${e}`:"//";case"itGenericBlock":{const r=t.attrs?.keyword||"text",s=nt(t.attrs?.props,n);return`${r}: ${e}${B(s)}`}default:return e?`text: ${e}${B(n)}`:null}}function i(t,e){return{property:t,css:e}}const en=[i("align","textAlign"),i("color","color"),i("size","fontSize"),i("weight","fontWeight"),{property:"style",css:"fontStyle"},i("bgcolor","backgroundColor"),i("padding","padding"),i("indent","paddingLeft"),i("opacity","opacity")],ut=[i("bgcolor","backgroundColor"),i("color","color"),i("border","borderLeft")],L=[i("color","borderColor"),i("bgcolor","backgroundColor")],nn={title:[i("align","textAlign"),i("color","color"),i("size","fontSize"),i("weight","fontWeight"),i("font","fontFamily")],summary:[i("align","textAlign"),i("color","color"),i("size","fontSize"),{property:"style",css:"fontStyle"}],section:[i("align","textAlign"),i("color","color"),i("size","fontSize"),i("weight","fontWeight"),i("border","borderBottom"),i("spacing","marginTop")],sub:[i("align","textAlign"),i("color","color"),i("size","fontSize"),i("weight","fontWeight")],divider:[{property:"style",css:"borderStyle"},i("color","borderColor"),i("width","borderTopWidth"),i("spacing","margin")],text:[...en],tip:[...ut],info:[...ut],warning:[...ut],danger:[...ut],success:[...ut],quote:[i("align","textAlign"),i("color","color"),i("size","fontSize"),{property:"style",css:"fontStyle"},i("border","borderLeft"),i("padding","paddingLeft"),i("bgcolor","backgroundColor")],cite:[i("align","textAlign"),i("color","color"),i("size","fontSize"),{property:"style",css:"fontStyle"}],def:[i("color","color"),i("bgcolor","backgroundColor"),i("border","borderLeft"),i("padding","paddingLeft")],caption:[i("align","textAlign"),i("color","color"),i("size","fontSize"),{property:"style",css:"fontStyle"}],footnote:[i("color","color"),i("size","fontSize")],byline:[i("align","textAlign"),i("color","color"),i("size","fontSize"),{property:"style",css:"fontStyle"},i("weight","fontWeight")],epigraph:[i("align","textAlign"),i("color","color"),i("size","fontSize"),{property:"style",css:"fontStyle"},i("padding","padding")],dedication:[i("align","textAlign"),i("color","color"),{property:"style",css:"fontStyle"},i("padding","padding")],image:[i("width","width"),i("height","height"),i("radius","borderRadius"),i("border","border"),i("opacity","opacity"),i("bgcolor","backgroundColor"),{property:"shadow",css:"boxShadow",transform:()=>"0 4px 12px rgba(0,0,0,0.15)"}],figure:[i("width","width"),i("align","textAlign"),i("border","border"),i("padding","padding"),i("bgcolor","backgroundColor"),{property:"shadow",css:"boxShadow",transform:()=>"0 4px 12px rgba(0,0,0,0.15)"}],link:[i("color","color"),i("weight","fontWeight")],ref:[i("color","color"),{property:"style",css:"fontStyle"}],embed:[i("width","width"),i("height","height"),i("border","border"),i("radius","borderRadius")],metric:[i("color","color"),i("size","fontSize"),i("align","textAlign"),i("bgcolor","backgroundColor"),i("border","border"),i("padding","padding")],columns:[i("border","border"),i("bgcolor","backgroundColor"),i("padding","padding"),i("size","fontSize"),i("align","textAlign")],row:[i("border","border"),i("bgcolor","backgroundColor"),i("padding","padding"),i("size","fontSize"),i("align","textAlign")],input:[i("color","color"),i("bgcolor","backgroundColor"),i("border","borderLeft"),i("size","fontSize")],output:[i("color","color"),i("bgcolor","backgroundColor"),i("border","borderLeft"),i("size","fontSize")],code:[i("size","fontSize"),i("bgcolor","backgroundColor"),i("color","color"),i("padding","padding"),i("radius","borderRadius"),i("border","border")],contact:[i("color","color"),i("bgcolor","backgroundColor"),i("border","border"),i("padding","padding"),i("size","fontSize")],deadline:[i("color","color"),i("bgcolor","backgroundColor"),i("weight","fontWeight"),i("size","fontSize")],step:[...L],decision:[...L],gate:[...L],trigger:[...L],loop:[...L],parallel:[...L],call:[...L],wait:[...L],checkpoint:[...L],error:[...L],result:[...L],audit:[...L],signal:[...L],handoff:[...L],retry:[...L],progress:[...L],tool:[...L],prompt:[...L],memory:[...L],policy:[...L],context:[...L],track:[...L],approve:[...L],sign:[...L],freeze:[...L],revision:[...L],amendment:[...L],history:[i("color","borderColor")],assert:[i("color","borderColor"),i("bgcolor","backgroundColor"),i("border","borderLeft")],secret:[i("color","color"),i("bgcolor","backgroundColor"),i("blur","filter")],watermark:[i("color","color"),i("size","fontSize"),i("opacity","opacity")],signline:[i("color","color"),i("width","width")]};function rn(t,e){const n=nn[t];if(!n)return{};const r={};for(const s of n){const l=e[s.property];l&&(s.transform?r[s.css]=s.transform(l):r[s.css]=l)}return r}function G(t,e){const n=rn(t,e);return e.leading&&(n.lineHeight=e.leading),e["space-before"]&&(n.marginTop=e["space-before"]),e["space-after"]&&(n.marginBottom=e["space-after"]),Object.entries(n).map(([r,s])=>`${r.replace(/([A-Z])/g,"-$1").toLowerCase()}:${s}`).join(";")}function Mt(t){return t.end?{"data-it-end":t.end}:{}}const sn=x.Node.create({name:"itTitle",group:"block",content:"inline*",defining:!0,addAttributes(){return{props:{default:"{}",parseHTML:t=>t.getAttribute("data-props")||"{}"}}},parseHTML(){return[{tag:'h1[data-it-type="title"]'}]},renderHTML({HTMLAttributes:t,node:e}){const n=Q(e.attrs.props),r=x.mergeAttributes(t,{"data-it-type":"title",class:"it-doc-title",style:G("title",n),...Mt(n)});return n.end?["h1",r,["span",{class:"it-split-main"},0]]:["h1",r,0]}}),on=x.Node.create({name:"itSummary",group:"block",content:"inline*",defining:!0,addAttributes(){return{props:{default:"{}"}}},parseHTML(){return[{tag:'p[data-it-type="summary"]'}]},renderHTML({HTMLAttributes:t,node:e}){const n=Q(e.attrs.props);return["p",x.mergeAttributes(t,{"data-it-type":"summary",class:"it-doc-summary",style:G("summary",n)}),0]}}),an=x.Node.create({name:"itSection",group:"block",content:"inline*",defining:!0,addAttributes(){return{props:{default:"{}"}}},parseHTML(){return[{tag:'h2[data-it-type="section"]'}]},renderHTML({HTMLAttributes:t,node:e}){const n=Q(e.attrs.props),r=x.mergeAttributes(t,{"data-it-type":"section",class:"it-doc-section",style:G("section",n),...Mt(n)});return n.end?["h2",r,["span",{class:"it-split-main"},0]]:["h2",r,0]}}),cn=x.Node.create({name:"itSub",group:"block",content:"inline*",defining:!0,addAttributes(){return{props:{default:"{}"}}},parseHTML(){return[{tag:'h3[data-it-type="sub"]'}]},renderHTML({HTMLAttributes:t,node:e}){const n=Q(e.attrs.props),r=x.mergeAttributes(t,{"data-it-type":"sub",class:"it-doc-sub",style:G("sub",n),...Mt(n)});return n.end?["h3",r,["span",{class:"it-split-main"},0]]:["h3",r,0]}}),ln=x.Node.create({name:"itCallout",group:"block",content:"inline*",defining:!0,addAttributes(){return{variant:{default:"tip",parseHTML:t=>t.getAttribute("data-variant")||"tip",renderHTML:t=>({"data-variant":t.variant})},props:{default:"{}"}}},parseHTML(){return[{tag:'div[data-it-type="callout"]'}]},renderHTML({HTMLAttributes:t,node:e}){const n=e.attrs.variant||"tip",r=Q(e.attrs.props),s={tip:"tip",info:"info",warning:"warning",danger:"danger",success:"success"};return["div",x.mergeAttributes(t,{"data-it-type":"callout","data-variant":n,class:`it-doc-callout it-doc-callout-${n}`,style:G(n,r)}),["span",{class:`it-doc-callout-icon it-doc-callout-icon-${s[n]||"tip"}`,contenteditable:"false"},""],["span",{class:"it-doc-callout-text"},0]]}}),dn=x.Node.create({name:"itQuote",group:"block",content:"inline*",defining:!0,addAttributes(){return{by:{default:""},props:{default:"{}"}}},parseHTML(){return[{tag:'blockquote[data-it-type="quote"]'}]},renderHTML({HTMLAttributes:t,node:e}){const n=Q(e.attrs.props);return["blockquote",x.mergeAttributes(t,{"data-it-type":"quote",class:"it-doc-quote",style:G("quote",n)}),0]}}),un=x.Node.create({name:"itCode",group:"block",content:"text*",marks:"",code:!0,defining:!0,addAttributes(){return{lang:{default:""},props:{default:"{}"}}},parseHTML(){return[{tag:"pre"}]},renderHTML({HTMLAttributes:t,node:e}){const n=Q(e.attrs.props);return["pre",x.mergeAttributes(t,{"data-it-type":"code",class:"it-doc-code","data-lang":e.attrs.lang||"",style:G("code",n)}),["code",0]]}}),pn=x.Node.create({name:"itDivider",group:"block",atom:!0,parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",x.mergeAttributes(t,{class:"it-doc-divider"})]}}),fn=x.Node.create({name:"itMeta",group:"block",atom:!0,addAttributes(){return{raw:{default:"",parseHTML:t=>t.getAttribute("data-raw")||"",renderHTML:t=>({"data-raw":t.raw})}}},parseHTML(){return[{tag:"div[data-it-meta]"}]},renderHTML({HTMLAttributes:t,node:e}){const n=String(e.attrs.raw||"").replace(/\s*\|\s*/g," · ");return["div",x.mergeAttributes(t,{"data-it-meta":"",class:"it-doc-meta"}),`⚙ ${n}`]}}),gn=x.Node.create({name:"itTable",group:"block",atom:!0,addAttributes(){return{rows:{default:"[]",parseHTML:t=>t.getAttribute("data-rows")||"[]",renderHTML:t=>({"data-rows":t.rows})}}},parseHTML(){return[{tag:"table[data-it-table]"}]},renderHTML({HTMLAttributes:t,node:e}){let n=[];try{n=JSON.parse(e.attrs.rows||"[]")}catch{n=[]}const r=n[0]||[],s=n.slice(1);return["table",x.mergeAttributes(t,{"data-it-table":"",class:"it-doc-table"}),["thead",["tr",...r.map(l=>["th",Ot(l),String(l)])]],["tbody",...s.map(l=>["tr",...l.map(a=>["td",Ot(a),String(a)])])]]}});function Ot(t){return/\{\{[^}]+\}\}|^each:/.test(String(t).trim())?{class:"it-doc-var-cell"}:{}}function zt(t){const e=t.indexOf(":"),n=(e>=0?t.slice(0,e):t).trim().toLowerCase(),s=(e>=0?t.slice(e+1).trim():"").split("|").map(p=>p.trim()),l=s.shift()||"",a={};for(const p of s){const c=p.indexOf(":");c>0&&(a[p.slice(0,c).trim().toLowerCase()]=p.slice(c+1).trim())}return{keyword:n,content:l,props:a}}const mn=x.Node.create({name:"itTrust",group:"block",atom:!0,addAttributes(){return{raw:{default:"",parseHTML:t=>t.getAttribute("data-raw")||"",renderHTML:t=>({"data-raw":t.raw})},keyword:{default:"",parseHTML:t=>t.getAttribute("data-trust")||"",renderHTML:t=>({"data-trust":t.keyword})}}},parseHTML(){return[{tag:"div[data-it-trust]"}]},renderHTML({HTMLAttributes:t,node:e}){const{keyword:n,content:r,props:s}=zt(String(e.attrs.raw||"")),l=s.role||s.title||"",a=s.at||s.date||s.time||"",p=[];if(n==="seal"){const c=r||s.hash||"",m=s.algo||"sha-256";p.push(["span",{class:"it-doc-trust__icon"},"🔒"],["span",{class:"it-doc-trust__label"},"Sealed"],["span",{class:"it-doc-trust__meta"},m],...c?[["code",{class:"it-doc-trust__hash"},c.slice(0,16)+"…"]]:[])}else if(n==="approve")p.push(["span",{class:"it-doc-trust__icon"},"✓"],["span",{class:"it-doc-trust__label"},"Approved"],["span",{class:"it-doc-trust__name"},r],...l?[["span",{class:"it-doc-trust__role"},l]]:[],...a?[["span",{class:"it-doc-trust__date"},a]]:[]);else if(n==="freeze")p.push(["span",{class:"it-doc-trust__icon"},"❄"],["span",{class:"it-doc-trust__label"},"Frozen"],...r?[["span",{class:"it-doc-trust__name"},r]]:[],...a?[["span",{class:"it-doc-trust__date"},a]]:[]);else if(n==="amend"||n==="amendment")p.push(["span",{class:"it-doc-trust__icon"},"✎"],["span",{class:"it-doc-trust__label"},"Amendment"],["span",{class:"it-doc-trust__name"},r],...a?[["span",{class:"it-doc-trust__date"},a]]:[]);else return["div",x.mergeAttributes(t,{"data-it-trust":"","data-trust":n,class:"it-doc-trust it-doc-sign"}),["div",{class:"it-doc-sign__script"},r||" "],["div",{class:"it-doc-sign__rule"}],["div",{class:"it-doc-sign__row"},["span",{class:"it-doc-sign__name"},r],...l?[["span",{class:"it-doc-sign__role"},l]]:[],...a?[["span",{class:"it-doc-sign__date"},a]]:[]]];return["div",x.mergeAttributes(t,{"data-it-trust":"","data-trust":n,class:`it-doc-trust it-doc-trust--${n}`}),...p]}}),hn=x.Node.create({name:"itMetric",group:"block",atom:!0,addAttributes(){return{raw:{default:"",parseHTML:t=>t.getAttribute("data-raw")||"",renderHTML:t=>({"data-raw":t.raw})}}},parseHTML(){return[{tag:"div[data-it-metric]"}]},renderHTML({HTMLAttributes:t,node:e}){const{content:n,props:r}=zt(String(e.attrs.raw||"")),s=[r.value,r.unit].filter(Boolean).join(" "),l=/\b(total|balance due|amount due|grand)\b/i.test(n),a=/\{\{[^}]+\}\}/.test(s);return["div",x.mergeAttributes(t,{"data-it-metric":"",class:`it-doc-metric${l?" it-doc-metric--total":""}`}),["span",{class:"it-doc-metric__label"},n],["span",{class:`it-doc-metric__value${a?" it-doc-var":""}`},s]]}}),bn=x.Node.create({name:"itStyleRule",group:"block",atom:!0,addAttributes(){return{raw:{default:"",parseHTML:t=>t.getAttribute("data-raw")||"",renderHTML:t=>({"data-raw":t.raw})}}},parseHTML(){return[{tag:"div[data-it-style-rule]"}]},renderHTML({HTMLAttributes:t,node:e}){const{content:n,props:r}=zt(String(e.attrs.raw||"")),s=Object.entries(r).map(([l,a])=>`${l}: ${a}`).join(" · ");return["div",x.mergeAttributes(t,{"data-it-style-rule":"",class:"it-doc-stylerule"}),["span",{class:"it-doc-stylerule__icon"},"🎨"],["span",{class:"it-doc-stylerule__target"},n||"?"],["span",{class:"it-doc-stylerule__decl"},s]]}}),yn=x.Node.create({name:"itBreak",group:"block",atom:!0,parseHTML(){return[{tag:'div[data-it-type="break"]'}]},renderHTML({HTMLAttributes:t}){return["div",x.mergeAttributes(t,{"data-it-type":"break",class:"it-doc-break"})]}}),xn=x.Node.create({name:"itGenericBlock",group:"block",content:"inline*",defining:!0,addAttributes(){return{keyword:{default:"text"},properties:{default:""},props:{default:"{}"}}},parseHTML(){return[{tag:'[data-it-type="generic"]'}]},renderHTML({HTMLAttributes:t,node:e}){const n=e.attrs.keyword,r=Q(e.attrs.props),s=String(r.to||r.url||r.href||r.file||"").trim();return(n==="link"||n==="ref")&&s?["p",x.mergeAttributes(t,{"data-it-type":"generic","data-keyword":n,class:`it-doc-generic it-doc-kw-${n}`,style:G(n,r)}),["a",{class:"it-doc-inline-link",href:s,target:"_blank",rel:"noopener noreferrer"},0]]:["p",x.mergeAttributes(t,{"data-it-type":"generic","data-keyword":n,class:`it-doc-generic it-doc-kw-${n}`,style:G(n,r)}),["span",{class:"it-doc-generic-content"},0]]}}),Sn=x.Node.create({name:"itComment",group:"block",content:"inline*",defining:!0,parseHTML(){return[{tag:'p[data-it-type="comment"]'}]},renderHTML({HTMLAttributes:t}){return["p",x.mergeAttributes(t,{"data-it-type":"comment",class:"it-doc-comment"}),0]}});function Q(t){try{return typeof t=="string"?JSON.parse(t):t||{}}catch{return{}}}const Kt={leading:"leading","space-before":"spaceBefore","space-after":"spaceAfter",end:"end"},kn=new Set(["itTitle","itSummary","itSection","itSub","itQuote","itCallout","itGenericBlock"]),wn=new Set(["itTitle","itSection","itSub"]);function Jt(t){try{return typeof t=="string"?JSON.parse(t):t||{}}catch{return{}}}function Vt(t,e){return t==="paragraph"?!0:e==="end"?wn.has(t):kn.has(t)}const vn=$e.default.extend({addAttributes(){return{...this.parent?.(),leading:{default:null,parseHTML:t=>t.style.lineHeight||null,renderHTML:t=>t.leading?{style:`line-height: ${t.leading}`}:{}},spaceBefore:{default:null,parseHTML:t=>t.style.marginTop||null,renderHTML:t=>t.spaceBefore?{style:`margin-top: ${t.spaceBefore}`}:{}},spaceAfter:{default:null,parseHTML:t=>t.style.marginBottom||null,renderHTML:t=>t.spaceAfter?{style:`margin-bottom: ${t.spaceAfter}`}:{}},end:{default:null,parseHTML:t=>t.getAttribute("data-it-end"),renderHTML:t=>t.end?{"data-it-end":t.end}:{}}}},renderHTML({node:t,HTMLAttributes:e}){return t.attrs.end?["p",x.mergeAttributes(e),["span",{class:"it-split-main"},0]]:["p",x.mergeAttributes(e),0]}}),Tn=x.Extension.create({name:"blockProps",addCommands(){return{setBlockProp:(t,e)=>({state:n,tr:r,dispatch:s})=>{const{from:l,to:a}=n.selection;let p=!1;return n.doc.nodesBetween(l,a,(c,m)=>{const f=c.type.name;if(f==="bulletList"||f==="orderedList"||!c.isBlock||c.isAtom)return!1;if(!Vt(f,t))return!0;if(f==="paragraph")r.setNodeMarkup(m,void 0,{...c.attrs,[Kt[t]]:e});else{const b=Jt(c.attrs.props);e==null||e===""?delete b[t]:b[t]=e,r.setNodeMarkup(m,void 0,{...c.attrs,props:JSON.stringify(b)})}return p=!0,!1}),p&&s&&s(r),p}}}});function J(t,e){if(!t)return null;const{state:n}=t,{from:r,to:s}=n.selection;let l=null;return n.doc.nodesBetween(r,s,a=>{if(l!==null)return!1;const p=a.type.name;if(!Vt(p,e))return!0;if(p==="paragraph"){const c=a.attrs[Kt[e]];l=c!=null?String(c):""}else l=Jt(a.attrs.props)[e]??"";return!1}),l}const Dt={identity:{label:"Identity",icon:"ID",color:"#3b82f6"},content:{label:"Content",icon:"Tx",color:"#6b7280"},structure:{label:"Structure",icon:"##",color:"#22c55e"},data:{label:"Data",icon:"Dt",color:"#a855f7"},agent:{label:"Agent",icon:"Ag",color:"#f97316"},trust:{label:"Trust",icon:"Tr",color:"#eab308"},layout:{label:"Layout",icon:"Pg",color:"#64748b"}};function Qt(t){const e=document.createElement("iframe");e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;right:0;bottom:0;width:210mm;height:297mm;border:0;visibility:hidden;",document.body.appendChild(e);let n=!1;const r=()=>{if(!n){n=!0;try{e.contentWindow.focus(),e.contentWindow.print()}finally{setTimeout(()=>e.remove(),1e3)}}};e.onload=()=>window.setTimeout(r,120);const s=e.contentWindow.document;s.open(),s.write(t),s.close(),s.readyState==="complete"&&window.setTimeout(r,250)}function jn(t,e){return t.includes("</head>")?t.replace("</head>",`<style>${e}</style></head>`):t}const Zt=".it-doc-callout{background:none!important;border:1px solid #ccc!important}",Ft=R.cssContentValue;function An(t,e){const n=document.querySelector(".docs-page .tiptap");if(!n)return null;const r=n.cloneNode(!0);r.querySelectorAll("[data-it-spacer]").forEach(b=>b.remove());const s=r.innerHTML,l=Array.from(document.querySelectorAll('style, link[rel="stylesheet"]')).map(b=>b.outerHTML).join(`
|
|
21
|
+
`),a=ht(t),p=a.autoHeight?`${a.width}px auto`:`${a.width}px ${a.height}px`,c=`${a.marginTop}px ${a.marginRight}px ${a.marginBottom}px ${a.marginLeft}px`;let m=`@page{size:${p};margin:${c};}`;a.header&&(m+=`@page{@top-center{content:${Ft(a.header)};font:10px -apple-system,sans-serif;color:#9aa0a6;}}`),a.footer&&(m+=`@page{@bottom-center{content:${Ft(a.footer)};font:10px -apple-system,sans-serif;color:#9aa0a6;}}`);const f=`
|
|
22
|
+
html,body{margin:0;background:#fff;}
|
|
23
|
+
.docs-page,.docs-page.docs-sheet{box-shadow:none;border-radius:0;margin:0;width:auto;min-height:0;padding:0;background:#fff;}
|
|
24
|
+
.docs-page .tiptap{padding:0;}
|
|
25
|
+
[data-it-spacer]{display:none!important;}
|
|
26
|
+
${e==="minimal-ink"?Zt:""}
|
|
27
|
+
`;return`<!doctype html><html><head><meta charset="utf-8">${l}<style>${m}${f}</style></head><body><div class="docs-page docs-sheet"><div class="tiptap">${s}</div></div></body></html>`}function Cn(t,e,n){const r=new Blob([t],{type:n}),s=URL.createObjectURL(r),l=document.createElement("a");l.href=s,l.download=e,l.click(),URL.revokeObjectURL(s)}function Xt(t,e,n){let r=An(t,n);if(!r){const s=R.parseIntentText(t);r=R.renderPrint(s,{theme:e}),n==="minimal-ink"&&(r=jn(r,Zt))}return r}function te(t,e,n="normal"){try{Qt(Xt(t,e,n))}catch{}}function ee(t,e,n="normal"){try{Cn(Xt(t,e,n),"document.html","text/html")}catch{}}function ne(){return R.listBuiltinThemes()}const wt=[{label:"Normal text",node:"paragraph"},{label:"Title",node:"itTitle"},{label:"Section",node:"itSection"},{label:"Subsection",node:"itSub"},{label:"Summary",node:"itSummary"},{label:"Quote",node:"itQuote"}],Nn=new Set(["history","revision","track","freeze"]),Ln=new Set(["agent","model","meta","context","history"]),_n=["identity","structure","content","data","trust","layout"],qt=[{label:"Default",value:""},{label:"Inter",value:"Inter"},{label:"Arial",value:"Arial"},{label:"Times New Roman",value:"Times New Roman"},{label:"Georgia",value:"Georgia"},{label:"Courier New",value:"Courier New"},{label:"Verdana",value:"Verdana"},{label:"Trebuchet MS",value:"Trebuchet MS"}],$n=["1","1.15","1.5","2","2.5","3"],Mn="12px",zn=["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#efefef","#f3f3f3","#ffffff","#980000","#ff0000","#ff9900","#ffff00","#00ff00","#00ffff","#4a86e8","#0000ff","#9900ff","#ff00ff","#e6b8af","#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#c9daf8","#cfe2f3","#d9d2e9","#ead1dc","#dd7e6b","#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#a4c2f4","#9fc5e8","#b4a7d6","#d5a6bd","#cc4125","#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6d9eeb","#6fa8dc","#8e7cc3","#c27ba0"],Hn=["#ffffff","#cfe2f3","#d9ead3","#fff2cc","#fce5cd","#f4cccc","#d9d2e9","#ead1dc","#d0e0e3","#e6b8af"];function _({onClick:t,active:e,disabled:n,title:r,children:s}){return o.jsx("button",{className:`docs-tb-btn${e?" active":""}`,onClick:t,disabled:n,title:r,children:s})}function at({label:t,children:e,className:n=""}){return o.jsxs("div",{className:`ribbon-group ${n}`.trim(),children:[o.jsx("div",{className:"ribbon-group-row",children:e}),o.jsx("div",{className:"ribbon-group-label",children:t})]})}function pt(){return o.jsx("div",{className:"ribbon-sep"})}function Rn({editor:t,isRtl:e=!1,onToggleRtl:n,content:r,theme:s,onThemeChange:l,onTrustAction:a,locked:p=!1}){const[c,m]=u.useState(!1),[f,b]=u.useState(!1),[g,S]=u.useState(!1),[j,M]=u.useState(!1),[k,T]=u.useState(!1),[Z,E]=u.useState(!1),[F,q]=u.useState(!1),I=u.useRef(null),X=u.useRef(null),$=u.useRef(null),H=u.useRef(null),tt=u.useRef(null),W=u.useRef(null);u.useEffect(()=>{const d=C=>{const w=C.target;I.current&&!I.current.contains(w)&&m(!1),X.current&&!X.current.contains(w)&&b(!1),$.current&&!$.current.contains(w)&&S(!1),H.current&&!H.current.contains(w)&&M(!1),tt.current&&!tt.current.contains(w)&&T(!1),W.current&&!W.current.contains(w)&&E(!1)};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[]);const N=()=>{m(!1),b(!1),S(!1),M(!1),T(!1),E(!1)},et=u.useCallback(()=>{if(!t)return"Normal text";for(const d of wt)if(d.node==="paragraph"&&t.isActive("paragraph")){if(!wt.some(w=>w.node!=="paragraph"&&t.isActive(w.node)))return d.label}else if(t.isActive(d.node))return d.label;return"Normal text"},[t]),ct=u.useCallback(()=>{if(!t)return"Default";const d=t.getAttributes("textStyle")?.fontFamily;if(!d)return"Default";const C=qt.find(w=>w.value===d);return C?C.label:"Default"},[t]),[U,lt]=u.useState(11),[,st]=u.useState(0),h=u.useMemo(()=>{const d=new Map;for(const w of R.LANGUAGE_REGISTRY){if(w.status!=="stable"||Ln.has(w.canonical)||w.category==="agent")continue;const K=w.category,gt=d.get(K)||[];gt.push({label:w.canonical,keyword:w.canonical,category:K,description:w.description,isReadOnly:Nn.has(w.canonical)}),d.set(K,gt)}const C=[];for(const w of _n){const K=d.get(w);!K||K.length===0||(K.sort((gt,de)=>gt.keyword.localeCompare(de.keyword)),C.push({category:Dt[w]?.label||w,items:K}))}return C},[]);u.useEffect(()=>{if(!t)return;const d=()=>{const C=t.getAttributes("textStyle");if(C?.fontSize){const w=parseInt(C.fontSize,10);isNaN(w)||lt(w)}st(w=>w+1)};return t.on("selectionUpdate",d),t.on("transaction",d),()=>{t.off("selectionUpdate",d),t.off("transaction",d)}},[t]);const y=u.useCallback(d=>{t&&(d==="paragraph"?t.chain().focus().setParagraph().run():d==="itQuote"?t.chain().focus().setNode("itQuote").run():t.chain().focus().setNode(d).run(),N())},[t]),A=u.useCallback(d=>{if(!t)return;const C=t.chain().focus();d==="divider"?C.setNode("itDivider").run():d==="break"?C.setNode("itBreak").run():d==="code"?C.setNode("itCode",{lang:""}).run():["tip","info","warning","danger","success"].includes(d)?C.setNode("itCallout",{variant:d}).run():C.setNode("itGenericBlock",{keyword:d,properties:""}).run(),N()},[t]),P=u.useCallback(d=>{const C=Math.min(96,Math.max(8,U+d));lt(C),t?.chain().focus().setFontSize(`${C}pt`).run()},[t,U]),Y=u.useCallback(d=>{t?.chain().focus().setBlockProp("leading",d).run(),N()},[t]),O=u.useCallback(d=>{if(!t)return;const C=J(t,d);t.chain().focus().setBlockProp(d,C?null:Mn).run(),N()},[t]),re=u.useCallback(()=>{if(!t)return;const d=window.prompt("Space before block (e.g. 12px, 1em — empty for none):",J(t,"space-before")||"");if(d===null)return;const C=window.prompt("Space after block (e.g. 12px, 1em — empty for none):",J(t,"space-after")||"");C!==null&&(t.chain().focus().setBlockProp("space-before",d.trim()||null).setBlockProp("space-after",C.trim()||null).run(),N())},[t]),se=u.useCallback(()=>{if(!t)return;const d=J(t,"end"),C=window.prompt("Line-end text (shown at the end of the line — empty to remove):",d||"");C!==null&&t.chain().focus().setBlockProp("end",C.trim()||null).run()},[t]),oe=u.useCallback(()=>{t&&(t.chain().focus().insertContent({type:"paragraph",attrs:{end:"End text"},content:[{type:"text",text:"Start text"}]}).run(),N())},[t]),ie=u.useMemo(()=>ne(),[]),ft=F?"minimal-ink":"normal",ae=u.useCallback(()=>te(r,s,ft),[r,s,ft]),ce=u.useCallback(()=>ee(r,s,ft),[r,s,ft]);if(!t)return null;const xt=J(t,"leading"),le=!!J(t,"end");return o.jsxs("div",{className:"docs-toolbar docs-ribbon",children:[o.jsxs(at,{label:"Edit",children:[o.jsx(_,{onClick:()=>t.chain().focus().undo().run(),disabled:p||!t.can().undo(),title:"Undo (⌘Z)",children:o.jsx(v.Undo2,{size:16})}),o.jsx(_,{onClick:()=>t.chain().focus().redo().run(),disabled:p||!t.can().redo(),title:"Redo (⌘⇧Z)",children:o.jsx(v.Redo2,{size:16})})]}),o.jsx(pt,{}),o.jsxs(at,{label:"File",children:[o.jsxs(_,{onClick:ae,title:"Print / Export PDF (WYSIWYG)",children:[o.jsx(v.Printer,{size:16}),o.jsx("span",{className:"ribbon-btn-text",children:"PDF"})]}),o.jsxs(_,{onClick:ce,title:"Export HTML",children:[o.jsx(v.FileCode2,{size:16}),o.jsx("span",{className:"ribbon-btn-text",children:"HTML"})]}),o.jsx(_,{onClick:()=>q(d=>!d),active:F,title:"Minimal ink mode (plain callouts when printing)",children:o.jsx(v.Droplets,{size:16})}),o.jsx("select",{className:"ribbon-theme-select",value:s,onChange:d=>l(d.target.value),title:"Document theme (used by print/export)",children:ie.map(d=>o.jsx("option",{value:d,children:d.charAt(0).toUpperCase()+d.slice(1)},d))})]}),o.jsx(pt,{}),o.jsxs("div",{className:p?"ribbon-locked":"ribbon-editing",children:[o.jsxs(at,{label:"Text",children:[o.jsxs("div",{className:"docs-tb-dropdown",ref:$,children:[o.jsxs("button",{className:"docs-tb-select docs-tb-font-select",onClick:()=>{N(),S(!g)},children:[o.jsx("span",{className:"docs-tb-select-label",children:ct()}),o.jsx(v.ChevronDown,{size:14})]}),g&&o.jsx("div",{className:"docs-tb-dropdown-menu docs-font-menu",children:qt.map(d=>o.jsx("button",{className:`docs-tb-dropdown-item${ct()===d.label?" active":""}`,style:{fontFamily:d.value||"inherit"},onClick:()=>{d.value?t.chain().focus().setFontFamily(d.value).run():t.chain().focus().unsetFontFamily().run(),N()},children:d.label},d.value||"default"))})]}),o.jsx(_,{onClick:()=>P(-1),title:"Decrease font size",children:o.jsx(v.Minus,{size:14})}),o.jsx("span",{className:"docs-tb-fontsize",children:U}),o.jsx(_,{onClick:()=>P(1),title:"Increase font size",children:o.jsx(v.Plus,{size:14})}),o.jsx(_,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (⌘B)",children:o.jsx(v.Bold,{size:16})}),o.jsx(_,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (⌘I)",children:o.jsx(v.Italic,{size:16})}),o.jsx(_,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (⌘U)",children:o.jsx(v.Underline,{size:16})}),o.jsx(_,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough (⌘⇧X)",children:o.jsx(v.Strikethrough,{size:16})}),o.jsxs("div",{className:"docs-tb-dropdown docs-tb-color-dropdown",ref:H,children:[o.jsxs("button",{className:"docs-tb-btn docs-tb-color-btn",onClick:()=>{N(),M(!j)},title:"Text color",children:[o.jsx(v.Palette,{size:16}),o.jsx("span",{className:"docs-tb-color-indicator",style:{background:t.getAttributes("textStyle")?.color||"#000000"}})]}),j&&o.jsxs("div",{className:"docs-tb-dropdown-menu docs-color-grid-menu",children:[o.jsx("div",{className:"docs-color-grid-label",children:"Text color"}),o.jsx("div",{className:"docs-color-grid",children:zn.map(d=>o.jsx("button",{className:"docs-color-swatch",style:{background:d},title:d,onClick:()=>{t.chain().focus().setColor(d).run(),N()}},d))}),o.jsxs("button",{className:"docs-tb-dropdown-item",onClick:()=>{t.chain().focus().unsetColor().run(),N()},children:[o.jsx(v.RemoveFormatting,{size:14})," Reset"]})]})]}),o.jsxs("div",{className:"docs-tb-dropdown docs-tb-color-dropdown",ref:tt,children:[o.jsxs("button",{className:"docs-tb-btn docs-tb-color-btn",onClick:()=>{N(),T(!k)},title:"Highlight color",children:[o.jsx(v.Highlighter,{size:16}),o.jsx("span",{className:"docs-tb-color-indicator",style:{background:t.getAttributes("highlight")?.color||"transparent"}})]}),k&&o.jsxs("div",{className:"docs-tb-dropdown-menu docs-color-grid-menu",children:[o.jsx("div",{className:"docs-color-grid-label",children:"Highlight color"}),o.jsx("div",{className:"docs-color-grid docs-highlight-grid",children:Hn.map(d=>o.jsx("button",{className:"docs-color-swatch",style:{background:d},title:d,onClick:()=>{d==="#ffffff"?t.chain().focus().unsetHighlight().run():t.chain().focus().toggleHighlight({color:d}).run(),N()}},d))})]})]}),o.jsx(_,{onClick:()=>t.chain().focus().toggleSubscript().run(),active:t.isActive("subscript"),title:"Subscript",children:o.jsx(v.Subscript,{size:16})}),o.jsx(_,{onClick:()=>t.chain().focus().toggleSuperscript().run(),active:t.isActive("superscript"),title:"Superscript",children:o.jsx(v.Superscript,{size:16})}),o.jsx(_,{onClick:()=>t.chain().focus().toggleCode().run(),active:t.isActive("code"),title:"Inline code",children:o.jsx(v.Code,{size:16})}),o.jsx(_,{onClick:()=>t.chain().focus().unsetAllMarks().clearNodes().run(),title:"Clear formatting",children:o.jsx(v.RemoveFormatting,{size:16})})]}),o.jsx(pt,{}),o.jsxs(at,{label:"Paragraph",children:[o.jsxs("div",{className:"docs-tb-dropdown",ref:I,children:[o.jsxs("button",{className:"docs-tb-select docs-tb-paragraph-select",onClick:()=>{N(),m(!c)},children:[o.jsx("span",{className:"docs-tb-select-label",children:et()}),o.jsx(v.ChevronDown,{size:14})]}),c&&o.jsx("div",{className:"docs-tb-dropdown-menu docs-style-menu",children:wt.map(d=>o.jsx("button",{className:`docs-tb-dropdown-item${et()===d.label?" active":""}`,onClick:()=>y(d.node),children:o.jsx("span",{className:`docs-style-preview docs-style-${d.node}`,children:d.label})},d.node))})]}),o.jsx(_,{onClick:()=>t.chain().focus().setTextAlign("left").run(),active:t.isActive({textAlign:"left"}),title:"Align left",children:o.jsx(v.AlignLeft,{size:16})}),o.jsx(_,{onClick:()=>t.chain().focus().setTextAlign("center").run(),active:t.isActive({textAlign:"center"}),title:"Align center",children:o.jsx(v.AlignCenter,{size:16})}),o.jsx(_,{onClick:()=>t.chain().focus().setTextAlign("right").run(),active:t.isActive({textAlign:"right"}),title:"Align right",children:o.jsx(v.AlignRight,{size:16})}),o.jsx(_,{onClick:()=>t.chain().focus().setTextAlign("justify").run(),active:t.isActive({textAlign:"justify"}),title:"Justify",children:o.jsx(v.AlignJustify,{size:16})}),o.jsx(_,{onClick:()=>n?.(),active:e,title:e?"Switch to LTR (left-to-right)":"Switch to RTL (right-to-left)",children:o.jsx("span",{style:{fontSize:11,fontWeight:700,letterSpacing:-.5,lineHeight:1},children:e?"LTR":"RTL"})}),o.jsxs("div",{className:"docs-tb-dropdown",ref:W,children:[o.jsxs("button",{className:`docs-tb-btn${xt?" active":""}`,onClick:()=>{N(),E(!Z)},title:"Line & paragraph spacing",children:[o.jsx(v.Rows3,{size:16}),o.jsx(v.ChevronDown,{size:12})]}),Z&&o.jsxs("div",{className:"docs-tb-dropdown-menu docs-spacing-menu",children:[o.jsx("div",{className:"docs-insert-category",children:"Line spacing"}),o.jsx("button",{className:`docs-tb-dropdown-item${xt?"":" active"}`,onClick:()=>Y(null),children:"Default"}),$n.map(d=>o.jsx("button",{className:`docs-tb-dropdown-item${xt===d?" active":""}`,onClick:()=>Y(d),children:d==="1"?"Single":d==="2"?"Double":d},d)),o.jsx("div",{className:"docs-insert-divider"}),o.jsx("div",{className:"docs-insert-category",children:"Paragraph spacing"}),o.jsx("button",{className:"docs-tb-dropdown-item",onClick:()=>O("space-before"),children:J(t,"space-before")?"Remove space before block":"Add space before block"}),o.jsx("button",{className:"docs-tb-dropdown-item",onClick:()=>O("space-after"),children:J(t,"space-after")?"Remove space after block":"Add space after block"}),o.jsx("button",{className:"docs-tb-dropdown-item",onClick:re,children:"Custom spacing…"})]})]}),o.jsx(_,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet list",children:o.jsx(v.List,{size:16})}),o.jsx(_,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Numbered list",children:o.jsx(v.ListOrdered,{size:16})})]}),o.jsx(pt,{}),o.jsxs(at,{label:"Insert",children:[o.jsxs("div",{className:"docs-tb-dropdown",ref:X,children:[o.jsxs("button",{className:"docs-tb-select docs-tb-insert-select",onClick:()=>{N(),b(!f)},children:[o.jsx(v.Plus,{size:15}),o.jsx("span",{children:"Insert"}),o.jsx(v.ChevronDown,{size:14})]}),f&&o.jsxs("div",{className:"docs-tb-dropdown-menu docs-insert-menu",children:[o.jsxs("button",{className:"docs-tb-dropdown-item docs-insert-item",onClick:oe,title:"Two-sided row — content at the line start, value at the line end (text: … | end: …)",children:[o.jsx("span",{className:"docs-insert-icon",children:o.jsx(v.AlignHorizontalSpaceBetween,{size:13})}),o.jsx("span",{className:"docs-insert-label",children:"two-sided row"}),o.jsx("span",{className:"docs-insert-kw",children:"end:"})]}),o.jsx("div",{className:"docs-insert-divider"}),h.map((d,C)=>o.jsxs("div",{children:[C>0&&o.jsx("div",{className:"docs-insert-divider"}),o.jsx("div",{className:"docs-insert-category",children:d.category}),d.items.map(w=>o.jsxs("button",{className:"docs-tb-dropdown-item docs-insert-item",onClick:()=>A(w.keyword),disabled:w.isReadOnly,title:w.description,children:[o.jsx("span",{className:"docs-insert-icon",children:Dt[w.category]?.icon||"•"}),o.jsx("span",{className:"docs-insert-label",children:w.label}),o.jsx("span",{className:"docs-insert-kw",children:w.isReadOnly?"locked":`.${w.keyword}`})]},w.keyword))]},d.category))]})]}),o.jsx(_,{onClick:se,active:le,title:"Two-sided row — set the text shown at the END of this line (end: property)",children:o.jsx(v.AlignHorizontalSpaceBetween,{size:16})})]})]}),a&&o.jsxs(o.Fragment,{children:[o.jsx(pt,{}),o.jsxs(at,{label:"Trust",children:[o.jsxs(_,{onClick:()=>a("seal"),disabled:p,title:p?"Document is already sealed":"Seal — freeze the document with a tamper-evident hash",children:[o.jsx(v.FileLock2,{size:16}),o.jsx("span",{className:"ribbon-btn-text",children:"Seal"})]}),o.jsxs(_,{onClick:()=>a("sign"),title:"Sign — add a signature",children:[o.jsx(v.PenTool,{size:16}),o.jsx("span",{className:"ribbon-btn-text",children:"Sign"})]}),o.jsxs(_,{onClick:()=>a("verify"),title:"Verify — check the document hash and signatures",children:[o.jsx(v.ShieldCheck,{size:16}),o.jsx("span",{className:"ribbon-btn-text",children:"Verify"})]})]})]})]})}function vt(t,e){return e?`${t} (${e})`:t}function En({trust:t,intact:e}){if(t.isSealed){const n=t.sealedBy||"unknown",r=t.signatures[t.signatures.length-1]?.role;return o.jsxs("div",{className:"docs-trust-banner docs-trust-banner--sealed",role:"status",children:[o.jsx("span",{className:"docs-trust-banner__icon",children:"🔒"}),o.jsx("span",{className:"docs-trust-banner__title",children:"Sealed"}),o.jsxs("span",{className:"docs-trust-banner__text",children:["signed by ",vt(n,r),t.sealedAt?` on ${t.sealedAt}`:""," · read-only"]}),e===!0&&o.jsx("span",{className:"docs-trust-banner__verify docs-trust-banner__verify--ok",children:"hash verified ✓"}),e===!1&&o.jsx("span",{className:"docs-trust-banner__verify docs-trust-banner__verify--bad",children:"⚠ hash mismatch — content changed after sealing"})]})}return t.signatures.length>0?o.jsxs("div",{className:"docs-trust-banner docs-trust-banner--signed",role:"status",children:[o.jsx("span",{className:"docs-trust-banner__icon",children:"✍"}),o.jsx("span",{className:"docs-trust-banner__title",children:"Signed"}),o.jsxs("span",{className:"docs-trust-banner__text",children:["by"," ",t.signatures.map(n=>`${vt(n.by,n.role)}${n.at?` on ${n.at}`:""}`).join(" · ")]})]}):t.approvals.length>0?o.jsxs("div",{className:"docs-trust-banner docs-trust-banner--approved",role:"status",children:[o.jsx("span",{className:"docs-trust-banner__icon",children:"✓"}),o.jsx("span",{className:"docs-trust-banner__title",children:"Approved"}),o.jsxs("span",{className:"docs-trust-banner__text",children:["by"," ",t.approvals.map(n=>`${vt(n.by,n.role)}${n.at?` on ${n.at}`:""}`).join(" · ")]})]}):null}function Pn(t){let e;try{e=R.parseIntentText(t)}catch{return[]}const n=[],r=(s,l)=>{const a=l==null?"":String(l).trim();a&&n.push({key:s,value:a})};for(const s of e.blocks)switch(s.type){case"meta":for(const[l,a]of Object.entries(s.properties||{}))r(l,a);break;case"track":r("tracked",s.properties?.id??s.content);break;case"page":{const l=s.properties?.orientation;r("page",[s.content,l].filter(Boolean).join(" · "));break}case"font":r("font",[s.content||s.properties?.family,s.properties?.size].filter(Boolean).join(" · "));break;case"header":r("header",s.content);break;case"footer":r("footer",s.content);break;case"watermark":r("watermark",s.content);break}return n}function Bn({source:t}){const[e,n]=u.useState(!1),r=u.useMemo(()=>Pn(t),[t]);if(r.length===0)return null;const s=r.slice(0,4).map(l=>`${l.key}: ${l.value}`).join(" · ");return o.jsxs("div",{className:`docs-props-bar${e?" open":""}`,children:[o.jsxs("button",{className:"docs-props-toggle",onClick:()=>n(l=>!l),title:e?"Hide document properties":"Show document properties",children:[o.jsx("span",{className:"docs-props-caret",children:e?"▾":"▸"}),"Document properties",!e&&o.jsx("span",{className:"docs-props-summary",children:s})]}),e&&o.jsx("div",{className:"docs-props-chips",children:r.map((l,a)=>o.jsxs("span",{className:"docs-props-chip",children:[o.jsx("b",{children:l.key})," ",l.value]},`${l.key}-${a}`))})]})}function z(t,e,n=""){const r=t?.properties?.[e];return r!=null?String(r):n}function Nt(t){const e={lifecycle:"draft",isTracked:!1,trackBlock:null,approvals:[],signatures:[],isSealed:!1,sealedBy:null,sealedAt:null,sealHash:null,amendments:[]};if(!t)return e;const n=t.blocks,r=n.find(c=>c.type==="track");r&&(e.isTracked=!0,e.lifecycle="tracked",e.trackBlock={id:z(r,"id",r.content??""),by:z(r,"by"),at:z(r,"at")});const s=n.filter(c=>c.type==="approve");for(const c of s)e.approvals.push({by:z(c,"by",c.content??""),role:z(c,"role"),at:z(c,"at"),note:z(c,"note")||void 0});e.approvals.length>0&&(e.lifecycle="approved");const l=n.filter(c=>c.type==="sign");for(const c of l)e.signatures.push({by:z(c,"by",c.content??""),role:z(c,"role"),at:z(c,"at")});e.signatures.length>0&&(e.lifecycle="signed");const a=n.find(c=>c.type==="freeze");if(a){e.isSealed=!0,e.lifecycle="sealed";const c=e.signatures[e.signatures.length-1];e.sealedBy=c?.by||z(a,"by",a.content??""),e.sealedAt=z(a,"at")||c?.at||"",e.sealHash=z(a,"hash")}const p=n.filter(c=>c.type==="amendment");for(const c of p)e.amendments.push({section:z(c,"section",c.content??""),was:z(c,"was"),now:z(c,"now"),by:z(c,"by"),ref:z(c,"ref"),at:z(c,"at")});return e}const Wt=new yt.PluginKey("template-highlight"),bt=/\{\{[^}]+\}\}/g;function Gt(t){const e=[];return t.descendants((n,r)=>{if(!n.isText||!n.text)return;bt.lastIndex=0;let s;for(;s=bt.exec(n.text);)e.push(rt.Decoration.inline(r+s.index,r+s.index+s[0].length,{class:"it-doc-var"}))}),rt.DecorationSet.create(t,e)}const In=x.Extension.create({name:"templateHighlight",addProseMirrorPlugins(){return[new yt.Plugin({key:Wt,state:{init:(t,e)=>Gt(e.doc),apply:(t,e)=>t.docChanged?Gt(t.doc):e},props:{decorations(t){return Wt.getState(t)}}})]}});function On(t){const e=new Set,n=[];bt.lastIndex=0;let r;for(;r=bt.exec(t);){const s=r[0].slice(2,-2).trim();/^(page|pages|date|time|year)$/i.test(s)||e.has(s)||(e.add(s),n.push(s))}return n}function Dn(t){const e={};for(const n of t){const r=n.split(".");let s=e;for(let l=0;l<r.length;l++){const a=r[l];l===r.length-1?a in s||(s[a]=""):((!(a in s)||typeof s[a]!="object"||s[a]===null)&&(s[a]={}),s=s[a])}}return e}const Fn=28,qn={title:[".it-doc-title"],summary:[".it-doc-summary"],section:[".it-doc-section"],sub:[".it-doc-sub"],text:["p"],quote:[".it-doc-quote"],callout:[".it-doc-callout"],info:[".it-doc-callout"],table:[".it-doc-table th",".it-doc-table td"],"table-header":[".it-doc-table th"],metric:[".it-doc-metric"],contact:['.it-doc-generic[data-keyword="contact"]'],divider:[".it-doc-divider"]};function Wn({value:t,onChange:e,theme:n,onThemeChange:r,readOnly:s=!1,showRibbon:l=!0,showTrustBanner:a=!0,onTrustAction:p}){const c=u.useRef(""),m=u.useRef(!1),f=u.useRef(!0),[b,g]=u.useState([]),S=u.useRef(ht("")),[j,M]=u.useState(1),k=Ht.useEditor({extensions:[Be.configure({geometry:()=>S.current,gap:Fn,onPages:M}),we.default.configure({heading:!1,codeBlock:!1,blockquote:!1,horizontalRule:!1,paragraph:!1}),vn,Tn,ve.default.configure({placeholder:({editor:h})=>h.isEmpty?"Start typing...":""}),Te.default,ge.TextStyle,je.default,Ae.default.configure({multicolor:!0}),Ce.default.configure({types:["paragraph","itTitle","itSummary","itSection","itSub"]}),Ne.default,Me,Le.default,_e.default,sn,on,an,cn,ln,dn,un,pn,gn,fn,mn,hn,bn,yn,xn,Sn,In],content:Ct(t),onUpdate:({editor:h})=>{if(f.current)return;const y=h.getJSON(),A=Yt(y);c.current=A,m.current=!0,g(Ve(y)),e(A)},editorProps:{attributes:{class:"docs-page-content",spellcheck:"true"}}});u.useEffect(()=>{const h=window.setTimeout(()=>{f.current=!1,c.current=t},0);return()=>window.clearTimeout(h)},[]),u.useEffect(()=>{if(k){if(m.current){m.current=!1;return}if(t!==c.current){const h=Ct(t);k.commands.setContent(h),c.current=t}}},[t,k]),u.useEffect(()=>{if(!k)return;const h=y=>{const A=y.detail;A&&k.chain().focus().insertContent(A).run()};return window.addEventListener("it-insert-text",h),()=>window.removeEventListener("it-insert-text",h)},[k]);const T=u.useMemo(()=>ht(t),[t]);u.useEffect(()=>{S.current=T,k?.view.dispatch(k.state.tr)},[T,k]);const Z=u.useRef(null),E=u.useCallback(()=>k?k.storage.characterCount?.words?.()??k.getText().split(/\s+/).filter(Boolean).length:0,[k]),F=u.useMemo(()=>{if(!n)return"";try{const h=R.getBuiltinTheme(n);return h?R.generateThemeCSS(h).replace(/:root\{/,".docs-page{"):""}catch{return""}},[n]),q=u.useMemo(()=>{try{const h=R.parseIntentText(t),y=h.blocks.find(O=>O.type==="header")?.content||"",A=h.blocks.find(O=>O.type==="footer")?.content||"",P=h.blocks.find(O=>O.type==="meta"),Y=String(P?.properties?.dir||"ltr").toLowerCase();return{header:y,footer:A,dir:Y}}catch{return{header:"",footer:"",dir:"ltr"}}},[t]),I=u.useMemo(()=>{try{return Nt(R.parseIntentText(t))}catch{return Nt(null)}},[t]),X=u.useMemo(()=>{if(!I.isSealed)return null;try{return R.verifyDocument(t).intact}catch{return null}},[t,I.isSealed]),$=I.isSealed||s;u.useEffect(()=>{k&&k.isEditable!==!$&&k.setEditable(!$)},[k,$]);const H=u.useMemo(()=>{try{return R.documentStyleCSS(R.parseIntentText(t),qn,".docs-page .tiptap ")}catch{return""}},[t]);u.useEffect(()=>{let h=document.getElementById("it-doc-style-rules");h||(h=document.createElement("style"),h.id="it-doc-style-rules",document.head.appendChild(h)),h.textContent=H},[H]);const tt=u.useCallback(()=>{if(q.dir==="rtl"){const y=t.split(`
|
|
28
|
+
`).map(A=>{if(/^meta:/i.test(A.trim())){const P=A.replace(/\s*\|\s*dir:\s*rtl/gi,"").trim();return P==="meta:"?null:P}return A}).filter(A=>A!==null).join(`
|
|
29
|
+
`);e(y)}else{const y=/^meta:.*$/m.exec(t);y?e(t.replace(/^meta:.*$/m,`${y[0]} | dir: rtl`)):/^(title:|summary:)/m.test(t)?e(t.replace(/^((?:title:|summary:).*)$/m,`$1
|
|
30
|
+
meta: | dir: rtl`)):e(`meta: | dir: rtl
|
|
31
|
+
${t}`)}},[t,e,q.dir]);u.useEffect(()=>{const h="it-editor-theme-css";let y=document.getElementById(h);y||(y=document.createElement("style"),y.id=h,document.head.appendChild(y)),y.textContent=F},[F]);const W=u.useRef(null),[N,et]=u.useState(1),ct=u.useRef(N),U=u.useRef(null),lt=u.useCallback(h=>{const y=W.current;if(!y)return;const A=y.getBoundingClientRect();U.current={cx:y.scrollLeft+(h.clientX-A.left),cy:y.scrollTop+(h.clientY-A.top)}},[]),st=u.useCallback(()=>{const h=W.current;h&&(U.current={cx:h.scrollLeft+h.clientWidth/2,cy:h.scrollTop+h.clientHeight/2})},[]);return u.useLayoutEffect(()=>{const h=W.current,y=U.current,A=ct.current;if(!h||!y||A===N)return;const P=N/A;h.getBoundingClientRect();const Y=y.cx-h.scrollLeft,O=y.cy-h.scrollTop;h.scrollLeft=y.cx*P-Y,h.scrollTop=y.cy*P-O,U.current=null,ct.current=N},[N]),u.useEffect(()=>{const h=y=>{(y.metaKey||y.ctrlKey)&&(y.key==="="||y.key==="+"?(y.preventDefault(),st(),et(A=>Math.min(2,+(A+.1).toFixed(2)))):y.key==="-"?(y.preventDefault(),st(),et(A=>Math.max(.25,+(A-.1).toFixed(2)))):y.key==="0"&&(y.preventDefault(),st(),et(1)))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[st]),u.useEffect(()=>{const h=W.current;if(!h)return;const y=A=>{if(A.ctrlKey||A.metaKey){A.preventDefault();const P=A.deltaY>0?-.1:.1;lt(A),et(Y=>Math.min(2,Math.max(.25,+(Y+P).toFixed(2))))}};return h.addEventListener("wheel",y,{passive:!1}),()=>h.removeEventListener("wheel",y)},[lt]),o.jsxs("div",{className:"docs-container",children:[l&&o.jsx(Rn,{editor:k,isRtl:q.dir==="rtl",onToggleRtl:tt,content:t,theme:n,onThemeChange:r,onTrustAction:p,locked:$}),a&&o.jsx(En,{trust:I,intact:X}),a&&o.jsx(Bn,{source:t}),b.length>0&&o.jsxs("div",{className:"docs-fidelity-warning",role:"status",children:["⚠ Some formatting (",b.join(", "),") can’t be saved to"," ",o.jsx("code",{children:".it"})," and won’t appear when printed through the template — remove it or use the toolbar’s color/size/style controls instead."]}),o.jsxs("div",{className:"docs-canvas",ref:W,children:[o.jsx("div",{className:"docs-page-scaler",style:{width:T.width*N},children:o.jsx("div",{className:"docs-page-flow",dir:q.dir,style:{transform:N!==1?`scale(${N})`:void 0,transformOrigin:"top left"},children:o.jsxs("div",{className:"docs-page docs-sheet",ref:Z,style:{width:T.width,minHeight:T.autoHeight?T.width:void 0,"--page-mx-l":`${T.marginLeft}px`,"--page-mx-r":`${T.marginRight}px`},children:[o.jsx("div",{className:"docs-sheet-header","data-it-spacer":"",style:{height:T.autoHeight?void 0:T.marginTop},children:o.jsx("div",{className:"docs-pb-header",children:o.jsx("span",{className:"docs-pb-text",children:T.autoHeight?"":Lt(T.header,1,j)})})}),o.jsx(Ht.EditorContent,{editor:k})]})})}),o.jsxs("div",{className:"docs-page-footer",children:[j," ",j===1?"page":"pages"," ·"," ",E()," words",N!==1&&o.jsxs("span",{className:"zoom-indicator",children:[" ","· ",Math.round(N*100),"%"]})]})]})]})}const Gn="corporate";function Un({value:t,onChange:e,theme:n,onThemeChange:r,readOnly:s=!1,showRibbon:l=!0,showTrustBanner:a=!0,onTrustAction:p}){const[c,m]=u.useState(n??Gn),f=n??c,b=u.useCallback(g=>{m(g),r?.(g)},[r]);return o.jsx(Wn,{value:t,onChange:e,theme:f,onThemeChange:b,readOnly:s,showRibbon:l,showTrustBanner:a,onTrustAction:p})}exports.IntentTextEditor=Un;exports.buildSampleSkeleton=Dn;exports.builtinThemes=ne;exports.docToSource=Yt;exports.exportDocumentHTML=ee;exports.exportDocumentPDF=te;exports.extractTemplateVariables=On;exports.extractTrustState=Nt;exports.getPageGeometry=ht;exports.printHtmlViaIframe=Qt;exports.resolvePageTokens=Lt;exports.sourceToDoc=Ct;
|
|
32
|
+
//# sourceMappingURL=index.cjs.map
|