@widgetic/editor 4.1.13 → 4.1.15

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 (89) hide show
  1. package/dist/components/PreviewChromeControls.svelte +15 -21
  2. package/dist/components/WidgetPreview.svelte +136 -105
  3. package/dist/components/color-select/ColorSelect.svelte +203 -224
  4. package/dist/components/color-select/constants.d.ts +4 -2
  5. package/dist/components/color-select/constants.js +4 -2
  6. package/dist/components/color-select/render.js +10 -9
  7. package/dist/components/editors/CompositionEditorApp.svelte +55 -40
  8. package/dist/components/editors/EditLeaseNotice.svelte +44 -33
  9. package/dist/components/editors/EmbedEditor.svelte +133 -259
  10. package/dist/components/editors/PropsEditor.svelte +426 -1333
  11. package/dist/components/editors/props-editor.css +5 -68
  12. package/dist/components/ic/AngleInputController.svelte +202 -277
  13. package/dist/components/ic/BrowserInputController.svelte +813 -803
  14. package/dist/components/ic/CheckboxInputController.svelte +92 -169
  15. package/dist/components/ic/CheckboxInputController.svelte.d.ts +2 -8
  16. package/dist/components/ic/ColorPickerInputController.svelte +1589 -1587
  17. package/dist/components/ic/ColorPickerInputController.svelte.d.ts +3 -3
  18. package/dist/components/ic/DateFieldInputController.svelte +455 -465
  19. package/dist/components/ic/DatePickerInputController.svelte +355 -368
  20. package/dist/components/ic/DatePickerInputController.svelte.d.ts +1 -1
  21. package/dist/components/ic/DropdownInputController.svelte +130 -200
  22. package/dist/components/ic/FixedPositionInputController.svelte +255 -276
  23. package/dist/components/ic/FixedPositionInputController.svelte.d.ts +5 -1
  24. package/dist/components/ic/FontInputController.svelte +2110 -2231
  25. package/dist/components/ic/FontInputController.svelte.d.ts +11 -11
  26. package/dist/components/ic/InputControllerHeader.svelte +141 -147
  27. package/dist/components/ic/InputControllerRenderer.svelte +5 -1
  28. package/dist/components/ic/InputControllerRenderer.svelte.d.ts +2 -1
  29. package/dist/components/ic/InputControllerRow.svelte +74 -0
  30. package/dist/components/ic/InputControllerRow.svelte.d.ts +14 -0
  31. package/dist/components/ic/KnowledgeDocumentsInputController.svelte +401 -0
  32. package/dist/components/ic/KnowledgeDocumentsInputController.svelte.d.ts +11 -0
  33. package/dist/components/ic/KnowledgeTextForm.svelte +109 -0
  34. package/dist/components/ic/KnowledgeTextForm.svelte.d.ts +15 -0
  35. package/dist/components/ic/NumberControls.svelte +303 -269
  36. package/dist/components/ic/NumberControls.svelte.d.ts +4 -1
  37. package/dist/components/ic/NumberInputController.svelte +361 -301
  38. package/dist/components/ic/NumberInputController.svelte.d.ts +2 -0
  39. package/dist/components/ic/PositionInputController.svelte +253 -176
  40. package/dist/components/ic/PositionInputController.svelte.d.ts +2 -0
  41. package/dist/components/ic/RadioGroupInputController.svelte +71 -137
  42. package/dist/components/ic/RadioGroupInputController.svelte.d.ts +2 -8
  43. package/dist/components/ic/RangeCalendarInputController.svelte +233 -270
  44. package/dist/components/ic/RangeCalendarInputController.svelte.d.ts +2 -2
  45. package/dist/components/ic/RoundedCornersInputController.svelte +412 -435
  46. package/dist/components/ic/RoundedCornersInputController.svelte.d.ts +2 -0
  47. package/dist/components/ic/SliderInputController.svelte +263 -332
  48. package/dist/components/ic/SliderInputController.svelte.d.ts +1 -1
  49. package/dist/components/ic/SliderRangeInputController.svelte +140 -144
  50. package/dist/components/ic/SliderRangeInputController.svelte.d.ts +3 -3
  51. package/dist/components/ic/SwitchInputController.svelte +47 -109
  52. package/dist/components/ic/TagsInputController.svelte +95 -110
  53. package/dist/components/ic/TextAreaInputController.svelte +1794 -1935
  54. package/dist/components/ic/TextAreaPreviewInputController.svelte +436 -438
  55. package/dist/components/ic/TextAreaPreviewInputController.svelte.d.ts +2 -2
  56. package/dist/components/ic/TextInputController.svelte +65 -75
  57. package/dist/components/ic/TextInputController.svelte.d.ts +2 -0
  58. package/dist/components/ic/TimeInputController.svelte +433 -431
  59. package/dist/components/ic/VectorInputController.svelte +1833 -1831
  60. package/dist/components/ic/VectorInputController.svelte.d.ts +10 -10
  61. package/dist/components/ic/index.d.ts +2 -0
  62. package/dist/components/ic/index.js +2 -0
  63. package/dist/components/ic/shared/CategoryTabs.svelte +28 -35
  64. package/dist/components/ic/shared/ItemGrid.svelte +145 -179
  65. package/dist/components/ic/shared/RecentItemsSection.svelte +208 -271
  66. package/dist/components/ic/shared/RecentItemsSection.svelte.d.ts +1 -1
  67. package/dist/components/ui/arrows/OpacitySliderArrows.svelte +23 -38
  68. package/dist/components/ui/arrows/OpacitySliderArrows.svelte.d.ts +1 -4
  69. package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte +45 -0
  70. package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte.d.ts +26 -0
  71. package/dist/components/ui/checkerboard-background/CheckerboardBackground.svelte +20 -12
  72. package/dist/components/ui/shadow-picker-host/ShadowPickerHost.svelte +39 -0
  73. package/dist/components/ui/shadow-picker-host/ShadowPickerHost.svelte.d.ts +10 -0
  74. package/dist/composition/compositionApi.d.ts +21 -1
  75. package/dist/composition/compositionApi.js +64 -5
  76. package/dist/composition/knowledgeDocuments.d.ts +90 -0
  77. package/dist/composition/knowledgeDocuments.js +94 -0
  78. package/dist/composition/knowledgeDocumentsPanel.d.ts +152 -0
  79. package/dist/composition/knowledgeDocumentsPanel.js +443 -0
  80. package/dist/i18n/language.d.ts +86 -36
  81. package/dist/i18n/messages.d.ts +97 -34
  82. package/dist/i18n/messages.js +104 -34
  83. package/dist/i18n/translate.d.ts +1 -1
  84. package/dist/index.d.ts +1 -0
  85. package/dist/knowledgeDocumentsContext.d.ts +10 -0
  86. package/dist/knowledgeDocumentsContext.js +31 -0
  87. package/dist/utils.d.ts +7 -0
  88. package/dist/utils.js +26 -2
  89. package/package.json +4 -4
