@webx-ui/module-blocks 0.15.0 → 0.16.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.
@@ -51,18 +51,20 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {},
51
51
  reload?: number;
52
52
  compact?: boolean;
53
53
  hidden?: string[];
54
+ region?: string | null;
54
55
  }> & Readonly<{
55
- onSelect?: ((key: string | null) => any) | undefined;
56
56
  onEdit?: (() => any) | undefined;
57
+ onSelect?: ((key: string | null) => any) | undefined;
57
58
  }>, {
58
59
  replace: (key: string, html: string) => boolean;
59
60
  refresh: () => void;
60
61
  open: () => boolean;
61
62
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
62
- select: (key: string | null) => any;
63
63
  edit: () => any;
64
+ select: (key: string | null) => any;
64
65
  }, import('vue').PublicProps, {
65
66
  reload: number;
67
+ region: string | null;
66
68
  hidden: string[];
67
69
  selected: string | null;
68
70
  compact: boolean;
@@ -83,15 +85,17 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {},
83
85
  reload?: number;
84
86
  compact?: boolean;
85
87
  hidden?: string[];
88
+ region?: string | null;
86
89
  }> & Readonly<{
87
- onSelect?: ((key: string | null) => any) | undefined;
88
90
  onEdit?: (() => any) | undefined;
91
+ onSelect?: ((key: string | null) => any) | undefined;
89
92
  }>, {
90
93
  replace: (key: string, html: string) => boolean;
91
94
  refresh: () => void;
92
95
  open: () => boolean;
93
96
  }, {}, {}, {}, {
94
97
  reload: number;
98
+ region: string | null;
95
99
  hidden: string[];
96
100
  selected: string | null;
97
101
  compact: boolean;
@@ -19,6 +19,11 @@ type __VLS_Props = {
19
19
  compact?: boolean;
20
20
  /** Keys of the blocks switched off: marked in the page until it reloads without them. */
21
21
  hidden?: string[];
22
+ /**
23
+ * A region to frame and scroll to: a shared block, which is wherever the page placed it and
24
+ * not where a header always is — down the page under the content, more often than not.
25
+ */
26
+ region?: string | null;
22
27
  };
23
28
  /** Swap one block's markup in place; false when the page has to be reloaded instead. */
24
29
  declare function replace(key: string, html: string): boolean;
@@ -28,13 +33,14 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {
28
33
  refresh: typeof refresh;
29
34
  open: () => boolean;
30
35
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
31
- select: (key: string | null) => any;
32
36
  edit: () => any;
37
+ select: (key: string | null) => any;
33
38
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
34
- onSelect?: ((key: string | null) => any) | undefined;
35
39
  onEdit?: (() => any) | undefined;
40
+ onSelect?: ((key: string | null) => any) | undefined;
36
41
  }>, {
37
42
  reload: number;
43
+ region: string | null;
38
44
  hidden: string[];
39
45
  selected: string | null;
40
46
  compact: boolean;
@@ -0,0 +1,17 @@
1
+ import { RegionRow } from './types';
2
+ type __VLS_Props = {
3
+ modelValue?: string | null;
4
+ disabled?: boolean;
5
+ /** The shared blocks to choose from. Fetched from the panel when absent — a demo hands them in. */
6
+ fragments?: RegionRow[] | null;
7
+ };
8
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
9
+ "update:modelValue": (value: string | null) => any;
10
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
11
+ "onUpdate:modelValue"?: ((value: string | null) => any) | undefined;
12
+ }>, {
13
+ modelValue: string | null;
14
+ disabled: boolean;
15
+ fragments: RegionRow[] | null;
16
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
17
+ export default _default;
package/dist/api.d.ts CHANGED
@@ -19,6 +19,8 @@ export interface BlocksApi {
19
19
  }): Promise<BlockType>;
20
20
  render(id: number, input?: RenderInput): Promise<RenderResult>;
21
21
  usage(id: number): Promise<BlockUsage[]>;
22
+ /** The shared blocks a page may place, with their state; open to whoever reads the catalog. */
23
+ fragments(): Promise<RegionRow[]>;
22
24
  versions(id: number): Promise<BlockVersionMeta[]>;
23
25
  version(id: number, number: number): Promise<BlockVersion>;
24
26
  restore(id: number, number: number): Promise<BlockType>;
@@ -73,6 +75,11 @@ export interface RegionsApi {
73
75
  restoreVersion(name: string, number: number): Promise<RegionDetail>;
74
76
  /** The fallback view made into a block type, and one of it put into the draft. */
75
77
  adopt(name: string): Promise<RegionAdopted>;
78
+ /**
79
+ * A shared block's published tree with fresh keys, to put in a page in its place. Writes nothing;
80
+ * 409 while the shared block is not published.
81
+ */
82
+ copy(name: string): Promise<BlockNode[]>;
76
83
  }
77
84
  /** Everything under `/regions`, below the panel's API path. */
78
85
  export declare function createRegionsApi(admin: AdminContext): RegionsApi;
package/dist/content.d.ts CHANGED
@@ -44,6 +44,11 @@ export declare function cloneNode(node: BlockNode): BlockNode;
44
44
  * save says so.
45
45
  */
46
46
  export declare function setHidden(tree: BlockNode[], key: string, hidden: boolean): BlockNode[];
47
+ /**
48
+ * One block taken out and others put where it stood, in its list — what «Make it this page's own»
49
+ * does to a shared block. The tree as it was when the key is not in it.
50
+ */
51
+ export declare function swapNode(tree: BlockNode[], key: string, nodes: BlockNode[]): BlockNode[];
47
52
  export declare function insertNode(tree: BlockNode[], parentKey: string | null, field: string | null, index: number, node: BlockNode): BlockNode[];
48
53
  export declare function removeNode(tree: BlockNode[], key: string): BlockNode[];
49
54
  export declare function updateValues(tree: BlockNode[], key: string, values: Record<string, unknown>): BlockNode[];
package/dist/frame.d.ts CHANGED
@@ -15,14 +15,44 @@ export interface MarkerRange {
15
15
  }
16
16
  /** The pair of markers around a block, or null when the page does not hold it. */
17
17
  export declare function findRange(root: Node, key: string): MarkerRange | null;
18
+ /**
19
+ * The pair around a region — `<!--wx-region:name-->` — which the region's own preview prints
20
+ * whatever the region holds, its fallback included.
21
+ */
22
+ export declare function findRegion(root: Node, name: string): MarkerRange | null;
18
23
  /**
19
24
  * Swap the block's markup — markers included, since the new HTML carries its own — and let
20
25
  * the runtime mount whatever script the new markup needs. False when the key is not on the
21
26
  * page, which means the page has to be reloaded rather than patched.
22
27
  */
23
28
  export declare function replaceBlock(doc: Document, key: string, html: string): boolean;
24
- /** The first element a block prints — where a highlight goes. */
29
+ /**
30
+ * The element a block is pointed at by — the outline, the scroll: the first one it prints that
31
+ * takes room on the page. One that draws nothing at all, or where the layout cannot be measured,
32
+ * gives the first it prints that could.
33
+ */
25
34
  export declare function blockElement(root: Node, key: string): Element | null;
35
+ /**
36
+ * Where a region stands on the page: one box around everything it printed, in the page's own
37
+ * coordinates. Null when the page does not print it, or it printed nothing that takes room.
38
+ */
39
+ export declare function regionRect(doc: Document, name: string): {
40
+ top: number;
41
+ left: number;
42
+ width: number;
43
+ height: number;
44
+ } | null;
45
+ export declare const REGION_FRAME_ID = "wx-preview-region";
46
+ /**
47
+ * Draw a frame around a region of the page, or take it away (null).
48
+ *
49
+ * A box laid over the page rather than a class on an element, as a block has: a region is any
50
+ * number of blocks side by side, and wrapping them in an element of ours would break the site's
51
+ * own rules — `.site-main > section` stops matching the moment there is a `div` in between.
52
+ * Hangs off the root element and not the body, which a site may have positioned: there its top
53
+ * is the page's top, whatever the body's margins.
54
+ */
55
+ export declare function frameRegion(doc: Document, name: string | null): void;
26
56
  /** Mark one block as the selected one, and nothing else. Null clears the selection. */
27
57
  export declare function highlightBlock(doc: Document, key: string | null): Element | null;
28
58
  export declare const HIDDEN_CLASS = "wx-preview-hidden";
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  export { blocks, regions, type BlocksOptions, type RegionsOptions } from './module';
2
2
  export { createBlocksApi, createRegionsApi, createSiteBarBlocksApi, type BlocksApi, type RegionsApi, type SiteBarBlocksApi, } from './api';
3
3
  export { blocksMessages } from './messages';
4
- export { blocksPreviewKey, blocksTopKey, provideBlocksPreview, provideBlocksTop, useBlocksPreview, type BlocksPreview, type BlocksTop, } from './preview';
5
- export { cloneNode, countType, insertNode, isNode, isNodeList, locate, makeNode, newKey, removeNode, replaceList, typesIn, updateValues, walk, type Located, } from './content';
4
+ export { blocksFragmentKey, blocksPreviewKey, blocksTopKey, provideBlocksPreview, provideBlocksTop, useBlocksPreview, type BlocksFragmentHost, type BlocksPreview, type BlocksTop, } from './preview';
5
+ export { cloneNode, countType, insertNode, isNode, isNodeList, locate, makeNode, newKey, removeNode, replaceList, swapNode, typesIn, updateValues, walk, type Located, } from './content';
6
6
  export { lintBlock, undeclared } from './lint';
7
- export { findRange, highlightBlock, replaceBlock, stageDocument } from './frame';
7
+ export { findRange, findRegion, frameRegion, highlightBlock, regionRect, replaceBlock, stageDocument, } from './frame';
8
8
  export { callTag, formSchema, kindOf } from './schema';
9
9
  export { default as WxBlocks } from './BlocksField';
10
10
  export { default as WxBlocksSiteBarTab } from './BlocksSiteBarTab';
@@ -13,6 +13,7 @@ export { default as WxBlockEditorPage } from './BlockEditorPage';
13
13
  export { default as WxBlockPicker } from './BlockPicker';
14
14
  export { default as WxBlockThumb } from './BlockThumb';
15
15
  export { default as WxBlockStage } from './BlockStage';
16
+ export { default as WxFragmentField } from './FragmentField';
16
17
  export { default as WxRegionsPage } from './RegionsPage';
17
18
  export { default as WxRegionEditorPage } from './RegionEditorPage';
18
- export type { BlockContent, BlockInput, BlockKind, BlockList, BlockNode, BlockParent, BlockSource, BlocksMeta, BlockThumbnail, BlockType, BlockUsage, BlockVersion, BlockVersionMeta, DeclaredComponent, Lint, PublishRefusal, RegionAdopted, RegionConflict, RegionDetail, RegionRow, RegionVersion, RenderInput, RenderResult, ShapeField, } from './types';
19
+ export type { BlockContent, BlockInput, BlockKind, BlockList, BlockNode, BlockParent, BlockSource, BlocksMeta, BlockThumbnail, BlockType, BlockUsage, BlockVersion, BlockVersionMeta, DeclaredComponent, FragmentUse, Lint, PublishRefusal, RegionAdopted, RegionConflict, RegionDetail, RegionRow, RegionVersion, RenderInput, RenderResult, ShapeField, } from './types';