@forgedevstack/ink 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.
Files changed (90) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +21 -0
  3. package/README.md +83 -0
  4. package/dist/angular/index.cjs +30 -0
  5. package/dist/angular/index.d.ts +16 -0
  6. package/dist/angular/index.d.ts.map +1 -0
  7. package/dist/angular/index.js +39 -0
  8. package/dist/components/InkEditor/InkEditor.cjs +1 -0
  9. package/dist/components/InkEditor/InkEditor.d.ts +4 -0
  10. package/dist/components/InkEditor/InkEditor.d.ts.map +1 -0
  11. package/dist/components/InkEditor/InkEditor.js +225 -0
  12. package/dist/components/InkEditor/components/ToolbarButton/ToolbarButton.cjs +1 -0
  13. package/dist/components/InkEditor/components/ToolbarButton/ToolbarButton.d.ts +4 -0
  14. package/dist/components/InkEditor/components/ToolbarButton/ToolbarButton.d.ts.map +1 -0
  15. package/dist/components/InkEditor/components/ToolbarButton/ToolbarButton.js +22 -0
  16. package/dist/components/InkEditor/components/ToolbarButton/index.d.ts +2 -0
  17. package/dist/components/InkEditor/components/ToolbarButton/index.d.ts.map +1 -0
  18. package/dist/components/InkEditor/components/ToolbarColorPicker/ToolbarColorPicker.cjs +1 -0
  19. package/dist/components/InkEditor/components/ToolbarColorPicker/ToolbarColorPicker.d.ts +4 -0
  20. package/dist/components/InkEditor/components/ToolbarColorPicker/ToolbarColorPicker.d.ts.map +1 -0
  21. package/dist/components/InkEditor/components/ToolbarColorPicker/ToolbarColorPicker.js +24 -0
  22. package/dist/components/InkEditor/components/ToolbarColorPicker/index.d.ts +2 -0
  23. package/dist/components/InkEditor/components/ToolbarColorPicker/index.d.ts.map +1 -0
  24. package/dist/components/InkEditor/components/ToolbarDropdown/ToolbarDropdown.cjs +1 -0
  25. package/dist/components/InkEditor/components/ToolbarDropdown/ToolbarDropdown.d.ts +4 -0
  26. package/dist/components/InkEditor/components/ToolbarDropdown/ToolbarDropdown.d.ts.map +1 -0
  27. package/dist/components/InkEditor/components/ToolbarDropdown/ToolbarDropdown.js +21 -0
  28. package/dist/components/InkEditor/components/ToolbarDropdown/index.d.ts +2 -0
  29. package/dist/components/InkEditor/components/ToolbarDropdown/index.d.ts.map +1 -0
  30. package/dist/components/InkEditor/components/index.d.ts +4 -0
  31. package/dist/components/InkEditor/components/index.d.ts.map +1 -0
  32. package/dist/components/InkEditor/helpers/format.utils.cjs +1 -0
  33. package/dist/components/InkEditor/helpers/format.utils.d.ts +13 -0
  34. package/dist/components/InkEditor/helpers/format.utils.d.ts.map +1 -0
  35. package/dist/components/InkEditor/helpers/format.utils.js +26 -0
  36. package/dist/components/InkEditor/helpers/index.d.ts +2 -0
  37. package/dist/components/InkEditor/helpers/index.d.ts.map +1 -0
  38. package/dist/components/InkEditor/index.d.ts +3 -0
  39. package/dist/components/InkEditor/index.d.ts.map +1 -0
  40. package/dist/components/index.d.ts +2 -0
  41. package/dist/components/index.d.ts.map +1 -0
  42. package/dist/constants/defaults.const.cjs +1 -0
  43. package/dist/constants/defaults.const.d.ts +19 -0
  44. package/dist/constants/defaults.const.d.ts.map +1 -0
  45. package/dist/constants/defaults.const.js +81 -0
  46. package/dist/constants/index.d.ts +4 -0
  47. package/dist/constants/index.d.ts.map +1 -0
  48. package/dist/constants/numbers.const.cjs +1 -0
  49. package/dist/constants/numbers.const.d.ts +5 -0
  50. package/dist/constants/numbers.const.d.ts.map +1 -0
  51. package/dist/constants/numbers.const.js +6 -0
  52. package/dist/constants/typos.const.cjs +1 -0
  53. package/dist/constants/typos.const.d.ts +3 -0
  54. package/dist/constants/typos.const.d.ts.map +1 -0
  55. package/dist/constants/typos.const.js +26 -0
  56. package/dist/index.cjs +1 -0
  57. package/dist/index.d.ts +6 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +17 -0
  60. package/dist/plugins/ai/aiPlugin.cjs +1 -0
  61. package/dist/plugins/ai/aiPlugin.d.ts +4 -0
  62. package/dist/plugins/ai/aiPlugin.d.ts.map +1 -0
  63. package/dist/plugins/ai/aiPlugin.js +22 -0
  64. package/dist/plugins/ai/index.cjs +1 -0
  65. package/dist/plugins/ai/index.d.ts +3 -0
  66. package/dist/plugins/ai/index.d.ts.map +1 -0
  67. package/dist/plugins/ai/index.js +5 -0
  68. package/dist/styles.css +149 -0
  69. package/dist/types/ai.types.d.ts +25 -0
  70. package/dist/types/ai.types.d.ts.map +1 -0
  71. package/dist/types/index.d.ts +3 -0
  72. package/dist/types/index.d.ts.map +1 -0
  73. package/dist/types/ink.types.d.ts +48 -0
  74. package/dist/types/ink.types.d.ts.map +1 -0
  75. package/dist/utils/cn.utils.cjs +1 -0
  76. package/dist/utils/cn.utils.d.ts +2 -0
  77. package/dist/utils/cn.utils.d.ts.map +1 -0
  78. package/dist/utils/cn.utils.js +4 -0
  79. package/dist/utils/index.d.ts +3 -0
  80. package/dist/utils/index.d.ts.map +1 -0
  81. package/dist/utils/typo.utils.cjs +1 -0
  82. package/dist/utils/typo.utils.d.ts +3 -0
  83. package/dist/utils/typo.utils.d.ts.map +1 -0
  84. package/dist/utils/typo.utils.js +15 -0
  85. package/dist/utils/typo.utils.test.d.ts +2 -0
  86. package/dist/utils/typo.utils.test.d.ts.map +1 -0
  87. package/package.json +89 -0
  88. package/wordpress/README.md +13 -0
  89. package/wordpress/ink-editor/assets/.gitkeep +0 -0
  90. package/wordpress/ink-editor/ink-editor.php +92 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 — 2026-08-01
