@formicoidea/labre-core 0.47.0 → 0.48.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 (72) hide show
  1. package/dist/_pkgs/affine-block-attachment/configs/slash-menu.js +2 -2
  2. package/dist/_pkgs/affine-block-attachment/translations.js +2 -2
  3. package/dist/_pkgs/affine-block-database/view.js +5 -0
  4. package/dist/_pkgs/affine-block-embed/embed-html-block/configs/toolbar.js +1 -1
  5. package/dist/_pkgs/affine-block-embed/embed-iframe-block/configs/toolbar.d.ts +1 -1
  6. package/dist/_pkgs/affine-block-embed/embed-iframe-block/configs/toolbar.js +1 -1
  7. package/dist/_pkgs/affine-block-embed/translations.d.ts +1 -1
  8. package/dist/_pkgs/affine-block-embed/translations.js +2 -2
  9. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/configs/new-doc.d.ts +25 -0
  10. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/configs/new-doc.js +71 -0
  11. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/configs/slash-menu.js +9 -17
  12. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/configs/toolbar.js +1 -1
  13. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/configs/toolbar.js +3 -3
  14. package/dist/_pkgs/affine-block-embed-doc/translations.d.ts +1 -1
  15. package/dist/_pkgs/affine-block-embed-doc/translations.js +8 -8
  16. package/dist/_pkgs/affine-block-frame/frame-toolbar.js +2 -2
  17. package/dist/_pkgs/affine-block-frame/translations.js +1 -1
  18. package/dist/_pkgs/affine-block-note/translations.js +8 -8
  19. package/dist/_pkgs/affine-block-root/commands/copy-link-commands.js +2 -2
  20. package/dist/_pkgs/affine-block-root/configs/toolbar.d.ts +1 -1
  21. package/dist/_pkgs/affine-block-root/configs/toolbar.js +1 -1
  22. package/dist/_pkgs/affine-block-root/edgeless/configs/toolbar/misc.d.ts +1 -1
  23. package/dist/_pkgs/affine-block-root/edgeless/configs/toolbar/more.d.ts +1 -1
  24. package/dist/_pkgs/affine-block-root/edgeless/configs/toolbar/more.js +1 -1
  25. package/dist/_pkgs/affine-block-root/translations.d.ts +1 -1
  26. package/dist/_pkgs/affine-block-root/translations.js +2 -2
  27. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.js +1 -1
  28. package/dist/_pkgs/affine-block-surface/extensions/interchange-import.js +1 -1
  29. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.js +1 -1
  30. package/dist/_pkgs/affine-block-surface/renderer/element-highlight-overlay.d.ts +8 -2
  31. package/dist/_pkgs/affine-block-surface/renderer/element-highlight-overlay.js +11 -13
  32. package/dist/_pkgs/affine-block-surface-ref/translations.js +8 -8
  33. package/dist/_pkgs/affine-components/translations.js +6 -6
  34. package/dist/_pkgs/affine-fragment-doc-title/index.d.ts +1 -1
  35. package/dist/_pkgs/affine-fragment-doc-title/index.js +1 -1
  36. package/dist/_pkgs/affine-fragment-doc-title/title-band/band-cell.d.ts +22 -0
  37. package/dist/_pkgs/affine-fragment-doc-title/title-band/band-cell.js +125 -0
  38. package/dist/_pkgs/affine-fragment-doc-title/title-band/format.d.ts +7 -19
  39. package/dist/_pkgs/affine-fragment-doc-title/title-band/format.js +0 -38
  40. package/dist/_pkgs/affine-fragment-doc-title/title-band/show-here.d.ts +19 -0
  41. package/dist/_pkgs/affine-fragment-doc-title/title-band/show-here.js +61 -0
  42. package/dist/_pkgs/affine-fragment-doc-title/title-band/title-band.d.ts +28 -18
  43. package/dist/_pkgs/affine-fragment-doc-title/title-band/title-band.js +225 -207
  44. package/dist/_pkgs/affine-fragment-doc-title/translations.d.ts +7 -4
  45. package/dist/_pkgs/affine-fragment-doc-title/translations.js +12 -9
  46. package/dist/_pkgs/affine-gfx-group/toolbar/config.d.ts +2 -2
  47. package/dist/_pkgs/affine-gfx-group/toolbar/config.js +2 -2
  48. package/dist/_pkgs/affine-gfx-group/translations.js +1 -1
  49. package/dist/_pkgs/affine-gfx-note/translations.js +2 -2
  50. package/dist/_pkgs/affine-shared/services/linked-doc-creation-service.d.ts +15 -6
  51. package/dist/_pkgs/affine-shared/services/title-band-service.d.ts +10 -7
  52. package/dist/_pkgs/affine-shared/services/translation-service/chrome.d.ts +3 -3
  53. package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +17 -17
  54. package/dist/_pkgs/affine-shared/utils/model/doc.d.ts +10 -2
  55. package/dist/_pkgs/affine-shared/utils/model/doc.js +17 -7
  56. package/dist/_pkgs/affine-widget-edgeless-auto-connect/translations.js +2 -2
  57. package/dist/_pkgs/affine-widget-edgeless-selected-rect/translations.js +1 -1
  58. package/dist/_pkgs/affine-widget-linked-doc/translations.js +3 -3
  59. package/dist/_pkgs/affine-widget-slash-menu/translations.js +1 -1
  60. package/dist/_pkgs/data-view/core/component/tags/multi-tag-select.d.ts +7 -2
  61. package/dist/_pkgs/data-view/core/component/tags/multi-tag-select.js +22 -15
  62. package/dist/_pkgs/data-view/core/effect.js +2 -0
  63. package/dist/_pkgs/data-view/core/property/index.d.ts +1 -0
  64. package/dist/_pkgs/data-view/core/property/index.js +1 -0
  65. package/dist/_pkgs/data-view/core/property/standalone-cell.d.ts +95 -0
  66. package/dist/_pkgs/data-view/core/property/standalone-cell.js +306 -0
  67. package/dist/_pkgs/data-view/core/view-manager/property.d.ts +6 -0
  68. package/dist/_pkgs/data-view/property-presets/multi-select/cell-renderer.js +1 -1
  69. package/dist/_pkgs/data-view/property-presets/select/cell-renderer.js +1 -1
  70. package/dist/_pkgs/data-view/property-presets/text/cell-renderer.js +3 -1
  71. package/dist/translations.js +1 -1
  72. package/package.json +1 -1
