@forgedevstack/ink 1.1.0 → 1.1.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.
Files changed (118) hide show
  1. package/CHANGELOG.md +27 -5
  2. package/README.md +77 -19
  3. package/dist/components/InkEditor/InkEditor.cjs +1 -1
  4. package/dist/components/InkEditor/InkEditor.d.ts.map +1 -1
  5. package/dist/components/InkEditor/InkEditor.js +448 -365
  6. package/dist/components/InkEditor/components/AiPanel/AiPanel.cjs +1 -1
  7. package/dist/components/InkEditor/components/AiPanel/AiPanel.js +7 -6
  8. package/dist/components/InkEditor/components/FindReplace/FindReplace.cjs +1 -0
  9. package/dist/components/InkEditor/components/FindReplace/FindReplace.const.cjs +1 -0
  10. package/dist/components/InkEditor/components/FindReplace/FindReplace.const.d.ts +11 -0
  11. package/dist/components/InkEditor/components/FindReplace/FindReplace.const.d.ts.map +1 -0
  12. package/dist/components/InkEditor/components/FindReplace/FindReplace.const.js +13 -0
  13. package/dist/components/InkEditor/components/FindReplace/FindReplace.d.ts +4 -0
  14. package/dist/components/InkEditor/components/FindReplace/FindReplace.d.ts.map +1 -0
  15. package/dist/components/InkEditor/components/FindReplace/FindReplace.js +49 -0
  16. package/dist/components/InkEditor/components/FindReplace/FindReplace.types.d.ts +12 -0
  17. package/dist/components/InkEditor/components/FindReplace/FindReplace.types.d.ts.map +1 -0
  18. package/dist/components/InkEditor/components/FindReplace/index.d.ts +3 -0
  19. package/dist/components/InkEditor/components/FindReplace/index.d.ts.map +1 -0
  20. package/dist/components/InkEditor/components/SignPad/SignPad.cjs +1 -0
  21. package/dist/components/InkEditor/components/SignPad/SignPad.const.cjs +1 -0
  22. package/dist/components/InkEditor/components/SignPad/SignPad.const.d.ts +17 -0
  23. package/dist/components/InkEditor/components/SignPad/SignPad.const.d.ts.map +1 -0
  24. package/dist/components/InkEditor/components/SignPad/SignPad.const.js +20 -0
  25. package/dist/components/InkEditor/components/SignPad/SignPad.d.ts +4 -0
  26. package/dist/components/InkEditor/components/SignPad/SignPad.d.ts.map +1 -0
  27. package/dist/components/InkEditor/components/SignPad/SignPad.js +76 -0
  28. package/dist/components/InkEditor/components/SignPad/SignPad.types.d.ts +10 -0
  29. package/dist/components/InkEditor/components/SignPad/SignPad.types.d.ts.map +1 -0
  30. package/dist/components/InkEditor/components/SignPad/SignPad.utils.cjs +1 -0
  31. package/dist/components/InkEditor/components/SignPad/SignPad.utils.d.ts +6 -0
  32. package/dist/components/InkEditor/components/SignPad/SignPad.utils.d.ts.map +1 -0
  33. package/dist/components/InkEditor/components/SignPad/SignPad.utils.js +19 -0
  34. package/dist/components/InkEditor/components/SignPad/SignPad.utils.test.d.ts +2 -0
  35. package/dist/components/InkEditor/components/SignPad/SignPad.utils.test.d.ts.map +1 -0
  36. package/dist/components/InkEditor/components/SignPad/index.d.ts +3 -0
  37. package/dist/components/InkEditor/components/SignPad/index.d.ts.map +1 -0
  38. package/dist/components/InkEditor/components/ToolbarButton/ToolbarButton.cjs +1 -1
  39. package/dist/components/InkEditor/components/ToolbarButton/ToolbarButton.js +3 -2
  40. package/dist/components/InkEditor/components/index.d.ts +2 -0
  41. package/dist/components/InkEditor/components/index.d.ts.map +1 -1
  42. package/dist/constants/defaults.const.cjs +1 -1
  43. package/dist/constants/defaults.const.d.ts.map +1 -1
  44. package/dist/constants/defaults.const.js +46 -39
  45. package/dist/constants/generals.const.cjs +1 -0
  46. package/dist/constants/generals.const.d.ts +6 -0
  47. package/dist/constants/generals.const.d.ts.map +1 -0
  48. package/dist/constants/generals.const.js +5 -0
  49. package/dist/constants/index.d.ts +4 -1
  50. package/dist/constants/index.d.ts.map +1 -1
  51. package/dist/constants/numbers.cjs +1 -0
  52. package/dist/constants/numbers.d.ts +119 -0
  53. package/dist/constants/numbers.d.ts.map +1 -0
  54. package/dist/constants/numbers.js +20 -0
  55. package/dist/constants/premium.const.cjs +1 -0
  56. package/dist/constants/premium.const.d.ts +8 -0
  57. package/dist/constants/premium.const.d.ts.map +1 -0
  58. package/dist/constants/premium.const.js +100 -0
  59. package/dist/constants/toolbar.const.cjs +1 -0
  60. package/dist/constants/toolbar.const.d.ts +4 -0
  61. package/dist/constants/toolbar.const.d.ts.map +1 -0
  62. package/dist/constants/toolbar.const.js +6 -0
  63. package/dist/index.cjs +1 -1
  64. package/dist/index.d.ts +3 -3
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +42 -29
  67. package/dist/plugins/ai/demoProvider.cjs +1 -1
  68. package/dist/plugins/ai/demoProvider.js +1 -1
  69. package/dist/styles.css +74 -1
  70. package/dist/types/features.types.d.ts +1 -1
  71. package/dist/types/features.types.d.ts.map +1 -1
  72. package/dist/types/index.d.ts +1 -0
  73. package/dist/types/index.d.ts.map +1 -1
  74. package/dist/types/ink.types.d.ts +10 -1
  75. package/dist/types/ink.types.d.ts.map +1 -1
  76. package/dist/types/premium.types.d.ts +30 -0
  77. package/dist/types/premium.types.d.ts.map +1 -0
  78. package/dist/utils/comments.utils.cjs +1 -1
  79. package/dist/utils/comments.utils.js +1 -1
  80. package/dist/utils/findReplace.utils.cjs +1 -0
  81. package/dist/utils/findReplace.utils.d.ts +3 -0
  82. package/dist/utils/findReplace.utils.d.ts.map +1 -0
  83. package/dist/utils/findReplace.utils.js +26 -0
  84. package/dist/utils/history.utils.cjs +1 -1
  85. package/dist/utils/history.utils.js +1 -1
  86. package/dist/utils/index.d.ts +6 -0
  87. package/dist/utils/index.d.ts.map +1 -1
  88. package/dist/utils/ink.features.test.d.ts +2 -0
  89. package/dist/utils/ink.features.test.d.ts.map +1 -0
  90. package/dist/utils/license.utils.cjs +1 -0
  91. package/dist/utils/license.utils.d.ts +2 -0
  92. package/dist/utils/license.utils.d.ts.map +1 -0
  93. package/dist/utils/license.utils.js +16 -0
  94. package/dist/utils/memory.utils.cjs +1 -0
  95. package/dist/utils/memory.utils.d.ts +5 -0
  96. package/dist/utils/memory.utils.d.ts.map +1 -0
  97. package/dist/utils/memory.utils.js +10 -0
  98. package/dist/utils/paste.utils.cjs +1 -0
  99. package/dist/utils/paste.utils.d.ts +4 -0
  100. package/dist/utils/paste.utils.d.ts.map +1 -0
  101. package/dist/utils/paste.utils.js +31 -0
  102. package/dist/utils/premium.utils.cjs +1 -0
  103. package/dist/utils/premium.utils.d.ts +6 -0
  104. package/dist/utils/premium.utils.d.ts.map +1 -0
  105. package/dist/utils/premium.utils.js +30 -0
  106. package/dist/utils/slash.utils.cjs +1 -1
  107. package/dist/utils/slash.utils.js +1 -1
  108. package/dist/utils/storage.utils.cjs +1 -0
  109. package/dist/utils/storage.utils.d.ts +2 -0
  110. package/dist/utils/storage.utils.d.ts.map +1 -0
  111. package/dist/utils/storage.utils.js +4 -0
  112. package/dist/utils/table.utils.cjs +1 -1
  113. package/dist/utils/table.utils.js +1 -1
  114. package/package.json +3 -2
  115. package/dist/constants/numbers.const.cjs +0 -1
  116. package/dist/constants/numbers.const.d.ts +0 -18
  117. package/dist/constants/numbers.const.d.ts.map +0 -1
  118. package/dist/constants/numbers.const.js +0 -16
