@forgedevstack/ink 1.1.1 → 1.1.3

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 (95) hide show
  1. package/CHANGELOG.md +28 -6
  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 +425 -351
  6. package/dist/components/InkEditor/components/FindReplace/FindReplace.cjs +1 -0
  7. package/dist/components/InkEditor/components/FindReplace/FindReplace.const.cjs +1 -0
  8. package/dist/components/InkEditor/components/FindReplace/FindReplace.const.d.ts +11 -0
  9. package/dist/components/InkEditor/components/FindReplace/FindReplace.const.d.ts.map +1 -0
  10. package/dist/components/InkEditor/components/FindReplace/FindReplace.const.js +13 -0
  11. package/dist/components/InkEditor/components/FindReplace/FindReplace.d.ts +4 -0
  12. package/dist/components/InkEditor/components/FindReplace/FindReplace.d.ts.map +1 -0
  13. package/dist/components/InkEditor/components/FindReplace/FindReplace.js +49 -0
  14. package/dist/components/InkEditor/components/FindReplace/FindReplace.types.d.ts +12 -0
  15. package/dist/components/InkEditor/components/FindReplace/FindReplace.types.d.ts.map +1 -0
  16. package/dist/components/InkEditor/components/FindReplace/index.d.ts +3 -0
  17. package/dist/components/InkEditor/components/FindReplace/index.d.ts.map +1 -0
  18. package/dist/components/InkEditor/components/SignPad/SignPad.cjs +1 -0
  19. package/dist/components/InkEditor/components/SignPad/SignPad.const.cjs +1 -0
  20. package/dist/components/InkEditor/components/SignPad/SignPad.const.d.ts +24 -0
  21. package/dist/components/InkEditor/components/SignPad/SignPad.const.d.ts.map +1 -0
  22. package/dist/components/InkEditor/components/SignPad/SignPad.const.js +18 -0
  23. package/dist/components/InkEditor/components/SignPad/SignPad.d.ts +4 -0
  24. package/dist/components/InkEditor/components/SignPad/SignPad.d.ts.map +1 -0
  25. package/dist/components/InkEditor/components/SignPad/SignPad.js +79 -0
  26. package/dist/components/InkEditor/components/SignPad/SignPad.types.d.ts +10 -0
  27. package/dist/components/InkEditor/components/SignPad/SignPad.types.d.ts.map +1 -0
  28. package/dist/components/InkEditor/components/SignPad/SignPad.utils.cjs +1 -0
  29. package/dist/components/InkEditor/components/SignPad/SignPad.utils.d.ts +6 -0
  30. package/dist/components/InkEditor/components/SignPad/SignPad.utils.d.ts.map +1 -0
  31. package/dist/components/InkEditor/components/SignPad/SignPad.utils.js +10 -0
  32. package/dist/components/InkEditor/components/SignPad/SignPad.utils.test.d.ts +2 -0
  33. package/dist/components/InkEditor/components/SignPad/SignPad.utils.test.d.ts.map +1 -0
  34. package/dist/components/InkEditor/components/SignPad/index.d.ts +3 -0
  35. package/dist/components/InkEditor/components/SignPad/index.d.ts.map +1 -0
  36. package/dist/components/InkEditor/components/index.d.ts +2 -0
  37. package/dist/components/InkEditor/components/index.d.ts.map +1 -1
  38. package/dist/constants/defaults.const.cjs +1 -1
  39. package/dist/constants/defaults.const.d.ts.map +1 -1
  40. package/dist/constants/defaults.const.js +46 -39
  41. package/dist/constants/generals.const.cjs +1 -0
  42. package/dist/constants/generals.const.d.ts +7 -0
  43. package/dist/constants/generals.const.d.ts.map +1 -0
  44. package/dist/constants/generals.const.js +6 -0
  45. package/dist/constants/index.d.ts +3 -1
  46. package/dist/constants/index.d.ts.map +1 -1
  47. package/dist/constants/numbers.cjs +1 -0
  48. package/dist/constants/numbers.d.ts +121 -0
  49. package/dist/constants/numbers.d.ts.map +1 -0
  50. package/dist/constants/numbers.js +18 -0
  51. package/dist/constants/premium.const.cjs +1 -1
  52. package/dist/constants/premium.const.d.ts.map +1 -1
  53. package/dist/constants/premium.const.js +3 -0
  54. package/dist/constants/toolbar.const.cjs +1 -0
  55. package/dist/constants/toolbar.const.d.ts +4 -0
  56. package/dist/constants/toolbar.const.d.ts.map +1 -0
  57. package/dist/constants/toolbar.const.js +6 -0
  58. package/dist/plugins/ai/demoProvider.cjs +1 -1
  59. package/dist/plugins/ai/demoProvider.js +1 -1
  60. package/dist/styles.css +51 -0
  61. package/dist/types/features.types.d.ts +1 -1
  62. package/dist/types/features.types.d.ts.map +1 -1
  63. package/dist/types/ink.types.d.ts +3 -1
  64. package/dist/types/ink.types.d.ts.map +1 -1
  65. package/dist/types/premium.types.d.ts +1 -1
  66. package/dist/types/premium.types.d.ts.map +1 -1
  67. package/dist/utils/comments.utils.cjs +1 -1
  68. package/dist/utils/comments.utils.js +1 -1
  69. package/dist/utils/findReplace.utils.cjs +1 -0
  70. package/dist/utils/findReplace.utils.d.ts +3 -0
  71. package/dist/utils/findReplace.utils.d.ts.map +1 -0
  72. package/dist/utils/findReplace.utils.js +26 -0
  73. package/dist/utils/history.utils.cjs +1 -1
  74. package/dist/utils/history.utils.js +1 -1
  75. package/dist/utils/index.d.ts +3 -0
  76. package/dist/utils/index.d.ts.map +1 -1
  77. package/dist/utils/ink.features.test.d.ts +2 -0
  78. package/dist/utils/ink.features.test.d.ts.map +1 -0
  79. package/dist/utils/memory.utils.cjs +1 -0
  80. package/dist/utils/memory.utils.d.ts +5 -0
  81. package/dist/utils/memory.utils.d.ts.map +1 -0
  82. package/dist/utils/memory.utils.js +22 -0
  83. package/dist/utils/slash.utils.cjs +1 -1
  84. package/dist/utils/slash.utils.js +1 -1
  85. package/dist/utils/storage.utils.cjs +1 -0
  86. package/dist/utils/storage.utils.d.ts +2 -0
  87. package/dist/utils/storage.utils.d.ts.map +1 -0
  88. package/dist/utils/storage.utils.js +4 -0
  89. package/dist/utils/table.utils.cjs +1 -1
  90. package/dist/utils/table.utils.js +1 -1
  91. package/package.json +3 -2
  92. package/dist/constants/numbers.const.cjs +0 -1
  93. package/dist/constants/numbers.const.d.ts +0 -18
  94. package/dist/constants/numbers.const.d.ts.map +0 -1
  95. package/dist/constants/numbers.const.js +0 -16
