@blokkli/editor 1.4.0-alpha.0 → 1.4.0-alpha.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/module.d.mts +71 -2
- package/dist/module.d.ts +71 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +293 -115
- package/dist/runtime/blokkliPlugins/AddAction/index.vue +1 -1
- package/dist/runtime/blokkliPlugins/DroppableEdit/index.vue +1 -1
- package/dist/runtime/blokkliPlugins/ItemAction/index.vue +1 -1
- package/dist/runtime/blokkliPlugins/MenuButton/index.vue +1 -1
- package/dist/runtime/blokkliPlugins/Sidebar/Detached/index.vue +1 -1
- package/dist/runtime/blokkliPlugins/Sidebar/index.vue +1 -1
- package/dist/runtime/blokkliPlugins/ToolbarButton/index.vue +1 -1
- package/dist/runtime/blokkliPlugins/ViewOption/index.vue +1 -1
- package/dist/runtime/components/Blocks/Fragment/index.vue +7 -4
- package/dist/runtime/components/Blocks/FromLibrary/index.vue +8 -5
- package/dist/runtime/components/BlokkliField.vue +2 -2
- package/dist/runtime/components/BlokkliItem.vue +2 -2
- package/dist/runtime/components/Edit/Actions/index.vue +1 -1
- package/dist/runtime/components/Edit/AddListItem/index.vue +1 -1
- package/dist/runtime/components/Edit/AppMenu/index.vue +1 -1
- package/dist/runtime/components/Edit/BlockProxy/index.vue +3 -5
- package/dist/runtime/components/Edit/Dialog/index.vue +1 -1
- package/dist/runtime/components/Edit/DraggableList.vue +2 -2
- package/dist/runtime/components/Edit/EditIndicator.vue +2 -2
- package/dist/runtime/components/Edit/EditProvider.vue +3 -4
- package/dist/runtime/components/Edit/Features/Artboard/index.vue +9 -8
- package/dist/runtime/components/Edit/Features/BlockAddList/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/Debug/index.vue +2 -2
- package/dist/runtime/components/Edit/Features/Diff/DiffView/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/DraggingOverlay/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/Edit/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/EditForm/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/Fragments/Dialog/Item/index.vue +2 -2
- package/dist/runtime/components/Edit/Features/Fragments/Dialog/index.vue +38 -32
- package/dist/runtime/components/Edit/Features/Library/LibraryDialog/Item/index.vue +13 -6
- package/dist/runtime/components/Edit/Features/Library/LibraryDialog/index.vue +65 -67
- package/dist/runtime/components/Edit/Features/Library/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/MediaLibrary/Library/Item.vue +1 -1
- package/dist/runtime/components/Edit/Features/MediaLibrary/Library/index.vue +3 -11
- package/dist/runtime/components/Edit/Features/MediaLibrary/types.d.ts +1 -1
- package/dist/runtime/components/Edit/Features/Options/Form/index.vue +28 -3
- package/dist/runtime/components/Edit/Features/Options/index.vue +4 -1
- package/dist/runtime/components/Edit/Features/Publish/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/ResponsivePreview/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/Settings/Dialog/FeatureSetting/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/Settings/Dialog/index.vue +3 -3
- package/dist/runtime/components/Edit/Features/Theme/Color/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/Theme/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/Translations/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/index.vue +1 -1
- package/dist/runtime/components/Edit/FormOverlay/Header/index.vue +1 -1
- package/dist/runtime/components/Edit/FormOverlay/index.vue +1 -1
- package/dist/runtime/components/Edit/Icon/index.vue +2 -2
- package/dist/runtime/components/Edit/ItemIcon/index.vue +1 -1
- package/dist/runtime/components/Edit/Pagination/index.vue +21 -0
- package/dist/runtime/components/Edit/PreviewProvider.vue +2 -2
- package/dist/runtime/components/Edit/ScaleToFit/index.vue +37 -6
- package/dist/runtime/components/Edit/index.d.ts +2 -1
- package/dist/runtime/components/Edit/index.js +3 -1
- package/dist/runtime/composables/defineBlokkli.d.ts +2 -2
- package/dist/runtime/composables/defineBlokkli.js +17 -22
- package/dist/runtime/composables/defineBlokkliFeature.d.ts +1 -1
- package/dist/runtime/composables/defineBlokkliFeature.js +1 -1
- package/dist/runtime/composables/defineBlokkliFragment.d.ts +1 -1
- package/dist/runtime/composables/defineBlokkliFragment.js +1 -1
- package/dist/runtime/css/output.css +1 -1
- package/dist/runtime/helpers/domProvider.js +1 -1
- package/dist/runtime/helpers/featuresProvider.d.ts +1 -1
- package/dist/runtime/helpers/featuresProvider.js +1 -1
- package/dist/runtime/helpers/index.d.ts +1 -0
- package/dist/runtime/helpers/index.js +7 -1
- package/dist/runtime/helpers/runtimeHelpers/index.d.ts +23 -2
- package/dist/runtime/helpers/runtimeHelpers/index.js +83 -10
- package/dist/runtime/helpers/storageProvider.js +1 -1
- package/dist/runtime/helpers/textProvider.js +2 -2
- package/dist/runtime/helpers/themeProvider.js +1 -1
- package/dist/runtime/types/index.d.ts +7 -4
- package/package.json +2 -2
- package/dist/runtime/helpers/options.d.ts +0 -2
- package/dist/runtime/helpers/options.js +0 -21
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { cloneElementWithStyles } from "./dom/index.js";
|
|
10
10
|
import onBlokkliEvent from "./composables/onBlokkliEvent.js";
|
|
11
11
|
import useDelayedIntersectionObserver from "./composables/useDelayedIntersectionObserver.js";
|
|
12
|
-
import { getDefinition } from "#blokkli/definitions";
|
|
12
|
+
import { getDefinition } from "#blokkli-build/definitions";
|
|
13
13
|
const buildFieldElement = (element) => {
|
|
14
14
|
const key = element.dataset.fieldKey;
|
|
15
15
|
const name = element.dataset.fieldName;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FeatureDefinition, AdapterMethods } from '#blokkli/types';
|
|
2
|
-
import { type ValidFeatureKey } from '#blokkli-
|
|
2
|
+
import { type ValidFeatureKey } from '#blokkli-build/features';
|
|
3
3
|
import { type ComputedRef } from '#imports';
|
|
4
4
|
import type { StorageProvider } from './storageProvider.js';
|
|
5
5
|
export type FeaturesProvider = {
|
|
@@ -86,3 +86,4 @@ export declare function getInteractionCoordinates(e: MouseEvent | TouchEvent): C
|
|
|
86
86
|
export declare function toShaderColor(rgba: RGB): RGB;
|
|
87
87
|
export declare function generateUUID(): string;
|
|
88
88
|
export declare function buildAttributesForLibraryItem(props: LibraryItemProps): Record<string, string | undefined>;
|
|
89
|
+
export declare function asValidNumber(v: unknown, defaultValue: number): number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { easeOutSine } from "./easing.js";
|
|
2
2
|
import { useRuntimeConfig } from "#imports";
|
|
3
|
-
import { getDefinition } from "#blokkli/definitions";
|
|
3
|
+
import { getDefinition } from "#blokkli-build/definitions";
|
|
4
4
|
export function falsy(value) {
|
|
5
5
|
return value !== null && value !== void 0;
|
|
6
6
|
}
|
|
@@ -474,3 +474,9 @@ export function buildAttributesForLibraryItem(props) {
|
|
|
474
474
|
"data-blokkli-is-reusable": "true"
|
|
475
475
|
};
|
|
476
476
|
}
|
|
477
|
+
export function asValidNumber(v, defaultValue) {
|
|
478
|
+
if (typeof v === "number" && !Number.isNaN(v)) {
|
|
479
|
+
return v;
|
|
480
|
+
}
|
|
481
|
+
return defaultValue;
|
|
482
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This file should contain all helpers that are meant for runtime functionality, such as defineBlokkli composable or <BlokkliProvider>.
|
|
3
3
|
*/
|
|
4
|
-
import type
|
|
4
|
+
import { type RuntimeBlockOptionArray, type RuntimeBlockOptions } from '#blokkli-build/runtime-options';
|
|
5
|
+
import type { FieldListItemTyped } from '#blokkli-build/generated-types';
|
|
5
6
|
import type { BlockOptionDefinition } from '#blokkli/types/blokkOptions';
|
|
6
7
|
import type { FieldListItem } from '#blokkli/types';
|
|
7
8
|
/**
|
|
@@ -14,8 +15,28 @@ export declare function mapCheckboxTrue(v?: unknown): '1' | '0';
|
|
|
14
15
|
*
|
|
15
16
|
* Internally, all option values are stored as strings. This function maps the stored data to the runtime value.
|
|
16
17
|
*/
|
|
17
|
-
export declare function getRuntimeOptionValue(definition: Pick<BlockOptionDefinition, 'type' | 'default'
|
|
18
|
+
export declare function getRuntimeOptionValue(definition: Pick<BlockOptionDefinition, 'type' | 'default'> | RuntimeBlockOptionArray, value: string | string[] | boolean | undefined | null | number): string | string[] | boolean | number;
|
|
18
19
|
/**
|
|
19
20
|
* Determines whether an item is visible.
|
|
20
21
|
*/
|
|
21
22
|
export declare function isVisibleByOptions(item?: FieldListItemTyped | FieldListItem, language?: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the runtime options for a block.
|
|
25
|
+
*
|
|
26
|
+
* If the provided item's bundle is 'from_library', the method will merge the
|
|
27
|
+
* options defined in the reusable block with the options defined in the
|
|
28
|
+
* from_library block.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getRuntimeOptions<K extends keyof RuntimeBlockOptions>(item: FieldListItemTyped & {
|
|
31
|
+
bundle: K;
|
|
32
|
+
}, fromLibraryOptions?: Record<string, any>): RuntimeBlockOptions[K];
|
|
33
|
+
/**
|
|
34
|
+
* Get the actual block for reusable blocks.
|
|
35
|
+
*
|
|
36
|
+
* If the provided bundle is 'from_library', the method will merge the options
|
|
37
|
+
* from both the from_library block and the actual block.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getActualBlock(item: FieldListItemTyped): FieldListItemTyped | null;
|
|
40
|
+
export declare function getItemsforBundles<K extends FieldListItemTyped['bundle']>(items: FieldListItemTyped[], bundles: K[]): Extract<FieldListItemTyped, {
|
|
41
|
+
bundle: K;
|
|
42
|
+
}>[];
|
|
@@ -1,27 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BLOCK_OPTIONS
|
|
3
|
+
} from "#blokkli-build/runtime-options";
|
|
1
4
|
import {
|
|
2
5
|
bundlesWithVisibleLanguage,
|
|
3
6
|
bundlesWithHiddenGlobally
|
|
4
|
-
} from "#blokkli/default-global-options";
|
|
7
|
+
} from "#blokkli-build/default-global-options";
|
|
5
8
|
import { BK_HIDDEN_GLOBALLY, BK_VISIBLE_LANGUAGES } from "../symbols.js";
|
|
6
9
|
export function mapCheckboxTrue(v) {
|
|
7
10
|
return v === true || v === "1" || v === 1 || v === "true" ? "1" : "0";
|
|
8
11
|
}
|
|
9
12
|
export function getRuntimeOptionValue(definition, value) {
|
|
10
|
-
|
|
13
|
+
const type = Array.isArray(definition) ? definition[0] : definition.type;
|
|
14
|
+
const defaultValue = Array.isArray(definition) ? definition[1] : definition.default;
|
|
15
|
+
if (value === null || value === void 0) {
|
|
16
|
+
return defaultValue;
|
|
17
|
+
}
|
|
18
|
+
if (type === "checkbox") {
|
|
11
19
|
return mapCheckboxTrue(value) === "1";
|
|
12
|
-
} else if (
|
|
20
|
+
} else if (type === "radios") {
|
|
13
21
|
if (typeof value === "string") {
|
|
14
22
|
return value;
|
|
15
23
|
}
|
|
16
|
-
|
|
17
|
-
} else if (definition.type === "checkboxes") {
|
|
24
|
+
} else if (type === "checkboxes") {
|
|
18
25
|
if (typeof value === "string") {
|
|
19
26
|
return value.split(",");
|
|
20
27
|
} else if (Array.isArray(value)) {
|
|
21
28
|
return value;
|
|
22
29
|
}
|
|
23
|
-
|
|
24
|
-
} else if (definition.type === "range" || definition.type === "number") {
|
|
30
|
+
} else if (type === "range" || type === "number") {
|
|
25
31
|
if (typeof value === "number" && !Number.isNaN(value)) {
|
|
26
32
|
return value;
|
|
27
33
|
} else if (typeof value === "string") {
|
|
@@ -30,11 +36,18 @@ export function getRuntimeOptionValue(definition, value) {
|
|
|
30
36
|
return parsed;
|
|
31
37
|
}
|
|
32
38
|
}
|
|
33
|
-
}
|
|
34
|
-
|
|
39
|
+
} else if (type === "color") {
|
|
40
|
+
if (typeof value === "string") {
|
|
41
|
+
if (value.startsWith("#")) {
|
|
42
|
+
return value;
|
|
43
|
+
} else if (value.length === 6) {
|
|
44
|
+
return `#${value}`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
} else if (type === "text" && typeof value === "string") {
|
|
35
48
|
return value;
|
|
36
49
|
}
|
|
37
|
-
return
|
|
50
|
+
return defaultValue;
|
|
38
51
|
}
|
|
39
52
|
export function isVisibleByOptions(item, language) {
|
|
40
53
|
if (!item) {
|
|
@@ -56,3 +69,63 @@ export function isVisibleByOptions(item, language) {
|
|
|
56
69
|
}
|
|
57
70
|
return true;
|
|
58
71
|
}
|
|
72
|
+
export function getRuntimeOptions(item, fromLibraryOptions) {
|
|
73
|
+
if (item.bundle === "from_library" && "libraryItem" in item.props) {
|
|
74
|
+
const actualBlock = item.props.libraryItem?.block;
|
|
75
|
+
if (!actualBlock) {
|
|
76
|
+
throw new Error("Missing block");
|
|
77
|
+
}
|
|
78
|
+
return getRuntimeOptions(
|
|
79
|
+
actualBlock,
|
|
80
|
+
item.options
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
const availableOptions = BLOCK_OPTIONS[item.bundle] || {};
|
|
84
|
+
return Object.entries(availableOptions).reduce(
|
|
85
|
+
(acc, [key, definition]) => {
|
|
86
|
+
if (fromLibraryOptions && fromLibraryOptions[key] !== void 0 && fromLibraryOptions[key] !== null) {
|
|
87
|
+
acc[key] = getRuntimeOptionValue(
|
|
88
|
+
definition,
|
|
89
|
+
fromLibraryOptions.value[key]
|
|
90
|
+
);
|
|
91
|
+
return acc;
|
|
92
|
+
}
|
|
93
|
+
if (item.options && item.options[key] !== void 0 && item.options[key] !== null) {
|
|
94
|
+
acc[key] = getRuntimeOptionValue(definition, item.options[key]);
|
|
95
|
+
return acc;
|
|
96
|
+
}
|
|
97
|
+
acc[key] = definition[1];
|
|
98
|
+
return acc;
|
|
99
|
+
},
|
|
100
|
+
{}
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
export function getActualBlock(item) {
|
|
104
|
+
if (item.bundle === "from_library") {
|
|
105
|
+
const block = item.props.libraryItem?.block;
|
|
106
|
+
if (!block) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const mergedOptions = {
|
|
110
|
+
...item.options || {},
|
|
111
|
+
...block.options || {}
|
|
112
|
+
};
|
|
113
|
+
return { ...block, options: mergedOptions };
|
|
114
|
+
}
|
|
115
|
+
return item;
|
|
116
|
+
}
|
|
117
|
+
export function getItemsforBundles(items, bundles) {
|
|
118
|
+
const filtered = [];
|
|
119
|
+
for (let i = 0; i < items.length; i++) {
|
|
120
|
+
const item = items[i];
|
|
121
|
+
if (item.bundle === "from_library") {
|
|
122
|
+
const actual = getActualBlock(item);
|
|
123
|
+
if (actual && bundles.includes(actual.bundle)) {
|
|
124
|
+
filtered.push(actual);
|
|
125
|
+
}
|
|
126
|
+
} else if (bundles.includes(item.bundle)) {
|
|
127
|
+
filtered.push(item);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return filtered;
|
|
131
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
|
-
import { translations } from "#blokkli/translations";
|
|
3
|
-
import { defaultLanguage, forceDefaultLanguage } from "#blokkli/config";
|
|
2
|
+
import { translations } from "#blokkli-build/translations";
|
|
3
|
+
import { defaultLanguage, forceDefaultLanguage } from "#blokkli-build/config";
|
|
4
4
|
export default function(context) {
|
|
5
5
|
const language = computed(() => {
|
|
6
6
|
if (forceDefaultLanguage) {
|
|
@@ -14,10 +14,10 @@ import type { BlockOptionDefinition } from './blokkOptions.js';
|
|
|
14
14
|
import type { BlokkliAdapter, AdapterContext, MutationResponseLike } from './../adapter.js';
|
|
15
15
|
import type { BroadcastProvider } from '#blokkli/helpers/broadcastProvider';
|
|
16
16
|
import type { FeaturesProvider } from '#blokkli/helpers/featuresProvider';
|
|
17
|
-
import type { BlokkliIcon } from '#blokkli/icons';
|
|
17
|
+
import type { BlokkliIcon } from '#blokkli-build/icons';
|
|
18
18
|
import type { SettingsGroup, Viewport } from '#blokkli/constants';
|
|
19
|
-
import type { BlockBundleWithNested, FieldListItemTyped, GlobalOptionsKey, ValidChunkNames, ValidFieldListTypes, ValidGlobalConfigKeys } from '#blokkli/generated-types';
|
|
20
|
-
import type { globalOptions } from '#blokkli/definitions';
|
|
19
|
+
import type { BlockBundleWithNested, FieldListItemTyped, GlobalOptionsKey, ValidChunkNames, ValidFieldListTypes, ValidGlobalConfigKeys } from '#blokkli-build/generated-types';
|
|
20
|
+
import type { globalOptions } from '#blokkli-build/definitions';
|
|
21
21
|
import type { ThemeProvider } from '#blokkli/helpers/themeProvider';
|
|
22
22
|
import type { CommandsProvider } from '#blokkli/helpers/commandsProvider';
|
|
23
23
|
import type { TourProvider } from '#blokkli/helpers/tourProvider';
|
|
@@ -244,7 +244,7 @@ export type BlockDefinitionRenderForFieldListType = {
|
|
|
244
244
|
fieldListType: ValidFieldListTypes;
|
|
245
245
|
};
|
|
246
246
|
export type BlockDefinitionRenderFor = BlockDefinitionRenderForParent | BlockDefinitionRenderForFieldList | BlockDefinitionRenderForFieldListType;
|
|
247
|
-
export type BlockDefinitionInput<Options extends BlockDefinitionOptionsInput = BlockDefinitionOptionsInput, GlobalOptions extends GlobalOptionsKey[] | undefined =
|
|
247
|
+
export type BlockDefinitionInput<Options extends BlockDefinitionOptionsInput = BlockDefinitionOptionsInput, GlobalOptions extends GlobalOptionsKey[] | undefined = []> = {
|
|
248
248
|
/**
|
|
249
249
|
* The bundle ID of the block, e.g. "text" or "section_title".
|
|
250
250
|
*/
|
|
@@ -279,6 +279,9 @@ export type BlockDefinitionInput<Options extends BlockDefinitionOptionsInput = B
|
|
|
279
279
|
*/
|
|
280
280
|
editor?: BlokkliDefinitionInputEditor<Options, GlobalOptions>;
|
|
281
281
|
};
|
|
282
|
+
export type RuntimeBlockDefinitionInput = {
|
|
283
|
+
bundle: string;
|
|
284
|
+
};
|
|
282
285
|
export type InjectedBlokkliItem = ComputedRef<{
|
|
283
286
|
index: ComputedRef<number>;
|
|
284
287
|
uuid: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blokkli/editor",
|
|
3
|
-
"version": "1.4.0-alpha.
|
|
3
|
+
"version": "1.4.0-alpha.1",
|
|
4
4
|
"description": "Interactive page building experience for Nuxt",
|
|
5
5
|
"repository": "blokkli/editor",
|
|
6
6
|
"type": "module",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"eslint-plugin-tailwindcss": "^3.17.4",
|
|
82
82
|
"gettext-parser": "^8.0.0",
|
|
83
83
|
"happy-dom": "^15.7.4",
|
|
84
|
-
"nuxt": "^3.
|
|
84
|
+
"nuxt": "^3.15.4",
|
|
85
85
|
"nuxt-svg-icon-sprite": "^1.0.2",
|
|
86
86
|
"openai": "^4.59.0",
|
|
87
87
|
"playwright-core": "^1.47.0",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export function optionValueToStorable(definition, value) {
|
|
2
|
-
if (definition.type === "checkbox") {
|
|
3
|
-
if (typeof value === "string" && (value === "1" || value === "0")) {
|
|
4
|
-
return value;
|
|
5
|
-
} else if (typeof value === "boolean") {
|
|
6
|
-
return value === true ? "1" : "0";
|
|
7
|
-
}
|
|
8
|
-
return "0";
|
|
9
|
-
} else if (definition.type === "text" || definition.type === "radios") {
|
|
10
|
-
if (typeof value === "string") {
|
|
11
|
-
return value;
|
|
12
|
-
}
|
|
13
|
-
} else if (definition.type === "checkboxes") {
|
|
14
|
-
if (Array.isArray(value)) {
|
|
15
|
-
return value.join(",");
|
|
16
|
-
} else if (typeof value === "string") {
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return "";
|
|
21
|
-
}
|