package/CHANGELOG.md CHANGED
@@ -1,9 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased — 1.1.2
4
+
5
+ ### Added
6
+ - Sign pad toolbar (`signature`) — canvas draw → insert PNG image
7
+ - `keepInMemory` + `memoryKey` — persist draft HTML in localStorage
8
+ - Find and replace toolbar (`findReplace`) — text-node safe
9
+ - Horizontal rule toolbar (`horizontalRule`)
10
+ - Aerocraft-style utility classes for SignPad / FindReplace panels
11
+ - `isLocalStorageAvailable` util; path aliases (`@/`)
12
+ - Docs: Jira bootstrap, Confluence paste pack, payments research, articles + Gemini video prompt
13
+ - Examples in README for sign pad, memory, find/replace
14
+
15
+ ### Changed
16
+ - Product copy no longer names other editor vendors
17
+
18
+ ### Previously unreleased (1.1.1)
19
+ - Premium scaffolding: `premium={{ enabled | licenseKey }}` unlocks theme tokens, icon map, rich paste, image upload, WYSIWYG
20
+ - Props: `theme`, `icons`, `pasteMode="rich"`, `onImageUpload`, `wysiwyg`
21
+ - Helpers: `resolveInkPremium`, `mintInkPremiumLicenseKey`, `sanitizePastedHtml`, `INK_DEFAULT_ICONS`
22
+ - License format: `ink_prem_XXXX_XXXX_XXXX_XXXX`
23
+ - Example Stripe webhook stub: `examples/stripe-webhook.mjs`
24
+
3
25
  ## 1.1.0 — 2026-08-01
4
26
 
5
27
  ### Added
6
- - CKEditor-inspired editor shell: soft light card, rounded toolbar, `variant="classic" | "document"`
28
+ - Editor shell: soft light card, rounded toolbar, `variant="classic" | "document"`
7
29
  - Structure blocks with hover/focus outline and block handles (move up/down MVP)
8
30
  - Toolbar: table insert, undo/redo, track changes, comments, AI toggles
9
31
  - Tables: insert N×M HTML tables with basic editable cells
@@ -22,17 +44,17 @@
22
44
  - Exports: `INK_COLLAB_TOOLBAR`, `INK_AI_MODEL_CATALOG`, `buildTableHtml`, comment/track helpers
23
45
 
24
46
  ### Docs
25
- - Feature matrix: CK-inspired capabilities → Ink status (Shipped MVP / Stub / Planned)
26
- - Honesty framing: CKEditor-inspired architecture with local demo providers; bring your own LLM. No SOC2/enterprise hosting claims.
47
+ - Feature matrix: capability → Ink status (Shipped MVP / Stub / Planned)
48
+ - Honesty framing: local demo providers; bring your own LLM. No SOC2/enterprise hosting claims.
27
49
 
28
50
  ## 1.0.1 — 2026-08-01
29
51
 
30
52
  ### Added
31
53
  - Theme helper classes: `.ink-theme-snow`, `.ink-theme-bubble`, `.ink-theme-dark`, `.ink-theme-minimal`
32
- - Expanded README: full prop table, `ToolbarOption` list, CSS variables, Quill positioning, portal links, asset screenshots
54
+ - Expanded README: full prop table, `ToolbarOption` list, CSS variables, portal links, asset screenshots
33
55
 
34
56
  ### Docs
35
- - Companion light Quill-inspired portal (docs + Format/Modules/Theme playground)
57
+ - Companion light portal (docs + Format/Modules/Theme playground)
36
58
 
37
59
  ## 1.0.0 — 2026-08-01
38
60
 
