@crediblemark/build 0.22.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 (52) hide show
  1. package/LICENSE +21 -0
  2. package/dist/Editor-XZF6CWVW.css +404 -0
  3. package/dist/Editor-ZC67OU2A.mjs +205 -0
  4. package/dist/Render-JBFI6HYN.mjs +55 -0
  5. package/dist/Render-WCX4AXOX.css +102 -0
  6. package/dist/actions-CEH_5LMY.d.mts +838 -0
  7. package/dist/actions-CEH_5LMY.d.ts +838 -0
  8. package/dist/chunk-3AJBFQU4.mjs +560 -0
  9. package/dist/chunk-4SQOX3ZQ.mjs +476 -0
  10. package/dist/chunk-B4BOBGYB.mjs +42 -0
  11. package/dist/chunk-CDMESQDA.mjs +148 -0
  12. package/dist/chunk-DSXRK4QJ.mjs +704 -0
  13. package/dist/chunk-GUJDGRSM.mjs +469 -0
  14. package/dist/chunk-HHBUU7WF.mjs +35 -0
  15. package/dist/chunk-IJHL7BIR.mjs +11 -0
  16. package/dist/chunk-PHGC6QYB.mjs +105 -0
  17. package/dist/chunk-QF3GD5WQ.mjs +65 -0
  18. package/dist/chunk-U2NVBXAC.mjs +2064 -0
  19. package/dist/chunk-VFD76OD5.mjs +55 -0
  20. package/dist/chunk-VGDMWS44.mjs +107 -0
  21. package/dist/chunk-VKBVSWU3.mjs +8538 -0
  22. package/dist/chunk-YH7AXYKP.mjs +109 -0
  23. package/dist/full-ABQQRJAO.css +301 -0
  24. package/dist/full-LJRK5736.mjs +94 -0
  25. package/dist/index-CkSfgrvw.d.ts +117 -0
  26. package/dist/index-Cxwg4vUV.d.mts +117 -0
  27. package/dist/index.css +2576 -0
  28. package/dist/index.d.mts +310 -0
  29. package/dist/index.d.ts +310 -0
  30. package/dist/index.js +15012 -0
  31. package/dist/index.mjs +83 -0
  32. package/dist/internal.d.mts +27 -0
  33. package/dist/internal.d.ts +27 -0
  34. package/dist/internal.js +960 -0
  35. package/dist/internal.mjs +13 -0
  36. package/dist/loaded-DWCENJKQ.mjs +55 -0
  37. package/dist/loaded-N7VXUR4O.mjs +59 -0
  38. package/dist/loaded-NE2PIHUQ.mjs +56 -0
  39. package/dist/loaded-SMEIWWHS.css +87 -0
  40. package/dist/no-external.css +2574 -0
  41. package/dist/no-external.d.mts +21 -0
  42. package/dist/no-external.d.ts +21 -0
  43. package/dist/no-external.js +15012 -0
  44. package/dist/no-external.mjs +83 -0
  45. package/dist/rsc.css +102 -0
  46. package/dist/rsc.d.mts +27 -0
  47. package/dist/rsc.d.ts +27 -0
  48. package/dist/rsc.js +1466 -0
  49. package/dist/rsc.mjs +147 -0
  50. package/dist/walk-tree-B4ZvMfxS.d.ts +29 -0
  51. package/dist/walk-tree-C78ZVz19.d.mts +29 -0
  52. package/package.json +145 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rasyiqi Crediblemark
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.
@@ -0,0 +1,404 @@
1
+ /* css-module:/home/crediblemark/Project/NEXT_CMS/packages/components/RichTextMenu/styles.module.css/#css-module-data */
2
+ ._RichTextMenu_193iw_1 {
3
+ display: flex;
4
+ flex-direction: row;
5
+ flex-wrap: nowrap;
6
+ }
7
+ ._RichTextMenu--form_193iw_7 {
8
+ border-top-left-radius: 4px;
9
+ border-top-right-radius: 4px;
10
+ padding: 6px 6px;
11
+ background-color: var(--credbuild-color-grey-12);
12
+ position: relative;
13
+ scrollbar-width: none;
14
+ overflow-x: auto;
15
+ }
16
+ ._RichTextMenu-group_193iw_17 {
17
+ display: flex;
18
+ align-items: space-between;
19
+ flex-direction: row;
20
+ flex-wrap: nowrap;
21
+ padding-inline: 6px;
22
+ gap: 2px;
23
+ position: relative;
24
+ }
25
+ ._RichTextMenu-group_193iw_17:first-of-type {
26
+ padding-left: 0;
27
+ }
28
+ ._RichTextMenu-group_193iw_17:last-of-type {
29
+ padding-right: 0;
30
+ }
31
+ ._RichTextMenu--inline_193iw_35 ._RichTextMenu-group_193iw_17 {
32
+ color: var(--credbuild-color-grey-08);
33
+ gap: 0px;
34
+ flex-wrap: nowrap;
35
+ }
36
+ ._RichTextMenu-group_193iw_17 + ._RichTextMenu-group_193iw_17 {
37
+ border-left: 1px solid var(--credbuild-color-grey-10);
38
+ }
39
+ ._RichTextMenu--inline_193iw_35 ._RichTextMenu-group_193iw_17 + ._RichTextMenu-group_193iw_17 {
40
+ border-left: 0.5px solid var(--credbuild-color-grey-05);
41
+ }
42
+
43
+ /* css-module:/home/crediblemark/Project/NEXT_CMS/packages/components/IconButton/IconButton.module.css/#css-module-data */
44
+ ._IconButton_1a0fz_1 {
45
+ align-items: center;
46
+ background: transparent;
47
+ border: none;
48
+ border-radius: var(--cb-radius-m);
49
+ color: currentColor;
50
+ display: flex;
51
+ font-family: var(--credbuild-font-family);
52
+ justify-content: center;
53
+ padding: 2px;
54
+ transition: all 0.2s ease;
55
+ }
56
+ ._IconButton--active_1a0fz_14 {
57
+ color: var(--credbuild-color-azure-04);
58
+ }
59
+ ._IconButton_1a0fz_1:focus-visible {
60
+ outline: 2px solid var(--credbuild-color-azure-05);
61
+ outline-offset: -2px;
62
+ }
63
+ @media (hover: hover) and (pointer: fine) {
64
+ ._IconButton_1a0fz_1:hover:not(._IconButton--disabled_1a0fz_24) {
65
+ background: var(--credbuild-color-grey-10);
66
+ color: var(--credbuild-color-azure-04);
67
+ cursor: pointer;
68
+ transition: none;
69
+ }
70
+ }
71
+ ._IconButton_1a0fz_1:active {
72
+ background: var(--credbuild-color-azure-11);
73
+ transition: none;
74
+ }
75
+ ._IconButton-title_1a0fz_37 {
76
+ clip: rect(0 0 0 0);
77
+ clip-path: inset(100%);
78
+ height: 1px;
79
+ overflow: hidden;
80
+ position: absolute;
81
+ white-space: nowrap;
82
+ width: 1px;
83
+ }
84
+ ._IconButton--disabled_1a0fz_24 {
85
+ color: var(--credbuild-color-grey-07);
86
+ }
87
+
88
+ /* css-module:/home/crediblemark/Project/NEXT_CMS/packages/components/Loader/styles.module.css/#css-module-data */
89
+ @keyframes _loader-animation_nacdm_1 {
90
+ 0% {
91
+ transform: rotate(0deg) scale(1);
92
+ }
93
+ 50% {
94
+ transform: rotate(180deg) scale(0.8);
95
+ }
96
+ 100% {
97
+ transform: rotate(360deg) scale(1);
98
+ }
99
+ }
100
+ ._Loader_nacdm_13 {
101
+ background: transparent;
102
+ border-radius: 100%;
103
+ border: 2px solid currentColor;
104
+ border-bottom-color: transparent;
105
+ display: inline-block;
106
+ animation: _loader-animation_nacdm_1 1s 0s infinite linear;
107
+ animation-fill-mode: both;
108
+ }
109
+
110
+ /* css-module:/home/crediblemark/Project/NEXT_CMS/packages/components/ActionBar/styles.module.css/#css-module-data */
111
+ ._ActionBar_ze0ci_1 {
112
+ align-items: center;
113
+ cursor: default;
114
+ display: flex;
115
+ width: auto;
116
+ padding: 4px;
117
+ padding-inline-start: 0;
118
+ padding-inline-end: 0;
119
+ border-top-left-radius: 8px;
120
+ border-top-right-radius: 8px;
121
+ border-radius: 8px;
122
+ background: var(--credbuild-color-grey-01);
123
+ color: var(--credbuild-color-white);
124
+ font-family: var(--credbuild-font-family);
125
+ min-height: 26px;
126
+ }
127
+ ._ActionBar-label_ze0ci_18 {
128
+ color: var(--credbuild-color-grey-08);
129
+ font-size: var(--credbuild-font-size-xxxs);
130
+ font-weight: 500;
131
+ padding-inline-start: 8px;
132
+ padding-inline-end: 8px;
133
+ margin-inline-start: 4px;
134
+ margin-inline-end: 4px;
135
+ text-overflow: ellipsis;
136
+ white-space: nowrap;
137
+ }
138
+ ._ActionBarAction_ze0ci_30 + ._ActionBar-label_ze0ci_18 {
139
+ padding-inline-start: 0;
140
+ }
141
+ ._ActionBar-label_ze0ci_18 + ._ActionBarAction_ze0ci_30 {
142
+ margin-inline-start: -4px;
143
+ }
144
+ ._ActionBar-group_ze0ci_38 {
145
+ align-items: center;
146
+ border-inline-start: 0.5px solid var(--credbuild-color-grey-05);
147
+ display: flex;
148
+ height: 100%;
149
+ padding-inline-start: 4px;
150
+ padding-inline-end: 4px;
151
+ }
152
+ ._ActionBar-group_ze0ci_38:first-of-type {
153
+ border-inline-start: 0;
154
+ }
155
+ ._ActionBar-group_ze0ci_38:empty {
156
+ display: none;
157
+ }
158
+ ._ActionBarAction_ze0ci_30 {
159
+ background: transparent;
160
+ border: none;
161
+ color: var(--credbuild-color-grey-08);
162
+ cursor: pointer;
163
+ padding: 6px;
164
+ margin-inline-start: 4px;
165
+ margin-inline-end: 4px;
166
+ border-radius: 4px;
167
+ overflow: hidden;
168
+ display: flex;
169
+ align-items: center;
170
+ justify-content: center;
171
+ transition: color 50ms ease-in;
172
+ }
173
+ ._ActionBarAction--disabled_ze0ci_71 {
174
+ cursor: auto;
175
+ color: var(--credbuild-color-grey-06);
176
+ }
177
+ ._ActionBarAction_ze0ci_30 svg {
178
+ max-width: none !important;
179
+ }
180
+ ._ActionBarAction_ze0ci_30:focus-visible {
181
+ outline: 2px solid var(--credbuild-color-azure-05);
182
+ outline-offset: -2px;
183
+ }
184
+ @media (hover: hover) and (pointer: fine) {
185
+ ._ActionBarAction_ze0ci_30:hover:not(._ActionBarAction--disabled_ze0ci_71) {
186
+ color: var(--credbuild-color-azure-06);
187
+ transition: none;
188
+ }
189
+ }
190
+ ._ActionBarAction_ze0ci_30:active:not(._ActionBarAction--disabled_ze0ci_71),
191
+ ._ActionBarAction--active_ze0ci_93 {
192
+ color: var(--credbuild-color-azure-07);
193
+ transition: none;
194
+ }
195
+ ._ActionBar-group_ze0ci_38 * {
196
+ margin: 0;
197
+ }
198
+ ._ActionBar-separator_ze0ci_102 {
199
+ background: var(--credbuild-color-grey-05);
200
+ margin-inline: 4px;
201
+ width: 0.5px;
202
+ height: 100%;
203
+ }
204
+
205
+ /* css-module:/home/crediblemark/Project/NEXT_CMS/packages/components/RichTextMenu/components/Control/styles.module.css/#css-module-data */
206
+ ._Control_1aveu_1 .lucide {
207
+ height: 18px;
208
+ width: 18px;
209
+ }
210
+ ._Control--inline_1aveu_6 .lucide {
211
+ height: 16px;
212
+ width: 16px;
213
+ }
214
+
215
+ /* css-module:/home/crediblemark/Project/NEXT_CMS/packages/components/Select/styles.module.css/#css-module-data */
216
+ ._Select_16son_1 {
217
+ position: relative;
218
+ z-index: 1;
219
+ }
220
+ ._Select-button_16son_6 {
221
+ align-items: center;
222
+ background: transparent;
223
+ border: none;
224
+ border-radius: 4px;
225
+ display: flex;
226
+ justify-content: center;
227
+ gap: 0px;
228
+ height: 100%;
229
+ padding: 4px;
230
+ padding-right: 2px;
231
+ }
232
+ ._Select--hasOptions_16son_19 ._Select-button_16son_6 {
233
+ color: currentColor;
234
+ }
235
+ ._Select--hasOptions_16son_19:not(._Select--disabled_16son_23) ._Select-button_16son_6 {
236
+ cursor: pointer;
237
+ }
238
+ ._Select-buttonIcon_16son_27 {
239
+ align-items: center;
240
+ display: flex;
241
+ justify-content: center;
242
+ }
243
+ ._Select--standalone_16son_33 ._Select-buttonIcon_16son_27 .lucide {
244
+ height: 18px;
245
+ width: 18px;
246
+ }
247
+ ._Select--actionBar_16son_38 ._Select-buttonIcon_16son_27 .lucide {
248
+ height: 16px;
249
+ width: 16px;
250
+ }
251
+ ._Select--hasOptions_16son_19:not(._Select--disabled_16son_23) ._Select-button_16son_6:hover,
252
+ ._Select--hasValue_16son_44 ._Select-button_16son_6 {
253
+ background: var(--credbuild-color-grey-10);
254
+ color: var(--credbuild-color-azure-04);
255
+ }
256
+ ._Select--disabled_16son_23 ._Select-button_16son_6 {
257
+ color: var(--credbuild-color-grey-07);
258
+ }
259
+ ._Select--actionBar_16son_38 {
260
+ &._Select--hasOptions_16son_19 ._Select-button_16son_6:hover,
261
+ &._Select--hasValue_16son_44 ._Select-button_16son_6 {
262
+ background: none;
263
+ color: var(--credbuild-color-azure-07);
264
+ }
265
+ }
266
+ ._Select-items_16son_61 {
267
+ background: white;
268
+ border: 1px solid var(--credbuild-color-grey-09);
269
+ border-radius: 8px;
270
+ margin: 10px 8px;
271
+ margin-left: 0;
272
+ padding: 4px;
273
+ z-index: 2;
274
+ list-style: none;
275
+ }
276
+ ._SelectItem_16son_72 {
277
+ background: transparent;
278
+ border-radius: 4px;
279
+ border: none;
280
+ color: var(--credbuild-color-grey-04);
281
+ cursor: pointer;
282
+ display: flex;
283
+ gap: 8px;
284
+ align-items: center;
285
+ font-size: var(--credbuild-font-size-xxs);
286
+ margin: 0;
287
+ padding: 8px 12px;
288
+ width: 100%;
289
+ }
290
+ ._SelectItem--isSelected_16son_87 {
291
+ background: var(--credbuild-color-azure-11);
292
+ color: var(--credbuild-color-azure-04);
293
+ font-weight: 500;
294
+ }
295
+ ._SelectItem--isSelected_16son_87 ._SelectItem-icon_16son_93 {
296
+ color: var(--credbuild-color-azure-04);
297
+ }
298
+ ._SelectItem_16son_72:hover {
299
+ background: var(--credbuild-color-azure-11);
300
+ color: var(--credbuild-color-azure-04);
301
+ }
302
+
303
+ /* css-module:/home/crediblemark/Project/NEXT_CMS/packages/components/RichTextEditor/styles.module.css/#css-module-data */
304
+ ._RichTextEditor_hp4qf_1 .ProseMirror {
305
+ white-space: pre-wrap;
306
+ word-wrap: break-word;
307
+ cursor: text;
308
+ outline: none;
309
+ position: relative;
310
+ }
311
+ ._RichTextEditor_hp4qf_1 .rich-text * {
312
+ white-space: pre-wrap;
313
+ user-select: auto;
314
+ -webkit-user-select: auto;
315
+ }
316
+ ._RichTextEditor_hp4qf_1 .rich-text blockquote {
317
+ margin: 1em 0;
318
+ padding: 0 1em;
319
+ border-left: 4px solid var(--credbuild-color-grey-09);
320
+ }
321
+ ._RichTextEditor_hp4qf_1 .rich-text code {
322
+ background-color: var(--credbuild-color-grey-11);
323
+ padding: 4px 8px;
324
+ border-radius: 4px;
325
+ }
326
+ ._RichTextEditor_hp4qf_1 .rich-text p:empty::before {
327
+ content: "\a0";
328
+ }
329
+ ._RichTextEditor_hp4qf_1 .rich-text pre code {
330
+ display: block;
331
+ padding: 8px 12px;
332
+ }
333
+ ._RichTextEditor_hp4qf_1 .rich-text > *:first-child,
334
+ ._RichTextEditor_hp4qf_1 .ProseMirror > *:first-child,
335
+ ._RichTextEditor_hp4qf_1 .rich-text * p:first-of-type {
336
+ margin-top: 0;
337
+ }
338
+ ._RichTextEditor_hp4qf_1 .rich-text > *:last-child,
339
+ ._RichTextEditor_hp4qf_1 .ProseMirror > *:last-child,
340
+ ._RichTextEditor_hp4qf_1 .rich-text * p:last-of-type {
341
+ margin-bottom: 0;
342
+ }
343
+ ._RichTextEditor--editor_hp4qf_50 {
344
+ background: var(--credbuild-color-white);
345
+ border-width: 1px;
346
+ border-style: solid;
347
+ border-color: var(--credbuild-color-grey-09);
348
+ border-radius: 4px;
349
+ box-sizing: border-box;
350
+ display: flex;
351
+ flex-direction: column;
352
+ font-family: inherit;
353
+ font-size: var(--credbuild-font-size-xxs);
354
+ resize: vertical;
355
+ text-align: initial;
356
+ transition: border-color 50ms ease-in;
357
+ width: 100%;
358
+ max-width: 100%;
359
+ min-height: 128px;
360
+ }
361
+ ._RichTextEditor--editor_hp4qf_50 .rich-text {
362
+ flex-grow: 1;
363
+ }
364
+ ._RichTextEditor--editor_hp4qf_50 .rich-text:not(:has(.ProseMirror)),
365
+ ._RichTextEditor--editor_hp4qf_50 .rich-text .ProseMirror {
366
+ height: 100%;
367
+ padding: 12px 15px;
368
+ }
369
+ ._RichTextEditor--editor_hp4qf_50 .rich-text ul,
370
+ ._RichTextEditor--editor_hp4qf_50 .rich-text ol {
371
+ padding-left: 24px;
372
+ }
373
+ ._RichTextEditor--editor_hp4qf_50 .rich-text li {
374
+ line-height: 1.5;
375
+ }
376
+ ._RichTextEditor--editor_hp4qf_50 .rich-text p {
377
+ margin-block: 12px;
378
+ }
379
+ ._RichTextEditor--editor_hp4qf_50 .rich-text ul {
380
+ list-style: disc;
381
+ }
382
+ ._RichTextEditor--editor_hp4qf_50 .rich-text ol {
383
+ list-style: decimal;
384
+ }
385
+ ._RichTextEditor--editor_hp4qf_50:focus-within {
386
+ border-color: var(--credbuild-color-grey-05);
387
+ outline: 2px solid var(--credbuild-color-azure-05);
388
+ transition: none;
389
+ }
390
+ ._RichTextEditor--editor_hp4qf_50._RichTextEditor--disabled_hp4qf_107 {
391
+ background: var(--credbuild-color-grey-11);
392
+ }
393
+ ._RichTextEditor_hp4qf_1:not(:focus-within):not(._RichTextEditor--isActive_hp4qf_111) .ProseMirror ::selection {
394
+ background-color: transparent;
395
+ }
396
+ ._RichTextEditor-menu_hp4qf_117 {
397
+ border-bottom: 1px solid var(--credbuild-color-grey-10);
398
+ position: sticky;
399
+ top: 0;
400
+ z-index: 1;
401
+ }
402
+ ._RichTextEditor--disabled_hp4qf_107 ._RichTextEditor-menu_hp4qf_117 {
403
+ border-bottom: 1px solid var(--credbuild-color-grey-09);
404
+ }
@@ -0,0 +1,205 @@
1
+ import {
2
+ CredBuildRichText
3
+ } from "./chunk-PHGC6QYB.mjs";
4
+ import {
5
+ EditorInner,
6
+ LoadedRichTextMenu
7
+ } from "./chunk-VGDMWS44.mjs";
8
+ import "./chunk-IJHL7BIR.mjs";
9
+ import "./chunk-DSXRK4QJ.mjs";
10
+ import "./chunk-VFD76OD5.mjs";
11
+ import "./chunk-QF3GD5WQ.mjs";
12
+ import "./chunk-HHBUU7WF.mjs";
13
+ import {
14
+ useAppStore,
15
+ useAppStoreApi
16
+ } from "./chunk-U2NVBXAC.mjs";
17
+ import "./chunk-3AJBFQU4.mjs";
18
+ import "./chunk-CDMESQDA.mjs";
19
+ import "./chunk-YH7AXYKP.mjs";
20
+ import "./chunk-GUJDGRSM.mjs";
21
+ import {
22
+ init_react_import
23
+ } from "./chunk-B4BOBGYB.mjs";
24
+
25
+ // components/RichTextEditor/components/Editor.tsx
26
+ init_react_import();
27
+ import { memo, useMemo } from "react";
28
+
29
+ // components/RichTextEditor/lib/use-synced-editor.ts
30
+ init_react_import();
31
+ import { useEditor } from "@tiptap/react";
32
+ import { useEffect, useRef } from "react";
33
+ import { useDebounce } from "use-debounce";
34
+ function useSyncedEditor({
35
+ content,
36
+ onChange,
37
+ extensions,
38
+ editable = true,
39
+ onFocusChange,
40
+ name
41
+ }) {
42
+ const [debouncedState, setDebouncedState] = useDebounce(null, 50, {
43
+ leading: true,
44
+ maxWait: 200
45
+ });
46
+ const syncingRef = useRef(false);
47
+ const lastSyncedRef = useRef("");
48
+ const editTimer = useRef(null);
49
+ const isPending = !!editTimer.current;
50
+ const isFocused = useAppStore((s) => s.state.ui.field.focus === name);
51
+ const resetTimer = (clearOn) => {
52
+ if (editTimer.current) {
53
+ clearTimeout(editTimer.current);
54
+ }
55
+ editTimer.current = setTimeout(() => {
56
+ if (lastSyncedRef.current === clearOn) {
57
+ editTimer.current = null;
58
+ }
59
+ }, 200);
60
+ };
61
+ const appStoreApi = useAppStoreApi();
62
+ const editor = useEditor({
63
+ extensions,
64
+ content,
65
+ editable,
66
+ immediatelyRender: false,
67
+ parseOptions: { preserveWhitespace: "full" },
68
+ onUpdate: ({ editor: editor2 }) => {
69
+ if (syncingRef.current || !isFocused) {
70
+ appStoreApi.getState().setUi({ field: { focus: name } });
71
+ return;
72
+ }
73
+ const html = editor2.getHTML();
74
+ const { from, to } = editor2.state.selection;
75
+ setDebouncedState({ from, to, html });
76
+ resetTimer(html);
77
+ lastSyncedRef.current = html;
78
+ }
79
+ });
80
+ useEffect(() => {
81
+ if (!editor) return;
82
+ const handleFocus = () => {
83
+ onFocusChange?.(editor);
84
+ };
85
+ editor.on("focus", handleFocus);
86
+ return () => {
87
+ editor.off("focus", handleFocus);
88
+ };
89
+ }, [editor, onFocusChange]);
90
+ useEffect(() => {
91
+ if (debouncedState) {
92
+ const { ui } = appStoreApi.getState().state;
93
+ onChange(debouncedState.html, {
94
+ field: {
95
+ ...ui.field,
96
+ metadata: { from: debouncedState.from, to: debouncedState.to }
97
+ }
98
+ });
99
+ }
100
+ }, [editor, debouncedState, onChange, appStoreApi, name]);
101
+ useEffect(() => {
102
+ editor?.setEditable(editable);
103
+ }, [editor, editable]);
104
+ useEffect(() => {
105
+ if (!editor) return;
106
+ if (isPending) {
107
+ return;
108
+ }
109
+ const current = editor.getHTML();
110
+ if (current === content) return;
111
+ syncingRef.current = true;
112
+ editor.commands.setContent(content, { emitUpdate: false });
113
+ const { ui } = appStoreApi.getState().state;
114
+ if (typeof ui.field.metadata?.from !== "undefined") {
115
+ editor.commands.setTextSelection({
116
+ from: ui.field.metadata.from,
117
+ to: ui.field.metadata.to
118
+ });
119
+ }
120
+ syncingRef.current = false;
121
+ }, [content, editor, appStoreApi, isPending]);
122
+ return editor;
123
+ }
124
+
125
+ // components/RichTextEditor/components/Editor.tsx
126
+ import { EditorContent } from "@tiptap/react";
127
+ import { jsx } from "react/jsx-runtime";
128
+ var Editor = memo((props) => {
129
+ const {
130
+ onChange,
131
+ content,
132
+ readOnly = false,
133
+ field,
134
+ inline = false,
135
+ onFocus,
136
+ id,
137
+ name
138
+ } = props;
139
+ const { tiptap = {}, options } = field;
140
+ const { extensions = [] } = tiptap;
141
+ const loadedExtensions = useMemo(
142
+ () => [CredBuildRichText.configure(options), ...extensions],
143
+ [extensions, options]
144
+ );
145
+ const appStoreApi = useAppStoreApi();
146
+ const focusName = `${name}${inline ? "::inline" : ""}`;
147
+ const editor = useSyncedEditor({
148
+ content,
149
+ onChange,
150
+ extensions: loadedExtensions,
151
+ editable: !readOnly,
152
+ name: focusName,
153
+ onFocusChange: (editor2) => {
154
+ if (editor2) {
155
+ const s = appStoreApi.getState();
156
+ appStoreApi.setState({
157
+ currentRichText: {
158
+ field,
159
+ editor: editor2,
160
+ id,
161
+ inline
162
+ },
163
+ state: {
164
+ ...s.state,
165
+ ui: {
166
+ ...s.state.ui,
167
+ field: {
168
+ ...s.state.ui.field,
169
+ focus: focusName
170
+ }
171
+ }
172
+ }
173
+ });
174
+ onFocus?.(editor2);
175
+ }
176
+ }
177
+ });
178
+ const menuEditor = useAppStore((s) => {
179
+ if (!inline && s.currentRichText?.id === id && s.currentRichText?.inlineComponentId) {
180
+ return s.currentRichText.editor;
181
+ }
182
+ return editor;
183
+ });
184
+ if (!editor) return null;
185
+ return /* @__PURE__ */ jsx(
186
+ EditorInner,
187
+ {
188
+ ...props,
189
+ editor,
190
+ menu: /* @__PURE__ */ jsx(
191
+ LoadedRichTextMenu,
192
+ {
193
+ field,
194
+ editor: menuEditor,
195
+ readOnly
196
+ }
197
+ ),
198
+ children: /* @__PURE__ */ jsx(EditorContent, { editor, className: "rich-text" })
199
+ }
200
+ );
201
+ });
202
+ Editor.displayName = "Editor";
203
+ export {
204
+ Editor
205
+ };
@@ -0,0 +1,55 @@
1
+ import {
2
+ CredBuildRichText
3
+ } from "./chunk-PHGC6QYB.mjs";
4
+ import {
5
+ styles_module_default
6
+ } from "./chunk-IJHL7BIR.mjs";
7
+ import {
8
+ get_class_name_factory_default
9
+ } from "./chunk-YH7AXYKP.mjs";
10
+ import {
11
+ init_react_import
12
+ } from "./chunk-B4BOBGYB.mjs";
13
+
14
+ // components/RichTextEditor/components/Render.tsx
15
+ init_react_import();
16
+ import { generateHTML, generateJSON } from "@tiptap/html";
17
+ import { useMemo } from "react";
18
+ import { jsx } from "react/jsx-runtime";
19
+ var getClassName = get_class_name_factory_default("RichTextEditor", styles_module_default);
20
+ function RichTextRender({
21
+ content,
22
+ field
23
+ }) {
24
+ const { tiptap = {}, options } = field;
25
+ const { extensions = [] } = tiptap;
26
+ const loadedExtensions = useMemo(
27
+ () => [CredBuildRichText.configure(options), ...extensions],
28
+ [extensions, options]
29
+ );
30
+ const normalized = useMemo(() => {
31
+ if (typeof content === "object" && content?.type === "doc") {
32
+ return content;
33
+ }
34
+ if (typeof content === "string") {
35
+ const isHtml = /<\/?[a-z][\s\S]*>/i.test(content);
36
+ if (isHtml) {
37
+ return generateJSON(content, loadedExtensions);
38
+ }
39
+ return {
40
+ type: "doc",
41
+ content: [
42
+ { type: "paragraph", content: [{ type: "text", text: content }] }
43
+ ]
44
+ };
45
+ }
46
+ return { type: "doc", content: [] };
47
+ }, [content, loadedExtensions]);
48
+ const html = useMemo(() => {
49
+ return generateHTML(normalized, loadedExtensions);
50
+ }, [normalized, loadedExtensions]);
51
+ return /* @__PURE__ */ jsx("div", { className: getClassName(), children: /* @__PURE__ */ jsx("div", { className: "rich-text", dangerouslySetInnerHTML: { __html: html } }) });
52
+ }
53
+ export {
54
+ RichTextRender
55
+ };