rimecms 0.26.8 → 0.27.0

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 (53) hide show
  1. package/dist/fields/group/component/Group.svelte +1 -0
  2. package/dist/fields/group/index.d.ts +12 -8
  3. package/dist/fields/group/index.js +4 -0
  4. package/dist/fields/link/component/RessourceInput.svelte +2 -2
  5. package/dist/fields/relation/component/Cell.svelte +2 -2
  6. package/dist/fields/relation/component/Relation.svelte +2 -2
  7. package/dist/fields/relation/component/upload/Browse.svelte +2 -2
  8. package/dist/fields/rich-text/client.d.ts +9 -2
  9. package/dist/fields/rich-text/core/config-builders.js +5 -2
  10. package/dist/fields/rich-text/core/features/fields/extension.d.ts +10 -3
  11. package/dist/fields/rich-text/core/features/fields/extension.js +1 -6
  12. package/dist/fields/rich-text/core/features/fields/fields.css +4 -0
  13. package/dist/fields/rich-text/core/features/fields/fields.svelte +13 -6
  14. package/dist/fields/rich-text/core/features/fields/fields.svelte.d.ts +4 -1
  15. package/dist/fields/rich-text/core/features/fields/index.d.ts +6 -4
  16. package/dist/fields/rich-text/core/features/fields/index.js +1 -2
  17. package/dist/fields/rich-text/core/features/link/component/link-selector.svelte +2 -6
  18. package/dist/fields/rich-text/core/features/resource/index.d.ts +2 -5
  19. package/dist/fields/rich-text/core/features/resource/index.js +0 -1
  20. package/dist/fields/rich-text/core/features/resource/resource-extension.d.ts +7 -2
  21. package/dist/fields/rich-text/core/features/resource/resource-extension.js +1 -7
  22. package/dist/fields/rich-text/core/features/resource/resource.svelte +2 -2
  23. package/dist/fields/rich-text/core/features/upload/index.js +1 -2
  24. package/dist/fields/rich-text/core/features/upload/upload-extension.d.ts +14 -1
  25. package/dist/fields/rich-text/core/features/upload/upload-extension.js +2 -10
  26. package/dist/fields/rich-text/core/features/upload/upload.svelte +2 -2
  27. package/dist/fields/rich-text/core/svelte/node-view-renderer.svelte.js +10 -5
  28. package/dist/fields/rich-text/core/svelte/node-view-wrapper.svelte +1 -0
  29. package/dist/fields/rich-text/core/svelte/renderer.d.ts +1 -1
  30. package/dist/fields/types.d.ts +10 -0
  31. package/dist/panel/components/Root.svelte +2 -2
  32. package/dist/panel/components/fields/FieldsPreview.svelte +34 -27
  33. package/dist/panel/components/fields/FieldsPreview.svelte.d.ts +5 -6
  34. package/dist/panel/components/sections/collection/folder/FolderEdit.svelte +0 -2
  35. package/dist/panel/components/sections/collection/folder/FolderWithActions.svelte +2 -2
  36. package/dist/panel/components/sections/collection/grid/create-directory-dialog/CreateDirectoryDialog.svelte +0 -2
  37. package/dist/panel/components/sections/document/Header.svelte +1 -0
  38. package/dist/panel/components/sections/document/Settings.svelte +3 -2
  39. package/dist/panel/components/sections/document/Settings.svelte.d.ts +2 -1
  40. package/dist/panel/components/sections/live/SidePanel.svelte +5 -7
  41. package/dist/panel/context/api-proxy.svelte.d.ts +0 -1
  42. package/dist/panel/context/api-proxy.svelte.js +0 -2
  43. package/dist/panel/context/documentForm.svelte.d.ts +2 -2
  44. package/dist/panel/context/documentForm.svelte.js +2 -2
  45. package/dist/panel/context/form.svelte.js +0 -1
  46. package/dist/panel/context/locale.svelte.d.ts +1 -0
  47. package/dist/panel/context/locale.svelte.js +3 -3
  48. package/dist/panel/pages/area/Area.svelte +1 -4
  49. package/dist/panel/pages/area/AreaVersionsDoc.svelte +0 -3
  50. package/dist/panel/pages/collection-document/CollectionDocVersions.svelte +0 -5
  51. package/dist/panel/pages/collection-document/CollectionDocument.svelte +0 -3
  52. package/dist/panel/pages/live/Live.svelte +3 -8
  53. package/package.json +233 -233
