react-restyle-components 0.4.13 → 0.4.14

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 (20) hide show
  1. package/lib/src/core-components/src/components/Accordion/AccordionSection/elements.d.ts.map +1 -1
  2. package/lib/src/core-components/src/components/Accordion/AccordionSection/elements.js +71 -20
  3. package/lib/src/core-components/src/components/Modal/ModalDocxContent/gemini.service.d.ts +4 -0
  4. package/lib/src/core-components/src/components/Modal/ModalDocxContent/gemini.service.d.ts.map +1 -0
  5. package/lib/src/core-components/src/components/Modal/ModalDocxContent/gemini.service.js +70 -0
  6. package/lib/src/core-components/src/components/Modal/ModalDocxContent/modal-docx-content.component.d.ts +43 -0
  7. package/lib/src/core-components/src/components/Modal/ModalDocxContent/modal-docx-content.component.d.ts.map +1 -0
  8. package/lib/src/core-components/src/components/Modal/ModalDocxContent/modal-docx-content.component.js +841 -0
  9. package/lib/src/core-components/src/components/Modal/index.d.ts +1 -0
  10. package/lib/src/core-components/src/components/Modal/index.d.ts.map +1 -1
  11. package/lib/src/core-components/src/components/Modal/index.js +1 -0
  12. package/lib/src/core-components/src/tc.global.css +2 -1
  13. package/lib/src/core-components/src/tc.module.css +1 -1
  14. package/lib/src/core-components/src/utils/index.d.ts +1 -0
  15. package/lib/src/core-components/src/utils/index.d.ts.map +1 -1
  16. package/lib/src/core-components/src/utils/index.js +1 -0
  17. package/lib/src/core-components/src/utils/jodit-editor-config.util.d.ts +189 -0
  18. package/lib/src/core-components/src/utils/jodit-editor-config.util.d.ts.map +1 -0
  19. package/lib/src/core-components/src/utils/jodit-editor-config.util.js +333 -0
  20. package/package.json +3 -1
