@blokkli/editor 2.0.0-alpha.22 → 2.0.0-alpha.24
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 +150 -226
- package/dist/runtime/blokkliPlugins/ContextMenu/index.vue +1 -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 +5 -4
- package/dist/runtime/blokkliPlugins/ToolbarButton/index.vue +9 -2
- package/dist/runtime/blokkliPlugins/ToolbarButton/index.vue.d.ts +2 -0
- package/dist/runtime/blokkliPlugins/TourItem/index.vue +22 -13
- package/dist/runtime/blokkliPlugins/TourItem/index.vue.d.ts +1 -0
- package/dist/runtime/blokkliPlugins/ViewOption/index.vue +3 -1
- package/dist/runtime/blokkliPlugins/index.d.ts +1 -5
- package/dist/runtime/blokkliPlugins/index.js +0 -8
- 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/BlokkliProvider.vue.d.ts +1 -1
- 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 +80 -117
- package/dist/runtime/components/Edit/AddListItem/index.vue +8 -29
- package/dist/runtime/components/Edit/AddListItem/index.vue.d.ts +2 -3
- package/dist/runtime/components/Edit/AnimationCanvas/index.vue +23 -68
- package/dist/runtime/components/Edit/AppMenu/MenuButton.vue +39 -0
- package/dist/runtime/{blokkliPlugins/MenuButton/index.vue.d.ts → components/Edit/AppMenu/MenuButton.vue.d.ts} +0 -4
- package/dist/runtime/components/Edit/AppMenu/index.vue +62 -40
- 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/Dialog/index.vue +26 -5
- package/dist/runtime/components/Edit/Dialog/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/DraggableList.vue +5 -25
- package/dist/runtime/components/Edit/EditProvider.vue +71 -41
- package/dist/runtime/components/Edit/EditProvider.vue.d.ts +1 -1
- package/dist/runtime/components/Edit/Features/AddList/Actions/Action.vue +52 -0
- package/dist/runtime/components/Edit/Features/AddList/Actions/Action.vue.d.ts +7 -0
- package/dist/runtime/components/Edit/Features/AddList/Actions/index.vue +41 -0
- package/dist/runtime/components/Edit/Features/{Selection/OverlayFallback → AddList/Actions}/index.vue.d.ts +1 -1
- package/dist/runtime/components/Edit/Features/{BlockAddList → AddList/Blocks}/index.vue +36 -108
- package/dist/runtime/components/Edit/Features/{Hover/Overlay → AddList/Blocks}/index.vue.d.ts +7 -2
- package/dist/runtime/components/Edit/Features/AddList/index.vue +76 -110
- 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/index.vue +7 -3
- package/dist/runtime/components/Edit/Features/Anchors/index.vue +2 -2
- package/dist/runtime/components/Edit/Features/Artboard/Renderer.vue +41 -20
- package/dist/runtime/components/Edit/Features/Artboard/Scrollbar/index.vue +3 -2
- package/dist/runtime/components/Edit/Features/Assistant/Overlay/index.vue +2 -28
- package/dist/runtime/components/Edit/Features/Assistant/index.vue +18 -14
- package/dist/runtime/components/Edit/Features/BlockScheduler/Dialog/index.vue +1 -0
- package/dist/runtime/components/Edit/Features/BlockScheduler/index.vue +2 -2
- package/dist/runtime/components/Edit/Features/Clipboard/List/index.vue +22 -11
- package/dist/runtime/components/Edit/Features/Clipboard/index.vue +70 -29
- package/dist/runtime/components/Edit/Features/CommandPalette/Palette/Item/index.vue +0 -2
- package/dist/runtime/components/Edit/Features/CommandPalette/Palette/Item/index.vue.d.ts +6 -4
- package/dist/runtime/components/Edit/Features/CommandPalette/Palette/index.vue +77 -27
- package/dist/runtime/components/Edit/Features/CommandPalette/index.vue +7 -4
- package/dist/runtime/components/Edit/Features/Comments/index.vue +2 -2
- 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/Debug/Section/Logging.vue.d.ts +6 -0
- 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/DragItem.vue +113 -0
- package/dist/runtime/components/Edit/Features/DraggingOverlay/DragItems/DragItem.vue.d.ts +25 -0
- package/dist/runtime/components/Edit/Features/DraggingOverlay/DragItems/index.vue +23 -119
- package/dist/runtime/components/Edit/Features/DraggingOverlay/Renderer/fragment.glsl +77 -0
- package/dist/runtime/components/Edit/Features/DraggingOverlay/{DropTargets → Renderer}/index.vue +138 -92
- package/dist/runtime/components/Edit/Features/DraggingOverlay/{DropTargets → Renderer}/vertex.glsl +60 -8
- package/dist/runtime/components/Edit/Features/DraggingOverlay/index.vue +4 -5
- package/dist/runtime/components/Edit/Features/EditForm/index.vue +2 -2
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue +0 -6
- package/dist/runtime/components/Edit/Features/EditableField/index.vue +8 -4
- package/dist/runtime/components/Edit/Features/Exit/index.vue +12 -9
- package/dist/runtime/components/Edit/Features/Fragments/Dialog/Item/index.vue +1 -5
- package/dist/runtime/components/Edit/Features/Fragments/index.vue +27 -31
- 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/ImportExisting/Dialog/index.vue +1 -0
- package/dist/runtime/components/Edit/Features/ImportExisting/index.vue +25 -24
- package/dist/runtime/components/Edit/Features/Library/EditReusable/index.vue +2 -2
- package/dist/runtime/components/Edit/Features/Library/LibraryDialog/Item/index.vue +1 -5
- package/dist/runtime/components/Edit/Features/Library/ReusableDialog/index.vue +1 -0
- package/dist/runtime/components/Edit/Features/Library/index.vue +50 -36
- 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 +131 -75
- 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/PreviewGrant/index.vue +2 -1
- package/dist/runtime/components/Edit/Features/Publish/Dialog/index.vue +1 -0
- package/dist/runtime/components/Edit/Features/Publish/index.vue +17 -15
- package/dist/runtime/components/Edit/Features/ResponsivePreview/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/Revert/index.vue +24 -18
- package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Content/index.vue +23 -6
- package/dist/runtime/components/Edit/Features/Search/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/Selection/AddButtons/Overlay/index.vue +21 -17
- package/dist/runtime/components/Edit/Features/Selection/AddButtons/Overlay/index.vue.d.ts +6 -6
- 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 +15 -10
- 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/Settings/Dialog/index.vue +1 -0
- package/dist/runtime/components/Edit/Features/Settings/index.vue +25 -17
- package/dist/runtime/components/Edit/Features/TouchActionBar/index.vue +2 -2
- package/dist/runtime/components/Edit/Features/Tour/Overlay/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/Tour/Popup/index.vue +2 -2
- package/dist/runtime/components/Edit/Features/Tour/index.vue +12 -10
- package/dist/runtime/components/Edit/Features/Transform/Dialog/index.vue +5 -5
- package/dist/runtime/components/Edit/Features/Transform/index.vue +30 -23
- package/dist/runtime/components/Edit/Features/Translations/index.vue +18 -17
- 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/FormOverlay/index.vue +13 -4
- package/dist/runtime/components/Edit/ItemIconBox/index.vue +41 -0
- package/dist/runtime/components/Edit/{AddListItemIcon → ItemIconBox}/index.vue.d.ts +5 -5
- package/dist/runtime/components/Edit/Konami/Game/index.vue +0 -1
- package/dist/runtime/components/Edit/Konami/index.vue +3 -5
- package/dist/runtime/components/Edit/Messages/Item/index.vue +11 -2
- package/dist/runtime/components/Edit/Messages/Item/index.vue.d.ts +1 -1
- package/dist/runtime/components/Edit/Messages/index.vue +6 -1
- package/dist/runtime/components/Edit/Overlay/index.vue +66 -0
- package/dist/runtime/components/Edit/Overlay/index.vue.d.ts +2 -0
- 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/SystemRequirements/index.vue +36 -36
- package/dist/runtime/components/Edit/Toolbar/index.vue +47 -51
- 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 +7 -5
- package/dist/runtime/components/Edit/index.js +13 -9
- 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/defineAddAction.d.ts +2 -0
- package/dist/runtime/helpers/composables/defineAddAction.js +10 -0
- package/dist/runtime/helpers/composables/defineItemDropdownAction.d.ts +2 -0
- package/dist/runtime/helpers/composables/defineItemDropdownAction.js +10 -0
- package/dist/runtime/helpers/composables/defineMenuButton.d.ts +2 -0
- package/dist/runtime/helpers/composables/defineMenuButton.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/useDialog.d.ts +3 -0
- package/dist/runtime/helpers/composables/useDialog.js +16 -0
- 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/defineElementStyle.d.ts +2 -0
- package/dist/runtime/helpers/defineElementStyle.js +33 -0
- package/dist/runtime/helpers/domProvider.d.ts +1 -0
- package/dist/runtime/helpers/domProvider.js +51 -32
- package/dist/runtime/helpers/dropTargets/index.d.ts +1 -1
- package/dist/runtime/helpers/dropTargets/index.js +18 -4
- 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 +38 -3
- package/dist/runtime/helpers/pluginProvider.js +49 -18
- package/dist/runtime/helpers/providers/blocks.js +10 -0
- package/dist/runtime/helpers/providers/directive.d.ts +4 -1
- package/dist/runtime/helpers/providers/directive.js +9 -2
- package/dist/runtime/helpers/providers/fields.d.ts +9 -1
- package/dist/runtime/helpers/stateProvider.js +1 -0
- package/dist/runtime/helpers/uiProvider.d.ts +13 -12
- package/dist/runtime/helpers/uiProvider.js +117 -81
- package/dist/runtime/helpers/webgl/index.d.ts +2 -3
- package/dist/runtime/helpers/webgl/index.js +9 -14
- package/dist/runtime/icons/click.svg +1 -0
- 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 +16 -26
- package/package.json +1 -1
- package/dist/runtime/blokkliPlugins/AddAction/index.vue +0 -96
- package/dist/runtime/blokkliPlugins/AddAction/index.vue.d.ts +0 -26
- 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/blokkliPlugins/MenuButton/index.vue +0 -66
- package/dist/runtime/components/Edit/AddListItemIcon/index.vue +0 -19
- 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,16 @@
|
|
|
1
|
+
import { computed, useBlokkli } from "#imports";
|
|
2
|
+
export function useDialog(id, alignment) {
|
|
3
|
+
const { ui } = useBlokkli();
|
|
4
|
+
return computed({
|
|
5
|
+
get() {
|
|
6
|
+
return ui.currentDialog.value?.id === id;
|
|
7
|
+
},
|
|
8
|
+
set(isOpen) {
|
|
9
|
+
if (isOpen) {
|
|
10
|
+
ui.openDialog({ id, alignment });
|
|
11
|
+
} else {
|
|
12
|
+
ui.closeDialog(id);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { LogMessage } from '../debugProvider.js';
|
|
2
|
+
type BlokkliGlobalWindowObject = {
|
|
3
|
+
messages: LogMessage[];
|
|
4
|
+
};
|
|
5
|
+
export declare function useGlobalBlokkliObject(): {
|
|
6
|
+
init: () => void;
|
|
7
|
+
pushMessage: (message: LogMessage) => void;
|
|
8
|
+
getMessages: () => LogMessage[];
|
|
9
|
+
cleanup: () => void;
|
|
10
|
+
};
|
|
11
|
+
declare global {
|
|
12
|
+
interface Window {
|
|
13
|
+
__BLOKKLI__?: BlokkliGlobalWindowObject;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
onBeforeUnmount,
|
|
3
|
+
watch,
|
|
4
|
+
computed,
|
|
5
|
+
unref
|
|
6
|
+
} from "#imports";
|
|
7
|
+
export function defineElementStyle(property, providedValue, providedElement) {
|
|
8
|
+
const element = providedElement ?? document.documentElement;
|
|
9
|
+
const value = computed(() => {
|
|
10
|
+
if (typeof providedValue === "function") {
|
|
11
|
+
return providedValue();
|
|
12
|
+
}
|
|
13
|
+
return unref(providedValue);
|
|
14
|
+
});
|
|
15
|
+
const originalValue = element.style.getPropertyValue(property);
|
|
16
|
+
watch(
|
|
17
|
+
value,
|
|
18
|
+
function(newValue) {
|
|
19
|
+
const styleValue = typeof newValue === "number" ? newValue + "px" : newValue;
|
|
20
|
+
element.style.setProperty(property, styleValue);
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
immediate: true
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
onBeforeUnmount(() => {
|
|
27
|
+
if (originalValue) {
|
|
28
|
+
element.style.setProperty(property, originalValue);
|
|
29
|
+
} else {
|
|
30
|
+
element.style.removeProperty(property);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -27,6 +27,10 @@ export default function(ui, debug, definitions, state, element) {
|
|
|
27
27
|
let initTimeout = null;
|
|
28
28
|
const isInitalizing = ref(true);
|
|
29
29
|
const observedElementCache = /* @__PURE__ */ new Map();
|
|
30
|
+
function getBoundingClientRect(element2) {
|
|
31
|
+
logger.log("getBoundingClientRect", element2);
|
|
32
|
+
return element2.getBoundingClientRect();
|
|
33
|
+
}
|
|
30
34
|
const registeredBlockUuids = computed(() => {
|
|
31
35
|
return Object.entries(registeredBlocks).map(([uuid, element2]) => {
|
|
32
36
|
if (element2) {
|
|
@@ -219,19 +223,18 @@ export default function(ui, debug, definitions, state, element) {
|
|
|
219
223
|
if (!el) {
|
|
220
224
|
return "";
|
|
221
225
|
}
|
|
222
|
-
|
|
226
|
+
if ("itemType" in item && item.itemType !== "existing_structure") {
|
|
227
|
+
return el.outerHTML;
|
|
228
|
+
}
|
|
223
229
|
const childCount = element.queryAll(
|
|
224
|
-
|
|
230
|
+
el,
|
|
225
231
|
"*",
|
|
226
232
|
"Get child count for drop element markup."
|
|
227
233
|
).length;
|
|
228
234
|
if (checkSize && childCount > 80) {
|
|
229
235
|
return "";
|
|
230
236
|
}
|
|
231
|
-
return cloneElementWithStyles(
|
|
232
|
-
/\sdata-\w+="[^"]*"/g,
|
|
233
|
-
""
|
|
234
|
-
);
|
|
237
|
+
return cloneElementWithStyles(el, true).replace(/\sdata-\w+="[^"]*"/g, "");
|
|
235
238
|
};
|
|
236
239
|
const getVisibleBlocks = () => Array.from(visibleBlocks);
|
|
237
240
|
const getVisibleFields = () => Array.from(visibleFields);
|
|
@@ -254,18 +257,22 @@ export default function(ui, debug, definitions, state, element) {
|
|
|
254
257
|
if (!el) {
|
|
255
258
|
return;
|
|
256
259
|
}
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
260
|
+
const item = state.getFieldListItem(uuid);
|
|
261
|
+
if (!item) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
const fieldList = state.getFieldListForBlock(item.uuid);
|
|
265
|
+
if (!fieldList) {
|
|
261
266
|
return;
|
|
262
267
|
}
|
|
268
|
+
const fieldListType = getRegisteredField(fieldList.entityUuid, fieldList.name)?.fieldListType ?? "default";
|
|
269
|
+
const parentBundle = fieldList.entityType === itemEntityType ? state.getFieldListItem(fieldList.entityUuid)?.bundle ?? null : null;
|
|
263
270
|
const observableElement = getElementToObserve(
|
|
264
271
|
uuid,
|
|
265
272
|
el,
|
|
266
|
-
bundle,
|
|
267
|
-
|
|
268
|
-
|
|
273
|
+
item.bundle,
|
|
274
|
+
fieldListType,
|
|
275
|
+
parentBundle
|
|
269
276
|
);
|
|
270
277
|
blockRects[uuid] = rectWithTime(
|
|
271
278
|
ui.getAbsoluteElementRect(
|
|
@@ -315,6 +322,9 @@ export default function(ui, debug, definitions, state, element) {
|
|
|
315
322
|
);
|
|
316
323
|
}
|
|
317
324
|
}
|
|
325
|
+
onBlokkliEvent("state:reload:before", () => {
|
|
326
|
+
observedElementCache.clear();
|
|
327
|
+
});
|
|
318
328
|
onBlokkliEvent("state:reloaded", () => {
|
|
319
329
|
observedElementCache.clear();
|
|
320
330
|
if (stateReloadTimeout) {
|
|
@@ -400,25 +410,33 @@ export default function(ui, debug, definitions, state, element) {
|
|
|
400
410
|
unregisterBlock(key, uuid);
|
|
401
411
|
}
|
|
402
412
|
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
|
-
}
|
|
413
|
+
if (!item) {
|
|
414
|
+
return logger.error(
|
|
415
|
+
"Failed to register block due to missing field list item.",
|
|
416
|
+
uuid
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
const fieldList = state.getFieldListForBlock(item.uuid);
|
|
420
|
+
if (!fieldList) {
|
|
421
|
+
return logger.error(
|
|
422
|
+
"Failed to register block due to missing field list.",
|
|
423
|
+
uuid
|
|
424
|
+
);
|
|
421
425
|
}
|
|
426
|
+
const fieldListType = getRegisteredField(fieldList.entityUuid, fieldList.name)?.fieldListType ?? "default";
|
|
427
|
+
const parentBundle = fieldList.entityType === itemEntityType ? state.getFieldListItem(fieldList.entityUuid)?.bundle ?? null : null;
|
|
428
|
+
const observableElement = getElementToObserve(
|
|
429
|
+
item.uuid,
|
|
430
|
+
el,
|
|
431
|
+
item.bundle,
|
|
432
|
+
fieldListType,
|
|
433
|
+
parentBundle
|
|
434
|
+
);
|
|
435
|
+
blockElementToUuid.set(observableElement, uuid);
|
|
436
|
+
registeredBlocks[uuid] = el;
|
|
437
|
+
observedElements[uuid] = observableElement;
|
|
438
|
+
intersectionObserver.observe(observableElement);
|
|
439
|
+
resizeObserver.observe(observableElement);
|
|
422
440
|
}
|
|
423
441
|
function unregisterBlock(key, uuid) {
|
|
424
442
|
const currentKey = blockUuidCurrentKey[uuid];
|
|
@@ -537,6 +555,7 @@ export default function(ui, debug, definitions, state, element) {
|
|
|
537
555
|
registeredBlockUuids,
|
|
538
556
|
getDebugData,
|
|
539
557
|
getRegisteredField,
|
|
540
|
-
registeredBlocks: computed(() => registeredBlocks)
|
|
558
|
+
registeredBlocks: computed(() => registeredBlocks),
|
|
559
|
+
getBoundingClientRect
|
|
541
560
|
};
|
|
542
561
|
}
|
|
@@ -3,4 +3,4 @@ export type Orientation = 'horizontal' | 'vertical';
|
|
|
3
3
|
export declare const MIN_GAP = 20;
|
|
4
4
|
export declare function getGapSize(orientation: Orientation, element: HTMLElement): number;
|
|
5
5
|
export declare function getChildrenOrientation(element: HTMLElement): Orientation;
|
|
6
|
-
export declare function determineCanAddChildren(field: BlokkliFieldElement, children: HTMLElement[], uuids: string[], currentCount: number, itemsToAdd: number, draggingBundles?: string[]): boolean;
|
|
6
|
+
export declare function determineCanAddChildren(field: BlokkliFieldElement, children: HTMLElement[], uuids: string[], currentCount: number, itemsToAdd: number, draggingBundles?: string[], draggingFragments?: string[]): boolean;
|
|
@@ -2,7 +2,7 @@ export const MIN_GAP = 20;
|
|
|
2
2
|
export function getGapSize(orientation, element) {
|
|
3
3
|
const computedStyle = window.getComputedStyle(element);
|
|
4
4
|
if (computedStyle.display.includes("grid") || computedStyle.display.includes("flex")) {
|
|
5
|
-
const gap = orientation === "vertical" ? computedStyle.
|
|
5
|
+
const gap = orientation === "vertical" ? computedStyle.rowGap || computedStyle.gridRowGap : computedStyle.columnGap || computedStyle.gridColumnGap;
|
|
6
6
|
if (gap) {
|
|
7
7
|
const gapParts = gap.split(" ");
|
|
8
8
|
const gapValue = gapParts[0];
|
|
@@ -31,10 +31,10 @@ export function getChildrenOrientation(element) {
|
|
|
31
31
|
}
|
|
32
32
|
return "vertical";
|
|
33
33
|
}
|
|
34
|
-
export function determineCanAddChildren(field, children, uuids, currentCount, itemsToAdd, draggingBundles) {
|
|
34
|
+
export function determineCanAddChildren(field, children, uuids, currentCount, itemsToAdd, draggingBundles, draggingFragments) {
|
|
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
|
}
|
|
@@ -45,5 +45,19 @@ export function determineCanAddChildren(field, children, uuids, currentCount, it
|
|
|
45
45
|
return false;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
if (!draggingBundles?.length) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
const bundlesAllowed = draggingBundles.every(
|
|
52
|
+
(bundle) => field.allowedBundles.includes(bundle)
|
|
53
|
+
);
|
|
54
|
+
if (!bundlesAllowed) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
if (draggingFragments?.length && field.allowedFragments.length > 0) {
|
|
58
|
+
return draggingFragments.every(
|
|
59
|
+
(fragment) => field.allowedFragments.includes(fragment)
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
49
63
|
}
|
|
@@ -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,45 @@
|
|
|
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>;
|
|
17
|
+
export type MenuButtonPlugin = {
|
|
18
|
+
id: string;
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
icon?: BlokkliIcon;
|
|
22
|
+
type?: 'success' | 'danger' | 'yellow';
|
|
23
|
+
weight?: number;
|
|
24
|
+
secondary?: boolean;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
callback: () => void;
|
|
27
|
+
};
|
|
28
|
+
type MenuButtonFunction = PluginAddFunction<MenuButtonPlugin>;
|
|
29
|
+
type PluginFunctionMap = {
|
|
30
|
+
addAction: AddActionFunction;
|
|
31
|
+
itemDropdownAction: ItemDropdownActionFunction;
|
|
32
|
+
menuButton: MenuButtonFunction;
|
|
33
|
+
};
|
|
34
|
+
type PluginDataMap = {
|
|
35
|
+
addAction: AddAction;
|
|
36
|
+
itemDropdownAction: ItemDropdownAction;
|
|
37
|
+
menuButton: MenuButtonPlugin;
|
|
38
|
+
};
|
|
4
39
|
export type PluginProvider = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
40
|
+
add<T extends keyof PluginFunctionMap>(type: T, fn: PluginFunctionMap[T]): void;
|
|
41
|
+
remove<T extends keyof PluginFunctionMap>(type: T, fn: PluginFunctionMap[T]): void;
|
|
42
|
+
get<T extends keyof PluginDataMap>(type: T): PluginDataMap[T][];
|
|
8
43
|
};
|
|
9
44
|
export default function (): PluginProvider;
|
|
10
45
|
export {};
|