@ablogcms/wysiwyg-editor 3.2.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # @ablogcms/wysiwyg-editor
2
+
3
+ Trumbowyg ベースの WYSIWYG エディタを提供するパッケージ。ローダー(trumbowyg 本体・プラグイン・
4
+ CSS・日本語ロケールの読み込み)と、React から使うための `WysiwygEditor` コンポーネントをセットで
5
+ 収容する。`@ablogcms/lib/wysiwyg`(ローダー)と `@ablogcms/components/wysiwyg-editor`
6
+ (コンポーネント)から切り出したもの。
7
+
8
+ ## 利用契約
9
+
10
+ jQuery はグローバル前提(webpack の `externals: { jquery: 'jQuery' }` と同じ設計)で、
11
+ このパッケージ自体は jquery/trumbowyg をランタイム依存として `dependencies` に含めない
12
+ (`trumbowyg` は型宣言と CSS/プラグインのロードパスのためだけに参照する)。
13
+
14
+ ## 使い方
15
+
16
+ ```tsx
17
+ import { WysiwygEditor } from '@ablogcms/wysiwyg-editor/wysiwyg-editor';
18
+
19
+ <WysiwygEditor value={html} onChange={setHtml} />;
20
+ ```
21
+
22
+ 素の trumbowyg ローダーを直接呼びたい場合(動的 import での遅延ロード等)は次を使う。
23
+
24
+ ```ts
25
+ const { default: initWysiwyg } = await import('@ablogcms/wysiwyg-editor/wysiwyg');
26
+ initWysiwyg(textarea, config);
27
+ ```
28
+
29
+ CSS import・jQuery プラグイン登録を伴う副作用パッケージのため、ルートバレル(`.`)は公開しない。
@@ -0,0 +1,22 @@
1
+ // src/wysiwyg.js
2
+ import "trumbowyg";
3
+ import "trumbowyg/dist/plugins/colors/trumbowyg.colors";
4
+ import "trumbowyg/dist/plugins/fontsize/trumbowyg.fontsize";
5
+ import "trumbowyg/dist/plugins/lineheight/trumbowyg.lineheight";
6
+ import "trumbowyg/dist/plugins/table/trumbowyg.table";
7
+ import "trumbowyg/dist/langs/ja";
8
+ import "trumbowyg/dist/plugins/colors/ui/trumbowyg.colors.css";
9
+ import "trumbowyg/dist/plugins/table/ui/trumbowyg.table.css";
10
+ import "trumbowyg/dist/ui/trumbowyg.css";
11
+ import "trumbowyg/dist/ui/icons.svg";
12
+ var wysiwyg_default = (elm, config) => {
13
+ $(() => {
14
+ $.trumbowyg.svgPath = `${ACMS.Config.root}js/dest/assets/icons.svg`;
15
+ $(elm).trumbowyg(config);
16
+ });
17
+ };
18
+
19
+ export {
20
+ wysiwyg_default
21
+ };
22
+ //# sourceMappingURL=chunk-R5Y7KGSC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/wysiwyg.js"],"sourcesContent":["import 'trumbowyg';\nimport 'trumbowyg/dist/plugins/colors/trumbowyg.colors';\nimport 'trumbowyg/dist/plugins/fontsize/trumbowyg.fontsize';\nimport 'trumbowyg/dist/plugins/lineheight/trumbowyg.lineheight';\nimport 'trumbowyg/dist/plugins/table/trumbowyg.table';\nimport 'trumbowyg/dist/langs/ja';\n\nimport 'trumbowyg/dist/plugins/colors/ui/trumbowyg.colors.css';\nimport 'trumbowyg/dist/plugins/table/ui/trumbowyg.table.css';\nimport 'trumbowyg/dist/ui/trumbowyg.css';\nimport 'trumbowyg/dist/ui/icons.svg';\n\nexport default (elm, config) => {\n $(() => {\n $.trumbowyg.svgPath = `${ACMS.Config.root}js/dest/assets/icons.svg`;\n $(elm).trumbowyg(config);\n });\n};\n"],"mappings":";AAAA,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AAEP,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AAEP,IAAO,kBAAQ,CAAC,KAAK,WAAW;AAC9B,IAAE,MAAM;AACN,MAAE,UAAU,UAAU,GAAG,KAAK,OAAO,IAAI;AACzC,MAAE,GAAG,EAAE,UAAU,MAAM;AAAA,EACzB,CAAC;AACH;","names":[]}
@@ -0,0 +1,4 @@
1
+ import WysiwygEditor from './wysiwyg-editor.js';
2
+ export { WysiwygEditor };
3
+ export default WysiwygEditor;
4
+ export * from './wysiwyg-editor.js';
@@ -0,0 +1,184 @@
1
+ import {
2
+ wysiwyg_default
3
+ } from "../chunk-R5Y7KGSC.mjs";
4
+
5
+ // src/wysiwyg-editor/wysiwyg-editor.tsx
6
+ import { useEffect, useRef, useCallback, useImperativeHandle, forwardRef } from "react";
7
+ import useEffectOnce from "@ablogcms/react-hooks/use-effect-once";
8
+ import { jsx } from "react/jsx-runtime";
9
+ var isRestAttributeKey = (key) => !key.startsWith("on") && key !== "style" && key !== "children" && key !== "dangerouslySetInnerHTML";
10
+ var applyRestAttribute = (textarea, key, value) => {
11
+ if (!isRestAttributeKey(key) || value === void 0) {
12
+ return;
13
+ }
14
+ if (key.startsWith("aria-") && typeof value === "boolean") {
15
+ textarea.setAttribute(key, value ? "true" : "false");
16
+ return;
17
+ }
18
+ if (value === false || value === null) {
19
+ textarea.removeAttribute(key);
20
+ return;
21
+ }
22
+ if (value === true) {
23
+ textarea.setAttribute(key, "");
24
+ return;
25
+ }
26
+ textarea.setAttribute(key, String(value));
27
+ };
28
+ var WysiwygEditor = forwardRef(
29
+ ({
30
+ value = "",
31
+ onChange,
32
+ onBlur,
33
+ onFocus,
34
+ options = {},
35
+ disabled = false,
36
+ placeholder,
37
+ className = "",
38
+ id,
39
+ name,
40
+ required = false,
41
+ autoFocus = false,
42
+ readOnly = false,
43
+ ...rest
44
+ }, ref) => {
45
+ const containerRef = useRef(null);
46
+ const textareaRef = useRef(null);
47
+ const isInitializedRef = useRef(false);
48
+ const createTextarea = useCallback(() => {
49
+ if (!containerRef.current) {
50
+ return;
51
+ }
52
+ const existingTextarea = containerRef.current.querySelector("textarea");
53
+ if (existingTextarea) {
54
+ existingTextarea.remove();
55
+ }
56
+ const textarea = document.createElement("textarea");
57
+ textarea.className = className;
58
+ if (id) textarea.id = id;
59
+ if (name) textarea.name = name;
60
+ if (placeholder) textarea.placeholder = placeholder;
61
+ if (required) textarea.required = required;
62
+ if (autoFocus) textarea.autofocus = autoFocus;
63
+ if (readOnly) textarea.readOnly = readOnly;
64
+ Object.entries(rest).forEach(([key, attrValue]) => {
65
+ applyRestAttribute(textarea, key, attrValue);
66
+ });
67
+ if (value) {
68
+ textarea.value = value;
69
+ }
70
+ containerRef.current.appendChild(textarea);
71
+ textareaRef.current = textarea;
72
+ return textarea;
73
+ }, [id, name, placeholder, required, autoFocus, readOnly, value, className, rest]);
74
+ const initializeTrumbowyg = useCallback(() => {
75
+ if (!containerRef.current || isInitializedRef.current) return;
76
+ const textarea = createTextarea();
77
+ if (!textarea) return;
78
+ wysiwyg_default(textarea, options);
79
+ const $textarea = $(textarea);
80
+ $textarea.on("tbwchange", () => {
81
+ const html = $textarea.trumbowyg("html");
82
+ onChange?.(typeof html === "string" ? html : "");
83
+ });
84
+ $textarea.on("tbwblur", () => {
85
+ const html = $textarea.trumbowyg("html");
86
+ onBlur?.(typeof html === "string" ? html : "");
87
+ });
88
+ $textarea.on("tbwfocus", () => {
89
+ onFocus?.();
90
+ });
91
+ if (value) {
92
+ $textarea.trumbowyg("html", value);
93
+ }
94
+ if (disabled) {
95
+ $textarea.trumbowyg("disable");
96
+ }
97
+ isInitializedRef.current = true;
98
+ }, [value, onChange, onBlur, onFocus, disabled, options, createTextarea]);
99
+ const destroyTrumbowyg = useCallback(() => {
100
+ if (textareaRef.current && isInitializedRef.current) {
101
+ $(textareaRef.current).trumbowyg("destroy");
102
+ textareaRef.current = null;
103
+ isInitializedRef.current = false;
104
+ }
105
+ }, []);
106
+ useEffectOnce(() => {
107
+ initializeTrumbowyg();
108
+ return () => {
109
+ destroyTrumbowyg();
110
+ };
111
+ });
112
+ useEffect(() => {
113
+ if (isInitializedRef.current && textareaRef.current) {
114
+ const $textarea = $(textareaRef.current);
115
+ const currentHtml = $textarea.trumbowyg("html");
116
+ const currentHtmlString = typeof currentHtml === "string" ? currentHtml : "";
117
+ if (currentHtmlString !== value) {
118
+ $textarea.trumbowyg("html", value);
119
+ }
120
+ }
121
+ }, [value]);
122
+ useEffect(() => {
123
+ if (isInitializedRef.current && textareaRef.current) {
124
+ const $textarea = $(textareaRef.current);
125
+ if (disabled) {
126
+ $textarea.trumbowyg("disable");
127
+ } else {
128
+ $textarea.trumbowyg("enable");
129
+ }
130
+ }
131
+ }, [disabled]);
132
+ useImperativeHandle(
133
+ ref,
134
+ () => ({
135
+ getInstance: () => {
136
+ if (textareaRef.current && isInitializedRef.current) {
137
+ return $(textareaRef.current);
138
+ }
139
+ return null;
140
+ },
141
+ getHtml: () => {
142
+ if (textareaRef.current && isInitializedRef.current) {
143
+ const html = $(textareaRef.current).trumbowyg("html");
144
+ return typeof html === "string" ? html : "";
145
+ }
146
+ return "";
147
+ },
148
+ setHtml: (html) => {
149
+ if (textareaRef.current && isInitializedRef.current) {
150
+ $(textareaRef.current).trumbowyg("html", html);
151
+ }
152
+ },
153
+ empty: () => {
154
+ if (textareaRef.current && isInitializedRef.current) {
155
+ $(textareaRef.current).trumbowyg("empty");
156
+ }
157
+ },
158
+ destroy: destroyTrumbowyg,
159
+ disable: () => {
160
+ if (textareaRef.current && isInitializedRef.current) {
161
+ $(textareaRef.current).trumbowyg("disable");
162
+ }
163
+ },
164
+ enable: () => {
165
+ if (textareaRef.current && isInitializedRef.current) {
166
+ $(textareaRef.current).trumbowyg("enable");
167
+ }
168
+ }
169
+ }),
170
+ [destroyTrumbowyg]
171
+ );
172
+ return /* @__PURE__ */ jsx("div", { ref: containerRef });
173
+ }
174
+ );
175
+ WysiwygEditor.displayName = "WysiwygEditor";
176
+ var wysiwyg_editor_default = WysiwygEditor;
177
+
178
+ // src/wysiwyg-editor/index.ts
179
+ var wysiwyg_editor_default2 = wysiwyg_editor_default;
180
+ export {
181
+ wysiwyg_editor_default as WysiwygEditor,
182
+ wysiwyg_editor_default2 as default
183
+ };
184
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/wysiwyg-editor/wysiwyg-editor.tsx","../../src/wysiwyg-editor/index.ts"],"sourcesContent":["/// <reference types=\"jquery\" />\nimport { useEffect, useRef, useCallback, useImperativeHandle, forwardRef } from 'react';\n\n// Import existing wysiwyg function\nimport useEffectOnce from '@ablogcms/react-hooks/use-effect-once';\nimport initWysiwyg from '../wysiwyg';\n\nexport interface WysiwygEditorProps extends Omit<\n React.TextareaHTMLAttributes<HTMLTextAreaElement>,\n 'value' | 'defaultValue' | 'onChange' | 'onBlur' | 'onFocus'\n> {\n value?: string;\n onChange?: (value: string) => void;\n onBlur?: (value: string) => void;\n onFocus?: () => void;\n options?: Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n}\n\n// イベントハンドラ・style・children は setAttribute で関数/オブジェクトをそのまま表現できず、\n// 他の属性と同じ経路で丸ごと反映すると壊れるため対象から外す\nconst isRestAttributeKey = (key: string) =>\n !key.startsWith('on') && key !== 'style' && key !== 'children' && key !== 'dangerouslySetInnerHTML';\n\n// aria-* は 'true'/'false' の文字列を持つトークン属性で、disabled 等の存在有無で真偽を表す\n// 素の HTML boolean 属性とは異なり false も明示的な値のため、他属性と同じ「false は除去」に寄せられない\nconst applyRestAttribute = (textarea: HTMLTextAreaElement, key: string, value: unknown) => {\n if (!isRestAttributeKey(key) || value === undefined) {\n return;\n }\n if (key.startsWith('aria-') && typeof value === 'boolean') {\n textarea.setAttribute(key, value ? 'true' : 'false');\n return;\n }\n if (value === false || value === null) {\n textarea.removeAttribute(key);\n return;\n }\n if (value === true) {\n textarea.setAttribute(key, '');\n return;\n }\n textarea.setAttribute(key, String(value));\n};\n\nexport interface WysiwygEditorRef {\n getInstance: () => any; // eslint-disable-line @typescript-eslint/no-explicit-any\n getHtml: () => string;\n setHtml: (html: string) => void;\n empty: () => void;\n destroy: () => void;\n disable: () => void;\n enable: () => void;\n}\n\nconst WysiwygEditor = forwardRef<WysiwygEditorRef, WysiwygEditorProps>(\n (\n {\n value = '',\n onChange,\n onBlur,\n onFocus,\n options = {},\n disabled = false,\n placeholder,\n className = '',\n id,\n name,\n required = false,\n autoFocus = false,\n readOnly = false,\n ...rest\n },\n ref\n ) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const textareaRef = useRef<HTMLTextAreaElement | null>(null);\n const isInitializedRef = useRef(false);\n\n // Create textarea element via DOM manipulation\n const createTextarea = useCallback(() => {\n if (!containerRef.current) {\n return;\n }\n\n // Remove existing textarea if any\n const existingTextarea = containerRef.current.querySelector('textarea');\n if (existingTextarea) {\n existingTextarea.remove();\n }\n\n // Create new textarea element\n const textarea = document.createElement('textarea');\n textarea.className = className;\n\n // Set attributes\n if (id) textarea.id = id;\n if (name) textarea.name = name;\n if (placeholder) textarea.placeholder = placeholder;\n if (required) textarea.required = required;\n if (autoFocus) textarea.autofocus = autoFocus;\n if (readOnly) textarea.readOnly = readOnly;\n\n // Field 等が cloneElement で注入する aria-describedby/aria-invalid をはじめ、\n // 明示的に受け取っていない残りの HTML 属性を反映する\n Object.entries(rest).forEach(([key, attrValue]) => {\n applyRestAttribute(textarea, key, attrValue);\n });\n\n // Set initial value\n if (value) {\n textarea.value = value;\n }\n\n // Append to container\n containerRef.current.appendChild(textarea);\n textareaRef.current = textarea;\n\n return textarea;\n }, [id, name, placeholder, required, autoFocus, readOnly, value, className, rest]);\n\n // Initialize Trumbowyg using existing function\n const initializeTrumbowyg = useCallback(() => {\n if (!containerRef.current || isInitializedRef.current) return;\n\n const textarea = createTextarea();\n if (!textarea) return;\n\n // Use existing wysiwyg function\n initWysiwyg(textarea, options);\n\n // Set up event listeners after initialization\n const $textarea = $(textarea);\n\n $textarea.on('tbwchange', () => {\n // @ts-expect-error trumbowygの型定義がない\n const html = $textarea.trumbowyg('html');\n onChange?.(typeof html === 'string' ? html : '');\n });\n\n $textarea.on('tbwblur', () => {\n // @ts-expect-error trumbowygの型定義がない\n const html = $textarea.trumbowyg('html');\n onBlur?.(typeof html === 'string' ? html : '');\n });\n\n $textarea.on('tbwfocus', () => {\n onFocus?.();\n });\n\n // Set initial value after initialization\n if (value) {\n // @ts-expect-error trumbowygの型定義がない\n $textarea.trumbowyg('html', value);\n }\n\n // Apply disabled state\n if (disabled) {\n // @ts-expect-error trumbowygの型定義がない\n $textarea.trumbowyg('disable');\n }\n\n isInitializedRef.current = true;\n }, [value, onChange, onBlur, onFocus, disabled, options, createTextarea]);\n\n // Destroy Trumbowyg\n const destroyTrumbowyg = useCallback(() => {\n if (textareaRef.current && isInitializedRef.current) {\n // @ts-expect-error trumbowygの型定義がない\n $(textareaRef.current).trumbowyg('destroy');\n textareaRef.current = null;\n isInitializedRef.current = false;\n }\n }, []);\n\n // Initialize on mount\n useEffectOnce(() => {\n initializeTrumbowyg();\n return () => {\n destroyTrumbowyg();\n };\n });\n\n // Handle value changes\n useEffect(() => {\n if (isInitializedRef.current && textareaRef.current) {\n const $textarea = $(textareaRef.current);\n // @ts-expect-error trumbowygの型定義がない\n const currentHtml = $textarea.trumbowyg('html');\n const currentHtmlString = typeof currentHtml === 'string' ? currentHtml : '';\n if (currentHtmlString !== value) {\n // @ts-expect-error trumbowygの型定義がない\n $textarea.trumbowyg('html', value);\n }\n }\n }, [value]);\n\n // Handle disabled state changes\n useEffect(() => {\n if (isInitializedRef.current && textareaRef.current) {\n const $textarea = $(textareaRef.current);\n if (disabled) {\n // @ts-expect-error trumbowygの型定義がない\n $textarea.trumbowyg('disable');\n } else {\n // @ts-expect-error trumbowygの型定義がない\n $textarea.trumbowyg('enable');\n }\n }\n }, [disabled]);\n\n // textarea は Trumbowyg が非表示化し実際の編集面は別要素(contenteditable)に置き換わるため、\n // DatePicker 等と違い実 DOM ノードを useMergeRefs でそのまま forwardedRef に混ぜても focus() 等が\n // 意味を持たない。加えて textarea 自体を useEffectOnce(副作用フェーズ)内で生成しており、\n // useImperativeHandle(レイアウトフェーズ)の初回実行時点ではまだ存在しないため合成も安全でない\n useImperativeHandle(\n ref,\n () => ({\n getInstance: () => {\n if (textareaRef.current && isInitializedRef.current) {\n return $(textareaRef.current) as any; // eslint-disable-line @typescript-eslint/no-explicit-any\n }\n return null;\n },\n getHtml: () => {\n if (textareaRef.current && isInitializedRef.current) {\n // @ts-expect-error trumbowygの型定義がない\n const html = $(textareaRef.current).trumbowyg('html');\n return typeof html === 'string' ? html : '';\n }\n return '';\n },\n setHtml: (html: string) => {\n if (textareaRef.current && isInitializedRef.current) {\n // @ts-expect-error trumbowygの型定義がない\n $(textareaRef.current).trumbowyg('html', html);\n }\n },\n empty: () => {\n if (textareaRef.current && isInitializedRef.current) {\n // @ts-expect-error trumbowygの型定義がない\n $(textareaRef.current).trumbowyg('empty');\n }\n },\n destroy: destroyTrumbowyg,\n disable: () => {\n if (textareaRef.current && isInitializedRef.current) {\n // @ts-expect-error trumbowygの型定義がない\n $(textareaRef.current).trumbowyg('disable');\n }\n },\n enable: () => {\n if (textareaRef.current && isInitializedRef.current) {\n // @ts-expect-error trumbowygの型定義がない\n $(textareaRef.current).trumbowyg('enable');\n }\n },\n }),\n [destroyTrumbowyg]\n );\n\n return <div ref={containerRef} />;\n }\n);\n\nWysiwygEditor.displayName = 'WysiwygEditor';\n\nexport default WysiwygEditor;\n","import WysiwygEditor from './wysiwyg-editor';\n\nexport { WysiwygEditor };\nexport default WysiwygEditor;\nexport * from './wysiwyg-editor';\n"],"mappings":";;;;;AACA,SAAS,WAAW,QAAQ,aAAa,qBAAqB,kBAAkB;AAGhF,OAAO,mBAAmB;AAgQf;AAhPX,IAAM,qBAAqB,CAAC,QAC1B,CAAC,IAAI,WAAW,IAAI,KAAK,QAAQ,WAAW,QAAQ,cAAc,QAAQ;AAI5E,IAAM,qBAAqB,CAAC,UAA+B,KAAa,UAAmB;AACzF,MAAI,CAAC,mBAAmB,GAAG,KAAK,UAAU,QAAW;AACnD;AAAA,EACF;AACA,MAAI,IAAI,WAAW,OAAO,KAAK,OAAO,UAAU,WAAW;AACzD,aAAS,aAAa,KAAK,QAAQ,SAAS,OAAO;AACnD;AAAA,EACF;AACA,MAAI,UAAU,SAAS,UAAU,MAAM;AACrC,aAAS,gBAAgB,GAAG;AAC5B;AAA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MACA,CAAC,gBAAgB;AAAA,IACnB;AAEA,WAAO,oBAAC,SAAI,KAAK,cAAc;AAAA,EACjC;AACF;AAEA,cAAc,cAAc;AAE5B,IAAO,yBAAQ;;;ACvQf,IAAOA,0BAAQ;","names":["wysiwyg_editor_default"]}
@@ -0,0 +1,18 @@
1
+ export interface WysiwygEditorProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'defaultValue' | 'onChange' | 'onBlur' | 'onFocus'> {
2
+ value?: string;
3
+ onChange?: (value: string) => void;
4
+ onBlur?: (value: string) => void;
5
+ onFocus?: () => void;
6
+ options?: Record<string, any>;
7
+ }
8
+ export interface WysiwygEditorRef {
9
+ getInstance: () => any;
10
+ getHtml: () => string;
11
+ setHtml: (html: string) => void;
12
+ empty: () => void;
13
+ destroy: () => void;
14
+ disable: () => void;
15
+ enable: () => void;
16
+ }
17
+ declare const WysiwygEditor: import("react").ForwardRefExoticComponent<WysiwygEditorProps & import("react").RefAttributes<WysiwygEditorRef>>;
18
+ export default WysiwygEditor;
@@ -0,0 +1,2 @@
1
+ declare function _default(elm: any, config: any): void;
2
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import {
2
+ wysiwyg_default
3
+ } from "./chunk-R5Y7KGSC.mjs";
4
+ export {
5
+ wysiwyg_default as default
6
+ };
7
+ //# sourceMappingURL=wysiwyg.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@ablogcms/wysiwyg-editor",
3
+ "version": "3.2.27",
4
+ "type": "module",
5
+ "description": "Trumbowyg-based WYSIWYG editor (loader + React component) for the a-blog cms admin frontend",
6
+ "license": "MIT",
7
+ "homepage": "https://www.a-blogcms.jp",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+ssh://git@bitbucket.org:appleple/ablogcms.git",
11
+ "directory": "packages/frontend/wysiwyg-editor"
12
+ },
13
+ "sideEffects": [
14
+ "**/*.css",
15
+ "**/wysiwyg.js"
16
+ ],
17
+ "dependencies": {
18
+ "trumbowyg": "2.31.0",
19
+ "@ablogcms/react-hooks": "3.2.27"
20
+ },
21
+ "devDependencies": {
22
+ "@storybook/react-vite": "10.5.4",
23
+ "@testing-library/react": "^16.3.2",
24
+ "@types/jquery": "^3.5.34",
25
+ "vitest": "^4.1.10"
26
+ },
27
+ "peerDependencies": {
28
+ "react": "^19",
29
+ "@types/react": "^19.2.18"
30
+ },
31
+ "peerDependenciesMeta": {
32
+ "@types/react": {
33
+ "optional": true
34
+ }
35
+ },
36
+ "exports": {
37
+ "./wysiwyg": {
38
+ "types": "./dist/wysiwyg.d.ts",
39
+ "import": "./dist/wysiwyg.mjs",
40
+ "default": "./dist/wysiwyg.mjs"
41
+ },
42
+ "./wysiwyg-editor": {
43
+ "types": "./dist/wysiwyg-editor/index.d.ts",
44
+ "import": "./dist/wysiwyg-editor/index.mjs",
45
+ "default": "./dist/wysiwyg-editor/index.mjs"
46
+ }
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
50
+ },
51
+ "files": [
52
+ "dist"
53
+ ],
54
+ "scripts": {
55
+ "build": "node ../../../tools/build-package.mjs"
56
+ }
57
+ }