package/CHANGELOG.md CHANGED
@@ -1,8 +1,30 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ ## Unreleased — 1.1.3
4
+
5
+ ### Fixed
6
+ - `keepInMemory` restores drafts on mount in controlled mode via `onChange`
7
+ - SignPad clears drawing state when closed; Insert relies on stroke state only
8
+ - `canvasHasInk` ignores white fill (RGB), not alpha alone
9
+ - localStorage read/write/clear wrapped in try/catch
10
+ - Default memory key moved to `DEFAULT_MEMORY_KEY` const
11
+
12
+ ## 1.1.2 — 2026-08-04
4
13
 
5
14
  ### Added
15
+ - Sign pad toolbar (`signature`) — canvas draw → insert PNG image
16
+ - `keepInMemory` + `memoryKey` — persist draft HTML in localStorage
17
+ - Find and replace toolbar (`findReplace`) — text-node safe
18
+ - Horizontal rule toolbar (`horizontalRule`)
19
+ - Aerocraft-style utility classes for SignPad / FindReplace panels
20
+ - `isLocalStorageAvailable` util; path aliases (`@/`)
21
+ - Docs: Jira bootstrap, Confluence paste pack, payments research, articles + Gemini video prompt
22
+ - Examples in README for sign pad, memory, find/replace
23
+
24
+ ### Changed
25
+ - Product copy no longer names other editor vendors
26
+
27
+ ### Previously unreleased (1.1.1)
6
28
  - Premium scaffolding: `premium={{ enabled | licenseKey }}` unlocks theme tokens, icon map, rich paste, image upload, WYSIWYG
7
29
  - Props: `theme`, `icons`, `pasteMode="rich"`, `onImageUpload`, `wysiwyg`
8
30
  - Helpers: `resolveInkPremium`, `mintInkPremiumLicenseKey`, `sanitizePastedHtml`, `INK_DEFAULT_ICONS`
@@ -12,7 +34,7 @@
12
34
  ## 1.1.0 — 2026-08-01
13
35
 
14
36
  ### Added
15
- - CKEditor-inspired editor shell: soft light card, rounded toolbar, `variant="classic" | "document"`
37
+ - Editor shell: soft light card, rounded toolbar, `variant="classic" | "document"`
16
38
  - Structure blocks with hover/focus outline and block handles (move up/down MVP)
17
39
  - Toolbar: table insert, undo/redo, track changes, comments, AI toggles
18
40
  - Tables: insert N×M HTML tables with basic editable cells
@@ -31,17 +53,17 @@
31
53
  - Exports: `INK_COLLAB_TOOLBAR`, `INK_AI_MODEL_CATALOG`, `buildTableHtml`, comment/track helpers
32
54
 
33
55
  ### Docs
