@webx-ui/module-blocks 0.11.7 → 0.13.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/BlockExportDialog.d.ts +14 -0
- package/dist/BlockImportDialog.d.ts +4 -0
- package/dist/BlocksField.d.ts +14 -3
- package/dist/BlocksPreview.d.ts +4 -1
- package/dist/BlocksTree.d.ts +11 -1
- package/dist/api.d.ts +21 -4
- package/dist/clipboard.d.ts +64 -0
- package/dist/frame.d.ts +7 -0
- package/dist/index.js +3593 -2522
- package/dist/index.js.map +1 -1
- package/dist/lint.d.ts +6 -0
- package/dist/schema.d.ts +39 -0
- package/dist/style.css +1 -1
- package/dist/types.d.ts +77 -1
- package/package.json +4 -4
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Export" (§17.1): the types to take, ticked, and one file out — the command's documents in a
|
|
3
|
+
* pack. The components the chosen types call are not offered as a choice: the server adds them,
|
|
4
|
+
* because a block without them draws nothing on the site it lands on, and a person exporting a
|
|
5
|
+
* block for another site would only find that out there.
|
|
6
|
+
*
|
|
7
|
+
* Opened from a type's editor, it comes with that type ticked: a block for the catalogue of
|
|
8
|
+
* ready blocks is made one at a time.
|
|
9
|
+
*/
|
|
10
|
+
type __VLS_Props = {
|
|
11
|
+
selected?: string[];
|
|
12
|
+
};
|
|
13
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
|
|
2
|
+
picker: HTMLInputElement;
|
|
3
|
+
}, any>;
|
|
4
|
+
export default _default;
|
package/dist/BlocksField.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ShortcodeToken } from '@webx-ui/module-admin';
|
|
1
2
|
import { RenderContext, ScreenNode } from '@webx-ui/schema';
|
|
2
3
|
import { BlockNode, BlockType } from './types';
|
|
3
4
|
type __VLS_Props = {
|
|
@@ -18,6 +19,11 @@ type __VLS_Props = {
|
|
|
18
19
|
disabled?: boolean;
|
|
19
20
|
/** Where the section lives, for the picker's "make one" link. */
|
|
20
21
|
blocksPath?: string;
|
|
22
|
+
/**
|
|
23
|
+
* The site's shortcodes, offered in the text fields of a block. Fetched from the panel when
|
|
24
|
+
* absent, like the catalog.
|
|
25
|
+
*/
|
|
26
|
+
shortcodes?: ShortcodeToken[] | null;
|
|
21
27
|
};
|
|
22
28
|
type __VLS_PublicProps = {
|
|
23
29
|
modelValue?: BlockNode[];
|
|
@@ -28,10 +34,11 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {},
|
|
|
28
34
|
"onUpdate:modelValue"?: ((value: BlockNode[]) => any) | undefined;
|
|
29
35
|
}>, {
|
|
30
36
|
allow: string[] | null;
|
|
37
|
+
shortcodes: ShortcodeToken[] | null;
|
|
31
38
|
disabled: boolean;
|
|
32
39
|
name: string;
|
|
33
|
-
node: ScreenNode;
|
|
34
40
|
localized: boolean;
|
|
41
|
+
node: ScreenNode;
|
|
35
42
|
max: number | null;
|
|
36
43
|
context: RenderContext;
|
|
37
44
|
catalog: BlockType[] | null;
|
|
@@ -43,6 +50,7 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {},
|
|
|
43
50
|
selected?: string | null;
|
|
44
51
|
reload?: number;
|
|
45
52
|
compact?: boolean;
|
|
53
|
+
hidden?: string[];
|
|
46
54
|
}> & Readonly<{
|
|
47
55
|
onSelect?: ((key: string | null) => any) | undefined;
|
|
48
56
|
onEdit?: (() => any) | undefined;
|
|
@@ -54,8 +62,9 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {},
|
|
|
54
62
|
select: (key: string | null) => any;
|
|
55
63
|
edit: () => any;
|
|
56
64
|
}, import('vue').PublicProps, {
|
|
57
|
-
|
|
65
|
+
hidden: string[];
|
|
58
66
|
selected: string | null;
|
|
67
|
+
compact: boolean;
|
|
59
68
|
reload: number;
|
|
60
69
|
}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
|
|
61
70
|
bar: HTMLDivElement;
|
|
@@ -73,6 +82,7 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {},
|
|
|
73
82
|
selected?: string | null;
|
|
74
83
|
reload?: number;
|
|
75
84
|
compact?: boolean;
|
|
85
|
+
hidden?: string[];
|
|
76
86
|
}> & Readonly<{
|
|
77
87
|
onSelect?: ((key: string | null) => any) | undefined;
|
|
78
88
|
onEdit?: (() => any) | undefined;
|
|
@@ -81,8 +91,9 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {},
|
|
|
81
91
|
refresh: () => void;
|
|
82
92
|
open: () => boolean;
|
|
83
93
|
}, {}, {}, {}, {
|
|
84
|
-
|
|
94
|
+
hidden: string[];
|
|
85
95
|
selected: string | null;
|
|
96
|
+
compact: boolean;
|
|
86
97
|
reload: number;
|
|
87
98
|
}> | null;
|
|
88
99
|
}, any>;
|
package/dist/BlocksPreview.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ type __VLS_Props = {
|
|
|
17
17
|
* there is no tree standing next to it to click.
|
|
18
18
|
*/
|
|
19
19
|
compact?: boolean;
|
|
20
|
+
/** Keys of the blocks switched off: marked in the page until it reloads without them. */
|
|
21
|
+
hidden?: string[];
|
|
20
22
|
};
|
|
21
23
|
/** Swap one block's markup in place; false when the page has to be reloaded instead. */
|
|
22
24
|
declare function replace(key: string, html: string): boolean;
|
|
@@ -32,8 +34,9 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {
|
|
|
32
34
|
onSelect?: ((key: string | null) => any) | undefined;
|
|
33
35
|
onEdit?: (() => any) | undefined;
|
|
34
36
|
}>, {
|
|
35
|
-
|
|
37
|
+
hidden: string[];
|
|
36
38
|
selected: string | null;
|
|
39
|
+
compact: boolean;
|
|
37
40
|
reload: number;
|
|
38
41
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
39
42
|
bar: HTMLDivElement;
|
package/dist/BlocksTree.d.ts
CHANGED
|
@@ -18,11 +18,17 @@ type __VLS_Props = {
|
|
|
18
18
|
selected?: string | null;
|
|
19
19
|
disabled?: boolean;
|
|
20
20
|
depth?: number;
|
|
21
|
+
/** What the last save was refused for, by block key. */
|
|
22
|
+
errors?: Record<string, string[]>;
|
|
23
|
+
/** What "Copy" put aside, for the paste lines; null while there is nothing. */
|
|
24
|
+
clip?: BlockNode[] | null;
|
|
21
25
|
};
|
|
22
26
|
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
23
27
|
add: (parentKey: string | null, field: string | null, node: ScreenNode | null, index?: number | undefined) => any;
|
|
24
28
|
remove: (key: string) => any;
|
|
25
29
|
duplicate: (key: string) => any;
|
|
30
|
+
copy: (key: string) => any;
|
|
31
|
+
paste: (parentKey: string | null, field: string | null, node: ScreenNode | null, index?: number | undefined) => any;
|
|
26
32
|
move: (key: string) => any;
|
|
27
33
|
select: (key: string) => any;
|
|
28
34
|
visibility: (key: string, hidden: boolean) => any;
|
|
@@ -31,6 +37,8 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {
|
|
|
31
37
|
onAdd?: ((parentKey: string | null, field: string | null, node: ScreenNode | null, index?: number | undefined) => any) | undefined;
|
|
32
38
|
onRemove?: ((key: string) => any) | undefined;
|
|
33
39
|
onDuplicate?: ((key: string) => any) | undefined;
|
|
40
|
+
onCopy?: ((key: string) => any) | undefined;
|
|
41
|
+
onPaste?: ((parentKey: string | null, field: string | null, node: ScreenNode | null, index?: number | undefined) => any) | undefined;
|
|
34
42
|
onMove?: ((key: string) => any) | undefined;
|
|
35
43
|
onSelect?: ((key: string) => any) | undefined;
|
|
36
44
|
onVisibility?: ((key: string, hidden: boolean) => any) | undefined;
|
|
@@ -38,10 +46,12 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {
|
|
|
38
46
|
}>, {
|
|
39
47
|
field: string | null;
|
|
40
48
|
disabled: boolean;
|
|
49
|
+
selected: string | null;
|
|
41
50
|
depth: number;
|
|
51
|
+
errors: Record<string, string[]>;
|
|
42
52
|
max: number | null;
|
|
43
|
-
selected: string | null;
|
|
44
53
|
parentKey: string | null;
|
|
45
54
|
fieldNode: ScreenNode | null;
|
|
55
|
+
clip: BlockNode[] | null;
|
|
46
56
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
47
57
|
export default _default;
|
package/dist/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AdminContext } from '@webx-ui/module-admin';
|
|
2
|
-
import { BlockInput, BlockList, BlockType, BlockUsage, BlockVersion, BlockNode, BlockVersionMeta, RegionAdopted, RegionDetail, RegionRow, RegionVersion, RenderInput, RenderResult } from './types';
|
|
2
|
+
import { BlockExport, BlockImportRow, BlockInput, BlockList, BlockType, BlockUsage, BlockVersion, BlockNode, BlockVersionMeta, RegionAdopted, RegionDetail, RegionRow, RegionVersion, RenderInput, RenderResult } from './types';
|
|
3
3
|
export interface BlocksApi {
|
|
4
4
|
/** Every type, without content: the section's list. */
|
|
5
5
|
list(): Promise<BlockType[]>;
|
|
@@ -13,7 +13,10 @@ export interface BlocksApi {
|
|
|
13
13
|
remove(id: number): Promise<void>;
|
|
14
14
|
/** A declared place made into the site's own type: an unpublished draft of the module's view. */
|
|
15
15
|
customise(slug: string): Promise<BlockType>;
|
|
16
|
-
|
|
16
|
+
/** `dropTranslations` agrees to keep one language where a field stops being localized. */
|
|
17
|
+
publish(id: number, options?: {
|
|
18
|
+
dropTranslations?: boolean;
|
|
19
|
+
}): Promise<BlockType>;
|
|
17
20
|
render(id: number, input?: RenderInput): Promise<RenderResult>;
|
|
18
21
|
usage(id: number): Promise<BlockUsage[]>;
|
|
19
22
|
versions(id: number): Promise<BlockVersionMeta[]>;
|
|
@@ -21,6 +24,19 @@ export interface BlocksApi {
|
|
|
21
24
|
restore(id: number, number: number): Promise<BlockType>;
|
|
22
25
|
/** The new order of some types — a group — in the places they held; the rest stay put. */
|
|
23
26
|
reorder(ids: number[]): Promise<void>;
|
|
27
|
+
/** A pack of the types named — every type when none is — and the components they call. */
|
|
28
|
+
exportPack(slugs: string[], options?: {
|
|
29
|
+
draft?: boolean;
|
|
30
|
+
}): Promise<BlockExport>;
|
|
31
|
+
/**
|
|
32
|
+
* What the file would do (`dryRun`), or what it did. Drafts, unless `publish` is asked for.
|
|
33
|
+
* The file goes as its text: the server compares it with what is stored, whitespace included.
|
|
34
|
+
*/
|
|
35
|
+
importPack(file: string, options?: {
|
|
36
|
+
name?: string;
|
|
37
|
+
dryRun?: boolean;
|
|
38
|
+
publish?: boolean;
|
|
39
|
+
}): Promise<BlockImportRow[]>;
|
|
24
40
|
}
|
|
25
41
|
/** Everything under `/blocks`, below the panel's API path. */
|
|
26
42
|
export declare function createBlocksApi(admin: AdminContext): BlocksApi;
|
|
@@ -30,13 +46,14 @@ export interface RegionsApi {
|
|
|
30
46
|
get(name: string): Promise<RegionDetail>;
|
|
31
47
|
/**
|
|
32
48
|
* Save the draft. Refused with a 409 when the revision is not the current one — the error's
|
|
33
|
-
* body is a {@link RegionConflict}
|
|
49
|
+
* body is a {@link RegionConflict}: the region as it now is, to merge with.
|
|
34
50
|
*/
|
|
35
51
|
save(name: string, input: {
|
|
36
52
|
blocks: BlockNode[];
|
|
37
53
|
revision?: string;
|
|
38
54
|
}): Promise<RegionDetail>;
|
|
39
|
-
|
|
55
|
+
/** `revision` is what the editor held: a draft that moved on since is answered 409, not published. */
|
|
56
|
+
publish(name: string, revision?: string): Promise<RegionDetail>;
|
|
40
57
|
/** Off the site: the code's view comes back, the blocks stay as the draft. */
|
|
41
58
|
unpublish(name: string): Promise<RegionDetail>;
|
|
42
59
|
discardDraft(name: string): Promise<RegionDetail>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { ScreenNode } from '@webx-ui/schema';
|
|
3
|
+
import { BlockNode, BlockType } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Copy and paste of blocks, across pages and across modules of the same panel.
|
|
6
|
+
*
|
|
7
|
+
* The clipboard is the browser's storage rather than the system one: a block is not text, the
|
|
8
|
+
* system clipboard asks for permission to be read, and what is copied here is only ever pasted
|
|
9
|
+
* into a constructor of the same site — every module stores the same `{ key, type, values }`.
|
|
10
|
+
* One entry, kept after a paste, so the same block can go onto several pages; every tab sees
|
|
11
|
+
* what another one copied.
|
|
12
|
+
*/
|
|
13
|
+
export declare const CLIPBOARD_KEY = "wx-blocks-clipboard";
|
|
14
|
+
export interface BlocksClip {
|
|
15
|
+
format: 'webx-blocks-clip';
|
|
16
|
+
/** Bumped when the shape changes; a clip of another version is treated as empty. */
|
|
17
|
+
format_version: 1;
|
|
18
|
+
copied_at: string;
|
|
19
|
+
nodes: BlockNode[];
|
|
20
|
+
}
|
|
21
|
+
/** What is stored, if it is a clip this code understands — anything else is no clip at all. */
|
|
22
|
+
export declare function parseClip(raw: string | null): BlocksClip | null;
|
|
23
|
+
export declare function useBlocksClipboard(): {
|
|
24
|
+
clip: Readonly<Ref<BlocksClip | null>>;
|
|
25
|
+
copy: (nodes: BlockNode[]) => void;
|
|
26
|
+
clear: () => void;
|
|
27
|
+
};
|
|
28
|
+
/** Why a block of the clip did not go in. */
|
|
29
|
+
export type SkipReason = 'unknown' | 'place' | 'limit' | 'full';
|
|
30
|
+
/** The list a paste goes into, and the rules that list stands under. */
|
|
31
|
+
export interface PasteTarget {
|
|
32
|
+
/** The whole tree of the page, for the per-page limits of the types. */
|
|
33
|
+
tree: BlockNode[];
|
|
34
|
+
/** The list itself — the tree, or a container's field. */
|
|
35
|
+
list: BlockNode[];
|
|
36
|
+
/** The container's type, or the top level's owner (a block's sample form), or null. */
|
|
37
|
+
parent: BlockType | null;
|
|
38
|
+
allow: string[] | null;
|
|
39
|
+
max: number | null;
|
|
40
|
+
/** What the list is called in `allowed_in`; only the top level is ever anything but `root`. */
|
|
41
|
+
root: string;
|
|
42
|
+
}
|
|
43
|
+
export interface PastePlan {
|
|
44
|
+
/** Fresh copies, keys renewed all the way down, in the clip's order. */
|
|
45
|
+
accepted: BlockNode[];
|
|
46
|
+
skipped: {
|
|
47
|
+
node: BlockNode;
|
|
48
|
+
reason: SkipReason;
|
|
49
|
+
}[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* What of the clip may go into this list, judged by the same rules the picker and "Move to"
|
|
53
|
+
* go by, so a paste never puts down what adding by hand would not.
|
|
54
|
+
*
|
|
55
|
+
* Block by block rather than all or nothing: a page copied whole into a region that takes half
|
|
56
|
+
* of it gets that half, and the rest is named. A block whose type — or the type of anything
|
|
57
|
+
* inside it — this site does not offer is left out whole: half a section is not that section.
|
|
58
|
+
*/
|
|
59
|
+
export declare function planPaste(nodes: BlockNode[], target: PasteTarget, catalog: BlockType[]): PastePlan;
|
|
60
|
+
/** A container field's own rules, read off its node in the type's schema. */
|
|
61
|
+
export declare function slotRules(slot: ScreenNode | null): {
|
|
62
|
+
allow: string[] | null;
|
|
63
|
+
max: number | null;
|
|
64
|
+
};
|
package/dist/frame.d.ts
CHANGED
|
@@ -25,6 +25,13 @@ export declare function replaceBlock(doc: Document, key: string, html: string):
|
|
|
25
25
|
export declare function blockElement(root: Node, key: string): Element | null;
|
|
26
26
|
/** Mark one block as the selected one, and nothing else. Null clears the selection. */
|
|
27
27
|
export declare function highlightBlock(doc: Document, key: string | null): Element | null;
|
|
28
|
+
export declare const HIDDEN_CLASS = "wx-preview-hidden";
|
|
29
|
+
/**
|
|
30
|
+
* Mark the blocks switched off. The page drawn under the preview token leaves a hidden block out,
|
|
31
|
+
* but one hidden after the page was drawn is still in the frame until it reloads — and it looked
|
|
32
|
+
* exactly like the blocks that will be on the site.
|
|
33
|
+
*/
|
|
34
|
+
export declare function markHidden(doc: Document, keys: string[]): void;
|
|
28
35
|
/** Mark one block as the one under the pointer. Null clears it. */
|
|
29
36
|
export declare function hoverBlock(doc: Document, key: string | null): void;
|
|
30
37
|
/**
|