@blokkli/editor 2.0.0-alpha.17 → 2.0.0-alpha.19
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 +380 -59
- package/dist/modules/drupal/graphql/base/fragment.paragraphsFieldItem.graphql +3 -1
- package/dist/modules/drupal/graphql/base/query.pbConfig.graphql +1 -10
- package/dist/modules/drupal/graphql/mutations/set_paragraph_schedule.graphql +15 -0
- package/dist/modules/drupal/index.mjs +33 -0
- package/dist/modules/drupal/runtime/adapter/index.js +10 -2
- package/dist/runtime/adapter/index.d.ts +21 -0
- package/dist/runtime/blokkliPlugins/ContextMenu/Menu/index.vue +3 -0
- package/dist/runtime/blokkliPlugins/ItemAction/index.vue +23 -13
- package/dist/runtime/blokkliPlugins/ItemAction/index.vue.d.ts +20 -44
- package/dist/runtime/blokkliPlugins/TourItem/index.vue +10 -5
- package/dist/runtime/components/BlokkliEditable.vue +13 -13
- package/dist/runtime/components/BlokkliField.vue.d.ts +3 -3
- package/dist/runtime/components/BlokkliItem.vue +1 -1
- package/dist/runtime/components/BlokkliItem.vue.d.ts +4 -2
- package/dist/runtime/components/BlokkliProvider.vue +12 -8
- package/dist/runtime/components/Edit/Actions/index.vue +27 -16
- package/dist/runtime/components/Edit/AnimationCanvas/index.vue +26 -10
- package/dist/runtime/components/Edit/ArtboardTooltip/index.vue +3 -0
- package/dist/runtime/components/Edit/Dialog/index.vue +6 -4
- package/dist/runtime/components/Edit/DraggableList.vue +15 -7
- package/dist/runtime/components/Edit/DraggableList.vue.d.ts +5 -5
- package/dist/runtime/components/Edit/EditProvider.vue +29 -16
- package/dist/runtime/components/Edit/EditProvider.vue.d.ts +1 -0
- package/dist/runtime/components/Edit/Features/AddList/index.vue +9 -11
- package/dist/runtime/components/Edit/Features/Analyze/Overlay/index.vue +9 -6
- package/dist/runtime/components/Edit/Features/Analyze/Renderer.vue +1 -1
- package/dist/runtime/components/Edit/Features/Analyze/Results/ResultsItemNodesTarget.vue +15 -11
- package/dist/runtime/components/Edit/Features/Anchors/Renderer.vue +19 -102
- package/dist/runtime/components/Edit/Features/Artboard/Renderer.vue +3 -0
- package/dist/runtime/components/Edit/Features/BlockAddList/index.vue +28 -52
- package/dist/runtime/components/Edit/Features/BlockScheduler/Dialog/ScheduleSection.vue +154 -0
- package/dist/runtime/components/Edit/Features/BlockScheduler/Dialog/ScheduleSection.vue.d.ts +27 -0
- package/dist/runtime/components/Edit/Features/BlockScheduler/Dialog/index.vue +222 -0
- package/dist/runtime/components/Edit/Features/BlockScheduler/Dialog/index.vue.d.ts +11 -0
- package/dist/runtime/components/Edit/Features/BlockScheduler/index.vue +96 -0
- package/dist/runtime/components/Edit/Features/BlockScheduler/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Clipboard/index.vue +15 -16
- package/dist/runtime/components/Edit/Features/CommandPalette/Palette/Item/index.vue +51 -0
- package/dist/runtime/components/Edit/Features/CommandPalette/Palette/{Group → Item}/index.vue.d.ts +9 -13
- package/dist/runtime/components/Edit/Features/CommandPalette/Palette/index.vue +46 -66
- package/dist/runtime/components/Edit/Features/Comments/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/Conversions/index.vue +4 -7
- package/dist/runtime/components/Edit/Features/Debug/Rects/index.vue +2 -2
- package/dist/runtime/components/Edit/Features/Debug/index.vue +4 -1
- package/dist/runtime/components/Edit/Features/Delete/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/DraggingOverlay/DragItems/index.vue +13 -5
- package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/index.vue +14 -11
- package/dist/runtime/components/Edit/Features/DraggingOverlay/index.vue +30 -18
- package/dist/runtime/components/Edit/Features/Duplicate/index.vue +6 -8
- package/dist/runtime/components/Edit/Features/Edit/index.vue +15 -21
- package/dist/runtime/components/Edit/Features/EditForm/index.vue +7 -6
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/Frame/index.vue +8 -3
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/Frame/index.vue.d.ts +2 -2
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue +29 -12
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue.d.ts +2 -2
- package/dist/runtime/components/Edit/Features/EditableField/index.vue +40 -42
- package/dist/runtime/components/Edit/Features/Fragments/Dialog/index.vue +11 -9
- package/dist/runtime/components/Edit/Features/Fragments/index.vue +3 -3
- package/dist/runtime/components/Edit/Features/Hover/Overlay/index.vue +16 -25
- package/dist/runtime/components/Edit/Features/Library/EditReusable/index.vue +5 -7
- package/dist/runtime/components/Edit/Features/Library/ReusableDialog/index.vue +5 -5
- package/dist/runtime/components/Edit/Features/Library/index.vue +27 -23
- package/dist/runtime/components/Edit/Features/MediaLibrary/Library/index.vue +6 -3
- package/dist/runtime/components/Edit/Features/MediaLibrary/index.vue +15 -12
- package/dist/runtime/components/Edit/Features/MultiSelect/Overlay/index.vue +2 -2
- package/dist/runtime/components/Edit/Features/Options/Form/index.vue +7 -6
- package/dist/runtime/components/Edit/Features/Options/index.vue +6 -6
- package/dist/runtime/components/Edit/Features/Publish/Dialog/index.vue +68 -15
- package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Page/index.vue +15 -15
- package/dist/runtime/components/Edit/Features/Search/index.vue +4 -1
- package/dist/runtime/components/Edit/Features/Selection/AddButtons/Overlay/index.vue.d.ts +3 -3
- package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/index.vue +34 -11
- package/dist/runtime/components/Edit/Features/Selection/AddButtons/index.vue +21 -20
- package/dist/runtime/components/Edit/Features/Selection/AddButtons/index.vue.d.ts +2 -2
- package/dist/runtime/components/Edit/Features/Selection/Overlay/index.vue.d.ts +3 -3
- package/dist/runtime/components/Edit/Features/Selection/OverlayFallback/index.vue +2 -2
- package/dist/runtime/components/Edit/Features/Selection/index.vue +61 -27
- package/dist/runtime/components/Edit/Features/Structure/List/Field/index.vue +2 -2
- package/dist/runtime/components/Edit/Features/Structure/List/Item/index.vue +13 -6
- package/dist/runtime/components/Edit/Features/Tour/Overlay/index.vue +3 -0
- package/dist/runtime/components/Edit/Features/Transform/index.vue +2 -27
- package/dist/runtime/components/Edit/Features/Translations/index.vue +7 -7
- package/dist/runtime/components/Edit/Features/Validations/SidebarItem/index.vue +5 -5
- package/dist/runtime/components/Edit/Features/index.vue +17 -7
- package/dist/runtime/components/Edit/Form/Toggle/index.vue +4 -3
- package/dist/runtime/components/Edit/Form/Toggle/index.vue.d.ts +12 -2
- package/dist/runtime/components/Edit/InfoBox/index.vue +6 -2
- package/dist/runtime/components/Edit/InfoBox/index.vue.d.ts +12 -2
- package/dist/runtime/components/Edit/{Features/Publish/Dialog/ScheduleDate.vue → ScheduleDate/index.vue} +6 -58
- package/dist/runtime/components/Edit/{Features/Publish/Dialog/ScheduleDate.vue.d.ts → ScheduleDate/index.vue.d.ts} +11 -1
- package/dist/runtime/components/Edit/ShortcutIndicator/index.vue +3 -0
- package/dist/runtime/components/Edit/Transition/Height.vue +95 -0
- package/dist/runtime/components/Edit/Transition/Height.vue.d.ts +36 -0
- package/dist/runtime/components/Edit/index.d.ts +3 -1
- package/dist/runtime/components/Edit/index.js +5 -1
- package/dist/runtime/css/output.css +1 -1
- package/dist/runtime/helpers/animationProvider.d.ts +2 -1
- package/dist/runtime/helpers/animationProvider.js +6 -2
- package/dist/runtime/helpers/composables/useStateBasedCache.d.ts +4 -0
- package/dist/runtime/helpers/composables/useStateBasedCache.js +13 -0
- package/dist/runtime/helpers/definitionProvider.d.ts +1 -1
- package/dist/runtime/helpers/dom/index.d.ts +1 -1
- package/dist/runtime/helpers/domProvider.d.ts +10 -16
- package/dist/runtime/helpers/domProvider.js +80 -135
- package/dist/runtime/helpers/index.d.ts +1 -8
- package/dist/runtime/helpers/index.js +1 -84
- package/dist/runtime/helpers/providers/blocks.d.ts +10 -0
- package/dist/runtime/helpers/providers/blocks.js +91 -0
- package/dist/runtime/helpers/providers/directive.d.ts +24 -0
- package/dist/runtime/helpers/{editableProvider.js → providers/directive.js} +90 -29
- package/dist/runtime/helpers/providers/element.d.ts +6 -0
- package/dist/runtime/helpers/providers/element.js +35 -0
- package/dist/runtime/helpers/providers/fields.d.ts +8 -0
- package/dist/runtime/helpers/providers/fields.js +47 -0
- package/dist/runtime/helpers/selectionProvider.d.ts +11 -11
- package/dist/runtime/helpers/selectionProvider.js +38 -45
- package/dist/runtime/helpers/stateProvider.d.ts +1 -0
- package/dist/runtime/helpers/stateProvider.js +21 -15
- package/dist/runtime/helpers/themeProvider.d.ts +2 -1
- package/dist/runtime/helpers/themeProvider.js +24 -14
- package/dist/runtime/helpers/typesProvider.js +10 -26
- package/dist/runtime/helpers/uiProvider.d.ts +3 -2
- package/dist/runtime/helpers/uiProvider.js +11 -15
- package/dist/runtime/icons/calendar.svg +1 -0
- package/dist/runtime/icons/clock.svg +1 -0
- package/dist/runtime/icons/comment_add.svg +1 -5
- package/dist/runtime/icons/delete.svg +1 -8
- package/dist/runtime/icons/duplicate.svg +1 -12
- package/dist/runtime/icons/edit.svg +1 -8
- package/dist/runtime/icons/reusable.svg +1 -5
- package/dist/runtime/plugins/{blokkliEditable.js → blokkliDirectives.js} +14 -20
- package/dist/runtime/types/index.d.ts +55 -36
- package/package.json +1 -1
- package/dist/runtime/components/Edit/Features/CommandPalette/Palette/Group/index.vue +0 -63
- package/dist/runtime/helpers/editableProvider.d.ts +0 -14
- /package/dist/runtime/plugins/{blokkliEditable.d.ts → blokkliDirectives.d.ts} +0 -0
|
@@ -5,6 +5,7 @@ import type { StorageProvider } from './storageProvider.js';
|
|
|
5
5
|
import type { CursorKeyword } from './dom/index.js';
|
|
6
6
|
import type { CanvasDrawEvent, Coord } from '#blokkli/types';
|
|
7
7
|
import type { SelectionProvider } from './selectionProvider.js';
|
|
8
|
+
import type { ElementProvider } from './providers/element.js';
|
|
8
9
|
export type RenderContext = CanvasDrawEvent & {
|
|
9
10
|
gl: WebGLRenderingContext;
|
|
10
11
|
};
|
|
@@ -57,4 +58,4 @@ export type AnimationProvider = {
|
|
|
57
58
|
*/
|
|
58
59
|
unregisterRenderer: (id: string) => void;
|
|
59
60
|
};
|
|
60
|
-
export default function (ui: UiProvider, storage: StorageProvider, selection: SelectionProvider): AnimationProvider;
|
|
61
|
+
export default function (ui: UiProvider, storage: StorageProvider, selection: SelectionProvider, element: ElementProvider): AnimationProvider;
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "#imports";
|
|
9
9
|
import { eventBus } from "#blokkli/helpers/eventBus";
|
|
10
10
|
import { createProgramInfo } from "twgl.js";
|
|
11
|
-
export default function(ui, storage, selection) {
|
|
11
|
+
export default function(ui, storage, selection, element) {
|
|
12
12
|
const webglEnabled = storage.use("webglEnabled", true);
|
|
13
13
|
const currentCursor = ref("default");
|
|
14
14
|
const cursor = computed(() => currentCursor.value);
|
|
@@ -49,7 +49,11 @@ export default function(ui, storage, selection) {
|
|
|
49
49
|
const maxCanvasHeight = ref(16384);
|
|
50
50
|
let webglLimitsQueried = false;
|
|
51
51
|
function getCanvasElement() {
|
|
52
|
-
const el =
|
|
52
|
+
const el = element.query(
|
|
53
|
+
document.documentElement,
|
|
54
|
+
"#bk-animation-canvas-webgl",
|
|
55
|
+
"Find animation canvas element."
|
|
56
|
+
);
|
|
53
57
|
if (!(el instanceof HTMLCanvasElement)) {
|
|
54
58
|
throw new TypeError("Failed to locate WebGL canvas.");
|
|
55
59
|
}
|
|
@@ -5,7 +5,7 @@ import type { DeepReadonly } from 'vue';
|
|
|
5
5
|
import type { BlockDefinitionOptionsInput } from '../types/index.js';
|
|
6
6
|
import { type RuntimeBlockOptionArray } from '#blokkli-build/runtime-options';
|
|
7
7
|
export type DefinitionProvider = {
|
|
8
|
-
getBlockDefinition: (bundle: string, fieldListType: ValidFieldListTypes, parentBundle?: BlockBundleWithNested) => BlockDefinition | undefined;
|
|
8
|
+
getBlockDefinition: (bundle: string, fieldListType: ValidFieldListTypes, parentBundle?: BlockBundleWithNested | null) => BlockDefinition | undefined;
|
|
9
9
|
getDefaultDefinition: (bundle: string) => BlockDefinition | undefined;
|
|
10
10
|
getFragmentDefinition: (name: string) => FragmentDefinition | undefined;
|
|
11
11
|
getProviderDefinition: (entityType: string, entityBundle: string) => ProviderDefinition | undefined;
|
|
@@ -62,4 +62,4 @@ export declare const MOUSE_BUTTON: Readonly<{
|
|
|
62
62
|
*/
|
|
63
63
|
FIFTH: 4;
|
|
64
64
|
}>;
|
|
65
|
-
export type CursorKeyword = '
|
|
65
|
+
export type CursorKeyword = 'alias' | 'all-scroll' | 'auto' | 'cell' | 'col-resize' | 'context-menu' | 'copy' | 'crosshair' | 'default' | 'e-resize' | 'ew-resize' | 'grab' | 'grabbing' | 'help' | 'move' | 'n-resize' | 'ne-resize' | 'nesw-resize' | 'no-drop' | 'none' | 'not-allowed' | 'ns-resize' | 'nw-resize' | 'nwse-resize' | 'pointer' | 'progress' | 'row-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'text' | 'vertical-text' | 'w-resize' | 'wait' | 'zoom-in' | 'zoom-out';
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type ComputedRef } from '#imports';
|
|
2
|
-
import type { DraggableExistingBlock,
|
|
2
|
+
import type { DraggableExistingBlock, DraggableItem, EntityContext, Rectangle, RenderedFieldListItem, RegisteredField, RegisterFieldData } from '#blokkli/types';
|
|
3
3
|
import type { UiProvider } from './uiProvider.js';
|
|
4
4
|
import type { DebugProvider } from './debugProvider.js';
|
|
5
5
|
import type { DefinitionProvider } from './definitionProvider.js';
|
|
6
|
+
import type { StateProvider } from './stateProvider.js';
|
|
7
|
+
import type { ElementProvider } from './providers/element.js';
|
|
6
8
|
type RegisteredFieldType = {
|
|
7
9
|
entityType: string;
|
|
8
10
|
entityBundle: string;
|
|
@@ -12,41 +14,35 @@ type MeasuredBlockRect = Rectangle & {
|
|
|
12
14
|
time: number;
|
|
13
15
|
};
|
|
14
16
|
export type DomProvider = {
|
|
15
|
-
findBlock(uuid: string): DraggableExistingBlock | undefined;
|
|
16
|
-
getAllBlocks(): DraggableExistingBlock[];
|
|
17
17
|
findClosestBlock(el: Element | EventTarget): DraggableExistingBlock | undefined;
|
|
18
18
|
/**
|
|
19
19
|
* Return the droppable markup for a draggable item.
|
|
20
20
|
*/
|
|
21
|
-
getDropElementMarkup(item: DraggableItem, checkSize?: boolean): string;
|
|
22
|
-
findField(entityUuid: string, fieldName: string): BlokkliFieldElement | undefined;
|
|
21
|
+
getDropElementMarkup(item: DraggableItem | RenderedFieldListItem, checkSize?: boolean): string;
|
|
23
22
|
registerBlock: (key: string, uuid: string, el: HTMLElement | null) => void;
|
|
24
23
|
unregisterBlock: (key: string, uuid: string) => void;
|
|
25
|
-
registerField: (entity: EntityContext, fieldName: string, instance: HTMLElement) => void;
|
|
26
|
-
updateFieldElement: (entity: EntityContext, fieldName: string, element: HTMLElement) => void;
|
|
24
|
+
registerField: (entity: EntityContext, fieldName: string, instance: HTMLElement, data: RegisterFieldData) => void;
|
|
25
|
+
updateFieldElement: (entity: EntityContext, fieldName: string, element: HTMLElement, data: RegisterFieldData) => void;
|
|
27
26
|
unregisterField: (entity: EntityContext, fieldName: string) => void;
|
|
27
|
+
getRegisteredField: (uuid: string, fieldName: string) => RegisteredField | undefined;
|
|
28
28
|
registeredFieldTypes: ComputedRef<RegisteredFieldType[]>;
|
|
29
29
|
registeredBlockUuids: ComputedRef<string[]>;
|
|
30
|
-
/**
|
|
31
|
-
* Get all droppable entity fields.
|
|
32
|
-
*/
|
|
33
|
-
getAllDroppableFields(): DroppableEntityField[];
|
|
34
30
|
findClosestEntityContext(el: HTMLElement): EntityContext | undefined;
|
|
35
31
|
getVisibleBlocks(): string[];
|
|
36
32
|
getVisibleFields(): string[];
|
|
37
33
|
isBlockVisible(uuid: string): boolean;
|
|
38
|
-
getActiveProviderElement: () => HTMLElement;
|
|
39
34
|
getBlockRects: () => Record<string, MeasuredBlockRect>;
|
|
40
35
|
getBlockRect: (uuid: string, refresh?: boolean) => MeasuredBlockRect | undefined;
|
|
41
36
|
refreshBlockRect: (uuid: string) => void;
|
|
42
37
|
getFieldRect: (key: string) => Rectangle | undefined;
|
|
38
|
+
registeredBlocks: ComputedRef<Record<string, HTMLElement | undefined>>;
|
|
43
39
|
updateVisibleRects: () => void;
|
|
44
40
|
isReady: ComputedRef<boolean>;
|
|
45
41
|
init: () => void;
|
|
46
42
|
/**
|
|
47
43
|
* Get the drag element for a block.
|
|
48
44
|
*/
|
|
49
|
-
getDragElement: (block: DraggableExistingBlock) => HTMLElement | undefined;
|
|
45
|
+
getDragElement: (block: DraggableExistingBlock | RenderedFieldListItem) => HTMLElement | undefined;
|
|
50
46
|
/**
|
|
51
47
|
* Get debug data for troubleshooting.
|
|
52
48
|
*/
|
|
@@ -58,7 +54,6 @@ export type DomProvider = {
|
|
|
58
54
|
hasRect: boolean;
|
|
59
55
|
hasCurrentKey: boolean;
|
|
60
56
|
isVisible: boolean;
|
|
61
|
-
inCache: boolean;
|
|
62
57
|
elementInfo?: {
|
|
63
58
|
tagName: string;
|
|
64
59
|
bundle?: string;
|
|
@@ -83,7 +78,6 @@ export type DomProvider = {
|
|
|
83
78
|
totalRegisteredFields: number;
|
|
84
79
|
totalVisibleFields: number;
|
|
85
80
|
totalFieldRects: number;
|
|
86
|
-
cacheSize: number;
|
|
87
81
|
isInitializing: boolean;
|
|
88
82
|
isReady: boolean;
|
|
89
83
|
};
|
|
@@ -94,5 +88,5 @@ export type DomProvider = {
|
|
|
94
88
|
};
|
|
95
89
|
};
|
|
96
90
|
};
|
|
97
|
-
export default function (ui: UiProvider, debug: DebugProvider, definitions: DefinitionProvider): DomProvider;
|
|
91
|
+
export default function (ui: UiProvider, debug: DebugProvider, definitions: DefinitionProvider, state: StateProvider, element: ElementProvider): DomProvider;
|
|
98
92
|
export {};
|
|
@@ -1,54 +1,20 @@
|
|
|
1
1
|
import { reactive, ref, computed } from "#imports";
|
|
2
2
|
import {
|
|
3
3
|
findClosestBlock,
|
|
4
|
-
buildDraggableItem,
|
|
5
4
|
falsy,
|
|
6
|
-
mapDroppableField,
|
|
7
5
|
findClosestEntityContext
|
|
8
6
|
} from "#blokkli/helpers";
|
|
9
7
|
import { cloneElementWithStyles } from "./dom/index.js";
|
|
10
8
|
import onBlokkliEvent from "./composables/onBlokkliEvent.js";
|
|
11
9
|
import useDelayedIntersectionObserver from "./composables/useDelayedIntersectionObserver.js";
|
|
12
|
-
|
|
13
|
-
const key = element.dataset.fieldKey;
|
|
14
|
-
const name = element.dataset.fieldName;
|
|
15
|
-
const label = element.dataset.fieldLabel;
|
|
16
|
-
const isNested = element.dataset.fieldIsNested === "true";
|
|
17
|
-
const nestingLevel = Number.parseInt(element.dataset.bkNestingLevel || "0");
|
|
18
|
-
const fieldListType = element.dataset.fieldListType;
|
|
19
|
-
const hostEntityType = element.dataset.hostEntityType;
|
|
20
|
-
const hostEntityBundle = element.dataset.hostEntityBundle;
|
|
21
|
-
const hostEntityUuid = element.dataset.hostEntityUuid;
|
|
22
|
-
const dropAlignment = element.dataset.fieldDropAlignment;
|
|
23
|
-
const cardinality = Number.parseInt(element.dataset.fieldCardinality || "-1");
|
|
24
|
-
const allowedBundles = (element.dataset.fieldAllowedBundles || "").split(",").filter(Boolean);
|
|
25
|
-
const allowedFragments = (element.dataset.allowedFragments || "").split(",").filter(Boolean);
|
|
26
|
-
if (key && name && label && hostEntityType && hostEntityUuid && hostEntityBundle && fieldListType) {
|
|
27
|
-
return {
|
|
28
|
-
key,
|
|
29
|
-
name,
|
|
30
|
-
label,
|
|
31
|
-
isNested,
|
|
32
|
-
nestingLevel,
|
|
33
|
-
hostEntityType,
|
|
34
|
-
hostEntityUuid,
|
|
35
|
-
hostEntityBundle,
|
|
36
|
-
cardinality: Number.isNaN(cardinality) ? -1 : cardinality,
|
|
37
|
-
allowedBundles,
|
|
38
|
-
allowedFragments,
|
|
39
|
-
fieldListType,
|
|
40
|
-
element,
|
|
41
|
-
dropAlignment: dropAlignment === "vertical" || dropAlignment === "horizontal" ? dropAlignment : void 0
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
};
|
|
10
|
+
import { itemEntityType } from "#blokkli-build/config";
|
|
45
11
|
function rectWithTime(rect, time) {
|
|
46
12
|
return {
|
|
47
13
|
...rect,
|
|
48
14
|
time: time || performance.now()
|
|
49
15
|
};
|
|
50
16
|
}
|
|
51
|
-
export default function(ui, debug, definitions) {
|
|
17
|
+
export default function(ui, debug, definitions, state, element) {
|
|
52
18
|
const logger = debug.createLogger("DomProvider");
|
|
53
19
|
const mutationsReady = ref(true);
|
|
54
20
|
const intersectionReady = ref(false);
|
|
@@ -60,13 +26,12 @@ export default function(ui, debug, definitions) {
|
|
|
60
26
|
const fieldRects = {};
|
|
61
27
|
const blockUuidCurrentKey = {};
|
|
62
28
|
const observedElements = {};
|
|
63
|
-
let draggableBlockCache = {};
|
|
64
29
|
let initTimeout = null;
|
|
65
30
|
const isInitalizing = ref(true);
|
|
66
31
|
const observedElementCache = /* @__PURE__ */ new Map();
|
|
67
32
|
const registeredBlockUuids = computed(() => {
|
|
68
|
-
return Object.entries(registeredBlocks).map(([uuid,
|
|
69
|
-
if (
|
|
33
|
+
return Object.entries(registeredBlocks).map(([uuid, element2]) => {
|
|
34
|
+
if (element2) {
|
|
70
35
|
return uuid;
|
|
71
36
|
}
|
|
72
37
|
return null;
|
|
@@ -172,19 +137,30 @@ export default function(ui, debug, definitions) {
|
|
|
172
137
|
}
|
|
173
138
|
return uniqueFieldTypes;
|
|
174
139
|
});
|
|
175
|
-
const registerField = (entity, fieldName,
|
|
140
|
+
const registerField = (entity, fieldName, element2, data) => {
|
|
176
141
|
const key = `${entity.uuid}:${fieldName}`;
|
|
177
|
-
registeredFields[key] = {
|
|
178
|
-
|
|
142
|
+
registeredFields[key] = {
|
|
143
|
+
element: element2,
|
|
144
|
+
entity,
|
|
145
|
+
fieldName,
|
|
146
|
+
...data
|
|
147
|
+
};
|
|
148
|
+
intersectionObserver.observe(element2);
|
|
149
|
+
doInitTimeout();
|
|
179
150
|
};
|
|
180
|
-
const updateFieldElement = (entity, fieldName,
|
|
151
|
+
const updateFieldElement = (entity, fieldName, element2, data) => {
|
|
181
152
|
const key = `${entity.uuid}:${fieldName}`;
|
|
182
153
|
const existingElement = registeredFields[key]?.element;
|
|
183
154
|
if (existingElement) {
|
|
184
155
|
intersectionObserver.unobserve(existingElement);
|
|
185
156
|
}
|
|
186
|
-
registeredFields[key] = {
|
|
187
|
-
|
|
157
|
+
registeredFields[key] = {
|
|
158
|
+
entity,
|
|
159
|
+
fieldName,
|
|
160
|
+
element: element2,
|
|
161
|
+
...data
|
|
162
|
+
};
|
|
163
|
+
intersectionObserver.observe(element2);
|
|
188
164
|
};
|
|
189
165
|
const unregisterField = (entity, fieldName) => {
|
|
190
166
|
const key = `${entity.uuid}:${fieldName}`;
|
|
@@ -195,6 +171,10 @@ export default function(ui, debug, definitions) {
|
|
|
195
171
|
visibleFields.delete(key);
|
|
196
172
|
registeredFields[key] = void 0;
|
|
197
173
|
};
|
|
174
|
+
const getRegisteredField = (uuid, fieldName) => {
|
|
175
|
+
const key = `${uuid}:${fieldName}`;
|
|
176
|
+
return registeredFields[key];
|
|
177
|
+
};
|
|
198
178
|
function getElementToObserve(uuid, el, bundle, fieldListType, parentBlockBundle) {
|
|
199
179
|
if (el.classList.contains("bk-block-proxy")) {
|
|
200
180
|
return el;
|
|
@@ -220,40 +200,26 @@ export default function(ui, debug, definitions) {
|
|
|
220
200
|
observedElementCache.set(key, el);
|
|
221
201
|
return el;
|
|
222
202
|
}
|
|
223
|
-
const findBlock = (uuid) => {
|
|
224
|
-
const cached = draggableBlockCache[uuid];
|
|
225
|
-
if (cached) {
|
|
226
|
-
return cached;
|
|
227
|
-
}
|
|
228
|
-
const el = registeredBlocks[uuid];
|
|
229
|
-
if (!el) {
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
const item = buildDraggableItem(el);
|
|
233
|
-
if (item?.itemType === "existing") {
|
|
234
|
-
draggableBlockCache[uuid] = item;
|
|
235
|
-
return item;
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
const getAllBlocks = () => {
|
|
239
|
-
return [
|
|
240
|
-
...document.querySelectorAll(
|
|
241
|
-
'[data-blokkli-provider-active="true"] [data-uuid]'
|
|
242
|
-
)
|
|
243
|
-
].map((v) => {
|
|
244
|
-
const item = buildDraggableItem(v);
|
|
245
|
-
if (item?.itemType === "existing") {
|
|
246
|
-
return item;
|
|
247
|
-
}
|
|
248
|
-
}).filter(falsy);
|
|
249
|
-
};
|
|
250
203
|
const getDropElementMarkup = (item, checkSize) => {
|
|
251
|
-
const
|
|
204
|
+
const getElement = () => {
|
|
205
|
+
if ("itemType" in item) {
|
|
206
|
+
if (item.itemType === "existing") {
|
|
207
|
+
return getDragElement(item);
|
|
208
|
+
}
|
|
209
|
+
return item.element();
|
|
210
|
+
}
|
|
211
|
+
return getDragElement(item);
|
|
212
|
+
};
|
|
213
|
+
const el = getElement();
|
|
252
214
|
if (!el) {
|
|
253
215
|
return "";
|
|
254
216
|
}
|
|
255
|
-
const dropElement =
|
|
256
|
-
const childCount =
|
|
217
|
+
const dropElement = element.query(el, ".bk-drop-element", "Find drop element for markup.") || el;
|
|
218
|
+
const childCount = element.queryAll(
|
|
219
|
+
dropElement,
|
|
220
|
+
"*",
|
|
221
|
+
"Get child count for drop element markup."
|
|
222
|
+
).length;
|
|
257
223
|
if (checkSize && childCount > 80) {
|
|
258
224
|
return "";
|
|
259
225
|
}
|
|
@@ -262,32 +228,8 @@ export default function(ui, debug, definitions) {
|
|
|
262
228
|
""
|
|
263
229
|
);
|
|
264
230
|
};
|
|
265
|
-
const findField = (uuid, fieldName) => {
|
|
266
|
-
const el = document.querySelector(
|
|
267
|
-
`[data-field-name="${fieldName}"][data-host-entity-uuid="${uuid}"]`
|
|
268
|
-
);
|
|
269
|
-
if (!(el instanceof HTMLElement)) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
return buildFieldElement(el);
|
|
273
|
-
};
|
|
274
|
-
const getAllDroppableFields = () => [...document.querySelectorAll("[data-blokkli-droppable-field]")].filter((el) => {
|
|
275
|
-
return !el.closest('[data-bk-in-proxy="true"]');
|
|
276
|
-
}).map(mapDroppableField);
|
|
277
231
|
const getVisibleBlocks = () => Array.from(visibleBlocks);
|
|
278
232
|
const getVisibleFields = () => Array.from(visibleFields);
|
|
279
|
-
const getActiveProviderElement = () => {
|
|
280
|
-
const el = document.querySelector('[data-blokkli-provider-active="true"]');
|
|
281
|
-
if (!el) {
|
|
282
|
-
throw new Error("Failed to find active <BlokkliProvider> element.");
|
|
283
|
-
}
|
|
284
|
-
if (!(el instanceof HTMLElement)) {
|
|
285
|
-
throw new TypeError(
|
|
286
|
-
"The root element of the active <BlokkliProvider> is not an HTMLElement."
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
return el;
|
|
290
|
-
};
|
|
291
233
|
function getBlockRects() {
|
|
292
234
|
return blockRects;
|
|
293
235
|
}
|
|
@@ -329,9 +271,7 @@ export default function(ui, debug, definitions) {
|
|
|
329
271
|
);
|
|
330
272
|
}
|
|
331
273
|
function refreshFieldRect(key) {
|
|
332
|
-
const el =
|
|
333
|
-
`.bk-draggable-list-container[data-field-key="${key}"]`
|
|
334
|
-
);
|
|
274
|
+
const el = registeredFields[key]?.element;
|
|
335
275
|
if (!(el instanceof HTMLElement)) {
|
|
336
276
|
return;
|
|
337
277
|
}
|
|
@@ -372,7 +312,6 @@ export default function(ui, debug, definitions) {
|
|
|
372
312
|
}
|
|
373
313
|
onBlokkliEvent("state:reloaded", () => {
|
|
374
314
|
observedElementCache.clear();
|
|
375
|
-
draggableBlockCache = {};
|
|
376
315
|
if (stateReloadTimeout) {
|
|
377
316
|
window.clearTimeout(stateReloadTimeout);
|
|
378
317
|
}
|
|
@@ -397,16 +336,20 @@ export default function(ui, debug, definitions) {
|
|
|
397
336
|
const dragElementUuidMap = /* @__PURE__ */ new WeakMap();
|
|
398
337
|
const dragElementCache = /* @__PURE__ */ new Map();
|
|
399
338
|
function getDragElement(block) {
|
|
400
|
-
const
|
|
339
|
+
const item = "itemType" in block ? block.block : block;
|
|
340
|
+
if (!item) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
const el = registeredBlocks[item.uuid];
|
|
401
344
|
if (!el) {
|
|
402
|
-
return
|
|
345
|
+
return;
|
|
403
346
|
}
|
|
404
347
|
return getElementToObserve(
|
|
405
|
-
|
|
348
|
+
item.uuid,
|
|
406
349
|
el,
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
350
|
+
item.bundle,
|
|
351
|
+
item.fieldListType,
|
|
352
|
+
item.parentBlockBundle
|
|
410
353
|
);
|
|
411
354
|
}
|
|
412
355
|
function isBlockVisible(uuid) {
|
|
@@ -424,9 +367,7 @@ export default function(ui, debug, definitions) {
|
|
|
424
367
|
}
|
|
425
368
|
}
|
|
426
369
|
}
|
|
427
|
-
function
|
|
428
|
-
logger.log("registerBlock: " + uuid);
|
|
429
|
-
blockUuidCurrentKey[uuid] = key;
|
|
370
|
+
function doInitTimeout() {
|
|
430
371
|
if (initTimeout) {
|
|
431
372
|
window.clearTimeout(initTimeout);
|
|
432
373
|
}
|
|
@@ -436,6 +377,11 @@ export default function(ui, debug, definitions) {
|
|
|
436
377
|
refreshAllBlockRects();
|
|
437
378
|
}, 500);
|
|
438
379
|
}
|
|
380
|
+
}
|
|
381
|
+
function registerBlock(key, uuid, el) {
|
|
382
|
+
logger.log("registerBlock: " + uuid);
|
|
383
|
+
blockUuidCurrentKey[uuid] = key;
|
|
384
|
+
doInitTimeout();
|
|
439
385
|
if (!el) {
|
|
440
386
|
logger.log("registerBlock call unregisterBlock because no element", uuid);
|
|
441
387
|
unregisterBlock(key, uuid);
|
|
@@ -448,19 +394,24 @@ export default function(ui, debug, definitions) {
|
|
|
448
394
|
);
|
|
449
395
|
unregisterBlock(key, uuid);
|
|
450
396
|
}
|
|
451
|
-
const item =
|
|
452
|
-
if (item
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
397
|
+
const item = state.getFieldListItem(uuid);
|
|
398
|
+
if (item) {
|
|
399
|
+
const fieldList = state.getFieldListForBlock(item.uuid);
|
|
400
|
+
if (fieldList) {
|
|
401
|
+
const fieldListType = getRegisteredField(fieldList.entityUuid, fieldList.name)?.fieldListType ?? "default";
|
|
402
|
+
const parentBundle = fieldList.entityType === itemEntityType ? state.getFieldListItem(fieldList.entityUuid)?.bundle ?? null : null;
|
|
403
|
+
const observableElement = getElementToObserve(
|
|
404
|
+
item.uuid,
|
|
405
|
+
el,
|
|
406
|
+
item.bundle,
|
|
407
|
+
fieldListType,
|
|
408
|
+
parentBundle
|
|
409
|
+
);
|
|
410
|
+
registeredBlocks[uuid] = el;
|
|
411
|
+
observedElements[uuid] = observableElement;
|
|
412
|
+
intersectionObserver.observe(observableElement);
|
|
413
|
+
resizeObserver.observe(observableElement);
|
|
414
|
+
}
|
|
464
415
|
}
|
|
465
416
|
}
|
|
466
417
|
function unregisterBlock(key, uuid) {
|
|
@@ -490,8 +441,7 @@ export default function(ui, debug, definitions) {
|
|
|
490
441
|
...Object.keys(registeredBlocks),
|
|
491
442
|
...Object.keys(blockRects),
|
|
492
443
|
...Object.keys(observedElements),
|
|
493
|
-
...Object.keys(blockUuidCurrentKey)
|
|
494
|
-
...Object.keys(draggableBlockCache)
|
|
444
|
+
...Object.keys(blockUuidCurrentKey)
|
|
495
445
|
]);
|
|
496
446
|
const blocksInfo = Array.from(allUuids).map((uuid) => {
|
|
497
447
|
const el = registeredBlocks[uuid];
|
|
@@ -502,7 +452,6 @@ export default function(ui, debug, definitions) {
|
|
|
502
452
|
hasRect: !!blockRects[uuid],
|
|
503
453
|
hasCurrentKey: !!blockUuidCurrentKey[uuid],
|
|
504
454
|
isVisible: visibleBlocks.has(uuid),
|
|
505
|
-
inCache: !!draggableBlockCache[uuid],
|
|
506
455
|
elementInfo: el ? {
|
|
507
456
|
tagName: el.tagName,
|
|
508
457
|
bundle: el.dataset.itemBundle,
|
|
@@ -547,7 +496,6 @@ export default function(ui, debug, definitions) {
|
|
|
547
496
|
).length,
|
|
548
497
|
totalVisibleFields: visibleFields.size,
|
|
549
498
|
totalFieldRects: Object.keys(fieldRects).length,
|
|
550
|
-
cacheSize: Object.keys(draggableBlockCache).length,
|
|
551
499
|
isInitializing: isInitalizing.value,
|
|
552
500
|
isReady: mutationsReady.value && intersectionReady.value && !isInitalizing.value
|
|
553
501
|
},
|
|
@@ -559,19 +507,14 @@ export default function(ui, debug, definitions) {
|
|
|
559
507
|
};
|
|
560
508
|
}
|
|
561
509
|
return {
|
|
562
|
-
findBlock,
|
|
563
|
-
getAllBlocks,
|
|
564
510
|
findClosestBlock,
|
|
565
511
|
getDropElementMarkup,
|
|
566
|
-
findField,
|
|
567
|
-
getAllDroppableFields,
|
|
568
512
|
findClosestEntityContext,
|
|
569
513
|
getVisibleBlocks,
|
|
570
514
|
getVisibleFields,
|
|
571
515
|
registerField,
|
|
572
516
|
unregisterField,
|
|
573
517
|
updateFieldElement,
|
|
574
|
-
getActiveProviderElement,
|
|
575
518
|
getBlockRects,
|
|
576
519
|
getBlockRect,
|
|
577
520
|
getFieldRect,
|
|
@@ -587,6 +530,8 @@ export default function(ui, debug, definitions) {
|
|
|
587
530
|
registerBlock,
|
|
588
531
|
unregisterBlock,
|
|
589
532
|
registeredBlockUuids,
|
|
590
|
-
getDebugData
|
|
533
|
+
getDebugData,
|
|
534
|
+
getRegisteredField,
|
|
535
|
+
registeredBlocks: computed(() => registeredBlocks)
|
|
591
536
|
};
|
|
592
537
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DraggableItem, Rectangle,
|
|
1
|
+
import type { DraggableItem, Rectangle, DraggableExistingBlock, EntityContext, Coord, LibraryItemProps, Size } from '#blokkli/types';
|
|
2
2
|
import type { RGB } from '#blokkli/types/theme';
|
|
3
3
|
/**
|
|
4
4
|
* Type check for falsy values.
|
|
@@ -11,7 +11,6 @@ export declare function falsy<T>(value: T): value is NonNullable<T>;
|
|
|
11
11
|
* Maps a HTML element that is draggable to a draggable item data object.
|
|
12
12
|
*/
|
|
13
13
|
export declare function buildDraggableItem(element: Element | EventTarget): DraggableItem | undefined;
|
|
14
|
-
export declare function findElement(uuid: string): HTMLElement | undefined;
|
|
15
14
|
export declare function onlyUnique(value: string, index: number, self: Array<string>): boolean;
|
|
16
15
|
/**
|
|
17
16
|
* Convert a date to a relative time string, such as
|
|
@@ -83,12 +82,6 @@ export declare const findClosestBlock: (el: Element | EventTarget) => DraggableE
|
|
|
83
82
|
*/
|
|
84
83
|
export declare const findClosestEntityContext: (el: HTMLElement) => EntityContext | undefined;
|
|
85
84
|
export declare const findParentContext: (el: HTMLElement) => EntityContext | DraggableExistingBlock | undefined;
|
|
86
|
-
/**
|
|
87
|
-
* Maps a HTMLElement to a DroppableEntityField.
|
|
88
|
-
*/
|
|
89
|
-
export declare const mapDroppableField: (el: Element) => DroppableEntityField;
|
|
90
|
-
export declare const originatesFromEditable: (e: MouseEvent | TouchEvent) => HTMLElement | undefined;
|
|
91
|
-
export declare const getOriginatingDroppableElement: (e: MouseEvent | TouchEvent) => HTMLElement | undefined;
|
|
92
85
|
export declare const originatesFromTextInput: (e: Event) => boolean;
|
|
93
86
|
export declare function getFieldKey(uuid: string, fieldName: string): string;
|
|
94
87
|
export declare function getInteractionCoordinates(e: MouseEvent | TouchEvent): Coord;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { easeOutSine } from "./easing.js";
|
|
2
|
-
import { useRuntimeConfig } from "#imports";
|
|
3
2
|
export function falsy(value) {
|
|
4
3
|
return value !== null && value !== void 0;
|
|
5
4
|
}
|
|
@@ -7,44 +6,8 @@ export function buildDraggableItem(element) {
|
|
|
7
6
|
if (!(element instanceof HTMLElement)) {
|
|
8
7
|
return;
|
|
9
8
|
}
|
|
10
|
-
const itemEntityType = useRuntimeConfig().public.blokkli.itemEntityType;
|
|
11
9
|
const dataset = element.dataset;
|
|
12
|
-
if (dataset.elementType === "
|
|
13
|
-
const uuid = dataset.uuid;
|
|
14
|
-
const itemBundle = dataset.itemBundle;
|
|
15
|
-
const entityType = dataset.entityType;
|
|
16
|
-
const hostType = dataset.hostType;
|
|
17
|
-
const hostUuid = dataset.hostUuid;
|
|
18
|
-
const hostBundle = dataset.hostBundle;
|
|
19
|
-
const hostFieldName = dataset.hostFieldName;
|
|
20
|
-
const reusableBundle = dataset.reusableBundle;
|
|
21
|
-
const hostFieldListType = dataset.hostFieldListType;
|
|
22
|
-
const libraryItemUuid = dataset.bkLibraryItemUuid;
|
|
23
|
-
const isNew = dataset.isNew === "true";
|
|
24
|
-
const parentBlockBundle = hostType === itemEntityType ? hostBundle : void 0;
|
|
25
|
-
if (uuid && hostType && hostUuid && hostFieldName && itemBundle && hostBundle && entityType && hostFieldListType) {
|
|
26
|
-
const libraryLabel = dataset.bkLibraryLabel;
|
|
27
|
-
const editTitle = libraryLabel || "";
|
|
28
|
-
return {
|
|
29
|
-
itemType: "existing",
|
|
30
|
-
element: () => document.querySelector(`[data-uuid="${uuid}"]`),
|
|
31
|
-
itemBundle,
|
|
32
|
-
entityType,
|
|
33
|
-
isNested: hostType === itemEntityType,
|
|
34
|
-
uuid,
|
|
35
|
-
hostType,
|
|
36
|
-
hostBundle,
|
|
37
|
-
hostUuid,
|
|
38
|
-
hostFieldName,
|
|
39
|
-
hostFieldListType,
|
|
40
|
-
reusableBundle,
|
|
41
|
-
libraryItemUuid,
|
|
42
|
-
editTitle: editTitle || void 0,
|
|
43
|
-
isNew,
|
|
44
|
-
parentBlockBundle
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
} else if (dataset.elementType === "new") {
|
|
10
|
+
if (dataset.elementType === "new") {
|
|
48
11
|
const itemBundle = dataset.itemBundle;
|
|
49
12
|
if (itemBundle) {
|
|
50
13
|
return {
|
|
@@ -111,14 +74,6 @@ export function buildDraggableItem(element) {
|
|
|
111
74
|
}
|
|
112
75
|
}
|
|
113
76
|
}
|
|
114
|
-
export function findElement(uuid) {
|
|
115
|
-
const el = document.querySelector(
|
|
116
|
-
`[data-uuid="${uuid}"]:not(.bk-sortli-leave-from)`
|
|
117
|
-
);
|
|
118
|
-
if (el instanceof HTMLElement) {
|
|
119
|
-
return el;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
77
|
export function onlyUnique(value, index, self) {
|
|
123
78
|
return self.indexOf(value) === index;
|
|
124
79
|
}
|
|
@@ -443,44 +398,6 @@ export const findParentContext = (el) => {
|
|
|
443
398
|
}
|
|
444
399
|
return findClosestEntityContext(el);
|
|
445
400
|
};
|
|
446
|
-
export const mapDroppableField = (el) => {
|
|
447
|
-
if (!(el instanceof HTMLElement)) {
|
|
448
|
-
throw new TypeError(
|
|
449
|
-
`v-blokkli-droppable directive is only allowed on elements of type HTMLElement.`
|
|
450
|
-
);
|
|
451
|
-
}
|
|
452
|
-
const fieldName = el.dataset.blokkliDroppableField;
|
|
453
|
-
if (!fieldName) {
|
|
454
|
-
throw new Error(`Missing field name in v-blokkli-droppable directive.`);
|
|
455
|
-
}
|
|
456
|
-
const host = findParentContext(el);
|
|
457
|
-
if (!host) {
|
|
458
|
-
throw new Error(
|
|
459
|
-
`Failed to locate parent context for v-blokkli-droppable field with name "${fieldName}". Make sure the element is always rendered inside a block component or inside a <BlokkliProvider>.`
|
|
460
|
-
);
|
|
461
|
-
}
|
|
462
|
-
return {
|
|
463
|
-
element: el,
|
|
464
|
-
host,
|
|
465
|
-
fieldName
|
|
466
|
-
};
|
|
467
|
-
};
|
|
468
|
-
export const originatesFromEditable = (e) => {
|
|
469
|
-
if (e.target instanceof HTMLElement) {
|
|
470
|
-
const el = e.target.closest("[data-blokkli-editable-field]");
|
|
471
|
-
if (el instanceof HTMLElement) {
|
|
472
|
-
return el;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
|
-
export const getOriginatingDroppableElement = (e) => {
|
|
477
|
-
if (e.target instanceof HTMLElement) {
|
|
478
|
-
const el = e.target.closest("[data-blokkli-droppable-field]");
|
|
479
|
-
if (el instanceof HTMLElement) {
|
|
480
|
-
return el;
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
401
|
export const originatesFromTextInput = (e) => e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement;
|
|
485
402
|
export function getFieldKey(uuid, fieldName) {
|
|
486
403
|
return uuid + ":" + fieldName;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RenderedFieldListItem } from '#blokkli/types';
|
|
2
|
+
import type { DomProvider } from '../domProvider.js';
|
|
3
|
+
import type { StateProvider } from '../stateProvider.js';
|
|
4
|
+
import type { AdapterContext } from '#blokkli/adapter';
|
|
5
|
+
import type { ComputedRef } from 'vue';
|
|
6
|
+
export type BlocksProvider = {
|
|
7
|
+
getBlock: (uuid: string) => RenderedFieldListItem | undefined;
|
|
8
|
+
getAllBlocks: () => RenderedFieldListItem[];
|
|
9
|
+
};
|
|
10
|
+
export default function (state: StateProvider, dom: DomProvider, context: ComputedRef<AdapterContext>): BlocksProvider;
|