@blokkli/editor 2.0.0-alpha.1 → 2.0.0-alpha.10

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.
Files changed (92) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +25 -9
  3. package/dist/modules/drupal/graphql/base/fragment.blokkliProps.graphql +8 -0
  4. package/dist/modules/drupal/graphql/base/fragment.paragraphsFieldItem.graphql +6 -0
  5. package/dist/modules/drupal/index.mjs +33 -7
  6. package/dist/modules/drupal/runtime/adapter/index.d.ts +3 -0
  7. package/dist/modules/drupal/{adapter/index.mjs → runtime/adapter/index.js} +13 -10
  8. package/dist/runtime/blokkliPlugins/ContextMenu/index.vue.d.ts +2 -19
  9. package/dist/runtime/blokkliPlugins/DebugOverlay/index.vue.d.ts +2 -7
  10. package/dist/runtime/blokkliPlugins/DroppableEdit/index.vue +1 -1
  11. package/dist/runtime/blokkliPlugins/DroppableEdit/index.vue.d.ts +2 -19
  12. package/dist/runtime/blokkliPlugins/ItemAction/index.vue.d.ts +4 -3
  13. package/dist/runtime/blokkliPlugins/ItemDropdown/index.vue.d.ts +1 -1
  14. package/dist/runtime/blokkliPlugins/MenuButton/index.vue.d.ts +1 -1
  15. package/dist/runtime/blokkliPlugins/Sidebar/Detached/index.vue.d.ts +2 -51
  16. package/dist/runtime/blokkliPlugins/Sidebar/index.vue.d.ts +11 -5
  17. package/dist/runtime/blokkliPlugins/ToolbarButton/index.vue.d.ts +1 -1
  18. package/dist/runtime/blokkliPlugins/TourItem/index.vue.d.ts +2 -4
  19. package/dist/runtime/blokkliPlugins/ViewOption/index.vue.d.ts +4 -3
  20. package/dist/runtime/components/BlokkliEditable.vue +1 -0
  21. package/dist/runtime/components/BlokkliEditable.vue.d.ts +4 -18
  22. package/dist/runtime/components/BlokkliField.vue +4 -2
  23. package/dist/runtime/components/BlokkliField.vue.d.ts +8 -92
  24. package/dist/runtime/components/BlokkliItem.vue +1 -1
  25. package/dist/runtime/components/BlokkliProvider.vue +2 -1
  26. package/dist/runtime/components/BlokkliProvider.vue.d.ts +5 -22
  27. package/dist/runtime/components/Edit/Actions/index.vue +4 -1
  28. package/dist/runtime/components/Edit/BlockProxy/index.vue +3 -1
  29. package/dist/runtime/components/Edit/BlokkliErrorBoundary.vue +4 -4
  30. package/dist/runtime/components/Edit/BlokkliErrorBoundary.vue.d.ts +2 -13
  31. package/dist/runtime/components/Edit/Dialog/index.vue.d.ts +1 -1
  32. package/dist/runtime/components/Edit/DragInteractions/index.vue +1 -1
  33. package/dist/runtime/components/Edit/EditProvider.vue +7 -4
  34. package/dist/runtime/components/Edit/EditProvider.vue.d.ts +3 -3
  35. package/dist/runtime/components/Edit/Features/Artboard/index.vue +29 -1
  36. package/dist/runtime/components/Edit/Features/Assistant/Overlay/index.vue +4 -4
  37. package/dist/runtime/components/Edit/Features/Assistant/index.vue +2 -1
  38. package/dist/runtime/components/Edit/Features/Clipboard/index.vue +1 -1
  39. package/dist/runtime/components/Edit/Features/Comments/AddForm/index.vue +2 -2
  40. package/dist/runtime/components/Edit/Features/Comments/Comment/index.vue +1 -1
  41. package/dist/runtime/components/Edit/Features/Comments/Overlay/Item/index.vue +2 -2
  42. package/dist/runtime/components/Edit/Features/Diff/DiffView/index.vue +7 -7
  43. package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/index.vue.d.ts +3 -132
  44. package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue +2 -2
  45. package/dist/runtime/components/Edit/Features/Fragments/Dialog/index.vue +4 -4
  46. package/dist/runtime/components/Edit/Features/Fragments/index.vue +2 -1
  47. package/dist/runtime/components/Edit/Features/Help/index.vue +2 -2
  48. package/dist/runtime/components/Edit/Features/History/List/index.vue +4 -4
  49. package/dist/runtime/components/Edit/Features/ImportExisting/Dialog/index.vue +5 -5
  50. package/dist/runtime/components/Edit/Features/Library/EditReusable/index.vue +2 -2
  51. package/dist/runtime/components/Edit/Features/Library/LibraryDialog/index.vue +5 -5
  52. package/dist/runtime/components/Edit/Features/Library/ReusableDialog/index.vue +2 -2
  53. package/dist/runtime/components/Edit/Features/Library/index.vue +2 -1
  54. package/dist/runtime/components/Edit/Features/MediaLibrary/Library/index.vue +1 -1
  55. package/dist/runtime/components/Edit/Features/Options/Form/Group.vue.d.ts +2 -11
  56. package/dist/runtime/components/Edit/Features/Options/Form/Radios/index.vue +1 -1
  57. package/dist/runtime/components/Edit/Features/Ownership/index.vue +1 -1
  58. package/dist/runtime/components/Edit/Features/PreviewGrant/QrCode/index.vue +1 -1
  59. package/dist/runtime/components/Edit/Features/Publish/index.vue +20 -2
  60. package/dist/runtime/components/Edit/Features/ResponsivePreview/Frame/index.vue.d.ts +2 -13
  61. package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Content/index.vue +1 -1
  62. package/dist/runtime/components/Edit/Features/Search/index.vue +1 -1
  63. package/dist/runtime/components/Edit/Features/Tour/Overlay/index.vue +2 -2
  64. package/dist/runtime/components/Edit/Features/Tour/Popup/index.vue +4 -4
  65. package/dist/runtime/components/Edit/Features/Translations/Banner/index.vue +1 -1
  66. package/dist/runtime/components/Edit/Features/Validations/index.vue +1 -1
  67. package/dist/runtime/components/Edit/Form/Group/index.vue.d.ts +2 -4
  68. package/dist/runtime/components/Edit/Form/Item/index.vue.d.ts +2 -4
  69. package/dist/runtime/components/Edit/FormOverlay/index.vue.d.ts +3 -2
  70. package/dist/runtime/components/Edit/PreviewProvider.vue +1 -0
  71. package/dist/runtime/components/Edit/PreviewProvider.vue.d.ts +3 -3
  72. package/dist/runtime/components/Edit/RelativeTime/index.vue.d.ts +2 -2
  73. package/dist/runtime/components/Edit/Resizable/index.vue.d.ts +1 -1
  74. package/dist/runtime/components/Edit/ScaleToFit/index.vue.d.ts +1 -1
  75. package/dist/runtime/components/Edit/ScrollBoundary/index.vue.d.ts +2 -7
  76. package/dist/runtime/components/Edit/Sortli/index.vue.d.ts +1 -1
  77. package/dist/runtime/components/Edit/SystemRequirements/index.vue +2 -2
  78. package/dist/runtime/components/Edit/ViewportBlockingRect/index.vue.d.ts +2 -7
  79. package/dist/runtime/composables/defineBlokkli.js +8 -1
  80. package/dist/runtime/composables/defineBlokkliFragment.js +8 -1
  81. package/dist/runtime/composables/useBlokkliHelper.d.ts +19 -0
  82. package/dist/runtime/composables/useBlokkliHelper.js +82 -0
  83. package/dist/runtime/css/output.css +1 -1
  84. package/dist/runtime/helpers/animationProvider.js +1 -1
  85. package/dist/runtime/helpers/composables/useBlockRegistration.d.ts +5 -0
  86. package/dist/runtime/helpers/composables/useBlockRegistration.js +23 -0
  87. package/dist/runtime/helpers/domProvider.d.ts +2 -0
  88. package/dist/runtime/helpers/domProvider.js +50 -65
  89. package/dist/runtime/helpers/runtimeHelpers/index.js +1 -1
  90. package/dist/runtime/types/index.d.ts +38 -1
  91. package/package.json +8 -11
  92. package/dist/modules/drupal/adapter/index.d.mts +0 -6