@@ -0,0 +1,306 @@
1
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
2
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
3
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
4
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
5
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
6
+ var _, done = false;
7
+ for (var i = decorators.length - 1; i >= 0; i--) {
8
+ var context = {};
9
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
10
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
11
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
12
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
13
+ if (kind === "accessor") {
14
+ if (result === void 0) continue;
15
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
16
+ if (_ = accept(result.get)) descriptor.get = _;
17
+ if (_ = accept(result.set)) descriptor.set = _;
18
+ if (_ = accept(result.init)) initializers.unshift(_);
19
+ }
20
+ else if (_ = accept(result)) {
21
+ if (kind === "field") initializers.unshift(_);
22
+ else descriptor[key] = _;
23
+ }
24
+ }
25
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
26
+ done = true;
27
+ };
28
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
29
+ var useValue = arguments.length > 2;
30
+ for (var i = 0; i < initializers.length; i++) {
31
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
32
+ }
33
+ return useValue ? value : void 0;
34
+ };
35
+ import { createIdentifier, } from '../../../global/di/index.js';
36
+ import { SignalWatcher, WithDisposable } from '../../../global/lit/index.js';
37
+ import { ShadowlessElement } from '../../../std/index.js';
38
+ import { computed, signal } from '@preact/signals-core';
39
+ import { css, html, nothing, unsafeCSS } from 'lit';
40
+ import { property } from 'lit/decorators.js';
41
+ import { dataViewCssVariable } from '../common/css-variable.js';
42
+ import { renderUniLit } from '../utils/uni-component/uni-component.js';
43
+ const NO_FLAGS = signal({
44
+ enable_number_formatting: false,
45
+ enable_table_virtual_scroll: false,
46
+ });
47
+ function isEmptyValue(value) {
48
+ if (value == null)
49
+ return true;
50
+ if (typeof value === 'string')
51
+ return value.trim() === '';
52
+ if (Array.isArray(value))
53
+ return value.length === 0;
54
+ return false;
55
+ }
56
+ class StandaloneCell {
57
+ get propertyId() {
58
+ return this._source.propertyId;
59
+ }
60
+ get rowId() {
61
+ return this._source.propertyId;
62
+ }
63
+ get row() {
64
+ throw new Error('A standalone cell has no row.');
65
+ }
66
+ constructor(meta, _source) {
67
+ this._source = _source;
68
+ const source = _source;
69
+ const view = {
70
+ readonly$: source.readonly$,
71
+ featureFlags$: source.featureFlags$ ?? NO_FLAGS,
72
+ serviceGet: (key) => source.serviceGet?.(key) ?? null,
73
+ };
74
+ // The whole seam is these three members, held by the spec named above.
75
+ this.view = view;
76
+ const type$ = signal(meta.type);
77
+ const property = {
78
+ id: source.propertyId,
79
+ name$: source.name$,
80
+ data$: source.data$,
81
+ type$,
82
+ readonly$: source.readonly$,
83
+ meta$: signal(meta),
84
+ renderer$: signal(meta.renderer.cellRenderer),
85
+ dataCanSet: !!source.dataSet,
86
+ dataUpdate: (updater) => {
87
+ if (!source.dataSet)
88
+ return;
89
+ const data = source.data$.peek();
90
+ source.dataSet({ ...data, ...updater(data) });
91
+ },
92
+ };
93
+ this.property = property;
94
+ this.value$ = source.value$;
95
+ this.jsonValue$ = source.value$;
96
+ this.isEmpty$ = computed(() => isEmptyValue(source.value$.value));
97
+ this.stringValue$ = computed(() => {
98
+ const value = source.value$.value;
99
+ if (value === undefined)
100
+ return undefined;
101
+ const toString = meta.config.rawValue.toString;
102
+ return toString({ value, data: source.data$.value });
103
+ });
104
+ }
105
+ valueSet(value) {
106
+ this._source.valueSet(value);
107
+ }
108
+ jsonValueSet(value) {
109
+ this._source.valueSet(value);
110
+ }
111
+ }
112
+ /** A `Cell` for one value outside any view, drawn with `meta`'s renderer. */
113
+ export function createStandaloneCell(meta, source) {
114
+ return new StandaloneCell(meta, source);
115
+ }
116
+ /**
117
+ * A property type a standalone cell can be drawn with, registered by the
118
+ * package that owns its renderer when that package sits above the host: the
119
+ * database block registers its `link` cell, which the title band (a fragment
120
+ * the database block depends on) cannot import. The presets of this package
121
+ * need no registration; a host imports them.
122
+ */
123
+ export const StandaloneCellMetaProvider = createIdentifier('DataViewStandaloneCellMeta');
124
+ export function StandaloneCellMetaExtension(meta) {
125
+ // Erased the way a data source's property list erases its metas.
126
+ const erased = meta;
127
+ return {
128
+ setup: di => {
129
+ di.override(StandaloneCellMetaProvider(meta.type), () => erased);
130
+ },
131
+ };
132
+ }
133
+ /**
134
+ * The element that hosts a standalone cell: it mounts the cell renderer the
135
+ * way a table cell container does and owns the same edit lifecycle
136
+ * (`beforeEnterEditMode`, `afterEnterEditingMode`, `beforeExitEditingMode`),
137
+ * so a click, Enter or Space starts the renderer's own editor: the checkbox
138
+ * toggles, a select pops its tag menu, the date its picker, a text its input.
139
+ *
140
+ * Leaving: a popup editor (select, date) closes itself on a click away and
141
+ * calls `selectCurrentCell(false)`, as in the table; an editor drawn in place
142
+ * (an input inside this element) leaves when the focus does, Escape included.
143
+ * Either way the renderer's exit hook commits, exactly once.
144
+ */
145
+ let StandaloneCellHost = (() => {
146
+ let _classSuper = SignalWatcher(WithDisposable(ShadowlessElement));
147
+ let _cell_decorators;
148
+ let _cell_initializers = [];
149
+ let _cell_extraInitializers = [];
150
+ let _placeholder_decorators;
151
+ let _placeholder_initializers = [];
152
+ let _placeholder_extraInitializers = [];
153
+ let _readonly_decorators;
154
+ let _readonly_initializers = [];
155
+ let _readonly_extraInitializers = [];
156
+ return class StandaloneCellHost extends _classSuper {
157
+ static {
158
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
159
+ _cell_decorators = [property({ attribute: false })];
160
+ _placeholder_decorators = [property({ attribute: false })];
161
+ _readonly_decorators = [property({ attribute: false })];
162
+ __esDecorate(this, null, _cell_decorators, { kind: "accessor", name: "cell", static: false, private: false, access: { has: obj => "cell" in obj, get: obj => obj.cell, set: (obj, value) => { obj.cell = value; } }, metadata: _metadata }, _cell_initializers, _cell_extraInitializers);
163
+ __esDecorate(this, null, _placeholder_decorators, { kind: "accessor", name: "placeholder", static: false, private: false, access: { has: obj => "placeholder" in obj, get: obj => obj.placeholder, set: (obj, value) => { obj.placeholder = value; } }, metadata: _metadata }, _placeholder_initializers, _placeholder_extraInitializers);
164
+ __esDecorate(this, null, _readonly_decorators, { kind: "accessor", name: "readonly", static: false, private: false, access: { has: obj => "readonly" in obj, get: obj => obj.readonly, set: (obj, value) => { obj.readonly = value; } }, metadata: _metadata }, _readonly_initializers, _readonly_extraInitializers);
165
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
166
+ }
167
+ static { this.styles = css `
168
+ dv-standalone-cell {
169
+ ${unsafeCSS(dataViewCssVariable())}
170
+ display: inline-flex;
171
+ align-items: center;
172
+ gap: 4px;
173
+ min-width: 0;
174
+ max-width: 100%;
175
+ outline: none;
176
+ }
177
+
178
+ dv-standalone-cell[data-editable='true'] {
179
+ cursor: pointer;
180
+ }
181
+
182
+ /* The record detail's editing ring (detail/field.ts). */
183
+ dv-standalone-cell[data-editing='true'] {
184
+ border-radius: 4px;
185
+ box-shadow: 0px 0px 0px 2px
186
+ color-mix(in srgb, var(--affine-primary-color) 30%, transparent);
187
+ }
188
+
189
+ .dv-standalone-cell-placeholder {
190
+ color: var(--affine-placeholder-color);
191
+ white-space: nowrap;
192
+ }
193
+ `; }
194
+ /** Opens the renderer's editor; a checkbox toggles instead. */
195
+ edit() {
196
+ if (this.readonly || this.isEditing$.peek())
197
+ return;
198
+ const cell = this._cell$.peek();
199
+ if (!cell?.beforeEnterEditMode())
200
+ return;
201
+ this.isEditing$.value = true;
202
+ requestAnimationFrame(() => {
203
+ if (this.isEditing$.peek())
204
+ cell.afterEnterEditingMode();
205
+ });
206
+ }
207
+ /** Closes the editor; the renderer's exit hook commits its value. */
208
+ exit() {
209
+ // An exit hook may close a popup whose own close asks to exit again.
210
+ if (!this.isEditing$.peek() || this._exiting)
211
+ return;
212
+ this._exiting = true;
213
+ try {
214
+ this._cell$.peek()?.beforeExitEditingMode();
215
+ }
216
+ finally {
217
+ this._exiting = false;
218
+ }
219
+ this.isEditing$.value = false;
220
+ }
221
+ connectedCallback() {
222
+ super.connectedCallback();
223
+ this._disposables.addFromEvent(this, 'click', event => {
224
+ if (this.readonly)
225
+ return;
226
+ event.stopPropagation();
227
+ this.edit();
228
+ });
229
+ this._disposables.addFromEvent(this, 'keydown', event => {
230
+ if (this.isEditing$.peek()) {
231
+ if (event.key === 'Escape')
232
+ this.exit();
233
+ return;
234
+ }
235
+ if (event.target !== this)
236
+ return;
237
+ if (event.key === 'Enter' || event.key === ' ') {
238
+ event.preventDefault();
239
+ this.edit();
240
+ }
241
+ });
242
+ this._disposables.addFromEvent(this, 'focusout', event => {
243
+ if (!this.isEditing$.peek())
244
+ return;
245
+ const { target, relatedTarget } = event;
246
+ if (!(target instanceof HTMLInputElement) &&
247
+ !(target instanceof HTMLTextAreaElement))
248
+ return;
249
+ if (relatedTarget instanceof Node && this.contains(relatedTarget))
250
+ return;
251
+ this.exit();
252
+ });
253
+ this._disposables.add(() => this.exit());
254
+ }
255
+ render() {
256
+ const view = this.cell.property.renderer$.value?.view;
257
+ if (!view)
258
+ return nothing;
259
+ this.dataset.editable = this.readonly ? 'false' : 'true';
260
+ this.dataset.editing = this.isEditing$.value ? 'true' : 'false';
261
+ if (this.readonly)
262
+ this.removeAttribute('tabindex');
263
+ else
264
+ this.tabIndex = 0;
265
+ const props = {
266
+ cell: this.cell,
267
+ isEditing$: this.isEditing$,
268
+ selectCurrentCell: this._selectCurrentCell,
269
+ };
270
+ const placeholder = this.placeholder && !this.isEditing$.value && this.cell.isEmpty$.value
271
+ ? html `<span class="dv-standalone-cell-placeholder"
272
+ >${this.placeholder}</span
273
+ >`
274
+ : nothing;
275
+ return html `${renderUniLit(view, props, { ref: this._cell$, style: { display: 'contents' } })}${placeholder}`;
276
+ }
277
+ #cell_accessor_storage;
278
+ get cell() { return this.#cell_accessor_storage; }
279
+ set cell(value) { this.#cell_accessor_storage = value; }
280
+ #placeholder_accessor_storage;
281
+ /** Drawn while the value is empty and no editor is open. */
282
+ get placeholder() { return this.#placeholder_accessor_storage; }
283
+ set placeholder(value) { this.#placeholder_accessor_storage = value; }
284
+ #readonly_accessor_storage;
285
+ /** Draws the value and opens no editor. */
286
+ get readonly() { return this.#readonly_accessor_storage; }
287
+ set readonly(value) { this.#readonly_accessor_storage = value; }
288
+ constructor() {
289
+ super(...arguments);
290
+ this._cell$ = signal();
291
+ this._exiting = false;
292
+ this.isEditing$ = signal(false);
293
+ this._selectCurrentCell = (editing) => {
294
+ if (editing)
295
+ this.edit();
296
+ else
297
+ this.exit();
298
+ };
299
+ this.#cell_accessor_storage = __runInitializers(this, _cell_initializers, void 0);
300
+ this.#placeholder_accessor_storage = (__runInitializers(this, _cell_extraInitializers), __runInitializers(this, _placeholder_initializers, ''));
301
+ this.#readonly_accessor_storage = (__runInitializers(this, _placeholder_extraInitializers), __runInitializers(this, _readonly_initializers, false));
302
+ __runInitializers(this, _readonly_extraInitializers);
303
+ }
304
+ };
305
+ })();
306
+ export { StandaloneCellHost };
@@ -27,6 +27,12 @@ export interface Property<RawValue = unknown, JsonValue = unknown, Data extends
27
27
  cellGetOrCreate(rowId: string): Cell<RawValue, JsonValue, Data>;
28
28
  readonly data$: ReadonlySignal<Data>;
29
29
  dataUpdate(updater: PropertyDataUpdater<Data>): void;
30
+ /**
31
+ * Whether `dataUpdate` writes anything; absent means it does. A standalone
32
+ * cell whose host cannot write the config says `false`, and a select then
33
+ * creates, edits and reorders no option (`standalone-cell.ts`).
34
+ */
35
+ readonly dataCanSet?: boolean;
30
36
  readonly type$: ReadonlySignal<string>;
31
37
  readonly typeSet?: (type: string) => void;
32
38
  get typeCanSet(): boolean;
@@ -16,7 +16,7 @@ export class MultiSelectCell extends BaseCellRenderer {
16
16
  this.closePopup = popTagSelect(popupTargetFromElement(this), {
17
17
  name: this.cell.property.name$.value,
18
18
  options: this.options$,
19
- onOptionsChange: this._onOptionsChange,
19
+ onOptionsChange: this.property.dataCanSet === false ? undefined : this._onOptionsChange,
20
20
  value: this._value$,
21
21
  onChange: v => {
22
22
  this.valueSetImmediate(v);
@@ -16,7 +16,7 @@ export class SelectCell extends BaseCellRenderer {
16
16
  name: this.cell.property.name$.value,
17
17
  mode: 'single',
18
18
  options: this.options$,
19
- onOptionsChange: this._onOptionsChange,
19
+ onOptionsChange: this.property.dataCanSet === false ? undefined : this._onOptionsChange,
20
20
  value: this._value$,
21
21
  onChange: v => {
22
22
  this.valueSetImmediate(v[0]);
@@ -50,7 +50,9 @@ let TextCell = (() => {
50
50
  this.#_inputEle_accessor_storage = __runInitializers(this, __inputEle_initializers, void 0);
51
51
  this._keydown = (__runInitializers(this, __inputEle_extraInitializers), (e) => {
52
52
  if (e.key === 'Enter' && !e.isComposing) {
53
- this._setValue();
53
+ // Leaving commits, once, through `beforeExitEditingMode`. Committing
54
+ // here as well reset the input to the old value, which the exit then
55
+ // wrote back over the new one (standalone-cell.unit.spec.ts).
54
56
  setTimeout(() => {
55
57
  this.selectCurrentCell(false);
56
58
  });
@@ -231,7 +231,7 @@ const CHROME_KEYS = [
231
231
  // person who picked it.
232
232
  [
233
233
  'com.labre.interchange.import.readonly',
234
- 'This document became read-only while the file was being read, so nothing was imported.',
234
+ 'This page became read-only while the file was being read, so nothing was imported.',
235
235
  ],
236
236
  [
237
237
  'com.labre.interchange.import.remarks',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formicoidea/labre-core",
3
3
  "description": "Labre editor — the full BlockSuite-derived editor as one package.",
4
- "version": "0.47.0",
4
+ "version": "0.48.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "author": "lajola",