@formicoidea/labre-core 0.58.0 → 0.59.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 (167) hide show
  1. package/architecture/code.c4 +94 -65
  2. package/architecture/domain.c4 +11 -5
  3. package/dist/_pkgs/affine-block-attachment/edgeless-clipboard-config.d.ts +3 -2
  4. package/dist/_pkgs/affine-block-attachment/edgeless-clipboard-config.js +18 -13
  5. package/dist/_pkgs/affine-block-callout/adapters/markdown.js +4 -1
  6. package/dist/_pkgs/affine-block-code/adapters/html.js +1 -1
  7. package/dist/_pkgs/affine-block-code/adapters/markdown/preprocessor.js +13 -1
  8. package/dist/_pkgs/affine-block-code/adapters/notion-html.js +1 -1
  9. package/dist/_pkgs/affine-block-code/code-block.d.ts +17 -2
  10. package/dist/_pkgs/affine-block-code/code-block.js +28 -23
  11. package/dist/_pkgs/affine-block-code/code-toolbar/components/lang-button.js +17 -4
  12. package/dist/_pkgs/affine-block-code/code-toolbar/components/preview-button.js +1 -1
  13. package/dist/_pkgs/affine-block-data-view/data-source.js +12 -5
  14. package/dist/_pkgs/affine-block-edgeless-text/edgeless-clipboard-config.d.ts +3 -2
  15. package/dist/_pkgs/affine-block-edgeless-text/edgeless-clipboard-config.js +8 -5
  16. package/dist/_pkgs/affine-block-image/asset-picker.d.ts +23 -2
  17. package/dist/_pkgs/affine-block-image/asset-picker.js +52 -12
  18. package/dist/_pkgs/affine-block-image/configs/replace-action.d.ts +8 -5
  19. package/dist/_pkgs/affine-block-image/configs/replace-action.js +8 -8
  20. package/dist/_pkgs/affine-block-image/configs/toolbar.js +2 -1
  21. package/dist/_pkgs/affine-block-image/crop/crop-controller.d.ts +15 -0
  22. package/dist/_pkgs/affine-block-image/crop/crop-controller.js +40 -2
  23. package/dist/_pkgs/affine-block-image/crop/crop-math.d.ts +22 -0
  24. package/dist/_pkgs/affine-block-image/crop/crop-math.js +55 -2
  25. package/dist/_pkgs/affine-block-image/crop/crop-overlay.d.ts +17 -3
  26. package/dist/_pkgs/affine-block-image/crop/crop-overlay.js +64 -6
  27. package/dist/_pkgs/affine-block-image/edgeless-clipboard-config.d.ts +3 -2
  28. package/dist/_pkgs/affine-block-image/edgeless-clipboard-config.js +20 -14
  29. package/dist/_pkgs/affine-block-image/image-block.js +1 -0
  30. package/dist/_pkgs/affine-block-image/image-edgeless-block.js +3 -0
  31. package/dist/_pkgs/affine-block-image/index.d.ts +2 -0
  32. package/dist/_pkgs/affine-block-image/index.js +2 -0
  33. package/dist/_pkgs/affine-block-image/replace/commands.d.ts +68 -0
  34. package/dist/_pkgs/affine-block-image/replace/commands.js +200 -0
  35. package/dist/_pkgs/affine-block-image/replace/replace-model.d.ts +44 -0
  36. package/dist/_pkgs/affine-block-image/replace/replace-model.js +168 -0
  37. package/dist/_pkgs/affine-block-image/replace/toolbar.d.ts +21 -0
  38. package/dist/_pkgs/affine-block-image/replace/toolbar.js +159 -0
  39. package/dist/_pkgs/affine-block-image/translations.d.ts +15 -2
  40. package/dist/_pkgs/affine-block-image/translations.js +35 -2
  41. package/dist/_pkgs/affine-block-image/utils.d.ts +7 -0
  42. package/dist/_pkgs/affine-block-image/utils.js +13 -0
  43. package/dist/_pkgs/affine-block-image/view.js +7 -0
  44. package/dist/_pkgs/affine-block-note/components/edgeless-page-block-title.d.ts +14 -5
  45. package/dist/_pkgs/affine-block-note/components/edgeless-page-block-title.js +18 -11
  46. package/dist/_pkgs/affine-block-note/config.d.ts +9 -2
  47. package/dist/_pkgs/affine-block-note/edgeless-clipboard-config.d.ts +3 -2
  48. package/dist/_pkgs/affine-block-note/edgeless-clipboard-config.js +8 -5
  49. package/dist/_pkgs/affine-block-paragraph/adapters/markdown.js +11 -0
  50. package/dist/_pkgs/affine-block-root/commands/invisible-characters-commands.d.ts +17 -0
  51. package/dist/_pkgs/affine-block-root/commands/invisible-characters-commands.js +123 -0
  52. package/dist/_pkgs/affine-block-root/edgeless/clipboard/command.js +82 -65
  53. package/dist/_pkgs/affine-block-root/edgeless/edgeless-keyboard.js +2 -0
  54. package/dist/_pkgs/affine-block-root/index.d.ts +1 -0
  55. package/dist/_pkgs/affine-block-root/index.js +1 -0
  56. package/dist/_pkgs/affine-block-root/translations.d.ts +6 -0
  57. package/dist/_pkgs/affine-block-root/translations.js +10 -0
  58. package/dist/_pkgs/affine-block-root/view.js +6 -1
  59. package/dist/_pkgs/affine-block-surface/commands/index.d.ts +1 -1
  60. package/dist/_pkgs/affine-block-surface/commands/index.js +1 -1
  61. package/dist/_pkgs/affine-block-surface/commands/reassociate-connectors.d.ts +9 -0
  62. package/dist/_pkgs/affine-block-surface/commands/reassociate-connectors.js +21 -12
  63. package/dist/_pkgs/affine-block-surface/extensions/clipboard-config.d.ts +33 -0
  64. package/dist/_pkgs/affine-block-surface/extensions/clipboard-config.js +53 -0
  65. package/dist/_pkgs/affine-block-surface/framework-background/background-view.js +2 -1
  66. package/dist/_pkgs/affine-block-surface/framework-background/band-widths.d.ts +104 -0
  67. package/dist/_pkgs/affine-block-surface/framework-background/band-widths.js +156 -0
  68. package/dist/_pkgs/affine-block-surface/framework-background/def.d.ts +87 -4
  69. package/dist/_pkgs/affine-block-surface/framework-background/def.js +26 -7
  70. package/dist/_pkgs/affine-block-surface/framework-background/ellipsis.d.ts +58 -0
  71. package/dist/_pkgs/affine-block-surface/framework-background/ellipsis.js +110 -0
  72. package/dist/_pkgs/affine-block-surface/framework-background/index.d.ts +3 -0
  73. package/dist/_pkgs/affine-block-surface/framework-background/index.js +3 -0
  74. package/dist/_pkgs/affine-block-surface/framework-background/labels.d.ts +12 -2
  75. package/dist/_pkgs/affine-block-surface/framework-background/labels.js +29 -5
  76. package/dist/_pkgs/affine-block-surface/framework-background/measure-text.d.ts +14 -0
  77. package/dist/_pkgs/affine-block-surface/framework-background/measure-text.js +31 -0
  78. package/dist/_pkgs/affine-block-surface/framework-background/renderer.d.ts +14 -1
  79. package/dist/_pkgs/affine-block-surface/framework-background/renderer.js +84 -31
  80. package/dist/_pkgs/affine-block-table/adapters/html.js +26 -14
  81. package/dist/_pkgs/affine-block-table/adapters/utils.d.ts +1 -0
  82. package/dist/_pkgs/affine-block-table/adapters/utils.js +23 -5
  83. package/dist/_pkgs/affine-block-table/header-menu.d.ts +13 -0
  84. package/dist/_pkgs/affine-block-table/header-menu.js +25 -0
  85. package/dist/_pkgs/affine-block-table/selection-controller.d.ts +15 -0
  86. package/dist/_pkgs/affine-block-table/selection-controller.js +62 -0
  87. package/dist/_pkgs/affine-block-table/table-cell-css.d.ts +7 -0
  88. package/dist/_pkgs/affine-block-table/table-cell-css.js +10 -0
  89. package/dist/_pkgs/affine-block-table/table-cell.d.ts +8 -0
  90. package/dist/_pkgs/affine-block-table/table-cell.js +35 -3
  91. package/dist/_pkgs/affine-block-table/table-data-manager.d.ts +14 -0
  92. package/dist/_pkgs/affine-block-table/table-data-manager.js +44 -3
  93. package/dist/_pkgs/affine-block-table/translations.d.ts +14 -0
  94. package/dist/_pkgs/affine-block-table/translations.js +22 -0
  95. package/dist/_pkgs/affine-gfx-mindmap/toolbar/mindmap-tool-button.d.ts +2 -2
  96. package/dist/_pkgs/affine-gfx-template/builtin/other.d.ts +4 -0
  97. package/dist/_pkgs/affine-gfx-template/builtin/other.js +1 -1
  98. package/dist/_pkgs/affine-gfx-template/builtin/slides/build.d.ts +81 -0
  99. package/dist/_pkgs/affine-gfx-template/builtin/slides/build.js +276 -0
  100. package/dist/_pkgs/affine-gfx-template/builtin/slides/consts.d.ts +126 -0
  101. package/dist/_pkgs/affine-gfx-template/builtin/slides/consts.js +101 -0
  102. package/dist/_pkgs/affine-gfx-template/builtin/slides/index.d.ts +8 -0
  103. package/dist/_pkgs/affine-gfx-template/builtin/slides/index.js +27 -0
  104. package/dist/_pkgs/affine-gfx-template/builtin/slides/masks.d.ts +83 -0
  105. package/dist/_pkgs/affine-gfx-template/builtin/slides/masks.js +674 -0
  106. package/dist/_pkgs/affine-gfx-template/contribute.js +12 -17
  107. package/dist/_pkgs/affine-gfx-template/make-snapshot.d.ts +14 -2
  108. package/dist/_pkgs/affine-gfx-template/make-snapshot.js +6 -2
  109. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.d.ts +12 -0
  110. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.js +48 -0
  111. package/dist/_pkgs/affine-gfx-template/services/template.js +2 -1
  112. package/dist/_pkgs/affine-gfx-template/toolbar/builtin-templates.d.ts +15 -1
  113. package/dist/_pkgs/affine-gfx-template/toolbar/builtin-templates.js +33 -37
  114. package/dist/_pkgs/affine-gfx-template/toolbar/template-type.d.ts +6 -0
  115. package/dist/_pkgs/affine-gfx-template/translations.d.ts +94 -0
  116. package/dist/_pkgs/affine-gfx-template/translations.js +441 -2
  117. package/dist/_pkgs/affine-model/blocks/table/table-model.d.ts +4 -0
  118. package/dist/_pkgs/affine-model/blocks/table/table-model.js +4 -0
  119. package/dist/_pkgs/affine-model/elements/bpmn/node.d.ts +46 -3
  120. package/dist/_pkgs/affine-model/elements/bpmn/node.js +47 -4
  121. package/dist/_pkgs/affine-model/elements/bpmn/pool.d.ts +20 -0
  122. package/dist/_pkgs/affine-model/elements/bpmn/pool.js +33 -4
  123. package/dist/_pkgs/affine-shared/services/edit-props-store.d.ts +3 -16
  124. package/dist/_pkgs/affine-shared/services/edit-props-store.js +16 -16
  125. package/dist/_pkgs/affine-shared/services/editor-setting-service.d.ts +3 -0
  126. package/dist/_pkgs/affine-shared/services/editor-setting-service.js +4 -0
  127. package/dist/_pkgs/affine-shared/services/index.d.ts +1 -0
  128. package/dist/_pkgs/affine-shared/services/index.js +1 -0
  129. package/dist/_pkgs/affine-shared/services/invisible-characters.d.ts +33 -0
  130. package/dist/_pkgs/affine-shared/services/invisible-characters.js +63 -0
  131. package/dist/_pkgs/affine-shared/services/link-preview-service/link-preview-cache.d.ts +0 -9
  132. package/dist/_pkgs/affine-shared/services/link-preview-service/link-preview-cache.js +3 -9
  133. package/dist/_pkgs/affine-shared/services/telemetry-service/lifecycle.d.ts +26 -0
  134. package/dist/_pkgs/affine-shared/services/telemetry-service/telemetry-service.d.ts +4 -3
  135. package/dist/_pkgs/affine-shared/services/telemetry-service/types.d.ts +11 -0
  136. package/dist/_pkgs/affine-shared/utils/index.d.ts +1 -0
  137. package/dist/_pkgs/affine-shared/utils/index.js +1 -0
  138. package/dist/_pkgs/affine-shared/utils/invisible-characters.d.ts +42 -0
  139. package/dist/_pkgs/affine-shared/utils/invisible-characters.js +81 -0
  140. package/dist/_pkgs/affine-widget-edgeless-zoom-toolbar/zoom-toolbar.js +13 -2
  141. package/dist/_pkgs/data-view/view-presets/table/pc/header/column-header.js +6 -0
  142. package/dist/_pkgs/data-view/view-presets/table/pc/table-view-ui-logic.js +5 -2
  143. package/dist/_pkgs/std/clipboard/clipboard.d.ts +15 -1
  144. package/dist/_pkgs/std/clipboard/clipboard.js +18 -0
  145. package/dist/_pkgs/std/inline/components/embed-gap.js +1 -1
  146. package/dist/_pkgs/std/inline/components/v-line.js +1 -1
  147. package/dist/_pkgs/std/inline/components/v-text.d.ts +15 -2
  148. package/dist/_pkgs/std/inline/components/v-text.js +147 -15
  149. package/dist/_pkgs/std/inline/consts.d.ts +5 -0
  150. package/dist/_pkgs/std/inline/consts.js +5 -0
  151. package/dist/_pkgs/std/inline/utils/index.d.ts +1 -0
  152. package/dist/_pkgs/std/inline/utils/index.js +1 -0
  153. package/dist/_pkgs/std/inline/utils/invisible-characters.d.ts +57 -0
  154. package/dist/_pkgs/std/inline/utils/invisible-characters.js +162 -0
  155. package/dist/_pkgs/std/inline/utils/point-conversion.js +3 -3
  156. package/dist/_pkgs/std/inline/utils/text.d.ts +8 -0
  157. package/dist/_pkgs/std/inline/utils/text.js +11 -2
  158. package/dist/_pkgs/store/model/store/crud.d.ts +28 -0
  159. package/dist/_pkgs/store/model/store/crud.js +97 -30
  160. package/dist/_pkgs/store/model/store/query.js +3 -2
  161. package/dist/_pkgs/store/model/store/store.d.ts +21 -0
  162. package/dist/_pkgs/store/model/store/store.js +88 -21
  163. package/dist/_pkgs/store/transformer/transformer.d.ts +46 -0
  164. package/dist/_pkgs/store/transformer/transformer.js +72 -0
  165. package/dist/commands.js +6 -1
  166. package/dist/translations.js +2 -0
  167. package/package.json +3 -4
