@contentstack/studio-internal 1.2.0 → 1.2.1
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/core/apply.d.ts.map +1 -1
- package/dist/core/apply.js +14 -1
- package/dist/core/apply.js.map +1 -1
- package/dist/index.d.ts +53 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/transforms/general.d.ts.map +1 -1
- package/dist/interfaces/transforms/general.js +11 -0
- package/dist/interfaces/transforms/general.js.map +1 -1
- package/dist/utils/section-slot-walker.d.ts +51 -0
- package/dist/utils/section-slot-walker.d.ts.map +1 -0
- package/dist/utils/section-slot-walker.js +63 -0
- package/dist/utils/section-slot-walker.js.map +1 -0
- package/package.json +5 -5
package/dist/core/apply.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/core/apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAQ,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/core/apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAQ,MAAM,eAAe,CAAC;AAmBxD,eAAO,MAAM,KAAK,GAAI,QAAQ,MAAM,EAAE,IAAI,SAAS,SAoClD,CAAC"}
|
package/dist/core/apply.js
CHANGED
|
@@ -7,6 +7,17 @@ import { FLUSHING } from '../utils/weak-maps.js';
|
|
|
7
7
|
import { isBatchingDirtyPaths } from './batch-dirty-paths.js';
|
|
8
8
|
import { updateDirtyPaths } from './update-dirty-paths.js';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Operation types that change view/cursor state but NOT the persisted
|
|
12
|
+
* content tree. Applying one must NOT mark the editor as having unsaved
|
|
13
|
+
* changes — otherwise actions like clearing the selection on load (e.g. a
|
|
14
|
+
* `setSelection(editor, { at: null })`) would spuriously enable Save with
|
|
15
|
+
* no real edit.
|
|
16
|
+
*/
|
|
17
|
+
const NON_DIRTYING_OP_TYPES = new Set([
|
|
18
|
+
"set_selection",
|
|
19
|
+
"set_active_context_path",
|
|
20
|
+
]);
|
|
10
21
|
const apply = (editor, op) => {
|
|
11
22
|
for (const ref of Editor.pathRefs(editor)) {
|
|
12
23
|
PathRef.transform(ref, op);
|
|
@@ -34,7 +45,9 @@ const apply = (editor, op) => {
|
|
|
34
45
|
editor.operations = [];
|
|
35
46
|
});
|
|
36
47
|
}
|
|
37
|
-
|
|
48
|
+
if (!NON_DIRTYING_OP_TYPES.has(op.type)) {
|
|
49
|
+
editor.setHasUnSavedChanges(true);
|
|
50
|
+
}
|
|
38
51
|
};
|
|
39
52
|
|
|
40
53
|
export { apply };
|
package/dist/core/apply.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.js","sources":["../../src/core/apply.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"apply.js","sources":["../../src/core/apply.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAOA;;;;;;AAMG;AACH,MAAM,qBAAqB,GAAmC,IAAI,GAAG,CAAC;IACpE,eAAe;IACf,yBAAyB;AAC1B,CAAA,CAAC;MAEW,KAAK,GAAG,CAAC,MAAc,EAAE,EAAa,KAAI;IACrD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;AACzC,QAAA,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,CAAC;IAC5B;AAEA,IAAA,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE;AACjC,QAAA,MAAM,SAAS,GAAG,IAAI,CAAC,yBAAyB,CAAC,EAAE;AACjD,cAAE,CAAC,CAAO,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,E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141
|
-
|
|
1140
|
+
/**
|
|
1141
|
+
* Shared section-UI walker for section-slot context resolution.
|
|
1142
|
+
*
|
|
1143
|
+
* Sections expose `section-slot` placeholders inside their authored UI. When
|
|
1144
|
+
* those slots are filled on a page composition, the slot children render
|
|
1145
|
+
* inside the section's body — surrounded by whatever Repeater /
|
|
1146
|
+
* ConditionBlock chain wraps the matching `section-slot` in the section's
|
|
1147
|
+
* authored UI.
|
|
1148
|
+
*
|
|
1149
|
+
* Three call sites historically each rolled their own walker:
|
|
1150
|
+
*
|
|
1151
|
+
* - Studio's `findSectionCompositionInstances` (auto-binder) — needs
|
|
1152
|
+
* parentRepeaterUid + cumulative schema-path segments for the
|
|
1153
|
+
* auto-binder's contextSchemaPath input.
|
|
1154
|
+
* - Studio's picker `getRepeatersWrappingSectionSlot` — needs the actual
|
|
1155
|
+
* Repeater node references for a SPECIFIC slot (to feed the picker's
|
|
1156
|
+
* repeater adapters and to surface the section title as the picker
|
|
1157
|
+
* header label).
|
|
1158
|
+
* - SDK's `indexSectionInternalSlotRepeaters` — needs only the nearest
|
|
1159
|
+
* ancestor Repeater uid per slot, for the per-instance binding seeder.
|
|
1160
|
+
*
|
|
1161
|
+
* All three did the same walk with different output shapes. This module
|
|
1162
|
+
* does the walk ONCE and exposes the raw ancestor-node chain per slot;
|
|
1163
|
+
* each consumer derives the shape it needs. Lives in `studio-internal`
|
|
1164
|
+
* because that's the only SDK package both Studio and the SDK packages
|
|
1165
|
+
* symlink to.
|
|
1166
|
+
*/
|
|
1167
|
+
interface SectionSlotContext {
|
|
1168
|
+
/**
|
|
1169
|
+
* Root→leaf chain of ancestor `repeater` AND `condition-block` nodes
|
|
1170
|
+
* wrapping the slot, interleaved in the order they appear in the
|
|
1171
|
+
* section's authored tree. Callers can filter by `node.type` if they
|
|
1172
|
+
* only need one kind, or walk in order to derive a cumulative
|
|
1173
|
+
* schema-path.
|
|
1174
|
+
*/
|
|
1175
|
+
ancestorNodes: any[];
|
|
1176
|
+
}
|
|
1177
|
+
/**
|
|
1178
|
+
* Walks `sectionUI` and returns, for every `section-slot` encountered, the
|
|
1179
|
+
* chain of ancestor Repeater and ConditionBlock nodes wrapping it.
|
|
1180
|
+
*
|
|
1181
|
+
* The returned arrays preserve root→leaf order so callers can either
|
|
1182
|
+
* - read the LAST entry as the nearest ancestor (e.g. parentRepeaterUid), or
|
|
1183
|
+
* - join their bindings to derive the cumulative schema path.
|
|
1184
|
+
*
|
|
1185
|
+
* Returns a map keyed by section-slot uid. If a slot uid is missing from the
|
|
1186
|
+
* map the slot isn't wrapped by any Repeater / ConditionBlock in the section
|
|
1187
|
+
* (or doesn't exist in this section).
|
|
1188
|
+
*/
|
|
1189
|
+
declare function indexSectionSlotContexts(sectionUI: any): Record<string, SectionSlotContext>;
|
|
1190
|
+
|
|
1191
|
+
export { CONDITION_OPERATORS, Editor, ID_LENGTH, Node, Operation, Path, PathRef, Transforms, apply, compressSpec, createEditor, decompressSpec, getDirtyPaths, hasUnsavedChanges, indexSectionSlotContexts, insertNodes, isNormalizing, liftNodes, moveNodes, node, nodes, normalize, normalizeNode, pathRef, pathRefs, removeNodes, setActiveContextPath, setClasses, setHasUnSavedChanges, setNodes, setNormalizing, setProp, setResponsiveStyles, setSelection, shouldNormalize, unsetProp, unsetResponsiveStyles, unwrapNodes, validateCompression, withoutNormalizing, wrapNodes };
|
|
1192
|
+
export type { Ancestor, ArrayCondition, ArrayOperator, BaseEditor, BindableNodeProp, BindableNodePropType, BindingMap, BindingType, BooleanCondition, BooleanOperator, ComparisonOperator, Condition, ConditionBindings, CustomTypes, DateCondition, Descendant, EditorInterface, EditorNodesOptions, EditorNormalizeOptions, EditorPathOptions, EditorPathRefOptions, ExtendedType, ImageCondition, ImageExtensionCondition, ImageExtensionOperator, ImageSizeCondition, InsertNodeOperation, LeafEdge, MaximizeMode, ModularBlockCondition, ModularBlockOperator, MoveNodeOperation, MoveUnit, MultiSelectOperator, NodeAncestorsOptions, NodeEntry, NodeInterface, NodeMatch, NodeOperation, NodeProp, NodePropStaticValueTypes, NodePropType, NodePropTypes, NodePropWithBindingMap, NodePropWithUnknownValue, NodeProps, NodePropsForArray, NodePropsForObject, NodePropsWithBinding, NodePropsWithSlot, NodeStyle, NodeStyles, NumberCondition, OmitFirstArg, OperationInterface, PathAncestorsOptions, PathIndex, PathInterface, PathLevelsOptions, PathNode, PathRefInterface, PathTransformOptions, PropsCompare, PropsMerge, RangeDirection, RangeMode, ReferenceCondition, ReferenceOperator, RemoveNodeOperation, SectionSlotContext, SelectCondition, SelectOperator, SelectionEdge, SelectionMode, SelectionOperation, SetActiveContextPathOperation, SetNodeOperation, SetPropOperation, SetSelectionOperation, SingleSelectOperator, SlotUid, StaticValueNodePropType, StringCondition, StringOperator, SymbolProp, TextDirection, TextUnit, TextUnitAdjustment, UnknownNodePropType, UnsetPropOperation };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAElC,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,YAAY,EACZ,cAAc,EACd,mBAAmB,GACpB,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAElC,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,YAAY,EACZ,cAAc,EACd,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,EACxB,KAAK,kBAAkB,GACxB,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -35,4 +35,5 @@ export { unsetProp } from './transforms-node/unset-props.js';
|
|
|
35
35
|
export { CONDITION_OPERATORS } from './constants/condition.js';
|
|
36
36
|
export { ID_LENGTH } from './constants/id.js';
|
|
37
37
|
export { compressSpec, decompressSpec, validateCompression } from './utils/spec-compression.js';
|
|
38
|
+
export { indexSectionSlotContexts } from './utils/section-slot-walker.js';
|
|
38
39
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../src/interfaces/transforms/general.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,MAAM,EAAQ,SAAS,EAAQ,MAAM,UAAU,CAAC;AAEnE,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,KAAK,MAAM,CAAC;CACtD;
|
|
1
|
+
{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../src/interfaces/transforms/general.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,MAAM,EAAQ,SAAS,EAAQ,MAAM,UAAU,CAAC;AAEnE,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,KAAK,MAAM,CAAC;CACtD;AAyID,eAAO,MAAM,iBAAiB,EAAE,iBAoB/B,CAAC"}
|
|
@@ -8,6 +8,17 @@ const applyToDraft = (editor, selection, op) => {
|
|
|
8
8
|
const { path, node } = op;
|
|
9
9
|
const parent = Node.parent(editor, path);
|
|
10
10
|
const [slot, index] = path[path.length - 1];
|
|
11
|
+
// Defensive: lazily create the slot array if the parent doesn't yet
|
|
12
|
+
// declare it. section-composition nodes don't pre-declare their
|
|
13
|
+
// exposed slots in `props.children` — the slot is identified by a
|
|
14
|
+
// section-slot placeholder inside the section's authored UI — so the
|
|
15
|
+
// page-side parent may be missing the slot key on first drop.
|
|
16
|
+
if (!parent.slots) {
|
|
17
|
+
parent.slots = {};
|
|
18
|
+
}
|
|
19
|
+
if (!parent.slots[slot]) {
|
|
20
|
+
parent.slots[slot] = [];
|
|
21
|
+
}
|
|
11
22
|
if (index > parent.slots[slot].length) {
|
|
12
23
|
throw new Error(`Cannot apply an "insert_node" operation at path [${path}] because the destination is past the end of the node.`);
|
|
13
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"general.js","sources":["../../../src/interfaces/transforms/general.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAUA,MAAM,YAAY,GAAG,CACnB,MAAc,EACd,SAAsB,EACtB,EAAa,KACX;AACF,IAAA,QAAQ,EAAE,CAAC,IAAI;QACb,KAAK,aAAa,EAAE;AAClB,YAAA,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE;YACzB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC;AACxC,YAAA,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"general.js","sources":["../../../src/interfaces/transforms/general.ts"],"sourcesContent":[null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A,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE;AACnB,YAAA,MAAM,CAAC,iBAAiB,GAAG,IAAI;YAC/B;QACF;;AAMF,IAAA,OAAO,SAAS;AAClB,CAAC;AAEM,MAAM,iBAAiB,GAAsB;IAClD,SAAS,CAAC,MAAc,EAAE,EAAa,EAAA;QACrC,MAAM,CAAC,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;AACxC,QAAA,IAAI,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC;AAEjE,QAAA,IAAI;YACF,SAAS,GAAG,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC;QACjD;gBAAU;YACR,MAAM,CAAC,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;YAExC,IAAI,SAAS,EAAE;AACb,gBAAA,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS;AAClC,sBAAE,WAAW,CAAC,SAAS;sBACrB,SAAS;YACf;iBAAO;AACL,gBAAA,MAAM,CAAC,SAAS,GAAG,IAAI;YACzB;QACF;AACA,QAAA,OAAO,MAAM;IACf,CAAC;;;;;"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared section-UI walker for section-slot context resolution.
|
|
3
|
+
*
|
|
4
|
+
* Sections expose `section-slot` placeholders inside their authored UI. When
|
|
5
|
+
* those slots are filled on a page composition, the slot children render
|
|
6
|
+
* inside the section's body — surrounded by whatever Repeater /
|
|
7
|
+
* ConditionBlock chain wraps the matching `section-slot` in the section's
|
|
8
|
+
* authored UI.
|
|
9
|
+
*
|
|
10
|
+
* Three call sites historically each rolled their own walker:
|
|
11
|
+
*
|
|
12
|
+
* - Studio's `findSectionCompositionInstances` (auto-binder) — needs
|
|
13
|
+
* parentRepeaterUid + cumulative schema-path segments for the
|
|
14
|
+
* auto-binder's contextSchemaPath input.
|
|
15
|
+
* - Studio's picker `getRepeatersWrappingSectionSlot` — needs the actual
|
|
16
|
+
* Repeater node references for a SPECIFIC slot (to feed the picker's
|
|
17
|
+
* repeater adapters and to surface the section title as the picker
|
|
18
|
+
* header label).
|
|
19
|
+
* - SDK's `indexSectionInternalSlotRepeaters` — needs only the nearest
|
|
20
|
+
* ancestor Repeater uid per slot, for the per-instance binding seeder.
|
|
21
|
+
*
|
|
22
|
+
* All three did the same walk with different output shapes. This module
|
|
23
|
+
* does the walk ONCE and exposes the raw ancestor-node chain per slot;
|
|
24
|
+
* each consumer derives the shape it needs. Lives in `studio-internal`
|
|
25
|
+
* because that's the only SDK package both Studio and the SDK packages
|
|
26
|
+
* symlink to.
|
|
27
|
+
*/
|
|
28
|
+
export interface SectionSlotContext {
|
|
29
|
+
/**
|
|
30
|
+
* Root→leaf chain of ancestor `repeater` AND `condition-block` nodes
|
|
31
|
+
* wrapping the slot, interleaved in the order they appear in the
|
|
32
|
+
* section's authored tree. Callers can filter by `node.type` if they
|
|
33
|
+
* only need one kind, or walk in order to derive a cumulative
|
|
34
|
+
* schema-path.
|
|
35
|
+
*/
|
|
36
|
+
ancestorNodes: any[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Walks `sectionUI` and returns, for every `section-slot` encountered, the
|
|
40
|
+
* chain of ancestor Repeater and ConditionBlock nodes wrapping it.
|
|
41
|
+
*
|
|
42
|
+
* The returned arrays preserve root→leaf order so callers can either
|
|
43
|
+
* - read the LAST entry as the nearest ancestor (e.g. parentRepeaterUid), or
|
|
44
|
+
* - join their bindings to derive the cumulative schema path.
|
|
45
|
+
*
|
|
46
|
+
* Returns a map keyed by section-slot uid. If a slot uid is missing from the
|
|
47
|
+
* map the slot isn't wrapped by any Repeater / ConditionBlock in the section
|
|
48
|
+
* (or doesn't exist in this section).
|
|
49
|
+
*/
|
|
50
|
+
export declare function indexSectionSlotContexts(sectionUI: any): Record<string, SectionSlotContext>;
|
|
51
|
+
//# sourceMappingURL=section-slot-walker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-slot-walker.d.ts","sourceRoot":"","sources":["../../src/utils/section-slot-walker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,aAAa,EAAE,GAAG,EAAE,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,GAAG,GACb,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAoBpC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared section-UI walker for section-slot context resolution.
|
|
3
|
+
*
|
|
4
|
+
* Sections expose `section-slot` placeholders inside their authored UI. When
|
|
5
|
+
* those slots are filled on a page composition, the slot children render
|
|
6
|
+
* inside the section's body — surrounded by whatever Repeater /
|
|
7
|
+
* ConditionBlock chain wraps the matching `section-slot` in the section's
|
|
8
|
+
* authored UI.
|
|
9
|
+
*
|
|
10
|
+
* Three call sites historically each rolled their own walker:
|
|
11
|
+
*
|
|
12
|
+
* - Studio's `findSectionCompositionInstances` (auto-binder) — needs
|
|
13
|
+
* parentRepeaterUid + cumulative schema-path segments for the
|
|
14
|
+
* auto-binder's contextSchemaPath input.
|
|
15
|
+
* - Studio's picker `getRepeatersWrappingSectionSlot` — needs the actual
|
|
16
|
+
* Repeater node references for a SPECIFIC slot (to feed the picker's
|
|
17
|
+
* repeater adapters and to surface the section title as the picker
|
|
18
|
+
* header label).
|
|
19
|
+
* - SDK's `indexSectionInternalSlotRepeaters` — needs only the nearest
|
|
20
|
+
* ancestor Repeater uid per slot, for the per-instance binding seeder.
|
|
21
|
+
*
|
|
22
|
+
* All three did the same walk with different output shapes. This module
|
|
23
|
+
* does the walk ONCE and exposes the raw ancestor-node chain per slot;
|
|
24
|
+
* each consumer derives the shape it needs. Lives in `studio-internal`
|
|
25
|
+
* because that's the only SDK package both Studio and the SDK packages
|
|
26
|
+
* symlink to.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Walks `sectionUI` and returns, for every `section-slot` encountered, the
|
|
30
|
+
* chain of ancestor Repeater and ConditionBlock nodes wrapping it.
|
|
31
|
+
*
|
|
32
|
+
* The returned arrays preserve root→leaf order so callers can either
|
|
33
|
+
* - read the LAST entry as the nearest ancestor (e.g. parentRepeaterUid), or
|
|
34
|
+
* - join their bindings to derive the cumulative schema path.
|
|
35
|
+
*
|
|
36
|
+
* Returns a map keyed by section-slot uid. If a slot uid is missing from the
|
|
37
|
+
* map the slot isn't wrapped by any Repeater / ConditionBlock in the section
|
|
38
|
+
* (or doesn't exist in this section).
|
|
39
|
+
*/
|
|
40
|
+
function indexSectionSlotContexts(sectionUI) {
|
|
41
|
+
const out = {};
|
|
42
|
+
const walk = (node, ancestors) => {
|
|
43
|
+
if (!node || typeof node !== "object")
|
|
44
|
+
return;
|
|
45
|
+
if (node.type === "section-slot" && typeof node.uid === "string") {
|
|
46
|
+
out[node.uid] = { ancestorNodes: ancestors };
|
|
47
|
+
}
|
|
48
|
+
const nextAncestors = node.type === "repeater" || node.type === "condition-block"
|
|
49
|
+
? [...ancestors, node]
|
|
50
|
+
: ancestors;
|
|
51
|
+
const slots = node.slots || {};
|
|
52
|
+
for (const slotId of Object.keys(slots)) {
|
|
53
|
+
for (const child of slots[slotId] || []) {
|
|
54
|
+
walk(child, nextAncestors);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
walk(sectionUI, []);
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { indexSectionSlotContexts };
|
|
63
|
+
//# sourceMappingURL=section-slot-walker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-slot-walker.js","sources":["../../src/utils/section-slot-walker.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;AAaH;;;;;;;;;;;AAWG;AACG,SAAU,wBAAwB,CACtC,SAAc,EAAA;IAEd,MAAM,GAAG,GAAuC,EAAE;AAClD,IAAA,MAAM,IAAI,GAAG,CAAC,IAAS,EAAE,SAAgB,KAAI;AAC3C,QAAA,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE;AACvC,QAAA,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,IAAI,OAAO,IAAI,CAAC,GAAG,KAAK,QAAQ,EAAE;YAChE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE;QAC9C;AACA,QAAA,MAAM,aAAa,GACjB,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,IAAI,KAAK;AACxC,cAAE,CAAC,GAAG,SAAS,EAAE,IAAI;cACnB,SAAS;AACf,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE;QAC9B,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YACvC,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE;AACvC,gBAAA,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC;YAC5B;QACF;AACF,IAAA,CAAC;AACD,IAAA,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;AACnB,IAAA,OAAO,GAAG;AACZ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/studio-internal",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "This is core package which is a flavour of slate js and consist of all editor functionality",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"homepage": "https://github.com/contentstack/composable-studio-sdk/tree/main/packages/studio-internal#readme",
|
|
@@ -34,22 +34,22 @@
|
|
|
34
34
|
"fflate": "^0.8.2",
|
|
35
35
|
"immer": "^10.1.1",
|
|
36
36
|
"is-plain-object": "^5.0.0",
|
|
37
|
-
"lodash-es": "^4.
|
|
37
|
+
"lodash-es": "^4.18.1",
|
|
38
38
|
"nanoid": "^3.3.11",
|
|
39
39
|
"uuid": "^10.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@contentstack/common-config": "^1.1.
|
|
42
|
+
"@contentstack/common-config": "^1.1.7",
|
|
43
43
|
"@rollup/plugin-commonjs": "^28.0.6",
|
|
44
44
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
45
45
|
"@rollup/plugin-terser": "^1.0.0",
|
|
46
46
|
"@rollup/plugin-typescript": "^12.1.4",
|
|
47
47
|
"@types/lodash-es": "^4.17.12",
|
|
48
48
|
"@types/uuid": "^10.0.0",
|
|
49
|
-
"happy-dom": "^20.
|
|
49
|
+
"happy-dom": "^20.8.9",
|
|
50
50
|
"rollup-plugin-dts": "^6.2.1",
|
|
51
51
|
"rollup-plugin-node-externals": "^8.0.1",
|
|
52
52
|
"rollup-plugin-preserve-directives": "^0.4.0"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "d4e0a1d80b39a2bfa9ac12baa5d4d4a852f4b326"
|
|
55
55
|
}
|