@blokkli/editor 1.4.0-alpha.1 → 2.0.0-alpha.2

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 (439) hide show
  1. package/dist/module.d.mts +12 -194
  2. package/dist/module.json +4 -4
  3. package/dist/module.mjs +1847 -1306
  4. package/dist/modules/drupal/adapter/index.d.mts +6 -0
  5. package/dist/modules/drupal/adapter/index.mjs +762 -0
  6. package/dist/modules/drupal/graphql/base/fragment.paragraphsBlokkliEditState.graphql +44 -0
  7. package/dist/modules/drupal/graphql/base/fragment.paragraphsBlokkliMutatedField.graphql +11 -0
  8. package/dist/modules/drupal/graphql/base/fragment.paragraphsBlokkliMutationItem.graphql +9 -0
  9. package/dist/modules/drupal/graphql/base/fragment.paragraphsBlokkliMutationResult.graphql +7 -0
  10. package/dist/modules/drupal/graphql/base/fragment.paragraphsBlokkliViolation.graphql +7 -0
  11. package/dist/modules/drupal/graphql/base/query.pbConfig.graphql +96 -0
  12. package/dist/modules/drupal/graphql/base/query.pbEditState.graphql +15 -0
  13. package/dist/modules/drupal/graphql/features/conversions.graphql +44 -0
  14. package/dist/modules/drupal/graphql/features/import-existing.graphql +34 -0
  15. package/dist/{runtime/adapter/drupal/graphql → modules/drupal/graphql/features}/library.graphql +17 -0
  16. package/dist/modules/drupal/graphql/features/media-library.graphql +28 -0
  17. package/dist/modules/drupal/graphql/features/preview-grant.graphql +13 -0
  18. package/dist/modules/drupal/graphql/features/publish.graphql +15 -0
  19. package/dist/modules/drupal/graphql/features/publishNew.graphql +59 -0
  20. package/dist/modules/drupal/graphql/mutations/add.graphql +25 -0
  21. package/dist/modules/drupal/graphql/mutations/add_clipboard_text.graphql +25 -0
  22. package/dist/modules/drupal/graphql/mutations/add_entity_reference.graphql +31 -0
  23. package/dist/modules/drupal/graphql/mutations/add_entity_reference_multiple.graphql +25 -0
  24. package/dist/modules/drupal/graphql/mutations/add_file.graphql +27 -0
  25. package/dist/modules/drupal/graphql/mutations/add_image.graphql +27 -0
  26. package/dist/modules/drupal/graphql/mutations/add_video_remote.graphql +25 -0
  27. package/dist/modules/drupal/graphql/mutations/bulk_update_behavior_settings.graphql +15 -0
  28. package/dist/modules/drupal/graphql/mutations/duplicate.graphql +33 -0
  29. package/dist/modules/drupal/graphql/mutations/move.graphql +25 -0
  30. package/dist/modules/drupal/graphql/mutations/move_multiple.graphql +25 -0
  31. package/dist/modules/drupal/graphql/mutations/redo.graphql +14 -0
  32. package/dist/modules/drupal/graphql/mutations/remove.graphql +15 -0
  33. package/dist/modules/drupal/graphql/mutations/remove_multiple.graphql +15 -0
  34. package/dist/modules/drupal/graphql/mutations/replace_host_entity_media.graphql +20 -0
  35. package/dist/modules/drupal/graphql/mutations/replace_media.graphql +22 -0
  36. package/dist/modules/drupal/graphql/mutations/revertAllChanges.graphql +14 -0
  37. package/dist/modules/drupal/graphql/mutations/setHistoryIndex.graphql +15 -0
  38. package/dist/modules/drupal/graphql/mutations/setMutationStatus.graphql +16 -0
  39. package/dist/modules/drupal/graphql/mutations/takeOwnership.graphql +14 -0
  40. package/dist/modules/drupal/graphql/mutations/undo.graphql +14 -0
  41. package/dist/modules/drupal/graphql/mutations/update_behavior_setting.graphql +23 -0
  42. package/dist/modules/drupal/graphql/mutations/update_field_value.graphql +22 -0
  43. package/dist/modules/drupal/graphql/mutations/update_host_entity_field_value.graphql +20 -0
  44. package/dist/modules/drupal/index.d.mts +10 -0
  45. package/dist/modules/drupal/index.mjs +170 -0
  46. package/dist/runtime/adapter/index.d.ts +30 -4
  47. package/dist/runtime/blokkliPlugins/AddAction/index.vue +39 -54
  48. package/dist/runtime/blokkliPlugins/AddAction/index.vue.d.ts +26 -0
  49. package/dist/runtime/blokkliPlugins/ContextMenu/Menu/index.vue +38 -64
  50. package/dist/runtime/blokkliPlugins/ContextMenu/Menu/index.vue.d.ts +12 -0
  51. package/dist/runtime/blokkliPlugins/ContextMenu/index.vue +19 -30
  52. package/dist/runtime/blokkliPlugins/ContextMenu/index.vue.d.ts +37 -0
  53. package/dist/runtime/blokkliPlugins/DebugOverlay/index.vue +15 -23
  54. package/dist/runtime/blokkliPlugins/DebugOverlay/index.vue.d.ts +21 -0
  55. package/dist/runtime/blokkliPlugins/DroppableEdit/index.vue +28 -45
  56. package/dist/runtime/blokkliPlugins/DroppableEdit/index.vue.d.ts +41 -0
  57. package/dist/runtime/blokkliPlugins/ItemAction/index.vue +39 -85
  58. package/dist/runtime/blokkliPlugins/ItemAction/index.vue.d.ts +83 -0
  59. package/dist/runtime/blokkliPlugins/ItemDropdown/index.vue +22 -26
  60. package/dist/runtime/blokkliPlugins/ItemDropdown/index.vue.d.ts +17 -0
  61. package/dist/runtime/blokkliPlugins/MenuButton/index.vue +30 -38
  62. package/dist/runtime/blokkliPlugins/MenuButton/index.vue.d.ts +32 -0
  63. package/dist/runtime/blokkliPlugins/Sidebar/Detached/index.vue +146 -211
  64. package/dist/runtime/blokkliPlugins/Sidebar/Detached/index.vue.d.ts +91 -0
  65. package/dist/runtime/blokkliPlugins/Sidebar/index.vue +95 -139
  66. package/dist/runtime/blokkliPlugins/Sidebar/index.vue.d.ts +85 -0
  67. package/dist/runtime/blokkliPlugins/ToolbarButton/index.vue +38 -57
  68. package/dist/runtime/blokkliPlugins/ToolbarButton/index.vue.d.ts +48 -0
  69. package/dist/runtime/blokkliPlugins/TourItem/index.vue +20 -29
  70. package/dist/runtime/blokkliPlugins/TourItem/index.vue.d.ts +20 -0
  71. package/dist/runtime/blokkliPlugins/ViewOption/index.vue +45 -59
  72. package/dist/runtime/blokkliPlugins/ViewOption/index.vue.d.ts +39 -0
  73. package/dist/runtime/components/Blocks/Fragment/index.vue +13 -20
  74. package/dist/runtime/components/Blocks/Fragment/index.vue.d.ts +6 -0
  75. package/dist/runtime/components/Blocks/FromLibrary/index.vue +19 -29
  76. package/dist/runtime/components/Blocks/FromLibrary/index.vue.d.ts +6 -0
  77. package/dist/runtime/components/BlokkliEditable.vue +30 -49
  78. package/dist/runtime/components/BlokkliEditable.vue.d.ts +20 -0
  79. package/dist/runtime/components/BlokkliField.vue +101 -159
  80. package/dist/runtime/components/BlokkliField.vue.d.ts +49 -0
  81. package/dist/runtime/components/BlokkliItem.vue +43 -66
  82. package/dist/runtime/components/BlokkliItem.vue.d.ts +26 -0
  83. package/dist/runtime/components/BlokkliProvider.vue +51 -87
  84. package/dist/runtime/components/BlokkliProvider.vue.d.ts +34 -0
  85. package/dist/runtime/components/Edit/Actions/index.vue +116 -164
  86. package/dist/runtime/components/Edit/Actions/index.vue.d.ts +2 -0
  87. package/dist/runtime/components/Edit/AddListItem/index.vue +45 -66
  88. package/dist/runtime/components/Edit/AddListItem/index.vue.d.ts +28 -0
  89. package/dist/runtime/components/Edit/AnimationCanvas/index.vue +52 -88
  90. package/dist/runtime/components/Edit/AnimationCanvas/index.vue.d.ts +2 -0
  91. package/dist/runtime/components/Edit/AppMenu/index.vue +12 -15
  92. package/dist/runtime/components/Edit/AppMenu/index.vue.d.ts +2 -0
  93. package/dist/runtime/components/Edit/BlockProxy/index.vue +48 -82
  94. package/dist/runtime/components/Edit/BlockProxy/index.vue.d.ts +10 -0
  95. package/dist/runtime/components/Edit/BlokkliErrorBoundary.vue +17 -21
  96. package/dist/runtime/components/Edit/BlokkliErrorBoundary.vue.d.ts +23 -0
  97. package/dist/runtime/components/Edit/Dialog/index.vue +67 -103
  98. package/dist/runtime/components/Edit/Dialog/index.vue.d.ts +44 -0
  99. package/dist/runtime/components/Edit/DragInteractions/index.vue +219 -333
  100. package/dist/runtime/components/Edit/DragInteractions/index.vue.d.ts +2 -0
  101. package/dist/runtime/components/Edit/DraggableList.vue +82 -125
  102. package/dist/runtime/components/Edit/DraggableList.vue.d.ts +27 -0
  103. package/dist/runtime/components/Edit/EditIndicator.vue +34 -46
  104. package/dist/runtime/components/Edit/EditIndicator.vue.d.ts +11 -0
  105. package/dist/runtime/components/Edit/EditProvider.vue +146 -142
  106. package/dist/runtime/components/Edit/EditProvider.vue.d.ts +26 -0
  107. package/dist/runtime/components/Edit/Features/AddList/index.vue +90 -117
  108. package/dist/runtime/components/Edit/Features/AddList/index.vue.d.ts +2 -0
  109. package/dist/runtime/components/Edit/Features/Artboard/Overview/index.vue +43 -63
  110. package/dist/runtime/components/Edit/Features/Artboard/Overview/index.vue.d.ts +6 -0
  111. package/dist/runtime/components/Edit/Features/Artboard/Scrollbar/index.vue +18 -23
  112. package/dist/runtime/components/Edit/Features/Artboard/Scrollbar/index.vue.d.ts +7 -0
  113. package/dist/runtime/components/Edit/Features/Artboard/index.vue +174 -223
  114. package/dist/runtime/components/Edit/Features/Artboard/index.vue.d.ts +2 -0
  115. package/dist/runtime/components/Edit/Features/Assistant/Overlay/ResultMarkup/index.vue +7 -7
  116. package/dist/runtime/components/Edit/Features/Assistant/Overlay/ResultMarkup/index.vue.d.ts +6 -0
  117. package/dist/runtime/components/Edit/Features/Assistant/Overlay/index.vue +41 -54
  118. package/dist/runtime/components/Edit/Features/Assistant/Overlay/index.vue.d.ts +8 -0
  119. package/dist/runtime/components/Edit/Features/Assistant/index.vue +31 -40
  120. package/dist/runtime/components/Edit/Features/Assistant/index.vue.d.ts +2 -0
  121. package/dist/runtime/components/Edit/Features/BlockAddList/index.vue +225 -326
  122. package/dist/runtime/components/Edit/Features/BlockAddList/index.vue.d.ts +2 -0
  123. package/dist/runtime/components/Edit/Features/Clipboard/List/Item/File.vue +36 -44
  124. package/dist/runtime/components/Edit/Features/Clipboard/List/Item/File.vue.d.ts +3 -0
  125. package/dist/runtime/components/Edit/Features/Clipboard/List/Item/Video.vue +33 -35
  126. package/dist/runtime/components/Edit/Features/Clipboard/List/Item/Video.vue.d.ts +3 -0
  127. package/dist/runtime/components/Edit/Features/Clipboard/List/index.vue +13 -21
  128. package/dist/runtime/components/Edit/Features/Clipboard/List/index.vue.d.ts +10 -0
  129. package/dist/runtime/components/Edit/Features/Clipboard/index.vue +227 -298
  130. package/dist/runtime/components/Edit/Features/Clipboard/index.vue.d.ts +2 -0
  131. package/dist/runtime/components/Edit/Features/CommandPalette/Palette/Group/index.vue +24 -34
  132. package/dist/runtime/components/Edit/Features/CommandPalette/Palette/Group/index.vue.d.ts +22 -0
  133. package/dist/runtime/components/Edit/Features/CommandPalette/Palette/index.vue +146 -195
  134. package/dist/runtime/components/Edit/Features/CommandPalette/Palette/index.vue.d.ts +6 -0
  135. package/dist/runtime/components/Edit/Features/CommandPalette/index.vue +21 -26
  136. package/dist/runtime/components/Edit/Features/CommandPalette/index.vue.d.ts +2 -0
  137. package/dist/runtime/components/Edit/Features/Comments/AddForm/index.vue +11 -14
  138. package/dist/runtime/components/Edit/Features/Comments/AddForm/index.vue.d.ts +8 -0
  139. package/dist/runtime/components/Edit/Features/Comments/Comment/index.vue +21 -29
  140. package/dist/runtime/components/Edit/Features/Comments/Comment/index.vue.d.ts +23 -0
  141. package/dist/runtime/components/Edit/Features/Comments/Overlay/Item/index.vue +31 -43
  142. package/dist/runtime/components/Edit/Features/Comments/Overlay/Item/index.vue.d.ts +19 -0
  143. package/dist/runtime/components/Edit/Features/Comments/Overlay/index.vue +70 -100
  144. package/dist/runtime/components/Edit/Features/Comments/Overlay/index.vue.d.ts +18 -0
  145. package/dist/runtime/components/Edit/Features/Comments/index.vue +37 -48
  146. package/dist/runtime/components/Edit/Features/Comments/index.vue.d.ts +2 -0
  147. package/dist/runtime/components/Edit/Features/Conversions/index.vue +40 -56
  148. package/dist/runtime/components/Edit/Features/Conversions/index.vue.d.ts +2 -0
  149. package/dist/runtime/components/Edit/Features/Debug/Rects/index.vue +37 -50
  150. package/dist/runtime/components/Edit/Features/Debug/Rects/index.vue.d.ts +2 -0
  151. package/dist/runtime/components/Edit/Features/Debug/Viewport/index.vue +35 -44
  152. package/dist/runtime/components/Edit/Features/Debug/Viewport/index.vue.d.ts +2 -0
  153. package/dist/runtime/components/Edit/Features/Debug/index.vue +43 -57
  154. package/dist/runtime/components/Edit/Features/Debug/index.vue.d.ts +2 -0
  155. package/dist/runtime/components/Edit/Features/Delete/index.vue +31 -52
  156. package/dist/runtime/components/Edit/Features/Delete/index.vue.d.ts +2 -0
  157. package/dist/runtime/components/Edit/Features/Diff/DiffView/index.vue +75 -114
  158. package/dist/runtime/components/Edit/Features/Diff/DiffView/index.vue.d.ts +2 -0
  159. package/dist/runtime/components/Edit/Features/Diff/index.vue +17 -19
  160. package/dist/runtime/components/Edit/Features/Diff/index.vue.d.ts +2 -0
  161. package/dist/runtime/components/Edit/Features/DraggingOverlay/DragItems/index.vue +193 -337
  162. package/dist/runtime/components/Edit/Features/DraggingOverlay/DragItems/index.vue.d.ts +27 -0
  163. package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/fragment.glsl +1 -1
  164. package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/index.vue +391 -644
  165. package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/index.vue.d.ts +156 -0
  166. package/dist/runtime/components/Edit/Features/DraggingOverlay/index.vue +197 -323
  167. package/dist/runtime/components/Edit/Features/DraggingOverlay/index.vue.d.ts +2 -0
  168. package/dist/runtime/components/Edit/Features/Duplicate/index.vue +49 -71
  169. package/dist/runtime/components/Edit/Features/Duplicate/index.vue.d.ts +2 -0
  170. package/dist/runtime/components/Edit/Features/Edit/index.vue +41 -71
  171. package/dist/runtime/components/Edit/Features/Edit/index.vue.d.ts +2 -0
  172. package/dist/runtime/components/Edit/Features/EditForm/Frame/index.vue +35 -51
  173. package/dist/runtime/components/Edit/Features/EditForm/Frame/index.vue.d.ts +11 -0
  174. package/dist/runtime/components/Edit/Features/EditForm/index.vue +104 -140
  175. package/dist/runtime/components/Edit/Features/EditForm/index.vue.d.ts +2 -0
  176. package/dist/runtime/components/Edit/Features/EditableField/Overlay/Contenteditable/index.vue +18 -25
  177. package/dist/runtime/components/Edit/Features/EditableField/Overlay/Contenteditable/index.vue.d.ts +12 -0
  178. package/dist/runtime/components/Edit/Features/EditableField/Overlay/Frame/index.vue +34 -50
  179. package/dist/runtime/components/Edit/Features/EditableField/Overlay/Frame/index.vue.d.ts +16 -0
  180. package/dist/runtime/components/Edit/Features/EditableField/Overlay/Plaintext/index.vue +40 -51
  181. package/dist/runtime/components/Edit/Features/EditableField/Overlay/Plaintext/index.vue.d.ts +16 -0
  182. package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue +147 -209
  183. package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue.d.ts +15 -0
  184. package/dist/runtime/components/Edit/Features/EditableField/index.vue +90 -143
  185. package/dist/runtime/components/Edit/Features/EditableField/index.vue.d.ts +2 -0
  186. package/dist/runtime/components/Edit/Features/EditableMask/index.vue +28 -36
  187. package/dist/runtime/components/Edit/Features/EditableMask/index.vue.d.ts +2 -0
  188. package/dist/runtime/components/Edit/Features/EntityTitle/index.vue +49 -58
  189. package/dist/runtime/components/Edit/Features/EntityTitle/index.vue.d.ts +2 -0
  190. package/dist/runtime/components/Edit/Features/Exit/index.vue +16 -20
  191. package/dist/runtime/components/Edit/Features/Exit/index.vue.d.ts +2 -0
  192. package/dist/runtime/components/Edit/Features/FieldAreas/Overlay/index.vue +4 -15
  193. package/dist/runtime/components/Edit/Features/FieldAreas/Overlay/index.vue.d.ts +2 -0
  194. package/dist/runtime/components/Edit/Features/FieldAreas/index.vue +19 -21
  195. package/dist/runtime/components/Edit/Features/FieldAreas/index.vue.d.ts +2 -0
  196. package/dist/runtime/components/Edit/Features/Fragments/Dialog/Item/index.vue +28 -35
  197. package/dist/runtime/components/Edit/Features/Fragments/Dialog/Item/index.vue.d.ts +8 -0
  198. package/dist/runtime/components/Edit/Features/Fragments/Dialog/index.vue +51 -74
  199. package/dist/runtime/components/Edit/Features/Fragments/Dialog/index.vue.d.ts +12 -0
  200. package/dist/runtime/components/Edit/Features/Fragments/index.vue +41 -51
  201. package/dist/runtime/components/Edit/Features/Fragments/index.vue.d.ts +2 -0
  202. package/dist/runtime/components/Edit/Features/Grid/index.vue +17 -20
  203. package/dist/runtime/components/Edit/Features/Grid/index.vue.d.ts +2 -0
  204. package/dist/runtime/components/Edit/Features/Help/Shortcuts/index.vue +24 -35
  205. package/dist/runtime/components/Edit/Features/Help/Shortcuts/index.vue.d.ts +2 -0
  206. package/dist/runtime/components/Edit/Features/Help/index.vue +19 -23
  207. package/dist/runtime/components/Edit/Features/Help/index.vue.d.ts +2 -0
  208. package/dist/runtime/components/Edit/Features/History/List/index.vue +49 -70
  209. package/dist/runtime/components/Edit/Features/History/List/index.vue.d.ts +5 -0
  210. package/dist/runtime/components/Edit/Features/History/index.vue +54 -69
  211. package/dist/runtime/components/Edit/Features/History/index.vue.d.ts +2 -0
  212. package/dist/runtime/components/Edit/Features/ImportExisting/Dialog/index.vue +48 -66
  213. package/dist/runtime/components/Edit/Features/ImportExisting/Dialog/index.vue.d.ts +14 -0
  214. package/dist/runtime/components/Edit/Features/ImportExisting/index.vue +38 -54
  215. package/dist/runtime/components/Edit/Features/ImportExisting/index.vue.d.ts +2 -0
  216. package/dist/runtime/components/Edit/Features/Library/EditReusable/index.vue +90 -128
  217. package/dist/runtime/components/Edit/Features/Library/EditReusable/index.vue.d.ts +13 -0
  218. package/dist/runtime/components/Edit/Features/Library/LibraryDialog/Item/index.vue +29 -38
  219. package/dist/runtime/components/Edit/Features/Library/LibraryDialog/Item/index.vue.d.ts +9 -0
  220. package/dist/runtime/components/Edit/Features/Library/LibraryDialog/index.vue +68 -93
  221. package/dist/runtime/components/Edit/Features/Library/LibraryDialog/index.vue.d.ts +12 -0
  222. package/dist/runtime/components/Edit/Features/Library/ReusableDialog/index.vue +39 -49
  223. package/dist/runtime/components/Edit/Features/Library/ReusableDialog/index.vue.d.ts +12 -0
  224. package/dist/runtime/components/Edit/Features/Library/index.vue +85 -117
  225. package/dist/runtime/components/Edit/Features/Library/index.vue.d.ts +2 -0
  226. package/dist/runtime/components/Edit/Features/MediaLibrary/Library/Item.vue +13 -19
  227. package/dist/runtime/components/Edit/Features/MediaLibrary/Library/Item.vue.d.ts +19 -0
  228. package/dist/runtime/components/Edit/Features/MediaLibrary/Library/index.vue +76 -112
  229. package/dist/runtime/components/Edit/Features/MediaLibrary/Library/index.vue.d.ts +6 -0
  230. package/dist/runtime/components/Edit/Features/MediaLibrary/index.vue +107 -140
  231. package/dist/runtime/components/Edit/Features/MediaLibrary/index.vue.d.ts +2 -0
  232. package/dist/runtime/components/Edit/Features/MultiSelect/Overlay/index.vue +128 -188
  233. package/dist/runtime/components/Edit/Features/MultiSelect/Overlay/index.vue.d.ts +12 -0
  234. package/dist/runtime/components/Edit/Features/MultiSelect/index.vue +42 -57
  235. package/dist/runtime/components/Edit/Features/MultiSelect/index.vue.d.ts +2 -0
  236. package/dist/runtime/components/Edit/Features/Options/Form/Checkbox/index.vue +27 -34
  237. package/dist/runtime/components/Edit/Features/Options/Form/Checkbox/index.vue.d.ts +14 -0
  238. package/dist/runtime/components/Edit/Features/Options/Form/Checkboxes/index.vue +55 -75
  239. package/dist/runtime/components/Edit/Features/Options/Form/Checkboxes/index.vue.d.ts +24 -0
  240. package/dist/runtime/components/Edit/Features/Options/Form/Color/index.vue +18 -21
  241. package/dist/runtime/components/Edit/Features/Options/Form/Color/index.vue.d.ts +12 -0
  242. package/dist/runtime/components/Edit/Features/Options/Form/DateTimeLocal/index.vue +36 -0
  243. package/dist/runtime/components/Edit/Features/Options/Form/DateTimeLocal/index.vue.d.ts +20 -0
  244. package/dist/runtime/components/Edit/Features/Options/Form/Group.vue +7 -9
  245. package/dist/runtime/components/Edit/Features/Options/Form/Group.vue.d.ts +29 -0
  246. package/dist/runtime/components/Edit/Features/Options/Form/Item.vue +87 -93
  247. package/dist/runtime/components/Edit/Features/Options/Form/Item.vue.d.ts +14 -0
  248. package/dist/runtime/components/Edit/Features/Options/Form/Number/index.vue +31 -45
  249. package/dist/runtime/components/Edit/Features/Options/Form/Number/index.vue.d.ts +21 -0
  250. package/dist/runtime/components/Edit/Features/Options/Form/Radios/index.vue +55 -79
  251. package/dist/runtime/components/Edit/Features/Options/Form/Radios/index.vue.d.ts +30 -0
  252. package/dist/runtime/components/Edit/Features/Options/Form/Range/index.vue +23 -33
  253. package/dist/runtime/components/Edit/Features/Options/Form/Range/index.vue.d.ts +18 -0
  254. package/dist/runtime/components/Edit/Features/Options/Form/Text/index.vue +17 -26
  255. package/dist/runtime/components/Edit/Features/Options/Form/Text/index.vue.d.ts +17 -0
  256. package/dist/runtime/components/Edit/Features/Options/Form/index.vue +178 -272
  257. package/dist/runtime/components/Edit/Features/Options/Form/index.vue.d.ts +9 -0
  258. package/dist/runtime/components/Edit/Features/Options/index.vue +38 -69
  259. package/dist/runtime/components/Edit/Features/Options/index.vue.d.ts +2 -0
  260. package/dist/runtime/components/Edit/Features/Ownership/index.vue +27 -34
  261. package/dist/runtime/components/Edit/Features/Ownership/index.vue.d.ts +2 -0
  262. package/dist/runtime/components/Edit/Features/Preview/index.vue +22 -27
  263. package/dist/runtime/components/Edit/Features/Preview/index.vue.d.ts +2 -0
  264. package/dist/runtime/components/Edit/Features/PreviewGrant/QrCode/index.vue +12 -16
  265. package/dist/runtime/components/Edit/Features/PreviewGrant/QrCode/index.vue.d.ts +5 -0
  266. package/dist/runtime/components/Edit/Features/PreviewGrant/index.vue +31 -36
  267. package/dist/runtime/components/Edit/Features/PreviewGrant/index.vue.d.ts +2 -0
  268. package/dist/runtime/components/Edit/Features/ProxyView/index.vue +18 -20
  269. package/dist/runtime/components/Edit/Features/ProxyView/index.vue.d.ts +2 -0
  270. package/dist/runtime/components/Edit/Features/Publish/Dialog/Item.vue +118 -0
  271. package/dist/runtime/components/Edit/Features/Publish/Dialog/Item.vue.d.ts +18 -0
  272. package/dist/runtime/components/Edit/Features/Publish/Dialog/index.vue +251 -0
  273. package/dist/runtime/components/Edit/Features/Publish/Dialog/index.vue.d.ts +19 -0
  274. package/dist/runtime/components/Edit/Features/Publish/Dialog/types.d.ts +7 -0
  275. package/dist/runtime/components/Edit/Features/Publish/index.vue +70 -74
  276. package/dist/runtime/components/Edit/Features/Publish/index.vue.d.ts +2 -0
  277. package/dist/runtime/components/Edit/Features/ResponsivePreview/Frame/index.vue +48 -54
  278. package/dist/runtime/components/Edit/Features/ResponsivePreview/Frame/index.vue.d.ts +27 -0
  279. package/dist/runtime/components/Edit/Features/ResponsivePreview/index.vue +77 -103
  280. package/dist/runtime/components/Edit/Features/ResponsivePreview/index.vue.d.ts +2 -0
  281. package/dist/runtime/components/Edit/Features/Revert/index.vue +27 -32
  282. package/dist/runtime/components/Edit/Features/Revert/index.vue.d.ts +2 -0
  283. package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Content/index.vue +67 -88
  284. package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Content/index.vue.d.ts +17 -0
  285. package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Page/index.vue +89 -139
  286. package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Page/index.vue.d.ts +18 -0
  287. package/dist/runtime/components/Edit/Features/Search/Overlay/index.vue +79 -108
  288. package/dist/runtime/components/Edit/Features/Search/Overlay/index.vue.d.ts +12 -0
  289. package/dist/runtime/components/Edit/Features/Search/index.vue +30 -37
  290. package/dist/runtime/components/Edit/Features/Search/index.vue.d.ts +2 -0
  291. package/dist/runtime/components/Edit/Features/Selection/Overlay/index.vue +67 -103
  292. package/dist/runtime/components/Edit/Features/Selection/Overlay/index.vue.d.ts +9 -0
  293. package/dist/runtime/components/Edit/Features/Selection/OverlayFallback/index.vue +28 -36
  294. package/dist/runtime/components/Edit/Features/Selection/OverlayFallback/index.vue.d.ts +5 -0
  295. package/dist/runtime/components/Edit/Features/Selection/index.vue +131 -217
  296. package/dist/runtime/components/Edit/Features/Selection/index.vue.d.ts +2 -0
  297. package/dist/runtime/components/Edit/Features/Settings/Dialog/FeatureSetting/index.vue +50 -81
  298. package/dist/runtime/components/Edit/Features/Settings/Dialog/FeatureSetting/index.vue.d.ts +9 -0
  299. package/dist/runtime/components/Edit/Features/Settings/Dialog/index.vue +73 -117
  300. package/dist/runtime/components/Edit/Features/Settings/Dialog/index.vue.d.ts +6 -0
  301. package/dist/runtime/components/Edit/Features/Settings/index.vue +41 -53
  302. package/dist/runtime/components/Edit/Features/Settings/index.vue.d.ts +2 -0
  303. package/dist/runtime/components/Edit/Features/Structure/List/Field/index.vue +65 -101
  304. package/dist/runtime/components/Edit/Features/Structure/List/Field/index.vue.d.ts +15 -0
  305. package/dist/runtime/components/Edit/Features/Structure/List/Item/index.vue +71 -99
  306. package/dist/runtime/components/Edit/Features/Structure/List/Item/index.vue.d.ts +12 -0
  307. package/dist/runtime/components/Edit/Features/Structure/List/index.vue +17 -26
  308. package/dist/runtime/components/Edit/Features/Structure/List/index.vue.d.ts +12 -0
  309. package/dist/runtime/components/Edit/Features/Structure/index.vue +31 -40
  310. package/dist/runtime/components/Edit/Features/Structure/index.vue.d.ts +2 -0
  311. package/dist/runtime/components/Edit/Features/Theme/Color/index.vue +32 -53
  312. package/dist/runtime/components/Edit/Features/Theme/Color/index.vue.d.ts +7 -0
  313. package/dist/runtime/components/Edit/Features/Theme/GeneratedCode/index.vue +7 -10
  314. package/dist/runtime/components/Edit/Features/Theme/GeneratedCode/index.vue.d.ts +2 -0
  315. package/dist/runtime/components/Edit/Features/Theme/index.vue +49 -63
  316. package/dist/runtime/components/Edit/Features/Theme/index.vue.d.ts +2 -0
  317. package/dist/runtime/components/Edit/Features/TouchActionBar/Bar/index.vue +9 -10
  318. package/dist/runtime/components/Edit/Features/TouchActionBar/Bar/index.vue.d.ts +12 -0
  319. package/dist/runtime/components/Edit/Features/TouchActionBar/index.vue +16 -19
  320. package/dist/runtime/components/Edit/Features/TouchActionBar/index.vue.d.ts +2 -0
  321. package/dist/runtime/components/Edit/Features/Tour/Overlay/index.vue +119 -174
  322. package/dist/runtime/components/Edit/Features/Tour/Overlay/index.vue.d.ts +6 -0
  323. package/dist/runtime/components/Edit/Features/Tour/Popup/index.vue +10 -12
  324. package/dist/runtime/components/Edit/Features/Tour/Popup/index.vue.d.ts +8 -0
  325. package/dist/runtime/components/Edit/Features/Tour/index.vue +21 -25
  326. package/dist/runtime/components/Edit/Features/Tour/index.vue.d.ts +2 -0
  327. package/dist/runtime/components/Edit/Features/Transform/index.vue +80 -120
  328. package/dist/runtime/components/Edit/Features/Transform/index.vue.d.ts +2 -0
  329. package/dist/runtime/components/Edit/Features/Translations/Banner/index.vue +21 -29
  330. package/dist/runtime/components/Edit/Features/Translations/Banner/index.vue.d.ts +6 -0
  331. package/dist/runtime/components/Edit/Features/Translations/index.vue +96 -139
  332. package/dist/runtime/components/Edit/Features/Translations/index.vue.d.ts +2 -0
  333. package/dist/runtime/components/Edit/Features/Validations/Overlay/Item.vue +21 -35
  334. package/dist/runtime/components/Edit/Features/Validations/Overlay/Item.vue.d.ts +6 -0
  335. package/dist/runtime/components/Edit/Features/Validations/Overlay/index.vue +30 -39
  336. package/dist/runtime/components/Edit/Features/Validations/Overlay/index.vue.d.ts +6 -0
  337. package/dist/runtime/components/Edit/Features/Validations/SidebarItem/index.vue +20 -28
  338. package/dist/runtime/components/Edit/Features/Validations/SidebarItem/index.vue.d.ts +9 -0
  339. package/dist/runtime/components/Edit/Features/Validations/index.vue +27 -33
  340. package/dist/runtime/components/Edit/Features/Validations/index.vue.d.ts +2 -0
  341. package/dist/runtime/components/Edit/Features/index.vue +33 -52
  342. package/dist/runtime/components/Edit/Features/index.vue.d.ts +6 -0
  343. package/dist/runtime/components/Edit/Form/Group/index.vue +23 -0
  344. package/dist/runtime/components/Edit/Form/Group/index.vue.d.ts +20 -0
  345. package/dist/runtime/components/Edit/Form/Item/index.vue +5 -0
  346. package/dist/runtime/components/Edit/Form/Item/index.vue.d.ts +14 -0
  347. package/dist/runtime/components/Edit/Form/Textarea/index.vue +27 -0
  348. package/dist/runtime/components/Edit/Form/Textarea/index.vue.d.ts +16 -0
  349. package/dist/runtime/components/Edit/Form/Toggle/index.vue +21 -0
  350. package/dist/runtime/components/Edit/Form/Toggle/index.vue.d.ts +14 -0
  351. package/dist/runtime/components/Edit/FormOverlay/Header/index.vue +11 -22
  352. package/dist/runtime/components/Edit/FormOverlay/Header/index.vue.d.ts +18 -0
  353. package/dist/runtime/components/Edit/FormOverlay/index.vue +15 -21
  354. package/dist/runtime/components/Edit/FormOverlay/index.vue.d.ts +25 -0
  355. package/dist/runtime/components/Edit/Highlight/index.vue +31 -70
  356. package/dist/runtime/components/Edit/Highlight/index.vue.d.ts +20 -0
  357. package/dist/runtime/components/Edit/Icon/index.vue +11 -14
  358. package/dist/runtime/components/Edit/Icon/index.vue.d.ts +7 -0
  359. package/dist/runtime/components/Edit/InfoBox/index.vue +5 -6
  360. package/dist/runtime/components/Edit/InfoBox/index.vue.d.ts +5 -0
  361. package/dist/runtime/components/Edit/ItemIcon/index.vue +13 -13
  362. package/dist/runtime/components/Edit/ItemIcon/index.vue.d.ts +6 -0
  363. package/dist/runtime/components/Edit/Loading/index.vue +8 -9
  364. package/dist/runtime/components/Edit/Loading/index.vue.d.ts +6 -0
  365. package/dist/runtime/components/Edit/Messages/Item/index.vue +30 -41
  366. package/dist/runtime/components/Edit/Messages/Item/index.vue.d.ts +11 -0
  367. package/dist/runtime/components/Edit/Messages/index.vue +13 -17
  368. package/dist/runtime/components/Edit/Messages/index.vue.d.ts +2 -0
  369. package/dist/runtime/components/Edit/Pagination/index.vue +6 -8
  370. package/dist/runtime/components/Edit/Pagination/index.vue.d.ts +12 -0
  371. package/dist/runtime/components/Edit/PreviewProvider.vue +124 -177
  372. package/dist/runtime/components/Edit/PreviewProvider.vue.d.ts +24 -0
  373. package/dist/runtime/components/Edit/RelativeTime/index.vue +19 -25
  374. package/dist/runtime/components/Edit/RelativeTime/index.vue.d.ts +15 -0
  375. package/dist/runtime/components/Edit/Resizable/index.vue +45 -55
  376. package/dist/runtime/components/Edit/Resizable/index.vue.d.ts +13 -0
  377. package/dist/runtime/components/Edit/ScaleToFit/index.vue +44 -62
  378. package/dist/runtime/components/Edit/ScaleToFit/index.vue.d.ts +15 -0
  379. package/dist/runtime/components/Edit/ScrollBoundary/index.vue +11 -27
  380. package/dist/runtime/components/Edit/ScrollBoundary/index.vue.d.ts +23 -0
  381. package/dist/runtime/components/Edit/ShortcutIndicator/index.vue +47 -59
  382. package/dist/runtime/components/Edit/ShortcutIndicator/index.vue.d.ts +20 -0
  383. package/dist/runtime/components/Edit/Sortli/index.vue +45 -59
  384. package/dist/runtime/components/Edit/Sortli/index.vue.d.ts +14 -0
  385. package/dist/runtime/components/Edit/SystemRequirements/index.vue +29 -43
  386. package/dist/runtime/components/Edit/SystemRequirements/index.vue.d.ts +2 -0
  387. package/dist/runtime/components/Edit/Toolbar/index.vue +26 -41
  388. package/dist/runtime/components/Edit/Toolbar/index.vue.d.ts +6 -0
  389. package/dist/runtime/components/Edit/ViewportBlockingRect/index.vue +29 -51
  390. package/dist/runtime/components/Edit/ViewportBlockingRect/index.vue.d.ts +20 -0
  391. package/dist/runtime/components/Edit/index.d.ts +5 -1
  392. package/dist/runtime/components/Edit/index.js +9 -1
  393. package/dist/runtime/composables/defineBlokkli.d.ts +2 -2
  394. package/dist/runtime/composables/defineBlokkli.js +29 -11
  395. package/dist/runtime/composables/defineBlokkliFragment.d.ts +1 -1
  396. package/dist/runtime/composables/defineBlokkliFragment.js +16 -24
  397. package/dist/runtime/css/output.css +1 -1
  398. package/dist/runtime/helpers/definitionProvider.d.ts +18 -0
  399. package/dist/runtime/helpers/definitionProvider.js +96 -0
  400. package/dist/runtime/helpers/domProvider.d.ts +2 -1
  401. package/dist/runtime/helpers/domProvider.js +6 -3
  402. package/dist/runtime/helpers/editComponents/index.d.ts +2 -0
  403. package/dist/runtime/helpers/editComponents/index.js +10 -0
  404. package/dist/runtime/helpers/featuresProvider.d.ts +2 -1
  405. package/dist/runtime/helpers/featuresProvider.js +19 -10
  406. package/dist/runtime/helpers/frameEventBus.d.ts +1 -1
  407. package/dist/runtime/helpers/imports/index.d.ts +1 -0
  408. package/dist/runtime/helpers/imports/index.js +44 -0
  409. package/dist/runtime/helpers/index.js +5 -8
  410. package/dist/runtime/helpers/runtimeHelpers/index.d.ts +5 -0
  411. package/dist/runtime/helpers/runtimeHelpers/index.js +17 -4
  412. package/dist/runtime/helpers/stateProvider.d.ts +1 -1
  413. package/dist/runtime/helpers/textProvider.d.ts +1 -1
  414. package/dist/runtime/helpers/themeProvider.js +4 -1
  415. package/dist/runtime/helpers/transform.d.ts +1 -1
  416. package/dist/runtime/helpers/typesProvider.d.ts +2 -2
  417. package/dist/runtime/helpers/uiProvider.js +4 -5
  418. package/dist/runtime/helpers/webgl/index.js +1 -1
  419. package/dist/runtime/icons/arrow-right-thin.svg +3 -0
  420. package/dist/runtime/public/_blokkli-assets/check.svg +6 -0
  421. package/dist/runtime/public/_blokkli-assets/loader.svg +1 -0
  422. package/dist/runtime/types/blokkOptions.d.ts +11 -2
  423. package/dist/runtime/types/index.d.ts +34 -14
  424. package/dist/shared/editor.gz_ac6uT.d.mts +431 -0
  425. package/dist/types.d.mts +1 -1
  426. package/package.json +30 -25
  427. package/dist/module.cjs +0 -5
  428. package/dist/module.d.ts +0 -198
  429. package/dist/runtime/adapter/drupal/graphql/base.graphql +0 -944
  430. package/dist/runtime/adapter/drupal/graphqlMiddleware.d.ts +0 -2
  431. package/dist/runtime/adapter/drupal/graphqlMiddleware.js +0 -680
  432. package/dist/runtime/types/generatedModuleTypes.d.ts +0 -49
  433. package/dist/types.d.ts +0 -1
  434. /package/dist/{runtime/adapter/drupal/graphql → modules/drupal/graphql/features}/comments.graphql +0 -0
  435. /package/dist/{runtime/adapter/drupal/graphql → modules/drupal/graphql/features}/fragments.graphql +0 -0
  436. /package/dist/{runtime/adapter/drupal/graphql → modules/drupal/graphql/features}/search.graphql +0 -0
  437. /package/dist/{runtime/adapter/drupal/graphql → modules/drupal/graphql/features}/transform.graphql +0 -0
  438. /package/dist/runtime/{types/generatedModuleTypes.js → components/Edit/Features/Publish/Dialog/types.js} +0 -0
  439. /package/dist/runtime/public/{Inter.var.woff2 → _blokkli-assets/Inter.var.woff2} +0 -0