@@ -1,6 +1,6 @@
1
1
  import { FrameTemplateProvider, } from '../affine-shared/services/index.js';
2
2
  import { createIdentifier } from '../global/di/index.js';
3
- import { builtInTemplates } from './toolbar/builtin-templates.js';
3
+ import { builtInTemplates, loadTemplates, templateMatches, templates as builtInCategories, } from './toolbar/builtin-templates.js';
4
4
  import { resolveTemplateName } from './toolbar/resolve-name.js';
5
5
  import { TEMPLATE_PANEL_CATEGORY_SAVED_FRAMES } from './translations.js';
6
6
  /**
@@ -70,11 +70,6 @@ function savedFramesCategory(std) {
70
70
  templates: async () => (await service.list()).map(saved => savedFrameTemplate(service, saved)),
71
71
  };
72
72
  }
73
- function loadCategory(category) {
74
- return Array.isArray(category.templates)
75
- ? Promise.resolve(category.templates)
76
- : category.templates();
77
- }
78
73
  /**
79
74
  * The catalogue ONE editor sees: the built-in `Other`, then the categories
80
75
  * the view extensions mounted on this `std` registered — i.e. exactly the
@@ -103,22 +98,22 @@ export function templateManagerFor(std) {
103
98
  list: async (name) => {
104
99
  const category = byName(name);
105
100
  return [
106
- ...(category ? await loadCategory(category) : []),
101
+ ...(category ? await loadTemplates(category) : []),
107
102
  ...(await builtInTemplates.list(name)),
108
103
  ];
109
104
  },
110
105
  search: async (keyword, name) => {
111
- const k = keyword.trim().toLocaleLowerCase();
112
- const pool = name ? [byName(name)].filter(c => !!c) : contributed;
113
- // Matches the ENGLISH name (`templateFromCommand`'s baked-in `name`,
114
- // still what a catalogue-less playground shows) or the host's own
115
- // translation of it (`resolveTemplateName`, through the command's
116
- // `labelKey`) — a search box must not go blind on a translated tile.
117
- const own = (await Promise.all(pool.map(loadCategory)))
106
+ // Built-in first, then contributed: the tab order. One pool and one
107
+ // predicate for both halves, so `Other` is searched exactly like a
108
+ // framework's category — the ENGLISH name (`templateFromCommand`'s
109
+ // baked-in `name`, still what a catalogue-less playground shows) or the
110
+ // host's own translation of it (`resolveTemplateName`, through the
111
+ // tile's `nameKey` or the command's `labelKey`): a search box must not
112
+ // go blind on a translated tile.
113
+ const pool = [...builtInCategories, ...contributed].filter(c => !name || c.name === name);
114
+ return (await Promise.all(pool.map(loadTemplates)))
118
115
  .flat()
119
- .filter(t => t.name?.toLocaleLowerCase().includes(k) ||
120
- resolveTemplateName(std, t).toLocaleLowerCase().includes(k));
121
- return [...(await builtInTemplates.search(keyword, name)), ...own];
116
+ .filter(t => templateMatches(t, keyword, resolveTemplateName(std, t)));
122
117
  },
123
118
  };
124
119
  }
@@ -1,5 +1,13 @@
1
1
  /** A surface-elements map as it appears inside a template's DocSnapshot. */
