@blokkli/editor 2.0.0-alpha.21 → 2.0.0-alpha.23
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.json +1 -1
- package/dist/module.mjs +97 -169
- package/dist/runtime/blokkliPlugins/MenuButton/index.vue +3 -1
- package/dist/runtime/blokkliPlugins/Sidebar/Detached/index.vue +20 -14
- package/dist/runtime/blokkliPlugins/Sidebar/Detached/index.vue.d.ts +8 -4
- package/dist/runtime/blokkliPlugins/Sidebar/index.vue +55 -25
- package/dist/runtime/blokkliPlugins/Sidebar/index.vue.d.ts +4 -3
- package/dist/runtime/blokkliPlugins/ToolbarButton/index.vue +4 -1
- package/dist/runtime/blokkliPlugins/ViewOption/index.vue +3 -1
- package/dist/runtime/blokkliPlugins/index.d.ts +1 -3
- package/dist/runtime/blokkliPlugins/index.js +0 -4
- package/dist/runtime/components/Blocks/FromLibrary/index.vue +0 -5
- package/dist/runtime/components/BlokkliEditable.vue +6 -1
- package/dist/runtime/components/BlokkliField.vue +1 -1
- package/dist/runtime/components/BlokkliProvider.vue +4 -4
- package/dist/runtime/components/Edit/Actions/ItemDropdown.vue +66 -0
- package/dist/runtime/components/Edit/Actions/ItemDropdown.vue.d.ts +6 -0
- package/dist/runtime/components/Edit/Actions/index.vue +7 -49
- package/dist/runtime/components/Edit/AnimationCanvas/index.vue +23 -68
- package/dist/runtime/components/Edit/BlockProxy/index.vue +2 -8
- package/dist/runtime/components/Edit/BlokkliErrorBoundary.vue +33 -49
- package/dist/runtime/components/Edit/BlokkliErrorBoundary.vue.d.ts +14 -1
- package/dist/runtime/components/Edit/BlokkliRootErrorBoundary.vue +93 -0
- package/dist/runtime/components/Edit/BlokkliRootErrorBoundary.vue.d.ts +12 -0
- package/dist/runtime/components/Edit/DraggableList.vue +5 -25
- package/dist/runtime/components/Edit/EditProvider.vue +24 -11
- package/dist/runtime/components/Edit/Features/{BlockAddList → AddList/Blocks}/index.vue +26 -62
- package/dist/runtime/components/Edit/Features/{Hover/Overlay → AddList/Blocks}/index.vue.d.ts +2 -2
- package/dist/runtime/components/Edit/Features/AddList/index.vue +29 -8
- package/dist/runtime/components/Edit/Features/Analyze/{Renderer.vue → Main.vue} +4 -8
- package/dist/runtime/components/Edit/Features/Analyze/{Overlay → Renderer}/fragment.glsl +10 -6
- package/dist/runtime/components/Edit/Features/Analyze/{Overlay → Renderer}/index.vue +43 -15
- package/dist/runtime/components/Edit/Features/Analyze/{Overlay → Renderer}/index.vue.d.ts +0 -2
- package/dist/runtime/components/Edit/Features/Analyze/{Overlay → Renderer}/vertex.glsl +11 -9
- package/dist/runtime/components/Edit/Features/Analyze/Results/ResultsItemNodesTarget.vue +15 -3
- package/dist/runtime/components/Edit/Features/Analyze/analyzers/helpers/collectTextElements.js +3 -0
- package/dist/runtime/components/Edit/Features/Analyze/index.vue +7 -3
- package/dist/runtime/components/Edit/Features/Anchors/index.vue +2 -2
- package/dist/runtime/components/Edit/Features/Clipboard/List/index.vue +21 -10
- package/dist/runtime/components/Edit/Features/Clipboard/index.vue +18 -11
- package/dist/runtime/components/Edit/Features/Conversions/index.vue +16 -9
- package/dist/runtime/components/Edit/Features/Debug/DebugSection.vue +24 -0
- package/dist/runtime/components/Edit/Features/Debug/DebugSection.vue.d.ts +16 -0
- package/dist/runtime/components/Edit/Features/Debug/Main.vue +80 -0
- package/dist/runtime/components/Edit/Features/Debug/Section/Features.vue +34 -0
- package/dist/runtime/components/Edit/Features/Debug/Section/Icons.vue +15 -0
- package/dist/runtime/components/Edit/Features/Debug/Section/Icons.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Debug/Section/Keyboard.vue +17 -0
- package/dist/runtime/components/Edit/Features/Debug/Section/Keyboard.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Debug/Section/Logging.vue +66 -0
- package/dist/runtime/components/Edit/Features/{Selection/OverlayFallback/index.vue.d.ts → Debug/Section/Logging.vue.d.ts} +2 -1
- package/dist/runtime/components/Edit/Features/Debug/Section/Rendering.vue +96 -0
- package/dist/runtime/components/Edit/Features/Debug/Section/Rendering.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Debug/Section/Selection.vue +25 -0
- package/dist/runtime/components/Edit/Features/Debug/Section/Selection.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Debug/index.vue +2 -2
- package/dist/runtime/components/Edit/Features/DraggingOverlay/DragItems/index.vue +20 -27
- package/dist/runtime/components/Edit/Features/DraggingOverlay/Renderer/fragment.glsl +80 -0
- package/dist/runtime/components/Edit/Features/DraggingOverlay/{DropTargets → Renderer}/index.vue +100 -87
- package/dist/runtime/components/Edit/Features/DraggingOverlay/{DropTargets → Renderer}/vertex.glsl +51 -8
- package/dist/runtime/components/Edit/Features/DraggingOverlay/index.vue +3 -3
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue +0 -6
- package/dist/runtime/components/Edit/Features/EditableField/index.vue +6 -2
- package/dist/runtime/components/Edit/Features/Fragments/Dialog/Item/index.vue +1 -5
- package/dist/runtime/components/Edit/Features/Hover/Renderer/fragment.glsl +141 -0
- package/dist/runtime/components/Edit/Features/Hover/{Overlay → Renderer}/index.vue +225 -38
- package/dist/runtime/components/Edit/Features/Hover/Renderer/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Hover/{Overlay → Renderer}/vertex.glsl +49 -11
- package/dist/runtime/components/Edit/Features/Hover/index.vue +9 -6
- package/dist/runtime/components/Edit/Features/Library/LibraryDialog/Item/index.vue +1 -5
- package/dist/runtime/components/Edit/Features/Library/index.vue +24 -12
- package/dist/runtime/components/Edit/Features/MediaLibrary/Library/Item.vue +1 -1
- package/dist/runtime/components/Edit/Features/MediaLibrary/Library/index.vue +26 -13
- package/dist/runtime/components/Edit/Features/MediaLibrary/Library/index.vue.d.ts +0 -1
- package/dist/runtime/components/Edit/Features/MediaLibrary/index.vue +3 -47
- package/dist/runtime/components/Edit/Features/MultiSelect/{Overlay → Renderer}/fragment.glsl +13 -26
- package/dist/runtime/components/Edit/Features/MultiSelect/{Overlay → Renderer}/index.vue +130 -72
- package/dist/runtime/components/Edit/Features/MultiSelect/{Overlay → Renderer}/index.vue.d.ts +0 -1
- package/dist/runtime/components/Edit/Features/MultiSelect/{Overlay → Renderer}/vertex.glsl +27 -2
- package/dist/runtime/components/Edit/Features/MultiSelect/index.vue +25 -12
- package/dist/runtime/components/Edit/Features/Ownership/index.vue +2 -2
- package/dist/runtime/components/Edit/Features/ResponsivePreview/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Content/index.vue +23 -6
- package/dist/runtime/components/Edit/Features/Selection/AddButtons/Overlay/index.vue.d.ts +2 -2
- package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/fragment.glsl +19 -17
- package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/index.vue +242 -131
- package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/vertex.glsl +29 -12
- package/dist/runtime/components/Edit/Features/Selection/AddButtons/index.vue +12 -4
- package/dist/runtime/components/Edit/Features/Selection/{Overlay → Renderer}/fragment.glsl +23 -14
- package/dist/runtime/components/Edit/Features/Selection/{Overlay → Renderer}/index.vue +121 -28
- package/dist/runtime/components/Edit/Features/Selection/{Overlay → Renderer}/index.vue.d.ts +0 -2
- package/dist/runtime/components/Edit/Features/Selection/{Overlay → Renderer}/vertex.glsl +23 -14
- package/dist/runtime/components/Edit/Features/Selection/index.vue +46 -59
- package/dist/runtime/components/Edit/Features/Transform/Dialog/index.vue +5 -5
- package/dist/runtime/components/Edit/Features/Transform/index.vue +29 -22
- package/dist/runtime/components/Edit/Form/Checkboxes/index.vue +43 -0
- package/dist/runtime/components/Edit/Form/Checkboxes/index.vue.d.ts +20 -0
- package/dist/runtime/components/Edit/Messages/Item/index.vue.d.ts +1 -1
- package/dist/runtime/components/Edit/PreviewProvider.vue +1 -1
- package/dist/runtime/components/Edit/Sortli/index.vue +5 -8
- package/dist/runtime/components/Edit/Sortli/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Toolbar/index.vue +1 -4
- package/dist/runtime/components/Edit/ViewportBlockingRect/index.vue +9 -2
- package/dist/runtime/components/Edit/ViewportBlockingRect/index.vue.d.ts +4 -1
- package/dist/runtime/components/Edit/index.d.ts +6 -4
- package/dist/runtime/components/Edit/index.js +11 -7
- package/dist/runtime/css/output.css +1 -1
- package/dist/runtime/helpers/animationProvider.d.ts +58 -9
- package/dist/runtime/helpers/animationProvider.js +318 -75
- package/dist/runtime/helpers/composables/defineItemDropdownAction.d.ts +2 -0
- package/dist/runtime/helpers/composables/defineItemDropdownAction.js +10 -0
- package/dist/runtime/helpers/composables/defineRenderer.d.ts +5 -2
- package/dist/runtime/helpers/composables/defineRenderer.js +3 -2
- package/dist/runtime/helpers/composables/useGlobalBlokkliObject.d.ts +16 -0
- package/dist/runtime/helpers/composables/useGlobalBlokkliObject.js +36 -0
- package/dist/runtime/helpers/debugProvider.d.ts +13 -3
- package/dist/runtime/helpers/debugProvider.js +80 -12
- package/dist/runtime/helpers/domProvider.js +46 -32
- package/dist/runtime/helpers/dropTargets/index.js +1 -1
- package/dist/runtime/helpers/eventBus.d.ts +1 -1
- package/dist/runtime/helpers/index.d.ts +1 -6
- package/dist/runtime/helpers/index.js +0 -81
- package/dist/runtime/helpers/pluginProvider.d.ts +16 -0
- package/dist/runtime/helpers/pluginProvider.js +30 -1
- package/dist/runtime/helpers/providers/directive.d.ts +4 -1
- package/dist/runtime/helpers/providers/directive.js +9 -2
- package/dist/runtime/helpers/stateProvider.js +1 -0
- package/dist/runtime/helpers/uiProvider.d.ts +5 -1
- package/dist/runtime/helpers/uiProvider.js +41 -7
- package/dist/runtime/helpers/webgl/index.d.ts +2 -3
- package/dist/runtime/helpers/webgl/index.js +9 -14
- package/dist/runtime/icons/dock-left.svg +1 -0
- package/dist/runtime/icons/dock-right.svg +1 -0
- package/dist/runtime/icons/dock-window.svg +1 -0
- package/dist/runtime/plugins/blokkliDirectives.js +1 -1
- package/dist/runtime/types/index.d.ts +4 -21
- package/package.json +1 -1
- package/dist/runtime/blokkliPlugins/DroppableEdit/index.vue +0 -56
- package/dist/runtime/blokkliPlugins/DroppableEdit/index.vue.d.ts +0 -24
- package/dist/runtime/blokkliPlugins/ItemDropdown/index.vue +0 -76
- package/dist/runtime/blokkliPlugins/ItemDropdown/index.vue.d.ts +0 -31
- package/dist/runtime/components/Edit/Features/BlockAddList/docs.md +0 -15
- package/dist/runtime/components/Edit/Features/Debug/Renderer.vue +0 -240
- package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/fragment.glsl +0 -96
- package/dist/runtime/components/Edit/Features/Hover/Overlay/fragment.glsl +0 -139
- package/dist/runtime/components/Edit/Features/Selection/OverlayFallback/index.vue +0 -42
- /package/dist/runtime/components/Edit/Features/Analyze/{Renderer.vue.d.ts → Main.vue.d.ts} +0 -0
- /package/dist/runtime/components/Edit/Features/Anchors/{Renderer.vue → Overlay/index.vue} +0 -0
- /package/dist/runtime/components/Edit/Features/{BlockAddList → Anchors/Overlay}/index.vue.d.ts +0 -0
- /package/dist/runtime/components/Edit/Features/Debug/{Renderer.vue.d.ts → Main.vue.d.ts} +0 -0
- /package/dist/runtime/components/Edit/Features/{Anchors/Renderer.vue.d.ts → Debug/Section/Features.vue.d.ts} +0 -0
- /package/dist/runtime/components/Edit/Features/DraggingOverlay/{DropTargets → Renderer}/index.vue.d.ts +0 -0
- /package/dist/runtime/components/Edit/Features/Ownership/{Renderer.vue → Banner/index.vue} +0 -0
- /package/dist/runtime/components/Edit/Features/Ownership/{Renderer.vue.d.ts → Banner/index.vue.d.ts} +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export function useGlobalBlokkliObject() {
|
|
2
|
+
function init() {
|
|
3
|
+
if (typeof window !== "undefined") {
|
|
4
|
+
if (!window.__BLOKKLI__) {
|
|
5
|
+
window.__BLOKKLI__ = {
|
|
6
|
+
messages: []
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function pushMessage(message) {
|
|
12
|
+
if (typeof window !== "undefined" && window.__BLOKKLI__) {
|
|
13
|
+
window.__BLOKKLI__.messages.push(message);
|
|
14
|
+
if (window.__BLOKKLI__.messages.length > 1e3) {
|
|
15
|
+
window.__BLOKKLI__.messages = window.__BLOKKLI__.messages.slice(-1e3);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function getMessages() {
|
|
20
|
+
if (typeof window !== "undefined" && window.__BLOKKLI__) {
|
|
21
|
+
return window.__BLOKKLI__.messages;
|
|
22
|
+
}
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
function cleanup() {
|
|
26
|
+
if (typeof window !== "undefined") {
|
|
27
|
+
delete window.__BLOKKLI__;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
init,
|
|
32
|
+
pushMessage,
|
|
33
|
+
getMessages,
|
|
34
|
+
cleanup
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import type { StorageProvider } from './storageProvider.js';
|
|
2
2
|
import { type ComputedRef } from '#imports';
|
|
3
3
|
export type DebugLogger = {
|
|
4
|
-
log: (...v: any) => void;
|
|
5
|
-
error: (...v: any) => void;
|
|
4
|
+
log: (message: string, ...v: any) => void;
|
|
5
|
+
error: (message: string, ...v: any) => void;
|
|
6
|
+
};
|
|
7
|
+
export type LogMessage = {
|
|
8
|
+
type: 'log' | 'error' | 'event';
|
|
9
|
+
name: string;
|
|
10
|
+
date: string;
|
|
11
|
+
message: string;
|
|
12
|
+
context?: string;
|
|
6
13
|
};
|
|
7
14
|
type RegisteredDebugOverlay = {
|
|
8
15
|
id: string;
|
|
@@ -12,12 +19,15 @@ type RegisteredDebugOverlay = {
|
|
|
12
19
|
export type DebugProvider = {
|
|
13
20
|
isEnabled: ComputedRef<boolean>;
|
|
14
21
|
toggle: () => void;
|
|
15
|
-
log: (...v: any) => void;
|
|
16
22
|
createLogger: (name: string) => DebugLogger;
|
|
17
23
|
registerOverlay: (id: string, label: string) => void;
|
|
18
24
|
unregisterOverlay: (id: string) => void;
|
|
19
25
|
overlays: ComputedRef<RegisteredDebugOverlay[]>;
|
|
20
26
|
toggleOverlay: (id: string) => void;
|
|
27
|
+
registeredLoggers: ComputedRef<string[]>;
|
|
28
|
+
enabledLoggers: ComputedRef<string[]>;
|
|
29
|
+
toggleLogger: (name: string) => void;
|
|
30
|
+
getMessages: () => LogMessage[];
|
|
21
31
|
};
|
|
22
32
|
export default function (storage: StorageProvider): DebugProvider;
|
|
23
33
|
export {};
|
|
@@ -1,31 +1,83 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
onBeforeUnmount,
|
|
4
|
+
onMounted,
|
|
5
|
+
ref
|
|
6
|
+
} from "#imports";
|
|
7
|
+
import { eventBus } from "./eventBus.js";
|
|
8
|
+
import { useGlobalBlokkliObject } from "./composables/useGlobalBlokkliObject.js";
|
|
2
9
|
export default function(storage) {
|
|
3
10
|
const showDebug = storage.use("showDebug", false);
|
|
4
11
|
const visible = storage.use("visibleDebugOverlays", []);
|
|
12
|
+
const enabledLoggers = storage.use("enabledDebugLoggers", []);
|
|
5
13
|
const registeredOverlays = ref([]);
|
|
14
|
+
const registeredLoggers = ref([]);
|
|
15
|
+
const globalBlokkli = useGlobalBlokkliObject();
|
|
16
|
+
globalBlokkli.init();
|
|
6
17
|
const isEnabled = computed(() => showDebug.value);
|
|
7
18
|
function toggle() {
|
|
8
19
|
showDebug.value = !showDebug.value;
|
|
9
20
|
}
|
|
10
|
-
function
|
|
11
|
-
if (
|
|
21
|
+
function argToString(arg) {
|
|
22
|
+
if (arg === null) return "null";
|
|
23
|
+
if (arg === void 0) return "undefined";
|
|
24
|
+
if (typeof arg === "string") return arg;
|
|
25
|
+
if (typeof arg === "number") return String(arg);
|
|
26
|
+
if (typeof arg === "boolean") return String(arg);
|
|
27
|
+
if (arg instanceof Error) return arg.stack || arg.message;
|
|
28
|
+
try {
|
|
29
|
+
return JSON.stringify(arg, null, 2);
|
|
30
|
+
} catch {
|
|
31
|
+
return String(arg);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const onEvent = (name, data) => {
|
|
35
|
+
if (name === "animationFrame" || name === "animationFrame:before" || name === "animationFrame:after" || name === "canvas:draw" || name === "updateMutatedFields") {
|
|
12
36
|
return;
|
|
13
37
|
}
|
|
14
|
-
|
|
38
|
+
globalBlokkli.pushMessage({
|
|
39
|
+
type: "event",
|
|
40
|
+
name: String(name),
|
|
41
|
+
date: (/* @__PURE__ */ new Date()).toISOString(),
|
|
42
|
+
message: data !== void 0 && data !== null ? argToString(data) : ""
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
function shouldLog(name) {
|
|
46
|
+
if (!showDebug.value) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (enabledLoggers.value.length === 0) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return enabledLoggers.value.includes(name);
|
|
15
53
|
}
|
|
16
54
|
function createLogger(name) {
|
|
55
|
+
if (!registeredLoggers.value.includes(name)) {
|
|
56
|
+
registeredLoggers.value.push(name);
|
|
57
|
+
}
|
|
58
|
+
function pushMessage(type, message, context) {
|
|
59
|
+
globalBlokkli.pushMessage({
|
|
60
|
+
type,
|
|
61
|
+
name,
|
|
62
|
+
date: (/* @__PURE__ */ new Date()).toISOString(),
|
|
63
|
+
message,
|
|
64
|
+
context: context.map(argToString).join(" ")
|
|
65
|
+
});
|
|
66
|
+
}
|
|
17
67
|
return {
|
|
18
|
-
log(...v) {
|
|
19
|
-
|
|
68
|
+
log(message, ...v) {
|
|
69
|
+
pushMessage("log", message, v);
|
|
70
|
+
if (!shouldLog(name)) {
|
|
20
71
|
return;
|
|
21
72
|
}
|
|
22
|
-
console.log(`[${name}]: `, ...v);
|
|
73
|
+
console.log(`[${name}]: ${message}`, ...v);
|
|
23
74
|
},
|
|
24
|
-
error(...v) {
|
|
25
|
-
|
|
75
|
+
error(message, ...v) {
|
|
76
|
+
pushMessage("error", message, v);
|
|
77
|
+
if (!shouldLog(name)) {
|
|
26
78
|
return;
|
|
27
79
|
}
|
|
28
|
-
console.error(`[${name}]: `, ...v);
|
|
80
|
+
console.error(`[${name}]: ${message}`, ...v);
|
|
29
81
|
}
|
|
30
82
|
};
|
|
31
83
|
}
|
|
@@ -52,14 +104,30 @@ export default function(storage) {
|
|
|
52
104
|
visible.value = [...visible.value, id];
|
|
53
105
|
}
|
|
54
106
|
}
|
|
107
|
+
function toggleLogger(name) {
|
|
108
|
+
if (enabledLoggers.value.includes(name)) {
|
|
109
|
+
enabledLoggers.value = enabledLoggers.value.filter((v) => v !== name);
|
|
110
|
+
} else {
|
|
111
|
+
enabledLoggers.value = [...enabledLoggers.value, name];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
onMounted(() => {
|
|
115
|
+
eventBus.on("*", onEvent);
|
|
116
|
+
});
|
|
117
|
+
onBeforeUnmount(() => {
|
|
118
|
+
eventBus.off("*", onEvent);
|
|
119
|
+
});
|
|
55
120
|
return {
|
|
56
121
|
isEnabled,
|
|
57
122
|
toggle,
|
|
58
|
-
log,
|
|
59
123
|
createLogger,
|
|
60
124
|
registerOverlay,
|
|
61
125
|
unregisterOverlay,
|
|
62
126
|
overlays,
|
|
63
|
-
toggleOverlay
|
|
127
|
+
toggleOverlay,
|
|
128
|
+
registeredLoggers: computed(() => registeredLoggers.value),
|
|
129
|
+
enabledLoggers: computed(() => enabledLoggers.value),
|
|
130
|
+
toggleLogger,
|
|
131
|
+
getMessages: globalBlokkli.getMessages
|
|
64
132
|
};
|
|
65
133
|
}
|
|
@@ -219,19 +219,18 @@ export default function(ui, debug, definitions, state, element) {
|
|
|
219
219
|
if (!el) {
|
|
220
220
|
return "";
|
|
221
221
|
}
|
|
222
|
-
|
|
222
|
+
if ("itemType" in item && item.itemType !== "new") {
|
|
223
|
+
return el.outerHTML;
|
|
224
|
+
}
|
|
223
225
|
const childCount = element.queryAll(
|
|
224
|
-
|
|
226
|
+
el,
|
|
225
227
|
"*",
|
|
226
228
|
"Get child count for drop element markup."
|
|
227
229
|
).length;
|
|
228
230
|
if (checkSize && childCount > 80) {
|
|
229
231
|
return "";
|
|
230
232
|
}
|
|
231
|
-
return cloneElementWithStyles(
|
|
232
|
-
/\sdata-\w+="[^"]*"/g,
|
|
233
|
-
""
|
|
234
|
-
);
|
|
233
|
+
return cloneElementWithStyles(el, true).replace(/\sdata-\w+="[^"]*"/g, "");
|
|
235
234
|
};
|
|
236
235
|
const getVisibleBlocks = () => Array.from(visibleBlocks);
|
|
237
236
|
const getVisibleFields = () => Array.from(visibleFields);
|
|
@@ -254,18 +253,22 @@ export default function(ui, debug, definitions, state, element) {
|
|
|
254
253
|
if (!el) {
|
|
255
254
|
return;
|
|
256
255
|
}
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
256
|
+
const item = state.getFieldListItem(uuid);
|
|
257
|
+
if (!item) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const fieldList = state.getFieldListForBlock(item.uuid);
|
|
261
|
+
if (!fieldList) {
|
|
261
262
|
return;
|
|
262
263
|
}
|
|
264
|
+
const fieldListType = getRegisteredField(fieldList.entityUuid, fieldList.name)?.fieldListType ?? "default";
|
|
265
|
+
const parentBundle = fieldList.entityType === itemEntityType ? state.getFieldListItem(fieldList.entityUuid)?.bundle ?? null : null;
|
|
263
266
|
const observableElement = getElementToObserve(
|
|
264
267
|
uuid,
|
|
265
268
|
el,
|
|
266
|
-
bundle,
|
|
267
|
-
|
|
268
|
-
|
|
269
|
+
item.bundle,
|
|
270
|
+
fieldListType,
|
|
271
|
+
parentBundle
|
|
269
272
|
);
|
|
270
273
|
blockRects[uuid] = rectWithTime(
|
|
271
274
|
ui.getAbsoluteElementRect(
|
|
@@ -315,6 +318,9 @@ export default function(ui, debug, definitions, state, element) {
|
|
|
315
318
|
);
|
|
316
319
|
}
|
|
317
320
|
}
|
|
321
|
+
onBlokkliEvent("state:reload:before", () => {
|
|
322
|
+
observedElementCache.clear();
|
|
323
|
+
});
|
|
318
324
|
onBlokkliEvent("state:reloaded", () => {
|
|
319
325
|
observedElementCache.clear();
|
|
320
326
|
if (stateReloadTimeout) {
|
|
@@ -387,7 +393,7 @@ export default function(ui, debug, definitions, state, element) {
|
|
|
387
393
|
logger.log("registerBlock: " + uuid);
|
|
388
394
|
blockUuidCurrentKey[uuid] = key;
|
|
389
395
|
doInitTimeout();
|
|
390
|
-
if (!el) {
|
|
396
|
+
if (!(el instanceof HTMLElement)) {
|
|
391
397
|
logger.log("registerBlock call unregisterBlock because no element", uuid);
|
|
392
398
|
unregisterBlock(key, uuid);
|
|
393
399
|
return;
|
|
@@ -400,25 +406,33 @@ export default function(ui, debug, definitions, state, element) {
|
|
|
400
406
|
unregisterBlock(key, uuid);
|
|
401
407
|
}
|
|
402
408
|
const item = state.getFieldListItem(uuid);
|
|
403
|
-
if (item) {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
blockElementToUuid.set(observableElement, uuid);
|
|
416
|
-
registeredBlocks[uuid] = el;
|
|
417
|
-
observedElements[uuid] = observableElement;
|
|
418
|
-
intersectionObserver.observe(observableElement);
|
|
419
|
-
resizeObserver.observe(observableElement);
|
|
420
|
-
}
|
|
409
|
+
if (!item) {
|
|
410
|
+
return logger.error(
|
|
411
|
+
"Failed to register block due to missing field list item.",
|
|
412
|
+
uuid
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
const fieldList = state.getFieldListForBlock(item.uuid);
|
|
416
|
+
if (!fieldList) {
|
|
417
|
+
return logger.error(
|
|
418
|
+
"Failed to register block due to missing field list.",
|
|
419
|
+
uuid
|
|
420
|
+
);
|
|
421
421
|
}
|
|
422
|
+
const fieldListType = getRegisteredField(fieldList.entityUuid, fieldList.name)?.fieldListType ?? "default";
|
|
423
|
+
const parentBundle = fieldList.entityType === itemEntityType ? state.getFieldListItem(fieldList.entityUuid)?.bundle ?? null : null;
|
|
424
|
+
const observableElement = getElementToObserve(
|
|
425
|
+
item.uuid,
|
|
426
|
+
el,
|
|
427
|
+
item.bundle,
|
|
428
|
+
fieldListType,
|
|
429
|
+
parentBundle
|
|
430
|
+
);
|
|
431
|
+
blockElementToUuid.set(observableElement, uuid);
|
|
432
|
+
registeredBlocks[uuid] = el;
|
|
433
|
+
observedElements[uuid] = observableElement;
|
|
434
|
+
intersectionObserver.observe(observableElement);
|
|
435
|
+
resizeObserver.observe(observableElement);
|
|
422
436
|
}
|
|
423
437
|
function unregisterBlock(key, uuid) {
|
|
424
438
|
const currentKey = blockUuidCurrentKey[uuid];
|
|
@@ -34,7 +34,7 @@ export function getChildrenOrientation(element) {
|
|
|
34
34
|
export function determineCanAddChildren(field, children, uuids, currentCount, itemsToAdd, draggingBundles) {
|
|
35
35
|
if (field.cardinality !== -1) {
|
|
36
36
|
const childrenThatAreSelection = children.filter((child) => {
|
|
37
|
-
const uuid = child.dataset.
|
|
37
|
+
const uuid = child.dataset.bkUuid;
|
|
38
38
|
if (!uuid) {
|
|
39
39
|
return false;
|
|
40
40
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { EventbusEvents } from '#blokkli/types';
|
|
2
2
|
export declare const eventBus: import("mitt").Emitter<EventbusEvents>;
|
|
3
|
-
export declare const emitMessage: (message: string, type?: "success" | "error", additional?: string | Error | unknown, replace?: boolean) => void;
|
|
3
|
+
export declare const emitMessage: (message: string, type?: "success" | "error" | "warning", additional?: string | Error | unknown, replace?: boolean) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Rectangle, Coord, Size } from '#blokkli/types';
|
|
2
2
|
import type { RGB } from '#blokkli/types/theme';
|
|
3
3
|
/**
|
|
4
4
|
* Type check for falsy values.
|
|
@@ -7,10 +7,6 @@ import type { RGB } from '#blokkli/types/theme';
|
|
|
7
7
|
* items.filter(falsy)
|
|
8
8
|
*/
|
|
9
9
|
export declare function falsy<T>(value: T): value is NonNullable<T>;
|
|
10
|
-
/**
|
|
11
|
-
* Maps a HTML element that is draggable to a draggable item data object.
|
|
12
|
-
*/
|
|
13
|
-
export declare function buildDraggableItem(element: Element | EventTarget): DraggableItem | undefined;
|
|
14
10
|
export declare function onlyUnique(value: string, index: number, self: Array<string>): boolean;
|
|
15
11
|
/**
|
|
16
12
|
* Convert a date to a relative time string, such as
|
|
@@ -81,5 +77,4 @@ export declare function getFieldKey(uuid: string, fieldName: string): string;
|
|
|
81
77
|
export declare function getInteractionCoordinates(e: MouseEvent | TouchEvent): Coord;
|
|
82
78
|
export declare function toShaderColor(rgba: RGB): RGB;
|
|
83
79
|
export declare function generateUUID(): string;
|
|
84
|
-
export declare function buildAttributesForLibraryItem(props: LibraryItemProps): Record<string, string | undefined>;
|
|
85
80
|
export declare function asValidNumber(v: unknown, defaultValue: number): number;
|
|
@@ -2,78 +2,6 @@ import { easeOutSine } from "./easing.js";
|
|
|
2
2
|
export function falsy(value) {
|
|
3
3
|
return value !== null && value !== void 0;
|
|
4
4
|
}
|
|
5
|
-
export function buildDraggableItem(element) {
|
|
6
|
-
if (!(element instanceof HTMLElement)) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
const dataset = element.dataset;
|
|
10
|
-
if (dataset.elementType === "new") {
|
|
11
|
-
const itemBundle = dataset.itemBundle;
|
|
12
|
-
if (itemBundle) {
|
|
13
|
-
return {
|
|
14
|
-
itemType: "new",
|
|
15
|
-
element: () => document.querySelector(
|
|
16
|
-
`[data-sortli-id="${itemBundle}"]`
|
|
17
|
-
),
|
|
18
|
-
itemBundle
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
} else if (dataset.elementType === "action") {
|
|
22
|
-
const actionType = dataset.actionType;
|
|
23
|
-
const itemBundle = dataset.itemBundle;
|
|
24
|
-
if (actionType) {
|
|
25
|
-
return {
|
|
26
|
-
itemType: "action",
|
|
27
|
-
actionType,
|
|
28
|
-
itemBundle,
|
|
29
|
-
element: () => document.querySelector(
|
|
30
|
-
`[data-element-type="action"][data-sortli-id="${actionType}"]`
|
|
31
|
-
)
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
} else if (dataset.elementType === "clipboard") {
|
|
35
|
-
const additional = dataset.clipboardAdditional;
|
|
36
|
-
const itemBundle = dataset.itemBundle;
|
|
37
|
-
const clipboardId = dataset.clipboardId;
|
|
38
|
-
const id = dataset.sortliId;
|
|
39
|
-
if (itemBundle && clipboardId) {
|
|
40
|
-
return {
|
|
41
|
-
itemType: "clipboard",
|
|
42
|
-
element: () => document.querySelector(`[data-sortli-id="${id}"]`),
|
|
43
|
-
itemBundle,
|
|
44
|
-
additional,
|
|
45
|
-
clipboardId
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
} else if (dataset.elementType === "media_library") {
|
|
49
|
-
const mediaId = dataset.mediaId;
|
|
50
|
-
const itemBundle = dataset.itemBundle;
|
|
51
|
-
const mediaBundle = dataset.mediaBundle;
|
|
52
|
-
if (mediaId && itemBundle && mediaBundle) {
|
|
53
|
-
return {
|
|
54
|
-
itemType: "media_library",
|
|
55
|
-
mediaId,
|
|
56
|
-
itemBundle,
|
|
57
|
-
mediaBundle,
|
|
58
|
-
element: () => document.querySelector(
|
|
59
|
-
`[data-element-type="media_library"][data-media-id="${mediaId}"]`
|
|
60
|
-
)
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
} else if (dataset.elementType === "search_content") {
|
|
64
|
-
const searchItemData = dataset.searchItem;
|
|
65
|
-
const id = dataset.sortliId;
|
|
66
|
-
if (searchItemData && id) {
|
|
67
|
-
const searchItem = JSON.parse(searchItemData);
|
|
68
|
-
return {
|
|
69
|
-
itemType: "search_content",
|
|
70
|
-
element: () => document.querySelector(`[data-sortli-id="${id}"]`),
|
|
71
|
-
itemBundle: searchItem.targetBundles[0],
|
|
72
|
-
searchItem
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
5
|
export function onlyUnique(value, index, self) {
|
|
78
6
|
return self.indexOf(value) === index;
|
|
79
7
|
}
|
|
@@ -399,15 +327,6 @@ export function generateUUID() {
|
|
|
399
327
|
return (c == "x" ? r : r & 7 | 8).toString(16);
|
|
400
328
|
});
|
|
401
329
|
}
|
|
402
|
-
export function buildAttributesForLibraryItem(props) {
|
|
403
|
-
return {
|
|
404
|
-
"data-reusable-bundle": props.block?.bundle,
|
|
405
|
-
"data-reusable-uuid": props.block?.uuid,
|
|
406
|
-
"data-bk-library-label": props.label,
|
|
407
|
-
"data-bk-library-item-uuid": props.uuid,
|
|
408
|
-
"data-blokkli-is-reusable": "true"
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
330
|
export function asValidNumber(v, defaultValue) {
|
|
412
331
|
if (typeof v === "number" && !Number.isNaN(v)) {
|
|
413
332
|
return v;
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
import type { AddAction } from '#blokkli/types';
|
|
2
|
+
import type { BlokkliIcon } from '#blokkli-build/icons';
|
|
2
3
|
type PluginAddFunction<T> = () => T | T[] | undefined;
|
|
3
4
|
type AddActionFunction = PluginAddFunction<AddAction>;
|
|
5
|
+
export type ItemDropdownAction = {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
icon?: BlokkliIcon;
|
|
11
|
+
bundle?: string;
|
|
12
|
+
weight?: number;
|
|
13
|
+
group: string;
|
|
14
|
+
callback: () => void;
|
|
15
|
+
};
|
|
16
|
+
type ItemDropdownActionFunction = PluginAddFunction<ItemDropdownAction>;
|
|
4
17
|
export type PluginProvider = {
|
|
5
18
|
addAddAction: (fn: AddActionFunction) => void;
|
|
6
19
|
removeAddAction: (fn: AddActionFunction) => void;
|
|
7
20
|
getAddActions: () => AddAction[];
|
|
21
|
+
addItemDropdownAction: (fn: ItemDropdownActionFunction) => void;
|
|
22
|
+
removeItemDropdownAction: (fn: ItemDropdownActionFunction) => void;
|
|
23
|
+
getItemDropdownActions: () => ItemDropdownAction[];
|
|
8
24
|
};
|
|
9
25
|
export default function (): PluginProvider;
|
|
10
26
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export default function() {
|
|
2
2
|
let addActions = [];
|
|
3
|
+
let itemDropdownActions = [];
|
|
3
4
|
function addAddAction(fn) {
|
|
4
5
|
addActions.push(fn);
|
|
5
6
|
}
|
|
@@ -25,9 +26,37 @@ export default function() {
|
|
|
25
26
|
}
|
|
26
27
|
return actions;
|
|
27
28
|
}
|
|
29
|
+
function addItemDropdownAction(fn) {
|
|
30
|
+
itemDropdownActions.push(fn);
|
|
31
|
+
}
|
|
32
|
+
function removeItemDropdownAction(fn) {
|
|
33
|
+
itemDropdownActions = itemDropdownActions.filter((v) => v !== fn);
|
|
34
|
+
}
|
|
35
|
+
function getItemDropdownActions() {
|
|
36
|
+
const actions = [];
|
|
37
|
+
for (let i = 0; i < itemDropdownActions.length; i++) {
|
|
38
|
+
const callback = itemDropdownActions[i];
|
|
39
|
+
if (!callback) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const result = callback();
|
|
43
|
+
if (!result) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (Array.isArray(result)) {
|
|
47
|
+
actions.push(...result);
|
|
48
|
+
} else {
|
|
49
|
+
actions.push(result);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return actions;
|
|
53
|
+
}
|
|
28
54
|
return {
|
|
29
55
|
addAddAction,
|
|
30
56
|
removeAddAction,
|
|
31
|
-
getAddActions
|
|
57
|
+
getAddActions,
|
|
58
|
+
addItemDropdownAction,
|
|
59
|
+
removeItemDropdownAction,
|
|
60
|
+
getItemDropdownActions
|
|
32
61
|
};
|
|
33
62
|
}
|
|
@@ -6,19 +6,22 @@ type EditableFieldData = EntityContext & {
|
|
|
6
6
|
key: string;
|
|
7
7
|
fieldName: string;
|
|
8
8
|
directiveType: BlokkliDirectiveType;
|
|
9
|
+
isComponent: boolean;
|
|
10
|
+
getValue?: () => string;
|
|
9
11
|
};
|
|
10
12
|
type DroppableFieldElementData = EditableFieldData & {
|
|
11
13
|
element: HTMLElement;
|
|
12
14
|
};
|
|
13
15
|
export type DirectiveProvider = {
|
|
14
16
|
init: () => void;
|
|
15
|
-
registerDirectiveElement: (el: HTMLElement, fieldName: string, entity: EntityContext, type: BlokkliDirectiveType) => void;
|
|
17
|
+
registerDirectiveElement: (el: HTMLElement, fieldName: string, entity: EntityContext, type: BlokkliDirectiveType, isComponent: boolean, getValue?: () => string) => void;
|
|
16
18
|
unregisterDirectiveElement: (el: HTMLElement, fieldName: string, entity: EntityContext, type: BlokkliDirectiveType) => void;
|
|
17
19
|
getVisible: (directiveType: BlokkliDirectiveType) => Rectangle[];
|
|
18
20
|
getEditableAtPoint: (x: number, y: number) => EditableFieldData | undefined;
|
|
19
21
|
getEditablesForBlock: (uuid: string) => EditableFieldData[];
|
|
20
22
|
getDroppableElements: () => DroppableFieldElementData[];
|
|
21
23
|
findEditableElement: (fieldName: string, host: EntityContext) => HTMLElement | undefined;
|
|
24
|
+
findEditable: (fieldName: string, host: EntityContext) => EditableFieldData | undefined;
|
|
22
25
|
isReady: ComputedRef<boolean>;
|
|
23
26
|
};
|
|
24
27
|
export default function (debug: DebugProvider, ui: UiProvider): DirectiveProvider;
|
|
@@ -71,13 +71,15 @@ export default function(debug, ui) {
|
|
|
71
71
|
rootMargin: "400px 0px 400px 0px"
|
|
72
72
|
}
|
|
73
73
|
);
|
|
74
|
-
function registerDirectiveElement(el, fieldName, entity, directiveType) {
|
|
74
|
+
function registerDirectiveElement(el, fieldName, entity, directiveType, isComponent, getValue) {
|
|
75
75
|
const key = getEditableKey(fieldName, entity, directiveType);
|
|
76
76
|
const data = {
|
|
77
77
|
...entity,
|
|
78
78
|
fieldName,
|
|
79
79
|
directiveType,
|
|
80
|
-
key
|
|
80
|
+
key,
|
|
81
|
+
isComponent,
|
|
82
|
+
getValue
|
|
81
83
|
};
|
|
82
84
|
elementMap.set(el, data);
|
|
83
85
|
fieldData.set(key, data);
|
|
@@ -186,6 +188,10 @@ export default function(debug, ui) {
|
|
|
186
188
|
const key = getEditableKey(fieldName, host, "editable");
|
|
187
189
|
return elements.get(key);
|
|
188
190
|
}
|
|
191
|
+
function findEditable(fieldName, host) {
|
|
192
|
+
const key = getEditableKey(fieldName, host, "editable");
|
|
193
|
+
return fieldData.get(key);
|
|
194
|
+
}
|
|
189
195
|
onBlokkliEvent("state:reloaded", handleRefresh);
|
|
190
196
|
onBlokkliEvent("ui:resized", handleRefresh);
|
|
191
197
|
onBlokkliEvent("option:finish-change", handleRefresh);
|
|
@@ -200,6 +206,7 @@ export default function(debug, ui) {
|
|
|
200
206
|
init,
|
|
201
207
|
getVisible,
|
|
202
208
|
getEditableAtPoint,
|
|
209
|
+
findEditable,
|
|
203
210
|
getEditablesForBlock,
|
|
204
211
|
findEditableElement,
|
|
205
212
|
getDroppableElements,
|
|
@@ -99,6 +99,7 @@ export default async function(adapter, context, $t, providerKey, permissions) {
|
|
|
99
99
|
publishOptions.value.revisionLogMessage = newPublishOptions.revisionLogMessage;
|
|
100
100
|
}
|
|
101
101
|
function setContext(context2, override) {
|
|
102
|
+
eventBus.emit("state:reload:before");
|
|
102
103
|
if (!override) {
|
|
103
104
|
_mappedState = context2 ?? null;
|
|
104
105
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Ref, type ComputedRef } from 'vue';
|
|
2
2
|
import type { StorageProvider } from './storageProvider.js';
|
|
3
|
-
import type { AddListOrientation, Coord, Rectangle, Size } from '#blokkli/types';
|
|
3
|
+
import type { AddListOrientation, Coord, Rectangle, SidebarRegion, Size } from '#blokkli/types';
|
|
4
4
|
import type { Viewport } from '#blokkli/constants';
|
|
5
5
|
import type { StateProvider } from './stateProvider.js';
|
|
6
6
|
import type { AdapterContext } from '#blokkli/adapter';
|
|
@@ -52,5 +52,9 @@ export type UiProvider = {
|
|
|
52
52
|
getViewportRelativeRect: (rect: Rectangle, scale?: number, offset?: Coord) => Rectangle;
|
|
53
53
|
setBannerHeight: (id: string, height: number) => void;
|
|
54
54
|
removeBanner: (id: string) => void;
|
|
55
|
+
setActiveSidebar: (region: SidebarRegion, id: string) => void;
|
|
56
|
+
removeActiveSidebar: (region: SidebarRegion, id: string) => void;
|
|
57
|
+
hasSidebarLeft: ComputedRef<boolean>;
|
|
58
|
+
hasSidebarRight: ComputedRef<boolean>;
|
|
55
59
|
};
|
|
56
60
|
export default function (providerElement: HTMLElement, storage: StorageProvider, state: StateProvider, context: ComputedRef<AdapterContext>, element: ElementProvider): UiProvider;
|