@widgetic/editor 4.1.17 → 4.1.19

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 (112) hide show
  1. package/dist/components/PreviewChromeControls.svelte +2 -2
  2. package/dist/components/WidgetPreview.svelte +79 -16
  3. package/dist/components/editors/CompositionEditorApp.svelte +71 -35
  4. package/dist/components/editors/CompositionEditorApp.svelte.d.ts +3 -1
  5. package/dist/components/editors/ContentTabBulkDrop.svelte +268 -0
  6. package/dist/components/editors/ContentTabBulkDrop.svelte.d.ts +37 -0
  7. package/dist/components/editors/EmbedAssistantPanel.svelte +303 -0
  8. package/dist/components/editors/EmbedAssistantPanel.svelte.d.ts +29 -0
  9. package/dist/components/editors/EmbedEditor.svelte +221 -15
  10. package/dist/components/editors/EmbedEditor.svelte.d.ts +31 -3
  11. package/dist/components/editors/PropsEditor.svelte +326 -37
  12. package/dist/components/editors/PropsEditor.svelte.d.ts +11 -0
  13. package/dist/components/editors/propsEditorContentStateFlatten.d.ts +12 -0
  14. package/dist/components/editors/propsEditorContentStateFlatten.js +40 -0
  15. package/dist/components/ic/AngleInputController.svelte +9 -5
  16. package/dist/components/ic/BrowserInputController.svelte +208 -132
  17. package/dist/components/ic/BrowserInputController.svelte.d.ts +2 -0
  18. package/dist/components/ic/CheckboxInputController.svelte +11 -0
  19. package/dist/components/ic/ColorPickerInputController.svelte +122 -49
  20. package/dist/components/ic/DatePickerInputController.svelte +23 -13
  21. package/dist/components/ic/FixedPositionInputController.svelte +1 -1
  22. package/dist/components/ic/FontInputController.svelte +48 -47
  23. package/dist/components/ic/InputControllerHeader.svelte +5 -4
  24. package/dist/components/ic/KnowledgeDocumentsInputController.svelte +20 -7
  25. package/dist/components/ic/NumberControls.svelte +163 -35
  26. package/dist/components/ic/PositionInputController.svelte +24 -15
  27. package/dist/components/ic/RadioGroupInputController.svelte +11 -0
  28. package/dist/components/ic/RangeCalendarInputController.svelte +73 -28
  29. package/dist/components/ic/RoundedCornersInputController.svelte +2 -2
  30. package/dist/components/ic/SliderInputController.svelte +11 -4
  31. package/dist/components/ic/TextAreaInputController.svelte +620 -327
  32. package/dist/components/ic/TextAreaPreviewInputController.svelte +53 -64
  33. package/dist/components/ic/TextInputController.svelte +15 -2
  34. package/dist/components/ic/TimeInputController.svelte +1 -1
  35. package/dist/components/ic/VectorInputController.svelte +152 -20
  36. package/dist/components/ic/numberControlsValueArea.d.ts +29 -0
  37. package/dist/components/ic/numberControlsValueArea.js +51 -0
  38. package/dist/components/ic/optionGroupCardPointerDown.d.ts +9 -0
  39. package/dist/components/ic/optionGroupCardPointerDown.js +20 -0
  40. package/dist/components/ic/shared/DropdownChevron.svelte +2 -2
  41. package/dist/components/ic/shared/DropdownChevron.svelte.d.ts +1 -1
  42. package/dist/components/ic/shared/EditorFileBrowserOverlay.svelte +174 -0
  43. package/dist/components/ic/shared/EditorFileBrowserOverlay.svelte.d.ts +30 -0
  44. package/dist/components/ic/shared/EditorSelectedFilePreviewOverlay.svelte +34 -0
  45. package/dist/components/ic/shared/EditorSelectedFilePreviewOverlay.svelte.d.ts +24 -0
  46. package/dist/components/ic/shared/ItemGrid.svelte +2 -2
  47. package/dist/components/ic/shared/RecentItemsSection.svelte +6 -6
  48. package/dist/components/ic/shared/editableFieldClasses.d.ts +15 -0
  49. package/dist/components/ic/shared/editableFieldClasses.js +15 -0
  50. package/dist/components/ic/shared/fileBrowserOverlayEscape.d.ts +29 -0
  51. package/dist/components/ic/shared/fileBrowserOverlayEscape.js +21 -0
  52. package/dist/components/ic/shared/index.d.ts +1 -0
  53. package/dist/components/ic/shared/index.js +1 -0
  54. package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte +41 -9
  55. package/dist/composition/compositionApi.d.ts +16 -0
  56. package/dist/composition/compositionApi.js +16 -1
  57. package/dist/composition/compositionEditorController.d.ts +46 -0
  58. package/dist/composition/compositionEditorController.js +277 -5
  59. package/dist/composition/compositionEditorSchemaCache.d.ts +35 -0
  60. package/dist/composition/compositionEditorSchemaCache.js +82 -0
  61. package/dist/contentBulkDrop/applyContentPlan.d.ts +18 -0
  62. package/dist/contentBulkDrop/applyContentPlan.js +55 -0
  63. package/dist/contentBulkDrop/bulkDropSummary.d.ts +4 -0
  64. package/dist/contentBulkDrop/bulkDropSummary.js +12 -0
  65. package/dist/contentBulkDrop/dragIntent.d.ts +7 -0
  66. package/dist/contentBulkDrop/dragIntent.js +24 -0
  67. package/dist/contentBulkDrop/filterDropFiles.d.ts +2 -0
  68. package/dist/contentBulkDrop/filterDropFiles.js +21 -0
  69. package/dist/contentBulkDrop/formatFileSize.d.ts +2 -0
  70. package/dist/contentBulkDrop/formatFileSize.js +13 -0
  71. package/dist/contentBulkDrop/types.d.ts +34 -0
  72. package/dist/contentBulkDrop/types.js +1 -0
  73. package/dist/contentBulkDrop/uploadQueue.d.ts +41 -0
  74. package/dist/contentBulkDrop/uploadQueue.js +114 -0
  75. package/dist/drafts/compositionDraft.d.ts +65 -0
  76. package/dist/drafts/compositionDraft.js +136 -0
  77. package/dist/drafts/compositionEditorViewState.d.ts +9 -0
  78. package/dist/drafts/compositionEditorViewState.js +33 -0
  79. package/dist/drafts/draftJournal.d.ts +59 -0
  80. package/dist/drafts/draftJournal.js +261 -0
  81. package/dist/embed/__fixtures__/gatewayGeneratedEmbedCodes.json +25 -0
  82. package/dist/embed/__fixtures__/generatedEmbedCodes.json +320 -0
  83. package/dist/embed/parseCompositionEmbedCode.d.ts +21 -0
  84. package/dist/embed/parseCompositionEmbedCode.js +376 -0
  85. package/dist/embedAssistant/embedAssistantEvents.d.ts +22 -0
  86. package/dist/embedAssistant/embedAssistantEvents.js +39 -0
  87. package/dist/embedAssistant/embedAssistantStream.d.ts +30 -0
  88. package/dist/embedAssistant/embedAssistantStream.js +125 -0
  89. package/dist/embedAssistant/highlightTiming.d.ts +1 -0
  90. package/dist/embedAssistant/highlightTiming.js +6 -0
  91. package/dist/embedAssistant/types.d.ts +27 -0
  92. package/dist/embedAssistant/types.js +1 -0
  93. package/dist/i18n/labels.js +8 -4
  94. package/dist/i18n/language.d.ts +297 -3
  95. package/dist/i18n/messages.d.ts +38 -1
  96. package/dist/i18n/messages.js +40 -1
  97. package/dist/i18n/translate.d.ts +1 -1
  98. package/dist/index.d.ts +3 -1
  99. package/dist/index.js +2 -0
  100. package/dist/utils/FontManager.d.ts +2 -0
  101. package/dist/utils/FontManager.js +16 -1
  102. package/dist/utils/angleMath.d.ts +2 -0
  103. package/dist/utils/angleMath.js +6 -0
  104. package/dist/utils/isEditableEventTarget.d.ts +5 -0
  105. package/dist/utils/isEditableEventTarget.js +25 -0
  106. package/dist/utils/linkUrlValidation.d.ts +17 -0
  107. package/dist/utils/linkUrlValidation.js +120 -0
  108. package/dist/utils/mediaFileValue.d.ts +12 -0
  109. package/dist/utils/mediaFileValue.js +24 -0
  110. package/dist/utils/placeRichTextCaretAtDocumentEnd.d.ts +11 -0
  111. package/dist/utils/placeRichTextCaretAtDocumentEnd.js +26 -0
  112. package/package.json +6 -6
