@syntrologie/adapt-content 2.16.0 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runtime.js +425 -366
- package/dist/runtime.js.map +7 -0
- package/dist/schema.d.ts +55 -16
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +316 -62
- package/dist/schema.js.map +7 -0
- package/package.json +2 -20
- package/dist/cdn.d.ts +0 -35
- package/dist/cdn.d.ts.map +0 -1
- package/dist/cdn.js +0 -39
- package/dist/components/AnchorPicker.d.ts +0 -8
- package/dist/components/AnchorPicker.d.ts.map +0 -1
- package/dist/components/AnchorPicker.js +0 -6
- package/dist/content-editor-state.d.ts +0 -45
- package/dist/content-editor-state.d.ts.map +0 -1
- package/dist/content-editor-state.js +0 -123
- package/dist/content-editor-ui.d.ts +0 -26
- package/dist/content-editor-ui.d.ts.map +0 -1
- package/dist/content-editor-ui.js +0 -291
- package/dist/editor.d.ts +0 -9
- package/dist/editor.d.ts.map +0 -1
- package/dist/editor.js +0 -8
- package/dist/reconciliation-guard.js +0 -80
- package/dist/sanitizer.js +0 -95
- package/dist/summarize.js +0 -88
- package/dist/types.js +0 -7
- package/dist/utils/selectorGenerator.d.ts +0 -6
- package/dist/utils/selectorGenerator.d.ts.map +0 -1
- package/dist/utils/selectorGenerator.js +0 -4
- package/node_modules/@syntrologie/shared-editor-ui/dist/cn.d.ts +0 -2
- package/node_modules/@syntrologie/shared-editor-ui/dist/cn.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/cn.js +0 -3
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPicker.d.ts +0 -34
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPicker.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPicker.js +0 -161
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPickerLit.d.ts +0 -84
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPickerLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPickerLit.js +0 -323
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggle.d.ts +0 -7
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggle.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggle.js +0 -9
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggleLit.d.ts +0 -25
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggleLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggleLit.js +0 -55
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLine.d.ts +0 -23
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLine.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLine.js +0 -40
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLineLit.d.ts +0 -33
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLineLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLineLit.js +0 -118
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadge.d.ts +0 -7
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadge.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadge.js +0 -22
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadgeLit.d.ts +0 -32
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadgeLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadgeLit.js +0 -68
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSection.d.ts +0 -8
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSection.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSection.js +0 -9
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSectionLit.d.ts +0 -34
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSectionLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSectionLit.js +0 -57
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButton.d.ts +0 -7
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButton.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButton.js +0 -4
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButtonLit.d.ts +0 -13
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButtonLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButtonLit.js +0 -31
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBody.d.ts +0 -7
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBody.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBody.js +0 -4
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBodyLit.d.ts +0 -7
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBodyLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBodyLit.js +0 -15
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCard.d.ts +0 -13
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCard.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCard.js +0 -15
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCardLit.d.ts +0 -36
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCardLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCardLit.js +0 -102
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooter.d.ts +0 -7
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooter.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooter.js +0 -4
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooterLit.d.ts +0 -20
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooterLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooterLit.js +0 -48
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeader.d.ts +0 -9
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeader.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeader.js +0 -4
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeaderLit.d.ts +0 -16
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeaderLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeaderLit.js +0 -25
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInput.d.ts +0 -8
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInput.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInput.js +0 -8
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInputLit.d.ts +0 -66
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInputLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInputLit.js +0 -87
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayout.d.ts +0 -7
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayout.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayout.js +0 -4
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayoutLit.d.ts +0 -7
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayoutLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayoutLit.js +0 -15
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShell.d.ts +0 -25
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShell.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShell.js +0 -390
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShellLit.d.ts +0 -66
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShellLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShellLit.js +0 -528
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelect.d.ts +0 -8
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelect.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelect.js +0 -8
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelectLit.d.ts +0 -41
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelectLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelectLit.js +0 -63
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextarea.d.ts +0 -8
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextarea.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextarea.js +0 -17
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextareaLit.d.ts +0 -55
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextareaLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextareaLit.js +0 -92
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlight.d.ts +0 -32
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlight.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlight.js +0 -85
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlightLit.d.ts +0 -90
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlightLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlightLit.js +0 -242
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyState.d.ts +0 -6
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyState.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyState.js +0 -4
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyStateLit.d.ts +0 -12
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyStateLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyStateLit.js +0 -21
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeader.d.ts +0 -8
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeader.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeader.js +0 -5
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeaderLit.d.ts +0 -21
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeaderLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeaderLit.js +0 -33
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourney.d.ts +0 -12
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourney.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourney.js +0 -40
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourneyLit.d.ts +0 -28
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourneyLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourneyLit.js +0 -121
- package/node_modules/@syntrologie/shared-editor-ui/dist/controllers/PanelShellController.d.ts +0 -110
- package/node_modules/@syntrologie/shared-editor-ui/dist/controllers/PanelShellController.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/controllers/PanelShellController.js +0 -481
- package/node_modules/@syntrologie/shared-editor-ui/dist/formatConditionLabel.d.ts +0 -26
- package/node_modules/@syntrologie/shared-editor-ui/dist/formatConditionLabel.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/formatConditionLabel.js +0 -202
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useElementRect.d.ts +0 -8
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useElementRect.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useElementRect.js +0 -46
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useTriggerWhenStatus.d.ts +0 -24
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useTriggerWhenStatus.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useTriggerWhenStatus.js +0 -86
- package/node_modules/@syntrologie/shared-editor-ui/dist/index.d.ts +0 -36
- package/node_modules/@syntrologie/shared-editor-ui/dist/index.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/index.js +0 -26
- package/node_modules/@syntrologie/shared-editor-ui/dist/lit-elements.d.ts +0 -15
- package/node_modules/@syntrologie/shared-editor-ui/dist/lit-elements.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/lit-elements.js +0 -14
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/elementChainRecommender.d.ts +0 -33
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/elementChainRecommender.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/elementChainRecommender.js +0 -68
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/selectorGenerator.d.ts +0 -22
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/selectorGenerator.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/selectorGenerator.js +0 -143
- package/node_modules/@syntrologie/shared-editor-ui/package.json +0 -55
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adaptive Content - Editor State & Logic
|
|
3
|
-
*
|
|
4
|
-
* Pure helpers for the content editor: anchor resolution, types, section config,
|
|
5
|
-
* flatten/filter logic, anchor detection hook, and dismissal management.
|
|
6
|
-
*/
|
|
7
|
-
import type { ContentConfig } from './schema';
|
|
8
|
-
/** Extract the CSS selector string from an anchorId (object or legacy string). */
|
|
9
|
-
export declare function resolveAnchorSelector(anchorId: unknown): string;
|
|
10
|
-
/** Extract the target route from an AnchorId object, ignoring wildcard '**'. */
|
|
11
|
-
export declare function resolveAnchorRoute(anchorId: unknown): string | null;
|
|
12
|
-
/** Save a pending highlight selector to sessionStorage (inlined to avoid cross-package import). */
|
|
13
|
-
export declare function savePendingHighlight(selector: string): void;
|
|
14
|
-
export type SectionKey = keyof ContentConfig;
|
|
15
|
-
export interface ItemRef {
|
|
16
|
-
section: SectionKey;
|
|
17
|
-
index: number;
|
|
18
|
-
}
|
|
19
|
-
export declare function itemKey(section: SectionKey, index: number): string;
|
|
20
|
-
export declare function parseItemKey(key: string): ItemRef;
|
|
21
|
-
export declare const SECTION_ICON_MAP: Record<SectionKey, React.ComponentType<{
|
|
22
|
-
size?: number;
|
|
23
|
-
className?: string;
|
|
24
|
-
}>>;
|
|
25
|
-
export interface FlatItem {
|
|
26
|
-
key: string;
|
|
27
|
-
section: SectionKey;
|
|
28
|
-
index: number;
|
|
29
|
-
summary: string;
|
|
30
|
-
anchorId: string;
|
|
31
|
-
rawAnchorId: unknown;
|
|
32
|
-
}
|
|
33
|
-
/** Build a flat list of all items across all section types. */
|
|
34
|
-
export declare function flattenItems(config: ContentConfig): FlatItem[];
|
|
35
|
-
/** Remove items by key set from a config, returning a new config. */
|
|
36
|
-
export declare function filterConfig(config: ContentConfig, dismissedKeys: Set<string>): ContentConfig;
|
|
37
|
-
export interface DetectionEntry {
|
|
38
|
-
found: boolean;
|
|
39
|
-
element: HTMLElement | null;
|
|
40
|
-
}
|
|
41
|
-
export declare function useAnchorDetection(items: Array<{
|
|
42
|
-
key: string;
|
|
43
|
-
anchorId: string;
|
|
44
|
-
}>): Map<string, DetectionEntry>;
|
|
45
|
-
//# sourceMappingURL=content-editor-state.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content-editor-state.d.ts","sourceRoot":"","sources":["../src/content-editor-state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAO9C,kFAAkF;AAClF,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAK/D;AAED,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CASnE;AAED,mGAAmG;AACnG,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,QAMpD;AAMD,MAAM,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,UAAU,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGjD;AAMD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,UAAU,EACV,KAAK,CAAC,aAAa,CAAC;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAQ3D,CAAC;AAMF,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,UAAU,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,QAAQ,EAAE,CAkB9D;AAED,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,aAAa,CAW7F;AAMD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;CAC7B;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,GAC9C,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CA6B7B"}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adaptive Content - Editor State & Logic
|
|
3
|
-
*
|
|
4
|
-
* Pure helpers for the content editor: anchor resolution, types, section config,
|
|
5
|
-
* flatten/filter logic, anchor detection hook, and dismissal management.
|
|
6
|
-
*/
|
|
7
|
-
import { FileCode, Minus, Palette, Plus, Tag, Type } from 'lucide-react';
|
|
8
|
-
import { useEffect, useRef, useState } from 'react';
|
|
9
|
-
import { summarizeContentChange } from './summarize';
|
|
10
|
-
// ============================================================================
|
|
11
|
-
// Anchor Helpers
|
|
12
|
-
// ============================================================================
|
|
13
|
-
/** Extract the CSS selector string from an anchorId (object or legacy string). */
|
|
14
|
-
export function resolveAnchorSelector(anchorId) {
|
|
15
|
-
if (!anchorId)
|
|
16
|
-
return '';
|
|
17
|
-
if (typeof anchorId === 'string')
|
|
18
|
-
return anchorId;
|
|
19
|
-
if (typeof anchorId === 'object')
|
|
20
|
-
return anchorId.selector ?? '';
|
|
21
|
-
return '';
|
|
22
|
-
}
|
|
23
|
-
/** Extract the target route from an AnchorId object, ignoring wildcard '**'. */
|
|
24
|
-
export function resolveAnchorRoute(anchorId) {
|
|
25
|
-
if (!anchorId || typeof anchorId !== 'object')
|
|
26
|
-
return null;
|
|
27
|
-
const route = anchorId.route;
|
|
28
|
-
if (typeof route === 'string' && route !== '**')
|
|
29
|
-
return route;
|
|
30
|
-
if (Array.isArray(route)) {
|
|
31
|
-
const first = route.find((r) => typeof r === 'string' && r !== '**');
|
|
32
|
-
return first ?? null;
|
|
33
|
-
}
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
/** Save a pending highlight selector to sessionStorage (inlined to avoid cross-package import). */
|
|
37
|
-
export function savePendingHighlight(selector) {
|
|
38
|
-
try {
|
|
39
|
-
sessionStorage.setItem('syntro:editor:pending-highlight', selector);
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
// Silently ignore
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export function itemKey(section, index) {
|
|
46
|
-
return `${section}:${index}`;
|
|
47
|
-
}
|
|
48
|
-
export function parseItemKey(key) {
|
|
49
|
-
const [section, indexStr] = key.split(':');
|
|
50
|
-
return { section: section, index: Number(indexStr) };
|
|
51
|
-
}
|
|
52
|
-
// ============================================================================
|
|
53
|
-
// Section Config
|
|
54
|
-
// ============================================================================
|
|
55
|
-
export const SECTION_ICON_MAP = {
|
|
56
|
-
textReplacements: Type,
|
|
57
|
-
attributeChanges: Tag,
|
|
58
|
-
styleChanges: Palette,
|
|
59
|
-
htmlInsertions: FileCode,
|
|
60
|
-
classAdditions: Plus,
|
|
61
|
-
classRemovals: Minus,
|
|
62
|
-
};
|
|
63
|
-
/** Build a flat list of all items across all section types. */
|
|
64
|
-
export function flattenItems(config) {
|
|
65
|
-
const items = [];
|
|
66
|
-
const sections = Object.keys(SECTION_ICON_MAP);
|
|
67
|
-
for (const section of sections) {
|
|
68
|
-
const arr = config[section] || [];
|
|
69
|
-
arr.forEach((item, i) => {
|
|
70
|
-
const rec = item;
|
|
71
|
-
items.push({
|
|
72
|
-
key: itemKey(section, i),
|
|
73
|
-
section,
|
|
74
|
-
index: i,
|
|
75
|
-
summary: summarizeContentChange(section, rec),
|
|
76
|
-
anchorId: resolveAnchorSelector(rec.anchorId),
|
|
77
|
-
rawAnchorId: rec.anchorId,
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
return items;
|
|
82
|
-
}
|
|
83
|
-
/** Remove items by key set from a config, returning a new config. */
|
|
84
|
-
export function filterConfig(config, dismissedKeys) {
|
|
85
|
-
const result = { ...config };
|
|
86
|
-
const sections = Object.keys(SECTION_ICON_MAP);
|
|
87
|
-
for (const section of sections) {
|
|
88
|
-
const arr = config[section] || [];
|
|
89
|
-
const filtered = arr.filter((_, i) => !dismissedKeys.has(itemKey(section, i)));
|
|
90
|
-
if (filtered.length > 0 || config[section] !== undefined) {
|
|
91
|
-
result[section] = filtered;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return result;
|
|
95
|
-
}
|
|
96
|
-
export function useAnchorDetection(items) {
|
|
97
|
-
const [detectionMap, setDetectionMap] = useState(new Map());
|
|
98
|
-
const itemsRef = useRef(items);
|
|
99
|
-
itemsRef.current = items;
|
|
100
|
-
useEffect(() => {
|
|
101
|
-
const runDetection = () => {
|
|
102
|
-
const map = new Map();
|
|
103
|
-
for (const item of itemsRef.current) {
|
|
104
|
-
if (!item.anchorId) {
|
|
105
|
-
map.set(item.key, { found: false, element: null });
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
try {
|
|
109
|
-
const el = document.querySelector(item.anchorId);
|
|
110
|
-
map.set(item.key, { found: el !== null, element: el });
|
|
111
|
-
}
|
|
112
|
-
catch {
|
|
113
|
-
map.set(item.key, { found: false, element: null });
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
setDetectionMap(map);
|
|
117
|
-
};
|
|
118
|
-
runDetection();
|
|
119
|
-
const interval = setInterval(runDetection, 2000);
|
|
120
|
-
return () => clearInterval(interval);
|
|
121
|
-
}, []);
|
|
122
|
-
return detectionMap;
|
|
123
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adaptive Content - Editor UI Component
|
|
3
|
-
*
|
|
4
|
-
* Main editor component with tab switching, item selection, form inputs,
|
|
5
|
-
* save/publish, and highlight on page.
|
|
6
|
-
*/
|
|
7
|
-
import type { EditorPanelProps } from './types';
|
|
8
|
-
export declare function ContentEditor({ config, onChange, editor }: EditorPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
/**
|
|
10
|
-
* Editor module configuration.
|
|
11
|
-
*/
|
|
12
|
-
export declare const editor: {
|
|
13
|
-
panel: {
|
|
14
|
-
title: string;
|
|
15
|
-
icon: string;
|
|
16
|
-
description: string;
|
|
17
|
-
};
|
|
18
|
-
component: typeof ContentEditor;
|
|
19
|
-
};
|
|
20
|
-
export declare const editorPanel: {
|
|
21
|
-
title: string;
|
|
22
|
-
icon: string;
|
|
23
|
-
description: string;
|
|
24
|
-
};
|
|
25
|
-
export default ContentEditor;
|
|
26
|
-
//# sourceMappingURL=content-editor-ui.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content-editor-ui.d.ts","sourceRoot":"","sources":["../src/content-editor-ui.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AA+BH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAgBhD,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,gBAAgB,2CAmjB3E;AAED;;GAEG;AACH,eAAO,MAAM,MAAM;;;;;;;CAOlB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;CAAe,CAAC;AAExC,eAAe,aAAa,CAAC"}
|
|
@@ -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, 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(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
|
package/dist/editor.d.ts.map
DELETED
|
@@ -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
|
-
}
|