34
- - Feature matrix: CK-inspired capabilities → Ink status (Shipped MVP / Stub / Planned)
35
- - Honesty framing: CKEditor-inspired architecture with local demo providers; bring your own LLM. No SOC2/enterprise hosting claims.
56
+ - Feature matrix: capability → Ink status (Shipped MVP / Stub / Planned)
57
+ - Honesty framing: local demo providers; bring your own LLM. No SOC2/enterprise hosting claims.
36
58
 
37
59
  ## 1.0.1 — 2026-08-01
38
60
 
39
61
  ### Added
40
62
  - Theme helper classes: `.ink-theme-snow`, `.ink-theme-bubble`, `.ink-theme-dark`, `.ink-theme-minimal`
41
- - Expanded README: full prop table, `ToolbarOption` list, CSS variables, Quill positioning, portal links, asset screenshots
63
+ - Expanded README: full prop table, `ToolbarOption` list, CSS variables, portal links, asset screenshots
42
64
 
43
65
  ### Docs
44
- - Companion light Quill-inspired portal (docs + Format/Modules/Theme playground)
66
+ - Companion light portal (docs + Format/Modules/Theme playground)
45
67
 
46
68
  ## 1.0.0 — 2026-08-01
47
69
 
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 (memory wins on mount for controlled `value` / `onChange` too).
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 c=require("react/jsx-runtime"),l=require("react"),Z=require("../../constants/numbers.const.cjs"),m=require("../../constants/defaults.const.cjs"),Ae=require("../../constants/premium.const.cjs"),Pt=require("../../utils/cn.utils.cjs"),Rt=require("../../utils/typo.utils.cjs"),ye=require("../../utils/id.utils.cjs"),Ot=require("../../utils/table.utils.cjs"),F=require("../../utils/blocks.utils.cjs"),I=require("../../utils/trackChanges.utils.cjs"),ee=require("../../utils/comments.utils.cjs"),Ee=require("../../utils/history.utils.cjs"),Ne=require("../../utils/slash.utils.cjs"),S=require("../../utils/premium.utils.cjs"),te=require("../../utils/paste.utils.cjs"),a=require("./helpers/format.utils.cjs"),T=require("./components/ToolbarButton/ToolbarButton.cjs"),Dt=require("./components/ToolbarDropdown/ToolbarDropdown.cjs"),ve=require("./components/ToolbarColorPicker/ToolbarColorPicker.cjs"),Ut=require("./components/CommentsPanel/CommentsPanel.cjs"),jt=require("./components/AiPanel/AiPanel.cjs"),Ft=require("./components/BlockHandles/BlockHandles.cjs"),Mt=require("./components/SlashMenu/SlashMenu.cjs"),Kt=require("./components/TrackChangesBar/TrackChangesBar.cjs"),ne=()=>{const A=window.getSelection();if(!A||A.rangeCount===0)return"";const g=A.getRangeAt(0),x=document.createElement("div");return x.appendChild(g.cloneContents()),x.innerHTML},qt=A=>{var Le;const{value:g,defaultValue:x="",onChange:M,placeholder:re=m.INK_PLACEHOLDER_DEFAULT,disabled:i=!1,readOnly:u=!1,minHeight:K=Z.INK_MIN_HEIGHT,maxHeight:q,toolbar:Be=m.INK_DEFAULT_TOOLBAR,className:Pe="",testId:Re,allowImagePaste:oe=!0,showCharCount:se=!1,charCountMax:ce,typoAutoFix:Oe=!0,variant:De=m.INK_DEFAULT_VARIANT,features:Ue,author:_=m.INK_DEFAULT_AUTHOR,trackChanges:y,onTrackChangesChange:V,trackChangesEnabled:O,onTrackChangesEnabledChange:G,comments:E,onCommentsChange:W,showCommentsPanel:N,onShowCommentsPanelChange:$,ai:h,slashCommands:je,tableRows:Fe=m.INK_TABLE_DEFAULT_ROWS,tableCols:Me=m.INK_TABLE_DEFAULT_COLS,premium:Ke,theme:qe,icons:ae,pasteMode:Ve="plain",onImageUpload:ie,wysiwyg:Ge=!1,style:We,...$e}=A,f={...m.INK_DEFAULT_FEATURES,...Ue},H=S.resolveInkPremium(Ke),ze=S.hasInkPremiumFeature(H,"icons"),Xe=S.hasInkPremiumFeature(H,"theme"),Qe=S.hasInkPremiumFeature(H,"richPaste"),Ye=S.hasInkPremiumFeature(H,"imageUpload"),Je=S.hasInkPremiumFeature(H,"wysiwyg")&&Ge,C=ze&&ae?{...Ae.INK_DEFAULT_ICONS,...ae}:Ae.INK_DEFAULT_ICONS,Ze=Xe?S.themeTokensToStyle(qe):{},et=Qe&&Ve==="rich",r=l.useRef(null),D=l.useRef(new Ee.InkHistoryStack(g??x)),[tt,nt]=l.useState(new Set),[rt,le]=l.useState("p"),[ot,st]=l.useState(0),[ct,at]=l.useState(Z.INK_DEFAULT_TEXT_COLOR),[it,lt]=l.useState(Z.INK_DEFAULT_HIGHLIGHT_COLOR),[w,ue]=l.useState(O??!1),[ut,de]=l.useState(y??[]),[dt,me]=l.useState(E??[]),[mt,fe]=l.useState(N??!1),[he,z]=l.useState(!!(h!=null&&h.enabled&&h.openOnInit)),[pe,ft]=l.useState(""),[ht,pt]=l.useState(0),[gt,ge]=l.useState(!1),[Ct,U]=l.useState([]),[Ce,Tt]=l.useState({top:0,left:0}),k=y??ut,v=E??dt,X=N??mt,Te=je??f.slash;l.useEffect(()=>{O!==void 0&&ue(O)},[O]),l.useEffect(()=>{y&&de(y)},[y]),l.useEffect(()=>{E&&me(E)},[E]),l.useEffect(()=>{N!==void 0&&fe(N)},[N]),l.useEffect(()=>{!r.current||g===void 0||r.current.innerHTML!==g&&(r.current.innerHTML=g)},[g]),l.useEffect(()=>{!r.current||g||!x||(r.current.innerHTML=x,D.current=new Ee.InkHistoryStack(x))},[]);const Q=e=>{var t;D.current.push(e),M==null||M(e),se&&r.current&&st(((t=r.current.textContent)==null?void 0:t.length)??0)},L=e=>{r.current&&(r.current.innerHTML=e,Q(e))},B=e=>{de(e),V==null||V(e)},Y=e=>{me(e),W==null||W(e)},J=e=>{fe(e),$==null||$(e)},kt=e=>{ue(e),G==null||G(e)},j=()=>{nt(a.getActiveFormats());const e=a.queryCommandValue("formatBlock");if(e&&le(e.toLowerCase().replace(/[<>]/g,"")),ft(ne()),!r.current||!f.blocks)return;const t=window.getSelection(),n=(t==null?void 0:t.anchorNode)??null,o=F.getBlockElement(n,r.current);if(F.markActiveBlock(r.current,o),o){const s=r.current.getBoundingClientRect(),p=o.getBoundingClientRect();pt(p.top-s.top+r.current.scrollTop),ge(!0)}else ge(!1)},d=()=>{var t,n,o;if(!r.current)return;let e=r.current.innerHTML;if(w&&f.trackChanges){const s=window.getSelection();if(s&&!s.isCollapsed){const p=ne();if(p){const b=I.createTrackChange("delete",p,_);B([...k,b]),bt(b.id),e=r.current.innerHTML}}}if(Q(e),j(),Te&&r.current){const s=((n=(t=window.getSelection())==null?void 0:t.anchorNode)==null?void 0:n.textContent)??"",p=Ne.extractSlashQuery(s);if(p!==null){U(Ne.filterSlashCommands(p));const b=(o=window.getSelection())==null?void 0:o.getRangeAt(0);if(b&&r.current){const P=b.getBoundingClientRect(),R=r.current.getBoundingClientRect();Tt({top:P.bottom-R.top+8,left:P.left-R.left})}}else U([])}},bt=e=>{const t=window.getSelection();if(!t||t.rangeCount===0)return;const n=ne();n&&a.insertHTML(I.wrapDeleteHtml(n,e))},It=()=>{if(!r.current||!Oe||!f.typoAutoFix||i||u)return;const e=r.current.innerHTML,t=Rt.applyTypoAutoFix(e);t.html!==e&&(r.current.innerHTML=t.html,Q(t.html))},xt=e=>{var n;if(i||u)return;(n=r.current)==null||n.focus();const t=m.INK_BUTTON_CONFIG[e];t&&(t.value?a.execCommand(t.command,t.value):a.execCommand(t.command),d())},St=e=>{var t;i||u||((t=r.current)==null||t.focus(),a.execCommand("formatBlock",e),le(e),d())},_t=()=>{var t;if(i||u)return;const e=window.prompt("Enter URL:","https://");e&&((t=r.current)==null||t.focus(),a.insertLink(e),d())},ke=async e=>Ye&&ie?ie(e):a.fileToDataUrl(e),Ht=async()=>{if(i||u)return;const e=document.createElement("input");e.type="file",e.accept="image/*",e.onchange=async()=>{var o,s;const t=(o=e.files)==null?void 0:o[0];if(!t)return;const n=await ke(t);(s=r.current)==null||s.focus(),a.insertImage(n,t.name),d()},e.click()},be=()=>{var t;if(i||u||!f.table)return;(t=r.current)==null||t.focus();const e=Ot.buildTableHtml(Fe,Me);if(w&&f.trackChanges){const n=I.createTrackChange("insert",e,_);B([...k,n]),a.insertHTML(I.wrapInsertHtml(e,n.id))}else a.insertHTML(e);d()},Ie=()=>{const e=D.current.undo();if(e===null||!r.current){a.execCommand("undo"),d();return}L(e)},xe=()=>{const e=D.current.redo();if(e===null||!r.current){a.execCommand("redo"),d();return}L(e)},wt=()=>{var s;if(i||u||!f.comments)return;const e=window.prompt("Comment:");if(!(e!=null&&e.trim()))return;const t=ye.createInkId("hl");if((s=r.current)==null||s.focus(),!ee.wrapSelectionAsComment(t))return;const o=ee.createCommentThread(_,e.trim(),t);Y([o,...v]),J(!0),d()},Se=e=>{if(!r.current)return;const t=I.acceptTrackChangeInHtml(r.current.innerHTML,e);L(t),B(k.map(n=>n.id===e?{...n,accepted:!0}:n))},_e=e=>{if(!r.current)return;const t=I.rejectTrackChangeInHtml(r.current.innerHTML,e);L(t),B(k.map(n=>n.id===e?{...n,rejected:!0}:n))},He=async e=>{const t=await ke(e),n=`<img src="${t}" alt="" style="max-width:100%;height:auto;" />`;if(w&&f.trackChanges){const o=I.createTrackChange("insert",n,_);B([...k,o]),a.insertHTML(I.wrapInsertHtml(n,o.id))}else a.insertImage(t);d()},Lt=async e=>{if(i||u)return;const t=e.clipboardData;if(!t)return;if(et){const o=te.extractClipboardHtml(t);if(o){e.preventDefault();const p=te.sanitizePastedHtml(o);p&&(a.insertHTML(p),d());const b=t.items;if(oe&&b)for(const P of Array.from(b)){if(!P.type.startsWith("image/"))continue;const R=P.getAsFile();R&&await He(R)}return}const s=te.extractClipboardText(t);if(s){e.preventDefault(),a.insertHTML(s.replace(/\n/g,"<br />")),d();return}}if(!oe)return;const n=t.items;if(n)for(const o of Array.from(n)){if(!o.type.startsWith("image/"))continue;e.preventDefault();const s=o.getAsFile();s&&await He(s)}},At=e=>{e.key==="Escape"&&U([]),(e.metaKey||e.ctrlKey)&&e.key==="z"&&(e.preventDefault(),e.shiftKey?xe():Ie())},yt=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 p=t.anchorNode.textContent.replace(/(?:^|\s)\/[^\s]*$/," ");t.anchorNode.nodeType===Node.TEXT_NODE&&(t.anchorNode.textContent=p)}switch(U([]),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":be();return;case"ai":z(!0);break}d()},we=e=>{if(!r.current)return;const t=window.getSelection(),n=F.getBlockElement((t==null?void 0:t.anchorNode)??null,r.current);n&&F.moveBlock(n,e)&&(d(),j())},Et=(e,t)=>{if(e==="divider")return c.jsx("span",{className:m.INK_CLASS_DIVIDER},`divider-${t}`);if(e==="headingDropdown")return c.jsx(Dt.ToolbarDropdown,{title:"Heading",options:m.INK_HEADING_OPTIONS,value:rt||"p",disabled:i||u,onChange:St},"heading");if(e==="textColor")return c.jsx(ve.ToolbarColorPicker,{title:"Text color",type:"text",value:ct,disabled:i||u,onChange:o=>{var s;(s=r.current)==null||s.focus(),a.setTextColor(o),at(o),d()}},"textColor");if(e==="highlightColor")return c.jsx(ve.ToolbarColorPicker,{title:"Highlight color",type:"highlight",value:it,disabled:i||u,onChange:o=>{var s;(s=r.current)==null||s.focus(),a.setHighlightColor(o),lt(o),d()}},"highlightColor");if(e==="link")return c.jsx(T.ToolbarButton,{icon:C.link,title:"Insert link",disabled:i||u,onClick:_t},"link");if(e==="image")return c.jsx(T.ToolbarButton,{icon:C.image,title:"Insert image",disabled:i||u,onClick:()=>{Ht()}},"image");if(e==="table")return f.table?c.jsx(T.ToolbarButton,{icon:C.table,title:"Insert table",disabled:i||u,onClick:be},"table"):null;if(e==="undo")return c.jsx(T.ToolbarButton,{icon:C.undo,title:"Undo",disabled:i||u,onClick:Ie},"undo");if(e==="redo")return c.jsx(T.ToolbarButton,{icon:C.redo,title:"Redo",disabled:i||u,onClick:xe},"redo");if(e==="trackChanges")return f.trackChanges?c.jsx(T.ToolbarButton,{icon:C.trackChanges,title:"Track changes",active:w,disabled:i||u,onClick:()=>kt(!w)},"trackChanges"):null;if(e==="comments")return f.comments?c.jsx(T.ToolbarButton,{icon:C.comments,title:"Comments",active:X,disabled:i||u,onClick:()=>{X?J(!1):wt()}},"comments"):null;if(e==="ai")return!f.ai||!(h!=null&&h.enabled)?null:c.jsx(T.ToolbarButton,{icon:C.ai,title:"Ink AI",active:he,disabled:i||u,onClick:()=>z(o=>!o)},"ai");const n=m.INK_BUTTON_CONFIG[e];return n?c.jsx(T.ToolbarButton,{icon:C[e]??e.slice(0,1).toUpperCase(),title:n.title,active:tt.has(e),disabled:i||u,onClick:()=>xt(e)},e):null},Nt=typeof K=="number"?`${K}px`:K,vt=typeof q=="number"?`${q}px`:q,Bt=!!(h!=null&&h.enabled&&he);return c.jsxs("div",{className:Pt.cn(m.INK_CLASS_ROOT,Pe),"data-testid":Re,"data-disabled":i||void 0,"data-variant":De,"data-premium":H.active||void 0,"data-wysiwyg":Je||void 0,style:{...Ze,...We},...$e,children:[c.jsx("div",{className:m.INK_CLASS_TOOLBAR,role:"toolbar","aria-label":"Ink formatting toolbar",children:Be.map(Et)}),w&&f.trackChanges?c.jsx(Kt.TrackChangesBar,{changes:k,onAccept:Se,onReject:_e,onAcceptAll:()=>k.forEach(e=>Se(e.id)),onRejectAll:()=>k.forEach(e=>_e(e.id))}):null,c.jsxs("div",{className:m.INK_CLASS_SHELL,children:[c.jsxs("div",{className:m.INK_CLASS_BODY,children:[f.blocks?c.jsx(Ft.BlockHandles,{visible:gt&&!i&&!u,top:ht,onMoveUp:()=>we("up"),onMoveDown:()=>we("down")}):null,c.jsx("div",{ref:r,className:m.INK_CLASS_CONTENT,contentEditable:!i&&!u,role:"textbox","aria-multiline":"true","aria-placeholder":re,"data-placeholder":re,suppressContentEditableWarning:!0,style:{minHeight:Nt,maxHeight:vt},onInput:d,onBlur:It,onKeyUp:j,onKeyDown:At,onMouseUp:j,onPaste:e=>{Lt(e)}}),Te?c.jsx(Mt.SlashMenu,{items:Ct,top:Ce.top,left:Ce.left,onSelect:yt}):null]}),X&&f.comments?c.jsx(Ut.CommentsPanel,{comments:v,author:_,onClose:()=>J(!1),onResolve:e=>{const t=v.find(n=>n.id===e);Y(v.map(n=>n.id===e?{...n,resolved:!0}:n)),t&&r.current&&L(ee.removeCommentMark(r.current.innerHTML,t.highlightId))},onAddReply:(e,t)=>{Y(v.map(n=>n.id===e?{...n,replies:[...n.replies,{id:ye.createInkId("reply"),author:_,body:t,timestamp:Date.now()}]}:n))}}):null,Bt&&h?c.jsx(jt.AiPanel,{config:h,documentHtml:((Le=r.current)==null?void 0:Le.innerHTML)??g??"",selectionHtml:pe,onClose:()=>z(!1),onApplyHtml:e=>{var t;if((t=r.current)==null||t.focus(),pe)a.insertHTML(e);else{L(e);return}d()}}):null]}),se?c.jsxs("div",{className:m.INK_CLASS_FOOTER,children:[ot,ce?` / ${ce}`:""]}):null]})};exports.InkEditor=qt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),u=require("react"),ee=require("../../constants/numbers.cjs"),y=require("../../constants/toolbar.const.cjs"),f=require("../../constants/defaults.const.cjs"),ve=require("../../constants/premium.const.cjs"),qt=require("../../utils/cn.utils.cjs"),Kt=require("../../utils/typo.utils.cjs"),je=require("../../utils/id.utils.cjs"),Vt=require("../../utils/table.utils.cjs"),q=require("../../utils/blocks.utils.cjs"),L=require("../../utils/trackChanges.utils.cjs"),te=require("../../utils/comments.utils.cjs"),ne=require("../../utils/history.utils.cjs"),Fe=require("../../utils/slash.utils.cjs"),x=require("../../utils/premium.utils.cjs"),re=require("../../utils/paste.utils.cjs"),Me=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"),Ue=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"),oe=()=>{const N=window.getSelection();if(!N||N.rangeCount===0)return"";const T=N.getRangeAt(0),I=document.createElement("div");return I.appendChild(T.cloneContents()),I.innerHTML},en=N=>{var Pe;const{value:T,defaultValue:I="",onChange:k,placeholder:se=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:ce=!0,showCharCount:ae=!1,charCountMax:ie,typoAutoFix:Ve=!0,variant:Ge=f.INK_DEFAULT_VARIANT,features:We,author:A=f.INK_DEFAULT_AUTHOR,trackChanges:w,onTrackChangesChange:G,trackChangesEnabled:M,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:le,pasteMode:Ye="plain",onImageUpload:ue,wysiwyg:Je=!1,keepInMemory:de=!1,memoryKey:me,style:et,...tt}=N,m={...f.INK_DEFAULT_FEATURES,...We},H=x.resolveInkPremium(Ze),nt=x.hasInkPremiumFeature(H,"icons"),rt=x.hasInkPremiumFeature(H,"theme"),ot=x.hasInkPremiumFeature(H,"richPaste"),st=x.hasInkPremiumFeature(H,"imageUpload"),ct=x.hasInkPremiumFeature(H,"wysiwyg")&&Je,p=nt&&le?{...ve.INK_DEFAULT_ICONS,...le}:ve.INK_DEFAULT_ICONS,at=rt?x.themeTokensToStyle(Qe):{},it=ot&&Ye==="rich",r=u.useRef(null),B=u.useRef(new ne.InkHistoryStack(T??I)),[lt,ut]=u.useState(new Set),[dt,fe]=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),[O,he]=u.useState(M??!1),[Tt,pe]=u.useState(w??[]),[kt,ge]=u.useState(R??[]),[It,Ce]=u.useState(E??!1),[Te,X]=u.useState(!!(h!=null&&h.enabled&&h.openOnInit)),[ke,bt]=u.useState(""),[_t,Lt]=u.useState(0),[St,Ie]=u.useState(!1),[xt,U]=u.useState([]),[be,At]=u.useState({top:0,left:0}),[_e,Le]=u.useState(!1),[Se,xe]=u.useState(!1),b=w??Tt,P=R??kt,Z=E??It,Ae=$e??m.slash;u.useEffect(()=>{M!==void 0&&he(M)},[M]),u.useEffect(()=>{w&&pe(w)},[w]),u.useEffect(()=>{R&&ge(R)},[R]),u.useEffect(()=>{E!==void 0&&Ce(E)},[E]),u.useEffect(()=>{!r.current||T===void 0||r.current.innerHTML!==T&&(r.current.innerHTML=T)},[T]),u.useEffect(()=>{if(!r.current)return;const e=de?Me.readInkMemory(me):"";if(e){r.current.innerHTML=e,B.current=new ne.InkHistoryStack(e),k==null||k(e);return}T===void 0&&I&&(r.current.innerHTML=I,B.current=new ne.InkHistoryStack(I),k==null||k(I))},[]);const Q=e=>{var t;B.current.push(e),k==null||k(e),de&&Me.writeInkMemory(e,me),ae&&r.current&&ft(((t=r.current.textContent)==null?void 0:t.length)??0)},S=e=>{r.current&&(r.current.innerHTML=e,Q(e))},v=e=>{pe(e),G==null||G(e)},Y=e=>{ge(e),$==null||$(e)},J=e=>{Ce(e),z==null||z(e)},Ht=e=>{he(e),W==null||W(e)},D=()=>{ut(a.getActiveFormats());const e=a.queryCommandValue("formatBlock");if(e&&fe(e.toLowerCase().replace(/[<>]/g,"")),bt(oe()),!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),Ie(!0)}else Ie(!1)},d=()=>{var t,n,o;if(!r.current)return;let e=r.current.innerHTML;if(O&&m.trackChanges){const l=window.getSelection();if(l&&!l.isCollapsed){const g=oe();if(g){const _=L.createTrackChange("delete",g,A);v([...b,_]),Ot(_.id),e=r.current.innerHTML}}}if(Q(e),D(),Ae&&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){U(Fe.filterSlashCommands(g));const _=(o=window.getSelection())==null?void 0:o.getRangeAt(0);if(_&&r.current){const j=_.getBoundingClientRect(),F=r.current.getBoundingClientRect();At({top:j.bottom-F.top+8,left:j.left-F.left})}}else U([])}},Ot=e=>{const t=window.getSelection();if(!t||t.rangeCount===0)return;const n=oe();n&&a.insertHTML(L.wrapDeleteHtml(n,e))},yt=()=>{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))},Nt=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),fe(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())},He=async e=>st&&ue?ue(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 He(t);(l=r.current)==null||l.focus(),a.insertImage(n,t.name),d()},e.click()},Oe=()=>{var t;if(c||i||!m.table)return;(t=r.current)==null||t.focus();const e=Vt.buildTableHtml(ze,Xe);if(O&&m.trackChanges){const n=L.createTrackChange("insert",e,A);v([...b,n]),a.insertHTML(L.wrapInsertHtml(e,n.id))}else a.insertHTML(e);d()},ye=()=>{const e=B.current.undo();if(e===null||!r.current){a.execCommand("undo"),d();return}S(e)},Ne=()=>{const e=B.current.redo();if(e===null||!r.current){a.execCommand("redo"),d();return}S(e)},Bt=()=>{var l;if(c||i||!m.comments)return;const e=window.prompt("Comment:");if(!(e!=null&&e.trim()))return;const t=je.createInkId("hl");if((l=r.current)==null||l.focus(),!te.wrapSelectionAsComment(t))return;const o=te.createCommentThread(A,e.trim(),t);Y([o,...P]),J(!0),d()},we=e=>{if(!r.current)return;const t=L.acceptTrackChangeInHtml(r.current.innerHTML,e);S(t),v(b.map(n=>n.id===e?{...n,accepted:!0}:n))},Re=e=>{if(!r.current)return;const t=L.rejectTrackChangeInHtml(r.current.innerHTML,e);S(t),v(b.map(n=>n.id===e?{...n,rejected:!0}:n))},Ee=async e=>{const t=await He(e),n=`<img src="${t}" alt="" style="max-width:100%;height:auto;" />`;if(O&&m.trackChanges){const o=L.createTrackChange("insert",n,A);v([...b,o]),a.insertHTML(L.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=re.extractClipboardHtml(t);if(o){e.preventDefault();const g=re.sanitizePastedHtml(o);g&&(a.insertHTML(g),d());const _=t.items;if(ce&&_)for(const j of Array.from(_)){if(!j.type.startsWith("image/"))continue;const F=j.getAsFile();F&&await Ee(F)}return}const l=re.extractClipboardText(t);if(l){e.preventDefault(),a.insertHTML(l.replace(/\n/g,"<br />")),d();return}}if(!ce)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 Ee(l)}},vt=e=>{e.key==="Escape"&&U([]),(e.metaKey||e.ctrlKey)&&e.key==="z"&&(e.preventDefault(),e.shiftKey?Ne():ye())},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(U([]),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":Oe();return;case"ai":X(!0);break}d()},Be=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(Ue.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(Ue.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:Oe},"table"):null;if(e===y.TOOLBAR_OPTION_SIGNATURE)return m.signature?s.jsx(C.ToolbarButton,{icon:p.signature,title:"Sign pad",active:_e,disabled:c||i,onClick:()=>Le(!0)},y.TOOLBAR_OPTION_SIGNATURE):null;if(e===y.TOOLBAR_OPTION_FIND_REPLACE)return m.findReplace?s.jsx(C.ToolbarButton,{icon:p.findReplace,title:"Find and replace",active:Se,disabled:c||i,onClick:()=>xe(o=>!o)},y.TOOLBAR_OPTION_FIND_REPLACE):null;if(e===y.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()}},y.TOOLBAR_OPTION_HORIZONTAL_RULE):null;if(e==="undo")return s.jsx(C.ToolbarButton,{icon:p.undo,title:"Undo",disabled:c||i,onClick:ye},"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:O,disabled:c||i,onClick:()=>Ht(!O)},"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:Te,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:()=>Nt(e)},e):null},Mt=typeof K=="number"?`${K}px`:K,Ut=typeof V=="number"?`${V}px`:V,Dt=!!(h!=null&&h.enabled&&Te);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":H.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:_e,onClose:()=>Le(!1),onConfirm:e=>{var t;(t=r.current)==null||t.focus(),a.insertImage(e),d()}}),s.jsx(Jt.FindReplace,{open:Se,onClose:()=>xe(!1),onReplace:(e,t,n)=>{if(!r.current)return;const o=Gt.replaceInHtml(r.current.innerHTML,e,t,n);S(o)}}),O&&m.trackChanges?s.jsx(Qt.TrackChangesBar,{changes:b,onAccept:we,onReject:Re,onAcceptAll:()=>b.forEach(e=>we(e.id)),onRejectAll:()=>b.forEach(e=>Re(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:()=>Be("up"),onMoveDown:()=>Be("down")}):null,s.jsx("div",{ref:r,className:f.INK_CLASS_CONTENT,contentEditable:!c&&!i,role:"textbox","aria-multiline":"true","aria-placeholder":se,"data-placeholder":se,suppressContentEditableWarning:!0,style:{minHeight:Mt,maxHeight:Ut},onInput:d,onBlur:yt,onKeyUp:D,onKeyDown:vt,onMouseUp:D,onPaste:e=>{Pt(e)}}),Ae?s.jsx(Zt.SlashMenu,{items:xt,top:be.top,left:be.left,onSelect:jt}):null]}),Z&&m.comments?s.jsx($t.CommentsPanel,{comments:P,author:A,onClose:()=>J(!1),onResolve:e=>{const t=P.find(n=>n.id===e);Y(P.map(n=>n.id===e?{...n,resolved:!0}:n)),t&&r.current&&S(te.removeCommentMark(r.current.innerHTML,t.highlightId))},onAddReply:(e,t)=>{Y(P.map(n=>n.id===e?{...n,replies:[...n.replies,{id:je.createInkId("reply"),author:A,body:t,timestamp:Date.now()}]}:n))}}):null,Dt&&h?s.jsx(zt.AiPanel,{config:h,documentHtml:((Pe=r.current)==null?void 0:Pe.innerHTML)??T??"",selectionHtml:ke,onClose:()=>X(!1),onApplyHtml:e=>{var t;if((t=r.current)==null||t.focus(),ke)a.insertHTML(e);else{S(e);return}d()}}):null]}),ae?s.jsxs("div",{className:f.INK_CLASS_FOOTER,children:[mt,ie?` / ${ie}`:""]}):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;AAgFrB,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAuuBxC,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,CAkzBxC,CAAC"}