@nascentdigital/funnel-editor 6.1.0 → 6.1.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/domain/Block.d.ts +2 -2
- package/dist/core/domain/Block.js +16 -1
- package/dist/core/domain/BlockConfiguration.d.ts +3 -1
- package/dist/core/domain/BlockConfiguration.js +33 -1
- package/dist/core/domain/Section.js +5 -19
- package/dist/core/domain/SectionBlock.d.ts +5 -1
- package/dist/core/domain/SectionBlock.js +11 -3
- package/dist/page/components/config/BlockConfigButton.js +1 -2
- package/dist/styles/index.css +8 -8
- package/package.json +2 -2
|
@@ -26,14 +26,14 @@ export declare class Block<TBlock extends Schema.Block = Schema.Block> extends I
|
|
|
26
26
|
get errors(): Block.Errors;
|
|
27
27
|
bind(parentContext: ParentContext): void;
|
|
28
28
|
getConfiguration(): BlockConfiguration;
|
|
29
|
-
getConfig(fieldId: Block.ConfigId<TBlock>): FieldModel;
|
|
29
|
+
getConfig(fieldId: Block.ConfigId<TBlock>): FieldModel.Config;
|
|
30
30
|
setConfig(config: ReadonlyArray<FieldModel.Config>): void;
|
|
31
31
|
getField(fieldId: Block.FieldId<TBlock>): FieldModel;
|
|
32
32
|
getTextField(fieldId: Block.FieldId<TBlock>): Field<Schema.TextField> | undefined;
|
|
33
33
|
repair(): void;
|
|
34
34
|
onSaveStart(): void;
|
|
35
35
|
onSaveComplete(): void;
|
|
36
|
-
clone(forceExists?: boolean): Block;
|
|
36
|
+
clone(forceExists?: boolean, parentContext?: ItemBase.ParentContext): Block;
|
|
37
37
|
protected onActivate(): void;
|
|
38
38
|
protected syncBlockConfig(): void;
|
|
39
39
|
protected onFieldChange(event: Field.Event): void;
|
|
@@ -277,7 +277,7 @@ class Block extends ItemBase_1.ItemBase {
|
|
|
277
277
|
// clear saving flag
|
|
278
278
|
delete this._savingOn;
|
|
279
279
|
}
|
|
280
|
-
clone(forceExists = false) {
|
|
280
|
+
clone(forceExists = false, parentContext) {
|
|
281
281
|
// create block
|
|
282
282
|
const block = new Block({
|
|
283
283
|
key: this.key,
|
|
@@ -288,6 +288,10 @@ class Block extends ItemBase_1.ItemBase {
|
|
|
288
288
|
required: this.required,
|
|
289
289
|
exists: forceExists || this.activated
|
|
290
290
|
});
|
|
291
|
+
// bind parent context
|
|
292
|
+
if (parentContext) {
|
|
293
|
+
block.bind(parentContext);
|
|
294
|
+
}
|
|
291
295
|
// activate it
|
|
292
296
|
if (forceExists) {
|
|
293
297
|
block.onActivate();
|
|
@@ -299,6 +303,17 @@ class Block extends ItemBase_1.ItemBase {
|
|
|
299
303
|
// call base
|
|
300
304
|
super.onActivate();
|
|
301
305
|
this._modifiedOn = Date.now();
|
|
306
|
+
// apply default content if specified
|
|
307
|
+
const { defaultContent } = this.schema;
|
|
308
|
+
if (defaultContent) {
|
|
309
|
+
// opt into array of fields
|
|
310
|
+
if (Array.isArray(defaultContent)) {
|
|
311
|
+
for (const fieldId of defaultContent) {
|
|
312
|
+
const field = this.getField(fieldId);
|
|
313
|
+
field.optIn();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
302
317
|
// pre-populate all fields
|
|
303
318
|
this.fields.forEach(field => {
|
|
304
319
|
// skip if there's an existing value OR it's not required
|
|
@@ -43,14 +43,16 @@ export declare class BlockConfiguration {
|
|
|
43
43
|
get events$(): import("rxjs").Observable<EventBus.Event<string, string>>;
|
|
44
44
|
get valid(): boolean;
|
|
45
45
|
get modified(): boolean;
|
|
46
|
-
getField(fieldId: string): FieldModel;
|
|
46
|
+
getField(fieldId: string): FieldModel.Config;
|
|
47
47
|
getFieldData(fieldId: string): Schema.Field.LinkedData | undefined;
|
|
48
48
|
getEditableField(fieldId: string): FieldModel.Config | undefined;
|
|
49
49
|
save(): void;
|
|
50
50
|
resetToDefault(): void;
|
|
51
51
|
get isConfigInDefault(): boolean | undefined;
|
|
52
|
+
setLayout(layout: PanelLayout): void;
|
|
52
53
|
sync(): void;
|
|
53
54
|
reset(): void;
|
|
55
|
+
private setConfigValues;
|
|
54
56
|
private raiseEvent;
|
|
55
57
|
}
|
|
56
58
|
export declare namespace BlockConfiguration {
|
|
@@ -398,6 +398,30 @@ class BlockConfiguration {
|
|
|
398
398
|
get isConfigInDefault() {
|
|
399
399
|
return this._isConfigInDefault;
|
|
400
400
|
}
|
|
401
|
+
setLayout(layout) {
|
|
402
|
+
var _a;
|
|
403
|
+
// bail if no layout field (shouldn't happen)
|
|
404
|
+
const { block, layoutField } = this;
|
|
405
|
+
if (!layoutField) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
// bail if no change in layout
|
|
409
|
+
const previousLayout = (_a = layoutField.value) === null || _a === void 0 ? void 0 : _a.value;
|
|
410
|
+
if (previousLayout === layout) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
// update layout if different
|
|
414
|
+
layoutField.value = funnel_core_1.Schema.EnumField.Value.toData(layout);
|
|
415
|
+
// finish here if no layout change
|
|
416
|
+
if (!block.schema.defaultLayoutConfigs) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
// set config for layout
|
|
420
|
+
const configForLayout = block.schema.defaultLayoutConfigs[layout];
|
|
421
|
+
if (configForLayout) {
|
|
422
|
+
this.setConfigValues(configForLayout);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
401
425
|
sync() {
|
|
402
426
|
var _a;
|
|
403
427
|
// recompute the editable fields
|
|
@@ -411,7 +435,7 @@ class BlockConfiguration {
|
|
|
411
435
|
const blockSchema = block.schema;
|
|
412
436
|
const { getConfig, getLayout } = blockSchema;
|
|
413
437
|
const { updatedConfig = configData, updatedConfigSchema = blockSchema.config, defaultConfig = {} } = getConfig
|
|
414
|
-
? getConfig({
|
|
438
|
+
? getConfig({ config: configData, fields: fieldData, block: block.schema })
|
|
415
439
|
: {};
|
|
416
440
|
// create new config fields
|
|
417
441
|
const configFields = fields
|
|
@@ -481,6 +505,14 @@ class BlockConfiguration {
|
|
|
481
505
|
// force sync
|
|
482
506
|
this.sync();
|
|
483
507
|
}
|
|
508
|
+
setConfigValues(config) {
|
|
509
|
+
Object.entries(config).forEach(([fieldId, value]) => {
|
|
510
|
+
const field = this.getEditableField(fieldId);
|
|
511
|
+
if (field) {
|
|
512
|
+
field.value = funnel_core_1.Schema.Field.Data.ForSimpleType.fromValue(field.schema, value);
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
}
|
|
484
516
|
raiseEvent(type) {
|
|
485
517
|
this.eventBus.publish(BlockConfiguration.Event.create({ type, configuration: this }));
|
|
486
518
|
}
|
|
@@ -7,7 +7,7 @@ const SectionBlock_1 = require("./SectionBlock");
|
|
|
7
7
|
// class
|
|
8
8
|
class Section extends ItemBase_1.ItemBase {
|
|
9
9
|
constructor(args) {
|
|
10
|
-
var _a;
|
|
10
|
+
var _a, _b;
|
|
11
11
|
// construct base
|
|
12
12
|
super(args);
|
|
13
13
|
// initialize instance variables
|
|
@@ -15,21 +15,7 @@ class Section extends ItemBase_1.ItemBase {
|
|
|
15
15
|
this.availableBlocks = args.availableBlocks;
|
|
16
16
|
this._initialBlocks = args.blocks;
|
|
17
17
|
// use existing blocks
|
|
18
|
-
|
|
19
|
-
if (blocks) {
|
|
20
|
-
this._blocks = blocks;
|
|
21
|
-
}
|
|
22
|
-
// or force presets
|
|
23
|
-
else {
|
|
24
|
-
// find preset in schema (or throw - should never happen)
|
|
25
|
-
const presets = this.schema.preset;
|
|
26
|
-
// bind blocks
|
|
27
|
-
const { availableBlocks } = this;
|
|
28
|
-
this._blocks = presets
|
|
29
|
-
.map(key => availableBlocks.find(block => block.key === key))
|
|
30
|
-
.filter(funnel_core_1.Value.isDefined)
|
|
31
|
-
.map(SectionBlock_1.SectionBlock.for);
|
|
32
|
-
}
|
|
18
|
+
this._blocks = (_b = (_a = args.blocks) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : [];
|
|
33
19
|
// mark as activated
|
|
34
20
|
this.activated = true;
|
|
35
21
|
}
|
|
@@ -91,12 +77,12 @@ class Section extends ItemBase_1.ItemBase {
|
|
|
91
77
|
if (!blockTemplate) {
|
|
92
78
|
throw new funnel_core_1.ArgumentError(`Unable to find block matching "${identifier}"`);
|
|
93
79
|
}
|
|
80
|
+
// parent context for block to create
|
|
81
|
+
const parentContext = { parent: this, area: this.area };
|
|
94
82
|
// create new section block
|
|
95
|
-
const block = SectionBlock_1.SectionBlock.for(blockTemplate);
|
|
83
|
+
const block = SectionBlock_1.SectionBlock.for({ block: blockTemplate, parentContext });
|
|
96
84
|
this._blocks.push(block);
|
|
97
85
|
this._modifiedOn = Date.now();
|
|
98
|
-
// bind block
|
|
99
|
-
block.bind({ parent: this, area: this.area });
|
|
100
86
|
// raise change
|
|
101
87
|
this.raiseEvent('changed');
|
|
102
88
|
// return block
|
|
@@ -26,7 +26,7 @@ export declare class SectionBlock<TBlock extends Schema.Block = Schema.Block> ex
|
|
|
26
26
|
getConfiguration(): BlockConfiguration;
|
|
27
27
|
bind(parentContext: ItemBase.ParentContext): void;
|
|
28
28
|
repair(): void;
|
|
29
|
-
static for(block:
|
|
29
|
+
static for({ block, parentContext }: SectionBlock.ForArgs): SectionBlock<Schema.Block<string, any, any>>;
|
|
30
30
|
}
|
|
31
31
|
export declare namespace SectionBlock {
|
|
32
32
|
type Id = Tagged<string, 'SectionBlock.Id'>;
|
|
@@ -34,4 +34,8 @@ export declare namespace SectionBlock {
|
|
|
34
34
|
id: string;
|
|
35
35
|
block: Block<TBlock>;
|
|
36
36
|
};
|
|
37
|
+
type ForArgs = {
|
|
38
|
+
block: Block;
|
|
39
|
+
parentContext: ItemBase.ParentContext;
|
|
40
|
+
};
|
|
37
41
|
}
|
|
@@ -79,15 +79,23 @@ class SectionBlock extends ItemBase_1.ItemBase {
|
|
|
79
79
|
// repair all blocks
|
|
80
80
|
this.block.repair();
|
|
81
81
|
}
|
|
82
|
-
static for(block) {
|
|
83
|
-
|
|
82
|
+
static for({ block, parentContext }) {
|
|
83
|
+
// create section block
|
|
84
|
+
const sectionBlock = new SectionBlock({
|
|
84
85
|
id: funnel_core_1.Value.uuid(),
|
|
85
86
|
key: block.key,
|
|
86
87
|
eventBus: block.eventBus,
|
|
87
|
-
block: block.clone(
|
|
88
|
+
block: block.clone(),
|
|
88
89
|
required: block.required,
|
|
89
90
|
exists: true
|
|
90
91
|
});
|
|
92
|
+
// bind parent context
|
|
93
|
+
sectionBlock.bind(parentContext);
|
|
94
|
+
// active block
|
|
95
|
+
// important that we activate after parent context bound
|
|
96
|
+
sectionBlock.block.activated = true;
|
|
97
|
+
// return
|
|
98
|
+
return sectionBlock;
|
|
91
99
|
}
|
|
92
100
|
}
|
|
93
101
|
exports.SectionBlock = SectionBlock;
|
|
@@ -68,9 +68,8 @@ function BlockConfigButton({ target, anchorId: anchorOverrideId, children = 'Con
|
|
|
68
68
|
})),
|
|
69
69
|
selectedItem: layoutData === null || layoutData === void 0 ? void 0 : layoutData.value
|
|
70
70
|
}));
|
|
71
|
-
// update if something was picked
|
|
72
71
|
if (selectedLayout) {
|
|
73
|
-
|
|
72
|
+
configuration.setLayout(selectedLayout);
|
|
74
73
|
}
|
|
75
74
|
};
|
|
76
75
|
// set variables
|
package/dist/styles/index.css
CHANGED
|
@@ -501,10 +501,10 @@ video {
|
|
|
501
501
|
}
|
|
502
502
|
|
|
503
503
|
[popover]{
|
|
504
|
-
inset: var(--toolwind-toggle-
|
|
505
|
-
background-color: var(--toolwind-toggle-
|
|
506
|
-
color: var(--toolwind-toggle-
|
|
507
|
-
margin: var(--toolwind-toggle-
|
|
504
|
+
inset: var(--toolwind-toggle-l0VgWy4h96, 0px);
|
|
505
|
+
background-color: var(--toolwind-toggle-G3M0LEAkEw, canvas);
|
|
506
|
+
color: var(--toolwind-toggle-OZJudeW1l9, canvastext);
|
|
507
|
+
margin: var(--toolwind-toggle-pXB34ljAOh, auto);
|
|
508
508
|
}
|
|
509
509
|
html, body, #__next, #root, .Editor-wrap{
|
|
510
510
|
position: relative;
|
|
@@ -6012,10 +6012,10 @@ img.nd-Visual-image {
|
|
|
6012
6012
|
.anchored\/\[--nd-popup-anchor\]:where(.anchored\/\[--nd-popup-anchor\]){
|
|
6013
6013
|
position: absolute;
|
|
6014
6014
|
view-transition-name: --tw-anchor-view-transition-2j1919322s193433343934192p322r2w33362l;
|
|
6015
|
-
--toolwind-toggle-
|
|
6016
|
-
--toolwind-toggle-
|
|
6017
|
-
--toolwind-toggle-
|
|
6018
|
-
--toolwind-toggle-
|
|
6015
|
+
--toolwind-toggle-l0VgWy4h96: auto;
|
|
6016
|
+
--toolwind-toggle-G3M0LEAkEw: transparent;
|
|
6017
|
+
--toolwind-toggle-OZJudeW1l9: inherit;
|
|
6018
|
+
--toolwind-toggle-pXB34ljAOh: 0px;
|
|
6019
6019
|
}
|
|
6020
6020
|
.counter-l1{
|
|
6021
6021
|
counter-reset: l1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nascentdigital/funnel-editor",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"ts-jest": "^29",
|
|
93
93
|
"type-fest": "^4"
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "697c3651dedb43a6e6ff373a495cb29c7e7e1fc6"
|
|
96
96
|
}
|