@formicoidea/labre-core 0.56.0 → 0.57.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.
@@ -3467,7 +3467,7 @@ model {
3467
3467
  assembly.all -[uses]-> features.inlines.preset '6 imports'
3468
3468
  assembly.all -[uses]-> features.inlines.reference '6 imports'
3469
3469
  assembly.all -[uses]-> features.rich-text '3 imports, 1 type-only'
3470
- assembly.all -[uses]-> features.shared '14 imports'
3470
+ assembly.all -[uses]-> features.shared '15 imports'
3471
3471
  assembly.all -[uses]-> features.widgets.drag-handle '4 imports'
3472
3472
  assembly.all -[uses]-> features.widgets.edgeless-auto-connect '4 imports'
3473
3473
  assembly.all -[uses]-> features.widgets.edgeless-dragging-area '3 imports'
@@ -3765,14 +3765,13 @@ model {
3765
3765
  features.fragments.doc-title -[uses]-> framework.store '1 import, 1 type-only'
3766
3766
  features.fragments.doc-title -[uses]-> model_.model_ '1 import'
3767
3767
  features.fragments.frame-panel -[uses]-> features.blocks.frame '2 imports'
3768
- features.fragments.frame-panel -[uses]-> features.blocks.surface '2 imports'
3768
+ features.fragments.frame-panel -[uses]-> features.blocks.surface '3 imports'
3769
3769
  features.fragments.frame-panel -[uses]-> features.ext-loader '2 imports'
3770
- features.fragments.frame-panel -[uses]-> features.rich-text '1 import, 1 type-only'
3771
- features.fragments.frame-panel -[uses]-> features.shared '8 imports'
3772
- features.fragments.frame-panel -[uses]-> framework.global_ '14 imports'
3773
- features.fragments.frame-panel -[uses]-> framework.std '11 imports, 2 type-only'
3770
+ features.fragments.frame-panel -[uses]-> features.shared '9 imports'
3771
+ features.fragments.frame-panel -[uses]-> framework.global_ '13 imports'
3772
+ features.fragments.frame-panel -[uses]-> framework.std '10 imports, 2 type-only'
3774
3773
  features.fragments.frame-panel -[uses]-> framework.store '2 imports, 2 type-only'
3775
- features.fragments.frame-panel -[uses]-> model_.model_ '5 imports, 5 type-only'
3774
+ features.fragments.frame-panel -[uses]-> model_.model_ '4 imports, 4 type-only'
3776
3775
  features.fragments.outline -[uses]-> features.blocks.note '1 import'
3777
3776
  features.fragments.outline -[uses]-> features.ext-loader '1 import'
3778
3777
  features.fragments.outline -[uses]-> features.fragments.doc-title '1 import'
@@ -4471,6 +4470,7 @@ model {
4471
4470
  assembly.all.src -[imports]-> features.inlines.reference.src '1 import'
4472
4471
  assembly.all.src -[imports]-> features.rich-text.src '1 import, 1 type-only'
4473
4472
  assembly.all.src -[imports]-> features.shared.services '2 imports'
4473
+ assembly.all.src -[imports]-> features.shared.utils '1 import'
4474
4474
  assembly.all.src -[imports]-> features.widgets.drag-handle.src '1 import'
4475
4475
  assembly.all.src -[imports]-> features.widgets.edgeless-auto-connect.src '1 import'
4476
4476
  assembly.all.src -[imports]-> features.widgets.edgeless-selected-rect.src '1 import'
@@ -5957,16 +5957,16 @@ model {
5957
5957
  features.fragments.frame-panel.body -[imports]-> framework.std.src '1 import'
5958
5958
  features.fragments.frame-panel.body -[imports]-> framework.store.src '1 import, 1 type-only'
5959
5959
  features.fragments.frame-panel.body -[imports]-> model_.model_.src '1 import, 1 type-only'
5960
+ features.fragments.frame-panel.card -[imports]-> features.blocks.surface.src '1 import'
5960
5961
  features.fragments.frame-panel.card -[imports]-> features.ext-loader.src '1 import'
5961
- features.fragments.frame-panel.card -[imports]-> features.rich-text.src '1 import, 1 type-only'
5962
- features.fragments.frame-panel.card -[imports]-> features.shared.services '1 import'
5962
+ features.fragments.frame-panel.card -[imports]-> features.shared.services '2 imports'
5963
5963
  features.fragments.frame-panel.card -[imports]-> framework.global_.disposable '2 imports'
5964
5964
  features.fragments.frame-panel.card -[imports]-> framework.global_.gfx '1 import'
5965
- features.fragments.frame-panel.card -[imports]-> framework.global_.lit '4 imports'
5965
+ features.fragments.frame-panel.card -[imports]-> framework.global_.lit '3 imports'
5966
5966
  features.fragments.frame-panel.card -[imports]-> framework.std.gfx '1 import'
5967
- features.fragments.frame-panel.card -[imports]-> framework.std.src '4 imports'
5967
+ features.fragments.frame-panel.card -[imports]-> framework.std.src '3 imports'
5968
5968
  features.fragments.frame-panel.card -[imports]-> framework.store.src '1 import, 1 type-only'
5969
- features.fragments.frame-panel.card -[imports]-> model_.model_.src '4 imports, 4 type-only'
5969
+ features.fragments.frame-panel.card -[imports]-> model_.model_.src '3 imports, 3 type-only'
5970
5970
  features.fragments.frame-panel.header -[imports]-> features.blocks.frame.src '1 import'
5971
5971
  features.fragments.frame-panel.header -[imports]-> features.blocks.surface.src '2 imports'
5972
5972
  features.fragments.frame-panel.header -[imports]-> features.fragments.frame-panel.src '2 imports'
@@ -5979,7 +5979,7 @@ model {
5979
5979
  features.fragments.frame-panel.header -[imports]-> framework.std.src '2 imports, 2 type-only'
5980
5980
  features.fragments.frame-panel.src -[imports]-> features.ext-loader.src '1 import'
5981
5981
  features.fragments.frame-panel.src -[imports]-> features.fragments.frame-panel.body '1 import'
5982
- features.fragments.frame-panel.src -[imports]-> features.fragments.frame-panel.card '4 imports'
5982
+ features.fragments.frame-panel.src -[imports]-> features.fragments.frame-panel.card '3 imports'
5983
5983
  features.fragments.frame-panel.src -[imports]-> features.fragments.frame-panel.header '2 imports'
5984
5984
  features.fragments.frame-panel.src -[imports]-> features.shared.services '1 import'
5985
5985
  features.fragments.frame-panel.src -[imports]-> framework.global_.lit '1 import'
@@ -64,13 +64,13 @@ function reorderCommand() {
64
64
  const styles = css `
65
65
  .frame-list-container {
66
66
  display: flex;
67
- align-items: start;
67
+ align-items: stretch;
68
68
  box-sizing: border-box;
69
69
  flex-direction: column;
70
70
  width: 100%;
71
71
  gap: 16px;
72
72
  position: relative;
73
- margin: 0 8px;
73
+ padding: 0 8px;
74
74
  }
75
75
 
76
76
  .no-frame-container {
@@ -101,8 +101,8 @@ const styles = css `
101
101
  background-color: var(--affine-blue-600);
102
102
  position: absolute;
103
103
  contain: layout size;
104
- width: 284px;
105
- left: 0;
104
+ left: 8px;
105
+ right: 8px;
106
106
  }
107
107
 
108
108
  /*
@@ -1,24 +1,37 @@
1
1
  import type { FrameBlockModel } from '../../affine-model/index.js';
2
- import { ShadowlessElement } from '../../std/index.js';
2
+ import { type BlockStdScope, ShadowlessElement } from '../../std/index.js';
3
3
  import { type PropertyValues } from 'lit';
4
4
  export declare const AFFINE_FRAME_CARD_TITLE = "affine-frame-card-title";
5
5
  declare const FrameCardTitle_base: typeof ShadowlessElement & import("../../global/utils/types.js").Constructor<import("../../global/lit/with-disposable.js").DisposableClass>;
6
+ /**
7
+ * A card's number and name. A double-click on the name renames the frame in
8
+ * place (recette 1, P0-1.4): Enter or leaving the field saves, Escape cancels.
9
+ *
10
+ * The field is a plain input committed once, through `canvas.frame.rename`
11
+ * (the selection pane's own rename): the read-only refusal, the empty and
12
+ * unchanged no-ops and the one undo step are the command's. It used to be a
13
+ * rich text bound live to the stored title, which wrote on every key — an
14
+ * Escape could not take a keystroke back. The descriptor is imported, not
15
+ * looked up in the registry, so the rename works in page mode too.
16
+ */
6
17
  export declare class FrameCardTitle extends FrameCardTitle_base {
7
18
  static styles: import("lit").CSSResult;
8
19
  private readonly _clearTitleDisposables;
9
- private readonly _mountTitleEditor;
10
20
  private _titleDisposables;
11
21
  private readonly _updateElement;
22
+ private readonly _startEditing;
23
+ private _commit;
24
+ private readonly _onKeydown;
12
25
  private _setFrameDisposables;
13
- connectedCallback(): void;
14
26
  disconnectedCallback(): void;
27
+ private _renderName;
15
28
  render(): import("lit-html").TemplateResult<1>;
16
29
  updated(_changedProperties: PropertyValues): void;
30
+ private accessor _editing;
31
+ private accessor _input;
17
32
  accessor cardIndex: number;
18
33
  accessor frame: FrameBlockModel;
19
- accessor titleContainer: HTMLElement;
20
- accessor titleContentElement: HTMLElement;
21
- accessor titleIndexElement: HTMLElement;
34
+ accessor std: BlockStdScope;
22
35
  }
23
36
  declare global {
24
37
  interface HTMLElementTagNameMap {
@@ -32,12 +32,13 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
32
32
  }
33
33
  return useValue ? value : void 0;
34
34
  };
35
+ import { selectionPaneCommands } from '../../affine-block-surface/index.js';
36
+ import { TOOLBAR_RENAME, translateKey } from '../../affine-shared/services/index.js';
35
37
  import { DisposableGroup } from '../../global/disposable/index.js';
36
38
  import { WithDisposable } from '../../global/lit/index.js';
37
- import { ShadowlessElement } from '../../std/index.js';
39
+ import { runCommand, ShadowlessElement, } from '../../std/index.js';
38
40
  import { css, html } from 'lit';
39
- import { property, query } from 'lit/decorators.js';
40
- import { FrameCardTitleEditor } from './frame-card-title-editor.js';
41
+ import { property, query, state } from 'lit/decorators.js';
41
42
  const styles = css `
42
43
  .frame-card-title-container {
43
44
  display: flex;
@@ -82,42 +83,90 @@ const styles = css `
82
83
  overflow: hidden;
83
84
  text-overflow: ellipsis;
84
85
  flex: 1;
86
+ min-width: 0;
87
+ }
88
+
89
+ .frame-card-title-container .card-title-input {
90
+ flex: 1;
91
+ min-width: 0;
92
+ height: 20px;
93
+ box-sizing: border-box;
94
+ padding: 0 4px;
95
+ border: 1px solid var(--affine-primary-color);
96
+ border-radius: 4px;
97
+ background: var(--affine-background-primary-color);
98
+ box-shadow: var(--affine-active-shadow);
99
+ color: var(--affine-text-primary-color);
100
+ font: inherit;
101
+ line-height: 18px;
102
+ outline: none;
85
103
  }
86
104
  `;
87
105
  export const AFFINE_FRAME_CARD_TITLE = 'affine-frame-card-title';
106
+ /** How the panel invokes the registry, like its reorder and the pane's rows. */
107
+ const PANEL_INVOCATION = {
108
+ surface: 'contextual-toolbar',
109
+ source: 'toolbar:general',
110
+ };
111
+ function renameCommand() {
112
+ const command = selectionPaneCommands.find(c => c.id === 'canvas.frame.rename');
113
+ if (!command)
114
+ throw new Error('frame panel: no canvas.frame.rename');
115
+ return command;
116
+ }
117
+ /**
118
+ * A card's number and name. A double-click on the name renames the frame in
119
+ * place (recette 1, P0-1.4): Enter or leaving the field saves, Escape cancels.
120
+ *
121
+ * The field is a plain input committed once, through `canvas.frame.rename`
122
+ * (the selection pane's own rename): the read-only refusal, the empty and
123
+ * unchanged no-ops and the one undo step are the command's. It used to be a
124
+ * rich text bound live to the stored title, which wrote on every key — an
125
+ * Escape could not take a keystroke back. The descriptor is imported, not
126
+ * looked up in the registry, so the rename works in page mode too.
127
+ */
88
128
  let FrameCardTitle = (() => {
89
129
  let _classSuper = WithDisposable(ShadowlessElement);
130
+ let __editing_decorators;
131
+ let __editing_initializers = [];
132
+ let __editing_extraInitializers = [];
133
+ let __input_decorators;
134
+ let __input_initializers = [];
135
+ let __input_extraInitializers = [];
90
136
  let _cardIndex_decorators;
91
137
  let _cardIndex_initializers = [];
92
138
  let _cardIndex_extraInitializers = [];
93
139
  let _frame_decorators;
94
140
  let _frame_initializers = [];
95
141
  let _frame_extraInitializers = [];
96
- let _titleContainer_decorators;
97
- let _titleContainer_initializers = [];
98
- let _titleContainer_extraInitializers = [];
99
- let _titleContentElement_decorators;
100
- let _titleContentElement_initializers = [];
101
- let _titleContentElement_extraInitializers = [];
102
- let _titleIndexElement_decorators;
103
- let _titleIndexElement_initializers = [];
104
- let _titleIndexElement_extraInitializers = [];
142
+ let _std_decorators;
143
+ let _std_initializers = [];
144
+ let _std_extraInitializers = [];
105
145
  return class FrameCardTitle extends _classSuper {
106
146
  static {
107
147
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
148
+ __editing_decorators = [state()];
149
+ __input_decorators = [query('.card-title-input')];
108
150
  _cardIndex_decorators = [property({ attribute: false })];
109
151
  _frame_decorators = [property({ attribute: false })];
110
- _titleContainer_decorators = [query('.frame-card-title-container')];
111
- _titleContentElement_decorators = [query('.frame-card-title-container .card-title')];
112
- _titleIndexElement_decorators = [query('.frame-card-title-container .card-index')];
152
+ _std_decorators = [property({ attribute: false })];
153
+ __esDecorate(this, null, __editing_decorators, { kind: "accessor", name: "_editing", static: false, private: false, access: { has: obj => "_editing" in obj, get: obj => obj._editing, set: (obj, value) => { obj._editing = value; } }, metadata: _metadata }, __editing_initializers, __editing_extraInitializers);
154
+ __esDecorate(this, null, __input_decorators, { kind: "accessor", name: "_input", static: false, private: false, access: { has: obj => "_input" in obj, get: obj => obj._input, set: (obj, value) => { obj._input = value; } }, metadata: _metadata }, __input_initializers, __input_extraInitializers);
113
155
  __esDecorate(this, null, _cardIndex_decorators, { kind: "accessor", name: "cardIndex", static: false, private: false, access: { has: obj => "cardIndex" in obj, get: obj => obj.cardIndex, set: (obj, value) => { obj.cardIndex = value; } }, metadata: _metadata }, _cardIndex_initializers, _cardIndex_extraInitializers);
114
156
  __esDecorate(this, null, _frame_decorators, { kind: "accessor", name: "frame", static: false, private: false, access: { has: obj => "frame" in obj, get: obj => obj.frame, set: (obj, value) => { obj.frame = value; } }, metadata: _metadata }, _frame_initializers, _frame_extraInitializers);
115
- __esDecorate(this, null, _titleContainer_decorators, { kind: "accessor", name: "titleContainer", static: false, private: false, access: { has: obj => "titleContainer" in obj, get: obj => obj.titleContainer, set: (obj, value) => { obj.titleContainer = value; } }, metadata: _metadata }, _titleContainer_initializers, _titleContainer_extraInitializers);
116
- __esDecorate(this, null, _titleContentElement_decorators, { kind: "accessor", name: "titleContentElement", static: false, private: false, access: { has: obj => "titleContentElement" in obj, get: obj => obj.titleContentElement, set: (obj, value) => { obj.titleContentElement = value; } }, metadata: _metadata }, _titleContentElement_initializers, _titleContentElement_extraInitializers);
117
- __esDecorate(this, null, _titleIndexElement_decorators, { kind: "accessor", name: "titleIndexElement", static: false, private: false, access: { has: obj => "titleIndexElement" in obj, get: obj => obj.titleIndexElement, set: (obj, value) => { obj.titleIndexElement = value; } }, metadata: _metadata }, _titleIndexElement_initializers, _titleIndexElement_extraInitializers);
157
+ __esDecorate(this, null, _std_decorators, { kind: "accessor", name: "std", static: false, private: false, access: { has: obj => "std" in obj, get: obj => obj.std, set: (obj, value) => { obj.std = value; } }, metadata: _metadata }, _std_initializers, _std_extraInitializers);
118
158
  if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
119
159
  }
120
160
  static { this.styles = styles; }
161
+ _commit(input) {
162
+ if (!this._editing)
163
+ return;
164
+ this._editing = false;
165
+ runCommand(this.std, renameCommand(), PANEL_INVOCATION, {
166
+ id: this.frame.id,
167
+ title: input.value,
168
+ });
169
+ }
121
170
  _setFrameDisposables(title) {
122
171
  this._clearTitleDisposables();
123
172
  title.observe(this._updateElement);
@@ -128,13 +177,39 @@ let FrameCardTitle = (() => {
128
177
  },
129
178
  });
130
179
  }
131
- connectedCallback() {
132
- super.connectedCallback();
133
- }
134
180
  disconnectedCallback() {
135
181
  super.disconnectedCallback();
136
182
  this._clearTitleDisposables();
137
183
  }
184
+ _renderName() {
185
+ const name = this.frame.props.title.toString();
186
+ if (!this._editing) {
187
+ return html `<div
188
+ class="card-title"
189
+ data-testid="frame-card-title"
190
+ title=${name}
191
+ @click=${(e) => e.stopPropagation()}
192
+ @dblclick=${this._startEditing}
193
+ >
194
+ ${name}
195
+ </div>`;
196
+ }
197
+ return html `<input
198
+ class="card-title-input"
199
+ data-testid="frame-card-title-input"
200
+ aria-label=${translateKey(this.std, ...TOOLBAR_RENAME)}
201
+ .value=${name}
202
+ @click=${(e) => e.stopPropagation()}
203
+ @dblclick=${(e) => e.stopPropagation()}
204
+ @select=${(e) => {
205
+ // The field's own text selection bubbles a native select event, which
206
+ // the card's own select listener would read as a frame pick.
207
+ e.stopPropagation();
208
+ }}
209
+ @keydown=${this._onKeydown}
210
+ @blur=${(e) => this._commit(e.target)}
211
+ />`;
212
+ }
138
213
  render() {
139
214
  return html `<div class="frame-card-title-container">
140
215
  <div
@@ -144,61 +219,70 @@ let FrameCardTitle = (() => {
144
219
  >
145
220
  ${this.cardIndex + 1}
146
221
  </div>
147
- <div class="card-title">
148
- <span
149
- @click=${(e) => e.stopPropagation()}
150
- @dblclick=${this._mountTitleEditor}
151
- >${this.frame.props.title}</span
152
- >
153
- </div>
222
+ ${this._renderName()}
154
223
  </div>`;
155
224
  }
156
225
  updated(_changedProperties) {
157
226
  if (_changedProperties.has('frame')) {
158
227
  this._setFrameDisposables(this.frame.props.title.yText);
159
228
  }
229
+ if (_changedProperties.has('_editing') && this._editing) {
230
+ this._input?.focus();
231
+ this._input?.select();
232
+ }
160
233
  }
234
+ #_editing_accessor_storage;
235
+ get _editing() { return this.#_editing_accessor_storage; }
236
+ set _editing(value) { this.#_editing_accessor_storage = value; }
237
+ #_input_accessor_storage;
238
+ get _input() { return this.#_input_accessor_storage; }
239
+ set _input(value) { this.#_input_accessor_storage = value; }
161
240
  #cardIndex_accessor_storage;
162
241
  get cardIndex() { return this.#cardIndex_accessor_storage; }
163
242
  set cardIndex(value) { this.#cardIndex_accessor_storage = value; }
164
243
  #frame_accessor_storage;
165
244
  get frame() { return this.#frame_accessor_storage; }
166
245
  set frame(value) { this.#frame_accessor_storage = value; }
167
- #titleContainer_accessor_storage;
168
- get titleContainer() { return this.#titleContainer_accessor_storage; }
169
- set titleContainer(value) { this.#titleContainer_accessor_storage = value; }
170
- #titleContentElement_accessor_storage;
171
- get titleContentElement() { return this.#titleContentElement_accessor_storage; }
172
- set titleContentElement(value) { this.#titleContentElement_accessor_storage = value; }
173
- #titleIndexElement_accessor_storage;
174
- get titleIndexElement() { return this.#titleIndexElement_accessor_storage; }
175
- set titleIndexElement(value) { this.#titleIndexElement_accessor_storage = value; }
246
+ #std_accessor_storage;
247
+ get std() { return this.#std_accessor_storage; }
248
+ set std(value) { this.#std_accessor_storage = value; }
176
249
  constructor() {
177
250
  super(...arguments);
178
251
  this._clearTitleDisposables = () => {
179
252
  this._titleDisposables?.dispose();
180
253
  this._titleDisposables = null;
181
254
  };
182
- this._mountTitleEditor = (e) => {
183
- e.stopPropagation();
184
- const titleEditor = new FrameCardTitleEditor();
185
- titleEditor.frameModel = this.frame;
186
- titleEditor.titleContentElement = this.titleContentElement;
187
- const left = this.titleIndexElement.offsetWidth + 6;
188
- titleEditor.left = left;
189
- titleEditor.maxWidth = this.titleContainer.offsetWidth - left - 6;
190
- this.titleContainer.append(titleEditor);
191
- };
192
255
  this._titleDisposables = null;
193
256
  this._updateElement = () => {
194
257
  this.requestUpdate();
195
258
  };
196
- this.#cardIndex_accessor_storage = __runInitializers(this, _cardIndex_initializers, void 0);
259
+ this._startEditing = (e) => {
260
+ e.stopPropagation();
261
+ if (this.std.store.readonly)
262
+ return;
263
+ this._editing = true;
264
+ };
265
+ this._onKeydown = (e) => {
266
+ // The canvas and the host's panel bind keys (Backspace, Escape closes a
267
+ // panel): a key typed into the name reaches neither.
268
+ e.stopPropagation();
269
+ if (e.isComposing)
270
+ return;
271
+ if (e.key === 'Enter') {
272
+ e.preventDefault();
273
+ this._commit(e.currentTarget);
274
+ }
275
+ else if (e.key === 'Escape') {
276
+ e.preventDefault();
277
+ this._editing = false;
278
+ }
279
+ };
280
+ this.#_editing_accessor_storage = __runInitializers(this, __editing_initializers, false);
281
+ this.#_input_accessor_storage = (__runInitializers(this, __editing_extraInitializers), __runInitializers(this, __input_initializers, null));
282
+ this.#cardIndex_accessor_storage = (__runInitializers(this, __input_extraInitializers), __runInitializers(this, _cardIndex_initializers, void 0));
197
283
  this.#frame_accessor_storage = (__runInitializers(this, _cardIndex_extraInitializers), __runInitializers(this, _frame_initializers, void 0));
198
- this.#titleContainer_accessor_storage = (__runInitializers(this, _frame_extraInitializers), __runInitializers(this, _titleContainer_initializers, void 0));
199
- this.#titleContentElement_accessor_storage = (__runInitializers(this, _titleContainer_extraInitializers), __runInitializers(this, _titleContentElement_initializers, void 0));
200
- this.#titleIndexElement_accessor_storage = (__runInitializers(this, _titleContentElement_extraInitializers), __runInitializers(this, _titleIndexElement_initializers, void 0));
201
- __runInitializers(this, _titleIndexElement_extraInitializers);
284
+ this.#std_accessor_storage = (__runInitializers(this, _frame_extraInitializers), __runInitializers(this, _std_initializers, void 0));
285
+ __runInitializers(this, _std_extraInitializers);
202
286
  }
203
287
  };
204
288
  })();
@@ -42,11 +42,16 @@ const styles = css `
42
42
  display: block;
43
43
  }
44
44
 
45
+ /*
46
+ The card takes the panel's width and its preview the frame's proportions
47
+ (recette 1, P0-1.2): widening the sidebar grows every card, so fewer fit
48
+ on screen. No fixed size anywhere; a ghost gets its width from the card it
49
+ copies.
50
+ */
45
51
  .frame-card-container {
46
52
  display: flex;
47
53
  flex-direction: column;
48
- width: 284px;
49
- height: 198px;
54
+ width: 100%;
50
55
  gap: 8px;
51
56
 
52
57
  position: relative;
@@ -55,7 +60,6 @@ const styles = css `
55
60
  .frame-card-body {
56
61
  display: flex;
57
62
  width: 100%;
58
- height: 170px;
59
63
  box-sizing: border-box;
60
64
  justify-content: center;
61
65
  align-items: center;
@@ -67,8 +71,15 @@ const styles = css `
67
71
  position: relative;
68
72
  }
69
73
 
74
+ /* A ring, not a thicker border: the preview inside keeps its width. */
70
75
  .frame-card-container.selected .frame-card-body {
71
- border: 2px solid var(--affine-primary-color);
76
+ border-color: var(--affine-primary-color);
77
+ box-shadow: 0 0 0 1px var(--affine-primary-color);
78
+ }
79
+
80
+ .frame-card-body > frame-preview {
81
+ border-radius: 7px;
82
+ overflow: hidden;
72
83
  }
73
84
 
74
85
  .frame-card-container.dragging {
@@ -84,6 +95,11 @@ const styles = css `
84
95
  display: none;
85
96
  }
86
97
 
98
+ /* The copy stacked behind draws no preview: it keeps a card's shape. */
99
+ .frame-card-container.dragging .frame-card-body {
100
+ aspect-ratio: 16 / 9;
101
+ }
102
+
87
103
  .frame-card-container.dragging .dragging-card-number {
88
104
  position: absolute;
89
105
  bottom: 0;
@@ -228,6 +244,7 @@ let FrameCard = (() => {
228
244
  : html `<affine-frame-card-title
229
245
  .cardIndex=${this.cardIndex}
230
246
  .frame=${this.frame}
247
+ .std=${this.std}
231
248
  ></affine-frame-card-title>`}
232
249
  <div
233
250
  class="frame-card-body"
@@ -240,6 +257,7 @@ let FrameCard = (() => {
240
257
  : html `<frame-preview
241
258
  .frame=${this.frame}
242
259
  .std=${this.std}
260
+ .fluid=${true}
243
261
  ></frame-preview>`}
244
262
  ${this._DraggingCardNumber()}
245
263
  </div>
@@ -13,6 +13,7 @@ export declare class FramePreview extends FramePreview_base {
13
13
  private _runtimePreviewExt;
14
14
  private get _viewExtensionManager();
15
15
  private get _previewSpec();
16
+ private _resizeObserver;
16
17
  private readonly _updateFrameViewportWH;
17
18
  get _originalDoc(): Store;
18
19
  private _initPreviewDoc;
@@ -22,10 +23,21 @@ export declare class FramePreview extends FramePreview_base {
22
23
  private _setFrameDisposables;
23
24
  connectedCallback(): void;
24
25
  disconnectedCallback(): void;
26
+ /** A fluid preview follows its own width: the panel's, as it is resized. */
27
+ private _observeWidth;
28
+ willUpdate(changed: PropertyValues): void;
25
29
  render(): import("lit-html").TemplateResult<1>;
26
30
  updated(_changedProperties: PropertyValues): void;
27
31
  accessor std: BlockStdScope;
32
+ /** The width a fluid preview measured on itself; `0` until laid out. */
33
+ private accessor _containerWidth;
28
34
  accessor fillScreen: boolean;
35
+ /**
36
+ * Take the container's width and the frame's proportions (recette 1,
37
+ * P0-1.2): the box grows and shrinks with the panel, never taller than
38
+ * wide, and `surfaceWidth` / `surfaceHeight` are computed, not read.
39
+ */
40
+ accessor fluid: boolean;
29
41
  accessor frame: FrameBlockModel;
30
42
  accessor frameViewportWH: {
31
43
  width: number;
@@ -45,9 +45,15 @@ import { property, query, state } from 'lit/decorators.js';
45
45
  import { guard } from 'lit/directives/guard.js';
46
46
  import { styleMap } from 'lit/directives/style-map.js';
47
47
  import debounce from 'lodash-es/debounce.js';
48
+ import { fluidPreviewSize } from './preview-size.js';
48
49
  const DEFAULT_PREVIEW_CONTAINER_WIDTH = 280;
49
50
  const DEFAULT_PREVIEW_CONTAINER_HEIGHT = 166;
50
51
  const styles = css `
52
+ frame-preview[data-fluid] {
53
+ display: block;
54
+ width: 100%;
55
+ }
56
+
51
57
  .frame-preview-container {
52
58
  display: block;
53
59
  width: 100%;
@@ -89,9 +95,15 @@ let FramePreview = (() => {
89
95
  let _std_decorators;
90
96
  let _std_initializers = [];
91
97
  let _std_extraInitializers = [];
98
+ let __containerWidth_decorators;
99
+ let __containerWidth_initializers = [];
100
+ let __containerWidth_extraInitializers = [];
92
101
  let _fillScreen_decorators;
93
102
  let _fillScreen_initializers = [];
94
103
  let _fillScreen_extraInitializers = [];
104
+ let _fluid_decorators;
105
+ let _fluid_initializers = [];
106
+ let _fluid_extraInitializers = [];
95
107
  let _frame_decorators;
96
108
  let _frame_initializers = [];
97
109
  let _frame_extraInitializers = [];
@@ -111,14 +123,18 @@ let FramePreview = (() => {
111
123
  static {
112
124
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
113
125
  _std_decorators = [property({ attribute: false })];
126
+ __containerWidth_decorators = [state()];
114
127
  _fillScreen_decorators = [state()];
128
+ _fluid_decorators = [property({ attribute: false })];
115
129
  _frame_decorators = [property({ attribute: false })];
116
130
  _frameViewportWH_decorators = [state()];
117
131
  _previewEditor_decorators = [query('editor-host')];
118
132
  _surfaceHeight_decorators = [property({ attribute: false })];
119
133
  _surfaceWidth_decorators = [property({ attribute: false })];
120
134
  __esDecorate(this, null, _std_decorators, { kind: "accessor", name: "std", static: false, private: false, access: { has: obj => "std" in obj, get: obj => obj.std, set: (obj, value) => { obj.std = value; } }, metadata: _metadata }, _std_initializers, _std_extraInitializers);
135
+ __esDecorate(this, null, __containerWidth_decorators, { kind: "accessor", name: "_containerWidth", static: false, private: false, access: { has: obj => "_containerWidth" in obj, get: obj => obj._containerWidth, set: (obj, value) => { obj._containerWidth = value; } }, metadata: _metadata }, __containerWidth_initializers, __containerWidth_extraInitializers);
121
136
  __esDecorate(this, null, _fillScreen_decorators, { kind: "accessor", name: "fillScreen", static: false, private: false, access: { has: obj => "fillScreen" in obj, get: obj => obj.fillScreen, set: (obj, value) => { obj.fillScreen = value; } }, metadata: _metadata }, _fillScreen_initializers, _fillScreen_extraInitializers);
137
+ __esDecorate(this, null, _fluid_decorators, { kind: "accessor", name: "fluid", static: false, private: false, access: { has: obj => "fluid" in obj, get: obj => obj.fluid, set: (obj, value) => { obj.fluid = value; } }, metadata: _metadata }, _fluid_initializers, _fluid_extraInitializers);
122
138
  __esDecorate(this, null, _frame_decorators, { kind: "accessor", name: "frame", static: false, private: false, access: { has: obj => "frame" in obj, get: obj => obj.frame, set: (obj, value) => { obj.frame = value; } }, metadata: _metadata }, _frame_initializers, _frame_extraInitializers);
123
139
  __esDecorate(this, null, _frameViewportWH_decorators, { kind: "accessor", name: "frameViewportWH", static: false, private: false, access: { has: obj => "frameViewportWH" in obj, get: obj => obj.frameViewportWH, set: (obj, value) => { obj.frameViewportWH = value; } }, metadata: _metadata }, _frameViewportWH_initializers, _frameViewportWH_extraInitializers);
124
140
  __esDecorate(this, null, _previewEditor_decorators, { kind: "accessor", name: "previewEditor", static: false, private: false, access: { has: obj => "previewEditor" in obj, get: obj => obj.previewEditor, set: (obj, value) => { obj.previewEditor = value; } }, metadata: _metadata }, _previewEditor_initializers, _previewEditor_extraInitializers);
@@ -157,9 +173,13 @@ let FramePreview = (() => {
157
173
  payload.view.model.flavour !== 'affine:page') {
158
174
  return;
159
175
  }
176
+ // Every size, not only the first: a fluid preview follows its
177
+ // panel's width, and the mini editor's viewport settles on the new
178
+ // size (debounced) after the box has changed — fitting then is what
179
+ // keeps the frame filling it. The subject completes with the
180
+ // viewport, which ends the subscription.
160
181
  const viewport = std.get(GfxControllerIdentifier).viewport;
161
- const subscription = viewport.sizeUpdated.subscribe(() => {
162
- subscription.unsubscribe();
182
+ viewport.sizeUpdated.subscribe(() => {
163
183
  refreshViewport();
164
184
  });
165
185
  });
@@ -219,14 +239,50 @@ let FramePreview = (() => {
219
239
  this._initPreviewDoc();
220
240
  this._updateFrameViewportWH();
221
241
  this._setFrameDisposables(this.frame);
242
+ this._observeWidth();
222
243
  }
223
244
  disconnectedCallback() {
224
245
  super.disconnectedCallback();
225
246
  this._clearFrameDisposables();
247
+ this._resizeObserver?.disconnect();
248
+ this._resizeObserver = null;
249
+ }
250
+ /** A fluid preview follows its own width: the panel's, as it is resized. */
251
+ _observeWidth() {
252
+ this._resizeObserver?.disconnect();
253
+ this._resizeObserver = null;
254
+ if (!this.fluid || typeof ResizeObserver === 'undefined')
255
+ return;
256
+ this._resizeObserver = new ResizeObserver(([entry]) => {
257
+ if (!entry)
258
+ return;
259
+ const width = Math.floor(entry.contentRect.width);
260
+ if (width !== this._containerWidth)
261
+ this._containerWidth = width;
262
+ });
263
+ this._resizeObserver.observe(this);
264
+ }
265
+ willUpdate(changed) {
266
+ if (changed.has('fluid')) {
267
+ this.toggleAttribute('data-fluid', this.fluid);
268
+ if (this.isConnected)
269
+ this._observeWidth();
270
+ }
271
+ // The box was only read at connect and on a frame's own update, so a host
272
+ // that resized it after mounting kept the old scale.
273
+ if (changed.has('fluid') ||
274
+ changed.has('_containerWidth') ||
275
+ changed.has('surfaceWidth') ||
276
+ changed.has('surfaceHeight') ||
277
+ changed.has('fillScreen')) {
278
+ this._updateFrameViewportWH();
279
+ }
226
280
  }
227
281
  render() {
228
282
  const { frame } = this;
229
- const noContent = !frame || !frame.xywh;
283
+ // A fluid preview builds its mini editor once it knows its width, never
284
+ // at the default box first.
285
+ const noContent = !frame || !frame.xywh || (this.fluid && this._containerWidth === 0);
230
286
  return html `<div class="frame-preview-container">
231
287
  ${noContent ? nothing : this._renderSurfaceContent()}
232
288
  </div>`;
@@ -242,9 +298,21 @@ let FramePreview = (() => {
242
298
  #std_accessor_storage;
243
299
  get std() { return this.#std_accessor_storage; }
244
300
  set std(value) { this.#std_accessor_storage = value; }
301
+ #_containerWidth_accessor_storage;
302
+ /** The width a fluid preview measured on itself; `0` until laid out. */
303
+ get _containerWidth() { return this.#_containerWidth_accessor_storage; }
304
+ set _containerWidth(value) { this.#_containerWidth_accessor_storage = value; }
245
305
  #fillScreen_accessor_storage;
246
306
  get fillScreen() { return this.#fillScreen_accessor_storage; }
247
307
  set fillScreen(value) { this.#fillScreen_accessor_storage = value; }
308
+ #fluid_accessor_storage;
309
+ /**
310
+ * Take the container's width and the frame's proportions (recette 1,
311
+ * P0-1.2): the box grows and shrinks with the panel, never taller than
312
+ * wide, and `surfaceWidth` / `surfaceHeight` are computed, not read.
313
+ */
314
+ get fluid() { return this.#fluid_accessor_storage; }
315
+ set fluid(value) { this.#fluid_accessor_storage = value; }
248
316
  #frame_accessor_storage;
249
317
  get frame() { return this.#frame_accessor_storage; }
250
318
  set frame(value) { this.#frame_accessor_storage = value; }
@@ -278,8 +346,14 @@ let FramePreview = (() => {
278
346
  this._frameDisposables = null;
279
347
  this._previewDoc = null;
280
348
  this._runtimePreviewExt = [];
349
+ this._resizeObserver = null;
281
350
  this._updateFrameViewportWH = () => {
282
351
  const [, , w, h] = deserializeXYWH(this.frame.xywh);
352
+ if (this.fluid) {
353
+ const box = fluidPreviewSize(this._containerWidth, w, h);
354
+ this.surfaceWidth = box.width;
355
+ this.surfaceHeight = box.height;
356
+ }
283
357
  let scale = 1;
284
358
  if (this.fillScreen) {
285
359
  scale = Math.max(this.surfaceWidth / w, this.surfaceHeight / h);
@@ -293,8 +367,10 @@ let FramePreview = (() => {
293
367
  };
294
368
  };
295
369
  this.#std_accessor_storage = __runInitializers(this, _std_initializers, void 0);
296
- this.#fillScreen_accessor_storage = (__runInitializers(this, _std_extraInitializers), __runInitializers(this, _fillScreen_initializers, false));
297
- this.#frame_accessor_storage = (__runInitializers(this, _fillScreen_extraInitializers), __runInitializers(this, _frame_initializers, void 0));
370
+ this.#_containerWidth_accessor_storage = (__runInitializers(this, _std_extraInitializers), __runInitializers(this, __containerWidth_initializers, 0));
371
+ this.#fillScreen_accessor_storage = (__runInitializers(this, __containerWidth_extraInitializers), __runInitializers(this, _fillScreen_initializers, false));
372
+ this.#fluid_accessor_storage = (__runInitializers(this, _fillScreen_extraInitializers), __runInitializers(this, _fluid_initializers, false));
373
+ this.#frame_accessor_storage = (__runInitializers(this, _fluid_extraInitializers), __runInitializers(this, _frame_initializers, void 0));
298
374
  this.#frameViewportWH_accessor_storage = (__runInitializers(this, _frame_extraInitializers), __runInitializers(this, _frameViewportWH_initializers, {
299
375
  width: 0,
300
376
  height: 0,
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The box of a fluid frame preview (recette 1, P0-1.2): the container's width,
3
+ * the frame's proportions, never taller than it is wide. A frame without an
4
+ * area gets a square box; a container not laid out yet gets no box at all.
5
+ */
6
+ export declare function fluidPreviewSize(containerWidth: number, frameWidth: number, frameHeight: number): {
7
+ width: number;
8
+ height: number;
9
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * A portrait frame previewed at the panel's full width would be taller than
3
+ * the sidebar is wide many times over and push every other card off screen:
4
+ * past a square, the box stops growing and the frame is contained in it.
5
+ */
6
+ const MAX_HEIGHT_PER_WIDTH = 1;
7
+ /**
8
+ * The box of a fluid frame preview (recette 1, P0-1.2): the container's width,
9
+ * the frame's proportions, never taller than it is wide. A frame without an
10
+ * area gets a square box; a container not laid out yet gets no box at all.
11
+ */
12
+ export function fluidPreviewSize(containerWidth, frameWidth, frameHeight) {
13
+ const width = Math.max(0, Math.floor(containerWidth));
14
+ if (width === 0)
15
+ return { width: 0, height: 0 };
16
+ const ratio = frameWidth > 0 && frameHeight > 0
17
+ ? Math.min(frameHeight / frameWidth, MAX_HEIGHT_PER_WIDTH)
18
+ : MAX_HEIGHT_PER_WIDTH;
19
+ return { width, height: Math.round(width * ratio) };
20
+ }
@@ -1,14 +1,12 @@
1
1
  import { AFFINE_FRAME_PANEL_BODY, FramePanelBody, } from './body/frame-panel-body.js';
2
2
  import { AFFINE_FRAME_CARD, FrameCard } from './card/frame-card.js';
3
3
  import { AFFINE_FRAME_CARD_TITLE, FrameCardTitle, } from './card/frame-card-title.js';
4
- import { AFFINE_FRAME_TITLE_EDITOR, FrameCardTitleEditor, } from './card/frame-card-title-editor.js';
5
4
  import { AFFINE_FRAME_PREVIEW, FramePreview } from './card/frame-preview.js';
6
5
  import { AFFINE_FRAME_PANEL, FramePanel } from './frame-panel.js';
7
6
  import { AFFINE_FRAME_PANEL_HEADER, FramePanelHeader, } from './header/frame-panel-header.js';
8
7
  import { AFFINE_FRAMES_SETTING_MENU, FramesSettingMenu, } from './header/frames-setting-menu.js';
9
8
  export function effects() {
10
9
  customElements.define(AFFINE_FRAME_PANEL, FramePanel);
11
- customElements.define(AFFINE_FRAME_TITLE_EDITOR, FrameCardTitleEditor);
12
10
  customElements.define(AFFINE_FRAME_CARD, FrameCard);
13
11
  customElements.define(AFFINE_FRAME_CARD_TITLE, FrameCardTitle);
14
12
  customElements.define(AFFINE_FRAME_PANEL_BODY, FramePanelBody);
@@ -68,6 +68,8 @@ const styles = css `
68
68
 
69
69
  overflow: auto;
70
70
  overflow-x: hidden;
71
+ /* A scrollbar appearing must not narrow the fluid cards it scrolls. */
72
+ scrollbar-gutter: stable;
71
73
  scrollbar-width: thin; /* For Firefox */
72
74
  scrollbar-color: transparent transparent; /* For Firefox */
73
75
  }
@@ -54,8 +54,9 @@ import { type BlockStdScope, type CommandFile } from './_pkgs/std/index.js';
54
54
  */
55
55
  export { type AnyCommandDescriptor, type CommandFile, type CommandInvocation, type CommandOwner, type CommandSurface, getCommandIcon, getCommandsForSurface, getRegisteredCommands, runCommand, runCommandAsync, } from './_pkgs/std/index.js';
56
56
  export { armArtefact } from './_pkgs/affine-widget-edgeless-toolbar/index.js';
57
- export { type SelectionPaneNode, selectionPaneTree, } from './_pkgs/affine-block-surface/index.js';
57
+ export { type SelectionPaneNode, selectionPaneCommands, selectionPaneTree, } from './_pkgs/affine-block-surface/index.js';
58
58
  export { frameCommands, type ReorderFramesParams, reorderFramesParams, } from './_pkgs/affine-block-frame/index.js';
59
+ export { createPanelReorderDrag, type PanelDragPoint, type PanelReorderDrag, type PanelReorderDragOptions, panelReorderGap, } from './_pkgs/affine-shared/utils/index.js';
59
60
  export { formatPropertyValue, isPropertyValueEmpty, } from './_pkgs/affine-fragment-doc-title/index.js';
60
61
  export type { PropertiesPanelRequest, PropertiesPanelService, TitleBandNotShownPage, TitleBandProperty, TitleBandService, TitleBandSheetState, } from './_pkgs/affine-shared/services/index.js';
61
62
  export { ThreadMarksExtension } from './_pkgs/affine-shared/services/index.js';
@@ -89,9 +90,12 @@ export declare function fitToModel(std: BlockStdScope, id: string, padding?: [nu
89
90
  * thumbnail renders one through `ExportManager` instead.
90
91
  *
91
92
  * Returns the element ready to be appended; `width` and `height` are the
92
- * preview box in CSS pixels (the panel's card is 280 × 166), `fillScreen`
93
- * covers the box instead of containing the frame. One mini editor per
94
- * preview: mount only the cards on screen. The element is defined by the
93
+ * preview box in CSS pixels, `fillScreen` covers the box instead of
94
+ * containing the frame. `fluid` (0.57) replaces the fixed box: the preview
95
+ * takes its container's width and the frame's proportions, never taller than
96
+ * wide, and follows the container as it is resized — the library's own panel
97
+ * cards draw it that way (recette 1, P0-1.2); `width` and `height` are then
98
+ * ignored. One mini editor per preview: mount only the cards on screen. The element is defined by the
95
99
  * frame panel's view extension, so it renders nothing in an assembly where the
96
100
  * `frame` flag is off (ADR 0009) — the same assembly where there is no frame
97
101
  * to preview.
@@ -100,6 +104,7 @@ export declare function createFramePreview(std: BlockStdScope, frame: FrameBlock
100
104
  width?: number;
101
105
  height?: number;
102
106
  fillScreen?: boolean;
107
+ fluid?: boolean;
103
108
  }): FramePreview;
104
109
  /**
105
110
  * One entry of the current view's own actions — what a host draws in the
@@ -57,8 +57,18 @@ import { frameworkDescriptor } from './frameworks.js';
57
57
  */
58
58
  export { getCommandIcon, getCommandsForSurface, getRegisteredCommands, runCommand, runCommandAsync, } from './_pkgs/std/index.js';
59
59
  export { armArtefact } from './_pkgs/affine-widget-edgeless-toolbar/index.js';
60
- export { selectionPaneTree, } from './_pkgs/affine-block-surface/index.js';
60
+ export { selectionPaneCommands, selectionPaneTree, } from './_pkgs/affine-block-surface/index.js';
61
61
  export { frameCommands, reorderFramesParams, } from './_pkgs/affine-block-frame/index.js';
62
+ /*
63
+ * The side panels' one drag-to-reorder gesture (ADR 0034 §6), the one the
64
+ * library's frame panel and selection pane run: a host's slide list hands it
65
+ * its rows, its drop rule and its write (`canvas.frame.reorder`), and gets the
66
+ * threshold, the read-only refusal, the cursor mask, Escape and
67
+ * `pointercancel` as cancels and the swallowed click. A factory, not a class:
68
+ * the controller it returns is the host's, disposed with its panel. DOM types
69
+ * only, so a React panel types it without Lit (recette 1, P0-1.3).
70
+ */
71
+ export { createPanelReorderDrag, panelReorderGap, } from './_pkgs/affine-shared/utils/index.js';
62
72
  /*
63
73
  * The properties panel (ADR 0035 §9b and §11). The editor asks the host to
64
74
  * show it through `PropertiesPanelExtension` and feeds the title band through
@@ -124,9 +134,12 @@ export function fitToModel(std, id, padding = [0, 0, 0, 0]) {
124
134
  * thumbnail renders one through `ExportManager` instead.
125
135
  *
126
136
  * Returns the element ready to be appended; `width` and `height` are the
127
- * preview box in CSS pixels (the panel's card is 280 × 166), `fillScreen`
128
- * covers the box instead of containing the frame. One mini editor per
129
- * preview: mount only the cards on screen. The element is defined by the
137
+ * preview box in CSS pixels, `fillScreen` covers the box instead of
138
+ * containing the frame. `fluid` (0.57) replaces the fixed box: the preview
139
+ * takes its container's width and the frame's proportions, never taller than
140
+ * wide, and follows the container as it is resized — the library's own panel
141
+ * cards draw it that way (recette 1, P0-1.2); `width` and `height` are then
142
+ * ignored. One mini editor per preview: mount only the cards on screen. The element is defined by the
130
143
  * frame panel's view extension, so it renders nothing in an assembly where the
131
144
  * `frame` flag is off (ADR 0009) — the same assembly where there is no frame
132
145
  * to preview.
@@ -141,6 +154,8 @@ export function createFramePreview(std, frame, options = {}) {
141
154
  preview.surfaceHeight = options.height;
142
155
  if (options.fillScreen !== undefined)
143
156
  preview.fillScreen = options.fillScreen;
157
+ if (options.fluid !== undefined)
158
+ preview.fluid = options.fluid;
144
159
  return preview;
145
160
  }
146
161
  /**
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.56.0",
4
+ "version": "0.57.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "author": "lajola",
@@ -1,25 +0,0 @@
1
- import type { FrameBlockModel } from '../../affine-model/index.js';
2
- import type { RichText } from '../../affine-rich-text/index.js';
3
- import { ShadowlessElement } from '../../std/index.js';
4
- export declare const AFFINE_FRAME_TITLE_EDITOR = "affine-frame-card-title-editor";
5
- declare const FrameCardTitleEditor_base: typeof ShadowlessElement & import("../../global/utils/types.js").Constructor<import("../../global/lit/with-disposable.js").DisposableClass>;
6
- export declare class FrameCardTitleEditor extends FrameCardTitleEditor_base {
7
- static styles: import("lit").CSSResult;
8
- private readonly _isComposing;
9
- get inlineEditor(): import("../../affine-shared/types/index.js").AffineInlineEditor | null;
10
- private _unmount;
11
- firstUpdated(): void;
12
- getUpdateComplete(): Promise<boolean>;
13
- render(): import("lit-html").TemplateResult<1>;
14
- accessor frameModel: FrameBlockModel;
15
- accessor left: number;
16
- accessor maxWidth: number;
17
- accessor richText: RichText;
18
- accessor titleContentElement: HTMLElement;
19
- }
20
- declare global {
21
- interface HTMLElementTagNameMap {
22
- [AFFINE_FRAME_TITLE_EDITOR]: FrameCardTitleEditor;
23
- }
24
- }
25
- export {};
@@ -1,181 +0,0 @@
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 { WithDisposable } from '../../global/lit/index.js';
36
- import { ShadowlessElement } from '../../std/index.js';
37
- import { css, html } from 'lit';
38
- import { property, query } from 'lit/decorators.js';
39
- import { styleMap } from 'lit/directives/style-map.js';
40
- const styles = css `
41
- frame-card-title-editor rich-text .nowrap-lines::-webkit-scrollbar {
42
- display: none;
43
- }
44
- `;
45
- export const AFFINE_FRAME_TITLE_EDITOR = 'affine-frame-card-title-editor';
46
- let FrameCardTitleEditor = (() => {
47
- let _classSuper = WithDisposable(ShadowlessElement);
48
- let _frameModel_decorators;
49
- let _frameModel_initializers = [];
50
- let _frameModel_extraInitializers = [];
51
- let _left_decorators;
52
- let _left_initializers = [];
53
- let _left_extraInitializers = [];
54
- let _maxWidth_decorators;
55
- let _maxWidth_initializers = [];
56
- let _maxWidth_extraInitializers = [];
57
- let _richText_decorators;
58
- let _richText_initializers = [];
59
- let _richText_extraInitializers = [];
60
- let _titleContentElement_decorators;
61
- let _titleContentElement_initializers = [];
62
- let _titleContentElement_extraInitializers = [];
63
- return class FrameCardTitleEditor extends _classSuper {
64
- static {
65
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
66
- _frameModel_decorators = [property({ attribute: false })];
67
- _left_decorators = [property({ attribute: false })];
68
- _maxWidth_decorators = [property({ attribute: false })];
69
- _richText_decorators = [query('rich-text')];
70
- _titleContentElement_decorators = [property({ attribute: false })];
71
- __esDecorate(this, null, _frameModel_decorators, { kind: "accessor", name: "frameModel", static: false, private: false, access: { has: obj => "frameModel" in obj, get: obj => obj.frameModel, set: (obj, value) => { obj.frameModel = value; } }, metadata: _metadata }, _frameModel_initializers, _frameModel_extraInitializers);
72
- __esDecorate(this, null, _left_decorators, { kind: "accessor", name: "left", static: false, private: false, access: { has: obj => "left" in obj, get: obj => obj.left, set: (obj, value) => { obj.left = value; } }, metadata: _metadata }, _left_initializers, _left_extraInitializers);
73
- __esDecorate(this, null, _maxWidth_decorators, { kind: "accessor", name: "maxWidth", static: false, private: false, access: { has: obj => "maxWidth" in obj, get: obj => obj.maxWidth, set: (obj, value) => { obj.maxWidth = value; } }, metadata: _metadata }, _maxWidth_initializers, _maxWidth_extraInitializers);
74
- __esDecorate(this, null, _richText_decorators, { kind: "accessor", name: "richText", static: false, private: false, access: { has: obj => "richText" in obj, get: obj => obj.richText, set: (obj, value) => { obj.richText = value; } }, metadata: _metadata }, _richText_initializers, _richText_extraInitializers);
75
- __esDecorate(this, null, _titleContentElement_decorators, { kind: "accessor", name: "titleContentElement", static: false, private: false, access: { has: obj => "titleContentElement" in obj, get: obj => obj.titleContentElement, set: (obj, value) => { obj.titleContentElement = value; } }, metadata: _metadata }, _titleContentElement_initializers, _titleContentElement_extraInitializers);
76
- if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
77
- }
78
- static { this.styles = styles; }
79
- get inlineEditor() {
80
- return this.richText.inlineEditor;
81
- }
82
- _unmount() {
83
- // dispose in advance to avoid execute `this.remove()` twice
84
- this.disposables.dispose();
85
- this.remove();
86
- this.titleContentElement.style.display = 'block';
87
- }
88
- firstUpdated() {
89
- this.updateComplete
90
- .then(() => {
91
- if (this.inlineEditor === null)
92
- return;
93
- this.titleContentElement.style.display = 'none';
94
- this.inlineEditor.selectAll();
95
- this.inlineEditor.slots.renderComplete.subscribe(() => {
96
- this.requestUpdate();
97
- });
98
- const inlineEditorContainer = this.inlineEditor.rootElement;
99
- if (!inlineEditorContainer)
100
- return;
101
- this.disposables.addFromEvent(inlineEditorContainer, 'blur', () => {
102
- this._unmount();
103
- });
104
- this.disposables.addFromEvent(inlineEditorContainer, 'click', e => {
105
- e.stopPropagation();
106
- });
107
- this.disposables.addFromEvent(inlineEditorContainer, 'dblclick', e => {
108
- e.stopPropagation();
109
- });
110
- this.disposables.addFromEvent(inlineEditorContainer, 'keydown', e => {
111
- e.stopPropagation();
112
- if (e.key === 'Enter' && !this._isComposing) {
113
- this._unmount();
114
- }
115
- });
116
- })
117
- .catch(console.error);
118
- }
119
- async getUpdateComplete() {
120
- const result = await super.getUpdateComplete();
121
- await this.richText?.updateComplete;
122
- return result;
123
- }
124
- render() {
125
- const inlineEditorStyle = styleMap({
126
- transformOrigin: 'top left',
127
- borderRadius: '4px',
128
- maxWidth: `${this.maxWidth}px`,
129
- maxHeight: '20px',
130
- width: 'fit-content',
131
- height: '20px',
132
- fontSize: 'var(--affine-font-sm)',
133
- lineHeight: '20px',
134
- position: 'absolute',
135
- left: `${this.left}px`,
136
- top: '0px',
137
- minWidth: '8px',
138
- background: 'var(--affine-background-primary-color)',
139
- border: '1px solid var(--affine-primary-color)',
140
- color: 'var(--affine-text-primary-color)',
141
- boxShadow: '0px 0px 0px 2px color-mix(in srgb, var(--affine-primary-color) 30%, transparent)',
142
- zIndex: '1',
143
- display: 'block',
144
- });
145
- return html `<rich-text
146
- .yText=${this.frameModel.props.title.yText}
147
- .enableFormat=${false}
148
- .enableAutoScrollHorizontally=${true}
149
- .enableUndoRedo=${false}
150
- .wrapText=${false}
151
- style=${inlineEditorStyle}
152
- ></rich-text>`;
153
- }
154
- #frameModel_accessor_storage;
155
- get frameModel() { return this.#frameModel_accessor_storage; }
156
- set frameModel(value) { this.#frameModel_accessor_storage = value; }
157
- #left_accessor_storage;
158
- get left() { return this.#left_accessor_storage; }
159
- set left(value) { this.#left_accessor_storage = value; }
160
- #maxWidth_accessor_storage;
161
- get maxWidth() { return this.#maxWidth_accessor_storage; }
162
- set maxWidth(value) { this.#maxWidth_accessor_storage = value; }
163
- #richText_accessor_storage;
164
- get richText() { return this.#richText_accessor_storage; }
165
- set richText(value) { this.#richText_accessor_storage = value; }
166
- #titleContentElement_accessor_storage;
167
- get titleContentElement() { return this.#titleContentElement_accessor_storage; }
168
- set titleContentElement(value) { this.#titleContentElement_accessor_storage = value; }
169
- constructor() {
170
- super(...arguments);
171
- this._isComposing = false;
172
- this.#frameModel_accessor_storage = __runInitializers(this, _frameModel_initializers, void 0);
173
- this.#left_accessor_storage = (__runInitializers(this, _frameModel_extraInitializers), __runInitializers(this, _left_initializers, void 0));
174
- this.#maxWidth_accessor_storage = (__runInitializers(this, _left_extraInitializers), __runInitializers(this, _maxWidth_initializers, void 0));
175
- this.#richText_accessor_storage = (__runInitializers(this, _maxWidth_extraInitializers), __runInitializers(this, _richText_initializers, void 0));
176
- this.#titleContentElement_accessor_storage = (__runInitializers(this, _richText_extraInitializers), __runInitializers(this, _titleContentElement_initializers, void 0));
177
- __runInitializers(this, _titleContentElement_extraInitializers);
178
- }
179
- };
180
- })();
181
- export { FrameCardTitleEditor };