@@ -4,96 +4,48 @@
4
4
  </Teleport>
5
5
  </template>
6
6
 
7
- <script lang="ts" setup>
7
+ <script setup>
8
8
  import {
9
9
  falsy,
10
10
  findClosestRectangle,
11
11
  intersects,
12
12
  isInsideRect,
13
13
  rgbaToString,
14
- toShaderColor,
15
- } from '#blokkli/helpers'
16
- import onBlokkliEvent from '#blokkli/helpers/composables/onBlokkliEvent'
17
- import type {
18
- DropTargetEvent,
19
- BlokkliFieldElement,
20
- DraggableItem,
21
- DropArea,
22
- Rectangle,
23
- Coord,
24
- } from '#blokkli/types'
25
- import { ref, computed, useBlokkli, onBeforeUnmount } from '#imports'
14
+ toShaderColor
15
+ } from "#blokkli/helpers";
16
+ import onBlokkliEvent from "#blokkli/helpers/composables/onBlokkliEvent";
17
+ import { ref, computed, useBlokkli, onBeforeUnmount } from "#imports";
26
18
  import {
27
19
  setBuffersAndAttributes,
28
20
  drawBufferInfo,
29
- setUniforms,
30
- type BufferInfo,
31
- } from 'twgl.js'
32
- import vs from './vertex.glsl?raw'
33
- import fs from './fragment.glsl?raw'
34
- import { RectangleBufferCollector } from '#blokkli/helpers/webgl'
35
-
36
- const props = defineProps<{
37
- items: DraggableItem[]
38
- box: Rectangle
39
- mouseX: number
40
- mouseY: number
41
- isTouch: boolean
42
- }>()
43
-
44
- const MIN_GAP = 20
45
-
46
- enum RectRenderType {
47
- DROP_AREA,
48
- FIELD_1,
49
- FIELD_2,
50
- FIELD_3,
51
- FIELD_4,
52
- ACTIVE_AREA,
53
- }
54
-
55
- type Orientation = 'horizontal' | 'vertical'
56
-
57
- type FieldRectChild = Rectangle & {
58
- id: string
59
- label: string
60
- }
61
-
62
- type FieldRect = Rectangle & {
63
- key: string
64
- field: BlokkliFieldElement
65
- label: string
66
- canAddChildren: boolean
67
- emptyChild?: FieldRectChild
68
- orientation: Orientation
69
- gap: number
70
- childrenElements: HTMLElement[]
71
- }
72
-
73
- type DrawnRect = Rectangle & {
74
- id: string
75
- type: 'field' | 'drop-area' | 'active-area'
76
- label: string
77
- color: string
78
- colorAlpha: string
79
- field?: FieldRect
80
- index: number
81
- }
82
-
83
- const dragStart = Date.now()
84
-
85
- const cursorIsInsideClipped = () =>
86
- isInsideRect(props.mouseX, props.mouseY, ui.visibleViewport.value) &&
87
- !ui.viewportBlockingRects.value.some((v) =>
88
- isInsideRect(props.mouseX, props.mouseY, v),
89
- )
90
-
91
- const active = ref<DrawnRect | null>(null)
92
-
93
- defineEmits<{
94
- (e: 'drop', data: DropTargetEvent): void
95
- }>()
96
-
21
+ setUniforms
22
+ } from "twgl.js";
23
+ import vs from "./vertex.glsl?raw";
24
+ import fs from "./fragment.glsl?raw";
25
+ import { RectangleBufferCollector } from "#blokkli/helpers/webgl";
26
+ const props = defineProps({
27
+ items: { type: Array, required: true },
28
+ box: { type: Object, required: true },
29
+ mouseX: { type: Number, required: true },
30
+ mouseY: { type: Number, required: true },
31
+ isTouch: { type: Boolean, required: true }
32
+ });
33
+ const MIN_GAP = 20;
34
+ var RectRenderType = /* @__PURE__ */ ((RectRenderType2) => {
35
+ RectRenderType2[RectRenderType2["DROP_AREA"] = 0] = "DROP_AREA";
36
+ RectRenderType2[RectRenderType2["FIELD_1"] = 1] = "FIELD_1";
37
+ RectRenderType2[RectRenderType2["FIELD_2"] = 2] = "FIELD_2";
38
+ RectRenderType2[RectRenderType2["FIELD_3"] = 3] = "FIELD_3";
39
+ RectRenderType2[RectRenderType2["FIELD_4"] = 4] = "FIELD_4";
40
+ RectRenderType2[RectRenderType2["ACTIVE_AREA"] = 5] = "ACTIVE_AREA";
41
+ return RectRenderType2;
42
+ })(RectRenderType || {});
43
+ const dragStart = Date.now();
44
+ const cursorIsInsideClipped = () => isInsideRect(props.mouseX, props.mouseY, ui.visibleViewport.value) && !ui.viewportBlockingRects.value.some(
45
+ (v) => isInsideRect(props.mouseX, props.mouseY, v)
46
+ );
47
+ const active = ref(null);
48
+ defineEmits(["drop"]);
97
49
  const {
98
50
  dom,
99
51
  ui,
@@ -103,409 +55,282 @@ const {
103
55
  animation,
104
56
  state,
105
57
  runtimeConfig,
106
- types,
107
- } = useBlokkli()
108
-
109
- const gl = animation.gl()
110
- const canvas = animation.getCanvasElement()
111
- const ctx: CanvasRenderingContext2D | null =
112
- !gl && canvas ? canvas.getContext('2d') : null
113
-
114
- const programInfo = gl
115
- ? animation.registerProgram('drop_targets', gl, [vs, fs])
116
- : null
117
-
118
- const areas = dropAreas
119
- .getDropAreas(props.items)
120
- .reduce<Record<string, DropArea>>((acc, v) => {
121
- acc[v.id] = v
122
- return acc
123
- }, {})
124
-
125
- const visibleDropAreas: Set<string> = new Set()
126
-
58
+ types
59
+ } = useBlokkli();
60
+ const gl = animation.gl();
61
+ const canvas = animation.getCanvasElement();
62
+ const ctx = !gl && canvas ? canvas.getContext("2d") : null;
63
+ const programInfo = gl ? animation.registerProgram("drop_targets", gl, [vs, fs]) : null;
64
+ const areas = dropAreas.getDropAreas(props.items).reduce((acc, v) => {
65
+ acc[v.id] = v;
66
+ return acc;
67
+ }, {});
68
+ const visibleDropAreas = /* @__PURE__ */ new Set();
127
69
  const areasObserver = new IntersectionObserver(
128
70
  (entries) => {
129
71
  for (const entry of entries) {
130
72
  if (entry.target instanceof HTMLElement) {
131
- const id = entry.target.dataset.dropAreaId
73
+ const id = entry.target.dataset.dropAreaId;
132
74
  if (id) {
133
75
  if (entry.isIntersecting) {
134
- visibleDropAreas.add(id)
76
+ visibleDropAreas.add(id);
135
77
  } else {
136
- visibleDropAreas.delete(id)
78
+ visibleDropAreas.delete(id);
137
79
  }
138
80
  }
139
81
  }
140
82
  }
141
83
  },
142
84
  {
143
- threshold: 0,
144
- },
145
- )
146
-
85
+ threshold: 0
86
+ }
87
+ );
147
88
  Object.values(areas).forEach((area) => {
148
- area.element.dataset.dropAreaId = area.id
149
- areasObserver.observe(area.element)
150
- })
151
-
152
- onBlokkliEvent('mouse:down', (e) => {
153
- const coord = toCanvasSpaceCoordinates(e.x, e.y)
154
- const match = collector.getRectAtPosition(coord)
155
- active.value = match || null
156
- })
157
-
158
- onBlokkliEvent('mouse:up', (e) => {
89
+ area.element.dataset.dropAreaId = area.id;
90
+ areasObserver.observe(area.element);
91
+ });
92
+ onBlokkliEvent("mouse:down", (e) => {
93
+ const coord = toCanvasSpaceCoordinates(e.x, e.y);
94
+ const match = collector.getRectAtPosition(coord);
95
+ active.value = match || null;
96
+ });
97
+ onBlokkliEvent("mouse:up", (e) => {
159
98
  if (!active.value) {
160
- return
99
+ return;
161
100
  }
162
-
163
- // On touch devices, if the distance is greater than the threshold, the user
164
- // has likely interacted with the artboard (panning, zooming).
165
101
  if (props.isTouch && e.distance > 10) {
166
- active.value = null
167
- return
102
+ active.value = null;
103
+ return;
168
104
  }
169
-
170
- // On desktop, only emit drop if the distance is greater than the threshold.
171
- // This prevents accidentally moving a block.
172
105
  if (!props.isTouch && e.distance < 7) {
173
- return
106
+ return;
174
107
  }
175
-
176
- emitDrop()
177
- })
178
-
108
+ emitDrop();
109
+ });
179
110
  const emitDrop = async () => {
180
- const timeDelta = Date.now() - dragStart
181
- // Prevent accidental drops. At least 200ms should have passed between the
182
- // time the drag was initiated and when the drop was made.
111
+ const timeDelta = Date.now() - dragStart;
183
112
  if (active.value && timeDelta > 200) {
184
- if (active.value.type === 'field') {
185
- const [hostUuid, fieldName, preceedingUuid] = active.value.id.split(':')
186
-
187
- const field = dom.findField(hostUuid, fieldName)
188
-
113
+ if (active.value.type === "field") {
114
+ const [hostUuid, fieldName, preceedingUuid] = active.value.id.split(":");
115
+ if (!hostUuid || !fieldName) {
116
+ return;
117
+ }
118
+ const field = dom.findField(hostUuid, fieldName);
189
119
  if (!field) {
190
- return
120
+ return;
191
121
  }
192
-
193
- eventBus.emit('dragging:drop', {
122
+ eventBus.emit("dragging:drop", {
194
123
  field,
195
124
  preceedingUuid,
196
125
  items: [...props.items],
197
126
  host: {
198
127
  type: field.hostEntityType,
199
128
  uuid: field.hostEntityUuid,
200
- fieldName: field.name,
201
- },
202
- })
203
- return
204
- } else if (active.value.type === 'drop-area') {
205
- const area = areas[active.value.id]
129
+ fieldName: field.name
130
+ }
131
+ });
132
+ return;
133
+ } else if (active.value.type === "drop-area") {
134
+ const area = areas[active.value.id];
206
135
  if (!area) {
207
- return
136
+ return;
208
137
  }
209
- await area.onDrop()
138
+ await area.onDrop();
210
139
  }
211
140
  }
212
-
213
- eventBus.emit('dragging:end')
214
- eventBus.emit('item:dropped')
215
- }
216
-
217
- function getChildrenOrientation(element: HTMLElement): Orientation {
218
- const computedStyle = window.getComputedStyle(element)
219
-
220
- // Check for Flex layout
221
- if (computedStyle.display.includes('flex')) {
222
- // Flex direction row or row-reverse indicates horizontal layout
223
- if (
224
- computedStyle.flexDirection === 'row' ||
225
- computedStyle.flexDirection === 'row-reverse'
226
- ) {
227
- return 'horizontal'
141
+ eventBus.emit("dragging:end");
142
+ eventBus.emit("item:dropped");
143
+ };
144
+ function getChildrenOrientation(element) {
145
+ const computedStyle = window.getComputedStyle(element);
146
+ if (computedStyle.display.includes("flex")) {
147
+ if (computedStyle.flexDirection === "row" || computedStyle.flexDirection === "row-reverse") {
148
+ return "horizontal";
228
149
  } else {
229
- // Otherwise, it's vertical
230
- return 'vertical'
150
+ return "vertical";
231
151
  }
232
152
  }
233
-
234
- // Check for Grid layout
235
- if (computedStyle.display.includes('grid')) {
236
- // We'll need to check the grid-template-columns and grid-template-rows
237
- // This is a simple check, assuming a basic grid layout
238
- if (computedStyle.gridTemplateColumns.split(' ').length > 1) {
239
- return 'horizontal'
153
+ if (computedStyle.display.includes("grid")) {
154
+ if (computedStyle.gridTemplateColumns.split(" ").length > 1) {
155
+ return "horizontal";
240
156
  } else {
241
- return 'vertical'
157
+ return "vertical";
242
158
  }
243
159
  }
244
-
245
- // Default to vertical for block elements and other displays
246
- return 'vertical'
160
+ return "vertical";
247
161
  }
248
-
249
- /**
250
- * The bundles being dragged.
251
- *
252
- * In case of dragging a from_library block, the bundle of the reusable block is also returned here.
253
- */
254
- const draggingBundles = computed<string[]>(() =>
255
- props.items
256
- .flatMap((item) => {
257
- const bundles: string[] = []
258
- if ('itemBundle' in item && item.itemBundle) {
259
- bundles.push(item.itemBundle)
260
- }
261
- if ('reusableBundle' in item && item.reusableBundle) {
262
- bundles.push(item.reusableBundle)
263
- }
264
- return bundles
265
- })
266
- .filter(falsy),
267
- )
268
-
269
- const selectionUuids = computed<string[]>(() =>
270
- props.items
271
- .map((item) => {
272
- if (item.itemType === 'existing') {
273
- return item.uuid
274
- }
275
- })
276
- .filter(falsy),
277
- )
278
-
279
- function getGapSize(orientation: Orientation, element: HTMLElement): number {
280
- const computedStyle = window.getComputedStyle(element)
281
-
282
- // Check for Grid or Flex layout
283
- if (
284
- computedStyle.display.includes('grid') ||
285
- computedStyle.display.includes('flex')
286
- ) {
287
- const gap =
288
- orientation === 'vertical'
289
- ? computedStyle.columnGap || computedStyle.gridColumnGap
290
- : computedStyle.rowGap || computedStyle.gridRowGap
291
-
162
+ const draggingBundles = computed(
163
+ () => props.items.flatMap((item) => {
164
+ const bundles = [];
165
+ if ("itemBundle" in item && item.itemBundle) {
166
+ bundles.push(item.itemBundle);
167
+ }
168
+ if ("reusableBundle" in item && item.reusableBundle) {
169
+ bundles.push(item.reusableBundle);
170
+ }
171
+ return bundles;
172
+ }).filter(falsy)
173
+ );
174
+ const selectionUuids = computed(
175
+ () => props.items.map((item) => {
176
+ if (item.itemType === "existing") {
177
+ return item.uuid;
178
+ }
179
+ }).filter(falsy)
180
+ );
181
+ function getGapSize(orientation, element) {
182
+ const computedStyle = window.getComputedStyle(element);
183
+ if (computedStyle.display.includes("grid") || computedStyle.display.includes("flex")) {
184
+ const gap = orientation === "vertical" ? computedStyle.columnGap || computedStyle.gridColumnGap : computedStyle.rowGap || computedStyle.gridRowGap;
292
185
  if (gap) {
293
- // Extract the first value.
294
- const gapParts = gap.split(' ')
295
- const gapValue = gapParts[0]
296
- if (gapValue.endsWith('px')) {
297
- return Number.parseFloat(gapValue)
186
+ const gapParts = gap.split(" ");
187
+ const gapValue = gapParts[0];
188
+ if (gapValue?.endsWith("px")) {
189
+ return Number.parseFloat(gapValue);
298
190
  }
299
191
  }
300
192
  }
301
-
302
- return MIN_GAP
193
+ return MIN_GAP;
303
194
  }
304
-
305
- const fieldChildCache: Record<string, FieldRectChild[]> = {}
306
-
307
- const buildChildId = (
308
- field: BlokkliFieldElement,
309
- preceedingUuid?: string | undefined | null,
310
- type?: string | undefined | null,
311
- uuid?: string | undefined | null,
312
- ) => {
313
- return `${field.key}:${preceedingUuid || ''}:${type || ''}:${uuid || ''}`
314
- }
315
-
316
- const buildChildren = (
317
- field: FieldRect,
318
- visible: string[],
319
- ): FieldRectChild[] => {
195
+ const fieldChildCache = {};
196
+ const buildChildId = (field, preceedingUuid, type, uuid) => {
197
+ return `${field.key}:${preceedingUuid || ""}:${type || ""}:${uuid || ""}`;
198
+ };
199
+ const buildChildren = (field, visible) => {
320
200
  if (!field.canAddChildren) {
321
- return []
201
+ return [];
322
202
  }
323
-
324
203
  if (field.emptyChild) {
325
- return [field.emptyChild]
204
+ return [field.emptyChild];
326
205
  }
327
-
328
- const children: FieldRectChild[] = []
329
-
330
- let prevWasInSelection = false
331
- let prevUuid: string | undefined = ''
332
-
206
+ const children = [];
207
+ let prevWasInSelection = false;
208
+ let prevUuid = "";
333
209
  for (let i = 0; i < field.childrenElements.length; i++) {
334
- const childrenForUuid: FieldRectChild[] = []
335
-
336
- const isLast = i === field.childrenElements.length - 1
337
-
338
- const el = field.childrenElements[i]
210
+ const childrenForUuid = [];
211
+ const isLast = i === field.childrenElements.length - 1;
212
+ const el = field.childrenElements[i];
339
213
  if (!(el instanceof HTMLElement)) {
340
- continue
214
+ continue;
341
215
  }
342
-
343
- const uuid = el.dataset.uuid
216
+ const uuid = el.dataset.uuid;
344
217
  if (!uuid) {
345
- continue
218
+ continue;
346
219
  }
347
-
348
220
  if (!visible.includes(uuid)) {
349
- prevUuid = uuid
350
- continue
221
+ prevUuid = uuid;
222
+ continue;
351
223
  }
352
-
353
- const cached = fieldChildCache[uuid]
224
+ const cached = fieldChildCache[uuid];
354
225
  if (cached) {
355
- children.push(...cached)
356
- prevUuid = uuid
357
- continue
226
+ children.push(...cached);
227
+ prevUuid = uuid;
228
+ continue;
358
229
  }
359
-
360
- // Skip child if it's part of the selection.
361
230
  if (selectionUuids.value.includes(uuid)) {
362
- prevWasInSelection = true
363
- prevUuid = uuid
364
- continue
231
+ prevWasInSelection = true;
232
+ prevUuid = uuid;
233
+ continue;
365
234
  }
366
-
367
- // Get the rect of the block. Use a cached one if possible.
368
- const elRect =
369
- dom.getBlockRect(uuid) ||
370
- ui.getAbsoluteElementRect(el.getBoundingClientRect())
371
-
372
- // Calculate the offset to the parent. We can not use el.offsetTop/el.offsetLeft here because the value could be 0.
373
- const elOffsetTop = elRect.y - field.y
374
- const elOffsetLeft = elRect.x - field.x
375
-
376
- // Last element.
235
+ const elRect = dom.getBlockRect(uuid) || ui.getAbsoluteElementRect(el.getBoundingClientRect());
236
+ const elOffsetTop = elRect.y - field.y;
237
+ const elOffsetLeft = elRect.x - field.x;
377
238
  if (isLast) {
378
- const id = buildChildId(field.field, uuid, 'last', uuid)
379
- if (field.orientation === 'vertical') {
239
+ const id2 = buildChildId(field.field, uuid, "last", uuid);
240
+ if (field.orientation === "vertical") {
380
241
  childrenForUuid.push({
381
- id,
242
+ id: id2,
382
243
  width: field.width,
383
244
  height: MIN_GAP,
384
245
  x: 0,
385
246
  y: elOffsetTop + el.scrollHeight,
386
- label: field.label,
387
- })
247
+ label: field.label
248
+ });
388
249
  } else {
389
250
  childrenForUuid.push({
390
- id,
251
+ id: id2,
391
252
  width: MIN_GAP,
392
253
  height: el.offsetHeight,
393
254
  x: elOffsetLeft + el.offsetWidth + (field.gap - MIN_GAP) / 2,
394
255
  y: elOffsetTop,
395
- label: field.label,
396
- })
256
+ label: field.label
257
+ });
397
258
  }
398
259
  }
399
-
400
- // If the previous element was part of the selection, don't add a child,
401
- // because the move operation would result in the same position.
402
260
  if (prevWasInSelection) {
403
- prevWasInSelection = false
404
- prevUuid = uuid
405
- children.push(...childrenForUuid)
406
- continue
261
+ prevWasInSelection = false;
262
+ prevUuid = uuid;
263
+ children.push(...childrenForUuid);
264
+ continue;
407
265
  }
408
-
409
- const id = buildChildId(field.field, prevUuid, 'between', uuid)
410
-
411
- if (field.orientation === 'vertical') {
266
+ const id = buildChildId(field.field, prevUuid, "between", uuid);
267
+ if (field.orientation === "vertical") {
412
268
  childrenForUuid.push({
413
269
  id,
414
270
  width: field.width,
415
271
  height: MIN_GAP,
416
272
  x: 0,
417
273
  y: elOffsetTop - field.gap / 2,
418
- label: field.label,
419
- })
274
+ label: field.label
275
+ });
420
276
  } else {
421
277
  childrenForUuid.push({
422
278
  id,
423
279
  width: MIN_GAP,
424
280
  height: Math.max(el.offsetHeight, MIN_GAP),
425
- x:
426
- Math.max(elOffsetLeft - field.gap, -field.gap) +
427
- (field.gap - MIN_GAP) / 2,
281
+ x: Math.max(elOffsetLeft - field.gap, -field.gap) + (field.gap - MIN_GAP) / 2,
428
282
  y: elOffsetTop,
429
- label: field.label,
430
- })
283
+ label: field.label
284
+ });
431
285
  }
432
-
433
- fieldChildCache[uuid] = childrenForUuid
434
-
435
- children.push(...childrenForUuid)
436
-
437
- prevUuid = uuid
438
- }
439
- return children
440
- }
441
-
442
- const fieldCache: Record<string, FieldRect> = {}
443
-
444
- function getBundleLabel(field: BlokkliFieldElement): string {
286
+ fieldChildCache[uuid] = childrenForUuid;
287
+ children.push(...childrenForUuid);
288
+ prevUuid = uuid;
289
+ }
290
+ return children;
291
+ };
292
+ const fieldCache = {};
293
+ function getBundleLabel(field) {
445
294
  if (field.hostEntityType === runtimeConfig.itemEntityType) {
446
- return (
447
- types.getBlockBundleDefinition(field.hostEntityBundle)?.label ||
448
- field.hostEntityBundle
449
- )
295
+ return types.getBlockBundleDefinition(field.hostEntityBundle)?.label || field.hostEntityBundle;
450
296
  }
451
-
452
- return state.entity.value.bundleLabel || field.hostEntityBundle
297
+ return state.entity.value.bundleLabel || field.hostEntityBundle;
453
298
  }
454
-
455
- function getInsertText(field: BlokkliFieldElement): string {
456
- const bundleLabel = getBundleLabel(field)
457
- return `${bundleLabel} » <strong>${field.label}</strong>`
299
+ function getInsertText(field) {
300
+ const bundleLabel = getBundleLabel(field);
301
+ return `${bundleLabel} \xBB <strong>${field.label}</strong>`;
458
302
  }
459
-
460
- const determineCanAddChildren = (
461
- field: BlokkliFieldElement,
462
- children: HTMLElement[],
463
- ) => {
464
- // Check cardinality of field.
303
+ const determineCanAddChildren = (field, children) => {
465
304
  if (field.cardinality !== -1) {
466
- // Current block count.
467
- const count = state.getFieldBlockCount(field.key)
468
-
469
- // Count of children that are also part of the selection.
305
+ const count = state.getFieldBlockCount(field.key);
470
306
  const childrenThatAreSelection = children.filter((child) => {
471
- const uuid = child.dataset.uuid
307
+ const uuid = child.dataset.uuid;
472
308
  if (!uuid) {
473
- return false
309
+ return false;
474
310
  }
475
- return selectionUuids.value.includes(uuid)
476
- }).length
477
- const countAfter = count - childrenThatAreSelection + props.items.length
311
+ return selectionUuids.value.includes(uuid);
312
+ }).length;
313
+ const countAfter = count - childrenThatAreSelection + props.items.length;
478
314
  if (countAfter > field.cardinality) {
479
- return false
315
+ return false;
480
316
  }
481
317
  }
482
-
483
- return (
484
- !draggingBundles.value.length ||
485
- draggingBundles.value.every((bundle) =>
486
- field.allowedBundles.includes(bundle),
487
- )
488
- )
489
- }
490
-
491
- const buildEmptyChild = (
492
- field: BlokkliFieldElement,
493
- children: HTMLElement[],
494
- orientation: Orientation,
495
- fieldWidth: number,
496
- fieldHeight: number,
497
- ): FieldRectChild | undefined => {
318
+ return !draggingBundles.value.length || draggingBundles.value.every(
319
+ (bundle) => field.allowedBundles.includes(bundle)
320
+ );
321
+ };
322
+ const buildEmptyChild = (field, children, orientation, fieldWidth, fieldHeight) => {
498
323
  if (children.length === 0) {
499
- const id = buildChildId(field, null, 'empty')
500
- if (orientation === 'horizontal') {
324
+ const id = buildChildId(field, null, "empty");
325
+ if (orientation === "horizontal") {
501
326
  return {
502
327
  id,
503
328
  x: 0,
504
329
  y: 0,
505
330
  width: fieldWidth,
506
331
  height: fieldHeight,
507
- label: getInsertText(field),
508
- }
332
+ label: getInsertText(field)
333
+ };
509
334
  } else {
510
335
  return {
511
336
  id,
@@ -513,47 +338,42 @@ const buildEmptyChild = (
513
338
  y: 0,
514
339
  width: fieldWidth,
515
340
  height: Math.max(fieldHeight, MIN_GAP),
516
- label: getInsertText(field),
517
- }
341
+ label: getInsertText(field)
342
+ };
518
343
  }
519
344
  }
520
- }
521
-
522
- const buildFieldRect = (key: string): FieldRect | undefined => {
345
+ };
346
+ const buildFieldRect = (key) => {
523
347
  if (fieldCache[key]) {
524
- return fieldCache[key]
348
+ return fieldCache[key];
525
349
  }
526
-
527
- const [uuid, name] = key.split(':')
528
- const field = dom.findField(uuid, name)
350
+ const [uuid, name] = key.split(":");
351
+ if (!uuid || !name) {
352
+ return;
353
+ }
354
+ const field = dom.findField(uuid, name);
529
355
  if (!field) {
530
- return
356
+ return;
531
357
  }
532
- const childElements = [...field.element.children] as HTMLElement[]
533
-
534
- const canAddChildren = determineCanAddChildren(field, childElements)
535
- const orientation =
536
- field.dropAlignment || getChildrenOrientation(field.element)
537
-
538
- const rect = dom.getFieldRect(field.key)
358
+ const childElements = [...field.element.children];
359
+ const canAddChildren = determineCanAddChildren(field, childElements);
360
+ const orientation = field.dropAlignment || getChildrenOrientation(field.element);
361
+ const rect = dom.getFieldRect(field.key);
539
362
  if (!rect) {
540
- throw new Error('Failed to get rect for field: ' + field.key)
363
+ throw new Error("Failed to get rect for field: " + field.key);
541
364
  }
542
- const x = rect.x
543
- const y = rect.y
544
- const width = Math.max(rect.width, MIN_GAP)
545
-
546
- const height = Math.max(rect.height, MIN_GAP)
365
+ const x = rect.x;
366
+ const y = rect.y;
367
+ const width = Math.max(rect.width, MIN_GAP);
368
+ const height = Math.max(rect.height, MIN_GAP);
547
369
  const emptyChild = buildEmptyChild(
548
370
  field,
549
371
  childElements,
550
372
  orientation,
551
373
  width,
552
- height,
553
- )
554
-
555
- const gap = Math.max(getGapSize(orientation, field.element), MIN_GAP)
556
-
374
+ height
375
+ );
376
+ const gap = Math.max(getGapSize(orientation, field.element), MIN_GAP);
557
377
  const fieldRect = {
558
378
  key: field.key,
559
379
  field,
@@ -566,74 +386,62 @@ const buildFieldRect = (key: string): FieldRect | undefined => {
566
386
  emptyChild,
567
387
  orientation,
568
388
  gap,
569
- childrenElements: childElements,
570
- }
571
-
572
- fieldCache[key] = fieldRect
573
- return fieldRect
574
- }
575
-
576
- const cachedDropAreaRects: Record<string, Rectangle> = {}
577
-
578
- const buildDropAreaRect = (area: DropArea): Rectangle => {
389
+ childrenElements: childElements
390
+ };
391
+ fieldCache[key] = fieldRect;
392
+ return fieldRect;
393
+ };
394
+ const cachedDropAreaRects = {};
395
+ const buildDropAreaRect = (area) => {
579
396
  if (cachedDropAreaRects[area.id]) {
580
- return cachedDropAreaRects[area.id]
397
+ return cachedDropAreaRects[area.id];
581
398
  }
582
-
583
- const rect = ui.getAbsoluteElementRect(area.element)
584
-
585
- const dropAreaRect: Rectangle = {
399
+ const rect = ui.getAbsoluteElementRect(area.element);
400
+ const dropAreaRect = {
586
401
  x: rect.x,
587
402
  y: rect.y,
588
403
  width: Math.max(rect.width, MIN_GAP),
589
- height: Math.max(rect.height, MIN_GAP),
590
- }
591
-
592
- cachedDropAreaRects[area.id] = dropAreaRect
593
- return dropAreaRect
594
- }
595
-
596
- const colorTeal = rgbaToString(theme.teal.value.normal)
597
- const colorTealAlpha = rgbaToString(theme.teal.value.normal, 0.7)
598
- const colorAccent = rgbaToString(theme.accent.value[800])
599
- const colorAccentAlpha = rgbaToString(theme.accent.value[800], 0.7)
600
-
601
- function getRectType(field: BlokkliFieldElement): RectRenderType {
404
+ height: Math.max(rect.height, MIN_GAP)
405
+ };
406
+ cachedDropAreaRects[area.id] = dropAreaRect;
407
+ return dropAreaRect;
408
+ };
409
+ const colorTeal = rgbaToString(theme.teal.value.normal);
410
+ const colorTealAlpha = rgbaToString(theme.teal.value.normal, 0.7);
411
+ const colorAccent = rgbaToString(theme.accent.value[800]);
412
+ const colorAccentAlpha = rgbaToString(theme.accent.value[800], 0.7);
413
+ function getRectType(field) {
602
414
  if (field.nestingLevel >= 3) {
603
- return RectRenderType.FIELD_4
415
+ return 4 /* FIELD_4 */;
604
416
  } else if (field.nestingLevel >= 2) {
605
- return RectRenderType.FIELD_3
417
+ return 3 /* FIELD_3 */;
606
418
  } else if (field.nestingLevel >= 1) {
607
- return RectRenderType.FIELD_2
419
+ return 2 /* FIELD_2 */;
608
420
  }
609
- return RectRenderType.FIELD_1
421
+ return 1 /* FIELD_1 */;
610
422
  }
