rimecms 0.26.9 → 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 +2 -2
@@ -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
 
@@ -1,42 +1,49 @@
1
1
  <script lang="ts">
2
2
  import { FormFieldBuilder } from '../../../core/fields/builders';
3
- import type { FormField } from '../../../fields/types.js';
3
+ import type { BaseUseFieldReturn, FieldsPreviewProps, FormField } from '../../../fields/types.js';
4
4
  import { capitalize } from '../../../util/string.js';
5
+ import type { Component } from 'svelte';
5
6
 
6
7
  type Props = {
7
8
  fields: FormFieldBuilder<FormField>[];
8
- getField: (field: FormFieldBuilder<FormField>) => { visible: boolean; value: any | null };
9
+ getField: (field: FormFieldBuilder<FormField>) => BaseUseFieldReturn;
10
+ preview?: Component<FieldsPreviewProps>;
9
11
  };
10
12
 
11
- const { fields, getField }: Props = $props();
12
-
13
- //
13
+ const { fields, getField, preview }: Props = $props();
14
14
  </script>
15
15
 
16
16
  <div class="rz-render-fields-preview">
17
- {#each fields as builder, index (index)}
18
- {@const field = getField(builder)}
19
- {#if !builder.raw.hidden && field.visible}
20
- <div class="rz-render-fields-preview__row" data-visible={field.visible || null}>
21
- <div class="rz-render-fields-preview__name">
22
- <p>
23
- {builder.raw.label || capitalize(builder.name)}
24
- </p>
25
- </div>
26
- <div class="rz-render-fields-preview__value">
27
- {#if builder.raw.table?.cell}
28
- {@const ColumnTableCell = builder.raw.table.cell}
29
- <span><ColumnTableCell value={field.value} /></span>
30
- {:else if builder.cell}
31
- {@const Cell = builder.cell}
32
- <span><Cell value={field.value} /></span>
33
- {:else}
34
- <span>{field.value}</span>
35
- {/if}
17
+ {#if preview}
18
+ {@const Preview = preview}
19
+ <div class="rz-render-fields-preview__custom" data-visible>
20
+ <Preview fields={Object.fromEntries(fields.map((field) => [field.name, getField(field)]))} />
21
+ </div>
22
+ {:else}
23
+ {#each fields as builder, index (index)}
24
+ {@const field = getField(builder)}
25
+ {#if !builder.raw.hidden && field.visible}
26
+ <div class="rz-render-fields-preview__row" data-visible={field.visible || null}>
27
+ <div class="rz-render-fields-preview__name">
28
+ <p>
29
+ {builder.raw.label || capitalize(builder.name)}
30
+ </p>
31
+ </div>
32
+ <div class="rz-render-fields-preview__value">
33
+ {#if builder.raw.table?.cell}
34
+ {@const ColumnTableCell = builder.raw.table.cell}
35
+ <span><ColumnTableCell value={field.value} /></span>
36
+ {:else if builder.cell}
37
+ {@const Cell = builder.cell}
38
+ <span><Cell value={field.value} /></span>
39
+ {:else}
40
+ <span>{field.value}</span>
41
+ {/if}
42
+ </div>
36
43
  </div>
37
- </div>
38
- {/if}
39
- {/each}
44
+ {/if}
45
+ {/each}
46
+ {/if}
40
47
  </div>
41
48
 
42
49
  <style>
@@ -1,12 +1,11 @@
1
1
  import { FormFieldBuilder } from '../../../core/fields/builders';
2
- import type { FormField } from '../../../fields/types.js';
2
+ import type { BaseUseFieldReturn, FieldsPreviewProps, FormField } from '../../../fields/types.js';
3
+ import type { Component } from 'svelte';
3
4
  type Props = {
4
5
  fields: FormFieldBuilder<FormField>[];
5
- getField: (field: FormFieldBuilder<FormField>) => {
6
- visible: boolean;
7
- value: any | null;
8
- };
6
+ getField: (field: FormFieldBuilder<FormField>) => BaseUseFieldReturn;
7
+ preview?: Component<FieldsPreviewProps>;
9
8
  };
10
- declare const FieldsPreview: import("svelte").Component<Props, {}, "">;
9
+ declare const FieldsPreview: Component<Props, {}, "">;
11
10
  type FieldsPreview = ReturnType<typeof FieldsPreview>;
12
11
  export default FieldsPreview;
@@ -6,7 +6,6 @@
6
6
  import RenderFields from '../../../fields/RenderFields.svelte';
7
7
  import Button from '../../../ui/button/button.svelte';
8
8
  import * as Dialog from '../../../ui/dialog/index.js';
9
- import { API_PROXY, setAPIProxyContext } from '../../../../context/api-proxy.svelte.js';
10
9
  import { getConfigContext } from '../../../../context/config.svelte.js';
11
10
  import { setDocumentFormContext } from '../../../../context/documentForm.svelte.js';
12
11
  import { getUserContext } from '../../../../context/user.svelte.js';
@@ -18,7 +17,6 @@
18
17
  };
19
18
  let { folder, collection, open = $bindable() }: Props = $props();
20
19
 
21
- setAPIProxyContext(API_PROXY.DOCUMENT);
22
20
  let formElement = $state<HTMLFormElement>();
23
21
  const user = getUserContext();
24
22
  const configCtx = getConfigContext();
@@ -10,7 +10,7 @@
10
10
  import ContextMenu from '../../../ui/context-menu/ContextMenu.svelte';
11
11
  import ContextMenuItem from '../../../ui/context-menu/ContextMenuItem.svelte';
12
12
  import * as Dialog from '../../../ui/dialog/index.js';
13
- import { API_PROXY, getAPIProxyContext } from '../../../../context/api-proxy.svelte.js';
13
+ import { getAPIProxyContext } from '../../../../context/api-proxy.svelte.js';
14
14
  import { panelUrl } from '../../../../util/url.js';
15
15
  import { trycatchFetch } from '../../../../../util/function.js';
16
16
  import { Pencil, Trash2 } from '@lucide/svelte';
@@ -42,7 +42,7 @@
42
42
  let rootElement = $state<HTMLButtonElement>();
43
43
  let isDragging = $state(false);
44
44
  const isFolderUpperPath = $derived(folder.name === '...');
45
- const APIProxy = getAPIProxyContext(API_PROXY.ROOT);
45
+ const APIProxy = getAPIProxyContext();
46
46
  const childFilesURL = $derived(
47
47
  `${apiUrl(collection.kebab)}?where[_path][equals]=${folder.id}&select=id`
48
48
  );
@@ -5,7 +5,6 @@
5
5
  import RenderFields from '../../../../fields/RenderFields.svelte';
6
6
  import Button from '../../../../ui/button/button.svelte';
7
7
  import * as Dialog from '../../../../ui/dialog/index.js';
8
- import { API_PROXY, setAPIProxyContext } from '../../../../../context/api-proxy.svelte.js';
9
8
  import type { CollectionContext } from '../../../../../context/collection.svelte.js';
10
9
  import { getConfigContext } from '../../../../../context/config.svelte.js';
11
10
  import {
@@ -16,7 +15,6 @@
16
15
  type Props = { collection: CollectionContext; open: boolean };
17
16
  let { collection, open = $bindable() }: Props = $props();
18
17
 
19
- setAPIProxyContext(API_PROXY.DOCUMENT);
20
18
  let formElement = $state<HTMLFormElement>();
21
19
  const configCtx = getConfigContext();
22
20
  // svelte-ignore state_referenced_locally
@@ -65,6 +65,7 @@
65
65
  {/if}
66
66
 
67
67
  {#if form.values.id}
68
+ {/* @ts-ignore form doc is GenericDoc as form.values.id is defined */ null}
68
69
  <Settings {form} />
69
70
  {/if}
70
71
 
@@ -8,13 +8,14 @@
8
8
  import type { DocumentFormContext } from '../../../context/documentForm.svelte.js';
9
9
  import { getLocaleContext } from '../../../context/locale.svelte.js';
10
10
  import { panelUrl } from '../../../util/url.js';
11
+ import type { GenericDoc } from '../../../../types.js';
11
12
  import { trycatchFetch } from '../../../../util/function.js';
12
13
  import { Copy, History, Import, Pickaxe, Settings, Trash2 } from '@lucide/svelte';
13
14
  import { toast } from 'svelte-sonner';
14
15
  import { t__ } from '../../../../core/i18n/index.js';
15
16
  import Button from '../../ui/button/button.svelte';
16
17
 
17
- type Props = { form: DocumentFormContext };
18
+ type Props = { form: DocumentFormContext<GenericDoc> };
18
19
 
19
20
  const { form }: Props = $props();
20
21
 
@@ -84,7 +85,7 @@
84
85
  }
85
86
  const { id } = await success.json();
86
87
  toast.success(t__('common.duplicate_success'));
87
- await goto(panelUrl(form.config.kebab, form.values.id));
88
+ await goto(panelUrl(form.config.kebab, id));
88
89
  }
89
90
 
90
91
  const shouldShowSettings = $derived.by(() => {
@@ -1,7 +1,8 @@
1
1
  import type { DocumentFormContext } from '../../../context/documentForm.svelte.js';
2
+ import type { GenericDoc } from '../../../../types.js';
2
3
  import { Settings } from '@lucide/svelte';
3
4
  type Props = {
4
- form: DocumentFormContext;
5
+ form: DocumentFormContext<GenericDoc>;
5
6
  };
6
7
  declare const Settings: import("svelte").Component<Props, {}, "">;
7
8
  type Settings = ReturnType<typeof Settings>;
@@ -3,7 +3,7 @@
3
3
  import type { User } from '../../../../core/collections/auth/types.js';
4
4
  import type { BuiltConfigClient } from '../../../../core/config/types.js';
5
5
  import { Toaster } from '../../ui/sonner';
6
- import { API_PROXY, setAPIProxyContext } from '../../../context/api-proxy.svelte.js';
6
+ import { setAPIProxyContext } from '../../../context/api-proxy.svelte.js';
7
7
  import { setConfigContext } from '../../../context/config.svelte.js';
8
8
  import createContext from '../../../context/createContext.svelte.js';
9
9
  import { setLocaleContext } from '../../../context/locale.svelte.js';
@@ -22,7 +22,7 @@
22
22
  user: User;
23
23
  };
24
24
 
25
- const { doc, config, locale: initialeLocale, user, onDataChange, onFieldFocus }: Props = $props();
25
+ const { doc, config, locale: initialLocale, user, onDataChange, onFieldFocus }: Props = $props();
26
26
 
27
27
  function buildPanelURL() {
28
28
  // Start with the base URI for the panel
@@ -35,16 +35,14 @@
35
35
  return panelUri;
36
36
  }
37
37
 
38
- setAPIProxyContext(API_PROXY.DOCUMENT);
38
+ setAPIProxyContext();
39
39
  // svelte-ignore state_referenced_locally
40
40
  setConfigContext(config);
41
41
  // svelte-ignore state_referenced_locally
42
42
  setUserContext(user);
43
+ // svelte-ignore state_referenced_locally
44
+ setLocaleContext(initialLocale);
43
45
  createContext('title', '[untitled]');
44
-
45
- $effect(() => {
46
- setLocaleContext(initialeLocale);
47
- });
48
46
  </script>
49
47
 
50
48
  <Toaster />
@@ -9,7 +9,6 @@ export declare function getAPIProxyContext(key?: symbol): {
9
9
  readonly urls: string[];
10
10
  };
11
11
  export declare const API_PROXY: {
12
- DOCUMENT: symbol;
13
12
  ROOT: symbol;
14
13
  };
15
14
  export type Resource<T = any> = {
@@ -78,8 +78,6 @@ export function setAPIProxyContext(key = API_PROXY.ROOT) {
78
78
  export function getAPIProxyContext(key = API_PROXY.ROOT) {
79
79
  return getContext(key);
80
80
  }
81
- // @TODO why multiple APIProxy... ROOT everywhere should work
82
81
  export const API_PROXY = {
83
- DOCUMENT: Symbol('api-proxy.document'),
84
82
  ROOT: Symbol('api-proxy.root')
85
83
  };
@@ -71,7 +71,7 @@ export declare function setDocumentFormContext<T extends WithOptional<GenericDoc
71
71
  readonly isLive: boolean;
72
72
  setFocusedField(path: string): void;
73
73
  };
74
- export declare function getDocumentFormContext<T extends WithOptional<GenericDoc, 'id'> = GenericDoc>(key?: string): {
74
+ export declare function getDocumentFormContext<T extends WithOptional<GenericDoc, 'id'> = WithOptional<GenericDoc, 'id'>>(key?: string): {
75
75
  key: string;
76
76
  setValue: (path: string, value: any) => void;
77
77
  getRawValue: <T_1>(path: string) => NonNullable<T_1> | null;
@@ -140,7 +140,7 @@ export declare function getDocumentFormContext<T extends WithOptional<GenericDoc
140
140
  readonly isLive: boolean;
141
141
  setFocusedField(path: string): void;
142
142
  };
143
- export type DocumentFormContext<T extends WithOptional<GenericDoc, 'id'> = GenericDoc> = ReturnType<typeof setDocumentFormContext<T>>;
143
+ export type DocumentFormContext<T extends WithOptional<GenericDoc, 'id'> = WithOptional<GenericDoc, 'id'>> = ReturnType<typeof setDocumentFormContext<T>>;
144
144
  type AddBlock = (block: Omit<GenericBlock, 'id' | 'path'>) => void;
145
145
  type MoveBlock = (from: number, to: number) => void;
146
146
  export type FormSuccessData = {
@@ -18,7 +18,7 @@ import { t__ } from '../../core/i18n/index.js';
18
18
  import { moveItem } from '../../util/array.js';
19
19
  import { getValueAtPath, setValueAtPath } from '../../util/object.js';
20
20
  import { snapshot } from '../../util/state.js';
21
- import { API_PROXY, getAPIProxyContext } from './api-proxy.svelte.js';
21
+ import { getAPIProxyContext } from './api-proxy.svelte.js';
22
22
  import { getCollectionContext } from './collection.svelte.js';
23
23
  import { setErrorsContext } from './errors.svelte.js';
24
24
  import { getLocaleContext } from './locale.svelte.js';
@@ -45,7 +45,7 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
45
45
  const titleContext = getContext('title');
46
46
  const initialTitle = initTitle();
47
47
  let title = $state(initialTitle);
48
- const apiProxy = getAPIProxyContext(API_PROXY.DOCUMENT);
48
+ const apiProxy = getAPIProxyContext();
49
49
  function initLevel() {
50
50
  const last = key.split('_').pop();
51
51
  const isDigit = /[\d]+/.test(last);
@@ -30,7 +30,6 @@ function createFormStore(initial, key) {
30
30
  * // value will not update if doc.blocks.0.title update
31
31
  */
32
32
  function getRawValue(path) {
33
- console.log(path);
34
33
  return snapshot(getValueAtPath(path, form)) || null;
35
34
  }
36
35
  function setValue(path, value) {
@@ -1,3 +1,4 @@
1
+ export declare const LOCALE_CTX: unique symbol;
1
2
  export declare function setLocaleContext(initial?: string): {
2
3
  dateFormat: (date: Date | string, args?: {
3
4
  short?: boolean;
@@ -1,6 +1,6 @@
1
1
  import { getContext, setContext } from 'svelte';
2
2
  import { getConfigContext } from './config.svelte.js';
3
- const LOCALE_KEY = Symbol('rime.locale');
3
+ export const LOCALE_CTX = Symbol('rime.locale');
4
4
  function createStore(initial) {
5
5
  let code = $state();
6
6
  let label = $state();
@@ -56,8 +56,8 @@ function createStore(initial) {
56
56
  }
57
57
  export function setLocaleContext(initial) {
58
58
  const store = createStore(initial);
59
- return setContext(LOCALE_KEY, store);
59
+ return setContext(LOCALE_CTX, store);
60
60
  }
61
61
  export function getLocaleContext() {
62
- return getContext(LOCALE_KEY);
62
+ return getContext(LOCALE_CTX);
63
63
  }
@@ -1,13 +1,10 @@
1
1
  <script lang="ts">
2
2
  import Document from '../../components/sections/document/Document.svelte';
3
- import Unauthorized from '../../components/sections/unauthorized/Unauthorized.svelte';
4
- import { API_PROXY, setAPIProxyContext } from '../../context/api-proxy.svelte.js';
5
3
  import Page from '../../components/sections/page-layout/Page.svelte';
4
+ import Unauthorized from '../../components/sections/unauthorized/Unauthorized.svelte';
6
5
  import type { AreaDocData } from '../../index.js';
7
6
 
8
7
  const { data }: { data: AreaDocData<false> } = $props();
9
-
10
- setAPIProxyContext(API_PROXY.DOCUMENT);
11
8
  </script>
12
9
 
13
10
  {#if data.status === 200}
@@ -3,12 +3,9 @@
3
3
  import Versions from '../../components/sections/document/Versions.svelte';
4
4
  import Page from '../../components/sections/page-layout/Page.svelte';
5
5
  import Unauthorized from '../../components/sections/unauthorized/Unauthorized.svelte';
6
- import { API_PROXY, setAPIProxyContext } from '../../context/api-proxy.svelte.js';
7
6
  import type { AreaDocData } from '../../index.js';
8
7
 
9
8
  const { data }: { data: AreaDocData<true> } = $props();
10
-
11
- setAPIProxyContext(API_PROXY.DOCUMENT);
12
9
  </script>
13
10
 
14
11
  {#if data.status === 200}
@@ -1,16 +1,11 @@
1
1
  <script lang="ts">
2
- import type { VersionsStatus } from '../../../core/constant.js';
3
- import type { VersionDoc } from '../../../core/types/doc.js';
4
2
  import Document from '../../components/sections/document/Document.svelte';
5
3
  import Versions from '../../components/sections/document/Versions.svelte';
6
4
  import Page from '../../components/sections/page-layout/Page.svelte';
7
5
  import Unauthorized from '../../components/sections/unauthorized/Unauthorized.svelte';
8
- import { API_PROXY, setAPIProxyContext } from '../../context/api-proxy.svelte.js';
9
6
  import type { CollectionDocData } from '../../index.js';
10
7
 
11
8
  const { data }: { data: CollectionDocData<true> } = $props();
12
-
13
- setAPIProxyContext(API_PROXY.DOCUMENT);
14
9
  </script>
15
10
 
16
11
  {#if data.status === 200}
@@ -2,12 +2,9 @@
2
2
  import Document from '../../components/sections/document/Document.svelte';
3
3
  import Page from '../../components/sections/page-layout/Page.svelte';
4
4
  import Unauthorized from '../../components/sections/unauthorized/Unauthorized.svelte';
5
- import { API_PROXY, setAPIProxyContext } from '../../context/api-proxy.svelte.js';
6
5
  import type { CollectionDocData } from '../../index.js';
7
6
 
8
7
  const { data }: { data: CollectionDocData<false> } = $props();
9
-
10
- setAPIProxyContext(API_PROXY.DOCUMENT);
11
8
  </script>
12
9
 
13
10
  {#if data.status === 200}
@@ -7,6 +7,7 @@
7
7
  import Button from '../../components/ui/button/button.svelte';
8
8
  import { Pane, PaneGroup, PaneResizer } from '../../components/ui/pane/index.js';
9
9
  import SpinLoader from '../../components/ui/spin-loader/SpinLoader.svelte';
10
+ import { snapshot } from '../../../util/state';
10
11
  import { Laptop, Smartphone } from '@lucide/svelte';
11
12
  import { onMount } from 'svelte';
12
13
  import { fade } from 'svelte/transition';
@@ -30,7 +31,8 @@
30
31
  const onDataChange = (args: Partial<GenericDoc>) => {
31
32
  /** Send message to iframe */
32
33
  if (iframe?.contentWindow) {
33
- iframe.contentWindow.postMessage(args);
34
+ // Use snapshot to ensure we're sending a plain object without reactive proxies
35
+ iframe.contentWindow.postMessage(snapshot(args));
34
36
  }
35
37
  };
36
38
 
@@ -89,12 +91,7 @@
89
91
  }
90
92
  });
91
93
 
92
- const ZOOMS = [0.5, 0.66, 1] as const;
93
-
94
- let currentZoom = $state(1);
95
94
  let currentDevice = $state<'mobile' | 'desktop'>('mobile');
96
-
97
- const iframeScale = $derived(ZOOMS[currentZoom]);
98
95
  </script>
99
96
 
100
97
  <div class="rz-live-container">
@@ -169,8 +166,6 @@
169
166
 
170
167
  .rz-live-container iframe.mobile {
171
168
  width: 320px;
172
- /*transform: translateX(-50%);
173
- margin-left: 50%;*/
174
169
  aspect-ratio: 2 / 3.3;
175
170
  scale: 1.25;
176
171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rimecms",
3
- "version": "0.26.9",
3
+ "version": "0.27.0",
4
4
  "homepage": "https://github.com/bienbiendev/rime",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -170,7 +170,7 @@
170
170
  "typescript": "^5.8.3",
171
171
  "typescript-eslint": "^8.20.0",
172
172
  "vite": "^8.0.8",
173
- "vitest": "^4.0.5"
173
+ "vitest": "^4.1.4"
174
174
  },
175
175
  "dependencies": {
176
176
  "@babel/generator": "^7.28.3",