@@ -0,0 +1,333 @@
1
+ /**
2
+ * JoditEditor Configuration Utility
3
+ *
4
+ * Provides common configuration options and helpers for JoditEditor instances
5
+ * to ensure consistency across components and reduce code duplication.
6
+ */
7
+ /**
8
+ * Common font list used across JoditEditor instances
9
+ */
10
+ export const JODIT_COMMON_FONTS = {
11
+ "'Open Sans',sans-serif": 'Open Sans',
12
+ 'Helvetica,sans-serif': 'Helvetica',
13
+ 'Arial,Helvetica,sans-serif': 'Arial',
14
+ 'Georgia,serif': 'Georgia',
15
+ 'Impact,Charcoal,sans-serif': 'Impact',
16
+ 'Tahoma,Geneva,sans-serif': 'Tahoma',
17
+ "'Times New Roman',Times,serif": 'Times New Roman',
18
+ 'Verdana,Geneva,sans-serif': 'Verdana',
19
+ 'Consolas,monaco,monospace': 'Consolas',
20
+ };
21
+ /**
22
+ * Font size list with comprehensive options (px values)
23
+ */
24
+ export const JODIT_FONT_SIZES = {
25
+ '8px': '8',
26
+ '9px': '9',
27
+ '10px': '10',
28
+ '11px': '11',
29
+ '12px': '12',
30
+ '13px': '13',
31
+ '14px': '14',
32
+ '15px': '15',
33
+ '16px': '16',
34
+ '18px': '18',
35
+ '20px': '20',
36
+ '22px': '22',
37
+ '24px': '24',
38
+ '26px': '26',
39
+ '28px': '28',
40
+ '30px': '30',
41
+ '32px': '32',
42
+ '36px': '36',
43
+ '40px': '40',
44
+ '44px': '44',
45
+ '48px': '48',
46
+ '54px': '54',
47
+ '60px': '60',
48
+ '72px': '72',
49
+ '80px': '80',
50
+ '96px': '96',
51
+ };
52
+ /**
53
+ * Line height list with comprehensive options
54
+ */
55
+ export const JODIT_LINE_HEIGHTS = {
56
+ '1': '1',
57
+ '1.1': '1.1',
58
+ '1.2': '1.2',
59
+ '1.3': '1.3',
60
+ '1.4': '1.4',
61
+ '1.5': '1.5',
62
+ '1.6': '1.6',
63
+ '1.7': '1.7',
64
+ '1.8': '1.8',
65
+ '1.9': '1.9',
66
+ '2': '2',
67
+ '2.2': '2.2',
68
+ '2.5': '2.5',
69
+ '3': '3',
70
+ };
71
+ /**
72
+ * Speech recognition plugin names that should be disabled
73
+ */
74
+ export const JODIT_SPEECH_PLUGINS_TO_DISABLE = [
75
+ 'speech-recognize',
76
+ 'speechRecognize',
77
+ 'speech',
78
+ ];
79
+ /**
80
+ * Speech recognition buttons that should be removed from toolbar
81
+ */
82
+ export const JODIT_SPEECH_BUTTONS_TO_REMOVE = [
83
+ 'speechRecognize',
84
+ 'speech-recognize',
85
+ ];
86
+ /**
87
+ * Base JoditEditor configuration with common settings
88
+ */
89
+ export const JODIT_BASE_CONFIG = {
90
+ readonly: false,
91
+ toolbar: true,
92
+ spellcheck: true,
93
+ language: 'en',
94
+ toolbarButtonSize: 'medium',
95
+ showCharsCounter: true,
96
+ showWordsCounter: true,
97
+ showXPathInStatusbar: false,
98
+ askBeforePasteHTML: true,
99
+ askBeforePasteFromWord: true,
100
+ disablePlugins: [...JODIT_SPEECH_PLUGINS_TO_DISABLE],
101
+ removeButtons: [...JODIT_SPEECH_BUTTONS_TO_REMOVE],
102
+ controls: {
103
+ font: {
104
+ command: 'fontname',
105
+ list: JODIT_COMMON_FONTS,
106
+ },
107
+ fontsize: {
108
+ list: JODIT_FONT_SIZES,
109
+ command: 'fontSize',
110
+ // Add custom value input popup with text input for manual entry (e.g., 5px, 100px)
111
+ popup: (editor, current, close) => {
112
+ const form = editor.create.fromHTML(`
113
+ <div style="padding: 10px; min-width: 200px;">
114
+ <label style="display: block; margin-bottom: 8px; font-weight: bold; color: #333;">Enter Font Size:</label>
115
+ <div style="display: flex; gap: 8px; align-items: center;">
116
+ <input type="text" placeholder="e.g., 14px, 1.5em, 12pt"
117
+ style="flex: 1; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;" />
118
+ <button type="button" style="padding: 8px 16px; background: #2196F3; color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: bold;">Apply</button>
119
+ </div>
120
+ <div style="margin-top: 8px; font-size: 11px; color: #666;">
121
+ Supports: px, pt, em, rem, % (e.g., 16px, 12pt, 1.2em)
122
+ </div>
123
+ </div>
124
+ `);
125
+ const input = form.querySelector('input');
126
+ const applyBtn = form.querySelector('button');
127
+ const handleApply = () => {
128
+ let value = input.value.trim();
129
+ if (value) {
130
+ // If user enters only number, default to px
131
+ if (/^\d+(\.\d+)?$/.test(value)) {
132
+ value = value + 'px';
133
+ }
134
+ // Try fontSize command first, fallback to direct style application
135
+ try {
136
+ editor.execCommand('fontSize', false, value);
137
+ }
138
+ catch {
139
+ // Fallback: Apply font-size directly via style
140
+ editor.s.applyStyle({ fontSize: value });
141
+ }
142
+ close();
143
+ }
144
+ };
145
+ applyBtn.addEventListener('click', handleApply);
146
+ input.addEventListener('keydown', (e) => {
147
+ if (e.key === 'Enter') {
148
+ e.preventDefault();
149
+ handleApply();
150
+ }
151
+ });
152
+ // Auto focus input
153
+ setTimeout(() => input.focus(), 100);
154
+ return form;
155
+ },
156
+ },
157
+ lineHeight: {
158
+ list: JODIT_LINE_HEIGHTS,
159
+ command: 'applyLineHeight',
160
+ // Add custom value input popup with text input for manual entry
161
+ popup: (editor, current, close) => {
162
+ const form = editor.create.fromHTML(`
163
+ <div style="padding: 10px; min-width: 200px;">
164
+ <label style="display: block; margin-bottom: 8px; font-weight: bold; color: #333;">Enter Line Height:</label>
165
+ <div style="display: flex; gap: 8px; align-items: center;">
166
+ <input type="text" placeholder="e.g., 1.5, 2, 24px"
167
+ style="flex: 1; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;" />
168
+ <button type="button" style="padding: 8px 16px; background: #2196F3; color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: bold;">Apply</button>
169
+ </div>
170
+ <div style="margin-top: 8px; font-size: 11px; color: #666;">
171
+ Supports: number (1.5, 2) or units (24px, 1.5em)
172
+ </div>
173
+ </div>
174
+ `);
175
+ const input = form.querySelector('input');
176
+ const applyBtn = form.querySelector('button');
177
+ const handleApply = () => {
178
+ const value = input.value.trim();
179
+ if (value) {
180
+ // Try applyLineHeight command first, fallback to direct style application
181
+ try {
182
+ editor.execCommand('applyLineHeight', false, value);
183
+ }
184
+ catch {
185
+ // Fallback: Apply line-height directly via style
186
+ editor.s.applyStyle({ lineHeight: value });
187
+ }
188
+ close();
189
+ }
190
+ };
191
+ applyBtn.addEventListener('click', handleApply);
192
+ input.addEventListener('keydown', (e) => {
193
+ if (e.key === 'Enter') {
194
+ e.preventDefault();
195
+ handleApply();
196
+ }
197
+ });
198
+ // Auto focus input
199
+ setTimeout(() => input.focus(), 100);
200
+ return form;
201
+ },
202
+ },
203
+ },
204
+ };
205
+ /**
206
+ * Creates a JoditEditor configuration
207
+ *
208
+ * @param overrides - Configuration overrides to merge with base config
209
+ * @param enableSpeechRecognition - If true, enables speech recognition (default: false)
210
+ * @returns Merged JoditEditor configuration
211
+ */
212
+ export function createJoditConfig(overrides = {}, enableSpeechRecognition = false) {
213
+ // Create mutable copies of arrays
214
+ const baseDisablePlugins = [...JODIT_BASE_CONFIG.disablePlugins];
215
+ const baseRemoveButtons = [...JODIT_BASE_CONFIG.removeButtons];
216
+ // If speech recognition is enabled, don't disable it
217
+ if (enableSpeechRecognition) {
218
+ const filteredPlugins = baseDisablePlugins.filter((plugin) => !JODIT_SPEECH_PLUGINS_TO_DISABLE.includes(plugin));
219
+ const filteredButtons = baseRemoveButtons.filter((button) => !JODIT_SPEECH_BUTTONS_TO_REMOVE.includes(button));
220
+ return {
221
+ ...JODIT_BASE_CONFIG,
222
+ ...overrides,
223
+ disablePlugins: overrides.disablePlugins || filteredPlugins,
224
+ removeButtons: overrides.removeButtons || filteredButtons,
225
+ // Merge controls if provided
226
+ controls: overrides.controls
227
+ ? {
228
+ ...JODIT_BASE_CONFIG.controls,
229
+ ...overrides.controls,
230
+ }
231
+ : JODIT_BASE_CONFIG.controls,
232
+ };
233
+ }
234
+ return {
235
+ ...JODIT_BASE_CONFIG,
236
+ ...overrides,
237
+ // Merge disablePlugins if provided
238
+ disablePlugins: [
239
+ ...baseDisablePlugins,
240
+ ...(overrides.disablePlugins || []),
241
+ ],
242
+ // Merge removeButtons if provided
243
+ removeButtons: [...baseRemoveButtons, ...(overrides.removeButtons || [])],
244
+ // Merge controls if provided
245
+ controls: overrides.controls
246
+ ? {
247
+ ...JODIT_BASE_CONFIG.controls,
248
+ ...overrides.controls,
249
+ }
250
+ : JODIT_BASE_CONFIG.controls,
251
+ };
252
+ }
253
+ /**
254
+ * Common paste dialog handler that closes the dialog immediately
255
+ */
256
+ export const JODIT_PASTE_DIALOG_HANDLER = {
257
+ afterOpenPasteDialog: (dialog, msg, title, callback) => {
258
+ dialog.close();
259
+ callback();
260
+ },
261
+ };
262
+ /**
263
+ * Common toolbar buttons configuration organized by category
264
+ * Used across all JoditEditor instances for consistency
265
+ */
266
+ export const JODIT_TOOLBAR_BUTTONS = [
267
+ // Source & View
268
+ 'source',
269
+ '|',
270
+ // Text Formatting
271
+ 'bold',
272
+ 'italic',
273
+ 'underline',
274
+ 'strikethrough',
275
+ '|',
276
+ 'superscript',
277
+ 'subscript',
278
+ '|',
279
+ // Font Styling
280
+ 'font',
281
+ 'fontsize',
282
+ 'lineHeight',
283
+ 'brush',
284
+ 'paragraph',
285
+ 'classSpan',
286
+ '|',
287
+ // Lists
288
+ 'ul',
289
+ 'ol',
290
+ '|',
291
+ // Indentation
292
+ 'indent',
293
+ 'outdent',
294
+ '|',
295
+ // Alignment
296
+ 'align',
297
+ 'left',
298
+ 'center',
299
+ 'right',
300
+ 'justify',
301
+ '|',
302
+ // Media & Links
303
+ 'image',
304
+ 'video',
305
+ 'file',
306
+ 'link',
307
+ '|',
308
+ // Insert Elements
309
+ 'hr',
310
+ 'table',
311
+ 'symbol',
312
+ '|',
313
+ // Clipboard
314
+ 'cut',
315
+ 'copy',
316
+ 'paste',
317
+ 'selectall',
318
+ 'copyformat',
319
+ 'eraser',
320
+ '|',
321
+ // History
322
+ 'undo',
323
+ 'redo',
324
+ '|',
325
+ // Tools
326
+ 'find',
327
+ 'spellcheck',
328
+ 'print',
329
+ 'fullsize',
330
+ '|',
331
+ // Other
332
+ 'dots',
333
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-restyle-components",
3
- "version": "0.4.13",
3
+ "version": "0.4.14",
4
4
  "private": false,
5
5
  "description": "Easy use restyle components",
6
6
  "author": {
@@ -52,10 +52,12 @@
52
52
  "clsx": "^2.1.1",
53
53
  "dayjs": "^1.11.1",
54
54
  "jest-environment-jsdom": "^29.7.0",
55
+ "jodit-react": "^5.2.38",
55
56
  "react-colorful": "^5.6.1",
56
57
  "react-datepicker": "^4.7.0",
57
58
  "react-icons": "^5.5.0",
58
59
  "react-scripts": "5.0.1",
60
+ "react-speech-recognition": "^4.0.1",
59
61
  "reactstrap": "^9.0.2",
60
62
  "styled-components": "^6.1.19",
61
63
  "tailwind-merge": "^2.5.5",