611
-
612
- class DropTargetRectangleBufferCollector extends RectangleBufferCollector<DrawnRect> {
613
- getBufferInfo(): { info: BufferInfo | null; hasChanged: boolean } {
614
- const visibleFields = dom.getVisibleFields()
615
- const visibleBlocks = dom.getVisibleBlocks()
616
-
617
- const lengthBefore = this.positions.length
618
-
423
+ class DropTargetRectangleBufferCollector extends RectangleBufferCollector {
424
+ getBufferInfo() {
425
+ const visibleFields = dom.getVisibleFields();
426
+ const visibleBlocks = dom.getVisibleBlocks();
427
+ const lengthBefore = this.positions.length;
619
428
  for (let i = 0; i < visibleFields.length; i++) {
620
- const key = visibleFields[i]
621
- const fieldRect = buildFieldRect(key)
622
-
429
+ const key = visibleFields[i];
430
+ const fieldRect = buildFieldRect(key);
623
431
  if (!fieldRect) {
624
- continue
432
+ continue;
625
433
  }
626
- const children = buildChildren(fieldRect, visibleBlocks)
434
+ const children = buildChildren(fieldRect, visibleBlocks);
627
435
  for (let j = 0; j < children.length; j++) {
628
- const child = children[j]
436
+ const child = children[j];
629
437
  if (this.added.has(child.id)) {
630
- continue
438
+ continue;
631
439
  }
632
- const type = getRectType(fieldRect.field)
440
+ const type = getRectType(fieldRect.field);
633
441
  this.addRectangle(
634
442
  {
635
443
  id: child.id,
636
- type: 'field',
444
+ type: "field",
637
445
  label: child.label,
638
446
  color: colorAccent,
639
447
  colorAlpha: colorAccentAlpha,
@@ -641,173 +449,146 @@ class DropTargetRectangleBufferCollector extends RectangleBufferCollector<DrawnR
641
449
  y: fieldRect.y + child.y,
642
450
  width: child.width,
643
451
  height: child.height,
644
- field: fieldRect,
452
+ field: fieldRect
645
453
  },
646
454
  type,
647
- true,
648
- )
455
+ true
456
+ );
649
457
  }
650
458
  }
651
-
652
- const visibleAreas = Array.from(visibleDropAreas)
653
-
459
+ const visibleAreas = Array.from(visibleDropAreas);
654
460
  for (let i = 0; i < visibleAreas.length; i++) {
655
- const area = areas[visibleAreas[i]]
461
+ const area = areas[visibleAreas[i]];
656
462
  if (!area) {
657
- continue
463
+ continue;
658
464
  }
659
465
  if (this.added.has(area.id)) {
660
- continue
466
+ continue;
661
467
  }
662
- const areaRect = buildDropAreaRect(area)
663
-
468
+ const areaRect = buildDropAreaRect(area);
664
469
  this.addRectangle(
665
470
  {
666
471
  id: area.id,
667
- type: 'drop-area',
472
+ type: "drop-area",
668
473
  label: area.label,
669
474
  color: colorTeal,
670
475
  colorAlpha: colorTealAlpha,
671
476
  x: areaRect.x,
672
477
  y: areaRect.y,
673
478
  width: areaRect.width,
674
- height: areaRect.height,
479
+ height: areaRect.height
675
480
  },
676
- RectRenderType.DROP_AREA,
677
- false,
678
- )
481
+ 0 /* DROP_AREA */,
482
+ false
483
+ );
679
484
  }
680
-
681
- const hasChanged = lengthBefore !== this.positions.length
682
-
683
- // Only update the buffer info if it has changed.
485
+ const hasChanged = lengthBefore !== this.positions.length;
684
486
  if (hasChanged) {
685
- this.bufferInfo = this.createBufferInfo()
487
+ this.bufferInfo = this.createBufferInfo();
686
488
  }
687
-
688
- return { info: this.bufferInfo, hasChanged }
489
+ return { info: this.bufferInfo, hasChanged };
689
490
  }
690
-
691
- getClosestIntersectingRect(box: Rectangle, coords: Coord): DrawnRect | null {
692
- const candidates: DrawnRect[] = []
693
- const rects = Object.values(this.rects)
491
+ getClosestIntersectingRect(box, coords) {
492
+ const candidates = [];
493
+ const rects = Object.values(this.rects);
694
494
  for (let i = 0; i < rects.length; i++) {
695
- const rect = rects[i]
696
- if (rect.type === 'active-area') {
697
- continue
495
+ const rect = rects[i];
496
+ if (rect.type === "active-area") {
497
+ continue;
698
498
  }
699
499
  if (intersects(box, rect)) {
700
- candidates.push(rect)
500
+ candidates.push(rect);
701
501
  }
702
502
  }
703
-
704
503
  if (candidates.length === 0) {
705
- return null
504
+ return null;
706
505
  } else if (candidates.length === 1) {
707
- return candidates[0]
506
+ return candidates[0];
708
507
  }
709
-
710
- return findClosestRectangle(coords.x, coords.y, candidates)
508
+ return findClosestRectangle(coords.x, coords.y, candidates);
711
509
  }
712
-
713
- getRectAtPosition(coord: Coord): DrawnRect | null {
714
- const rects = Object.values(this.rects)
715
-
510
+ getRectAtPosition(coord) {
511
+ const rects = Object.values(this.rects);
716
512
  for (let i = 0; i < rects.length; i++) {
717
- const rect = rects[i]
718
- if (rect.type === 'active-area') {
719
- continue
513
+ const rect = rects[i];
514
+ if (rect.type === "active-area") {
515
+ continue;
720
516
  }
721
517
  if (isInsideRect(coord.x, coord.y, rect)) {
722
- return rect
518
+ return rect;
723
519
  }
724
520
  }
725
-
726
- return null
521
+ return null;
727
522
  }
728
523
  }
729
-
730
- const collector = new DropTargetRectangleBufferCollector(gl)
731
-
732
- // Add a rectangle that we will use to display the hovered field area.
733
- // The vertex shader will dynamically transform the quad to match the currently hovered field area.
524
+ const collector = new DropTargetRectangleBufferCollector(gl);
734
525
  collector.addRectangle(
735
526
  {
736
- id: 'active-hover-rect',
737
- type: 'active-area',
738
- label: 'Field Area',
739
- color: 'red',
740
- colorAlpha: 'red',
527
+ id: "active-hover-rect",
528
+ type: "active-area",
529
+ label: "Field Area",
530
+ color: "red",
531
+ colorAlpha: "red",
741
532
  x: 0,
742
533
  y: 0,
743
534
  width: ui.artboardSize.value.width,
744
- height: ui.artboardSize.value.height,
535
+ height: ui.artboardSize.value.height
745
536
  },
746
- RectRenderType.ACTIVE_AREA,
747
- false,
748
- )
749
-
537
+ 5 /* ACTIVE_AREA */,
538
+ false
539
+ );
750
540
  const fieldColors = computed(() => {
751
541
  return {
752
- '0': theme.accent.value[900],
753
- '1': theme.accent.value[400],
754
- '2': theme.accent.value[600],
755
- '3': theme.accent.value[500],
756
- }
757
- })
758
-
759
- function getColorForField(field?: FieldRect | null) {
760
- const nestingLevel = field?.field.nestingLevel || 0
542
+ "0": theme.accent.value[900],
543
+ "1": theme.accent.value[400],
544
+ "2": theme.accent.value[600],
545
+ "3": theme.accent.value[500]
546
+ };
547
+ });
548
+ function getColorForField(field) {
549
+ const nestingLevel = field?.field.nestingLevel || 0;
761
550
  if (nestingLevel >= 3) {
762
- return fieldColors.value[3]
551
+ return fieldColors.value[3];
763
552
  } else if (nestingLevel >= 2) {
764
- return fieldColors.value[2]
553
+ return fieldColors.value[2];
765
554
  } else if (nestingLevel >= 1) {
766
- return fieldColors.value[1]
555
+ return fieldColors.value[1];
767
556
  }
768
- return fieldColors.value[0]
557
+ return fieldColors.value[0];
769
558
  }
770
-
771
559
  const activeColorRgb = computed(() => {
772
- if (active.value?.type === 'drop-area') {
773
- return theme.teal.value.normal
560
+ if (active.value?.type === "drop-area") {
561
+ return theme.teal.value.normal;
774
562
  }
775
563
  if (!active.value) {
776
- return
564
+ return;
777
565
  }
778
- return getColorForField(active.value?.field)
779
- })
780
-
566
+ return getColorForField(active.value?.field);
567
+ });
781
568
  const activeColorHex = computed(() => {
782
569
  if (activeColorRgb.value) {
783
- return rgbaToString(activeColorRgb.value)
570
+ return rgbaToString(activeColorRgb.value);
784
571
  }
785
- return ''
786
- })
787
-
788
- const activeHoverField = ref<FieldRect | null>(null)
789
-
572
+ return "";
573
+ });
574
+ const activeHoverField = ref(null);
790
575
  const activeHoverRect = computed(() => {
791
576
  if (!activeHoverField.value) {
792
- return [0, 0, 0, 0]
577
+ return [0, 0, 0, 0];
793
578
  }
794
-
795
- const outset = activeHoverField.value.field.nestingLevel === 0 ? 0 : 20
796
-
579
+ const outset = activeHoverField.value.field.nestingLevel === 0 ? 0 : 20;
797
580
  return [
798
581
  activeHoverField.value.x - outset,
799
582
  activeHoverField.value.y - outset,
800
583
  activeHoverField.value.width + 2 * outset,
801
- activeHoverField.value.height + 2 * outset,
802
- ]
803
- })
804
-
584
+ activeHoverField.value.height + 2 * outset
585
+ ];
586
+ });
805
587
  const activeHoverColor = computed(() => {
806
- return getColorForField(activeHoverField.value)
807
- })
808
-
588
+ return getColorForField(activeHoverField.value);
589
+ });
809
590
  const uniforms = computed(() => {
810
- const index = active.value?.index
591
+ const index = active.value?.index;
811
592
  return {
812
593
  u_color_field_0: toShaderColor(fieldColors.value[0]),
813
594
  u_color_field_1: toShaderColor(fieldColors.value[1]),
@@ -815,152 +596,118 @@ const uniforms = computed(() => {
815
596
  u_color_field_3: toShaderColor(fieldColors.value[3]),
816
597
  u_color_hover_area: toShaderColor(activeHoverColor.value),
817
598
  u_color_area: toShaderColor(theme.teal.value.normal),
818
- u_active_rect_id: index === undefined ? -1 : index,
819
- u_active_hover_rect: activeHoverRect.value,
820
- }
821
- })
822
-
823
- const dragBox = ref<Rectangle>({
599
+ u_active_rect_id: index === void 0 ? -1 : index,
600
+ u_active_hover_rect: activeHoverRect.value
601
+ };
602
+ });
603
+ const dragBox = ref({
824
604
  x: 0,
825
605
  y: 0,
826
606
  width: 0,
827
- height: 0,
828
- })
829
-
830
- function toCanvasSpaceCoordinates(x: number, y: number): Coord {
831
- const scale = ui.artboardScale.value
832
- const offset = { ...ui.artboardOffset.value }
607
+ height: 0
608
+ });
609
+ function toCanvasSpaceCoordinates(x, y) {
610
+ const scale = ui.artboardScale.value;
611
+ const offset = { ...ui.artboardOffset.value };
833
612
  return {
834
613
  x: (x - offset.x) / scale,
835
- y: (y - offset.y) / scale,
836
- }
614
+ y: (y - offset.y) / scale
615
+ };
837
616
  }