package/README.md CHANGED
@@ -3,14 +3,14 @@
3
3
  [![npm version](https://img.shields.io/npm/v/@forgedevstack/ink.svg)](https://www.npmjs.com/package/@forgedevstack/ink)
4
4
  [![license](https://img.shields.io/npm/l/@forgedevstack/ink.svg)](./LICENSE)
5
5
 
6
- **ForgeStack rich text editor** for React. CKEditor-inspired shell with tables, track changes, comments, block handles, slash commands, and pluggable Ink AI (bring your own LLM + local demo provider).
6
+ **ForgeStack rich text editor** for React. Soft document shell with tables, track changes, comments, block handles, slash commands, sign pad, draft memory, and pluggable Ink AI (bring your own LLM + local demo provider).
7
7
 
8
8
  <p align="center">
9
9
  <img src="./assets/ink-logo.png" alt="Ink logo" width="120" />
10
10
  </p>
11
11
 
12
12
  > **Domain:** [inkforgejs.com](https://inkforgejs.com) — docs + demos.
13
- > **Inspired by CKEditor 5** demos / AI features pages and earlier Quill-like portal aesthetics — not a fork. Ink is a contenteditable React component with ForgeStack integrations.
13
+ > Ink is a contenteditable React component with ForgeStack integrations — not a fork of other editors.
14
14
  > **Honesty:** Local demo AI providers only. No hosted enterprise LLM, SOC2, or on-prem claims. Connect Claude / Gemini / GPT (or custom) via `inkAi.registerProvider`.
15
15
 
16
16
  ## Install
@@ -51,26 +51,82 @@ export function App() {
51
51
  | npm | https://www.npmjs.com/package/@forgedevstack/ink |
52
52
  | Repo | https://github.com/yaghobieh/ink |
53
53
 
54
- ## Feature matrix (CK-inspired → Ink 1.1.0)
54
+ ## Feature matrix (Ink 1.1.2)
55
55
 
56
56
  | Capability | Status |
57
57
  |---|---|
58
- | Classic / document editor shell | **Shipped MVP** |
59
- | Headings, lists, links, images, colors | **Shipped MVP** |
60
- | Tables (insert N×M) | **Shipped MVP** |
61
- | Undo / redo | **Shipped MVP** |
62
- | Block handles (move up/down) | **Shipped MVP** (full DnD Planned) |
63
- | Slash commands | **Shipped MVP** |
64
- | Track changes + Accept/Reject | **Shipped MVP** |
65
- | Comments archive sidebar | **Shipped MVP** |
66
- | AI chat + history | **Shipped MVP** (demo provider) |
67
- | AI Quick Actions / Review / Translate | **Shipped MVP** (demo) |
68
- | AI diff preview → apply | **Shipped MVP** |
69
- | Provider registry + model catalog | **Shipped MVP** (catalog constants; BYO run) |
70
- | Cost control / moderation / permissions / RAG hooks | **Stub** (typed interfaces + no-ops) |
71
- | Quality eval suite / MCP hosting | **Stub / Planned** |
58
+ | Classic / document editor shell | **Shipped** |
59
+ | Headings, lists, links, images, colors | **Shipped** |
60
+ | Tables (insert N×M) | **Shipped** |
61
+ | Undo / redo | **Shipped** |
62
+ | Block handles (move up/down) | **Shipped** (full DnD Planned) |
63
+ | Slash commands | **Shipped** |
64
+ | Track changes + Accept/Reject | **Shipped** |
65
+ | Comments archive sidebar | **Shipped** |
66
+ | Sign pad (canvas → image) | **Shipped** (1.1.2) |
67
+ | Keep in memory (localStorage drafts) | **Shipped** (1.1.2) |
68
+ | Find and replace | **Shipped** (1.1.2) |
69
+ | Horizontal rule | **Shipped** (1.1.2) |
70
+ | AI chat + history | **Shipped** (demo provider) |
71
+ | AI Quick Actions / Review / Translate | **Shipped** (demo) |
72
+ | Provider registry + model catalog | **Shipped** (BYO run) |
73
+ | Cost control / moderation / permissions / RAG hooks | **Stub** |
72
74
  | Real-time multiplayer CRDT | **Planned** |
73
75
 
76
+ ## Examples
77
+
78
+ ### Sign pad + draft memory
79
+
80
+ ```tsx
81
+ import { useState } from 'react';
82
+ import { InkEditor } from '@forgedevstack/ink';
83
+ import '@forgedevstack/ink/styles.css';
84
+
85
+ export function ContractEditor() {
86
+ const [html, setHtml] = useState('<p>Sign below.</p>');
87
+ return (
88
+ <InkEditor
89
+ value={html}
90
+ onChange={setHtml}
91
+ keepInMemory
92
+ memoryKey="contract-draft"
93
+ features={{ signature: true, findReplace: true, horizontalRule: true }}
94
+ toolbar={[
95
+ 'bold',
96
+ 'italic',
97
+ 'divider',
98
+ 'signature',
99
+ 'findReplace',
100
+ 'horizontalRule',
101
+ 'divider',
102
+ 'undo',
103
+ 'redo',
104
+ ]}
105
+ />
106
+ );
107
+ }
108
+ ```
109
+
110
+ **How to test sign pad**
111
+
112
+ 1. Open the portal playground or the example above.
113
+ 2. Click the **✍** toolbar button.
114
+ 3. Draw with mouse/touch on the canvas.
115
+ 4. Click **Insert** — a PNG image is inserted into the document.
116
+ 5. Refresh with `keepInMemory` + `memoryKey` — draft HTML restores.
117
+
118
+ ### Find and replace
119
+
120
+ ```tsx
121
+ <InkEditor
122
+ defaultValue="<p>Hello world</p>"
123
+ features={{ findReplace: true }}
124
+ toolbar={['findReplace', 'bold', 'italic']}
125
+ />
126
+ ```
127
+
128
+ Open **⌕**, type find/replace, use **Replace** or **Replace all** (text nodes only — attributes are safe).
129
+
74
130
  ## Props (`InkEditorProps`)
75
131
 
76
132
  | Prop | Type | Default | Description |
@@ -88,14 +144,16 @@ export function App() {
88
144
  | `tableRows` / `tableCols` | `number` | `3` | Default table size |
89
145
  | `author` | `string` | `'You'` | TC / comment author |
90
146
  | `typoAutoFix` | `boolean` | `true` | Blur typo MVP |
147
+ | `keepInMemory` | `boolean` | `false` | Persist HTML in localStorage |
148
+ | `memoryKey` | `string` | `'default'` | Storage key suffix (`ink-memory:{key}`) |
91
149
 
92
150
  ## Toolbar options
93
151
 
94
152
  ```
95
153
  headingDropdown | bold | italic | underline | strikethrough
96
154
  textColor | highlightColor | bulletList | orderedList
97
- link | image | table | undo | redo
98
- trackChanges | comments | ai | clearFormat | divider
155
+ link | image | table | signature | findReplace | horizontalRule
156
+ undo | redo | trackChanges | comments | ai | clearFormat | divider
99
157
  + align* | indent | outdent | blockquote | code | heading1–6
100
158
  ```
101
159
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),a=require("react"),J=require("../../constants/numbers.const.cjs"),d=require("../../constants/defaults.const.cjs"),ht=require("../../utils/cn.utils.cjs"),Ct=require("../../utils/typo.utils.cjs"),be=require("../../utils/id.utils.cjs"),gt=require("../../utils/table.utils.cjs"),D=require("../../utils/blocks.utils.cjs"),I=require("../../utils/trackChanges.utils.cjs"),Q=require("../../utils/comments.utils.cjs"),Ie=require("../../utils/history.utils.cjs"),Se=require("../../utils/slash.utils.cjs"),l=require("./helpers/format.utils.cjs"),p=require("./components/ToolbarButton/ToolbarButton.cjs"),pt=require("./components/ToolbarDropdown/ToolbarDropdown.cjs"),xe=require("./components/ToolbarColorPicker/ToolbarColorPicker.cjs"),kt=require("./components/CommentsPanel/CommentsPanel.cjs"),Tt=require("./components/AiPanel/AiPanel.cjs"),bt=require("./components/BlockHandles/BlockHandles.cjs"),It=require("./components/SlashMenu/SlashMenu.cjs"),St=require("./components/TrackChangesBar/TrackChangesBar.cjs"),k={bold:"B",italic:"I",underline:"U",strikethrough:"S",bulletList:"•",orderedList:"1.",link:"🔗",image:"🖼",table:"▦",undo:"↶",redo:"↷",trackChanges:"±",comments:"💬",ai:"✦",clearFormat:"⌫",alignLeft:"⫷",alignCenter:"☰",alignRight:"⫸",alignJustify:"≡",indent:"→",outdent:"←",blockquote:"“",code:"</>"},Y=()=>{const H=window.getSelection();if(!H||H.rangeCount===0)return"";const g=H.getRangeAt(0),S=document.createElement("div");return S.appendChild(g.cloneContents()),S.innerHTML},xt=H=>{var ke;const{value:g,defaultValue:S="",onChange:M,placeholder:Z=d.INK_PLACEHOLDER_DEFAULT,disabled:c=!1,readOnly:i=!1,minHeight:K=J.INK_MIN_HEIGHT,maxHeight:U,toolbar:Le=d.INK_DEFAULT_TOOLBAR,className:_e="",testId:He,allowImagePaste:Ae=!0,showCharCount:ee=!1,charCountMax:te,typoAutoFix:we=!0,variant:Ee=d.INK_DEFAULT_VARIANT,features:Ne,author:x=d.INK_DEFAULT_AUTHOR,trackChanges:A,onTrackChangesChange:q,trackChangesEnabled:y,onTrackChangesEnabledChange:P,comments:w,onCommentsChange:F,showCommentsPanel:E,onShowCommentsPanelChange:V,ai:h,slashCommands:Be,tableRows:ve=d.INK_TABLE_DEFAULT_ROWS,tableCols:ye=d.INK_TABLE_DEFAULT_COLS,...Re}=H,m={...d.INK_DEFAULT_FEATURES,...Ne},o=a.useRef(null),R=a.useRef(new Ie.InkHistoryStack(g??S)),[Oe,je]=a.useState(new Set),[De,ne]=a.useState("p"),[Me,Ke]=a.useState(0),[Ue,qe]=a.useState(J.INK_DEFAULT_TEXT_COLOR),[Pe,Fe]=a.useState(J.INK_DEFAULT_HIGHLIGHT_COLOR),[L,oe]=a.useState(y??!1),[Ve,re]=a.useState(A??[]),[Ge,se]=a.useState(w??[]),[$e,ce]=a.useState(E??!1),[ae,G]=a.useState(!!(h!=null&&h.enabled&&h.openOnInit)),[le,We]=a.useState(""),[Xe,ze]=a.useState(0),[Je,ie]=a.useState(!1),[Qe,O]=a.useState([]),[ue,Ye]=a.useState({top:0,left:0}),T=A??Ve,N=w??Ge,$=E??$e,de=Be??m.slash;a.useEffect(()=>{y!==void 0&&oe(y)},[y]),a.useEffect(()=>{A&&re(A)},[A]),a.useEffect(()=>{w&&se(w)},[w]),a.useEffect(()=>{E!==void 0&&ce(E)},[E]),a.useEffect(()=>{!o.current||g===void 0||o.current.innerHTML!==g&&(o.current.innerHTML=g)},[g]),a.useEffect(()=>{!o.current||g||!S||(o.current.innerHTML=S,R.current=new Ie.InkHistoryStack(S))},[]);const W=e=>{var t;R.current.push(e),M==null||M(e),ee&&o.current&&Ke(((t=o.current.textContent)==null?void 0:t.length)??0)},_=e=>{o.current&&(o.current.innerHTML=e,W(e))},B=e=>{re(e),q==null||q(e)},X=e=>{se(e),F==null||F(e)},z=e=>{ce(e),V==null||V(e)},Ze=e=>{oe(e),P==null||P(e)},j=()=>{je(l.getActiveFormats());const e=l.queryCommandValue("formatBlock");if(e&&ne(e.toLowerCase().replace(/[<>]/g,"")),We(Y()),!o.current||!m.blocks)return;const t=window.getSelection(),n=(t==null?void 0:t.anchorNode)??null,r=D.getBlockElement(n,o.current);if(D.markActiveBlock(o.current,r),r){const u=o.current.getBoundingClientRect(),C=r.getBoundingClientRect();ze(C.top-u.top+o.current.scrollTop),ie(!0)}else ie(!1)},f=()=>{var t,n,r;if(!o.current)return;let e=o.current.innerHTML;if(L&&m.trackChanges){const u=window.getSelection();if(u&&!u.isCollapsed){const C=Y();if(C){const b=I.createTrackChange("delete",C,x);B([...T,b]),et(b.id),e=o.current.innerHTML}}}if(W(e),j(),de&&o.current){const u=((n=(t=window.getSelection())==null?void 0:t.anchorNode)==null?void 0:n.textContent)??"",C=Se.extractSlashQuery(u);if(C!==null){O(Se.filterSlashCommands(C));const b=(r=window.getSelection())==null?void 0:r.getRangeAt(0);if(b&&o.current){const v=b.getBoundingClientRect(),Te=o.current.getBoundingClientRect();Ye({top:v.bottom-Te.top+8,left:v.left-Te.left})}}else O([])}},et=e=>{const t=window.getSelection();if(!t||t.rangeCount===0)return;const n=Y();n&&l.insertHTML(I.wrapDeleteHtml(n,e))},tt=()=>{if(!o.current||!we||!m.typoAutoFix||c||i)return;const e=o.current.innerHTML,t=Ct.applyTypoAutoFix(e);t.html!==e&&(o.current.innerHTML=t.html,W(t.html))},nt=e=>{var n;if(c||i)return;(n=o.current)==null||n.focus();const t=d.INK_BUTTON_CONFIG[e];t&&(t.value?l.execCommand(t.command,t.value):l.execCommand(t.command),f())},ot=e=>{var t;c||i||((t=o.current)==null||t.focus(),l.execCommand("formatBlock",e),ne(e),f())},rt=()=>{var t;if(c||i)return;const e=window.prompt("Enter URL:","https://");e&&((t=o.current)==null||t.focus(),l.insertLink(e),f())},st=async()=>{if(c||i)return;const e=document.createElement("input");e.type="file",e.accept="image/*",e.onchange=async()=>{var r,u;const t=(r=e.files)==null?void 0:r[0];if(!t)return;const n=await l.fileToDataUrl(t);(u=o.current)==null||u.focus(),l.insertImage(n,t.name),f()},e.click()},me=()=>{var t;if(c||i||!m.table)return;(t=o.current)==null||t.focus();const e=gt.buildTableHtml(ve,ye);if(L&&m.trackChanges){const n=I.createTrackChange("insert",e,x);B([...T,n]),l.insertHTML(I.wrapInsertHtml(e,n.id))}else l.insertHTML(e);f()},fe=()=>{const e=R.current.undo();if(e===null||!o.current){l.execCommand("undo"),f();return}_(e)},he=()=>{const e=R.current.redo();if(e===null||!o.current){l.execCommand("redo"),f();return}_(e)},ct=()=>{var u;if(c||i||!m.comments)return;const e=window.prompt("Comment:");if(!(e!=null&&e.trim()))return;const t=be.createInkId("hl");if((u=o.current)==null||u.focus(),!Q.wrapSelectionAsComment(t))return;const r=Q.createCommentThread(x,e.trim(),t);X([r,...N]),z(!0),f()},Ce=e=>{if(!o.current)return;const t=I.acceptTrackChangeInHtml(o.current.innerHTML,e);_(t),B(T.map(n=>n.id===e?{...n,accepted:!0}:n))},ge=e=>{if(!o.current)return;const t=I.rejectTrackChangeInHtml(o.current.innerHTML,e);_(t),B(T.map(n=>n.id===e?{...n,rejected:!0}:n))},at=async e=>{var n;if(!Ae||c||i)return;const t=(n=e.clipboardData)==null?void 0:n.items;if(t)for(const r of Array.from(t)){if(!r.type.startsWith("image/"))continue;e.preventDefault();const u=r.getAsFile();if(!u)continue;const C=await l.fileToDataUrl(u);if(L&&m.trackChanges){const b=`<img src="${C}" alt="" style="max-width:100%;height:auto;" />`,v=I.createTrackChange("insert",b,x);B([...T,v]),l.insertHTML(I.wrapInsertHtml(b,v.id))}else l.insertImage(C);f()}},lt=e=>{e.key==="Escape"&&O([]),(e.metaKey||e.ctrlKey)&&e.key==="z"&&(e.preventDefault(),e.shiftKey?he():fe())},it=e=>{var n,r;(n=o.current)==null||n.focus();const t=window.getSelection();if((r=t==null?void 0:t.anchorNode)!=null&&r.textContent){const C=t.anchorNode.textContent.replace(/(?:^|\s)\/[^\s]*$/," ");t.anchorNode.nodeType===Node.TEXT_NODE&&(t.anchorNode.textContent=C)}switch(O([]),e.insert){case"heading1":l.execCommand("formatBlock","h1");break;case"heading2":l.execCommand("formatBlock","h2");break;case"bulletList":l.execCommand("insertUnorderedList");break;case"orderedList":l.execCommand("insertOrderedList");break;case"table":me();return;case"ai":G(!0);break}f()},pe=e=>{if(!o.current)return;const t=window.getSelection(),n=D.getBlockElement((t==null?void 0:t.anchorNode)??null,o.current);n&&D.moveBlock(n,e)&&(f(),j())},ut=(e,t)=>{if(e==="divider")return s.jsx("span",{className:d.INK_CLASS_DIVIDER},`divider-${t}`);if(e==="headingDropdown")return s.jsx(pt.ToolbarDropdown,{title:"Heading",options:d.INK_HEADING_OPTIONS,value:De||"p",disabled:c||i,onChange:ot},"heading");if(e==="textColor")return s.jsx(xe.ToolbarColorPicker,{title:"Text color",type:"text",value:Ue,disabled:c||i,onChange:r=>{var u;(u=o.current)==null||u.focus(),l.setTextColor(r),qe(r),f()}},"textColor");if(e==="highlightColor")return s.jsx(xe.ToolbarColorPicker,{title:"Highlight color",type:"highlight",value:Pe,disabled:c||i,onChange:r=>{var u;(u=o.current)==null||u.focus(),l.setHighlightColor(r),Fe(r),f()}},"highlightColor");if(e==="link")return s.jsx(p.ToolbarButton,{icon:k.link,title:"Insert link",disabled:c||i,onClick:rt},"link");if(e==="image")return s.jsx(p.ToolbarButton,{icon:k.image,title:"Insert image",disabled:c||i,onClick:()=>{st()}},"image");if(e==="table")return m.table?s.jsx(p.ToolbarButton,{icon:k.table,title:"Insert table",disabled:c||i,onClick:me},"table"):null;if(e==="undo")return s.jsx(p.ToolbarButton,{icon:k.undo,title:"Undo",disabled:c||i,onClick:fe},"undo");if(e==="redo")return s.jsx(p.ToolbarButton,{icon:k.redo,title:"Redo",disabled:c||i,onClick:he},"redo");if(e==="trackChanges")return m.trackChanges?s.jsx(p.ToolbarButton,{icon:k.trackChanges,title:"Track changes",active:L,disabled:c||i,onClick:()=>Ze(!L)},"trackChanges"):null;if(e==="comments")return m.comments?s.jsx(p.ToolbarButton,{icon:k.comments,title:"Comments",active:$,disabled:c||i,onClick:()=>{$?z(!1):ct()}},"comments"):null;if(e==="ai")return!m.ai||!(h!=null&&h.enabled)?null:s.jsx(p.ToolbarButton,{icon:k.ai,title:"Ink AI",active:ae,disabled:c||i,onClick:()=>G(r=>!r)},"ai");const n=d.INK_BUTTON_CONFIG[e];return n?s.jsx(p.ToolbarButton,{icon:k[e]??e.slice(0,1).toUpperCase(),title:n.title,active:Oe.has(e),disabled:c||i,onClick:()=>nt(e)},e):null},dt=typeof K=="number"?`${K}px`:K,mt=typeof U=="number"?`${U}px`:U,ft=!!(h!=null&&h.enabled&&ae);return s.jsxs("div",{className:ht.cn(d.INK_CLASS_ROOT,_e),"data-testid":He,"data-disabled":c||void 0,"data-variant":Ee,...Re,children:[s.jsx("div",{className:d.INK_CLASS_TOOLBAR,role:"toolbar","aria-label":"Ink formatting toolbar",children:Le.map(ut)}),L&&m.trackChanges?s.jsx(St.TrackChangesBar,{changes:T,onAccept:Ce,onReject:ge,onAcceptAll:()=>T.forEach(e=>Ce(e.id)),onRejectAll:()=>T.forEach(e=>ge(e.id))}):null,s.jsxs("div",{className:d.INK_CLASS_SHELL,children:[s.jsxs("div",{className:d.INK_CLASS_BODY,children:[m.blocks?s.jsx(bt.BlockHandles,{visible:Je&&!c&&!i,top:Xe,onMoveUp:()=>pe("up"),onMoveDown:()=>pe("down")}):null,s.jsx("div",{ref:o,className:d.INK_CLASS_CONTENT,contentEditable:!c&&!i,role:"textbox","aria-multiline":"true","aria-placeholder":Z,"data-placeholder":Z,suppressContentEditableWarning:!0,style:{minHeight:dt,maxHeight:mt},onInput:f,onBlur:tt,onKeyUp:j,onKeyDown:lt,onMouseUp:j,onPaste:e=>{at(e)}}),de?s.jsx(It.SlashMenu,{items:Qe,top:ue.top,left:ue.left,onSelect:it}):null]}),$&&m.comments?s.jsx(kt.CommentsPanel,{comments:N,author:x,onClose:()=>z(!1),onResolve:e=>{const t=N.find(n=>n.id===e);X(N.map(n=>n.id===e?{...n,resolved:!0}:n)),t&&o.current&&_(Q.removeCommentMark(o.current.innerHTML,t.highlightId))},onAddReply:(e,t)=>{X(N.map(n=>n.id===e?{...n,replies:[...n.replies,{id:be.createInkId("reply"),author:x,body:t,timestamp:Date.now()}]}:n))}}):null,ft&&h?s.jsx(Tt.AiPanel,{config:h,documentHtml:((ke=o.current)==null?void 0:ke.innerHTML)??g??"",selectionHtml:le,onClose:()=>G(!1),onApplyHtml:e=>{var t;if((t=o.current)==null||t.focus(),le)l.insertHTML(e);else{_(e);return}f()}}):null]}),ee?s.jsxs("div",{className:d.INK_CLASS_FOOTER,children:[Me,te?` / ${te}`:""]}):null]})};exports.InkEditor=xt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),u=require("react"),ee=require("../../constants/numbers.cjs"),O=require("../../constants/toolbar.const.cjs"),f=require("../../constants/defaults.const.cjs"),Pe=require("../../constants/premium.const.cjs"),qt=require("../../utils/cn.utils.cjs"),Kt=require("../../utils/typo.utils.cjs"),ve=require("../../utils/id.utils.cjs"),Vt=require("../../utils/table.utils.cjs"),q=require("../../utils/blocks.utils.cjs"),b=require("../../utils/trackChanges.utils.cjs"),te=require("../../utils/comments.utils.cjs"),je=require("../../utils/history.utils.cjs"),Fe=require("../../utils/slash.utils.cjs"),L=require("../../utils/premium.utils.cjs"),ne=require("../../utils/paste.utils.cjs"),Ue=require("../../utils/memory.utils.cjs"),Gt=require("../../utils/findReplace.utils.cjs"),a=require("./helpers/format.utils.cjs"),C=require("./components/ToolbarButton/ToolbarButton.cjs"),Wt=require("./components/ToolbarDropdown/ToolbarDropdown.cjs"),Me=require("./components/ToolbarColorPicker/ToolbarColorPicker.cjs"),$t=require("./components/CommentsPanel/CommentsPanel.cjs"),zt=require("./components/AiPanel/AiPanel.cjs"),Xt=require("./components/BlockHandles/BlockHandles.cjs"),Zt=require("./components/SlashMenu/SlashMenu.cjs"),Qt=require("./components/TrackChangesBar/TrackChangesBar.cjs"),Yt=require("./components/SignPad/SignPad.cjs"),Jt=require("./components/FindReplace/FindReplace.cjs"),re=()=>{const N=window.getSelection();if(!N||N.rangeCount===0)return"";const T=N.getRangeAt(0),y=document.createElement("div");return y.appendChild(T.cloneContents()),y.innerHTML},en=N=>{var Be;const{value:T,defaultValue:y="",onChange:S,placeholder:oe=f.INK_PLACEHOLDER_DEFAULT,disabled:c=!1,readOnly:i=!1,minHeight:K=ee.INK_MIN_HEIGHT,maxHeight:V,toolbar:De=f.INK_DEFAULT_TOOLBAR,className:qe="",testId:Ke,allowImagePaste:se=!0,showCharCount:ce=!1,charCountMax:ae,typoAutoFix:Ve=!0,variant:Ge=f.INK_DEFAULT_VARIANT,features:We,author:x=f.INK_DEFAULT_AUTHOR,trackChanges:w,onTrackChangesChange:G,trackChangesEnabled:F,onTrackChangesEnabledChange:W,comments:R,onCommentsChange:$,showCommentsPanel:E,onShowCommentsPanelChange:z,ai:h,slashCommands:$e,tableRows:ze=f.INK_TABLE_DEFAULT_ROWS,tableCols:Xe=f.INK_TABLE_DEFAULT_COLS,premium:Ze,theme:Qe,icons:ie,pasteMode:Ye="plain",onImageUpload:le,wysiwyg:Je=!1,keepInMemory:ue=!1,memoryKey:de,style:et,...tt}=N,m={...f.INK_DEFAULT_FEATURES,...We},A=L.resolveInkPremium(Ze),nt=L.hasInkPremiumFeature(A,"icons"),rt=L.hasInkPremiumFeature(A,"theme"),ot=L.hasInkPremiumFeature(A,"richPaste"),st=L.hasInkPremiumFeature(A,"imageUpload"),ct=L.hasInkPremiumFeature(A,"wysiwyg")&&Je,p=nt&&ie?{...Pe.INK_DEFAULT_ICONS,...ie}:Pe.INK_DEFAULT_ICONS,at=rt?L.themeTokensToStyle(Qe):{},it=ot&&Ye==="rich",r=u.useRef(null),U=u.useRef(new je.InkHistoryStack(T??y)),[lt,ut]=u.useState(new Set),[dt,me]=u.useState("p"),[mt,ft]=u.useState(0),[ht,pt]=u.useState(ee.INK_DEFAULT_TEXT_COLOR),[gt,Ct]=u.useState(ee.INK_DEFAULT_HIGHLIGHT_COLOR),[H,fe]=u.useState(F??!1),[Tt,he]=u.useState(w??[]),[kt,pe]=u.useState(R??[]),[It,ge]=u.useState(E??!1),[Ce,X]=u.useState(!!(h!=null&&h.enabled&&h.openOnInit)),[Te,bt]=u.useState(""),[_t,Lt]=u.useState(0),[St,ke]=u.useState(!1),[xt,M]=u.useState([]),[Ie,At]=u.useState({top:0,left:0}),[be,_e]=u.useState(!1),[Le,Se]=u.useState(!1),k=w??Tt,B=R??kt,Z=E??It,xe=$e??m.slash;u.useEffect(()=>{F!==void 0&&fe(F)},[F]),u.useEffect(()=>{w&&he(w)},[w]),u.useEffect(()=>{R&&pe(R)},[R]),u.useEffect(()=>{E!==void 0&&ge(E)},[E]),u.useEffect(()=>{!r.current||T===void 0||r.current.innerHTML!==T&&(r.current.innerHTML=T)},[T]),u.useEffect(()=>{if(!r.current||T!==void 0)return;const t=(ue?Ue.readInkMemory(de):"")||y;t&&(r.current.innerHTML=t,U.current=new je.InkHistoryStack(t),S==null||S(t))},[]);const Q=e=>{var t;U.current.push(e),S==null||S(e),ue&&Ue.writeInkMemory(e,de),ce&&r.current&&ft(((t=r.current.textContent)==null?void 0:t.length)??0)},_=e=>{r.current&&(r.current.innerHTML=e,Q(e))},P=e=>{he(e),G==null||G(e)},Y=e=>{pe(e),$==null||$(e)},J=e=>{ge(e),z==null||z(e)},Ht=e=>{fe(e),W==null||W(e)},D=()=>{ut(a.getActiveFormats());const e=a.queryCommandValue("formatBlock");if(e&&me(e.toLowerCase().replace(/[<>]/g,"")),bt(re()),!r.current||!m.blocks)return;const t=window.getSelection(),n=(t==null?void 0:t.anchorNode)??null,o=q.getBlockElement(n,r.current);if(q.markActiveBlock(r.current,o),o){const l=r.current.getBoundingClientRect(),g=o.getBoundingClientRect();Lt(g.top-l.top+r.current.scrollTop),ke(!0)}else ke(!1)},d=()=>{var t,n,o;if(!r.current)return;let e=r.current.innerHTML;if(H&&m.trackChanges){const l=window.getSelection();if(l&&!l.isCollapsed){const g=re();if(g){const I=b.createTrackChange("delete",g,x);P([...k,I]),Ot(I.id),e=r.current.innerHTML}}}if(Q(e),D(),xe&&r.current){const l=((n=(t=window.getSelection())==null?void 0:t.anchorNode)==null?void 0:n.textContent)??"",g=Fe.extractSlashQuery(l);if(g!==null){M(Fe.filterSlashCommands(g));const I=(o=window.getSelection())==null?void 0:o.getRangeAt(0);if(I&&r.current){const v=I.getBoundingClientRect(),j=r.current.getBoundingClientRect();At({top:v.bottom-j.top+8,left:v.left-j.left})}}else M([])}},Ot=e=>{const t=window.getSelection();if(!t||t.rangeCount===0)return;const n=re();n&&a.insertHTML(b.wrapDeleteHtml(n,e))},Nt=()=>{if(!r.current||!Ve||!m.typoAutoFix||c||i)return;const e=r.current.innerHTML,t=Kt.applyTypoAutoFix(e);t.html!==e&&(r.current.innerHTML=t.html,Q(t.html))},yt=e=>{var n;if(c||i)return;(n=r.current)==null||n.focus();const t=f.INK_BUTTON_CONFIG[e];t&&(t.value?a.execCommand(t.command,t.value):a.execCommand(t.command),d())},wt=e=>{var t;c||i||((t=r.current)==null||t.focus(),a.execCommand("formatBlock",e),me(e),d())},Rt=()=>{var t;if(c||i)return;const e=window.prompt("Enter URL:","https://");e&&((t=r.current)==null||t.focus(),a.insertLink(e),d())},Ae=async e=>st&&le?le(e):a.fileToDataUrl(e),Et=async()=>{if(c||i)return;const e=document.createElement("input");e.type="file",e.accept="image/*",e.onchange=async()=>{var o,l;const t=(o=e.files)==null?void 0:o[0];if(!t)return;const n=await Ae(t);(l=r.current)==null||l.focus(),a.insertImage(n,t.name),d()},e.click()},He=()=>{var t;if(c||i||!m.table)return;(t=r.current)==null||t.focus();const e=Vt.buildTableHtml(ze,Xe);if(H&&m.trackChanges){const n=b.createTrackChange("insert",e,x);P([...k,n]),a.insertHTML(b.wrapInsertHtml(e,n.id))}else a.insertHTML(e);d()},Oe=()=>{const e=U.current.undo();if(e===null||!r.current){a.execCommand("undo"),d();return}_(e)},Ne=()=>{const e=U.current.redo();if(e===null||!r.current){a.execCommand("redo"),d();return}_(e)},Bt=()=>{var l;if(c||i||!m.comments)return;const e=window.prompt("Comment:");if(!(e!=null&&e.trim()))return;const t=ve.createInkId("hl");if((l=r.current)==null||l.focus(),!te.wrapSelectionAsComment(t))return;const o=te.createCommentThread(x,e.trim(),t);Y([o,...B]),J(!0),d()},ye=e=>{if(!r.current)return;const t=b.acceptTrackChangeInHtml(r.current.innerHTML,e);_(t),P(k.map(n=>n.id===e?{...n,accepted:!0}:n))},we=e=>{if(!r.current)return;const t=b.rejectTrackChangeInHtml(r.current.innerHTML,e);_(t),P(k.map(n=>n.id===e?{...n,rejected:!0}:n))},Re=async e=>{const t=await Ae(e),n=`<img src="${t}" alt="" style="max-width:100%;height:auto;" />`;if(H&&m.trackChanges){const o=b.createTrackChange("insert",n,x);P([...k,o]),a.insertHTML(b.wrapInsertHtml(n,o.id))}else a.insertImage(t);d()},Pt=async e=>{if(c||i)return;const t=e.clipboardData;if(!t)return;if(it){const o=ne.extractClipboardHtml(t);if(o){e.preventDefault();const g=ne.sanitizePastedHtml(o);g&&(a.insertHTML(g),d());const I=t.items;if(se&&I)for(const v of Array.from(I)){if(!v.type.startsWith("image/"))continue;const j=v.getAsFile();j&&await Re(j)}return}const l=ne.extractClipboardText(t);if(l){e.preventDefault(),a.insertHTML(l.replace(/\n/g,"<br />")),d();return}}if(!se)return;const n=t.items;if(n)for(const o of Array.from(n)){if(!o.type.startsWith("image/"))continue;e.preventDefault();const l=o.getAsFile();l&&await Re(l)}},vt=e=>{e.key==="Escape"&&M([]),(e.metaKey||e.ctrlKey)&&e.key==="z"&&(e.preventDefault(),e.shiftKey?Ne():Oe())},jt=e=>{var n,o;(n=r.current)==null||n.focus();const t=window.getSelection();if((o=t==null?void 0:t.anchorNode)!=null&&o.textContent){const g=t.anchorNode.textContent.replace(/(?:^|\s)\/[^\s]*$/," ");t.anchorNode.nodeType===Node.TEXT_NODE&&(t.anchorNode.textContent=g)}switch(M([]),e.insert){case"heading1":a.execCommand("formatBlock","h1");break;case"heading2":a.execCommand("formatBlock","h2");break;case"bulletList":a.execCommand("insertUnorderedList");break;case"orderedList":a.execCommand("insertOrderedList");break;case"table":He();return;case"ai":X(!0);break}d()},Ee=e=>{if(!r.current)return;const t=window.getSelection(),n=q.getBlockElement((t==null?void 0:t.anchorNode)??null,r.current);n&&q.moveBlock(n,e)&&(d(),D())},Ft=(e,t)=>{if(e==="divider")return s.jsx("span",{className:f.INK_CLASS_DIVIDER},`divider-${t}`);if(e==="headingDropdown")return s.jsx(Wt.ToolbarDropdown,{title:"Heading",options:f.INK_HEADING_OPTIONS,value:dt||"p",disabled:c||i,onChange:wt},"heading");if(e==="textColor")return s.jsx(Me.ToolbarColorPicker,{title:"Text color",type:"text",value:ht,disabled:c||i,onChange:o=>{var l;(l=r.current)==null||l.focus(),a.setTextColor(o),pt(o),d()}},"textColor");if(e==="highlightColor")return s.jsx(Me.ToolbarColorPicker,{title:"Highlight color",type:"highlight",value:gt,disabled:c||i,onChange:o=>{var l;(l=r.current)==null||l.focus(),a.setHighlightColor(o),Ct(o),d()}},"highlightColor");if(e==="link")return s.jsx(C.ToolbarButton,{icon:p.link,title:"Insert link",disabled:c||i,onClick:Rt},"link");if(e==="image")return s.jsx(C.ToolbarButton,{icon:p.image,title:"Insert image",disabled:c||i,onClick:()=>{Et()}},"image");if(e==="table")return m.table?s.jsx(C.ToolbarButton,{icon:p.table,title:"Insert table",disabled:c||i,onClick:He},"table"):null;if(e===O.TOOLBAR_OPTION_SIGNATURE)return m.signature?s.jsx(C.ToolbarButton,{icon:p.signature,title:"Sign pad",active:be,disabled:c||i,onClick:()=>_e(!0)},O.TOOLBAR_OPTION_SIGNATURE):null;if(e===O.TOOLBAR_OPTION_FIND_REPLACE)return m.findReplace?s.jsx(C.ToolbarButton,{icon:p.findReplace,title:"Find and replace",active:Le,disabled:c||i,onClick:()=>Se(o=>!o)},O.TOOLBAR_OPTION_FIND_REPLACE):null;if(e===O.TOOLBAR_OPTION_HORIZONTAL_RULE)return m.horizontalRule?s.jsx(C.ToolbarButton,{icon:p.horizontalRule,title:"Horizontal rule",disabled:c||i,onClick:()=>{var o;(o=r.current)==null||o.focus(),a.insertHTML("<hr />"),d()}},O.TOOLBAR_OPTION_HORIZONTAL_RULE):null;if(e==="undo")return s.jsx(C.ToolbarButton,{icon:p.undo,title:"Undo",disabled:c||i,onClick:Oe},"undo");if(e==="redo")return s.jsx(C.ToolbarButton,{icon:p.redo,title:"Redo",disabled:c||i,onClick:Ne},"redo");if(e==="trackChanges")return m.trackChanges?s.jsx(C.ToolbarButton,{icon:p.trackChanges,title:"Track changes",active:H,disabled:c||i,onClick:()=>Ht(!H)},"trackChanges"):null;if(e==="comments")return m.comments?s.jsx(C.ToolbarButton,{icon:p.comments,title:"Comments",active:Z,disabled:c||i,onClick:()=>{Z?J(!1):Bt()}},"comments"):null;if(e==="ai")return!m.ai||!(h!=null&&h.enabled)?null:s.jsx(C.ToolbarButton,{icon:p.ai,title:"Ink AI",active:Ce,disabled:c||i,onClick:()=>X(o=>!o)},"ai");const n=f.INK_BUTTON_CONFIG[e];return n?s.jsx(C.ToolbarButton,{icon:p[e]??e.slice(0,1).toUpperCase(),title:n.title,active:lt.has(e),disabled:c||i,onClick:()=>yt(e)},e):null},Ut=typeof K=="number"?`${K}px`:K,Mt=typeof V=="number"?`${V}px`:V,Dt=!!(h!=null&&h.enabled&&Ce);return s.jsxs("div",{className:qt.cn(f.INK_CLASS_ROOT,qe),"data-testid":Ke,"data-disabled":c||void 0,"data-variant":Ge,"data-premium":A.active||void 0,"data-wysiwyg":ct||void 0,style:{...at,...et},...tt,children:[s.jsx("div",{className:f.INK_CLASS_TOOLBAR,role:"toolbar","aria-label":"Ink formatting toolbar",children:De.map(Ft)}),s.jsx(Yt.SignPad,{open:be,onClose:()=>_e(!1),onConfirm:e=>{var t;(t=r.current)==null||t.focus(),a.insertImage(e),d()}}),s.jsx(Jt.FindReplace,{open:Le,onClose:()=>Se(!1),onReplace:(e,t,n)=>{if(!r.current)return;const o=Gt.replaceInHtml(r.current.innerHTML,e,t,n);_(o)}}),H&&m.trackChanges?s.jsx(Qt.TrackChangesBar,{changes:k,onAccept:ye,onReject:we,onAcceptAll:()=>k.forEach(e=>ye(e.id)),onRejectAll:()=>k.forEach(e=>we(e.id))}):null,s.jsxs("div",{className:f.INK_CLASS_SHELL,children:[s.jsxs("div",{className:f.INK_CLASS_BODY,children:[m.blocks?s.jsx(Xt.BlockHandles,{visible:St&&!c&&!i,top:_t,onMoveUp:()=>Ee("up"),onMoveDown:()=>Ee("down")}):null,s.jsx("div",{ref:r,className:f.INK_CLASS_CONTENT,contentEditable:!c&&!i,role:"textbox","aria-multiline":"true","aria-placeholder":oe,"data-placeholder":oe,suppressContentEditableWarning:!0,style:{minHeight:Ut,maxHeight:Mt},onInput:d,onBlur:Nt,onKeyUp:D,onKeyDown:vt,onMouseUp:D,onPaste:e=>{Pt(e)}}),xe?s.jsx(Zt.SlashMenu,{items:xt,top:Ie.top,left:Ie.left,onSelect:jt}):null]}),Z&&m.comments?s.jsx($t.CommentsPanel,{comments:B,author:x,onClose:()=>J(!1),onResolve:e=>{const t=B.find(n=>n.id===e);Y(B.map(n=>n.id===e?{...n,resolved:!0}:n)),t&&r.current&&_(te.removeCommentMark(r.current.innerHTML,t.highlightId))},onAddReply:(e,t)=>{Y(B.map(n=>n.id===e?{...n,replies:[...n.replies,{id:ve.createInkId("reply"),author:x,body:t,timestamp:Date.now()}]}:n))}}):null,Dt&&h?s.jsx(zt.AiPanel,{config:h,documentHtml:((Be=r.current)==null?void 0:Be.innerHTML)??T??"",selectionHtml:Te,onClose:()=>X(!1),onApplyHtml:e=>{var t;if((t=r.current)==null||t.focus(),Te)a.insertHTML(e);else{_(e);return}d()}}):null]}),ce?s.jsxs("div",{className:f.INK_CLASS_FOOTER,children:[mt,ae?` / ${ae}`:""]}):null]})};exports.InkEditor=en;
@@ -1 +1 @@
1
- {"version":3,"file":"InkEditor.d.ts","sourceRoot":"","sources":["../../../src/components/InkEditor/InkEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,EAAE,EAIR,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAEV,cAAc,EAIf,MAAM,aAAa,CAAC;AAmGrB,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAyqBxC,CAAC"}
1
+ {"version":3,"file":"InkEditor.d.ts","sourceRoot":"","sources":["../../../src/components/InkEditor/InkEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,EAAE,EAIR,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAEV,cAAc,EAIf,MAAM,aAAa,CAAC;AAwFrB,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CA6yBxC,CAAC"}