@@ -1,447 +1,445 @@
1
1
  <script module lang="ts">
2
- import type { InputControllerConfig } from './index';
3
-
4
- /** Declared props contract — export lets below are annotated from it so the
5
- * interface cannot drift from what the component actually reads. */
6
- export interface TextAreaPreviewInputControllerProps {
7
- label?: string;
8
- value?: string;
9
- onChange: (newValue: string) => void;
10
- config?: InputControllerConfig;
11
- description?: string;
12
- portalTarget?: string | HTMLElement;
13
- }
2
+ import type { InputControllerConfig } from './index';
3
+
4
+ /** Declared props contract — export lets below are annotated from it so the
5
+ * interface cannot drift from what the component actually reads. */
6
+ export interface TextAreaPreviewInputControllerProps {
7
+ label?: string;
8
+ value?: string;
9
+ onChange: (newValue: string) => void;
10
+ config?: InputControllerConfig;
11
+ description?: string;
12
+ portalTarget?: string | HTMLElement;
13
+ }
14
14
  </script>
15
15
 
16
16
  <script lang="ts">
17
- import { Portal } from '@widgetic/design-system/components';
18
- import { IconArrowsDiagonal } from '@widgetic/design-system/icons';
19
- import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
20
- import { onMount, onDestroy } from 'svelte';
21
-
22
- import { TextAreaInputController } from './index';
23
- import { createPreviewHtml } from '../../utils/richTextPreview';
24
- import { escapeHtml } from '../../utils/htmlSafety';
25
-
26
- // The way the screen is read: the text in the preview is what a person wrote, so on a right to left screen it is read by its own first letter.
27
- const textDirection = useTextDirection();
28
-
29
- /**
30
- * Component props
31
- */
32
- export let label: TextAreaPreviewInputControllerProps['label'] = '';
33
- export let value: TextAreaPreviewInputControllerProps['value'] = '';
34
- export let onChange: TextAreaPreviewInputControllerProps['onChange'];
35
- export let config: TextAreaPreviewInputControllerProps['config'] = {};
36
- export let description: TextAreaPreviewInputControllerProps['description'] = undefined;
37
- export let portalTarget: TextAreaPreviewInputControllerProps['portalTarget'] = '';
38
- /**
39
- * Local Variables
40
- */
41
-
42
- // Use config values with fallbacks
43
- const placeholder: string = config.placeholder || '';
44
-
45
- let isShowingTextArea = false;
46
-
47
- // Add a computed property to determine if we're showing placeholder
48
- $: isShowingPlaceholder = !value && placeholder;
49
-
50
- // Create a preview version of the text that preserves formatting
51
- $: previewText = value ? createPreviewText(value) : escapeHtml(placeholder);
52
-
53
- // Add this to track the current color
54
- let currentColor = '#1a1a1a'; // Default color
55
-
56
- // Add this near the top with other state declarations
57
- let isPortalHovered = false;
58
-
59
- // Add this to store the background rect ref
60
- let backgroundRectRef: HTMLDivElement;
61
-
62
- // The box the text editor is shown in. The editor is found through it: a search of the whole `document` finds nothing
63
- // inside a module's shadow root, and finds the customer's own text editor (and focuses it) when the page has one.
64
- let portalContentRef: HTMLDivElement | undefined;
65
-
66
- // Add these near the top with other state declarations
67
- let isClosing = false;
68
-
69
- /**
70
- * Methods
71
- */
72
- function createPreviewText(text: string) {
73
- // The text is rich text somebody typed or pasted, and this editor can run inside a customer's page: the preview is
74
- // not a copy of that HTML. It is built by a renderer that escapes every text and keeps only the tags and styles on
75
- // its lists (see richTextPreview.ts). Block wrappers (p, div, br) are flattened there, so marks render inside the
76
- // compact clamp box.
77
- try {
78
- return createPreviewHtml(text);
79
- } catch (error) {
80
- console.error('[TextAreaPreview] Could not build the preview of the text:', error);
81
- return escapeHtml(text);
82
- }
83
- }
84
-
85
- function handleFullEditorChange(html: string) {
86
- value = html;
87
- if (typeof onChange === 'function') onChange(html);
88
- }
89
-
90
- function handleClick() {
91
- // console.log('Opening text area in portal');
92
- isShowingTextArea = !isShowingTextArea;
93
- }
94
-
95
- $: if (isShowingTextArea) {
96
- setTimeout(() => {
97
- const editor = portalContentRef?.querySelector('.ProseMirror');
98
- if (editor instanceof HTMLElement) {
99
- editor.focus();
100
- }
101
- }, 100); // Give a bit more time for the portal to mount
102
- }
103
-
104
- // Update value reactively to track color changes
105
- $: {
106
- if (value) {
107
- const colorMatch = value.match(/color:\s*(#[0-9A-Fa-f]{6}|rgb\([^)]+\))/);
108
- if (colorMatch) {
109
- currentColor = colorMatch[1];
110
- }
111
- }
112
- }
113
-
114
- $: if (value) {
115
- // console.log('[TextAreaPreview] compact preview html', value.slice(0, 180));
116
- }
117
-
118
- function handlePortalMouseEnter() {
119
- // console.log('Portal mouse entered');
120
- isPortalHovered = true;
121
- }
122
-
123
- function handlePortalMouseLeave(event: MouseEvent) {
124
- // if (!backgroundRectRef) return;
125
- // console.log('Portal mouse leave: ', event, backgroundRectRef.getBoundingClientRect());
126
-
127
- // Get mouse position relative to the portal content
128
- const { offsetX, offsetY } = event;
129
- const offsetWidth = backgroundRectRef.getBoundingClientRect().width;
130
- const offsetHeight = backgroundRectRef.getBoundingClientRect().height;
131
- // console.log('Portal mouse leave mousePosition: ', offsetX, offsetY, offsetWidth, offsetHeight);
132
-
133
- // Check if cursor is within the background rect boundaries
134
- if (
135
- 0 < offsetX && offsetX < offsetWidth &&
136
- 0 < offsetY && offsetY < offsetHeight
137
- ) {
138
- // console.log('Portal mouse leave mousePosition: ', offsetX, offsetY, offsetWidth, offsetHeight);
139
- return;
140
- }
141
-
142
- // console.log('Portal mouse leave mousePosition: ', offsetX, offsetY, offsetWidth, offsetHeight);
143
- isPortalHovered = false;
144
- }
145
-
146
- // Add keyboard event handler for Escape key
147
- function handleKeydown(event: KeyboardEvent) {
148
- if (event.key === 'Escape' && isShowingTextArea) {
149
- handleClose();
150
- }
151
- }
152
-
153
- onMount(() => {
154
- // Add keyboard event listener when component mounts
155
- window.addEventListener('keydown', handleKeydown);
156
- });
157
-
158
- onDestroy(() => {
159
- // Remove keyboard event listener when component is destroyed
160
- window.removeEventListener('keydown', handleKeydown);
161
- });
162
-
163
- // Update the close handler
164
- function handleClose() {
165
- if (isClosing) return; // Prevent multiple closes
166
- isClosing = true;
167
-
168
- // Add animation end handler
169
- const content = portalContentRef;
170
- const overlay = content?.previousElementSibling as HTMLDivElement;
171
-
172
- const handleAnimationEnd = () => {
173
- if (content) content.dataset.state = 'complete';
174
- if (overlay) overlay.dataset.state = 'complete';
175
-
176
- // Remove the elements after a short delay
177
- setTimeout(() => {
178
- isShowingTextArea = false;
179
- isClosing = false;
180
- if (content) content.dataset.state = '';
181
- if (overlay) overlay.dataset.state = '';
182
- }, 50);
183
- };
184
-
185
- // Listen for the end of the scale animation
186
- content?.addEventListener('animationend', handleAnimationEnd, { once: true });
187
- }
17
+ import { Portal } from '@widgetic/design-system/components';
18
+ import { IconArrowsDiagonal } from '@widgetic/design-system/icons';
19
+ import {
20
+ dirForUserText,
21
+ useTextDirection
22
+ } from '@widgetic/design-system/components/textDirection';
23
+ import { onMount, onDestroy } from 'svelte';
24
+
25
+ import { TextAreaInputController } from './index';
26
+ import { createPreviewHtml } from '../../utils/richTextPreview';
27
+ import { escapeHtml } from '../../utils/htmlSafety';
28
+
29
+ // The way the screen is read: the text in the preview is what a person wrote, so on a right to left screen it is read by its own first letter.
30
+ const textDirection = useTextDirection();
31
+
32
+ /**
33
+ * Component props
34
+ */
35
+ export let label: TextAreaPreviewInputControllerProps['label'] = '';
36
+ export let value: TextAreaPreviewInputControllerProps['value'] = '';
37
+ export let onChange: TextAreaPreviewInputControllerProps['onChange'];
38
+ export let config: TextAreaPreviewInputControllerProps['config'] = {};
39
+ export let description: TextAreaPreviewInputControllerProps['description'] = undefined;
40
+ export let portalTarget: TextAreaPreviewInputControllerProps['portalTarget'] = '';
41
+ /**
42
+ * Local Variables
43
+ */
44
+
45
+ // Use config values with fallbacks
46
+ const placeholder: string = config.placeholder || '';
47
+
48
+ let isShowingTextArea = false;
49
+
50
+ // Add a computed property to determine if we're showing placeholder
51
+ $: isShowingPlaceholder = !value && placeholder;
52
+
53
+ // Create a preview version of the text that preserves formatting
54
+ $: previewText = value ? createPreviewText(value) : escapeHtml(placeholder);
55
+
56
+ // Add this to track the current color
57
+ let currentColor = '#1a1a1a'; // Default color
58
+
59
+ // Add this near the top with other state declarations
60
+ let isPortalHovered = false;
61
+
62
+ // Add this to store the background rect ref
63
+ let backgroundRectRef: HTMLDivElement;
64
+
65
+ // The box the text editor is shown in. The editor is found through it: a search of the whole `document` finds nothing
66
+ // inside a module's shadow root, and finds the customer's own text editor (and focuses it) when the page has one.
67
+ let portalContentRef: HTMLDivElement | undefined;
68
+
69
+ // Add these near the top with other state declarations
70
+ let isClosing = false;
71
+
72
+ /**
73
+ * Methods
74
+ */
75
+ function createPreviewText(text: string) {
76
+ // The text is rich text somebody typed or pasted, and this editor can run inside a customer's page: the preview is
77
+ // not a copy of that HTML. It is built by a renderer that escapes every text and keeps only the tags and styles on
78
+ // its lists (see richTextPreview.ts). Block wrappers (p, div, br) are flattened there, so marks render inside the
79
+ // compact clamp box.
80
+ try {
81
+ return createPreviewHtml(text);
82
+ } catch (error) {
83
+ console.error('[TextAreaPreview] Could not build the preview of the text:', error);
84
+ return escapeHtml(text);
85
+ }
86
+ }
87
+
88
+ function handleFullEditorChange(html: string) {
89
+ value = html;
90
+ if (typeof onChange === 'function') onChange(html);
91
+ }
92
+
93
+ function handleClick() {
94
+ // console.log('Opening text area in portal');
95
+ isShowingTextArea = !isShowingTextArea;
96
+ }
97
+
98
+ $: if (isShowingTextArea) {
99
+ setTimeout(() => {
100
+ const editor = portalContentRef?.querySelector('.ProseMirror');
101
+ if (editor instanceof HTMLElement) {
102
+ editor.focus();
103
+ }
104
+ }, 100); // Give a bit more time for the portal to mount
105
+ }
106
+
107
+ // Update value reactively to track color changes
108
+ $: {
109
+ if (value) {
110
+ const colorMatch = value.match(/color:\s*(#[0-9A-Fa-f]{6}|rgb\([^)]+\))/);
111
+ if (colorMatch) {
112
+ currentColor = colorMatch[1];
113
+ }
114
+ }
115
+ }
116
+
117
+ $: if (value) {
118
+ // console.log('[TextAreaPreview] compact preview html', value.slice(0, 180));
119
+ }
120
+
121
+ function handlePortalMouseEnter() {
122
+ // console.log('Portal mouse entered');
123
+ isPortalHovered = true;
124
+ }
125
+
126
+ function handlePortalMouseLeave(event: MouseEvent) {
127
+ // if (!backgroundRectRef) return;
128
+ // console.log('Portal mouse leave: ', event, backgroundRectRef.getBoundingClientRect());
129
+
130
+ // Get mouse position relative to the portal content
131
+ const { offsetX, offsetY } = event;
132
+ const offsetWidth = backgroundRectRef.getBoundingClientRect().width;
133
+ const offsetHeight = backgroundRectRef.getBoundingClientRect().height;
134
+ // console.log('Portal mouse leave mousePosition: ', offsetX, offsetY, offsetWidth, offsetHeight);
135
+
136
+ // Check if cursor is within the background rect boundaries
137
+ if (0 < offsetX && offsetX < offsetWidth && 0 < offsetY && offsetY < offsetHeight) {
138
+ // console.log('Portal mouse leave mousePosition: ', offsetX, offsetY, offsetWidth, offsetHeight);
139
+ return;
140
+ }
141
+
142
+ // console.log('Portal mouse leave mousePosition: ', offsetX, offsetY, offsetWidth, offsetHeight);
143
+ isPortalHovered = false;
144
+ }
145
+
146
+ // Add keyboard event handler for Escape key
147
+ function handleKeydown(event: KeyboardEvent) {
148
+ if (event.key === 'Escape' && isShowingTextArea) {
149
+ handleClose();
150
+ }
151
+ }
152
+
153
+ onMount(() => {
154
+ // Add keyboard event listener when component mounts
155
+ window.addEventListener('keydown', handleKeydown);
156
+ });
157
+
158
+ onDestroy(() => {
159
+ // Remove keyboard event listener when component is destroyed
160
+ window.removeEventListener('keydown', handleKeydown);
161
+ });
162
+
163
+ // Update the close handler
164
+ function handleClose() {
165
+ if (isClosing) return; // Prevent multiple closes
166
+ isClosing = true;
167
+
168
+ // Add animation end handler
169
+ const content = portalContentRef;
170
+ const overlay = content?.previousElementSibling as HTMLDivElement;
171
+
172
+ const handleAnimationEnd = () => {
173
+ if (content) content.dataset.state = 'complete';
174
+ if (overlay) overlay.dataset.state = 'complete';
175
+
176
+ // Remove the elements after a short delay
177
+ setTimeout(() => {
178
+ isShowingTextArea = false;
179
+ isClosing = false;
180
+ if (content) content.dataset.state = '';
181
+ if (overlay) overlay.dataset.state = '';
182
+ }, 50);
183
+ };
184
+
185
+ // Listen for the end of the scale animation
186
+ content?.addEventListener('animationend', handleAnimationEnd, { once: true });
187
+ }
188
188
  </script>
189
189
 
190
- <div class="text-area-preview-input-controller w-full min-w-0 overflow-hidden widgetic-colors">
191
- <div
192
- class="text-area-preview-main-container w-full min-w-0 overflow-hidden"
193
- >
194
- <div
195
- class="textarea-ic-preview-box relative h-[92px] w-full min-w-0 border border-grey2 bg-grey1 transition-colors duration-200 hover:border-forest-green cursor-pointer group overflow-hidden"
196
- style="border-radius: var(--radius-large);"
197
- on:click={handleClick}
198
- on:keydown={(e) => e.key === 'Enter' && handleClick()}
199
- role="button"
200
- tabindex="0"
201
- >
202
- <div class="textarea-ic-preview-copy min-w-0 overflow-hidden pe-10 pt-[13px] pb-4 ps-4">
203
- <div
204
- class="textarea-ic-preview-html break-words text-grey7 text-sm leading-5"
205
- class:text-grey3={isShowingPlaceholder}
206
- dir={dirForUserText($textDirection)}
207
- >
208
- {@html previewText}
209
- </div>
210
- </div>
211
- <div class="textarea-ic-expand-icon absolute top-[14px] end-[12px]">
212
- <IconArrowsDiagonal
213
- class="w-5 h-5 text-grey5 group-hover:text-grey7 transition-colors duration-200"
214
- />
215
- </div>
216
- </div>
217
- </div>
218
-
219
- <!-- Description -->
220
- {#if description}
221
- <p class="subtext text-grey5">{description}</p>
222
- {/if}
223
-
224
- <!-- Text Area Input Controller in Portal -->
225
- {#if isShowingTextArea}
226
- <Portal
227
- target={portalTarget}
228
- class="text-area-portal absolute top-0 start-0 w-full h-full"
229
- >
230
- <!-- Blocking overlay -->
231
- <div
232
- class="absolute inset-0 bg-white {isClosing ? 'fade-out-animation' : 'fade-in-animation'}"
233
- style="z-index: 50; transform: translateZ(0); backface-visibility: hidden;"
234
- ></div>
235
- <!-- svelte-ignore a11y_no_static_element_interactions -->
236
- <div
237
- bind:this={portalContentRef}
238
- class="text-area-portal-content absolute mt-4 mx-6 mb-6 inset-0 {isClosing ? 'scale-out-animation' : 'scale-in-animation'}"
239
- style="z-index: 51; transform: translateZ(0); backface-visibility: hidden;"
240
- on:mouseenter={handlePortalMouseEnter}
241
- on:mouseleave={handlePortalMouseLeave}
242
- >
243
- <!-- Background rect that defines our hover boundaries -->
244
- <div
245
- bind:this={backgroundRectRef}
246
- class="portal-background-rect absolute inset-0 bg-transparent pointer-events-none"
247
- style="border-radius: var(--radius-large);"
248
- ></div>
249
-
250
- <TextAreaInputController
251
- class="text-area w-full h-full transition-colors duration-200 {isPortalHovered ? 'border-solid !border-forest-green' : ''}"
252
- label={label}
253
- bind:value
254
- onChange={handleFullEditorChange}
255
- config={config}
256
- description={description}
257
- onClose={handleClose}
258
- />
259
- </div>
260
- </Portal>
261
- {/if}
262
-
190
+ <div class="text-area-preview-input-controller w-full min-w-0 overflow-hidden">
191
+ <div class="text-area-preview-main-container w-full min-w-0 overflow-hidden">
192
+ <div
193
+ class="textarea-ic-preview-box group relative h-[92px] w-full min-w-0 cursor-pointer overflow-hidden rounded-lg bg-accent p-2 pb-3 pe-10 ps-3 transition-colors duration-fast hover:bg-accent-hover focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
194
+ on:click={handleClick}
195
+ on:keydown={(e) => e.key === 'Enter' && handleClick()}
196
+ role="button"
197
+ tabindex="0"
198
+ >
199
+ <div class="textarea-ic-preview-copy min-w-0 overflow-hidden">
200
+ <div
201
+ class="textarea-ic-preview-html text-body break-words text-foreground"
202
+ class:text-muted-foreground={isShowingPlaceholder}
203
+ dir={dirForUserText($textDirection)}
204
+ >
205
+ {@html previewText}
206
+ </div>
207
+ </div>
208
+ <div
209
+ class="textarea-ic-expand-icon absolute end-2 top-2 flex size-6 items-center justify-center rounded-lg"
210
+ aria-hidden="true"
211
+ >
212
+ <IconArrowsDiagonal
213
+ class="size-4 stroke-[1.333] text-muted-foreground transition-colors duration-fast group-hover:text-foreground"
214
+ />
215
+ </div>
216
+ </div>
217
+ </div>
218
+
219
+ <!-- Description -->
220
+ {#if description}
221
+ <p class="text-caption text-muted-foreground mt-2">{description}</p>
222
+ {/if}
223
+
224
+ <!-- Text Area Input Controller in Portal -->
225
+ {#if isShowingTextArea}
226
+ <Portal target={portalTarget} class="text-area-portal absolute top-0 start-0 w-full h-full">
227
+ <!-- Blocking overlay -->
228
+ <div
229
+ class="absolute inset-0 bg-background {isClosing
230
+ ? 'fade-out-animation'
231
+ : 'fade-in-animation'}"
232
+ style="z-index: 50; transform: translateZ(0); backface-visibility: hidden;"
233
+ ></div>
234
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
235
+ <div
236
+ bind:this={portalContentRef}
237
+ class="text-area-portal-content absolute mt-4 mx-6 mb-6 inset-0 {isClosing
238
+ ? 'scale-out-animation'
239
+ : 'scale-in-animation'}"
240
+ style="z-index: 51; transform: translateZ(0); backface-visibility: hidden;"
241
+ on:mouseenter={handlePortalMouseEnter}
242
+ on:mouseleave={handlePortalMouseLeave}
243
+ >
244
+ <!-- Background rect that defines our hover boundaries -->
245
+ <!-- Add portal border radius -->
246
+ <div
247
+ bind:this={backgroundRectRef}
248
+ class="portal-background-rect absolute inset-0 bg-transparent pointer-events-none"
249
+ style="border-radius: var(--radius-lg);"
250
+ ></div>
251
+
252
+ <TextAreaInputController
253
+ class="text-area w-full h-full transition-colors duration-fast {isPortalHovered
254
+ ? 'ring-2 ring-ring ring-offset-2 ring-offset-background'
255
+ : ''}"
256
+ {label}
257
+ bind:value
258
+ onChange={handleFullEditorChange}
259
+ {config}
260
+ {description}
261
+ onClose={handleClose}
262
+ />
263
+ </div>
264
+ </Portal>
265
+ {/if}
263
266
  </div>
264
267
 
265
268
  <style>
266
- /* Keep only preview-specific styles */
267
- :global(.text-area-preview-main-container .group) {
268
- position: relative;
269
- isolation: isolate;
270
- }
271
-
272
- :global(.text-area-preview-main-container .group:hover) {
273
- border-color: hsl(var(--forest-green)) !important;
274
- }
275
-
276
-
277
- /* Heading styles matching tiptap editor */
278
- :global(.textarea-ic-preview-html h1.tiptap-heading) {
279
- font-size: 2em !important;
280
- font-weight: 600 !important;
281
- line-height: 1.2 !important;
282
- margin-top: 0 !important;
283
- margin-bottom: 0 !important;
284
- color: inherit !important;
285
- }
286
-
287
- :global(.textarea-ic-preview-html h2.tiptap-heading) {
288
- font-size: 1.5em !important;
289
- font-weight: 600 !important;
290
- line-height: 1.3 !important;
291
- margin-top: 0.4em !important;
292
- margin-bottom: 0.2em !important;
293
- color: inherit !important;
294
- }
295
-
296
- :global(.textarea-ic-preview-html h3.tiptap-heading) {
297
- font-size: 1.17em !important;
298
- font-weight: 600 !important;
299
- line-height: 1.3 !important;
300
- margin-top: 0.3em !important;
301
- margin-bottom: 0.2em !important;
302
- color: inherit !important;
303
- }
304
-
305
- :global(.textarea-ic-preview-html h4.tiptap-heading) {
306
- font-size: 1em !important;
307
- font-weight: 600 !important;
308
- line-height: 1.4 !important;
309
- margin-top: 0.2em !important;
310
- margin-bottom: 0.1em !important;
311
- color: inherit !important;
312
- }
313
-
314
- :global(.textarea-ic-preview-html) {
315
- display: -webkit-box;
316
- -webkit-box-orient: vertical;
317
- -webkit-line-clamp: 3;
318
- line-clamp: 3;
319
- overflow: hidden;
320
- }
321
-
322
- /* Color preservation */
323
- :global(.textarea-ic-preview-html [style*="color"]) {
324
- color: var(--color) !important;
325
- }
326
-
327
- /* Text formatting — {@html} children need :global; include b/i as well as strong/em/u */
328
- :global(.textarea-ic-preview-html :is(strong, b, [style*="font-weight"])) {
329
- font-weight: 700 !important;
330
- }
331
-
332
- :global(.textarea-ic-preview-html :is(em, i)) {
333
- font-style: italic !important;
334
- }
335
-
336
- :global(.textarea-ic-preview-html :is(u, [style*="text-decoration: underline"])) {
337
- text-decoration: underline !important;
338
- }
339
-
340
- :global(.textarea-ic-preview-html strong[style*="color"]),
341
- :global(.textarea-ic-preview-html em[style*="color"]),
342
- :global(.textarea-ic-preview-html u[style*="color"]) {
343
- color: var(--color) !important;
344
- }
345
-
346
- /* Add specific color inheritance for data-text-style */
347
- :global(.textarea-ic-preview-html [data-text-style*="color"]) {
348
- color: var(--color) !important;
349
- }
350
-
351
- /* Ensure all text elements can inherit colors */
352
- :global(.textarea-ic-preview-html *) {
353
- color: inherit;
354
- }
355
-
356
- /* Ensure paragraphs have no margins */
357
- :global(.textarea-ic-preview-html p) {
358
- margin-top: 0 !important;
359
- margin-bottom: 0 !important;
360
- }
361
-
362
- /* Ensure line-clamp ellipsis inherits color */
363
- :global(.line-clamp-3) {
364
- -webkit-box-orient: vertical;
365
- -webkit-line-clamp: 3;
366
- line-clamp: 3;
367
- display: -webkit-box;
368
- overflow: hidden;
369
- color: inherit;
370
- }
371
-
372
- /* Add scale animation */
373
- @keyframes scaleIn {
374
- from {
375
- transform: scale(0.95) translateZ(0);
376
- opacity: 0;
377
- }
378
- to {
379
- transform: scale(1) translateZ(0);
380
- opacity: 1;
381
- }
382
- }
383
-
384
- @keyframes fadeIn {
385
- from {
386
- opacity: 0;
387
- }
388
- to {
389
- opacity: 1;
390
- }
391
- }
392
-
393
- :global(.scale-in-animation) {
394
- animation: scaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
395
- transform-origin: center center;
396
- will-change: transform, opacity;
397
- backface-visibility: hidden;
398
- }
399
-
400
- :global(.fade-in-animation) {
401
- animation: fadeIn 0.15s ease-out;
402
- will-change: opacity;
403
- backface-visibility: hidden;
404
- }
405
-
406
- /* Add scale out animation */
407
- @keyframes scaleOut {
408
- 0% {
409
- transform: scale(1) translateZ(0);
410
- opacity: 1;
411
- }
412
- 100% {
413
- transform: scale(0.95) translateZ(0);
414
- opacity: 0;
415
- }
416
- }
417
-
418
- @keyframes fadeOut {
419
- 0% {
420
- opacity: 1;
421
- }
422
- 100% {
423
- opacity: 0;
424
- }
425
- }
426
-
427
- :global(.scale-out-animation) {
428
- animation: scaleOut 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
429
- transform-origin: center center;
430
- will-change: transform, opacity;
431
- backface-visibility: hidden;
432
- pointer-events: none;
433
- }
434
-
435
- :global(.fade-out-animation) {
436
- animation: fadeOut 0.15s ease-out forwards;
437
- will-change: opacity;
438
- backface-visibility: hidden;
439
- pointer-events: none;
440
- }
441
-
442
- /* Add a class to handle visibility at animation end */
443
- :global(.scale-out-animation[data-state="complete"]),
444
- :global(.fade-out-animation[data-state="complete"]) {
445
- visibility: hidden;
446
- }
447
- </style>
269
+ /* Keep only preview-specific styles */
270
+ :global(.text-area-preview-main-container .group) {
271
+ position: relative;
272
+ isolation: isolate;
273
+ }
274
+
275
+ /* Heading styles matching tiptap editor */
276
+ :global(.textarea-ic-preview-html h1.tiptap-heading) {
277
+ font-size: 2em !important;
278
+ font-weight: 600 !important;
279
+ line-height: 1.2 !important;
280
+ margin-top: 0 !important;
281
+ margin-bottom: 0 !important;
282
+ color: inherit !important;
283
+ }
284
+
285
+ :global(.textarea-ic-preview-html h2.tiptap-heading) {
286
+ font-size: 1.5em !important;
287
+ font-weight: 600 !important;
288
+ line-height: 1.3 !important;
289
+ margin-top: 0.4em !important;
290
+ margin-bottom: 0.2em !important;
291
+ color: inherit !important;
292
+ }
293
+
294
+ :global(.textarea-ic-preview-html h3.tiptap-heading) {
295
+ font-size: 1.17em !important;
296
+ font-weight: 600 !important;
297
+ line-height: 1.3 !important;
298
+ margin-top: 0.3em !important;
299
+ margin-bottom: 0.2em !important;
300
+ color: inherit !important;
301
+ }
302
+
303
+ :global(.textarea-ic-preview-html h4.tiptap-heading) {
304
+ font-size: 1em !important;
305
+ font-weight: 600 !important;
306
+ line-height: 1.4 !important;
307
+ margin-top: 0.2em !important;
308
+ margin-bottom: 0.1em !important;
309
+ color: inherit !important;
310
+ }
311
+
312
+ :global(.textarea-ic-preview-html) {
313
+ display: -webkit-box;
314
+ -webkit-box-orient: vertical;
315
+ -webkit-line-clamp: 3;
316
+ line-clamp: 3;
317
+ overflow: hidden;
318
+ }
319
+
320
+ /* Color preservation */
321
+ :global(.textarea-ic-preview-html [style*='color']) {
322
+ color: var(--color) !important;
323
+ }
324
+
325
+ /* Text formatting — {@html} children need :global; include b/i as well as strong/em/u */
326
+ :global(.textarea-ic-preview-html :is(strong, b, [style*='font-weight'])) {
327
+ font-weight: 700 !important;
328
+ }
329
+
330
+ :global(.textarea-ic-preview-html :is(em, i)) {
331
+ font-style: italic !important;
332
+ }
333
+
334
+ :global(.textarea-ic-preview-html :is(u, [style*='text-decoration: underline'])) {
335
+ text-decoration: underline !important;
336
+ }
337
+
338
+ :global(.textarea-ic-preview-html strong[style*='color']),
339
+ :global(.textarea-ic-preview-html em[style*='color']),
340
+ :global(.textarea-ic-preview-html u[style*='color']) {
341
+ color: var(--color) !important;
342
+ }
343
+
344
+ /* Add specific color inheritance for data-text-style */
345
+ :global(.textarea-ic-preview-html [data-text-style*='color']) {
346
+ color: var(--color) !important;
347
+ }
348
+
349
+ /* Ensure all text elements can inherit colors */
350
+ :global(.textarea-ic-preview-html *) {
351
+ color: inherit;
352
+ }
353
+
354
+ /* Ensure paragraphs have no margins */
355
+ :global(.textarea-ic-preview-html p) {
356
+ margin-top: 0 !important;
357
+ margin-bottom: 0 !important;
358
+ }
359
+
360
+ /* Ensure line-clamp ellipsis inherits color */
361
+ :global(.line-clamp-3) {
362
+ -webkit-box-orient: vertical;
363
+ -webkit-line-clamp: 3;
364
+ line-clamp: 3;
365
+ display: -webkit-box;
366
+ overflow: hidden;
367
+ color: inherit;
368
+ }
369
+
370
+ /* Add scale animation */
371
+ @keyframes scaleIn {
372
+ from {
373
+ transform: scale(0.95) translateZ(0);
374
+ opacity: 0;
375
+ }
376
+ to {
377
+ transform: scale(1) translateZ(0);
378
+ opacity: 1;
379
+ }
380
+ }
381
+
382
+ @keyframes fadeIn {
383
+ from {
384
+ opacity: 0;
385
+ }
386
+ to {
387
+ opacity: 1;
388
+ }
389
+ }
390
+
391
+ :global(.scale-in-animation) {
392
+ animation: scaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
393
+ transform-origin: center center;
394
+ will-change: transform, opacity;
395
+ backface-visibility: hidden;
396
+ }
397
+
398
+ :global(.fade-in-animation) {
399
+ animation: fadeIn 0.15s ease-out;
400
+ will-change: opacity;
401
+ backface-visibility: hidden;
402
+ }
403
+
404
+ /* Add scale out animation */
405
+ @keyframes scaleOut {
406
+ 0% {
407
+ transform: scale(1) translateZ(0);
408
+ opacity: 1;
409
+ }
410
+ 100% {
411
+ transform: scale(0.95) translateZ(0);
412
+ opacity: 0;
413
+ }
414
+ }
415
+
416
+ @keyframes fadeOut {
417
+ 0% {
418
+ opacity: 1;
419
+ }
420
+ 100% {
421
+ opacity: 0;
422
+ }
423
+ }
424
+
425
+ :global(.scale-out-animation) {
426
+ animation: scaleOut 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
427
+ transform-origin: center center;
428
+ will-change: transform, opacity;
429
+ backface-visibility: hidden;
430
+ pointer-events: none;
431
+ }
432
+
433
+ :global(.fade-out-animation) {
434
+ animation: fadeOut 0.15s ease-out forwards;
435
+ will-change: opacity;
436
+ backface-visibility: hidden;
437
+ pointer-events: none;
438
+ }
439
+
440
+ /* Add a class to handle visibility at animation end */
441
+ :global(.scale-out-animation[data-state='complete']),
442
+ :global(.fade-out-animation[data-state='complete']) {
443
+ visibility: hidden;
444
+ }
445
+ </style>