@blokkli/editor 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "blokkli",
3
3
  "configKey": "blokkli",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.12.0"
7
7
  },
package/dist/module.mjs CHANGED
@@ -6,7 +6,7 @@ import { createUnplugin } from 'unplugin';
6
6
  import MagicString from 'magic-string';
7
7
  import { walk } from 'estree-walker-ts';
8
8
 
9
- const version = "1.0.0";
9
+ const version = "1.0.1";
10
10
 
11
11
  function sortObjectKeys(obj) {
12
12
  const sortedKeys = Object.keys(obj).sort();
@@ -4972,12 +4972,14 @@ const module = defineNuxtModule({
4972
4972
  followSymbolicLinks: false
4973
4973
  }) : [];
4974
4974
  await featureExtractor.addFiles([...builtinFeatures, ...customFeatures]);
4975
- const features = featureExtractor.getFeatures().filter((v) => {
4975
+ const extractedFeatures = featureExtractor.getFeatures();
4976
+ const features = extractedFeatures.filter((v) => {
4976
4977
  return v.id !== "theme" || moduleOptions.enableThemeEditor;
4977
4978
  });
4978
4979
  const featuresContext = {
4979
4980
  features
4980
4981
  };
4982
+ const allFeatureIds = extractedFeatures.map((v) => v.id);
4981
4983
  if (moduleOptions.alterFeatures) {
4982
4984
  featuresContext.features = await Promise.resolve(
4983
4985
  moduleOptions.alterFeatures(featuresContext)
@@ -5023,7 +5025,7 @@ export const availableFeaturesAtBuild = ${JSON.stringify(
5023
5025
  availableFeaturesAtBuild
5024
5026
  )} as const
5025
5027
 
5026
- export type ValidFeatureKey = typeof availableFeaturesAtBuild[number]
5028
+ export type ValidFeatureKey = ${allFeatureIds.map((v) => '"' + v + '"').join(" | ")}
5027
5029
 
5028
5030
  type FeatureComponent = {
5029
5031
  id: string
@@ -60,7 +60,11 @@ import {
60
60
  nextTick,
61
61
  } from '#imports'
62
62
  import { AddListItem } from '#blokkli/components'
63
- import type { Command, DraggableExistingBlock } from '#blokkli/types'
63
+ import type {
64
+ Command,
65
+ DraggableExistingBlock,
66
+ FieldConfig,
67
+ } from '#blokkli/types'
64
68
  import { getDefaultDefinition } from '#blokkli/definitions'
65
69
  import defineCommands from '#blokkli/helpers/composables/defineCommands'
66
70
  import onBlokkliEvent from '#blokkli/helpers/composables/onBlokkliEvent'
@@ -225,7 +229,7 @@ const getBundlesForAppendCommands = () => {
225
229
  }
226
230
 
227
231
  const block = selection.blocks.value[0]
228
- const field = types.getFieldConfig(
232
+ const field: FieldConfig | undefined = types.getFieldConfig(
229
233
  block.hostType,
230
234
  block.hostBundle,
231
235
  block.hostFieldName,
@@ -256,7 +260,7 @@ const getAppendEndCommands = (): Command[] => {
256
260
  context.value.entityType,
257
261
  context.value.entityBundle,
258
262
  )
259
- .flatMap((field) => {
263
+ .flatMap((field: FieldConfig) => {
260
264
  if (field.cardinality !== -1) {
261
265
  const key = getFieldKey(context.value.entityUuid, field.name)
262
266
  const count = state.getFieldBlockCount(key)
@@ -267,7 +271,7 @@ const getAppendEndCommands = (): Command[] => {
267
271
  }
268
272
  return field.allowedBundles
269
273
  .filter((v) => !reservedBundles.includes(v))
270
- .map((bundle) => {
274
+ .map((bundle: string) => {
271
275
  const definition = types.getBlockBundleDefinition(bundle)
272
276
  return {
273
277
  id: 'block_add_list:append_end:' + bundle + field.name,
@@ -350,29 +354,31 @@ const getInsertCommands = (
350
354
  }
351
355
  })
352
356
 
353
- const commands: Command[] = nestedFields.flatMap((field) => {
354
- return field.allowedBundles.map((bundle) => {
355
- const label = types.getBlockBundleDefinition(bundle)?.label || bundle
356
- return {
357
- id: 'block_add_list:insert:' + field.name + ':' + bundle,
358
- label: $t(
359
- 'addBlockCommand.insertInField',
360
- 'Insert "@block" into "@field"',
361
- )
362
- .replace('@block', label)
363
- .replace('@field', field.label),
364
- group: 'add',
365
- bundle,
366
- callback: () =>
367
- commandCallbackInsert(
368
- bundle,
369
- field.name,
370
- field.entityType,
371
- field.uuid,
372
- ),
373
- }
374
- })
375
- })
357
+ const commands: Command[] = nestedFields.flatMap(
358
+ (field: FieldConfig & { uuid: string }) => {
359
+ return field.allowedBundles.map((bundle: string) => {
360
+ const label = types.getBlockBundleDefinition(bundle)?.label || bundle
361
+ return {
362
+ id: 'block_add_list:insert:' + field.name + ':' + bundle,
363
+ label: $t(
364
+ 'addBlockCommand.insertInField',
365
+ 'Insert "@block" into "@field"',
366
+ )
367
+ .replace('@block', label)
368
+ .replace('@field', field.label),
369
+ group: 'add',
370
+ bundle,
371
+ callback: () =>
372
+ commandCallbackInsert(
373
+ bundle,
374
+ field.name,
375
+ field.entityType,
376
+ field.uuid,
377
+ ),
378
+ }
379
+ })
380
+ },
381
+ )
376
382
 
377
383
  if (block.hostType === runtimeConfig.itemEntityType) {
378
384
  const parentBlock = dom.findBlock(block.hostUuid)
@@ -93,7 +93,7 @@ import type {
93
93
  } from '#blokkli/adapter'
94
94
  import { FormOverlay, Icon } from '#blokkli/components'
95
95
  import Loading from './../../../Loading/index.vue'
96
- import type { BlokkliFieldElement } from '#blokkli/types'
96
+ import type { BlokkliFieldElement, FieldConfig } from '#blokkli/types'
97
97
  import { ref, useBlokkli, useAsyncData, computed, watch } from '#imports'
98
98
  import LibraryListItem from './Item/index.vue'
99
99
 
@@ -115,13 +115,12 @@ const selectedItem = ref('')
115
115
  const page = ref(0)
116
116
 
117
117
  const allowedBundles = computed<string[]>(() => {
118
- return (
119
- types.getFieldConfig(
120
- props.field.hostEntityType,
121
- props.field.hostEntityBundle,
122
- props.field.name,
123
- )?.allowedBundles || []
124
- ).filter((v) => {
118
+ const fieldConfig: FieldConfig | undefined = types.getFieldConfig(
119
+ props.field.hostEntityType,
120
+ props.field.hostEntityBundle,
121
+ props.field.name,
122
+ )
123
+ return (fieldConfig?.allowedBundles || []).filter((v) => {
125
124
  return types.getBlockBundleDefinition(v)?.allowReusable
126
125
  })
127
126
  })
@@ -98,7 +98,7 @@ import {
98
98
  nextTick,
99
99
  } from '#imports'
100
100
  import { Sortli, Icon } from '#blokkli/components'
101
- import type { MediaLibraryFilter } from './../types'
101
+ import type { MediaLibraryFilter, MediaLibraryGetResults } from './../types'
102
102
  import type { BlokkliIcon } from '#blokkli/icons'
103
103
 
104
104
  const props = defineProps<{
@@ -150,15 +150,16 @@ watch(key, () => {
150
150
  page.value = 0
151
151
  })
152
152
 
153
- const { data, status } = await useLazyAsyncData(
154
- () => {
155
- return adapter.mediaLibraryGetResults!({
156
- filters: filterValues.value,
157
- page: page.value,
158
- })
159
- },
160
- { watch: [key, page] },
161
- )
153
+ const { data, status } =
154
+ await useLazyAsyncData<MediaLibraryGetResults<any> | null>(
155
+ () => {
156
+ return adapter.mediaLibraryGetResults!({
157
+ filters: filterValues.value,
158
+ page: page.value,
159
+ })
160
+ },
161
+ { watch: [key, page] },
162
+ )
162
163
 
163
164
  watch(data, () => {
164
165
  nextTick(() => {
@@ -111,7 +111,7 @@ defineDropAreas((dragItems) => {
111
111
  // Generate a drop area for every matching droppable field.
112
112
  return dom
113
113
  .getAllDroppableFields()
114
- .map<DropArea | undefined>((field) => {
114
+ .map<DropArea | undefined>((field: DroppableEntityField) => {
115
115
  const config = types.getDroppableFieldConfig(field.fieldName, field.host)
116
116
  // @TODO: This should be provided by the adapter on the item.
117
117
  if (config.allowedEntityType !== 'media') {
@@ -96,7 +96,7 @@ const doSearch = () => {
96
96
  // This component can only ever be rendered if this adapter method exists,
97
97
  // so we can safely assume it's there.
98
98
  adapter.getContentSearchResults!(props.tab, props.search).then(
99
- (newItems) => {
99
+ (newItems: SearchContentItem[]) => {
100
100
  items.value = newItems
101
101
  itemsSearchTerm.value = searchTerm
102
102
  isLoading.value = false
@@ -8,11 +8,11 @@ export type FeaturesProvider = {
8
8
  };
9
9
  export default function (): {
10
10
  features: ComputedRef<{
11
- id: "artboard" | "clipboard" | "delete" | "duplicate" | "edit" | "exit" | "grid" | "help" | "history" | "multi-select" | "preview" | "publish" | "revert" | "search" | "selection" | "options" | "add-list" | "assistant" | "block-add-list" | "command-palette" | "comments" | "conversions" | "debug" | "dragging-overlay" | "edit-form" | "editable-field" | "editable-mask" | "entity-title" | "field-areas" | "fragments" | "import-existing" | "library" | "media-library" | "ownership" | "preview-grant" | "responsive-preview" | "settings" | "structure" | "theme" | "touch-action-bar" | "tour" | "transform" | "translations" | "validations" | "demo-feature";
11
+ id: ValidFeatureKey;
12
12
  label?: string | undefined;
13
13
  icon: import("../../../playground/.nuxt/blokkli/icons").BlokkliIcon;
14
14
  description?: string | undefined;
15
- dependencies?: ("artboard" | "clipboard" | "delete" | "duplicate" | "edit" | "exit" | "grid" | "help" | "history" | "multi-select" | "preview" | "publish" | "revert" | "search" | "selection" | "options" | "add-list" | "assistant" | "block-add-list" | "command-palette" | "comments" | "conversions" | "debug" | "dragging-overlay" | "edit-form" | "editable-field" | "editable-mask" | "entity-title" | "field-areas" | "fragments" | "import-existing" | "library" | "media-library" | "ownership" | "preview-grant" | "responsive-preview" | "settings" | "structure" | "theme" | "touch-action-bar" | "tour" | "transform" | "translations" | "validations" | "demo-feature")[] | undefined;
15
+ dependencies?: ValidFeatureKey[] | undefined;
16
16
  viewports?: import("../constants").Viewport[] | undefined;
17
17
  requiredAdapterMethods?: (keyof import("../adapter").BlokkliAdapter<any>)[] | undefined;
18
18
  settings?: Record<string, import("#blokkli/types").FeatureDefinitionSetting> | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blokkli/editor",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Interactive page building experience for Nuxt",
5
5
  "repository": "blokkli/editor",
6
6
  "type": "module",