2
2
  export type SurfaceElementsJSON = Record<string, Record<string, unknown>>;
3
+ /** A block the surface holds (a frame), as it appears inside a DocSnapshot. */
4
+ export type SurfaceChildBlockJSON = {
5
+ type: 'block';
6
+ id: string;
7
+ flavour: string;
8
+ props: Record<string, unknown>;
9
+ children: [];
10
+ };
3
11
  /**
4
12
  * Serialize a plain string into the surface `Y.Text` JSON form used inside
5
13
  * snapshots (the shape inner-text / label field). Mirrors what
@@ -31,8 +39,12 @@ export declare function surfaceYMap(json: Record<string, unknown>): {
31
39
  * (group-aware) and only then mints fresh keys — and it skips any element that
32
40
  * carries no `index` at all. So a missing `index` is filled in here, in key
33
41
  * (insertion) order, which is the order a creation action added the elements.
42
+ *
43
+ * `blocks` are the surface's own child blocks — a slide mask's frame. They
44
+ * keep the props they are given: the template job remaps their ids, their
45
+ * `childElementIds` and their `index` on insert like any frame's.
34
46
  */
35
- export declare function makeTemplateSnapshot(elements: SurfaceElementsJSON, title?: string): {
47
+ export declare function makeTemplateSnapshot(elements: SurfaceElementsJSON, title?: string, blocks?: SurfaceChildBlockJSON[]): {
36
48
  type: string;
37
49
  meta: {
38
50
  id: string;
@@ -59,7 +71,7 @@ export declare function makeTemplateSnapshot(elements: SurfaceElementsJSON, titl
59
71
  props: {
60
72
  elements: SurfaceElementsJSON;
61
73
  };
62
- children: never[];
74
+ children: SurfaceChildBlockJSON[];
63
75
  }[];
64
76
  };
65
77
  };
@@ -32,8 +32,12 @@ export function surfaceYMap(json) {
32
32
  * (group-aware) and only then mints fresh keys — and it skips any element that
33
33
  * carries no `index` at all. So a missing `index` is filled in here, in key
34
34
  * (insertion) order, which is the order a creation action added the elements.
35
+ *
36
+ * `blocks` are the surface's own child blocks — a slide mask's frame. They
37
+ * keep the props they are given: the template job remaps their ids, their
38
+ * `childElementIds` and their `index` on insert like any frame's.
35
39
  */
36
- export function makeTemplateSnapshot(elements, title = 'Template') {
40
+ export function makeTemplateSnapshot(elements, title = 'Template', blocks = []) {
37
41
  const indexed = {};
38
42
  let last = null;
39
43
  for (const [id, element] of Object.entries(elements)) {
@@ -81,7 +85,7 @@ export function makeTemplateSnapshot(elements, title = 'Template') {
81
85
  id: 'block:template-surface',
82
86
  flavour: 'affine:surface',
83
87
  props: { elements: indexed },
84
- children: [],
88
+ children: blocks,
85
89
  },
86
90
  ],
87
91
  },
@@ -10,6 +10,18 @@ import type { TemplateJob } from './template.js';
10
10
  */
11
11
  export declare const createActiveLayerMiddleware: (std: BlockStdScope) => (job: TemplateJob) => void;
12
12
  export declare const replaceIdMiddleware: (job: TemplateJob) => void;
13
+ /**
14
+ * Every inserted frame takes a fresh `presentationIndex` AFTER the last frame
15
+ * of the document, the template's frames keeping their relative order. A
16
+ * saved frame's snapshot carries its source's key, so without this the copy
17
+ * shared the source's slideshow position, and so did every further insertion;
18
+ * the clipboard has always minted fresh keys on paste
19
+ * (`EdgelessClipboardFrameConfig`, `newPresentationIndexes`).
20
+ *
21
+ * Keyed by the snapshot OBJECT, not its id, so it works on either side of
22
+ * `replaceIdMiddleware` (`template-presentation-index.unit.spec.ts`).
23
+ */
24
+ export declare const createPresentationIndexMiddleware: (job: TemplateJob) => void;
13
25
  export declare const createInsertPlaceMiddleware: (targetPlace: Bound) => (job: TemplateJob) => void;
14
26
  export declare const createStickerMiddleware: (center: {
15
27
  x: number;
@@ -1,6 +1,7 @@
1
1
  import { applyCreationLayer, generateElementId, sortIndex, } from '../../affine-block-surface/index.js';
2
2
  import { Bound } from '../../global/gfx/index.js';
3
3
  import { assertType } from '../../global/utils/index.js';
4
+ import { generateKeyBetweenV2 } from '../../std/gfx/index.js';
4
5
  /**
5
6
  * Everything a template inserts lands in the viewer's active layer (ADR 0031
6
7
  * §6). The insertion bypasses both stamped paths — its elements are merged
@@ -126,6 +127,53 @@ export const replaceIdMiddleware = (job) => {
126
127
  }
127
128
  };
128
129
  };
130
+ /**
131
+ * Every inserted frame takes a fresh `presentationIndex` AFTER the last frame
132
+ * of the document, the template's frames keeping their relative order. A
133
+ * saved frame's snapshot carries its source's key, so without this the copy
134
+ * shared the source's slideshow position, and so did every further insertion;
135
+ * the clipboard has always minted fresh keys on paste
136
+ * (`EdgelessClipboardFrameConfig`, `newPresentationIndexes`).
137
+ *
138
+ * Keyed by the snapshot OBJECT, not its id, so it works on either side of
139
+ * `replaceIdMiddleware` (`template-presentation-index.unit.spec.ts`).
140
+ */
141
+ export const createPresentationIndexMiddleware = (job) => {
142
+ const fresh = new Map();
143
+ const keyOf = (props) => typeof props.presentationIndex === 'string' ? props.presentationIndex : '';
144
+ job.slots.beforeInsert.subscribe(payload => {
145
+ if (payload.type === 'template') {
146
+ const inserted = [];
147
+ job.walk(block => {
148
+ if (block.flavour === 'affine:frame')
149
+ inserted.push(block);
150
+ });
151
+ if (!inserted.length)
152
+ return;
153
+ // The document's frames are all still the existing ones here.
154
+ let last = null;
155
+ for (const model of job.model.store.getModelsByFlavour('affine:frame')) {
156
+ const key = keyOf(model.props);
157
+ if (key && (last === null || key > last))
158
+ last = key;
159
+ }
160
+ inserted
161
+ .sort((a, b) => {
162
+ const ka = keyOf(a.props);
163
+ const kb = keyOf(b.props);
164
+ return ka < kb ? -1 : ka > kb ? 1 : 0;
165
+ })
166
+ .forEach(block => {
167
+ last = generateKeyBetweenV2(last, null);
168
+ fresh.set(block, last);
169
+ });
170
+ return;
171
+ }
172
+ const key = fresh.get(payload.data.blockJson);
173
+ if (key)
174
+ payload.data.blockJson.props.presentationIndex = key;
175
+ });
176
+ };
129
177
  export const createInsertPlaceMiddleware = (targetPlace) => {
130
178
  return (job) => {
131
179
  if (job.type !== 'template')
@@ -5,7 +5,7 @@ import { assertType } from '../../global/utils/index.js';
5
5
  import { GfxControllerIdentifier } from '../../std/gfx/index.js';
6
6
  import { DocSnapshotSchema, } from '../../store/index.js';
7
7
  import { Subject } from 'rxjs';
8
- import { createActiveLayerMiddleware, createInsertPlaceMiddleware, createRegenerateIndexMiddleware, createStickerMiddleware, replaceIdMiddleware, } from './template-middlewares.js';
8
+ import { createActiveLayerMiddleware, createInsertPlaceMiddleware, createPresentationIndexMiddleware, createRegenerateIndexMiddleware, createStickerMiddleware, replaceIdMiddleware, } from './template-middlewares.js';
9
9
  /**
10
10
  * Those block contains other block's id
11
11
  * should defer the loading
@@ -238,6 +238,7 @@ export function createTemplateJob(std, type, center) {
238
238
  }
239
239
  const idxGenerator = layer.createIndexGenerator();
240
240
  middlewares.push(createRegenerateIndexMiddleware(() => idxGenerator()));
241
+ middlewares.push(createPresentationIndexMiddleware);
241
242
  }
242
243
  if (type === 'sticker') {
243
244
  middlewares.push(createStickerMiddleware(center || viewport.center, () => layer.generateIndex()));
@@ -1,7 +1,21 @@
1
1
  import type { Template, TemplateCategory } from './template-type.js';
2
2
  export declare const templates: TemplateCategory[];
3
+ /** A category's pack, whichever of its two shapes (array or thunk) it has. */
4
+ export declare function loadTemplates(category: TemplateCategory): Promise<Template[]>;
3
5
  /**
4
- * The catalogue every editor has, whatever is mounted: `Other`. A host or a
6
+ * The ONE search predicate of the Templates panel, built-in and contributed
7
+ * categories alike: a case-insensitive substring of the English `name` (the
8
+ * stable identity, what a catalogue-less playground shows) or of the
9
+ * displayed name the caller resolved through the translation seam.
10
+ *
11
+ * Until 0.58 the built-in half matched the keyword against
12
+ * `Object.entries(templates)` of an ARRAY, i.e. against "0", "1", … — SWOT,
13
+ * Kanban, BMC, Fishbone and Gantt were unfindable, and a lazy built-in
14
+ * category's results were dropped (`template-search.unit.spec.ts`).
15
+ */
16
+ export declare function templateMatches(template: Template, keyword: string, displayName?: string): boolean;
17
+ /**
18
+ * The catalogue every editor has, whatever is mounted: `Other` and `Slides`. A host or a
5
19
  * framework adds a category per editor with `TemplateCategoryExtension`; the
6
20
  * module-level `extend(...)` this object carried until 0.49 appended for every
7
21
  * editor of the page and was never emptied.
@@ -1,23 +1,32 @@
1
1
  import { otherTemplateCategory } from '../builtin/other.js';
2
- export const templates = [otherTemplateCategory];
3
- function lcs(text1, text2) {
4
- const dp = Array.from({
5
- length: text1.length + 1,
6
- }, () => Array.from({ length: text2.length + 1 }, () => 0));
7
- for (let i = 1; i <= text1.length; i++) {
8
- for (let j = 1; j <= text2.length; j++) {
9
- if (text1[i - 1] === text2[j - 1]) {
10
- dp[i][j] = dp[i - 1][j - 1] + 1;
11
- }
12
- else {
13
- dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
14
- }
15
- }
16
- }
17
- return dp[text1.length][text2.length];
2
+ import { slidesTemplateCategory } from '../builtin/slides/index.js';
3
+ export const templates = [
4
+ otherTemplateCategory,
5
+ slidesTemplateCategory,
6
+ ];
7
+ /** A category's pack, whichever of its two shapes (array or thunk) it has. */
8
+ export function loadTemplates(category) {
9
+ return Array.isArray(category.templates)
10
+ ? Promise.resolve(category.templates)
11
+ : category.templates();
18
12
  }
19
13
  /**
20
- * The catalogue every editor has, whatever is mounted: `Other`. A host or a
14
+ * The ONE search predicate of the Templates panel, built-in and contributed
15
+ * categories alike: a case-insensitive substring of the English `name` (the
16
+ * stable identity, what a catalogue-less playground shows) or of the
17
+ * displayed name the caller resolved through the translation seam.
18
+ *
19
+ * Until 0.58 the built-in half matched the keyword against
20
+ * `Object.entries(templates)` of an ARRAY, i.e. against "0", "1", … — SWOT,
21
+ * Kanban, BMC, Fishbone and Gantt were unfindable, and a lazy built-in
22
+ * category's results were dropped (`template-search.unit.spec.ts`).
23
+ */
24
+ export function templateMatches(template, keyword, displayName) {
25
+ const k = keyword.trim().toLocaleLowerCase();
26
+ return [template.name, displayName].some(name => name !== undefined && name.toLocaleLowerCase().includes(k));
27
+ }
28
+ /**
29
+ * The catalogue every editor has, whatever is mounted: `Other` and `Slides`. A host or a
21
30
  * framework adds a category per editor with `TemplateCategoryExtension`; the
22
31
  * module-level `extend(...)` this object carried until 0.49 appended for every
23
32
  * editor of the page and was never emptied.
@@ -27,29 +36,16 @@ export const builtInTemplates = {
27
36
  const cate = templates.find(cate => cate.name === category);
28
37
  if (!cate)
29
38
  return [];
30
- return cate.templates instanceof Function
31
- ? cate.templates()
32
- : cate.templates;
39
+ return loadTemplates(cate);
33
40
  },
34
41
  categories: async () => templates.map(cate => cate.name),
35
42
  categoryLabel: (name) => templates.find(cate => cate.name === name)?.nameKey,
43
+ // No `std` here, so the English name only; `templateManagerFor` (what the
44
+ // panel reads) also matches the translated name.
36
45
  search: async (keyword, cateName) => {
37
- const candidates = [];
38
- keyword = keyword.trim().toLocaleLowerCase();
39
- await Promise.all(templates.map(async (categroy) => {
40
- if (cateName && cateName !== categroy.name) {
41
- return;
42
- }
43
- if (categroy.templates instanceof Function) {
44
- return categroy.templates();
45
- }
46
- return Promise.all(Object.entries(categroy.templates).map(async ([name, template]) => {
47
- if (lcs(keyword, name.toLocaleLowerCase()) ===
48
- keyword.length) {
49
- candidates.push(template);
50
- }
51
- }));
52
- }));
53
- return candidates;
46
+ const pool = templates.filter(c => !cateName || c.name === cateName);
47
+ return (await Promise.all(pool.map(loadTemplates)))
48
+ .flat()
49
+ .filter(t => templateMatches(t, keyword));
54
50
  },
55
51
  };
@@ -42,6 +42,12 @@ export type Template = {
42
42
  * shipped template declares both today.
43
43
  */
44
44
  nameKey?: string;
45
+ /**
46
+ * Plain English words a search may match besides the name ("cover",
47
+ * "agenda", "kpi"), like `CommandDescriptor.keywords`. Not displayed, so
48
+ * not keyed: they widen what a search finds, they never label anything.
49
+ */
50
+ keywords?: string[];
45
51
  /**
46
52
  * Rebuild {@link content} in the inserting editor's language — the seeds a
47
53
  * template writes into the document (a component's name, a lane's title) go
@@ -30,6 +30,100 @@ export declare const TEMPLATE_NAME_KANBAN_BOARD: ChromeWording;
30
30
  export declare const TEMPLATE_NAME_BUSINESS_MODEL_CANVAS: ChromeWording;
31
31
  export declare const TEMPLATE_NAME_FISHBONE: ChromeWording;
32
32
  export declare const TEMPLATE_NAME_GANTT_CHART: ChromeWording;
33
+ export declare const TEMPLATE_PANEL_CATEGORY_SLIDES: ChromeWording;
34
+ export declare const SLIDE_NAME_COVER: ChromeWording;
35
+ export declare const SLIDE_NAME_COVER_IMAGE: ChromeWording;
36
+ export declare const SLIDE_NAME_SECTION: ChromeWording;
37
+ export declare const SLIDE_NAME_STATEMENT: ChromeWording;
38
+ export declare const SLIDE_NAME_TEXT_IMAGE: ChromeWording;
39
+ export declare const SLIDE_NAME_FULL_IMAGE: ChromeWording;
40
+ export declare const SLIDE_NAME_TWO_COLUMNS: ChromeWording;
41
+ export declare const SLIDE_NAME_THREE_COLUMNS: ChromeWording;
42
+ export declare const SLIDE_NAME_SIX_POINTS: ChromeWording;
43
+ export declare const SLIDE_NAME_IMAGE_CARDS: ChromeWording;
44
+ export declare const SLIDE_NAME_AGENDA: ChromeWording;
45
+ /** An alias (L7 dedupe): the quote block's own word, one key. */
46
+ export declare const SLIDE_NAME_QUOTE: ChromeWording;
47
+ export declare const SLIDE_NAME_TESTIMONIALS: ChromeWording;
48
+ export declare const SLIDE_NAME_TEAM: ChromeWording;
49
+ export declare const SLIDE_NAME_CONTACT: ChromeWording;
50
+ export declare const SLIDE_NAME_ORG_CHART: ChromeWording;
51
+ export declare const SLIDE_NAME_KEY_FIGURES: ChromeWording;
52
+ export declare const SLIDE_NAME_TIMELINE: ChromeWording;
53
+ export declare const SLIDE_NAME_ROADMAP: ChromeWording;
54
+ export declare const SLIDE_NAME_PROCESS: ChromeWording;
55
+ export declare const SLIDE_NAME_MATRIX: ChromeWording;
56
+ export declare const SLIDE_NAME_VENN: ChromeWording;
57
+ export declare const SLIDE_NAME_MARKET_SIZE: ChromeWording;
58
+ export declare const SLIDE_NAME_PRICING: ChromeWording;
59
+ export declare const SLIDE_NAME_LOGO_WALL: ChromeWording;
60
+ export declare const SLIDE_NAME_GANTT: ChromeWording;
61
+ export declare const SLIDE_NAME_CHART_TEXT: ChromeWording;
62
+ export declare const SLIDE_NAME_THREE_CHARTS: ChromeWording;
63
+ export declare const SLIDE_NAME_COLLAGE: ChromeWording;
64
+ export declare const SLIDE_NAME_BENTO: ChromeWording;
65
+ export declare const SLIDE_NAME_IMAGE_GRID: ChromeWording;
66
+ export declare const SLIDE_NAME_FEATURE_BENTO: ChromeWording;
67
+ export declare const SLIDE_NAME_PHONE: ChromeWording;
68
+ export declare const SLIDE_NAME_TABLET: ChromeWording;
69
+ /**
70
+ * The slide-mask tile names this package declares (the quote slide's is the
71
+ * quote block's own, declared in `chrome.ts`).
72
+ */
73
+ export declare const SLIDE_NAME_WORDINGS: readonly ChromeWording[];
74
+ /** The seeds a slide mask writes into the document, shared by every mask. */
75
+ export declare const SLIDE_SEED_EYEBROW: ChromeWording;
76
+ export declare const SLIDE_SEED_COVER_TITLE: ChromeWording;
77
+ export declare const SLIDE_SEED_DATE: ChromeWording;
78
+ export declare const SLIDE_SEED_TITLE: ChromeWording;
79
+ export declare const SLIDE_SEED_SUBTITLE: ChromeWording;
80
+ export declare const SLIDE_SEED_SECTION_TITLE: ChromeWording;
81
+ export declare const SLIDE_SEED_SECTION_SUBTITLE: ChromeWording;
82
+ export declare const SLIDE_SEED_STATEMENT: ChromeWording;
83
+ export declare const SLIDE_SEED_HEADING: ChromeWording;
84
+ export declare const SLIDE_SEED_BODY: ChromeWording;
85
+ export declare const SLIDE_SEED_IMAGE: ChromeWording;
86
+ export declare const SLIDE_SEED_CAPTION: ChromeWording;
87
+ export declare const SLIDE_SEED_FOOTER: ChromeWording;
88
+ export declare const SLIDE_SEED_AGENDA_TITLE: ChromeWording;
89
+ export declare const SLIDE_SEED_AGENDA_ITEM: ChromeWording;
90
+ export declare const SLIDE_SEED_QUOTE: ChromeWording;
91
+ export declare const SLIDE_SEED_QUOTE_AUTHOR: ChromeWording;
92
+ export declare const SLIDE_SEED_TESTIMONIALS_TITLE: ChromeWording;
93
+ export declare const SLIDE_SEED_TEAM_TITLE: ChromeWording;
94
+ export declare const SLIDE_SEED_PERSON_NAME: ChromeWording;
95
+ export declare const SLIDE_SEED_PERSON_ROLE: ChromeWording;
96
+ export declare const SLIDE_SEED_CONTACT_TITLE: ChromeWording;
97
+ export declare const SLIDE_SEED_CONTACT_ADDRESS: ChromeWording;
98
+ export declare const SLIDE_SEED_CONTACT_PHONE: ChromeWording;
99
+ export declare const SLIDE_SEED_CONTACT_EMAIL: ChromeWording;
100
+ export declare const SLIDE_SEED_CONTACT_VALUE: ChromeWording;
101
+ export declare const SLIDE_SEED_FIGURE: ChromeWording;
102
+ export declare const SLIDE_SEED_DETAIL: ChromeWording;
103
+ export declare const SLIDE_SEED_FIGURE_LABEL: ChromeWording;
104
+ export declare const SLIDE_SEED_MILESTONE: ChromeWording;
105
+ export declare const SLIDE_SEED_QUARTER: ChromeWording;
106
+ export declare const SLIDE_SEED_STEP: ChromeWording;
107
+ export declare const SLIDE_SEED_AXIS_VALUE: ChromeWording;
108
+ export declare const SLIDE_SEED_AXIS_EFFORT: ChromeWording;
109
+ export declare const SLIDE_SEED_QUADRANT: ChromeWording;
110
+ export declare const SLIDE_SEED_VENN_IDEA: ChromeWording;
111
+ export declare const SLIDE_SEED_VENN_OTHER: ChromeWording;
112
+ export declare const SLIDE_SEED_VENN_OVERLAP: ChromeWording;
113
+ export declare const SLIDE_SEED_MARKET_TOTAL: ChromeWording;
114
+ export declare const SLIDE_SEED_MARKET_SERVICEABLE: ChromeWording;
115
+ export declare const SLIDE_SEED_MARKET_OBTAINABLE: ChromeWording;
116
+ export declare const SLIDE_SEED_PLAN: ChromeWording;
117
+ export declare const SLIDE_SEED_PRICE: ChromeWording;
118
+ export declare const SLIDE_SEED_FEATURE: ChromeWording;
119
+ export declare const SLIDE_SEED_LOGO: ChromeWording;
120
+ /** The label of a chart placeholder: a dashed zone, like a picture's. */
121
+ export declare const SLIDE_SEED_CHART: ChromeWording;
122
+ /** The label of a device mockup's screen zone. */
123
+ export declare const SLIDE_SEED_SCREEN: ChromeWording;
124
+ export declare const SLIDE_SEED_TASK: ChromeWording;
125
+ export declare const SLIDE_SEED_MONTH: ChromeWording;
126
+ export declare const SLIDE_SEED_WORDINGS: readonly ChromeWording[];
33
127
  export declare const TEMPLATE_PACKAGE_WORDINGS: readonly ChromeWording[];
34
128
  /**
35
129
  * The generic ("Other") diagrams' own seeds: the captions painted onto the