4
+
5
+ ### Added
6
+ - `InkEditor` React WYSIWYG with controlled HTML `value` / `onChange`
7
+ - Toolbar: bold, italic, underline, strikethrough, headings, text/highlight colors, lists, links, image paste/insert
8
+ - Typo auto-fix MVP via bundled dictionary (`applyTypoAutoFix`, blur-triggered)
9
+ - AI agent plugin stub (`@forgedevstack/ink/plugins/ai`) — register/run API; full agents in 1.x
10
+ - Angular adapter entry (`@forgedevstack/ink/angular`) with usage helpers
11
+ - WordPress plugin stub under `wordpress/ink-editor`
12
+ - Styles export `@forgedevstack/ink/styles.css`
13
+ - Docs site placeholder **inkforgejs.com** (register at registrar)
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 John Yaghobieh
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,83 @@
1
+ # Ink — `@forgedevstack/ink`
2
+
3
+ **ForgeStack rich text editor** for React. WYSIWYG toolbar, heading styles, colors, lists, links, image paste, built-in typo auto-fix MVP, Angular usage stub, and a WordPress plugin stub.
4
+
5
+ > **Domain:** [inkforgejs.com](https://inkforgejs.com) — placeholder until registered at your registrar.
6
+ > Avoid conflating with unrelated brands (e.g. proseforge / forgequill).
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install @forgedevstack/ink
12
+ ```
13
+
14
+ ```tsx
15
+ import { useState } from 'react';
16
+ import { InkEditor } from '@forgedevstack/ink';
17
+ import '@forgedevstack/ink/styles.css';
18
+
19
+ export function App() {
20
+ const [value, setValue] = useState('<p>Start typing…</p>');
21
+ return (
22
+ <InkEditor
23
+ value={value}
24
+ onChange={setValue}
25
+ placeholder="Write something…"
26
+ typoAutoFix
27
+ />
28
+ );
29
+ }
30
+ ```
31
+
32
+ ## Features (1.0.0)
33
+
34
+ - Controlled `value` / `onChange` (HTML string)
35
+ - Toolbar: bold / italic / underline / strike, headings, text + highlight colors, lists, links, image insert/paste
36
+ - **Typo auto-fix MVP** — small bundled dictionary + heuristics (`applyTypoAutoFix`), runs on blur; no heavy proprietary spell engine
37
+ - **AI agent stub** — `@forgedevstack/ink/plugins/ai` register/run interface; full agents coming in **1.x**
38
+ - **Angular** — `@forgedevstack/ink/angular` thin usage helpers / docs entry
39
+ - **WordPress** — `wordpress/ink-editor` classic meta box stub
40
+
41
+ ## AI plugin (stub)
42
+
43
+ ```ts
44
+ import { inkAi } from '@forgedevstack/ink/plugins/ai';
45
+
46
+ // Register a real agent in 1.x — interface is stable now:
47
+ inkAi.register({
48
+ id: 'my-agent',
49
+ name: 'My Agent',
50
+ capabilities: ['rewrite'],
51
+ async run({ html }) {
52
+ return { html };
53
+ },
54
+ });
55
+ ```
56
+
57
+ ## Angular
58
+
59
+ ```ts
60
+ import { createInkAngularUsage, documentInkAngularAdapter } from '@forgedevstack/ink/angular';
61
+
62
+ console.log(documentInkAngularAdapter());
63
+ console.log(createInkAngularUsage());
64
+ ```
65
+
66
+ Mount `InkEditor` via your preferred React↔Angular bridge. A dedicated Angular component lands in 1.x.
67
+
68
+ ## WordPress
69
+
70
+ See [`wordpress/README.md`](./wordpress/README.md).
71
+
72
+ ## Links
73
+
74
+ | | |
75
+ |---|---|
76
+ | npm | https://www.npmjs.com/package/@forgedevstack/ink |
77
+ | Repo | https://github.com/yaghobieh/ink |
78
+ | Portal | https://inkforgejs.com (register domain) |
79
+ | Companion | https://github.com/yaghobieh/ink-portal |
80
+
81
+ ## License
82
+
83
+ MIT © John Yaghobieh
@@ -0,0 +1,30 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t="ink-editor",e=()=>`
2
+ import { Component } from '@angular/core';
3
+
4
+ @Component({
5
+ selector: 'app-editor',
6
+ template: \`
7
+ <div
8
+ id="ink-host"
9
+ [attr.data-value]="html"
10
+ contenteditable="false"
11
+ ></div>
12
+ \`,
13
+ })
14
+ export class EditorHostComponent {
15
+ html = '<p>Start typing with Ink…</p>';
16
+ }
17
+
18
+ // Mount the React InkEditor into #ink-host with your preferred bridge
19
+ // (e.g. @angular/elements, react2angular, or a small custom adapter).
20
+ // Example:
21
+ //
22
+ // import { createRoot } from 'react-dom/client';
23
+ // import { InkEditor } from '@forgedevstack/ink';
24
+ // import '@forgedevstack/ink/styles.css';
25
+ //
26
+ // const root = createRoot(document.getElementById('ink-host')!);
27
+ // root.render(
28
+ // <InkEditor value={html} onChange={(next) => { this.html = next; }} />
29
+ // );
30
+ `.trim(),o=()=>({packageEntry:"@forgedevstack/ink/angular",status:"stub",note:"Thin Angular usage docs + helper constants for 1.0.0. A dedicated @angular/core wrapper lands in 1.x."});exports.INK_ANGULAR_SELECTOR=t;exports.createInkAngularUsage=e;exports.documentInkAngularAdapter=o;
@@ -0,0 +1,16 @@
1
+ export type InkAngularValueChange = (html: string) => void;
2
+ export interface InkAngularBindings {
3
+ value: string;
4
+ placeholder?: string;
5
+ disabled?: boolean;
6
+ typoAutoFix?: boolean;
7
+ onChange?: InkAngularValueChange;
8
+ }
9
+ export declare const INK_ANGULAR_SELECTOR = "ink-editor";
10
+ export declare const createInkAngularUsage: () => string;
11
+ export declare const documentInkAngularAdapter: () => {
12
+ packageEntry: string;
13
+ status: "stub";
14
+ note: string;
15
+ };
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/angular/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AAED,eAAO,MAAM,oBAAoB,eAAe,CAAC;AAEjD,eAAO,MAAM,qBAAqB,QAAO,MA6BjC,CAAC;AAET,eAAO,MAAM,yBAAyB,QAAO;IAC3C,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CAKb,CAAC"}
@@ -0,0 +1,39 @@
1
+ const t = "ink-editor", e = () => `
2
+ import { Component } from '@angular/core';
3
+
4
+ @Component({
5
+ selector: 'app-editor',
6
+ template: \`
7
+ <div
8
+ id="ink-host"
9
+ [attr.data-value]="html"
10
+ contenteditable="false"
11
+ ></div>
12
+ \`,
13
+ })
14
+ export class EditorHostComponent {
15
+ html = '<p>Start typing with Ink…</p>';
16
+ }
17
+
18
+ // Mount the React InkEditor into #ink-host with your preferred bridge
19
+ // (e.g. @angular/elements, react2angular, or a small custom adapter).
20
+ // Example:
21
+ //
22
+ // import { createRoot } from 'react-dom/client';
23
+ // import { InkEditor } from '@forgedevstack/ink';
24
+ // import '@forgedevstack/ink/styles.css';
25
+ //
26
+ // const root = createRoot(document.getElementById('ink-host')!);
27
+ // root.render(
28
+ // <InkEditor value={html} onChange={(next) => { this.html = next; }} />
29
+ // );
30
+ `.trim(), o = () => ({
31
+ packageEntry: "@forgedevstack/ink/angular",
32
+ status: "stub",
33
+ note: "Thin Angular usage docs + helper constants for 1.0.0. A dedicated @angular/core wrapper lands in 1.x."
34
+ });
35
+ export {
36
+ t as INK_ANGULAR_SELECTOR,
37
+ e as createInkAngularUsage,
38
+ o as documentInkAngularAdapter
39
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),f=require("react"),T=require("../../constants/numbers.const.cjs"),u=require("../../constants/defaults.const.cjs"),ee=require("../../utils/cn.utils.cjs"),te=require("../../utils/typo.utils.cjs"),i=require("./helpers/format.utils.cjs"),I=require("./components/ToolbarButton/ToolbarButton.cjs"),re=require("./components/ToolbarDropdown/ToolbarDropdown.cjs"),O=require("./components/ToolbarColorPicker/ToolbarColorPicker.cjs"),b={bold:"B",italic:"I",underline:"U",strikethrough:"S",bulletList:"•",orderedList:"1.",link:"🔗",image:"🖼",clearFormat:"⌫",alignLeft:"⫷",alignCenter:"☰",alignRight:"⫸",alignJustify:"≡",indent:"→",outdent:"←",blockquote:"“",code:"</>"},ne=v=>{const{value:h,defaultValue:_="",onChange:g,placeholder:x=u.INK_PLACEHOLDER_DEFAULT,disabled:n=!1,readOnly:o=!1,minHeight:m=T.INK_MIN_HEIGHT,maxHeight:C,toolbar:y=u.INK_DEFAULT_TOOLBAR,className:E="",testId:S,allowImagePaste:A=!0,showCharCount:L=!1,charCountMax:N,typoAutoFix:B=!0,...F}=v,r=f.useRef(null),[D,U]=f.useState(new Set),[K,k]=f.useState("p"),[j,R]=f.useState(0),[q,w]=f.useState(T.INK_DEFAULT_TEXT_COLOR),[M,P]=f.useState(T.INK_DEFAULT_HIGHLIGHT_COLOR);f.useEffect(()=>{!r.current||h===void 0||r.current.innerHTML!==h&&(r.current.innerHTML=h)},[h]),f.useEffect(()=>{!r.current||h||!_||(r.current.innerHTML=_)},[]);const H=e=>{var t;g==null||g(e),L&&r.current&&R(((t=r.current.textContent)==null?void 0:t.length)??0)},p=()=>{U(i.getActiveFormats());const e=i.queryCommandValue("formatBlock");e&&k(e.toLowerCase().replace(/[<>]/g,""))},d=()=>{r.current&&(H(r.current.innerHTML),p())},V=()=>{if(!r.current||!B||n||o)return;const e=r.current.innerHTML,t=te.applyTypoAutoFix(e);t.html!==e&&(r.current.innerHTML=t.html,H(t.html))},G=e=>{var c;if(n||o)return;(c=r.current)==null||c.focus();const t=u.INK_BUTTON_CONFIG[e];t&&(t.value?i.execCommand(t.command,t.value):i.execCommand(t.command),d())},$=e=>{var t;n||o||((t=r.current)==null||t.focus(),i.execCommand("formatBlock",e),k(e),d())},W=()=>{var t;if(n||o)return;const e=window.prompt("Enter URL:","https://");e&&((t=r.current)==null||t.focus(),i.insertLink(e),d())},J=async()=>{if(n||o)return;const e=document.createElement("input");e.type="file",e.accept="image/*",e.onchange=async()=>{var a,l;const t=(a=e.files)==null?void 0:a[0];if(!t)return;const c=await i.fileToDataUrl(t);(l=r.current)==null||l.focus(),i.insertImage(c,t.name),d()},e.click()},X=async e=>{var c;if(!A||n||o)return;const t=(c=e.clipboardData)==null?void 0:c.items;if(t)for(const a of Array.from(t)){if(!a.type.startsWith("image/"))continue;e.preventDefault();const l=a.getAsFile();if(!l)continue;const Z=await i.fileToDataUrl(l);i.insertImage(Z),d()}},z=(e,t)=>{if(e==="divider")return s.jsx("span",{className:u.INK_CLASS_DIVIDER},`divider-${t}`);if(e==="headingDropdown")return s.jsx(re.ToolbarDropdown,{title:"Heading",options:u.INK_HEADING_OPTIONS,value:K||"p",disabled:n||o,onChange:$},"heading");if(e==="textColor")return s.jsx(O.ToolbarColorPicker,{title:"Text color",type:"text",value:q,disabled:n||o,onChange:a=>{var l;(l=r.current)==null||l.focus(),i.setTextColor(a),w(a),d()}},"textColor");if(e==="highlightColor")return s.jsx(O.ToolbarColorPicker,{title:"Highlight color",type:"highlight",value:M,disabled:n||o,onChange:a=>{var l;(l=r.current)==null||l.focus(),i.setHighlightColor(a),P(a),d()}},"highlightColor");if(e==="link")return s.jsx(I.ToolbarButton,{icon:b.link,title:"Insert link",disabled:n||o,onClick:W},"link");if(e==="image")return s.jsx(I.ToolbarButton,{icon:b.image,title:"Insert image",disabled:n||o,onClick:()=>{J()}},"image");const c=u.INK_BUTTON_CONFIG[e];return c?s.jsx(I.ToolbarButton,{icon:b[e]??e.slice(0,1).toUpperCase(),title:c.title,active:D.has(e),disabled:n||o,onClick:()=>G(e)},e):null},Q=typeof m=="number"?`${m}px`:m,Y=typeof C=="number"?`${C}px`:C;return s.jsxs("div",{className:ee.cn(u.INK_CLASS_ROOT,E),"data-testid":S,"data-disabled":n||void 0,...F,children:[s.jsx("div",{className:u.INK_CLASS_TOOLBAR,role:"toolbar","aria-label":"Ink formatting toolbar",children:y.map(z)}),s.jsx("div",{ref:r,className:u.INK_CLASS_CONTENT,contentEditable:!n&&!o,role:"textbox","aria-multiline":"true","aria-placeholder":x,"data-placeholder":x,suppressContentEditableWarning:!0,style:{minHeight:Q,maxHeight:Y},onInput:d,onBlur:V,onKeyUp:p,onMouseUp:p,onPaste:e=>{X(e)}}),L?s.jsxs("div",{className:u.INK_CLASS_FOOTER,children:[j,N?` / ${N}`:""]}):null]})};exports.InkEditor=ne;
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { InkEditorProps } from '../../types';
3
+ export declare const InkEditor: FC<InkEditorProps>;
4
+ //# sourceMappingURL=InkEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkEditor.d.ts","sourceRoot":"","sources":["../../../src/components/InkEditor/InkEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,EAAE,EAAuC,MAAM,OAAO,CAAC;AAClG,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,aAAa,CAAC;AAgDjE,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAiQxC,CAAC"}
@@ -0,0 +1,225 @@
1
+ import { jsxs as k, jsx as s } from "react/jsx-runtime";
2
+ import { useRef as nt, useState as d, useEffect as x } from "react";
3
+ import { INK_MIN_HEIGHT as ot, INK_DEFAULT_TEXT_COLOR as it, INK_DEFAULT_HIGHLIGHT_COLOR as at } from "../../constants/numbers.const.js";
4
+ import { INK_PLACEHOLDER_DEFAULT as lt, INK_DEFAULT_TOOLBAR as st, INK_CLASS_TOOLBAR as ct, INK_CLASS_CONTENT as ut, INK_CLASS_FOOTER as dt, INK_CLASS_DIVIDER as ft, INK_HEADING_OPTIONS as mt, INK_BUTTON_CONFIG as v, INK_CLASS_ROOT as ht } from "../../constants/defaults.const.js";
5
+ import { cn as gt } from "../../utils/cn.utils.js";
6
+ import { applyTypoAutoFix as pt } from "../../utils/typo.utils.js";
7
+ import { setTextColor as Ct, setHighlightColor as It, getActiveFormats as Tt, queryCommandValue as Lt, fileToDataUrl as A, insertImage as O, execCommand as p, insertLink as _t } from "./helpers/format.utils.js";
8
+ import { ToolbarButton as C } from "./components/ToolbarButton/ToolbarButton.js";
9
+ import { ToolbarDropdown as bt } from "./components/ToolbarDropdown/ToolbarDropdown.js";
10
+ import { ToolbarColorPicker as E } from "./components/ToolbarColorPicker/ToolbarColorPicker.js";
11
+ const I = {
12
+ bold: "B",
13
+ italic: "I",
14
+ underline: "U",
15
+ strikethrough: "S",
16
+ bulletList: "•",
17
+ orderedList: "1.",
18
+ link: "🔗",
19
+ image: "🖼",
20
+ clearFormat: "⌫",
21
+ alignLeft: "⫷",
22
+ alignCenter: "☰",
23
+ alignRight: "⫸",
24
+ alignJustify: "≡",
25
+ indent: "→",
26
+ outdent: "←",
27
+ blockquote: "“",
28
+ code: "</>"
29
+ }, St = (y) => {
30
+ const {
31
+ value: u,
32
+ defaultValue: T = "",
33
+ onChange: f,
34
+ placeholder: L = lt,
35
+ disabled: n = !1,
36
+ readOnly: o = !1,
37
+ minHeight: m = ot,
38
+ maxHeight: h,
39
+ toolbar: F = st,
40
+ className: S = "",
41
+ testId: D,
42
+ allowImagePaste: K = !0,
43
+ showCharCount: _ = !1,
44
+ charCountMax: b,
45
+ typoAutoFix: U = !0,
46
+ ...B
47
+ } = y, r = nt(null), [R, w] = d(/* @__PURE__ */ new Set()), [M, N] = d("p"), [V, P] = d(0), [G, $] = d(it), [j, q] = d(at);
48
+ x(() => {
49
+ !r.current || u === void 0 || r.current.innerHTML !== u && (r.current.innerHTML = u);
50
+ }, [u]), x(() => {
51
+ !r.current || u || !T || (r.current.innerHTML = T);
52
+ }, []);
53
+ const H = (t) => {
54
+ var e;
55
+ f == null || f(t), _ && r.current && P(((e = r.current.textContent) == null ? void 0 : e.length) ?? 0);
56
+ }, g = () => {
57
+ w(Tt());
58
+ const t = Lt("formatBlock");
59
+ t && N(t.toLowerCase().replace(/[<>]/g, ""));
60
+ }, c = () => {
61
+ r.current && (H(r.current.innerHTML), g());
62
+ }, W = () => {
63
+ if (!r.current || !U || n || o) return;
64
+ const t = r.current.innerHTML, e = pt(t);
65
+ e.html !== t && (r.current.innerHTML = e.html, H(e.html));
66
+ }, J = (t) => {
67
+ var l;
68
+ if (n || o) return;
69
+ (l = r.current) == null || l.focus();
70
+ const e = v[t];
71
+ e && (e.value ? p(e.command, e.value) : p(e.command), c());
72
+ }, X = (t) => {
73
+ var e;
74
+ n || o || ((e = r.current) == null || e.focus(), p("formatBlock", t), N(t), c());
75
+ }, z = () => {
76
+ var e;
77
+ if (n || o) return;
78
+ const t = window.prompt("Enter URL:", "https://");
79
+ t && ((e = r.current) == null || e.focus(), _t(t), c());
80
+ }, Q = async () => {
81
+ if (n || o) return;
82
+ const t = document.createElement("input");
83
+ t.type = "file", t.accept = "image/*", t.onchange = async () => {
84
+ var i, a;
85
+ const e = (i = t.files) == null ? void 0 : i[0];
86
+ if (!e) return;
87
+ const l = await A(e);
88
+ (a = r.current) == null || a.focus(), O(l, e.name), c();
89
+ }, t.click();
90
+ }, Y = async (t) => {
91
+ var l;
92
+ if (!K || n || o) return;
93
+ const e = (l = t.clipboardData) == null ? void 0 : l.items;
94
+ if (e)
95
+ for (const i of Array.from(e)) {
96
+ if (!i.type.startsWith("image/")) continue;
97
+ t.preventDefault();
98
+ const a = i.getAsFile();
99
+ if (!a) continue;
100
+ const rt = await A(a);
101
+ O(rt), c();
102
+ }
103
+ }, Z = (t, e) => {
104
+ if (t === "divider")
105
+ return /* @__PURE__ */ s("span", { className: ft }, `divider-${e}`);
106
+ if (t === "headingDropdown")
107
+ return /* @__PURE__ */ s(
108
+ bt,
109
+ {
110
+ title: "Heading",
111
+ options: mt,
112
+ value: M || "p",
113
+ disabled: n || o,
114
+ onChange: X
115
+ },
116
+ "heading"
117
+ );
118
+ if (t === "textColor")
119
+ return /* @__PURE__ */ s(
120
+ E,
121
+ {
122
+ title: "Text color",
123
+ type: "text",
124
+ value: G,
125
+ disabled: n || o,
126
+ onChange: (i) => {
127
+ var a;
128
+ (a = r.current) == null || a.focus(), Ct(i), $(i), c();
129
+ }
130
+ },
131
+ "textColor"
132
+ );
133
+ if (t === "highlightColor")
134
+ return /* @__PURE__ */ s(
135
+ E,
136
+ {
137
+ title: "Highlight color",
138
+ type: "highlight",
139
+ value: j,
140
+ disabled: n || o,
141
+ onChange: (i) => {
142
+ var a;
143
+ (a = r.current) == null || a.focus(), It(i), q(i), c();
144
+ }
145
+ },
146
+ "highlightColor"
147
+ );
148
+ if (t === "link")
149
+ return /* @__PURE__ */ s(
150
+ C,
151
+ {
152
+ icon: I.link,
153
+ title: "Insert link",
154
+ disabled: n || o,
155
+ onClick: z
156
+ },
157
+ "link"
158
+ );
159
+ if (t === "image")
160
+ return /* @__PURE__ */ s(
161
+ C,
162
+ {
163
+ icon: I.image,
164
+ title: "Insert image",
165
+ disabled: n || o,
166
+ onClick: () => {
167
+ Q();
168
+ }
169
+ },
170
+ "image"
171
+ );
172
+ const l = v[t];
173
+ return l ? /* @__PURE__ */ s(
174
+ C,
175
+ {
176
+ icon: I[t] ?? t.slice(0, 1).toUpperCase(),
177
+ title: l.title,
178
+ active: R.has(t),
179
+ disabled: n || o,
180
+ onClick: () => J(t)
181
+ },
182
+ t
183
+ ) : null;
184
+ }, tt = typeof m == "number" ? `${m}px` : m, et = typeof h == "number" ? `${h}px` : h;
185
+ return /* @__PURE__ */ k(
186
+ "div",
187
+ {
188
+ className: gt(ht, S),
189
+ "data-testid": D,
190
+ "data-disabled": n || void 0,
191
+ ...B,
192
+ children: [
193
+ /* @__PURE__ */ s("div", { className: ct, role: "toolbar", "aria-label": "Ink formatting toolbar", children: F.map(Z) }),
194
+ /* @__PURE__ */ s(
195
+ "div",
196
+ {
197
+ ref: r,
198
+ className: ut,
199
+ contentEditable: !n && !o,
200
+ role: "textbox",
201
+ "aria-multiline": "true",
202
+ "aria-placeholder": L,
203
+ "data-placeholder": L,
204
+ suppressContentEditableWarning: !0,
205
+ style: { minHeight: tt, maxHeight: et },
206
+ onInput: c,
207
+ onBlur: W,
208
+ onKeyUp: g,
209
+ onMouseUp: g,
210
+ onPaste: (t) => {
211
+ Y(t);
212
+ }
213
+ }
214
+ ),
215
+ _ ? /* @__PURE__ */ k("div", { className: dt, children: [
216
+ V,
217
+ b ? ` / ${b}` : ""
218
+ ] }) : null
219
+ ]
220
+ }
221
+ );
222
+ };
223
+ export {
224
+ St as InkEditor
225
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),o=require("../../../../constants/defaults.const.cjs"),l=require("../../../../utils/cn.utils.cjs"),c=n=>{const{icon:s,title:t,active:e=!1,onClick:r,disabled:a=!1}=n;return i.jsx("button",{type:"button",title:t,"aria-label":t,"aria-pressed":e,disabled:a,className:l.cn(o.INK_CLASS_BUTTON,e&&o.INK_CLASS_BUTTON_ACTIVE),onClick:r,children:s})};exports.ToolbarButton=c;
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { ToolbarButtonProps } from '../../../../types';
3
+ export declare const ToolbarButton: FC<ToolbarButtonProps>;
4
+ //# sourceMappingURL=ToolbarButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/InkEditor/components/ToolbarButton/ToolbarButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAI5D,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAehD,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ import { INK_CLASS_BUTTON_ACTIVE as n, INK_CLASS_BUTTON as s } from "../../../../constants/defaults.const.js";
3
+ import { cn as c } from "../../../../utils/cn.utils.js";
4
+ const b = (r) => {
5
+ const { icon: e, title: t, active: o = !1, onClick: a, disabled: i = !1 } = r;
6
+ return /* @__PURE__ */ l(
7
+ "button",
8
+ {
9
+ type: "button",
10
+ title: t,
11
+ "aria-label": t,
12
+ "aria-pressed": o,
13
+ disabled: i,
14
+ className: c(s, o && n),
15
+ onClick: a,
16
+ children: e
17
+ }
18
+ );
19
+ };
20
+ export {
21
+ b as ToolbarButton
22
+ };
@@ -0,0 +1,2 @@
1
+ export { ToolbarButton } from './ToolbarButton';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/InkEditor/components/ToolbarButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("../../../../constants/defaults.const.cjs"),d=r=>{const{value:l,onChange:s,title:a,disabled:n=!1,type:t="text"}=r,i=o=>{s(o.target.value)};return e.jsxs("label",{className:"Ink-Editor__color",title:a,"aria-label":a,children:[e.jsx("span",{className:"Ink-Editor__color-swatch",style:{background:l},"data-type":t}),e.jsx("input",{type:"color",value:l,disabled:n,onChange:i,list:`ink-colors-${t}`}),e.jsx("datalist",{id:`ink-colors-${t}`,children:c.INK_COLOR_SWATCHES.map(o=>e.jsx("option",{value:o},o))})]})};exports.ToolbarColorPicker=d;
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { ToolbarColorPickerProps } from '../../../../types';
3
+ export declare const ToolbarColorPicker: FC<ToolbarColorPickerProps>;
4
+ //# sourceMappingURL=ToolbarColorPicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarColorPicker.d.ts","sourceRoot":"","sources":["../../../../../src/components/InkEditor/components/ToolbarColorPicker/ToolbarColorPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,EAAE,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAGjE,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CAwB1D,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { jsxs as i, jsx as a } from "react/jsx-runtime";
2
+ import { INK_COLOR_SWATCHES as c } from "../../../../constants/defaults.const.js";
3
+ const m = (n) => {
4
+ const { value: l, onChange: r, title: t, disabled: s = !1, type: e = "text" } = n;
5
+ return /* @__PURE__ */ i("label", { className: "Ink-Editor__color", title: t, "aria-label": t, children: [
6
+ /* @__PURE__ */ a("span", { className: "Ink-Editor__color-swatch", style: { background: l }, "data-type": e }),
7
+ /* @__PURE__ */ a(
8
+ "input",
9
+ {
10
+ type: "color",
11
+ value: l,
12
+ disabled: s,
13
+ onChange: (o) => {
14
+ r(o.target.value);
15
+ },
16
+ list: `ink-colors-${e}`
17
+ }
18
+ ),
19
+ /* @__PURE__ */ a("datalist", { id: `ink-colors-${e}`, children: c.map((o) => /* @__PURE__ */ a("option", { value: o }, o)) })
20
+ ] });
21
+ };
22
+ export {
23
+ m as ToolbarColorPicker
24
+ };
@@ -0,0 +1,2 @@
1
+ export { ToolbarColorPicker } from './ToolbarColorPicker';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/InkEditor/components/ToolbarColorPicker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),i=n=>{const{options:o,value:t,onChange:r,title:a,disabled:s=!1}=n,c=e=>{r(e.target.value)};return l.jsx("select",{className:"Ink-Editor__select",title:a,"aria-label":a,value:t,disabled:s,onChange:c,children:o.map(e=>l.jsx("option",{value:e.value,children:e.label},e.value))})};exports.ToolbarDropdown=i;
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { ToolbarDropdownProps } from '../../../../types';
3
+ export declare const ToolbarDropdown: FC<ToolbarDropdownProps>;
4
+ //# sourceMappingURL=ToolbarDropdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarDropdown.d.ts","sourceRoot":"","sources":["../../../../../src/components/InkEditor/components/ToolbarDropdown/ToolbarDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,EAAE,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAuBpD,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ const h = (n) => {
3
+ const { options: o, value: t, onChange: r, title: a, disabled: s = !1 } = n;
4
+ return /* @__PURE__ */ l(
5
+ "select",
6
+ {
7
+ className: "Ink-Editor__select",
8
+ title: a,
9
+ "aria-label": a,
10
+ value: t,
11
+ disabled: s,
12
+ onChange: (e) => {
13
+ r(e.target.value);
14
+ },
15
+ children: o.map((e) => /* @__PURE__ */ l("option", { value: e.value, children: e.label }, e.value))
16
+ }
17
+ );
18
+ };
19
+ export {
20
+ h as ToolbarDropdown
21
+ };
@@ -0,0 +1,2 @@
1
+ export { ToolbarDropdown } from './ToolbarDropdown';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/InkEditor/components/ToolbarDropdown/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { ToolbarButton } from './ToolbarButton';
2
+ export { ToolbarDropdown } from './ToolbarDropdown';
3
+ export { ToolbarColorPicker } from './ToolbarColorPicker';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/InkEditor/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=(t,e)=>document.execCommand(t,!1,e),r=t=>document.queryCommandState(t),a=t=>document.queryCommandValue(t),d=t=>{if(!t)return!1;const e=t.startsWith("http://")||t.startsWith("https://")||t.startsWith("mailto:")?t:`https://${t}`;return o("createLink",e)},l=t=>o("foreColor",t),m=t=>o("hiliteColor",t),s=t=>o("insertHTML",t),c=(t,e="")=>{const i=e.replace(/"/g,"&quot;");return s(`<img src="${t}" alt="${i}" style="max-width:100%;height:auto;" />`)},u=t=>new Promise((e,i)=>{const n=new FileReader;n.onload=()=>e(String(n.result)),n.onerror=i,n.readAsDataURL(t)}),h=()=>{const t=new Set;return r("bold")&&t.add("bold"),r("italic")&&t.add("italic"),r("underline")&&t.add("underline"),r("strikeThrough")&&t.add("strikethrough"),r("insertUnorderedList")&&t.add("bulletList"),r("insertOrderedList")&&t.add("orderedList"),t};exports.execCommand=o;exports.fileToDataUrl=u;exports.getActiveFormats=h;exports.insertHTML=s;exports.insertImage=c;exports.insertLink=d;exports.queryCommandState=r;exports.queryCommandValue=a;exports.setHighlightColor=m;exports.setTextColor=l;
@@ -0,0 +1,13 @@
1
+ import { ToolbarOption } from '../../../types';
2
+ export declare const execCommand: (command: string, value?: string) => boolean;
3
+ export declare const queryCommandState: (command: string) => boolean;
4
+ export declare const queryCommandValue: (command: string) => string;
5
+ export declare const insertLink: (url: string) => boolean;
6
+ export declare const setTextColor: (color: string) => boolean;
7
+ export declare const setHighlightColor: (color: string) => boolean;
8
+ export declare const insertHTML: (html: string) => boolean;
9
+ export declare const insertImage: (src: string, alt?: string) => boolean;
10
+ export declare const fileToDataUrl: (file: File) => Promise<string>;
11
+ export declare const getActiveFormats: () => Set<string>;
12
+ export declare const applyFormat: (format: ToolbarOption) => boolean;
13
+ //# sourceMappingURL=format.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.utils.d.ts","sourceRoot":"","sources":["../../../../src/components/InkEditor/helpers/format.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,EAAE,QAAQ,MAAM,KAAG,OACjB,CAAC;AAE9C,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,KAAG,OACf,CAAC;AAEtC,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,KAAG,MACf,CAAC;AAEtC,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,OAOxC,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,OAA0C,CAAC;AAExF,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,KAAG,OAA4C,CAAC;AAE/F,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,KAAG,OAA0C,CAAC;AAErF,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,YAAQ,KAAG,OAGnD,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,MAAM,IAAI,KAAG,OAAO,CAAC,MAAM,CAMrD,CAAC;AAEL,eAAO,MAAM,gBAAgB,QAAO,GAAG,CAAC,MAAM,CAS7C,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,QAAQ,aAAa,KAAG,OAuBnD,CAAC"}