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.
- package/dist/fields/group/component/Group.svelte +1 -0
- package/dist/fields/group/index.d.ts +12 -8
- package/dist/fields/group/index.js +4 -0
- package/dist/fields/link/component/RessourceInput.svelte +2 -2
- package/dist/fields/relation/component/Cell.svelte +2 -2
- package/dist/fields/relation/component/Relation.svelte +2 -2
- package/dist/fields/relation/component/upload/Browse.svelte +2 -2
- package/dist/fields/rich-text/client.d.ts +9 -2
- package/dist/fields/rich-text/core/config-builders.js +5 -2
- package/dist/fields/rich-text/core/features/fields/extension.d.ts +10 -3
- package/dist/fields/rich-text/core/features/fields/extension.js +1 -6
- package/dist/fields/rich-text/core/features/fields/fields.css +4 -0
- package/dist/fields/rich-text/core/features/fields/fields.svelte +13 -6
- package/dist/fields/rich-text/core/features/fields/fields.svelte.d.ts +4 -1
- package/dist/fields/rich-text/core/features/fields/index.d.ts +6 -4
- package/dist/fields/rich-text/core/features/fields/index.js +1 -2
- package/dist/fields/rich-text/core/features/link/component/link-selector.svelte +2 -6
- package/dist/fields/rich-text/core/features/resource/index.d.ts +2 -5
- package/dist/fields/rich-text/core/features/resource/index.js +0 -1
- package/dist/fields/rich-text/core/features/resource/resource-extension.d.ts +7 -2
- package/dist/fields/rich-text/core/features/resource/resource-extension.js +1 -7
- package/dist/fields/rich-text/core/features/resource/resource.svelte +2 -2
- package/dist/fields/rich-text/core/features/upload/index.js +1 -2
- package/dist/fields/rich-text/core/features/upload/upload-extension.d.ts +14 -1
- package/dist/fields/rich-text/core/features/upload/upload-extension.js +2 -10
- package/dist/fields/rich-text/core/features/upload/upload.svelte +2 -2
- package/dist/fields/rich-text/core/svelte/node-view-renderer.svelte.js +10 -5
- package/dist/fields/rich-text/core/svelte/node-view-wrapper.svelte +1 -0
- package/dist/fields/rich-text/core/svelte/renderer.d.ts +1 -1
- package/dist/fields/types.d.ts +10 -0
- package/dist/panel/components/Root.svelte +2 -2
- package/dist/panel/components/fields/FieldsPreview.svelte +34 -27
- package/dist/panel/components/fields/FieldsPreview.svelte.d.ts +5 -6
- package/dist/panel/components/sections/collection/folder/FolderEdit.svelte +0 -2
- package/dist/panel/components/sections/collection/folder/FolderWithActions.svelte +2 -2
- package/dist/panel/components/sections/collection/grid/create-directory-dialog/CreateDirectoryDialog.svelte +0 -2
- package/dist/panel/components/sections/document/Header.svelte +1 -0
- package/dist/panel/components/sections/document/Settings.svelte +3 -2
- package/dist/panel/components/sections/document/Settings.svelte.d.ts +2 -1
- package/dist/panel/components/sections/live/SidePanel.svelte +5 -7
- package/dist/panel/context/api-proxy.svelte.d.ts +0 -1
- package/dist/panel/context/api-proxy.svelte.js +0 -2
- package/dist/panel/context/documentForm.svelte.d.ts +2 -2
- package/dist/panel/context/documentForm.svelte.js +2 -2
- package/dist/panel/context/form.svelte.js +0 -1
- package/dist/panel/context/locale.svelte.d.ts +1 -0
- package/dist/panel/context/locale.svelte.js +3 -3
- package/dist/panel/pages/area/Area.svelte +1 -4
- package/dist/panel/pages/area/AreaVersionsDoc.svelte +0 -3
- package/dist/panel/pages/collection-document/CollectionDocVersions.svelte +0 -5
- package/dist/panel/pages/collection-document/CollectionDocument.svelte +0 -3
- package/dist/panel/pages/live/Live.svelte +3 -8
- package/package.json +2 -2
|
@@ -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():
|
|
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:
|
|
23
|
-
cell:
|
|
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:
|
|
31
|
-
cell?:
|
|
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:
|
|
41
|
-
cell:
|
|
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 {
|
|
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(
|
|
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 {
|
|
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(
|
|
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 {
|
|
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(
|
|
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 {
|
|
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(
|
|
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 {
|
|
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:
|
|
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(
|
|
66
|
+
const apiProxyContext = getAPIProxyContext();
|
|
65
67
|
const userContext = getUserContext();
|
|
66
68
|
contexts.set(CONFIG_CTX, configContext);
|
|
67
|
-
contexts.set(API_PROXY.
|
|
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
|
-
|
|
6
|
-
insertSheet: (attributes
|
|
8
|
+
'richt-text-fields': {
|
|
9
|
+
insertSheet: (attributes?: Dic) => ReturnType;
|
|
7
10
|
};
|
|
8
11
|
}
|
|
9
12
|
}
|
|
10
|
-
export
|
|
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,
|
|
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 };
|
|
@@ -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
|
|
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:
|
|
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
|
-
|
|
5
|
+
export interface FieldsFeatureOptions {
|
|
4
6
|
name: string;
|
|
5
7
|
label: string;
|
|
6
8
|
fields: FieldBuilder[];
|
|
7
|
-
|
|
8
|
-
|
|
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(
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
slug: PrototypeSlug;
|
|
6
|
-
}) => RichTextFeature;
|
|
2
|
+
import { type ResourceFeatureExtensionOptions } from './resource-extension.js';
|
|
3
|
+
export declare const ResourceFeature: (args: ResourceFeatureExtensionOptions) => RichTextFeature;
|
|
@@ -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
|
|
7
|
+
insertResource: (attributes?: Dic) => ReturnType;
|
|
7
8
|
};
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
|
-
export
|
|
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,
|
|
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 {
|
|
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(
|
|
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
|
-
|
|
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
|
|
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,
|
|
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
|
-
|
|
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 {
|
|
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(
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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';
|
package/dist/fields/types.d.ts
CHANGED
|
@@ -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 {
|
|
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(
|
|
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>) =>
|
|
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
|
-
{#
|
|
18
|
-
{@const
|
|
19
|
-
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<div class="rz-render-fields-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
38
|
-
{/
|
|
39
|
-
{/
|
|
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
|
-
|
|
7
|
-
value: any | null;
|
|
8
|
-
};
|
|
6
|
+
getField: (field: FormFieldBuilder<FormField>) => BaseUseFieldReturn;
|
|
7
|
+
preview?: Component<FieldsPreviewProps>;
|
|
9
8
|
};
|
|
10
|
-
declare const FieldsPreview:
|
|
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 {
|
|
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(
|
|
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
|
|
@@ -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,
|
|
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 {
|
|
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:
|
|
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(
|
|
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 />
|
|
@@ -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
|
|
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
|
|
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 {
|
|
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(
|
|
48
|
+
const apiProxy = getAPIProxyContext();
|
|
49
49
|
function initLevel() {
|
|
50
50
|
const last = key.split('_').pop();
|
|
51
51
|
const isDigit = /[\d]+/.test(last);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getContext, setContext } from 'svelte';
|
|
2
2
|
import { getConfigContext } from './config.svelte.js';
|
|
3
|
-
const
|
|
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(
|
|
59
|
+
return setContext(LOCALE_CTX, store);
|
|
60
60
|
}
|
|
61
61
|
export function getLocaleContext() {
|
|
62
|
-
return getContext(
|
|
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
|
-
|
|
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.
|
|
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.
|
|
173
|
+
"vitest": "^4.1.4"
|
|
174
174
|
},
|
|
175
175
|
"dependencies": {
|
|
176
176
|
"@babel/generator": "^7.28.3",
|