@syntrologie/adapt-content 2.8.0-canary.62 → 2.8.0-canary.621

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 (115) hide show
  1. package/dist/chunk-PZ5AY32C.js +10 -0
  2. package/dist/chunk-PZ5AY32C.js.map +7 -0
  3. package/dist/runtime.d.ts +8 -1
  4. package/dist/runtime.d.ts.map +1 -1
  5. package/dist/runtime.js +503 -348
  6. package/dist/runtime.js.map +7 -0
  7. package/dist/sanitizer.d.ts.map +1 -1
  8. package/dist/schema.d.ts +62 -22
  9. package/dist/schema.d.ts.map +1 -1
  10. package/dist/schema.js +4777 -62
  11. package/dist/schema.js.map +7 -0
  12. package/dist/types.d.ts +12 -0
  13. package/dist/types.d.ts.map +1 -1
  14. package/package.json +2 -23
  15. package/dist/cdn.d.ts +0 -35
  16. package/dist/cdn.d.ts.map +0 -1
  17. package/dist/cdn.js +0 -39
  18. package/dist/components/AnchorPicker.d.ts +0 -8
  19. package/dist/components/AnchorPicker.d.ts.map +0 -1
  20. package/dist/components/AnchorPicker.js +0 -6
  21. package/dist/content-editor-state.d.ts +0 -45
  22. package/dist/content-editor-state.d.ts.map +0 -1
  23. package/dist/content-editor-state.js +0 -123
  24. package/dist/content-editor-ui.d.ts +0 -26
  25. package/dist/content-editor-ui.d.ts.map +0 -1
  26. package/dist/content-editor-ui.js +0 -291
  27. package/dist/editor.d.ts +0 -9
  28. package/dist/editor.d.ts.map +0 -1
  29. package/dist/editor.js +0 -8
  30. package/dist/reconciliation-guard.js +0 -80
  31. package/dist/sanitizer.js +0 -95
  32. package/dist/summarize.js +0 -88
  33. package/dist/types.js +0 -7
  34. package/dist/utils/selectorGenerator.d.ts +0 -6
  35. package/dist/utils/selectorGenerator.d.ts.map +0 -1
  36. package/dist/utils/selectorGenerator.js +0 -4
  37. package/node_modules/@syntrologie/shared-editor-ui/dist/cn.d.ts +0 -2
  38. package/node_modules/@syntrologie/shared-editor-ui/dist/cn.d.ts.map +0 -1
  39. package/node_modules/@syntrologie/shared-editor-ui/dist/cn.js +0 -3
  40. package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPicker.d.ts +0 -34
  41. package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPicker.d.ts.map +0 -1
  42. package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPicker.js +0 -158
  43. package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggle.d.ts +0 -7
  44. package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggle.d.ts.map +0 -1
  45. package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggle.js +0 -9
  46. package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLine.d.ts +0 -23
  47. package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLine.d.ts.map +0 -1
  48. package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLine.js +0 -40
  49. package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadge.d.ts +0 -7
  50. package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadge.d.ts.map +0 -1
  51. package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadge.js +0 -22
  52. package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSection.d.ts +0 -8
  53. package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSection.d.ts.map +0 -1
  54. package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSection.js +0 -9
  55. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButton.d.ts +0 -7
  56. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButton.d.ts.map +0 -1
  57. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButton.js +0 -4
  58. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBody.d.ts +0 -7
  59. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBody.d.ts.map +0 -1
  60. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBody.js +0 -4
  61. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCard.d.ts +0 -13
  62. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCard.d.ts.map +0 -1
  63. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCard.js +0 -15
  64. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooter.d.ts +0 -7
  65. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooter.d.ts.map +0 -1
  66. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooter.js +0 -4
  67. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeader.d.ts +0 -9
  68. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeader.d.ts.map +0 -1
  69. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeader.js +0 -4
  70. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInput.d.ts +0 -8
  71. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInput.d.ts.map +0 -1
  72. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInput.js +0 -8
  73. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayout.d.ts +0 -7
  74. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayout.d.ts.map +0 -1
  75. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayout.js +0 -4
  76. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShell.d.ts +0 -25
  77. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShell.d.ts.map +0 -1
  78. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShell.js +0 -379
  79. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelect.d.ts +0 -8
  80. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelect.d.ts.map +0 -1
  81. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelect.js +0 -8
  82. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextarea.d.ts +0 -8
  83. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextarea.d.ts.map +0 -1
  84. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextarea.js +0 -17
  85. package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlight.d.ts +0 -32
  86. package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlight.d.ts.map +0 -1
  87. package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlight.js +0 -85
  88. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyState.d.ts +0 -6
  89. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyState.d.ts.map +0 -1
  90. package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyState.js +0 -4
  91. package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeader.d.ts +0 -8
  92. package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeader.d.ts.map +0 -1
  93. package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeader.js +0 -5
  94. package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourney.d.ts +0 -12
  95. package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourney.d.ts.map +0 -1
  96. package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourney.js +0 -40
  97. package/node_modules/@syntrologie/shared-editor-ui/dist/formatConditionLabel.d.ts +0 -26
  98. package/node_modules/@syntrologie/shared-editor-ui/dist/formatConditionLabel.d.ts.map +0 -1
  99. package/node_modules/@syntrologie/shared-editor-ui/dist/formatConditionLabel.js +0 -202
  100. package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useElementRect.d.ts +0 -8
  101. package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useElementRect.d.ts.map +0 -1
  102. package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useElementRect.js +0 -46
  103. package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useTriggerWhenStatus.d.ts +0 -24
  104. package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useTriggerWhenStatus.d.ts.map +0 -1
  105. package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useTriggerWhenStatus.js +0 -86
  106. package/node_modules/@syntrologie/shared-editor-ui/dist/index.d.ts +0 -34
  107. package/node_modules/@syntrologie/shared-editor-ui/dist/index.d.ts.map +0 -1
  108. package/node_modules/@syntrologie/shared-editor-ui/dist/index.js +0 -25
  109. package/node_modules/@syntrologie/shared-editor-ui/dist/utils/elementChainRecommender.d.ts +0 -37
  110. package/node_modules/@syntrologie/shared-editor-ui/dist/utils/elementChainRecommender.d.ts.map +0 -1
  111. package/node_modules/@syntrologie/shared-editor-ui/dist/utils/elementChainRecommender.js +0 -52
  112. package/node_modules/@syntrologie/shared-editor-ui/dist/utils/selectorGenerator.d.ts +0 -22
  113. package/node_modules/@syntrologie/shared-editor-ui/dist/utils/selectorGenerator.d.ts.map +0 -1
  114. package/node_modules/@syntrologie/shared-editor-ui/dist/utils/selectorGenerator.js +0 -143
  115. package/node_modules/@syntrologie/shared-editor-ui/package.json +0 -47