@@ -79,6 +79,7 @@
79
79
  {#if !groupOpen}
80
80
  <FieldsPreviewTrigger onclick={handleClick}>
81
81
  <FieldsPreview
82
+ preview={config.preview}
82
83
  fields={previewFields}
83
84
  getField={(field) => form.useField(basePath + field.name)}
84
85
  />
@@ -1,10 +1,11 @@
1
1
  import type { FieldBuilder } from '../../core/fields/builders/field-builder.js';
2
2
  import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
3
- import type { Field, FormField } from '../types.js';
3
+ import type { Field, FieldsPreviewProps, FormField } from '../types.js';
4
+ import type { Component } from 'svelte';
4
5
  export declare class GroupFieldBuilder extends FormFieldBuilder<GroupField> {
5
6
  _metaUrl: string;
6
7
  constructor(name: string);
7
- get component(): import("svelte").Component<{
8
+ get component(): Component<{
8
9
  path: string;
9
10
  config: GroupField;
10
11
  form: import("../../panel").DocumentFormContext<import("../../types").GenericDoc>;
@@ -12,6 +13,7 @@ export declare class GroupFieldBuilder extends FormFieldBuilder<GroupField> {
12
13
  label(label: string): this;
13
14
  fields(...fields: FieldBuilder<Field>[]): this;
14
15
  localized(): this;
16
+ preview(component: Component<FieldsPreviewProps>): this;
15
17
  compile(): {
16
18
  fields: ({
17
19
  type: string;
@@ -19,16 +21,16 @@ export declare class GroupFieldBuilder extends FormFieldBuilder<GroupField> {
19
21
  condition?: ((doc: any, siblings: any) => boolean) | undefined;
20
22
  width?: import("../types.js").FieldWidth | undefined;
21
23
  className?: string | undefined;
22
- component: import("svelte").Component<any>;
23
- cell: import("svelte").Component<any> | undefined;
24
+ component: Component<any>;
25
+ cell: Component<any> | undefined;
24
26
  access: {
25
27
  create: import("../types.js").FieldAccess;
26
28
  read: import("../types.js").FieldAccess;
27
29
  update: import("../types.js").FieldAccess;
28
30
  };
29
31
  } & {
30
- component: import("svelte").Component<any>;
31
- cell?: import("svelte").Component<{
32
+ component: Component<any>;
33
+ cell?: Component<{
32
34
  value: any;
33
35
  }> | null;
34
36
  })[];
@@ -37,8 +39,8 @@ export declare class GroupFieldBuilder extends FormFieldBuilder<GroupField> {
37
39
  condition?: (doc: any, siblings: any) => boolean;
38
40
  width?: import("../types.js").FieldWidth;
39
41
  className?: string;
40
- component: import("svelte").Component<any>;
41
- cell: import("svelte").Component<any> | undefined;
42
+ component: Component<any>;
43
+ cell: Component<any> | undefined;
42
44
  access: {
43
45
  create: import("../types.js").FieldAccess;
44
46
  read: import("../types.js").FieldAccess;
@@ -60,6 +62,7 @@ export declare class GroupFieldBuilder extends FormFieldBuilder<GroupField> {
60
62
  };
61
63
  defaultValue?: import("../types.js").DefaultValueFn<any> | unknown;
62
64
  isEmpty: (value: unknown) => boolean;
65
+ preview?: Component<FieldsPreviewProps>;
63
66
  };
64
67
  }
65
68
  export declare const group: (name: string) => GroupFieldBuilder;
@@ -77,6 +80,7 @@ export type GroupField = FormField & {
77
80
  name: string;
78
81
  label?: string;
79
82
  fields: FieldBuilder<Field>[];
83
+ preview?: Component<FieldsPreviewProps>;
80
84
  };
81
85
  export type GroupFieldRaw = FormField & {
82
86
  type: 'group';
@@ -34,6 +34,10 @@ export class GroupFieldBuilder extends FormFieldBuilder {
34
34
  });
35
35
  return this;
36
36
  }
37
+ preview(component) {
38
+ this.field.preview = component;
39
+ return this;
40
+ }
37
41
  compile() {
38
42
  return { ...this.field, fields: this.field.fields.map((f) => f.compile()) };
39
43
  }
@@ -4,7 +4,7 @@
4
4
  import type { GenericDoc } from '../../../core/types/doc.js';
5
5
  import * as Command from '../../../panel/components/ui/command/index.js';
6
6
  import Tag from '../../../panel/components/ui/tag/tag.svelte';
7
- import { API_PROXY, getAPIProxyContext } from '../../../panel/context/api-proxy.svelte.js';
7
+ import { getAPIProxyContext } from '../../../panel/context/api-proxy.svelte.js';
8
8
  import type { PrototypeSlug } from '../../../types';
9
9
  import { toKebabCase } from '../../../util/string';
10
10
 
@@ -28,7 +28,7 @@
28
28
  let resources = $state<Ressource[]>([]);
29
29
  let selected = $state<Ressource | null>();
30
30
 
31
- const APIProxy = getAPIProxyContext(API_PROXY.DOCUMENT);
31
+ const APIProxy = getAPIProxyContext();
32
32
  let resource = $state<any>(null);
33
33
 
34
34
  function convertDocToResource(doc: GenericDoc) {
@@ -3,7 +3,7 @@
3
3
  import { apiUrl } from '../../../core/api/index.js';
4
4
  import type { GenericDoc } from '../../../core/types/doc.js';
5
5
  import UploadThumbCell from '../../../panel/components/sections/collection/upload-thumb-cell/UploadThumbCell.svelte';
6
- import { API_PROXY, getAPIProxyContext } from '../../../panel/context/api-proxy.svelte.js';
6
+ import { getAPIProxyContext } from '../../../panel/context/api-proxy.svelte.js';
7
7
  import { toKebabCase } from '../../../util/string';
8
8
 
9
9
  type Props = {
@@ -17,7 +17,7 @@
17
17
  let { value }: Props = $props();
18
18
  let displayCount = $derived(value && value.length > 1);
19
19
 
20
- const APIProxy = getAPIProxyContext(API_PROXY.ROOT);
20
+ const APIProxy = getAPIProxyContext();
21
21
 
22
22
  let APIUrl = $derived.by(() => {
23
23
  if (value && value.length && value[0].documentId) {
@@ -11,7 +11,7 @@
11
11
  import { panelUrl } from '../../../panel/util/url.js';
12
12
  import { moveItem } from '../../../util/array.js';
13
13
  import { snapshot } from '../../../util/state.js';
14
- import { API_PROXY, getAPIProxyContext } from '../../../panel/context/api-proxy.svelte.js';
14
+ import { getAPIProxyContext } from '../../../panel/context/api-proxy.svelte.js';
15
15
  import type { Relation, RelationField } from '../index.js';
16
16
  import Default from './default/Default.svelte';
17
17
  import type { RelationFieldItem } from './types.js';
@@ -24,7 +24,7 @@
24
24
  // Context
25
25
  const { getCollection } = getConfigContext();
26
26
  const locale = getLocaleContext();
27
- const APIProxy = getAPIProxyContext(API_PROXY.DOCUMENT);
27
+ const APIProxy = getAPIProxyContext();
28
28
  const field = $derived(form.useField(path, config));
29
29
  // svelte-ignore state_referenced_locally
30
30
  const relationConfig = getCollection(config.relationTo);
@@ -10,7 +10,7 @@
10
10
  import * as Dialog from '../../../../panel/components/ui/dialog/index.js';
11
11
  import * as DropdownMenu from '../../../../panel/components/ui/dropdown-menu/index.js';
12
12
  import Input from '../../../../panel/components/ui/input/input.svelte';
13
- import { API_PROXY, getAPIProxyContext } from '../../../../panel/context/api-proxy.svelte.js';
13
+ import { getAPIProxyContext } from '../../../../panel/context/api-proxy.svelte.js';
14
14
  import type { BuiltCollection, UploadDoc } from '../../../../types';
15
15
  import { ListFilter, Search } from '@lucide/svelte';
16
16
 
@@ -62,7 +62,7 @@
62
62
  return `${apiUrl(withDirectoriesSuffix(config.kebab))}?where[parent][equals]=${path}`;
63
63
  });
64
64
 
65
- const APIProxy = getAPIProxyContext(API_PROXY.DOCUMENT);
65
+ const APIProxy = getAPIProxyContext();
66
66
  let files = $derived(APIProxy.getRessource<{ docs: UploadDoc[] }>(filesURL));
67
67
  let folders = $derived(APIProxy.getRessource<{ docs: Directory[] }>(foldersURL));
68
68
 
@@ -1,5 +1,7 @@
1
+ import type { FieldBuilder } from '../../core/fields/builders/index.js';
1
2
  import type { Level } from '@tiptap/extension-heading';
2
- import { FieldsFeature } from './core/features/fields/index.js';
3
+ import type { Component } from 'svelte';
4
+ import type { FieldsPreviewProps } from '../types.js';
3
5
  import { LinkFeature } from './core/features/link/index.js';
4
6
  import { ResourceFeature } from './core/features/resource/index.js';
5
7
  import type { RichTextResource } from './core/features/resource/types.js';
@@ -9,7 +11,12 @@ import SvelteNodeViewRenderer from './core/svelte/node-view-renderer.svelte';
9
11
  import NodeViewWrapper from './core/svelte/node-view-wrapper.svelte';
10
12
  import type { RichTextNodeRenderer, RichTextNodeRendererProps } from './core/types.js';
11
13
  import { richTextJSONToText } from './index.js';
12
- export declare const fields: (args: Parameters<typeof FieldsFeature>[0]) => import("./core/types.js").RichTextFeature;
14
+ export declare const fields: (args: {
15
+ name: string;
16
+ label: string;
17
+ fields: FieldBuilder[];
18
+ preview: Component<FieldsPreviewProps>;
19
+ }) => import("./core/types.js").RichTextFeature;
13
20
  export declare const bold: () => import("./core/types.js").RichTextFeature;
14
21
  export declare const bulletList: () => import("./core/types.js").RichTextFeature;
15
22
  export declare const heading: (...levels: Level[]) => import("./core/types.js").RichTextFeature;
@@ -7,6 +7,7 @@ import Typography from '@tiptap/extension-typography';
7
7
  import { Dropcursor, Gapcursor, Placeholder, UndoRedo } from '@tiptap/extensions';
8
8
  import { API_PROXY, getAPIProxyContext } from '../../../panel/context/api-proxy.svelte.js';
9
9
  import { CONFIG_CTX, getConfigContext } from '../../../panel/context/config.svelte.js';
10
+ import { getLocaleContext, LOCALE_CTX } from '../../../panel/context/locale.svelte.js';
10
11
  import { getUserContext, USER_CTX } from '../../../panel/context/user.svelte.js';
11
12
  import { hasSuggestion } from '../util.js';
12
13
  import { CurrentNodeAttribute } from './extensions/current-node/current-node.js';
@@ -60,12 +61,14 @@ export function buildEditorConfig(args) {
60
61
  if ('addNodeView' in feature.extension.config) {
61
62
  const originalAddOption = feature.extension.config.addOptions || (() => ({}));
62
63
  const contexts = new Map();
64
+ const localeContext = getLocaleContext();
63
65
  const configContext = getConfigContext();
64
- const apiProxyContext = getAPIProxyContext(API_PROXY.DOCUMENT);
66
+ const apiProxyContext = getAPIProxyContext();
65
67
  const userContext = getUserContext();
66
68
  contexts.set(CONFIG_CTX, configContext);
67
- contexts.set(API_PROXY.DOCUMENT, apiProxyContext);
69
+ contexts.set(API_PROXY.ROOT, apiProxyContext);
68
70
  contexts.set(USER_CTX, userContext);
71
+ contexts.set(LOCALE_CTX, localeContext);
69
72
  feature.extension.config.addOptions = () => {
70
73
  // @ts-expect-error
71
74
  return { ...originalAddOption(), contexts };
@@ -1,10 +1,17 @@
1
+ import type { FieldBuilder } from '../../../../../core/fields/builders';
2
+ import type { FieldsPreviewProps } from '../../../../types';
1
3
  import type { Dic } from '../../../../../util/types.js';
2
4
  import { Node } from '@tiptap/core';
5
+ import type { Component } from 'svelte';
3
6
  declare module '@tiptap/core' {
4
7
  interface Commands<ReturnType> {
5
- sheet: {
6
- insertSheet: (attributes: Dic) => ReturnType;
8
+ 'richt-text-fields': {
9
+ insertSheet: (attributes?: Dic) => ReturnType;
7
10
  };
8
11
  }
9
12
  }
10
- export declare const FieldsExtension: Node<any, any>;
13
+ export interface FieldsFeatureExtensionOptions {
14
+ fields: FieldBuilder[];
15
+ preview?: Component<FieldsPreviewProps>;
16
+ }
17
+ export declare const FieldsExtension: Node<FieldsFeatureExtensionOptions, any>;
@@ -5,13 +5,8 @@ export const FieldsExtension = Node.create({
5
5
  name: 'richt-text-fields',
6
6
  group: 'block',
7
7
  atom: true,
8
- draggable: true, // Optional: to make the node draggable
8
+ draggable: true,
9
9
  inline: false,
10
- addOptions() {
11
- return {
12
- fields: null
13
- };
14
- },
15
10
  addAttributes() {
16
11
  return ['json'].reduce((acc, key) => {
17
12
  acc[key] = { default: null };
@@ -25,4 +25,8 @@
25
25
  .rz-render-fields-preview__row:last-child .rz-render-fields-preview__name {
26
26
  border-bottom-left-radius: var(--rz-radius-lg);
27
27
  }
28
+
29
+ &.rz-rich-text-fields-preview--custom {
30
+ max-width: unset;
31
+ }
28
32
  }
@@ -1,13 +1,12 @@
1
1
  <script lang="ts">
2
- import { page } from '$app/state';
3
2
  import { FieldBuilder, FormFieldBuilder } from '../../../../../core/fields/builders';
3
+ import type { FieldsPreviewProps } from '../../../../types';
4
4
  import FieldsPreview from '../../../../../panel/components/fields/FieldsPreview.svelte';
5
5
  import FieldsPreviewTrigger from '../../../../../panel/components/fields/FieldsPreviewTrigger.svelte';
6
6
  import * as Sheet from '../../../../../panel/components/ui/sheet/index.js';
7
7
  import { setFormContext } from '../../../../../panel/context/form.svelte';
8
- import { setLocaleContext } from '../../../../../panel/context/locale.svelte';
9
8
  import type { NodeViewProps } from '@tiptap/core';
10
- import { onMount } from 'svelte';
9
+ import { onMount, type Component } from 'svelte';
11
10
  import NodeViewWrapper from '../../svelte/node-view-wrapper.svelte';
12
11
  import './fields.css';
13
12
 
@@ -15,6 +14,7 @@
15
14
  extension: {
16
15
  options: {
17
16
  fields: FieldBuilder[];
17
+ preview?: Component<FieldsPreviewProps>;
18
18
  };
19
19
  };
20
20
  };
@@ -22,7 +22,6 @@
22
22
  let { node, extension, updateAttributes }: Props = $props();
23
23
  let isSheetOpen = $state(false);
24
24
 
25
- setLocaleContext(page.data.locale || 'en');
26
25
  // svelte-ignore state_referenced_locally
27
26
  const form = setFormContext(node.attrs.json || {}, 'fields');
28
27
 
@@ -43,19 +42,27 @@
43
42
  const previewFields = $derived.by(() => {
44
43
  return extension.options.fields.filter((field) => field instanceof FormFieldBuilder);
45
44
  });
45
+
46
+ const classModifiers = $derived(
47
+ extension.options.preview ? 'rz-rich-text-fields-preview--custom' : ''
48
+ );
46
49
  </script>
47
50
 
48
51
  <NodeViewWrapper>
49
- <FieldsPreviewTrigger class="rz-rich-text-fields-preview" onclick={() => (isSheetOpen = true)}>
52
+ <FieldsPreviewTrigger
53
+ class="rz-rich-text-fields-preview {classModifiers}"
54
+ onclick={() => (isSheetOpen = true)}
55
+ >
50
56
  <FieldsPreview
51
57
  fields={previewFields}
52
58
  getField={(field) => form.useField(field.name, field.raw)}
59
+ preview={extension.options.preview}
53
60
  />
54
61
  </FieldsPreviewTrigger>
55
62
  </NodeViewWrapper>
56
63
 
57
64
  <Sheet.Root bind:open={isSheetOpen}>
58
- <Sheet.Content side="right" class="rz-rich-text-sheet">
65
+ <Sheet.Content preventScroll={false} side="right" class="rz-rich-text-sheet">
59
66
  {#each previewFields || [] as field, index (index)}
60
67
  {@const FieldComponent = field.component}
61
68
  <FieldComponent path={field.raw.name} config={field.raw} {form} />
@@ -1,13 +1,16 @@
1
1
  import { FieldBuilder } from '../../../../../core/fields/builders';
2
+ import type { FieldsPreviewProps } from '../../../../types';
2
3
  import type { NodeViewProps } from '@tiptap/core';
4
+ import { type Component } from 'svelte';
3
5
  import './fields.css';
4
6
  type Props = Omit<NodeViewProps, 'extension'> & {
5
7
  extension: {
6
8
  options: {
7
9
  fields: FieldBuilder[];
10
+ preview?: Component<FieldsPreviewProps>;
8
11
  };
9
12
  };
10
13
  };
11
- declare const Fields: import("svelte").Component<Props, {}, "">;
14
+ declare const Fields: Component<Props, {}, "">;
12
15
  type Fields = ReturnType<typeof Fields>;
13
16
  export default Fields;
@@ -1,9 +1,11 @@
1
1
  import type { FieldBuilder } from '../../../../../core/fields/builders/field-builder.js';
2
+ import type { FieldsPreviewProps } from '../../../../types.js';
3
+ import type { Component } from 'svelte';
2
4
  import type { RichTextFeature } from '../../../../../types.js';
3
- type Args = {
5
+ export interface FieldsFeatureOptions {
4
6
  name: string;
5
7
  label: string;
6
8
  fields: FieldBuilder[];
7
- };
8
- export declare const FieldsFeature: (args: Args) => RichTextFeature;
9
- export {};
9
+ preview?: Component<FieldsPreviewProps>;
10
+ }
11
+ export declare const FieldsFeature: (args: FieldsFeatureOptions) => RichTextFeature;
@@ -5,11 +5,10 @@ const fieldsFeatureNode = (args) => ({
5
5
  icon: SheetIcon,
6
6
  isActive: ({ editor }) => editor.isActive('richt-text-fields'),
7
7
  suggestion: {
8
- //@ts-expect-error annoying
9
8
  command: ({ editor }) => editor.chain().focus().insertSheet().run()
10
9
  }
11
10
  });
12
11
  export const FieldsFeature = (args) => ({
13
- extension: FieldsExtension.configure(args),
12
+ extension: FieldsExtension.configure({ fields: args.fields, preview: args.preview }),
14
13
  nodes: [fieldsFeatureNode(args)]
15
14
  });
@@ -6,11 +6,7 @@
6
6
  import Button from '../../../../../../panel/components/ui/button/button.svelte';
7
7
  import * as Command from '../../../../../../panel/components/ui/command/index.js';
8
8
  import Input from '../../../../../../panel/components/ui/input/input.svelte';
9
- import {
10
- API_PROXY,
11
- getAPIProxyContext,
12
- type Resource
13
- } from '../../../../../../panel/context/api-proxy.svelte.js';
9
+ import { getAPIProxyContext, type Resource } from '../../../../../../panel/context/api-proxy.svelte.js';
14
10
  import { getLocaleContext } from '../../../../../../panel/context/locale.svelte';
15
11
  import validate from '../../../../../../util/validate.js';
16
12
  import { CornerDownLeft, ExternalLink, Link2, Newspaper, Trash } from '@lucide/svelte';
@@ -40,7 +36,7 @@
40
36
  /**
41
37
  * Logic to get internal resources e.g., collections, areas
42
38
  */
43
- const APIProxy = getAPIProxyContext(API_PROXY.DOCUMENT);
39
+ const APIProxy = getAPIProxyContext();
44
40
  const locale = getLocaleContext();
45
41
  let resources = $state<Resource<LinkResource[]>[]>([]);
46
42
  let resourcesFlatMap = $state<LinkResource[]>();
@@ -1,6 +1,3 @@
1
- import type { PrototypeSlug } from '../../../../../types.js';
2
1
  import type { RichTextFeature } from '../../types.js';
3
- export declare const ResourceFeature: (args: {
4
- query?: string;
5
- slug: PrototypeSlug;
6
- }) => RichTextFeature;
2
+ import { type ResourceFeatureExtensionOptions } from './resource-extension.js';
3
+ export declare const ResourceFeature: (args: ResourceFeatureExtensionOptions) => RichTextFeature;
@@ -5,7 +5,6 @@ const resourceFeatureNode = {
5
5
  icon: Images,
6
6
  isActive: ({ editor }) => editor.isActive('richt-text-resource'),
7
7
  suggestion: {
8
- //@ts-expect-error annoying
9
8
  command: ({ editor }) => editor.chain().focus().insertResource().run()
10
9
  }
11
10
  };
@@ -1,10 +1,15 @@
1
+ import type { PrototypeSlug } from '../../../../../core/types/doc';
1
2
  import type { Dic } from '../../../../../util/types.js';
2
3
  import { Node } from '@tiptap/core';
3
4
  declare module '@tiptap/core' {
4
5
  interface Commands<ReturnType> {
5
6
  resource: {
6
- insertResource: (attributes: Dic) => ReturnType;
7
+ insertResource: (attributes?: Dic) => ReturnType;
7
8
  };
8
9
  }
9
10
  }
10
- export declare const Resource: Node<any, any>;
11
+ export interface ResourceFeatureExtensionOptions {
12
+ query?: string;
13
+ slug: PrototypeSlug;
14
+ }
15
+ export declare const Resource: Node<ResourceFeatureExtensionOptions, any>;
@@ -5,14 +5,8 @@ export const Resource = Node.create({
5
5
  name: 'resource',
6
6
  group: 'block',
7
7
  atom: true,
8
- draggable: true, // Optional: to make the node draggable
8
+ draggable: true,
9
9
  inline: false,
10
- addOptions() {
11
- return {
12
- query: null,
13
- _type: null
14
- };
15
- },
16
10
  addAttributes() {
17
11
  return ['id', 'title', '_type', '_thumbnail'].reduce((acc, key) => {
18
12
  acc[key] = { default: null };
@@ -4,7 +4,7 @@
4
4
  import Button from '../../../../../panel/components/ui/button/button.svelte';
5
5
  import CardResource from '../../../../../panel/components/ui/card-resource/card-resource.svelte';
6
6
  import * as Command from '../../../../../panel/components/ui/command/index.js';
7
- import { API_PROXY, getAPIProxyContext } from '../../../../../panel/context/api-proxy.svelte.js';
7
+ import { getAPIProxyContext } from '../../../../../panel/context/api-proxy.svelte.js';
8
8
  import type { NodeViewProps } from '@tiptap/core';
9
9
  import { onMount } from 'svelte';
10
10
  import NodeViewWrapper from '../../svelte/node-view-wrapper.svelte';
@@ -37,7 +37,7 @@
37
37
  }
38
38
  });
39
39
 
40
- const APIProxy = getAPIProxyContext(API_PROXY.DOCUMENT);
40
+ const APIProxy = getAPIProxyContext();
41
41
 
42
42
  // svelte-ignore state_referenced_locally
43
43
  const url = extension.options.query
@@ -5,8 +5,7 @@ const uploadFeatureNode = {
5
5
  icon: Images,
6
6
  isActive: ({ editor }) => editor.isActive('richt-text-media'),
7
7
  suggestion: {
8
- //@ts-expect-error insertMedia is defined by the extension
9
- command: ({ editor }) => editor.chain().focus().insertMedia().run()
8
+ command: ({ editor }) => editor.chain().focus().insertUpload().run()
10
9
  }
11
10
  };
12
11
  export const UploadFeature = (args) => ({
@@ -1,2 +1,15 @@
1
+ import type { CollectionSlug } from '../../../../../types';
2
+ import type { Dic } from '../../../../../util/types.js';
1
3
  import { Node } from '@tiptap/core';
2
- export declare const Upload: Node<any, any>;
4
+ export interface UploadFeatureExtensionOptions {
5
+ query?: string;
6
+ slug: CollectionSlug;
7
+ }
8
+ declare module '@tiptap/core' {
9
+ interface Commands<ReturnType> {
10
+ upload: {
11
+ insertUpload: (attributes?: Dic) => ReturnType;
12
+ };
13
+ }
14
+ }
15
+ export declare const Upload: Node<UploadFeatureExtensionOptions, any>;
@@ -5,25 +5,17 @@ export const Upload = Node.create({
5
5
  name: 'upload',
6
6
  group: 'block',
7
7
  atom: true,
8
- draggable: true, // Optional: to make the node draggable
8
+ draggable: true,
9
9
  inline: false,
10
- addOptions() {
11
- return {
12
- query: null
13
- };
14
- },
15
10
  addAttributes() {
16
11
  return ['id', 'title', 'sizes', 'mimeType', 'url', 'filename', 'legend'].reduce((acc, key) => {
17
12
  acc[key] = { default: null };
18
13
  return acc;
19
14
  }, {});
20
15
  },
21
- //@ts-expect-error annoying
22
16
  addCommands() {
23
17
  return {
24
- insertMedia: (attributes = {}) =>
25
- //@ts-expect-error annoying
26
- ({ commands }) => {
18
+ insertUpload: (attributes = {}) => ({ commands }) => {
27
19
  return commands.insertContent({
28
20
  type: this.name,
29
21
  attrs: attributes
@@ -6,7 +6,7 @@
6
6
  import * as Command from '../../../../../panel/components/ui/command/index.js';
7
7
  import * as Dialog from '../../../../../panel/components/ui/dialog/index.js';
8
8
  import Input from '../../../../../panel/components/ui/input/input.svelte';
9
- import { API_PROXY, getAPIProxyContext } from '../../../../../panel/context/api-proxy.svelte.js';
9
+ import { getAPIProxyContext } from '../../../../../panel/context/api-proxy.svelte.js';
10
10
  import { X } from '@lucide/svelte';
11
11
  import type { NodeViewProps } from '@tiptap/core';
12
12
  import { onMount } from 'svelte';
@@ -54,7 +54,7 @@
54
54
  }
55
55
  });
56
56
 
57
- const APIProxy = getAPIProxyContext(API_PROXY.DOCUMENT);
57
+ const APIProxy = getAPIProxyContext();
58
58
 
59
59
  // svelte-ignore state_referenced_locally
60
60
  const url = extension.options.query
@@ -55,11 +55,16 @@ class SvelteNodeView extends NodeView {
55
55
  // Focus the editor
56
56
  this.editor.view.focus();
57
57
  });
58
- const svelteComponent = mount(Component, { target, props, context });
59
- this.renderer = new SvelteRenderer(svelteComponent, {
60
- element: target,
61
- props
62
- });
58
+ try {
59
+ this.renderer = new SvelteRenderer(mount(Component, { target, props, context }), {
60
+ element: target,
61
+ props
62
+ });
63
+ }
64
+ catch (e) {
65
+ console.error('Error mounting Svelte component in NodeView', e);
66
+ throw e;
67
+ }
63
68
  this.appendContendDom();
64
69
  this.updateElementAttributes();
65
70
  }
@@ -1,3 +1,4 @@
1
+ <!-- based on https://github.com/sibiraj-s/svelte-tiptap/blob/master/src/lib/NodeViewWrapper.svelte -->
1
2
  <script lang="ts" generics="T extends keyof SvelteHTMLElements = 'div'">
2
3
  import { getContext, onMount, tick } from 'svelte';
3
4
  import type { SvelteHTMLElements } from 'svelte/elements';
@@ -1,5 +1,5 @@
1
- import { mount } from 'svelte';
2
1
  import type { NodeViewProps } from '@tiptap/core';
2
+ import { mount } from 'svelte';
3
3
  interface RendererOptions {
4
4
  element: HTMLElement;
5
5
  props: NodeViewProps;
@@ -110,3 +110,13 @@ export type RelationValue<T> = T[] | {
110
110
  documentId: string;
111
111
  }[] | string[] | string;
112
112
  export type SimplerField<T extends FormField> = WithRequired<Partial<T>, 'name' | 'isEmpty' | 'type'>;
113
+ export type BaseUseFieldReturn = {
114
+ path: string;
115
+ value: any;
116
+ readonly editable: boolean;
117
+ readonly visible: boolean;
118
+ readonly error: string | false;
119
+ };
120
+ export type FieldsPreviewProps = {
121
+ fields: Record<string, BaseUseFieldReturn>;
122
+ };
@@ -10,7 +10,7 @@
10
10
  import { setUserContext } from '../context/user.svelte.js';
11
11
  import type { Route } from '../types.js';
12
12
  import { onMount, type Snippet } from 'svelte';
13
- import { API_PROXY, setAPIProxyContext } from '../context/api-proxy.svelte.js';
13
+ import { setAPIProxyContext } from '../context/api-proxy.svelte.js';
14
14
 
15
15
  type Props = {
16
16
  routes: Record<string, Route[]>;
@@ -29,7 +29,7 @@
29
29
  // svelte-ignore state_referenced_locally
30
30
  setUserContext(user);
31
31
  createContext('title', '[untitled]');
32
- setAPIProxyContext(API_PROXY.ROOT);
32
+ setAPIProxyContext();
33
33
 
34
34
  const locale = $derived(setLocaleContext(initialeLocale));
35
35