@blokkli/editor 2.0.0-alpha.53 → 2.0.0-alpha.55

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 (218) hide show
  1. package/dist/global/constants/index.d.ts +1 -1
  2. package/dist/global/constants/index.js +1 -1
  3. package/dist/global/types/features.d.ts +5 -9
  4. package/dist/module.json +1 -1
  5. package/dist/module.mjs +28 -35
  6. package/dist/modules/agent/index.mjs +46 -29
  7. package/dist/modules/agent/runtime/app/composables/agentProvider.js +2 -1
  8. package/dist/modules/agent/runtime/app/features/agent/Container.d.vue.ts +19 -0
  9. package/dist/modules/agent/runtime/app/features/agent/Container.vue +195 -0
  10. package/dist/modules/agent/runtime/app/features/agent/Container.vue.d.ts +19 -0
  11. package/dist/modules/agent/runtime/app/features/agent/index.vue +18 -164
  12. package/dist/modules/agent/runtime/app/features/agent/types.d.ts +9 -0
  13. package/dist/modules/agent/runtime/app/helpers/index.d.ts +7 -3
  14. package/dist/modules/agent/runtime/app/helpers/index.js +9 -3
  15. package/dist/modules/agent/runtime/app/prompts/fixReadability.js +51 -44
  16. package/dist/modules/agent/runtime/app/tools/add_media_paragraph/index.js +2 -1
  17. package/dist/modules/agent/runtime/app/tools/check_readability/index.js +1 -0
  18. package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/Component.vue +1 -1
  19. package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/index.js +6 -1
  20. package/dist/modules/agent/runtime/app/tools/get_readability_issues/index.js +1 -0
  21. package/dist/modules/agent/runtime/app/types/index.d.ts +12 -0
  22. package/dist/modules/charts/runtime/components/ChartRenderer/index.vue +34 -18
  23. package/dist/modules/drupal/graphql/base/fragment.paragraphsBlokkliEditState.graphql +7 -0
  24. package/dist/modules/drupal/graphql/features/droppable-field-items.graphql +22 -0
  25. package/dist/modules/drupal/graphql/features/import-existing.graphql +0 -25
  26. package/dist/modules/drupal/graphql/features/workspace.graphql +9 -2
  27. package/dist/modules/drupal/graphql/mutations/update_droppable_field.graphql +21 -0
  28. package/dist/modules/drupal/index.mjs +6 -2
  29. package/dist/modules/drupal/runtime/adapter/index.js +75 -39
  30. package/dist/modules/readability/index.d.mts +11 -0
  31. package/dist/modules/readability/index.mjs +17 -0
  32. package/dist/modules/readability/runtime/adapter-extension.d.ts +2 -0
  33. package/dist/modules/readability/runtime/adapter-extension.js +5 -0
  34. package/dist/modules/readability/runtime/analyzers/builtin.d.ts +10 -0
  35. package/dist/modules/readability/runtime/analyzers/builtin.js +340 -0
  36. package/dist/runtime/components/BlokkliEditable.vue +10 -90
  37. package/dist/runtime/components/BlokkliItem.vue +2 -2
  38. package/dist/runtime/components/BlokkliProvider.vue +11 -5
  39. package/dist/runtime/composables/defineBlokkli.js +3 -1
  40. package/dist/runtime/composables/defineBlokkliFeature.d.ts +2 -3
  41. package/dist/runtime/editor/components/Actions/index.vue +1 -1
  42. package/dist/runtime/editor/components/AnimationCanvas/index.vue +41 -6
  43. package/dist/runtime/editor/components/AppMenu/Inner.d.vue.ts +7 -0
  44. package/dist/runtime/editor/components/AppMenu/Inner.vue +83 -0
  45. package/dist/runtime/editor/components/AppMenu/Inner.vue.d.ts +7 -0
  46. package/dist/runtime/editor/components/AppMenu/index.vue +5 -79
  47. package/dist/runtime/editor/components/ArtboardTooltip/index.d.vue.ts +1 -0
  48. package/dist/runtime/editor/components/ArtboardTooltip/index.vue +9 -1
  49. package/dist/runtime/editor/components/ArtboardTooltip/index.vue.d.ts +1 -0
  50. package/dist/runtime/editor/components/BlockPreviewItem/index.vue +12 -6
  51. package/dist/runtime/editor/components/BlokkliEditableEdit.d.vue.ts +23 -0
  52. package/dist/runtime/editor/components/BlokkliEditableEdit.vue +95 -0
  53. package/dist/runtime/editor/components/BlokkliEditableEdit.vue.d.ts +23 -0
  54. package/dist/runtime/editor/components/BlokkliRootErrorBoundary.d.vue.ts +4 -1
  55. package/dist/runtime/editor/components/BlokkliRootErrorBoundary.vue +4 -1
  56. package/dist/runtime/editor/components/BlokkliRootErrorBoundary.vue.d.ts +4 -1
  57. package/dist/runtime/editor/components/BundleSelector/index.vue +10 -5
  58. package/dist/runtime/editor/components/Dialog/index.vue +0 -77
  59. package/dist/runtime/editor/components/EditIndicator.d.vue.ts +1 -0
  60. package/dist/runtime/editor/components/EditIndicator.vue +3 -2
  61. package/dist/runtime/editor/components/EditIndicator.vue.d.ts +1 -0
  62. package/dist/runtime/editor/components/EditProvider.d.vue.ts +3 -1
  63. package/dist/runtime/editor/components/EditProvider.vue +13 -4
  64. package/dist/runtime/editor/components/EditProvider.vue.d.ts +3 -1
  65. package/dist/runtime/editor/components/FeaturesRenderer/index.vue +1 -4
  66. package/dist/runtime/editor/components/Form/Text/index.d.vue.ts +5 -0
  67. package/dist/runtime/editor/components/Form/Text/index.vue +10 -4
  68. package/dist/runtime/editor/components/Form/Text/index.vue.d.ts +5 -0
  69. package/dist/runtime/editor/components/FormOverlay/index.vue +0 -24
  70. package/dist/runtime/editor/components/GrowOnly/index.d.vue.ts +10 -0
  71. package/dist/runtime/editor/components/GrowOnly/index.vue +34 -0
  72. package/dist/runtime/editor/components/GrowOnly/index.vue.d.ts +10 -0
  73. package/dist/runtime/editor/components/Konami/Game/index.vue +120 -0
  74. package/dist/runtime/editor/components/Konami/index.vue +7 -124
  75. package/dist/runtime/editor/components/Loading/index.vue +1 -1
  76. package/dist/runtime/editor/components/PluginConfigForm/Text/index.vue +1 -0
  77. package/dist/runtime/editor/components/PluginConfigForm/index.vue +1 -0
  78. package/dist/runtime/editor/components/PreviewProvider.d.vue.ts +3 -1
  79. package/dist/runtime/editor/components/PreviewProvider.vue +6 -1
  80. package/dist/runtime/editor/components/PreviewProvider.vue.d.ts +3 -1
  81. package/dist/runtime/editor/components/Toolbar/index.vue +1 -1
  82. package/dist/runtime/editor/components/index.d.ts +11 -10
  83. package/dist/runtime/editor/components/index.js +32 -10
  84. package/dist/runtime/editor/composables/defineRenderer.d.ts +2 -2
  85. package/dist/runtime/editor/composables/defineRenderer.js +8 -3
  86. package/dist/runtime/editor/css/output.css +1 -1
  87. package/dist/runtime/editor/events/index.d.ts +6 -0
  88. package/dist/runtime/editor/features/analyze/Main.d.vue.ts +1 -0
  89. package/dist/runtime/editor/features/analyze/Main.vue +9 -8
  90. package/dist/runtime/editor/features/analyze/Main.vue.d.ts +1 -0
  91. package/dist/runtime/editor/features/analyze/Results/ResultsItem.vue +7 -15
  92. package/dist/runtime/editor/features/analyze/Results/ResultsItemNodesTarget.vue +4 -2
  93. package/dist/runtime/editor/features/analyze/analyzers/axe.js +9 -9
  94. package/dist/runtime/editor/features/analyze/analyzers/readability.js +7 -7
  95. package/dist/runtime/editor/features/analyze/index.vue +26 -26
  96. package/dist/runtime/editor/features/analyze/readability/types.d.ts +18 -14
  97. package/dist/runtime/editor/features/anchors/index.vue +6 -2
  98. package/dist/runtime/editor/features/artboard/Renderer.vue +3 -2
  99. package/dist/runtime/editor/features/block-scheduler/Dialog/index.vue +78 -0
  100. package/dist/runtime/editor/features/block-scheduler/index.vue +34 -89
  101. package/dist/runtime/editor/features/breadcrumbs/index.vue +2 -2
  102. package/dist/runtime/editor/features/changelog/changelog.json +8 -0
  103. package/dist/runtime/editor/features/changelog/index.vue +10 -8
  104. package/dist/runtime/editor/features/clipboard/DropElement/index.vue +152 -0
  105. package/dist/runtime/editor/features/clipboard/index.vue +13 -159
  106. package/dist/runtime/editor/features/command-palette/Palette/Item/index.vue +0 -28
  107. package/dist/runtime/editor/features/command-palette/Palette/index.vue +17 -6
  108. package/dist/runtime/editor/features/command-palette/index.vue +7 -2
  109. package/dist/runtime/editor/features/comments/index.vue +6 -3
  110. package/dist/runtime/editor/features/debug/Main.vue +168 -0
  111. package/dist/runtime/editor/features/debug/Section/Features.vue +1 -2
  112. package/dist/runtime/editor/features/debug/index.vue +6 -170
  113. package/dist/runtime/editor/features/dev-mode/index.vue +2 -1
  114. package/dist/runtime/editor/features/diff/index.vue +6 -2
  115. package/dist/runtime/editor/features/dragging-overlay/Renderer/index.vue +15 -16
  116. package/dist/runtime/editor/features/dragging-overlay/index.vue +4 -3
  117. package/dist/runtime/editor/features/droppable-field-edit/Overlay/index.d.vue.ts +15 -0
  118. package/dist/runtime/editor/features/droppable-field-edit/Overlay/index.vue +547 -0
  119. package/dist/runtime/editor/features/droppable-field-edit/Overlay/index.vue.d.ts +15 -0
  120. package/dist/runtime/editor/features/droppable-field-edit/index.d.vue.ts +3 -0
  121. package/dist/runtime/editor/features/droppable-field-edit/index.vue +231 -0
  122. package/dist/runtime/editor/features/droppable-field-edit/index.vue.d.ts +3 -0
  123. package/dist/runtime/editor/features/droppable-field-edit/types.d.ts +70 -0
  124. package/dist/runtime/editor/features/editable-field/Overlay/Frame/index.d.vue.ts +1 -0
  125. package/dist/runtime/editor/features/editable-field/Overlay/Frame/index.vue +34 -21
  126. package/dist/runtime/editor/features/editable-field/Overlay/Frame/index.vue.d.ts +1 -0
  127. package/dist/runtime/editor/features/editable-field/Overlay/Plaintext/index.d.vue.ts +2 -2
  128. package/dist/runtime/editor/features/editable-field/Overlay/Plaintext/index.vue.d.ts +2 -2
  129. package/dist/runtime/editor/features/editable-field/Overlay/ReadabilityIndicator/ChunkOverlay.vue +1 -1
  130. package/dist/runtime/editor/features/editable-field/Overlay/ReadabilityIndicator/index.vue +6 -13
  131. package/dist/runtime/editor/features/editable-field/Overlay/index.vue +4 -4
  132. package/dist/runtime/editor/features/fragments/index.vue +9 -4
  133. package/dist/runtime/editor/features/help/index.vue +7 -2
  134. package/dist/runtime/editor/features/highlights/Renderer/index.vue +11 -17
  135. package/dist/runtime/editor/features/history/index.vue +3 -2
  136. package/dist/runtime/editor/features/hover/Renderer/index.vue +87 -36
  137. package/dist/runtime/editor/features/hover/Renderer/vertex.glsl +5 -5
  138. package/dist/runtime/editor/features/hover/index.vue +1 -1
  139. package/dist/runtime/editor/features/import-existing/Dialog/Item.d.vue.ts +5 -0
  140. package/dist/runtime/editor/features/import-existing/Dialog/Item.vue +55 -0
  141. package/dist/runtime/editor/features/import-existing/Dialog/Item.vue.d.ts +5 -0
  142. package/dist/runtime/editor/features/import-existing/Dialog/index.d.vue.ts +7 -3
  143. package/dist/runtime/editor/features/import-existing/Dialog/index.vue +107 -65
  144. package/dist/runtime/editor/features/import-existing/Dialog/index.vue.d.ts +7 -3
  145. package/dist/runtime/editor/features/import-existing/index.vue +19 -6
  146. package/dist/runtime/editor/features/import-existing/types.d.ts +0 -11
  147. package/dist/runtime/editor/features/library/ReusableDialog/index.vue +7 -33
  148. package/dist/runtime/editor/features/library/index.vue +14 -5
  149. package/dist/runtime/editor/features/media-library/Library/index.vue +3 -1
  150. package/dist/runtime/editor/features/media-library/index.vue +9 -2
  151. package/dist/runtime/editor/features/media-library/types.d.ts +2 -0
  152. package/dist/runtime/editor/features/multi-select/Renderer/index.vue +16 -15
  153. package/dist/runtime/editor/features/multi-select/index.vue +9 -3
  154. package/dist/runtime/editor/features/options/Form/Radios/index.vue +4 -8
  155. package/dist/runtime/editor/features/options/index.vue +7 -2
  156. package/dist/runtime/editor/features/preview-grant/index.vue +8 -2
  157. package/dist/runtime/editor/features/publish/index.vue +3 -2
  158. package/dist/runtime/editor/features/referenced-entities/index.vue +7 -2
  159. package/dist/runtime/editor/features/responsive-preview/index.vue +13 -11
  160. package/dist/runtime/editor/features/search/index.vue +6 -2
  161. package/dist/runtime/editor/features/selection/AddButtons/Renderer/index.vue +6 -11
  162. package/dist/runtime/editor/features/selection/Renderer/index.vue +9 -14
  163. package/dist/runtime/editor/features/selection/index.vue +7 -4
  164. package/dist/runtime/editor/features/settings/index.vue +8 -3
  165. package/dist/runtime/editor/features/structure/index.vue +3 -2
  166. package/dist/runtime/editor/features/templates/CreateDialog/index.vue +1 -0
  167. package/dist/runtime/editor/features/templates/index.vue +14 -6
  168. package/dist/runtime/editor/features/theme/index.vue +2 -1
  169. package/dist/runtime/editor/features/tour/index.vue +6 -2
  170. package/dist/runtime/editor/features/translations/index.vue +7 -4
  171. package/dist/runtime/editor/features/workspace/Overlay/Item.d.vue.ts +3 -0
  172. package/dist/runtime/editor/features/workspace/Overlay/Item.vue +49 -0
  173. package/dist/runtime/editor/features/workspace/Overlay/Item.vue.d.ts +3 -0
  174. package/dist/runtime/editor/features/workspace/Overlay/index.vue +16 -104
  175. package/dist/runtime/editor/features/workspace/index.vue +6 -2
  176. package/dist/runtime/editor/helpers/webgl/index.d.ts +3 -2
  177. package/dist/runtime/editor/helpers/webgl/index.js +2 -3
  178. package/dist/runtime/editor/libraries/fzf.d.ts +3 -0
  179. package/dist/runtime/editor/libraries/fzf.js +7 -0
  180. package/dist/runtime/editor/libraries/twgl.d.ts +10 -0
  181. package/dist/runtime/editor/libraries/twgl.js +14 -0
  182. package/dist/runtime/editor/plugins/DebugOverlay/index.vue +3 -1
  183. package/dist/runtime/editor/plugins/Sidebar/Detached/index.vue +39 -18
  184. package/dist/runtime/editor/plugins/Sidebar/index.d.vue.ts +2 -0
  185. package/dist/runtime/editor/plugins/Sidebar/index.vue +12 -4
  186. package/dist/runtime/editor/plugins/Sidebar/index.vue.d.ts +2 -0
  187. package/dist/runtime/editor/providers/animation.d.ts +5 -10
  188. package/dist/runtime/editor/providers/animation.js +10 -8
  189. package/dist/runtime/editor/providers/directive.d.ts +11 -0
  190. package/dist/runtime/editor/providers/directive.js +16 -0
  191. package/dist/runtime/editor/providers/features.d.ts +3 -3
  192. package/dist/runtime/editor/providers/features.js +1 -1
  193. package/dist/runtime/editor/providers/fieldValue.d.ts +27 -0
  194. package/dist/runtime/editor/providers/fieldValue.js +21 -1
  195. package/dist/runtime/editor/providers/keyboard.js +6 -3
  196. package/dist/runtime/editor/providers/readability.d.ts +28 -4
  197. package/dist/runtime/editor/providers/readability.js +30 -46
  198. package/dist/runtime/editor/providers/selection.d.ts +8 -0
  199. package/dist/runtime/editor/providers/selection.js +6 -0
  200. package/dist/runtime/editor/providers/texts.d.ts +1 -3
  201. package/dist/runtime/editor/providers/texts.js +34 -37
  202. package/dist/runtime/editor/providers/workspaces.d.ts +93 -0
  203. package/dist/runtime/editor/providers/workspaces.js +76 -0
  204. package/dist/runtime/editor/translations/de.json +918 -3616
  205. package/dist/runtime/editor/translations/fr.json +250 -3616
  206. package/dist/runtime/editor/translations/gsw_CH.json +918 -3616
  207. package/dist/runtime/editor/translations/it.json +250 -3616
  208. package/dist/runtime/editor/types/app.d.ts +2 -0
  209. package/dist/runtime/editor/types/features.d.ts +1 -1
  210. package/dist/runtime/editor/types/state.d.ts +7 -0
  211. package/dist/runtime/helpers/injections.d.ts +6 -0
  212. package/dist/runtime/helpers/injections.js +3 -0
  213. package/dist/runtime/types/definitions.d.ts +4 -0
  214. package/package.json +14 -4
  215. package/dist/runtime/editor/features/analyze/readability/builtinAnalyzer.d.ts +0 -6
  216. package/dist/runtime/editor/features/analyze/readability/builtinAnalyzer.js +0 -216
  217. package/dist/runtime/editor/features/workspace/types.d.ts +0 -59
  218. /package/dist/runtime/editor/features/{workspace → droppable-field-edit}/types.js +0 -0