@@ -1,291 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- /**
3
- * Adaptive Content - Editor UI Component
4
- *
5
- * Main editor component with tab switching, item selection, form inputs,
6
- * save/publish, and highlight on page.
7
- */
8
- import { DetectionBadge, DismissedSection, EditorBody, EditorCard, EditorFooter, EditorHeader, EditorInput, EditorLayout, EditorSelect, EditorTextarea, EmptyState, GroupHeader, } from '@syntrologie/shared-editor-ui';
9
- import { useCallback, useEffect, useRef, useState } from 'react';
10
- import { AnchorPicker } from './components/AnchorPicker';
11
- import { filterConfig, flattenItems, parseItemKey, resolveAnchorRoute, resolveAnchorSelector, SECTION_ICON_MAP, savePendingHighlight, useAnchorDetection, } from './content-editor-state';
12
- // ============================================================================
13
- // Section Icon Component
14
- // ============================================================================
15
- /** Renders the appropriate Lucide icon for a section type */
16
- function SectionIcon({ section, className }) {
17
- const IconComponent = SECTION_ICON_MAP[section];
18
- return _jsx(IconComponent, { size: 16, className: className });
19
- }
20
- // ============================================================================
21
- // ContentEditor Component
22
- // ============================================================================
23
- export function ContentEditor({ config, onChange, editor }) {
24
- const typedConfig = config;
25
- const [dismissedKeys, setDismissedKeys] = useState(() => editor.getDismissedKeys?.() ?? new Set());
26
- const [editingKey, setEditingKey] = useState(null);
27
- const [, setPreviewMode] = useState('after');
28
- // Sync dismissed keys back to navigation context on every change
29
- useEffect(() => {
30
- editor.setDismissedKeys?.(dismissedKeys);
31
- }, [dismissedKeys, editor]);
32
- // Create mode state
33
- const [createMode, setCreateMode] = useState(null);
34
- const [createAnchorId, setCreateAnchorId] = useState('');
35
- const [createText, setCreateText] = useState('');
36
- const [createDescription, setCreateDescription] = useState('');
37
- // React to global before/after toggle from the panel
38
- // biome-ignore lint/correctness/useExhaustiveDependencies: intentionally omitted — adding config/typedConfig/previewConfig would cause infinite re-renders since previewConfig triggers state updates
39
- useEffect(() => {
40
- const mode = editor.previewMode;
41
- if (!mode)
42
- return;
43
- if (mode === 'before') {
44
- // Remove all content changes — push a config with every item filtered out
45
- const allKeys = new Set(flattenItems(typedConfig).map((item) => item.key));
46
- const empty = filterConfig(typedConfig, allKeys);
47
- editor.previewConfig(empty);
48
- }
49
- else {
50
- // Restore the full config
51
- editor.previewConfig(config);
52
- }
53
- }, [editor.previewMode]);
54
- // Consume initialEditKey from accordion navigation on mount
55
- const initialConsumed = useRef(false);
56
- useEffect(() => {
57
- if (editor.initialEditKey != null && !initialConsumed.current) {
58
- initialConsumed.current = true;
59
- const allFlat = flattenItems(typedConfig);
60
- const targetIdx = Number(editor.initialEditKey);
61
- if (targetIdx >= 0 && targetIdx < allFlat.length) {
62
- const target = allFlat[targetIdx];
63
- setEditingKey(target.key);
64
- if (target.anchorId) {
65
- editor.highlightElement(target.anchorId);
66
- }
67
- }
68
- editor.clearInitialState?.();
69
- }
70
- else if (editor.initialCreate && !initialConsumed.current) {
71
- initialConsumed.current = true;
72
- setCreateMode('form');
73
- editor.clearInitialState?.();
74
- }
75
- }, [editor, typedConfig]);
76
- const allItems = flattenItems(typedConfig);
77
- const activeItems = allItems.filter((item) => !dismissedKeys.has(item.key));
78
- const dismissedItems = allItems.filter((item) => dismissedKeys.has(item.key));
79
- const totalChanges = activeItems.length;
80
- const [, setHoveredKey] = useState(null);
81
- const detectionMap = useAnchorDetection(allItems);
82
- const foundCount = activeItems.filter((item) => detectionMap.get(item.key)?.found).length;
83
- const handleDismiss = useCallback((key) => {
84
- setDismissedKeys((prev) => {
85
- const next = new Set(prev);
86
- next.add(key);
87
- return next;
88
- });
89
- if (editingKey === key)
90
- setEditingKey(null);
91
- }, [editingKey]);
92
- const handleRestore = useCallback((key) => {
93
- setDismissedKeys((prev) => {
94
- const next = new Set(prev);
95
- next.delete(key);
96
- return next;
97
- });
98
- }, []);
99
- const handleCardClick = useCallback((item) => {
100
- if (item.anchorId) {
101
- editor.highlightElement(item.anchorId);
102
- }
103
- setEditingKey(item.key);
104
- }, [editor]);
105
- const handleBackToList = useCallback(() => {
106
- setEditingKey(null);
107
- setPreviewMode('after');
108
- editor.previewConfig(config);
109
- editor.clearHighlight();
110
- }, [editor, config]);
111
- // Register back handler in panel header when editing
112
- useEffect(() => {
113
- editor.setBackHandler?.(editingKey !== null ? handleBackToList : null);
114
- return () => editor.setBackHandler?.(null);
115
- }, [editingKey, handleBackToList, editor]);
116
- const handleFieldChange = useCallback((section, index, field, value) => {
117
- const arr = (typedConfig[section] || []).slice();
118
- const item = { ...arr[index] };
119
- item[field] = value;
120
- arr[index] = item;
121
- const updated = { ...typedConfig, [section]: arr };
122
- onChange(updated);
123
- editor.setDirty(true);
124
- }, [typedConfig, onChange, editor]);
125
- const handlePublish = useCallback(() => {
126
- // Filter dismissed items before publishing
127
- if (dismissedKeys.size > 0) {
128
- const filtered = filterConfig(typedConfig, dismissedKeys);
129
- onChange(filtered);
130
- }
131
- editor.publish();
132
- }, [dismissedKeys, typedConfig, onChange, editor]);
133
- const handleBadgeClick = useCallback(async (item) => {
134
- const detection = detectionMap.get(item.key);
135
- if (detection?.found && item.anchorId) {
136
- editor.highlightElement(item.anchorId);
137
- }
138
- else {
139
- const route = resolveAnchorRoute(item.rawAnchorId);
140
- if (route) {
141
- if (item.anchorId)
142
- savePendingHighlight(item.anchorId);
143
- await editor.navigateTo(route);
144
- if (item.anchorId)
145
- editor.highlightElement(item.anchorId);
146
- }
147
- else if (item.anchorId) {
148
- editor.highlightElement(item.anchorId);
149
- }
150
- }
151
- }, [editor, detectionMap]);
152
- const handleCardHover = useCallback((item) => {
153
- setHoveredKey(item.key);
154
- if (item.anchorId) {
155
- editor.highlightElement(item.anchorId);
156
- }
157
- }, [editor]);
158
- const handleCardLeave = useCallback(() => {
159
- setHoveredKey(null);
160
- editor.clearHighlight();
161
- }, [editor]);
162
- // ---- Create flow handlers ----
163
- const handleStartCreate = useCallback(() => {
164
- setEditingKey(null);
165
- editor.clearHighlight();
166
- setCreateAnchorId('');
167
- setCreateText('');
168
- setCreateDescription('');
169
- setCreateMode('form');
170
- }, [editor]);
171
- const handleElementPicked = useCallback((picked) => {
172
- setCreateAnchorId(picked.selector);
173
- setCreateDescription(picked.description);
174
- // Pre-fill with the element's current text content
175
- const text = picked.element.textContent?.trim() || '';
176
- setCreateText(text);
177
- setCreateMode('form');
178
- editor.highlightElement(picked.selector);
179
- }, [editor]);
180
- const handleCancelCreate = useCallback(() => {
181
- setCreateMode(null);
182
- setCreateAnchorId('');
183
- setCreateText('');
184
- setCreateDescription('');
185
- editor.clearHighlight();
186
- }, [editor]);
187
- const handleSaveCreate = useCallback(() => {
188
- if (!createAnchorId)
189
- return;
190
- // Add a new textReplacement to the config
191
- const existing = typedConfig.textReplacements || [];
192
- const newItem = {
193
- anchorId: { selector: createAnchorId, route: '**' },
194
- text: createText,
195
- summary: `Set text on ${createAnchorId}`,
196
- };
197
- const updated = {
198
- ...typedConfig,
199
- textReplacements: [...existing, newItem],
200
- };
201
- onChange(updated);
202
- editor.setDirty(true);
203
- // Return to list
204
- setCreateMode(null);
205
- setCreateAnchorId('');
206
- setCreateText('');
207
- setCreateDescription('');
208
- editor.clearHighlight();
209
- }, [createAnchorId, createText, typedConfig, onChange, editor]);
210
- // ---- Edit form renderers per section type ----
211
- const renderEditFields = (section, index) => {
212
- const arr = typedConfig[section] || [];
213
- const item = arr[index];
214
- if (!item)
215
- return null;
216
- const anchorId = resolveAnchorSelector(item.anchorId);
217
- switch (section) {
218
- case 'textReplacements':
219
- return (_jsxs("div", { className: "se-py-1", children: [_jsx("div", { className: "se-text-sm se-font-mono se-text-text-secondary se-py-1 se-px-2 se-bg-slate-grey-3 se-rounded-lg se-mb-3", children: anchorId }), _jsx(EditorTextarea, { label: "Text", value: item.text || '', onChange: (e) => handleFieldChange(section, index, 'text', e.target.value) })] }));
220
- case 'attributeChanges':
221
- return (_jsxs("div", { className: "se-py-1", children: [_jsx("div", { className: "se-text-sm se-font-mono se-text-text-secondary se-py-1 se-px-2 se-bg-slate-grey-3 se-rounded-lg se-mb-3", children: anchorId }), _jsx(EditorInput, { label: "Attribute", value: item.attr || '', onChange: (e) => handleFieldChange(section, index, 'attr', e.target.value) }), _jsx(EditorInput, { label: "Value", value: item.value || '', onChange: (e) => handleFieldChange(section, index, 'value', e.target.value) })] }));
222
- case 'styleChanges': {
223
- const styleObj = item.styles || {};
224
- return (_jsxs("div", { className: "se-py-1", children: [_jsx("div", { className: "se-text-sm se-font-mono se-text-text-secondary se-py-1 se-px-2 se-bg-slate-grey-3 se-rounded-lg se-mb-3", children: anchorId }), _jsx("label", { className: "se-text-[11px] se-font-semibold se-text-slate-grey-7 se-mb-1 se-block", children: "Styles" }), Object.entries(styleObj).map(([prop, val]) => (_jsxs("div", { className: "se-flex se-gap-1 se-mb-1", children: [_jsx("input", { className: "se-flex-1 se-py-1.5 se-px-2 se-rounded-lg se-border se-border-input-field-border se-bg-slate-grey-3 se-text-text-primary se-text-sm se-font-[inherit] se-box-border", value: prop, readOnly: true }), _jsx("input", { className: "se-flex-1 se-py-1.5 se-px-2 se-rounded-lg se-border se-border-input-field-border se-bg-slate-grey-3 se-text-text-primary se-text-sm se-font-[inherit] se-box-border", value: val, onChange: (e) => {
225
- const newStyles = { ...styleObj, [prop]: e.target.value };
226
- handleFieldChange(section, index, 'styles', newStyles);
227
- } })] }, prop)))] }));
228
- }
229
- case 'htmlInsertions':
230
- return (_jsxs("div", { className: "se-py-1", children: [_jsx("div", { className: "se-text-sm se-font-mono se-text-text-secondary se-py-1 se-px-2 se-bg-slate-grey-3 se-rounded-lg se-mb-3", children: anchorId }), _jsxs(EditorSelect, { label: "Position", value: item.position || 'after', onChange: (e) => handleFieldChange(section, index, 'position', e.target.value), children: [_jsx("option", { value: "before", children: "Before" }), _jsx("option", { value: "after", children: "After" }), _jsx("option", { value: "prepend", children: "Prepend" }), _jsx("option", { value: "append", children: "Append" }), _jsx("option", { value: "replace", children: "Replace" })] }), _jsx(EditorTextarea, { label: "HTML", value: item.html || '', onChange: (e) => handleFieldChange(section, index, 'html', e.target.value), className: "se-font-mono" })] }));
231
- case 'classAdditions':
232
- case 'classRemovals':
233
- return (_jsxs("div", { className: "se-py-1", children: [_jsx("div", { className: "se-text-sm se-font-mono se-text-text-secondary se-py-1 se-px-2 se-bg-slate-grey-3 se-rounded-lg se-mb-3", children: anchorId }), _jsx(EditorInput, { label: "Class Name", value: item.className || '', onChange: (e) => handleFieldChange(section, index, 'className', e.target.value) })] }));
234
- default:
235
- return null;
236
- }
237
- };
238
- const headerTitle = createMode === 'form' || createMode === 'picking' ? 'Add Text Change' : 'Content';
239
- const headerSubtitle = createMode === 'picking'
240
- ? 'Click an element on the page to select it. Press ESC to go back.'
241
- : createMode === 'form'
242
- ? 'Pick an element and set its new text'
243
- : `${totalChanges} change${totalChanges !== 1 ? 's' : ''}${totalChanges > 0 ? ` (${foundCount} found on this page)` : ''}`;
244
- const handleHeaderBack = () => {
245
- if (createMode === 'picking') {
246
- setCreateMode('form');
247
- }
248
- else if (createMode === 'form') {
249
- handleCancelCreate();
250
- }
251
- else if (editingKey !== null) {
252
- handleBackToList();
253
- }
254
- else {
255
- editor.navigateHome();
256
- }
257
- };
258
- return (_jsxs(EditorLayout, { children: [_jsx(EditorHeader, { title: headerTitle, subtitle: headerSubtitle, onBack: handleHeaderBack }), _jsx(EditorBody, { children: createMode === 'form' || createMode === 'picking' ? (
259
- /* ---- Create form mode ---- */
260
- _jsxs("div", { className: "se-flex se-flex-col se-gap-4", children: [_jsxs("div", { className: "se-flex se-flex-col se-gap-1.5", children: [_jsx("span", { className: "se-text-sm se-font-semibold se-text-text-primary se-uppercase se-tracking-wide", children: "Target Element" }), createAnchorId ? (_jsxs("div", { className: "se-flex se-gap-2 se-items-center", children: [_jsx("code", { className: "se-flex-1 se-py-1.5 se-px-2 se-rounded-lg se-border se-border-input-field-border se-bg-slate-grey-3 se-text-text-primary se-text-sm se-overflow-hidden se-text-ellipsis se-whitespace-nowrap", children: createAnchorId }), _jsx("button", { type: "button", onClick: () => setCreateMode('picking'), className: "se-py-1.5 se-px-3 se-rounded-lg se-border se-border-btn-neutral-border se-bg-btn-neutral se-text-btn-neutral-text se-text-sm se-cursor-pointer se-shrink-0 hover:se-text-btn-neutral-text-hover", children: "Re-pick" })] })) : (_jsx("button", { type: "button", onClick: () => setCreateMode('picking'), className: "se-w-full se-h-12 se-px-4 se-py-2 se-rounded-lg se-border-2 se-border-dashed se-border-btn-primary/30 se-bg-btn-primary/5 se-text-btn-primary se-text-sm se-font-medium se-cursor-pointer se-inline-flex se-items-center se-justify-center se-gap-2 hover:se-bg-btn-primary/10 hover:se-border-btn-primary/50", children: "+ Pick Target Element" })), createDescription && (_jsx("span", { className: "se-text-sm se-text-text-secondary", children: createDescription }))] }), _jsxs("div", { className: "se-flex se-flex-col se-gap-1.5", children: [_jsx("span", { className: "se-text-sm se-font-semibold se-text-text-primary se-uppercase se-tracking-wide", children: "Text Content" }), _jsx(EditorTextarea, { value: createText, onChange: (e) => setCreateText(e.target.value) })] }), _jsxs("div", { className: "se-flex se-gap-2 se-mt-2", children: [_jsx("button", { type: "button", onClick: handleCancelCreate, className: "se-flex-1 se-h-10 se-px-4 se-py-2 se-rounded-md se-border se-border-btn-neutral-border se-bg-btn-neutral se-text-btn-neutral-text se-text-sm se-font-medium se-cursor-pointer se-inline-flex se-items-center se-justify-center hover:se-text-btn-neutral-text-hover", children: "Cancel" }), _jsx("button", { type: "button", onClick: handleSaveCreate, disabled: !createAnchorId, className: "se-flex-1 se-h-10 se-px-4 se-py-2 se-rounded-md se-border-none se-bg-btn-primary se-text-btn-primary-text se-text-sm se-font-medium se-cursor-pointer se-inline-flex se-items-center se-justify-center hover:se-bg-btn-primary-hover disabled:se-opacity-50 disabled:se-pointer-events-none", children: "Add Change" })] })] })) : editingKey !== null ? (
261
- /* ---- Edit mode ---- */
262
- (() => {
263
- const ref = parseItemKey(editingKey);
264
- const editItem = allItems.find((it) => it.key === editingKey);
265
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "se-flex se-items-center se-gap-2 se-mb-3 se-text-lg se-font-semibold se-text-text-primary", children: [_jsx("span", { children: editItem && _jsx(SectionIcon, { section: editItem.section }) }), _jsx("span", { children: editItem?.summary })] }), renderEditFields(ref.section, ref.index)] }));
266
- })()) : (
267
- /* ---- List mode ---- */
268
- _jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: handleStartCreate, className: "se-w-full se-h-10 se-px-4 se-py-2 se-rounded-md se-border se-border-dashed se-border-btn-primary/30 se-bg-btn-primary/5 se-text-btn-primary se-text-sm se-font-medium se-cursor-pointer se-flex se-items-center se-justify-center se-gap-2 se-mb-3", children: "+ Add Text Change" }), allItems.length === 0 && (_jsx(EmptyState, { message: "No content changes configured. Click above to add one." })), activeItems.length > 0 && (_jsxs(_Fragment, { children: [_jsx(GroupHeader, { label: "CONTENT", count: activeItems.length }), activeItems.map((item) => {
269
- const detection = detectionMap.get(item.key);
270
- return (_jsxs(EditorCard, { itemKey: item.key, onClick: () => handleCardClick(item), className: "se-flex se-items-center se-gap-2", onMouseEnter: () => handleCardHover(item), onMouseLeave: handleCardLeave, children: [_jsx(DetectionBadge, { found: detection?.found ?? false, onClick: () => handleBadgeClick(item) }), _jsx("span", { className: "se-shrink-0 se-flex se-items-center -se-ml-1", children: _jsx(SectionIcon, { section: item.section }) }), _jsx("span", { className: "se-flex-1 se-overflow-hidden se-text-ellipsis se-whitespace-nowrap", children: item.summary }), _jsx("button", { type: "button", className: "se-py-0.5 se-px-1.5 se-rounded se-border-none se-bg-transparent se-text-slate-grey-7 se-text-sm se-cursor-pointer se-shrink-0 se-leading-none", onClick: (e) => {
271
- e.stopPropagation();
272
- handleDismiss(item.key);
273
- }, title: "Dismiss this change", children: "\u00D7" })] }, item.key));
274
- })] })), dismissedItems.length > 0 && (_jsx(DismissedSection, { count: dismissedItems.length, children: dismissedItems.map((item) => (_jsxs("div", { className: "se-flex se-items-center se-gap-2 se-py-1.5 se-px-2.5 se-rounded-lg se-border se-border-white/[0.03] se-bg-transparent se-mb-0.5 se-cursor-pointer se-text-sm se-text-text-tertiary se-opacity-60", children: [_jsx("span", { className: "se-shrink-0 se-flex se-items-center -se-ml-1", children: _jsx(SectionIcon, { section: item.section }) }), _jsx("span", { className: "se-flex-1 se-overflow-hidden se-text-ellipsis se-whitespace-nowrap se-line-through", children: item.summary }), _jsx("button", { type: "button", className: "se-py-0.5 se-px-1.5 se-rounded se-border-none se-bg-transparent se-text-blue-5 se-text-[11px] se-cursor-pointer se-shrink-0 se-leading-none", onClick: (e) => {
275
- e.stopPropagation();
276
- handleRestore(item.key);
277
- }, children: "Restore" })] }, item.key))) }))] })) }), _jsx(EditorFooter, { onSave: () => editor.save(), onPublish: handlePublish }), _jsx(AnchorPicker, { isActive: createMode === 'picking', onPick: handleElementPicked, onCancel: () => setCreateMode('form') })] }));
278
- }
279
- /**
280
- * Editor module configuration.
281
- */
282
- export const editor = {
283
- panel: {
284
- title: 'Content',
285
- icon: '\u{1f4dd}',
286
- description: 'Text and attribute modifications',
287
- },
288
- component: ContentEditor,
289
- };
290
- export const editorPanel = editor.panel;
291
- export default ContentEditor;
package/dist/editor.d.ts DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * Adaptive Content - Editor Module (barrel)
3
- *
4
- * Re-exports from the split state and UI modules for backward compatibility.
5
- */
6
- import { ContentEditor } from './content-editor-ui';
7
- export { ContentEditor, editor, editorPanel } from './content-editor-ui';
8
- export default ContentEditor;
9
- //# sourceMappingURL=editor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACzE,eAAe,aAAa,CAAC"}
package/dist/editor.js DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * Adaptive Content - Editor Module (barrel)
3
- *
4
- * Re-exports from the split state and UI modules for backward compatibility.
5
- */
6
- import { ContentEditor } from './content-editor-ui';
7
- export { ContentEditor, editor, editorPanel } from './content-editor-ui';
8
- export default ContentEditor;
@@ -1,80 +0,0 @@
1
- /**
2
- * Reconciliation Guard - MutationObserver defense against React DOM removal.
3
- *
4
- * When the Syntrologie SDK inserts DOM nodes into a React-managed subtree
5
- * (via content:insertHtml), React's reconciliation will silently remove them
6
- * on the next render because they don't exist in React's virtual DOM.
7
- *
8
- * This guard watches for the removal of our inserted container and re-inserts
9
- * it using a debounced retry mechanism with a maximum retry count to prevent
10
- * infinite loops (e.g., in React StrictMode which double-invokes effects).
11
- */
12
- /**
13
- * Watch for a container element being removed from the DOM by an external
14
- * framework (React, Vue, etc.) and call `reinsertFn` to re-insert it.
15
- *
16
- * @param container The element we inserted (has data-syntro-action-id)
17
- * @param anchor The anchor element our container is positioned relative to
18
- * @param reinsertFn Called when the container is removed — should re-insert it
19
- * @param opts Configuration for retry limits and debounce timing
20
- * @returns Cleanup function that disconnects the observer
21
- */
22
- export function guardAgainstReconciliation(container, anchor, reinsertFn, opts) {
23
- const maxRetries = opts?.maxRetries ?? 3;
24
- const debounceMs = opts?.debounceMs ?? 50;
25
- // Find the nearest parent to observe. Prefer container's parent, then anchor's.
26
- const observeTarget = container.parentElement ?? anchor.parentElement;
27
- if (!observeTarget)
28
- return () => { };
29
- let retries = 0;
30
- let debounceTimer = null;
31
- let disconnected = false;
32
- const observer = new MutationObserver((mutations) => {
33
- if (disconnected)
34
- return;
35
- for (const mutation of mutations) {
36
- for (const removed of mutation.removedNodes) {
37
- // Check if the removed node is our container
38
- if (removed !== container)
39
- continue;
40
- if (retries >= maxRetries) {
41
- observer.disconnect();
42
- disconnected = true;
43
- return;
44
- }
45
- // Debounce to coalesce rapid React re-renders
46
- if (debounceTimer)
47
- clearTimeout(debounceTimer);
48
- debounceTimer = setTimeout(() => {
49
- if (disconnected)
50
- return;
51
- // If the anchor has been removed from the DOM (SPA navigation),
52
- // the page has been torn down — stop fighting React's reconciler.
53
- // Re-inserting into a dying subtree triggers removeChild crashes.
54
- if (!anchor.isConnected) {
55
- observer.disconnect();
56
- disconnected = true;
57
- return;
58
- }
59
- retries++;
60
- try {
61
- reinsertFn();
62
- }
63
- catch {
64
- // Re-insertion failed — stop trying
65
- observer.disconnect();
66
- disconnected = true;
67
- }
68
- }, debounceMs);
69
- return; // Found our container, no need to check further
70
- }
71
- }
72
- });
73
- observer.observe(observeTarget, { childList: true, subtree: true });
74
- return () => {
75
- disconnected = true;
76
- observer.disconnect();
77
- if (debounceTimer)
78
- clearTimeout(debounceTimer);
79
- };
80
- }
package/dist/sanitizer.js DELETED
@@ -1,95 +0,0 @@
1
- /**
2
- * HTML Sanitizer
3
- *
4
- * Sanitizes HTML to prevent XSS attacks.
5
- * Uses native Sanitizer API when available, falls back to whitelist approach.
6
- */
7
- const ALLOWED_TAGS = new Set([
8
- 'b',
9
- 'strong',
10
- 'i',
11
- 'em',
12
- 'u',
13
- 'span',
14
- 'div',
15
- 'p',
16
- 'br',
17
- 'ul',
18
- 'ol',
19
- 'li',
20
- 'code',
21
- 'pre',
22
- 'small',
23
- 'sup',
24
- 'sub',
25
- 'a',
26
- 'button',
27
- // SVG elements (for inline Lucide icons in config HTML)
28
- 'svg',
29
- 'path',
30
- 'circle',
31
- 'line',
32
- 'polyline',
33
- 'polygon',
34
- 'rect',
35
- 'g',
36
- ]);
37
- export function sanitizeHtml(html) {
38
- // Try native Sanitizer API first
39
- const hasNative = typeof window.Sanitizer === 'function';
40
- if (hasNative) {
41
- try {
42
- const s = new window.Sanitizer({});
43
- const frag = s.sanitizeToFragment(html);
44
- const div = document.createElement('div');
45
- div.append(frag);
46
- return div.innerHTML;
47
- }
48
- catch {
49
- // Fall through to manual sanitizer
50
- }
51
- }
52
- // Conservative fallback sanitizer
53
- const tpl = document.createElement('template');
54
- tpl.innerHTML = html;
55
- const root = tpl.content;
56
- const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, null);
57
- const toRemove = [];
58
- while (walker.nextNode()) {
59
- const el = walker.currentNode;
60
- const tag = el.tagName.toLowerCase();
61
- if (!ALLOWED_TAGS.has(tag)) {
62
- toRemove.push(el);
63
- continue;
64
- }
65
- // Remove dangerous attributes
66
- for (const attr of Array.from(el.attributes)) {
67
- const name = attr.name.toLowerCase();
68
- const value = attr.value.trim().toLowerCase();
69
- const isEvent = name.startsWith('on');
70
- const isUrlAttr = name === 'href' || name === 'src' || name === 'formaction';
71
- const isDangerousUrl = isUrlAttr &&
72
- (value.startsWith('javascript:') ||
73
- value.startsWith('vbscript:') ||
74
- value.startsWith('data:text/html'));
75
- if (isEvent || isDangerousUrl) {
76
- el.removeAttribute(attr.name);
77
- }
78
- }
79
- }
80
- // Strip SVG elements that contained script children (XSS vector)
81
- const svgs = Array.from(root.querySelectorAll('svg'));
82
- for (const svg of svgs) {
83
- if (toRemove.some((el) => svg.contains(el) && el.tagName.toLowerCase() === 'script')) {
84
- toRemove.push(svg);
85
- }
86
- }
87
- // Remove disallowed elements but keep their children
88
- for (const el of toRemove) {
89
- while (el.firstChild) {
90
- el.parentNode?.insertBefore(el.firstChild, el);
91
- }
92
- el.remove();
93
- }
94
- return tpl.innerHTML;
95
- }
package/dist/summarize.js DELETED
@@ -1,88 +0,0 @@
1
- /**
2
- * Human-readable summary generation for content config changes.
3
- *
4
- * Pure functions — no DOM access, just string formatting from config data.
5
- */
6
- const MAX_TEXT_LEN = 40;
7
- /** Extract the CSS selector string from an anchorId object. */
8
- function resolveAnchorSelector(anchorId) {
9
- if (!anchorId)
10
- return '';
11
- if (typeof anchorId === 'string')
12
- return anchorId;
13
- if (typeof anchorId === 'object')
14
- return anchorId.selector ?? '';
15
- return '';
16
- }
17
- /**
18
- * Convert a CSS selector into a human-friendly element description.
19
- */
20
- export function describeSelector(selector) {
21
- if (!selector)
22
- return '(no target)';
23
- // ID selector: strip # and common prefixes
24
- if (selector.startsWith('#')) {
25
- let name = selector.slice(1);
26
- const prefixes = ['hero-', 'main-', 'page-', 'app-', 'section-'];
27
- for (const prefix of prefixes) {
28
- if (name.startsWith(prefix)) {
29
- name = name.slice(prefix.length);
30
- break;
31
- }
32
- }
33
- return truncate(name, 50);
34
- }
35
- // data-testid selector
36
- const testIdMatch = selector.match(/\[data-testid="([^"]+)"\]/);
37
- if (testIdMatch) {
38
- return `${testIdMatch[1]} element`;
39
- }
40
- // Class selector or complex selector: keep as-is
41
- return truncate(selector, 50);
42
- }
43
- function truncate(text, max) {
44
- if (text.length <= max)
45
- return text;
46
- return `${text.slice(0, max)}...`;
47
- }
48
- function truncateQuoted(text, max) {
49
- if (text.length <= max)
50
- return `"${text}"`;
51
- return `"${text.slice(0, max)}..."`;
52
- }
53
- /**
54
- * Generate a human-readable one-liner for a content config change.
55
- */
56
- export function summarizeContentChange(type, item) {
57
- const desc = describeSelector(resolveAnchorSelector(item.anchorId));
58
- switch (type) {
59
- case 'textReplacements': {
60
- const text = item.text || '';
61
- return `Change ${desc} to ${truncateQuoted(text, MAX_TEXT_LEN)}`;
62
- }
63
- case 'attributeChanges': {
64
- const attr = item.attr || '';
65
- const value = item.value || '';
66
- return `Set ${desc} ${attr} to ${truncateQuoted(value, MAX_TEXT_LEN)}`;
67
- }
68
- case 'styleChanges': {
69
- const styles = item.styles || {};
70
- const count = Object.keys(styles).length;
71
- return `Restyle ${desc} (${count} ${count === 1 ? 'property' : 'properties'})`;
72
- }
73
- case 'htmlInsertions': {
74
- const position = item.position || 'append';
75
- return `Insert HTML ${position} ${desc}`;
76
- }
77
- case 'classAdditions': {
78
- const className = item.className || '';
79
- return `Add class "${className}" to ${desc}`;
80
- }
81
- case 'classRemovals': {
82
- const className = item.className || '';
83
- return `Remove class "${className}" from ${desc}`;
84
- }
85
- default:
86
- return `Unknown change on ${desc}`;
87
- }
88
- }
package/dist/types.js DELETED
@@ -1,7 +0,0 @@
1
- /**
2
- * Types from @syntrologie/runtime-sdk
3
- *
4
- * Minimal type definitions for building this app independently.
5
- * These match the types exported from @syntrologie/runtime-sdk/types.
6
- */
7
- export {};
@@ -1,6 +0,0 @@
1
- /**
2
- * Re-export selector utilities from shared-editor-ui.
3
- */
4
- export type { SelectorOptions } from '@syntrologie/shared-editor-ui';
5
- export { generateSelector, getElementDescription, validateSelector, } from '@syntrologie/shared-editor-ui';
6
- //# sourceMappingURL=selectorGenerator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"selectorGenerator.d.ts","sourceRoot":"","sources":["../../src/utils/selectorGenerator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,+BAA+B,CAAC"}
@@ -1,4 +0,0 @@
1
- /**
2
- * Re-export selector utilities from shared-editor-ui.
3
- */
4
- export { generateSelector, getElementDescription, validateSelector, } from '@syntrologie/shared-editor-ui';
@@ -1,2 +0,0 @@
1
- export declare function cn(...classes: (string | false | null | undefined)[]): string;
2
- //# sourceMappingURL=cn.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cn.d.ts","sourceRoot":"","sources":["../src/cn.ts"],"names":[],"mappings":"AAAA,wBAAgB,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAE5E"}
@@ -1,3 +0,0 @@
1
- export function cn(...classes) {
2
- return classes.filter(Boolean).join(' ');
3
- }
@@ -1,34 +0,0 @@
1
- /**
2
- * AnchorPicker — Shared Element Picker Overlay
3
- *
4
- * Full-page overlay that lets the user hover and click to select a DOM element.
5
- * Returns the element, its CSS selector, and a human-readable description.
6
- *
7
- * Renders via createPortal to document.body. Uses inline styles (not Tailwind)
8
- * because it lives outside the editor's style scope.
9
- *
10
- * EXCEPTION: This component MUST stay on document.body (not in shadow root).
11
- * It uses document.elementFromPoint() to detect host page elements under the
12
- * cursor. If placed inside a shadow root, the overlay would block detection
13
- * of underlying host elements.
14
- *
15
- * Instructions / cancel UI should be rendered by the consumer in their own
16
- * panel — this component only provides the page overlay.
17
- */
18
- export interface PickedElement {
19
- element: Element;
20
- selector: string;
21
- description: string;
22
- }
23
- export interface AnchorPickerProps {
24
- isActive: boolean;
25
- onPick: (picked: PickedElement) => void;
26
- onCancel: () => void;
27
- /** When true, clicks pass through to the page (no preventDefault/stopPropagation).
28
- * The consumer is responsible for capturing the pick via EventBus or other means.
29
- * Hover highlighting still works for visual feedback. */
30
- passthroughClicks?: boolean;
31
- excludeSelector?: string;
32
- }
33
- export declare function AnchorPicker({ isActive, onPick, onCancel, passthroughClicks, excludeSelector, }: AnchorPickerProps): import("react").ReactPortal | null;
34
- //# sourceMappingURL=AnchorPicker.d.ts.map