@@ -18,7 +18,7 @@ export default function(ui) {
18
18
  return;
19
19
  }
20
20
  iterator--;
21
- eventBus.emit("animationFrame:before", time);
21
+ eventBus.emit("animationFrame:before", { time, mouseX, mouseY });
22
22
  eventBus.emit("animationFrame", {
23
23
  mouseX,
24
24
  mouseY,
@@ -0,0 +1,5 @@
1
+ import type { DomProvider } from '../domProvider.js';
2
+ /**
3
+ * Helper composable to handle registering the block in the DOM provider.
4
+ */
5
+ export declare function useBlockRegistration(dom: DomProvider, uuid: string): void;
@@ -0,0 +1,23 @@
1
+ import {
2
+ getCurrentInstance,
3
+ onBeforeUnmount,
4
+ onMounted,
5
+ onUpdated
6
+ } from "#imports";
7
+ export function useBlockRegistration(dom, uuid) {
8
+ const instance = getCurrentInstance();
9
+ const key = uuid + Math.round(Math.random() * 1e10).toString() + Date.now().toString();
10
+ let rootElement = null;
11
+ function setRootElement() {
12
+ const newElement = instance?.proxy?.$el;
13
+ if (newElement && rootElement !== newElement) {
14
+ rootElement = newElement;
15
+ dom.registerBlock(key, uuid, newElement);
16
+ }
17
+ }
18
+ onMounted(setRootElement);
19
+ onUpdated(setRootElement);
20
+ onBeforeUnmount(() => {
21
+ dom.unregisterBlock(key, uuid);
22
+ });
23
+ }
@@ -20,6 +20,8 @@ export type DomProvider = {
20
20
  */
21
21
  getDropElementMarkup(item: DraggableItem, checkSize?: boolean): string;
22
22
  findField(entityUuid: string, fieldName: string): BlokkliFieldElement | undefined;
23
+ registerBlock: (key: string, uuid: string, el: HTMLElement | null) => void;
24
+ unregisterBlock: (key: string, uuid: string) => void;
23
25
  registerField: (entity: EntityContext, fieldName: string, instance: HTMLElement) => void;
24
26
  updateFieldElement: (entity: EntityContext, fieldName: string, element: HTMLElement) => void;
25
27
  unregisterField: (entity: EntityContext, fieldName: string) => void;
@@ -49,7 +49,6 @@ function rectWithTime(rect, time) {
49
49
  };
50
50
  }
51
51
  export default function(ui, debug, definitions) {
52
- const artboardElement = ui.artboardElement();
53
52
  const logger = debug.createLogger("DomProvider");
54
53
  const mutationsReady = ref(true);
55
54
  const intersectionReady = ref(false);
@@ -57,6 +56,7 @@ export default function(ui, debug, definitions) {
57
56
  const visibleFields = /* @__PURE__ */ new Set();
58
57
  const blockRects = {};
59
58
  const fieldRects = {};
59
+ const blockUuidCurrentKey = {};
60
60
  let draggableBlockCache = {};
61
61
  const resizeObserver = new ResizeObserver(function(entries) {
62
62
  for (const entry of entries) {
@@ -360,66 +360,6 @@ export default function(ui, debug, definitions) {
360
360
  }
361
361
  const dragElementUuidMap = /* @__PURE__ */ new WeakMap();
362
362
  const dragElementCache = /* @__PURE__ */ new Map();
363
- function handleNodeAdded(node) {
364
- if (!(node instanceof HTMLElement)) {
365
- return;
366
- }
367
- if (node.dataset.uuid) {
368
- const item = buildDraggableItem(node);
369
- if (item && item.itemType === "existing") {
370
- const observableElement = getElementToObserve(
371
- node,
372
- item.itemBundle,
373
- item.hostFieldListType,
374
- item.hostBundle
375
- );
376
- intersectionObserver.observe(observableElement);
377
- resizeObserver.observe(observableElement);
378
- registeredBlocks[item.uuid] = node;
379
- }
380
- } else if (node.dataset.fieldName && node.dataset.fieldKey && node.dataset.fieldCardinality) {
381
- const blocks = node.querySelectorAll('[data-element-type="existing"]');
382
- for (const block of blocks) {
383
- handleNodeAdded(block);
384
- }
385
- }
386
- }
387
- function handleNodeRemoved(node) {
388
- if (node instanceof HTMLElement && node.dataset.uuid) {
389
- const uuid = node.dataset.uuid;
390
- const el = registeredBlocks[uuid];
391
- if (el !== node) {
392
- return;
393
- }
394
- if (el) {
395
- intersectionObserver.unobserve(el);
396
- resizeObserver.unobserve(el);
397
- dragElementUuidMap.delete(el);
398
- }
399
- dragElementUuidMap.delete(node);
400
- dragElementCache.delete(uuid);
401
- registeredBlocks[uuid] = void 0;
402
- delete blockRects[uuid];
403
- visibleBlocks.delete(uuid);
404
- }
405
- }
406
- const mutationObserverCallback = function(mutationsList) {
407
- for (const mutation of mutationsList) {
408
- if (mutation.type === "childList") {
409
- for (const node of mutation.removedNodes) {
410
- handleNodeRemoved(node);
411
- }
412
- for (const node of mutation.addedNodes) {
413
- handleNodeAdded(node);
414
- }
415
- }
416
- }
417
- };
418
- const mutationObserver = new MutationObserver(mutationObserverCallback);
419
- mutationObserver.observe(artboardElement, {
420
- subtree: true,
421
- childList: true
422
- });
423
363
  function getDragElement(block) {
424
364
  const cached = dragElementCache.get(block.uuid);
425
365
  if (cached && document.body.contains(cached)) {
@@ -429,9 +369,6 @@ export default function(ui, debug, definitions) {
429
369
  if (!el) {
430
370
  return;
431
371
  }
432
- if (el.parentNode) {
433
- mutationObserver.observe(el.parentNode, { childList: true });
434
- }
435
372
  dragElementUuidMap.set(el, block.uuid);
436
373
  dragElementCache.set(block.uuid, el);
437
374
  return el;
@@ -439,6 +376,52 @@ export default function(ui, debug, definitions) {
439
376
  function isBlockVisible(uuid) {
440
377
  return visibleBlocks.has(uuid);
441
378
  }
379
+ function registerBlock(key, uuid, el) {
380
+ logger.log("registerBlock: " + uuid);
381
+ blockUuidCurrentKey[uuid] = key;
382
+ if (!el) {
383
+ logger.log("registerBlock call unregisterBlock because no element", uuid);
384
+ unregisterBlock(key, uuid);
385
+ return;
386
+ }
387
+ if (registeredBlocks[uuid]) {
388
+ logger.log(
389
+ "registerBlock call unregisterBlock because already registered",
390
+ uuid
391
+ );
392
+ unregisterBlock(key, uuid);
393
+ }
394
+ const item = buildDraggableItem(el);
395
+ if (item && item.itemType === "existing") {
396
+ const observableElement = getElementToObserve(
397
+ el,
398
+ item.itemBundle,
399
+ item.hostFieldListType,
400
+ item.hostBundle
401
+ );
402
+ intersectionObserver.observe(observableElement);
403
+ resizeObserver.observe(observableElement);
404
+ registeredBlocks[item.uuid] = el;
405
+ }
406
+ }
407
+ function unregisterBlock(key, uuid) {
408
+ const currentKey = blockUuidCurrentKey[uuid];
409
+ if (currentKey && currentKey !== key) {
410
+ return;
411
+ }
412
+ logger.log("unregisterBlock: " + uuid);
413
+ const el = registeredBlocks[uuid];
414
+ if (el) {
415
+ intersectionObserver.unobserve(el);
416
+ resizeObserver.unobserve(el);
417
+ dragElementUuidMap.delete(el);
418
+ dragElementUuidMap.delete(el);
419
+ }
420
+ dragElementCache.delete(uuid);
421
+ registeredBlocks[uuid] = void 0;
422
+ delete blockRects[uuid];
423
+ visibleBlocks.delete(uuid);
424
+ }
442
425
  return {
443
426
  findBlock,
444
427
  getAllBlocks,
@@ -462,6 +445,8 @@ export default function(ui, debug, definitions) {
462
445
  init,
463
446
  getDragElement,
464
447
  updateVisibleRects,
465
- registeredFieldTypes
448
+ registeredFieldTypes,
449
+ registerBlock,
450
+ unregisterBlock
466
451
  };
467
452
  }
@@ -99,7 +99,7 @@ export function getRuntimeOptions(item, context, fromLibraryOptions) {
99
99
  if (fromLibraryOptions && fromLibraryOptions[key] !== void 0 && fromLibraryOptions[key] !== null) {
100
100
  acc[key] = getRuntimeOptionValue(
101
101
  definition,
102
- fromLibraryOptions.value[key]
102
+ fromLibraryOptions.value?.[key]
103
103
  );
104
104
  return acc;
105
105
  }
@@ -283,6 +283,37 @@ export type BlockDefinitionInput<Options extends BlockDefinitionOptionsInput = B
283
283
  * Settings for the behaviour in the editor.
284
284
  */
285
285
  editor?: BlokkliDefinitionInputEditor<Options, GlobalOptions, Bundle>;
286
+ /**
287
+ * Map which component prop maps to which field name.
288
+ *
289
+ * For example, if the field is named "field_paragraphs_header" and the prop
290
+ * is named "headerParagraphs", you would define it as such:
291
+ *
292
+ * @example
293
+ * ```vue
294
+ * <template>
295
+ * <div>
296
+ * <BlokkliField :list="headerParagraphs" name="field_paragraphs_header" />
297
+ * </div>
298
+ * <template>
299
+ *
300
+ * <script lang="ts" setup>
301
+ * import type { ParagraphTwoColumnsFragment } from '#graphql-operations'
302
+ *
303
+ * defineProps<{
304
+ * headerParagraphs: ParagraphTwoColumnsFragment['headerParagraphs']
305
+ * }>()
306
+ *
307
+ * defineBlokkli({
308
+ * bundle: 'section',
309
+ * propsFieldMapping: {
310
+ * headerParagraphs: 'field_paragraphs_header',
311
+ * }
312
+ * })
313
+ * </script>
314
+ * ```
315
+ */
316
+ propsFieldMapping?: Bundle extends BundleKey ? Partial<Record<keyof BundleProps[Bundle], string>> : never;
286
317
  };
287
318
  export type RuntimeBlockDefinitionInput = {
288
319
  bundle: string;
@@ -870,6 +901,11 @@ export type LibraryEditItemEvent = {
870
901
  uuid: string;
871
902
  label?: string;
872
903
  };
904
+ export type AnimationFrameBeforeEvent = {
905
+ time: number;
906
+ mouseX: number;
907
+ mouseY: number;
908
+ };
873
909
  export type EventbusEvents = {
874
910
  select: string | string[];
875
911
  'select:unselect': undefined;
@@ -899,7 +935,7 @@ export type EventbusEvents = {
899
935
  'block:append': BlockAppendEvent;
900
936
  'item:doubleClick': DraggableExistingBlock;
901
937
  scrollIntoView: ScrollIntoViewEvent;
902
- 'animationFrame:before': number;
938
+ 'animationFrame:before': AnimationFrameBeforeEvent;
903
939
  'canvas:draw': CanvasDrawEvent;
904
940
  'state:reloaded': undefined;
905
941
  addContentSearchItem: AddContentSearchItemEvent;
@@ -936,6 +972,7 @@ export type ItemEditContext = {
936
972
  mutatedOptions: MutatedOptions;
937
973
  dom?: DomProvider;
938
974
  definitions: DefinitionProvider;
975
+ useBlockRegistration?: (dom: DomProvider, uuid: string) => void;
939
976
  };
940
977
  export interface BlokkliApp {
941
978
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blokkli/editor",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-alpha.10",
4
4
  "description": "Interactive page building experience for Nuxt",
5
5
  "repository": "blokkli/editor",
6
6
  "type": "module",
@@ -70,10 +70,10 @@
70
70
  "@ckeditor/ckeditor5-build-classic": "^43.1.0",
71
71
  "@ckeditor/ckeditor5-vue": "^7.0.0",
72
72
  "@nuxt/devtools": "latest",
73
- "@nuxt/eslint-config": "^0.5.7",
74
- "@nuxt/kit": "^3.16.2",
73
+ "@nuxt/eslint-config": "^1.3.0",
74
+ "@nuxt/kit": "^3.17.2",
75
75
  "@nuxt/module-builder": "^1.0.1",
76
- "@nuxt/schema": "^3.16.2",
76
+ "@nuxt/schema": "^3.17.2",
77
77
  "@nuxt/test-utils": "^3.14.2",
78
78
  "@nuxtjs/tailwindcss": "^6.12.1",
79
79
  "@tailwindcss/forms": "^0.5.9",
@@ -84,12 +84,12 @@
84
84
  "@vue/test-utils": "^2.4.6",
85
85
  "changelogen": "^0.5.5",
86
86
  "cypress": "^13.14.2",
87
- "eslint": "^8.57.0",
88
- "eslint-plugin-sonarjs": "^2.0.2",
89
- "eslint-plugin-tailwindcss": "^3.17.4",
87
+ "eslint": "^9.24.0",
88
+ "eslint-plugin-sonarjs": "^3.0.2",
89
+ "eslint-plugin-tailwindcss": "^3.18.0",
90
90
  "gettext-parser": "^8.0.0",
91
91
  "happy-dom": "^15.7.4",
92
- "nuxt": "^3.16.2",
92
+ "nuxt": "^3.17.2",
93
93
  "nuxt-graphql-middleware": "^5.0.0-alpha.18",
94
94
  "nuxt-svg-icon-sprite": "^2.0.0-alpha.1",
95
95
  "openai": "^4.59.0",
@@ -107,8 +107,5 @@
107
107
  "vite-plugin-glsl": "^1.3.0",
108
108
  "vitepress": "^1.3.4",
109
109
  "vitest": "^2.0.5"
110
- },
111
- "overrides": {
112
- "@parcel/watcher": "~2.1.0"
113
110
  }
114
111
  }
@@ -1,6 +0,0 @@
1
- import * as _blokkli_adapter from '#blokkli/adapter';
2
- import { ParagraphsBlokkliEditStateFragment } from '#graphql-operations';
3
-
4
- declare const _default: _blokkli_adapter.BlokkliAdapterFactory<ParagraphsBlokkliEditStateFragment>;
5
-
6
- export { _default as default };