@@ -1,53 +1,50 @@
1
- import { computed, ref } from "vue";
1
+ import { shallowRef } from "vue";
2
2
  import {
3
- translations
3
+ translationLoaders
4
4
  } from "#blokkli-build/translations";
5
5
  import {
6
6
  defaultLanguage,
7
7
  forceDefaultLanguage
8
8
  } from "#blokkli-build/editor-config";
9
- import { LANGUAGES } from "../../../global/constants";
9
+ import { TRANSLATION_LANGUAGES } from "../../../global/constants";
10
10
  function isInterfaceLanguage(value) {
11
- return LANGUAGES.includes(value);
11
+ return TRANSLATION_LANGUAGES.includes(value);
12
12
  }
13
13
  const DEBUG_SWISS_GERMAN = false;
14
- export default function(context) {
15
- const allTranslations = ref(translations);
14
+ function resolveEffectiveLanguage(requested) {
15
+ const today = /* @__PURE__ */ new Date();
16
+ const isAprilFirst = today.getMonth() === 3 && today.getDate() === 1;
17
+ if (isAprilFirst && requested === "de" || DEBUG_SWISS_GERMAN && import.meta.dev && requested === "de") {
18
+ return "gsw_CH";
19
+ }
20
+ if (forceDefaultLanguage) {
21
+ return defaultLanguage;
22
+ }
23
+ if (isInterfaceLanguage(requested)) {
24
+ return requested;
25
+ }
26
+ return defaultLanguage;
27
+ }
28
+ export default async function(requestedLanguage) {
29
+ const language = resolveEffectiveLanguage(requestedLanguage);
30
+ const currentTranslations = shallowRef({});
31
+ async function loadTranslations(loaders, langcode) {
32
+ const loader = loaders[langcode];
33
+ if (loader) {
34
+ currentTranslations.value = await loader();
35
+ } else {
36
+ currentTranslations.value = {};
37
+ }
38
+ }
16
39
  if (import.meta.hot) {
17
- import.meta.hot.accept("#blokkli-build/translations", (mod) => {
18
- if (mod?.translations) {
19
- allTranslations.value = mod.translations;
40
+ import.meta.hot.accept("#blokkli-build/translations", async (mod) => {
41
+ if (mod?.translationLoaders) {
42
+ loadTranslations(mod.translationLoaders, language);
20
43
  }
21
44
  });
22
45
  }
23
- const language = computed(() => {
24
- if (forceDefaultLanguage) {
25
- return defaultLanguage;
26
- }
27
- if (context?.value.language && isInterfaceLanguage(context.value.language)) {
28
- return context.value.language;
29
- }
30
- return defaultLanguage;
31
- });
32
- const currentTranslations = computed(() => {
33
- const today = /* @__PURE__ */ new Date();
34
- const isAprilFirst = today.getMonth() === 3 && today.getDate() === 1;
35
- if (isAprilFirst && language.value === "de" || DEBUG_SWISS_GERMAN && import.meta.dev) {
36
- return allTranslations.value.gsw_CH || allTranslations.value[language.value] || {};
37
- }
38
- return allTranslations.value[language.value] || {};
39
- });
46
+ await loadTranslations(translationLoaders, language);
40
47
  return (key, defaultValue) => {
41
- const existingForCurrent = currentTranslations.value[key];
42
- if (existingForCurrent) {
43
- return existingForCurrent;
44
- }
45
- if (language.value === "gsw_CH") {
46
- const fallback = translations.de[key];
47
- if (fallback) {
48
- return fallback;
49
- }
50
- }
51
- return defaultValue || key;
48
+ return currentTranslations.value[key] || defaultValue || key;
52
49
  };
53
50
  }
@@ -0,0 +1,93 @@
1
+ import { type Ref, type ComputedRef } from '#imports';
2
+ import type { AdapterContext, FullBlokkliAdapter } from '#blokkli/editor/adapter';
3
+ import type { StateProvider } from './state.js';
4
+ export type HostEntitySearchResultLabelMap = {
5
+ label: string;
6
+ bundles: Record<string, string>;
7
+ };
8
+ export type HostEntitySearchResultItem = {
9
+ /**
10
+ * The ID of the host entity.
11
+ */
12
+ id: string;
13
+ /**
14
+ * The UUID of the host entity.
15
+ */
16
+ uuid: string;
17
+ /**
18
+ * The entity type of the host entity.
19
+ */
20
+ entityType: string;
21
+ /**
22
+ * The entity bundle of the host entity.
23
+ */
24
+ bundle: string;
25
+ /**
26
+ * The label of the host entity.
27
+ */
28
+ label: string;
29
+ /**
30
+ * The url to start editing.
31
+ */
32
+ url: string;
33
+ /**
34
+ * If an edit state exists: The time when the edit state was last changed.
35
+ */
36
+ lastChanged: string | null;
37
+ /**
38
+ * If an edit state exists: The ID of the owner of the edit state.
39
+ */
40
+ uid: string | null;
41
+ /**
42
+ * Optional additional context used for searching (e.g. SKU, internal ID).
43
+ *
44
+ * Not displayed in the UI, but included in the fzf search.
45
+ */
46
+ context?: string;
47
+ };
48
+ export type HostEntitySearchResult = {
49
+ items: HostEntitySearchResultItem[];
50
+ /**
51
+ * A map with keys that are entity types.
52
+ */
53
+ labelMap: HostEntitySearchResultLabelMap;
54
+ };
55
+ export type WorkspacesProvider = {
56
+ /**
57
+ * Whether the host entities have been fetched.
58
+ */
59
+ isLoaded: Readonly<Ref<boolean>>;
60
+ /**
61
+ * Whether the host entities are currently being fetched.
62
+ */
63
+ isLoading: Readonly<Ref<boolean>>;
64
+ /**
65
+ * Loaded items minus the current entity, in workspace default sort order:
66
+ * entries with edit states first → current user as owner → most-recent →
67
+ * alphabetic by label.
68
+ */
69
+ defaultSorted: ComputedRef<HostEntitySearchResultItem[]>;
70
+ /**
71
+ * Load the host entities. Idempotent — concurrent calls share the same
72
+ * in-flight promise, and resolved data is reused on subsequent calls.
73
+ */
74
+ ensureLoaded: () => Promise<void>;
75
+ /**
76
+ * Run a fuzzy search over loaded items. Resolves to fzf-ordered results
77
+ * (excluding the current entity). An empty/whitespace query resolves to [].
78
+ */
79
+ search: (query: string) => Promise<HostEntitySearchResultItem[]>;
80
+ /**
81
+ * Translated label for a bundle key, falling back to the key itself.
82
+ */
83
+ getBundleLabel: (bundle: string) => string;
84
+ };
85
+ declare module '#blokkli/editor/adapter' {
86
+ interface BlokkliAdapter<T> {
87
+ /**
88
+ * Search for host entities.
89
+ */
90
+ getHostEntities?: () => Promise<HostEntitySearchResult>;
91
+ }
92
+ }
93
+ export default function workspacesProvider(adapter: FullBlokkliAdapter<any>, context: ComputedRef<AdapterContext>, state: StateProvider): WorkspacesProvider;
@@ -0,0 +1,76 @@
1
+ import { ref, computed } from "#imports";
2
+ import { loadFzf } from "#blokkli/editor/libraries/fzf";
3
+ export default function workspacesProvider(adapter, context, state) {
4
+ const items = ref([]);
5
+ const labelMap = ref(null);
6
+ const isLoaded = ref(false);
7
+ const isLoading = ref(false);
8
+ let loadPromise = null;
9
+ let fzf = null;
10
+ function ensureLoaded() {
11
+ if (isLoaded.value) {
12
+ return Promise.resolve();
13
+ }
14
+ if (loadPromise) {
15
+ return loadPromise;
16
+ }
17
+ isLoading.value = true;
18
+ loadPromise = adapter.getHostEntities().then((result) => {
19
+ items.value = result.items;
20
+ labelMap.value = result.labelMap;
21
+ isLoaded.value = true;
22
+ }).finally(() => {
23
+ isLoading.value = false;
24
+ });
25
+ return loadPromise;
26
+ }
27
+ const ownerId = computed(() => state.owner.value?.id);
28
+ const currentEntityUuid = computed(() => context.value.entityUuid);
29
+ const defaultSorted = computed(() => {
30
+ return items.value.filter((v) => v.uuid !== currentEntityUuid.value).sort((a, b) => {
31
+ const aHasState = a.lastChanged !== null ? 0 : 1;
32
+ const bHasState = b.lastChanged !== null ? 0 : 1;
33
+ if (aHasState !== bHasState) return aHasState - bHasState;
34
+ const aIsOwner = a.uid && a.uid === ownerId.value ? 0 : 1;
35
+ const bIsOwner = b.uid && b.uid === ownerId.value ? 0 : 1;
36
+ if (aIsOwner !== bIsOwner) return aIsOwner - bIsOwner;
37
+ if (a.lastChanged && b.lastChanged) {
38
+ return new Date(b.lastChanged).getTime() - new Date(a.lastChanged).getTime();
39
+ }
40
+ if (a.lastChanged) return -1;
41
+ if (b.lastChanged) return 1;
42
+ return a.label.localeCompare(b.label);
43
+ });
44
+ });
45
+ async function getFzf() {
46
+ if (!fzf) {
47
+ const { AsyncFzf, asyncExtendedMatch } = await loadFzf();
48
+ fzf = new AsyncFzf(items.value, {
49
+ selector: (item) => item.context ? item.label + " " + item.context : item.label,
50
+ match: asyncExtendedMatch
51
+ });
52
+ }
53
+ return fzf;
54
+ }
55
+ async function search(query) {
56
+ const trimmed = query.trim();
57
+ if (!trimmed) {
58
+ return [];
59
+ }
60
+ await ensureLoaded();
61
+ const instance = await getFzf();
62
+ const results = await instance.find(trimmed);
63
+ return results.map((r) => r.item).filter((v) => v.uuid !== currentEntityUuid.value);
64
+ }
65
+ function getBundleLabel(bundle) {
66
+ return labelMap.value?.bundles[bundle] ?? bundle;
67
+ }
68
+ return {
69
+ isLoaded,
70
+ isLoading,
71
+ defaultSorted,
72
+ ensureLoaded,
73
+ search,
74
+ getBundleLabel
75
+ };
76
+ }