@@ -0,0 +1,25 @@
1
+ const EDITABLE_SELECTOR = 'input, textarea, select, option, [contenteditable]:not([contenteditable="false"]), [role="textbox"], [role="combobox"], [role="searchbox"]';
2
+ function elementIsEditable(element) {
3
+ if (!element || typeof element !== 'object')
4
+ return false;
5
+ const htmlElement = element;
6
+ if (htmlElement.isContentEditable)
7
+ return true;
8
+ const contentEditable = htmlElement.getAttribute?.('contenteditable');
9
+ if (contentEditable !== null && contentEditable !== undefined && contentEditable !== 'false')
10
+ return true;
11
+ return typeof htmlElement.matches === 'function' && htmlElement.matches(EDITABLE_SELECTOR);
12
+ }
13
+ /**
14
+ * True when a keyboard event originated from (or should be treated as) typing in an editable control,
15
+ * including fields inside shadow roots and portaled popovers (composedPath).
16
+ */
17
+ export function isEditableEventTarget(event) {
18
+ for (const node of event.composedPath()) {
19
+ if (elementIsEditable(node))
20
+ return true;
21
+ }
22
+ if (elementIsEditable(event.target))
23
+ return true;
24
+ return elementIsEditable(typeof document !== 'undefined' ? document.activeElement : null);
25
+ }
@@ -0,0 +1,17 @@
1
+ /** The words of the editor that explain why a link URL was not accepted. */
2
+ export type LinkUrlMessageKey = 'editor.textArea.linkUrlEmpty' | 'editor.textArea.linkUrlInvalid';
3
+ /**
4
+ * Result of validating a URL typed into the rich-text link popover: `normalizedHref` is set when `ok`, `messageKey` when
5
+ * not. One object type, not a union of two: this project does not use strict null checks, and without them TypeScript
6
+ * does not narrow a union on a boolean `ok`.
7
+ */
8
+ export interface LinkUrlValidationResult {
9
+ ok: boolean;
10
+ normalizedHref?: string;
11
+ messageKey?: LinkUrlMessageKey;
12
+ }
13
+ /**
14
+ * Normalizes and validates a link URL for the rich text editor.
15
+ * Empty input is invalid unless the caller treats empty as "remove link" on apply.
16
+ */
17
+ export declare function validateLinkUrl(rawInput: string): LinkUrlValidationResult;
@@ -0,0 +1,120 @@
1
+ const BLOCKED_SCHEME_PATTERN = /^\s*(javascript|data|vbscript):/i;
2
+ const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
3
+ const IPV4_PATTERN = /^(?:\d{1,3}\.){3}\d{1,3}$/;
4
+ const LABEL_PATTERN = /^(?:[\p{L}\p{N}]|xn--)(?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?$/u;
5
+ function rejectInvalid() {
6
+ return { ok: false, messageKey: 'editor.textArea.linkUrlInvalid' };
7
+ }
8
+ function isValidIpv4(host) {
9
+ if (!IPV4_PATTERN.test(host))
10
+ return false;
11
+ return host.split('.').every((octet) => {
12
+ const value = Number(octet);
13
+ return value >= 0 && value <= 255 && String(value) === octet;
14
+ });
15
+ }
16
+ function isValidDottedHost(hostname) {
17
+ if (!hostname || hostname.includes('..') || hostname.startsWith('.') || hostname.endsWith('.')) {
18
+ return false;
19
+ }
20
+ const labels = hostname.split('.');
21
+ if (labels.length < 2)
22
+ return false;
23
+ for (const label of labels) {
24
+ if (!label || label.startsWith('-') || label.endsWith('-'))
25
+ return false;
26
+ if (!LABEL_PATTERN.test(label))
27
+ return false;
28
+ }
29
+ const topLevelLabel = labels[labels.length - 1];
30
+ if (topLevelLabel.startsWith('xn--'))
31
+ return true;
32
+ if (!/[\p{L}]/u.test(topLevelLabel) || topLevelLabel.length < 2)
33
+ return false;
34
+ return true;
35
+ }
36
+ function isValidWebHostname(hostname) {
37
+ const lower = hostname.toLowerCase();
38
+ if (lower === 'localhost')
39
+ return true;
40
+ if (hostname.startsWith('[') && hostname.endsWith(']'))
41
+ return hostname.length > 2;
42
+ if (isValidIpv4(hostname))
43
+ return true;
44
+ return isValidDottedHost(hostname);
45
+ }
46
+ function isPlausibleMailtoHref(href) {
47
+ const address = href
48
+ .replace(/^mailto:/i, '')
49
+ .split('?')[0]
50
+ .trim();
51
+ return EMAIL_PATTERN.test(address);
52
+ }
53
+ function isPlausibleTelHref(href) {
54
+ try {
55
+ const parsed = new URL(href);
56
+ const digits = parsed.pathname.replace(/[\s\-().]/g, '');
57
+ return digits.length >= 3 && /^\+?\d+$/.test(digits);
58
+ }
59
+ catch {
60
+ const digits = href.replace(/^tel:/i, '').replace(/[\s\-().]/g, '');
61
+ return digits.length >= 3 && /^\+?\d+$/.test(digits);
62
+ }
63
+ }
64
+ function validateWebUrl(parsed) {
65
+ if (/\s/.test(parsed.pathname + parsed.search + parsed.hash))
66
+ return rejectInvalid();
67
+ if (!isValidWebHostname(parsed.hostname))
68
+ return rejectInvalid();
69
+ return { ok: true, normalizedHref: parsed.href };
70
+ }
71
+ /**
72
+ * Normalizes and validates a link URL for the rich text editor.
73
+ * Empty input is invalid unless the caller treats empty as "remove link" on apply.
74
+ */
75
+ export function validateLinkUrl(rawInput) {
76
+ const trimmed = rawInput.trim();
77
+ if (!trimmed) {
78
+ return { ok: false, messageKey: 'editor.textArea.linkUrlEmpty' };
79
+ }
80
+ if (BLOCKED_SCHEME_PATTERN.test(trimmed)) {
81
+ return rejectInvalid();
82
+ }
83
+ const hasExplicitScheme = /^[a-z][a-z0-9+.-]*:/i.test(trimmed);
84
+ const isTelScheme = /^tel:/i.test(trimmed);
85
+ const isMailtoScheme = /^mailto:/i.test(trimmed);
86
+ if (!isTelScheme && /\s/.test(trimmed)) {
87
+ return rejectInvalid();
88
+ }
89
+ let candidate = trimmed;
90
+ if (isMailtoScheme || isTelScheme) {
91
+ candidate = trimmed;
92
+ }
93
+ else if (EMAIL_PATTERN.test(trimmed)) {
94
+ candidate = `mailto:${trimmed}`;
95
+ }
96
+ else if (!hasExplicitScheme) {
97
+ candidate = `https://${trimmed}`;
98
+ }
99
+ try {
100
+ const parsed = new URL(candidate);
101
+ const scheme = parsed.protocol.replace(/:$/, '').toLowerCase();
102
+ if (!['http', 'https', 'mailto', 'tel'].includes(scheme)) {
103
+ return rejectInvalid();
104
+ }
105
+ if (scheme === 'mailto') {
106
+ return isPlausibleMailtoHref(parsed.href)
107
+ ? { ok: true, normalizedHref: parsed.href }
108
+ : rejectInvalid();
109
+ }
110
+ if (scheme === 'tel') {
111
+ return isPlausibleTelHref(parsed.href)
112
+ ? { ok: true, normalizedHref: parsed.href }
113
+ : rejectInvalid();
114
+ }
115
+ return validateWebUrl(parsed);
116
+ }
117
+ catch {
118
+ return rejectInvalid();
119
+ }
120
+ }
@@ -0,0 +1,12 @@
1
+ /** Browser input value shape persisted in editor state. */
2
+ export type BrowserFileValue = {
3
+ id: string;
4
+ file: string;
5
+ url: string;
6
+ hash?: string;
7
+ thumbnail?: string;
8
+ mimeType?: string;
9
+ };
10
+ export declare function isBrowserFileValue(raw: unknown): raw is BrowserFileValue;
11
+ /** Keep the full file reference when the parent echoes a browser field back (not just `url`). */
12
+ export declare function hydrateBrowserFileValue(raw: unknown): string | BrowserFileValue | '';
@@ -0,0 +1,24 @@
1
+ export function isBrowserFileValue(raw) {
2
+ if (!raw || typeof raw !== 'object')
3
+ return false;
4
+ const o = raw;
5
+ return typeof o.url === 'string' && o.url.length > 0;
6
+ }
7
+ /** Keep the full file reference when the parent echoes a browser field back (not just `url`). */
8
+ export function hydrateBrowserFileValue(raw) {
9
+ if (raw === undefined || raw === null || raw === '')
10
+ return '';
11
+ if (typeof raw === 'string')
12
+ return raw;
13
+ if (isBrowserFileValue(raw)) {
14
+ return {
15
+ id: String(raw.id ?? raw.url),
16
+ file: String(raw.file ?? raw.url.split('/').pop() ?? ''),
17
+ url: raw.url,
18
+ hash: raw.hash,
19
+ thumbnail: raw.thumbnail,
20
+ mimeType: raw.mimeType
21
+ };
22
+ }
23
+ return raw;
24
+ }
@@ -0,0 +1,11 @@
1
+ import type { Editor } from '@tiptap/core';
2
+ /**
3
+ * ProseMirror document position for a collapsed caret at the end of the document text.
4
+ * The document `content.size` is one past the last valid caret position.
5
+ */
6
+ export declare function collapsedCaretPositionAtDocumentEnd(documentContentSize: number): number;
7
+ /**
8
+ * Focus the rich text editor and place the caret after the last character of the last block,
9
+ * scrolling the editor's own scroller so the caret stays visible.
10
+ */
11
+ export declare function placeRichTextCaretAtDocumentEnd(editor: Editor | null | undefined): boolean;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * ProseMirror document position for a collapsed caret at the end of the document text.
3
+ * The document `content.size` is one past the last valid caret position.
4
+ */
5
+ export function collapsedCaretPositionAtDocumentEnd(documentContentSize) {
6
+ if (!Number.isFinite(documentContentSize) || documentContentSize < 1) {
7
+ return 1;
8
+ }
9
+ return Math.max(1, documentContentSize - 1);
10
+ }
11
+ /**
12
+ * Focus the rich text editor and place the caret after the last character of the last block,
13
+ * scrolling the editor's own scroller so the caret stays visible.
14
+ */
15
+ export function placeRichTextCaretAtDocumentEnd(editor) {
16
+ if (!editor || editor.isDestroyed) {
17
+ return false;
18
+ }
19
+ try {
20
+ return editor.chain().focus('end', { scrollIntoView: true }).run();
21
+ }
22
+ catch (error) {
23
+ console.error('[TextAreaInputController] Could not place caret at document end:', error);
24
+ return false;
25
+ }
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widgetic/editor",
3
- "version": "4.1.17",
3
+ "version": "4.1.19",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -52,8 +52,8 @@
52
52
  "peerDependencies": {
53
53
  "@widgetic/api-sdk": "*",
54
54
  "@widgetic/cache-layer": "^0.1.1",
55
- "@widgetic/design-system": ">=0.5.23",
56
- "@widgetic/file-browser": "^0.5.16",
55
+ "@widgetic/design-system": ">=0.5.28",
56
+ "@widgetic/file-browser": "^0.5.41",
57
57
  "svelte": "^5.27.0"
58
58
  },
59
59
  "devDependencies": {
@@ -68,9 +68,9 @@
68
68
  "@types/node": "26.6.2",
69
69
  "@widgetic/api-sdk": "^2.0.1",
70
70
  "@widgetic/cache-layer": "^0.1.1",
71
- "@widgetic/design-system": "^0.5.23",
71
+ "@widgetic/design-system": "^0.5.28",
72
72
  "@widgetic/dev-tools": "^0.2.0",
73
- "@widgetic/file-browser": "^0.5.16",
73
+ "@widgetic/file-browser": "^0.5.41",
74
74
  "eslint": "^9.0.0",
75
75
  "eslint-config-prettier": "^9.1.0",
76
76
  "eslint-plugin-svelte": "^2.36.0",
@@ -116,7 +116,7 @@
116
116
  "@tiptap/extension-underline": "^2.9.1",
117
117
  "@tiptap/pm": "^2.9.1",
118
118
  "@tiptap/starter-kit": "^2.9.1",
119
- "@widgetic/design-system": ">=0.5.23",
119
+ "@widgetic/design-system": ">=0.5.28",
120
120
  "bits-ui": "^2.16.3",
121
121
  "clsx": "^2.1.1",
122
122
  "dotenv": "^16.4.5",