838
-
839
- function setHoveredFieldArea(box: Rectangle, mouse: Coord) {
617
+ function setHoveredFieldArea(box, mouse) {
840
618
  if (active.value?.field) {
841
619
  if (activeHoverField.value?.key !== active.value.field.key) {
842
- activeHoverField.value = active.value.field
620
+ activeHoverField.value = active.value.field;
843
621
  }
844
- return
622
+ return;
845
623
  }
846
- const fields = Object.values(fieldCache)
847
-
848
- let highestNestingLevel = 0
849
- let candidate: FieldRect | null = null
850
-
624
+ const fields = Object.values(fieldCache);
625
+ let highestNestingLevel = 0;
626
+ let candidate = null;
851
627
  for (let i = 0; i < fields.length; i++) {
852
- const field = fields[i]
628
+ const field = fields[i];
853
629
  if (!field.canAddChildren) {
854
- continue
630
+ continue;
855
631
  }
856
- if (
857
- isInsideRect(mouse.x, mouse.y, field) &&
858
- field.field.nestingLevel >= highestNestingLevel
859
- ) {
860
- candidate = field
861
- highestNestingLevel = field.field.nestingLevel
862
- continue
632
+ if (isInsideRect(mouse.x, mouse.y, field) && field.field.nestingLevel >= highestNestingLevel) {
633
+ candidate = field;
634
+ highestNestingLevel = field.field.nestingLevel;
635
+ continue;
863
636
  }
864
- if (
865
- intersects(box, field) &&
866
- field.field.nestingLevel >= highestNestingLevel
867
- ) {
868
- highestNestingLevel = field.field.nestingLevel
869
- candidate = field
637
+ if (intersects(box, field) && field.field.nestingLevel >= highestNestingLevel) {
638
+ highestNestingLevel = field.field.nestingLevel;
639
+ candidate = field;
870
640
  }
871
641
  }
872
-
873
642
  if (candidate && candidate.key !== activeHoverField.value?.key) {
874
- activeHoverField.value = candidate
643
+ activeHoverField.value = candidate;
875
644
  }
876
645
  }
877
-
878
- onBlokkliEvent('canvas:draw', () => {
879
- const scale = ui.artboardScale.value
880
- const offset = { ...ui.artboardOffset.value }
881
-
646
+ onBlokkliEvent("canvas:draw", () => {
647
+ const scale = ui.artboardScale.value;
648
+ const offset = { ...ui.artboardOffset.value };
882
649
  dragBox.value = {
883
650
  x: (props.box.x - offset.x) / scale,
884
651
  y: (props.box.y - offset.y) / scale,
885
652
  width: props.box.width / scale,
886
- height: props.box.height / scale,
887
- }
888
-
889
- const mouseAbsolute = toCanvasSpaceCoordinates(props.mouseX, props.mouseY)
890
-
653
+ height: props.box.height / scale
654
+ };
655
+ const mouseAbsolute = toCanvasSpaceCoordinates(props.mouseX, props.mouseY);
891
656
  if (gl && programInfo) {
892
- gl.useProgram(programInfo.program)
893
- animation.setSharedUniforms(gl, programInfo)
657
+ gl.useProgram(programInfo.program);
658
+ animation.setSharedUniforms(gl, programInfo);
894
659
  }
895
-
896
660
  if (!props.isTouch) {
897
661
  if (cursorIsInsideClipped()) {
898
662
  const closest = collector.getClosestIntersectingRect(
899
663
  dragBox.value,
900
- mouseAbsolute,
901
- )
902
-
903
- active.value = closest || null
664
+ mouseAbsolute
665
+ );
666
+ active.value = closest || null;
904
667
  } else {
905
- active.value = null
668
+ active.value = null;
906
669
  }
907
670
  }
908
-
909
- const { info, hasChanged } = collector.getBufferInfo()
910
-
911
- // WebGL rendering.
671
+ const { info, hasChanged } = collector.getBufferInfo();
912
672
  if (programInfo && gl) {
913
- setHoveredFieldArea(dragBox.value, mouseAbsolute)
914
- setUniforms(programInfo, uniforms.value)
915
-
916
- // Nothing to draw.
673
+ setHoveredFieldArea(dragBox.value, mouseAbsolute);
674
+ setUniforms(programInfo, uniforms.value);
917
675
  if (info) {
918
- // Only update buffer and attributes when they have changed.
919
676
  if (hasChanged && gl && programInfo) {
920
- setBuffersAndAttributes(gl, programInfo, info)
677
+ setBuffersAndAttributes(gl, programInfo, info);
921
678
  }
922
-
923
679
  if (gl) {
924
- drawBufferInfo(gl, info, gl.TRIANGLES)
680
+ drawBufferInfo(gl, info, gl.TRIANGLES);
925
681
  }
926
682
  }
927
-
928
- return
683
+ return;
929
684
  }
930
-
931
- // Fallback rendering.
932
685
  if (!ctx) {
933
- return
686
+ return;
934
687
  }
935
-
936
- ctx.clearRect(0, 0, canvas.width, canvas.height)
937
-
938
- const rects = Object.values(collector.rects)
939
-
688
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
689
+ const rects = Object.values(collector.rects);
940
690
  for (let i = 0; i < rects.length; i++) {
941
- const rect = rects[i]
691
+ const rect = rects[i];
942
692
  if (active.value?.id === rect.id) {
943
- ctx.fillStyle = rect.color
693
+ ctx.fillStyle = rect.color;
944
694
  } else {
945
- ctx.fillStyle = rect.colorAlpha
695
+ ctx.fillStyle = rect.colorAlpha;
946
696
  }
947
-
948
697
  ctx.fillRect(
949
698
  (rect.x * scale + offset.x) * animation.dpi.value,
950
699
  (rect.y * scale + offset.y) * animation.dpi.value,
951
700
  rect.width * animation.dpi.value * scale,
952
- rect.height * animation.dpi.value * scale,
953
- )
701
+ rect.height * animation.dpi.value * scale
702
+ );
954
703
  }
955
- })
956
-
704
+ });
957
705
  onBeforeUnmount(() => {
958
706
  if (gl) {
959
- gl.clear(gl.COLOR_BUFFER_BIT)
707
+ gl.clear(gl.COLOR_BUFFER_BIT);
960
708
  }
961
-
962
709
  if (ctx) {
963
- ctx.clearRect(0, 0, canvas.width, canvas.height)
710
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
964
711
  }
965
- })
712
+ });
966
713
  </script>