@formicoidea/labre-core 0.45.0 → 0.46.1

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 (73) hide show
  1. package/dist/_pkgs/affine-block-callout/commands/turn-callout-into.d.ts +43 -0
  2. package/dist/_pkgs/affine-block-callout/commands/turn-callout-into.js +109 -0
  3. package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.d.ts +1 -1
  4. package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.js +1 -1
  5. package/dist/_pkgs/affine-block-callout/configs/slash-menu.js +4 -2
  6. package/dist/_pkgs/affine-block-callout/configs/toolbar.d.ts +65 -0
  7. package/dist/_pkgs/affine-block-callout/configs/toolbar.js +178 -0
  8. package/dist/_pkgs/affine-block-callout/view.d.ts +30 -1
  9. package/dist/_pkgs/affine-block-callout/view.js +45 -3
  10. package/dist/_pkgs/affine-block-code/code-toolbar/components/lang-button.js +1 -1
  11. package/dist/_pkgs/affine-block-frame/commands.d.ts +27 -0
  12. package/dist/_pkgs/affine-block-frame/commands.js +49 -0
  13. package/dist/_pkgs/affine-block-frame/frame-manager.d.ts +11 -6
  14. package/dist/_pkgs/affine-block-frame/frame-manager.js +10 -5
  15. package/dist/_pkgs/affine-block-frame/frame-order.d.ts +43 -0
  16. package/dist/_pkgs/affine-block-frame/frame-order.js +93 -0
  17. package/dist/_pkgs/affine-block-frame/index.d.ts +2 -0
  18. package/dist/_pkgs/affine-block-frame/index.js +2 -0
  19. package/dist/_pkgs/affine-block-frame/present/frame-order-menu.d.ts +10 -2
  20. package/dist/_pkgs/affine-block-frame/present/frame-order-menu.js +32 -18
  21. package/dist/_pkgs/affine-block-frame/view.js +6 -0
  22. package/dist/_pkgs/affine-block-note/configs/toolbar.d.ts +19 -0
  23. package/dist/_pkgs/affine-block-note/configs/toolbar.js +38 -23
  24. package/dist/_pkgs/affine-block-note/translations.d.ts +2 -0
  25. package/dist/_pkgs/affine-block-note/translations.js +14 -1
  26. package/dist/_pkgs/affine-block-root/configs/toolbar.js +31 -2
  27. package/dist/_pkgs/affine-block-root/translations.d.ts +7 -2
  28. package/dist/_pkgs/affine-block-root/translations.js +10 -13
  29. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.d.ts +20 -9
  30. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.js +57 -20
  31. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.d.ts +6 -8
  32. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.js +21 -8
  33. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.d.ts +1 -1
  34. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.js +1 -1
  35. package/dist/_pkgs/affine-components/portal/portal.d.ts +1 -1
  36. package/dist/_pkgs/affine-foundation/view.d.ts +8 -8
  37. package/dist/_pkgs/affine-fragment-frame-panel/body/frame-panel-body.d.ts +34 -2
  38. package/dist/_pkgs/affine-fragment-frame-panel/body/frame-panel-body.js +194 -81
  39. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.d.ts +7 -4
  40. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.js +9 -24
  41. package/dist/_pkgs/affine-fragment-frame-panel/index.d.ts +1 -0
  42. package/dist/_pkgs/affine-fragment-frame-panel/index.js +1 -0
  43. package/dist/_pkgs/affine-model/utils/types.d.ts +2 -2
  44. package/dist/_pkgs/affine-shared/services/edit-props-store.d.ts +4 -4
  45. package/dist/_pkgs/affine-shared/services/font-loader/config.d.ts +2 -2
  46. package/dist/_pkgs/affine-shared/services/font-loader/font-loader-service.d.ts +3 -3
  47. package/dist/_pkgs/affine-shared/services/index.d.ts +1 -1
  48. package/dist/_pkgs/affine-shared/services/index.js +1 -1
  49. package/dist/_pkgs/affine-shared/services/link-preview-service/link-preview-storage.d.ts +4 -4
  50. package/dist/_pkgs/affine-shared/services/outline-panel-service.d.ts +31 -0
  51. package/dist/_pkgs/affine-shared/services/outline-panel-service.js +17 -0
  52. package/dist/_pkgs/affine-shared/services/translation-service/chrome.d.ts +11 -0
  53. package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +19 -0
  54. package/dist/_pkgs/affine-shared/utils/index.d.ts +1 -0
  55. package/dist/_pkgs/affine-shared/utils/index.js +1 -0
  56. package/dist/_pkgs/affine-shared/utils/panel-reorder-drag.d.ts +85 -0
  57. package/dist/_pkgs/affine-shared/utils/panel-reorder-drag.js +162 -0
  58. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.d.ts +7 -6
  59. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.js +11 -8
  60. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.d.ts +31 -15
  61. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.js +178 -142
  62. package/dist/_pkgs/std/scope/std-scope.d.ts +1 -1
  63. package/dist/commands.js +2 -0
  64. package/dist/extensions/view.js +5 -1
  65. package/dist/flags.d.ts +3 -0
  66. package/dist/flags.js +3 -0
  67. package/dist/host-panels.d.ts +90 -0
  68. package/dist/host-panels.js +111 -0
  69. package/package.json +5 -1
  70. package/dist/_pkgs/affine-fragment-frame-panel/utils/drag.d.ts +0 -27
  71. package/dist/_pkgs/affine-fragment-frame-panel/utils/drag.js +0 -96
  72. package/dist/_pkgs/affine-shared/services/sidebar-service.d.ts +0 -8
  73. package/dist/_pkgs/affine-shared/services/sidebar-service.js +0 -7
@@ -32,20 +32,35 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
32
32
  }
33
33
  return useValue ? value : void 0;
34
34
  };
35
- import { EdgelessFrameManager } from '../../affine-block-frame/index.js';
35
+ import { EdgelessFrameManager, frameCommands } from '../../affine-block-frame/index.js';
36
36
  import { DocModeProvider, EditPropsStore, translateKey, } from '../../affine-shared/services/index.js';
37
+ import { createPanelReorderDrag, } from '../../affine-shared/utils/index.js';
37
38
  import { DisposableGroup } from '../../global/disposable/index.js';
38
39
  import { Bound } from '../../global/gfx/index.js';
39
40
  import { SignalWatcher, WithDisposable } from '../../global/lit/index.js';
40
- import { ShadowlessElement } from '../../std/index.js';
41
- import { generateKeyBetweenV2, GfxControllerIdentifier } from '../../std/gfx/index.js';
41
+ import { runCommand, ShadowlessElement, } from '../../std/index.js';
42
+ import { GfxControllerIdentifier } from '../../std/gfx/index.js';
42
43
  import { css, html, nothing } from 'lit';
43
44
  import { property, query, state } from 'lit/decorators.js';
44
45
  import { keyed } from 'lit/directives/keyed.js';
45
46
  import { repeat } from 'lit/directives/repeat.js';
47
+ import { FrameCard, } from '../card/frame-card.js';
46
48
  import { FRAME_PANEL_EMPTY_PLACEHOLDER } from '../translations.js';
47
- import { startDragging } from '../utils/drag.js';
48
49
  const compare = EdgelessFrameManager.framePresentationComparator;
50
+ /**
51
+ * How the panel invokes the registry: from the editor's chrome, on the cards
52
+ * it names, like the selection pane's rows.
53
+ */
54
+ const PANEL_INVOCATION = {
55
+ surface: 'contextual-toolbar',
56
+ source: 'toolbar:general',
57
+ };
58
+ function reorderCommand() {
59
+ const command = frameCommands.find(c => c.id === 'canvas.frame.reorder');
60
+ if (!command)
61
+ throw new Error('frame panel: no canvas.frame.reorder');
62
+ return command;
63
+ }
49
64
  const styles = css `
50
65
  .frame-list-container {
51
66
  display: flex;
@@ -89,6 +104,19 @@ const styles = css `
89
104
  width: 284px;
90
105
  left: 0;
91
106
  }
107
+
108
+ /*
109
+ The drag mask, created by the drag controller (createPanelReorderDrag):
110
+ over the whole viewport for the length of the drag, so its cursor — set
111
+ inline by the controller, "grabbing" or "not-allowed" — speaks wherever
112
+ the pointer is. The dragged cards are appended after it, so they paint
113
+ over it.
114
+ */
115
+ .frame-panel-drag-mask {
116
+ position: fixed;
117
+ inset: 0;
118
+ z-index: calc(var(--affine-z-index-popover, 0) + 3);
119
+ }
92
120
  `;
93
121
  export const AFFINE_FRAME_PANEL_BODY = 'affine-frame-panel-body';
94
122
  let FramePanelBody = (() => {
@@ -99,9 +127,6 @@ let FramePanelBody = (() => {
99
127
  let __selected_decorators;
100
128
  let __selected_initializers = [];
101
129
  let __selected_extraInitializers = [];
102
- let _domHost_decorators;
103
- let _domHost_initializers = [];
104
- let _domHost_extraInitializers = [];
105
130
  let _editorHost_decorators;
106
131
  let _editorHost_initializers = [];
107
132
  let _editorHost_extraInitializers = [];
@@ -119,14 +144,12 @@ let FramePanelBody = (() => {
119
144
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
120
145
  __dragging_decorators = [state()];
121
146
  __selected_decorators = [state()];
122
- _domHost_decorators = [property({ attribute: false })];
123
147
  _editorHost_decorators = [property({ attribute: false })];
124
148
  _fitPadding_decorators = [property({ attribute: false })];
125
149
  _frameListContainer_decorators = [query('.frame-list-container')];
126
150
  _insertIndex_decorators = [property({ attribute: false })];
127
151
  __esDecorate(this, null, __dragging_decorators, { kind: "accessor", name: "_dragging", static: false, private: false, access: { has: obj => "_dragging" in obj, get: obj => obj._dragging, set: (obj, value) => { obj._dragging = value; } }, metadata: _metadata }, __dragging_initializers, __dragging_extraInitializers);
128
152
  __esDecorate(this, null, __selected_decorators, { kind: "accessor", name: "_selected", static: false, private: false, access: { has: obj => "_selected" in obj, get: obj => obj._selected, set: (obj, value) => { obj._selected = value; } }, metadata: _metadata }, __selected_initializers, __selected_extraInitializers);
129
- __esDecorate(this, null, _domHost_decorators, { kind: "accessor", name: "domHost", static: false, private: false, access: { has: obj => "domHost" in obj, get: obj => obj.domHost, set: (obj, value) => { obj.domHost = value; } }, metadata: _metadata }, _domHost_initializers, _domHost_extraInitializers);
130
153
  __esDecorate(this, null, _editorHost_decorators, { kind: "accessor", name: "editorHost", static: false, private: false, access: { has: obj => "editorHost" in obj, get: obj => obj.editorHost, set: (obj, value) => { obj.editorHost = value; } }, metadata: _metadata }, _editorHost_initializers, _editorHost_extraInitializers);
131
154
  __esDecorate(this, null, _fitPadding_decorators, { kind: "accessor", name: "fitPadding", static: false, private: false, access: { has: obj => "fitPadding" in obj, get: obj => obj.fitPadding, set: (obj, value) => { obj.fitPadding = value; } }, metadata: _metadata }, _fitPadding_initializers, _fitPadding_extraInitializers);
132
155
  __esDecorate(this, null, _frameListContainer_decorators, { kind: "accessor", name: "frameListContainer", static: false, private: false, access: { has: obj => "frameListContainer" in obj, get: obj => obj.frameListContainer, set: (obj, value) => { obj.frameListContainer = value; } }, metadata: _metadata }, _frameListContainer_initializers, _frameListContainer_extraInitializers);
@@ -148,53 +171,129 @@ let FramePanelBody = (() => {
148
171
  ? [0, 0, 0, 0].map((val, idx) => Number.isFinite(this.fitPadding[idx]) ? this.fitPadding[idx] : val)
149
172
  : [0, 0, 0, 0];
150
173
  }
151
- _drag(e) {
152
- if (!this._selected.length)
153
- return;
154
- this._dragging = true;
155
- const framesMap = this._frameItems.reduce((map, frame) => {
156
- map.set(frame.frame.id, {
157
- ...frame,
158
- });
159
- return map;
160
- }, new Map());
161
- const selected = this._selected.slice();
162
- const draggedFramesInfo = selected.map(id => {
163
- const frame = framesMap.get(id);
164
- return {
165
- frame: frame.frame,
166
- element: this.renderRoot.querySelector(`[data-frame-id="${frame.frame.id}"]`),
167
- cardIndex: frame.cardIndex,
168
- frameIndex: frame.frameIndex,
169
- };
170
- });
171
- const width = draggedFramesInfo[0].element.clientWidth;
172
- this._frameElementHeight = draggedFramesInfo[0].element.offsetHeight;
173
- startDragging(draggedFramesInfo, {
174
- width,
175
- container: this,
176
- document: this.ownerDocument,
177
- domHost: this.domHost ?? this.ownerDocument,
178
- start: {
179
- x: e.detail.clientX,
180
- y: e.detail.clientY,
174
+ /* ── Drag to reorder ────────────────────────────────────────────────── */
175
+ /*
176
+ * The gesture is the side panels' one controller (`createPanelReorderDrag`,
177
+ * `@labre/affine-shared/utils`, ADR 0034), shared with the selection pane:
178
+ * pointer events, the 5px threshold, the read-only refusal, the mask and
179
+ * its cursor, Escape and `pointercancel` as cancels, the swallowed click.
180
+ * What is the panel's own is below: the selected cards move together, their
181
+ * copies follow the pointer, a line marks the gap, and the write is
182
+ * `canvas.frame.reorder`.
183
+ */
184
+ _createReorderDrag() {
185
+ return createPanelReorderDrag({
186
+ readonly: () => this.editorHost.store.readonly,
187
+ rows: () => this._cards(),
188
+ bounds: () => this,
189
+ onPickUp: press => this._pickUp(press),
190
+ dropAt: gap => this._dropAt(gap),
191
+ onMove: (drop, point) => {
192
+ for (const ghost of this._ghosts) {
193
+ ghost.pos = { x: point.clientX, y: point.clientY };
194
+ }
195
+ this._indicatorTranslateY = drop?.lineY ?? 0;
196
+ this.insertIndex = drop?.gap;
197
+ this.requestUpdate();
181
198
  },
182
- framePanelBody: this,
183
- frameListContainer: this.frameListContainer,
184
- frameElementHeight: this._frameElementHeight,
185
- onDragEnd: insertIdx => {
199
+ onDrop: drop => this._reorderFrames(this._selected.slice(), drop.before),
200
+ onEnd: () => {
201
+ this._ghosts.forEach(ghost => ghost.remove());
202
+ this._ghosts = [];
203
+ this._pressed = null;
186
204
  this._dragging = false;
187
205
  this.insertIndex = undefined;
188
- if (insertIdx === undefined || this._frameItems.length <= 1)
189
- return;
190
- this._reorderFrames(selected, framesMap, insertIdx);
206
+ this._updateFrames();
191
207
  },
192
- onDragMove: (idx, indicatorTranslateY) => {
193
- this.insertIndex = idx;
194
- this._indicatorTranslateY = indicatorTranslateY ?? 0;
208
+ mask: {
209
+ host: () => this,
210
+ className: 'frame-panel-drag-mask',
211
+ testId: 'frame-panel-drag-mask',
195
212
  },
196
213
  });
197
214
  }
215
+ /** The cards on screen, in presentation order. */
216
+ _cards() {
217
+ const list = this.frameListContainer;
218
+ if (!list)
219
+ return [];
220
+ return Array.from(list.querySelectorAll(':scope > affine-frame-card'));
221
+ }
222
+ /** A press on a card: the controller decides whether it becomes a drag. */
223
+ _drag(e) {
224
+ const { event } = e.detail;
225
+ this._pressed = {
226
+ card: e.currentTarget,
227
+ shiftKey: event.shiftKey,
228
+ };
229
+ this._reorder?.press(event);
230
+ }
231
+ /**
232
+ * The press became a drag. The pressed card is selected if it was not
233
+ * (shift adds it to the selection), and every selected card moves: their
234
+ * copies — the last two, the top one counting them — follow the pointer,
235
+ * and the cards themselves stay in place as placeholders.
236
+ */
237
+ _pickUp(press) {
238
+ const card = this._pressed?.card;
239
+ if (!card?.frame)
240
+ return;
241
+ const id = card.frame.id;
242
+ if (!this._selected.includes(id)) {
243
+ this._selected = this._pressed?.shiftKey ? [...this._selected, id] : [id];
244
+ this._gfx.selection.set({ elements: this._selected, editing: false });
245
+ }
246
+ const list = this.frameListContainer;
247
+ this._listGap = list ? parseFloat(getComputedStyle(list).gap) || 0 : 0;
248
+ const items = new Map(this._frameItems.map(item => [item.frame.id, item]));
249
+ const dragged = this._selected.flatMap(selected => {
250
+ const item = items.get(selected);
251
+ return item ? [item] : [];
252
+ });
253
+ const width = this.renderRoot.querySelector(`[data-frame-id="${dragged[0]?.frame.id}"]`)?.clientWidth ?? card.clientWidth;
254
+ this._ghosts = dragged.slice(-2).map((item, idx, arr) => {
255
+ const ghost = new FrameCard();
256
+ ghost.frame = item.frame;
257
+ ghost.cardIndex = item.cardIndex;
258
+ ghost.frameIndex = item.frameIndex;
259
+ ghost.status = 'dragging';
260
+ ghost.stackOrder = arr.length - 1 - idx;
261
+ ghost.pos = { x: press.clientX, y: press.clientY };
262
+ ghost.width = width;
263
+ ghost.std = this.editorHost.std;
264
+ if (ghost.stackOrder === 0) {
265
+ ghost.dataset.testid = 'frame-panel-drag-ghost';
266
+ if (dragged.length > 1)
267
+ ghost.draggingCardNumber = dragged.length;
268
+ }
269
+ return ghost;
270
+ });
271
+ this.renderRoot.append(...this._ghosts);
272
+ this._dragging = true;
273
+ }
274
+ /**
275
+ * A release at the gap `gap` puts the selected cards right before the first
276
+ * card at or after it that does not move, or at the end. The line sits in
277
+ * the middle of the list's gap: above the card under the gap, or under the
278
+ * last card — the frame panel's own drag used to draw that last one at 0.
279
+ */
280
+ _dropAt(gap) {
281
+ const cards = this._cards();
282
+ const last = cards[cards.length - 1];
283
+ if (!last)
284
+ return null;
285
+ const moving = new Set(this._selected);
286
+ const before = cards
287
+ .slice(gap)
288
+ .map(card => card.frame?.id)
289
+ .find(id => id !== undefined && !moving.has(id)) ?? null;
290
+ const half = this._listGap / 2;
291
+ const under = cards[gap];
292
+ const lineY = under
293
+ ? under.offsetTop - half
294
+ : last.offsetTop + last.offsetHeight + half;
295
+ return { gap, before, lineY };
296
+ }
198
297
  _fitToElement(e) {
199
298
  const { block } = e.detail;
200
299
  const bound = Bound.deserialize(block.xywh);
@@ -246,6 +345,7 @@ let FramePanelBody = (() => {
246
345
  ${this.insertIndex !== undefined
247
346
  ? html `<div
248
347
  class="insert-indicator"
348
+ data-testid="frame-panel-drop-indicator"
249
349
  style=${`transform: translateY(${this._indicatorTranslateY}px)`}
250
350
  ></div>`
251
351
  : nothing}
@@ -253,37 +353,41 @@ let FramePanelBody = (() => {
253
353
  </div>`;
254
354
  return frameList;
255
355
  }
256
- _reorderFrames(selected, framesMap, insertIndex) {
257
- if (insertIndex >= 0 && insertIndex <= this._frameItems.length) {
258
- const frames = Array.from(framesMap.values()).map(frameItem => frameItem.frame);
259
- const selectedFrames = selected
260
- .map(id => framesMap.get(id))
261
- .map(frameItem => frameItem.frame)
262
- .sort(compare);
263
- // update selected frames index
264
- // make the indexes larger than the frame before and smaller than the frame after
265
- let before = frames[insertIndex - 1]?.props.presentationIndex || null;
266
- const after = frames[insertIndex]?.props.presentationIndex || null;
267
- selectedFrames.forEach(frame => {
268
- const newIndex = generateKeyBetweenV2(before, after);
269
- frame.store.updateBlock(frame, {
270
- presentationIndex: newIndex,
271
- });
272
- before = newIndex;
273
- });
274
- this.editorHost.store.captureSync();
275
- this._updateFrames();
276
- }
356
+ /**
357
+ * Move the selected cards, as one block, right before the frame `before`
358
+ * (`null` = at the end; `_dropAt` picks it). The write is
359
+ * `canvas.frame.reorder` (ADR 0034): the read-only refusal, the no-op check
360
+ * and the one undo step live in its action, run through the imported
361
+ * descriptor so the panel reorders in page mode too, where the command is
362
+ * not registered.
363
+ */
364
+ _reorderFrames(selected, before) {
365
+ if (!selected.length)
366
+ return;
367
+ runCommand(this.editorHost.std, reorderCommand(), PANEL_INVOCATION, {
368
+ ids: selected,
369
+ before,
370
+ });
371
+ this._updateFrames();
277
372
  }
278
373
  _setDocDisposables(doc) {
279
374
  this._clearDocDisposables();
280
375
  this._docDisposables = new DisposableGroup();
281
- this._docDisposables.add(doc.slots.blockUpdated.subscribe(({ type, flavour }) => {
282
- if (flavour === 'affine:frame' && type !== 'update') {
283
- requestAnimationFrame(() => {
284
- this._updateFrames();
285
- });
376
+ this._docDisposables.add(doc.slots.blockUpdated.subscribe(payload => {
377
+ if (payload.flavour !== 'affine:frame')
378
+ return;
379
+ // A frame added or deleted changes the cards; of the updates, only a
380
+ // new presentation order does. The panel is not the order's only
381
+ // writer — an undo, a host's slide panel running
382
+ // `canvas.frame.reorder`, a remote peer — and it went stale on all
383
+ // three until reopened.
384
+ if (payload.type === 'update' &&
385
+ payload.props.key !== 'presentationIndex') {
386
+ return;
286
387
  }
388
+ requestAnimationFrame(() => {
389
+ this._updateFrames();
390
+ });
287
391
  }));
288
392
  }
289
393
  _updateFrames() {
@@ -316,10 +420,13 @@ let FramePanelBody = (() => {
316
420
  connectedCallback() {
317
421
  super.connectedCallback();
318
422
  this._updateFrameItems();
423
+ this._reorder = this._createReorderDrag();
319
424
  }
320
425
  disconnectedCallback() {
321
426
  super.disconnectedCallback();
322
427
  this._clearDocDisposables();
428
+ this._reorder?.dispose();
429
+ this._reorder = null;
323
430
  }
324
431
  firstUpdated() {
325
432
  const disposables = this.disposables;
@@ -354,9 +461,6 @@ let FramePanelBody = (() => {
354
461
  // Store the ids of the selected frames
355
462
  get _selected() { return this.#_selected_accessor_storage; }
356
463
  set _selected(value) { this.#_selected_accessor_storage = value; }
357
- #domHost_accessor_storage;
358
- get domHost() { return this.#domHost_accessor_storage; }
359
- set domHost(value) { this.#domHost_accessor_storage = value; }
360
464
  #editorHost_accessor_storage;
361
465
  get editorHost() { return this.#editorHost_accessor_storage; }
362
466
  set editorHost(value) { this.#editorHost_accessor_storage = value; }
@@ -392,11 +496,21 @@ let FramePanelBody = (() => {
392
496
  });
393
497
  };
394
498
  this._docDisposables = null;
395
- this._frameElementHeight = 0;
396
499
  this._frameItems = [];
500
+ /** The side panels' one reorder gesture (ADR 0034), made on connect. */
501
+ this._reorder = null;
502
+ /** The card a press landed on: what a pick-up picks up. */
503
+ this._pressed = null;
504
+ /** The dragged cards' copies following the pointer, top one last. */
505
+ this._ghosts = [];
506
+ /** The list's `gap`, read once at the pick-up: the drop line sits in it. */
507
+ this._listGap = 0;
397
508
  this._indicatorTranslateY = 0;
398
509
  this._lastEdgelessRootId = '';
399
510
  this._selectFrame = (e) => {
511
+ // A drag ends with a click on the card it started on; that click is not one.
512
+ if (this._reorder?.consumeSwallowedClick())
513
+ return;
400
514
  const { selected, id, multiselect } = e.detail;
401
515
  if (!selected) {
402
516
  // de-select frame
@@ -422,8 +536,7 @@ let FramePanelBody = (() => {
422
536
  };
423
537
  this.#_dragging_accessor_storage = __runInitializers(this, __dragging_initializers, false);
424
538
  this.#_selected_accessor_storage = (__runInitializers(this, __dragging_extraInitializers), __runInitializers(this, __selected_initializers, []));
425
- this.#domHost_accessor_storage = (__runInitializers(this, __selected_extraInitializers), __runInitializers(this, _domHost_initializers, void 0));
426
- this.#editorHost_accessor_storage = (__runInitializers(this, _domHost_extraInitializers), __runInitializers(this, _editorHost_initializers, void 0));
539
+ this.#editorHost_accessor_storage = (__runInitializers(this, __selected_extraInitializers), __runInitializers(this, _editorHost_initializers, void 0));
427
540
  this.#fitPadding_accessor_storage = (__runInitializers(this, _editorHost_extraInitializers), __runInitializers(this, _fitPadding_initializers, void 0));
428
541
  this.#frameListContainer_accessor_storage = (__runInitializers(this, _fitPadding_extraInitializers), __runInitializers(this, _frameListContainer_initializers, void 0));
429
542
  this.#insertIndex_accessor_storage = (__runInitializers(this, _frameListContainer_extraInitializers), __runInitializers(this, _insertIndex_initializers, undefined));
@@ -11,11 +11,9 @@ export type SelectEvent = CustomEvent<{
11
11
  index: number;
12
12
  multiselect: boolean;
13
13
  }>;
14
+ /** A press on a card's body, handed to the panel's drag controller. */
14
15
  export type DragEvent = CustomEvent<{
15
- clientX: number;
16
- clientY: number;
17
- pageX: number;
18
- pageY: number;
16
+ event: PointerEvent;
19
17
  }>;
20
18
  export type FitViewEvent = CustomEvent<{
21
19
  block: FrameBlockModel;
@@ -24,6 +22,11 @@ export declare const AFFINE_FRAME_CARD = "affine-frame-card";
24
22
  declare const FrameCard_base: typeof ShadowlessElement & import("../../global/utils/types.js").Constructor<import("../../global/lit/with-disposable.js").DisposableClass>;
25
23
  export declare class FrameCard extends FrameCard_base {
26
24
  static styles: import("lit").CSSResult;
25
+ /**
26
+ * Hand the press to the panel body: the threshold, the selection and the
27
+ * drag itself belong to the side panels' one controller, which the body
28
+ * holds (`createPanelReorderDrag`, ADR 0034).
29
+ */
27
30
  private _dispatchDragEvent;
28
31
  private _dispatchFitViewEvent;
29
32
  private _dispatchSelectEvent;
@@ -32,8 +32,6 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
32
32
  }
33
33
  return useValue ? value : void 0;
34
34
  };
35
- import { panelDragStarted } from '../../affine-shared/styles/index.js';
36
- import { on, once } from '../../affine-shared/utils/index.js';
37
35
  import { WithDisposable } from '../../global/lit/index.js';
38
36
  import { ShadowlessElement } from '../../std/index.js';
39
37
  import { css, html, nothing } from 'lit';
@@ -169,32 +167,19 @@ let FrameCard = (() => {
169
167
  if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
170
168
  }
171
169
  static { this.styles = styles; }
170
+ /**
171
+ * Hand the press to the panel body: the threshold, the selection and the
172
+ * drag itself belong to the side panels' one controller, which the body
173
+ * holds (`createPanelReorderDrag`, ADR 0034).
174
+ */
172
175
  _dispatchDragEvent(e) {
173
176
  e.preventDefault();
174
177
  if (e.button !== 0)
175
178
  return;
176
- const { clientX: startX, clientY: startY } = e;
177
- const disposeDragStart = on(this.ownerDocument, 'mousemove', e => {
178
- if (!panelDragStarted({ x: startX, y: startY }, { x: e.clientX, y: e.clientY })) {
179
- return;
180
- }
181
- if (this.status !== 'selected') {
182
- this._dispatchSelectEvent(e);
183
- }
184
- const event = new CustomEvent('drag', {
185
- detail: {
186
- clientX: e.clientX,
187
- clientY: e.clientY,
188
- pageX: e.pageX,
189
- pageY: e.pageY,
190
- },
191
- });
192
- this.dispatchEvent(event);
193
- disposeDragStart();
194
- });
195
- once(this.ownerDocument, 'mouseup', () => {
196
- disposeDragStart();
179
+ const event = new CustomEvent('drag', {
180
+ detail: { event: e },
197
181
  });
182
+ this.dispatchEvent(event);
198
183
  }
199
184
  _dispatchFitViewEvent(e) {
200
185
  e.stopPropagation();
@@ -248,7 +233,7 @@ let FrameCard = (() => {
248
233
  class="frame-card-body"
249
234
  @click=${this._dispatchSelectEvent}
250
235
  @dblclick=${this._dispatchFitViewEvent}
251
- @mousedown=${this._dispatchDragEvent}
236
+ @pointerdown=${this._dispatchDragEvent}
252
237
  >
253
238
  ${this.status === 'dragging' && stackOrder !== 0
254
239
  ? nothing
@@ -1,2 +1,3 @@
1
+ export * from './card/frame-preview.js';
1
2
  export * from './frame-panel.js';
2
3
  export * from './header/frame-panel-header.js';
@@ -1,2 +1,3 @@
1
+ export * from './card/frame-preview.js';
1
2
  export * from './frame-panel.js';
2
3
  export * from './header/frame-panel-header.js';
@@ -10,13 +10,13 @@ export declare const LinkPreviewDataSchema: z.ZodObject<{
10
10
  }, "strip", z.ZodTypeAny, {
11
11
  description: string | null;
12
12
  title: string | null;
13
- image: string | null;
14
13
  icon: string | null;
14
+ image: string | null;
15
15
  }, {
16
16
  description: string | null;
17
17
  title: string | null;
18
- image: string | null;
19
18
  icon: string | null;
19
+ image: string | null;
20
20
  }>;
21
21
  export type LinkPreviewData = z.infer<typeof LinkPreviewDataSchema>;
22
22
  export type Connectable = Exclude<GfxModel, ConnectorElementModel | BrushElementModel | GroupElementModel>;
@@ -24,12 +24,12 @@ declare const LocalPropsSchema: z.ZodObject<{
24
24
  centerY: z.ZodNumber;
25
25
  zoom: z.ZodNumber;
26
26
  }, "strip", z.ZodTypeAny, {
27
- centerX: number;
28
27
  zoom: number;
28
+ centerX: number;
29
29
  centerY: number;
30
30
  }, {
31
- centerX: number;
32
31
  zoom: number;
32
+ centerX: number;
33
33
  centerY: number;
34
34
  }>, z.ZodObject<{
35
35
  xywh: z.ZodString;
@@ -68,8 +68,8 @@ declare const LocalPropsSchema: z.ZodObject<{
68
68
  localShowGrid: z.ZodBoolean;
69
69
  }, "strip", z.ZodTypeAny, {
70
70
  viewport: {
71
- centerX: number;
72
71
  zoom: number;
72
+ centerX: number;
73
73
  centerY: number;
74
74
  } | {
75
75
  xywh: string;
@@ -86,8 +86,8 @@ declare const LocalPropsSchema: z.ZodObject<{
86
86
  localShowGrid: boolean;
87
87
  }, {
88
88
  viewport: {
89
- centerX: number;
90
89
  zoom: number;
90
+ centerX: number;
91
91
  centerY: number;
92
92
  } | {
93
93
  xywh: string;
@@ -6,13 +6,13 @@ export declare const fontConfigSchema: z.ZodObject<{
6
6
  style: z.ZodString;
7
7
  }, "strip", z.ZodTypeAny, {
8
8
  style: string;
9
- font: string;
10
9
  url: string;
10
+ font: string;
11
11
  weight: string;
12
12
  }, {
13
13
  style: string;
14
- font: string;
15
14
  url: string;
15
+ font: string;
16
16
  weight: string;
17
17
  }>;
18
18
  export type FontConfig = z.infer<typeof fontConfigSchema>;
@@ -36,18 +36,18 @@ export declare class FontLoaderService extends LifeCycleWatcher {
36
36
  }
37
37
  export declare const FontConfigIdentifier: import("../../../global/di/types.js").ServiceIdentifier<{
38
38
  style: string;
39
- font: string;
40
39
  url: string;
40
+ font: string;
41
41
  weight: string;
42
42
  }[]> & (<U extends {
43
43
  style: string;
44
- font: string;
45
44
  url: string;
45
+ font: string;
46
46
  weight: string;
47
47
  }[] = {
48
48
  style: string;
49
- font: string;
50
49
  url: string;
50
+ font: string;
51
51
  weight: string;
52
52
  }[]>(variant: import("../../../global/di/types.js").ServiceVariant) => import("../../../global/di/types.js").ServiceIdentifier<U>);
53
53
  export declare const FontConfigExtension: (fontConfig: FontConfig[]) => ExtensionType;
@@ -25,13 +25,13 @@ export * from './linked-doc-creation-service.js';
25
25
  export * from './native-clipboard-service.js';
26
26
  export * from './notification-service.js';
27
27
  export * from './open-doc-config.js';
28
+ export * from './outline-panel-service.js';
28
29
  export * from './page-viewport-service.js';
29
30
  export * from './parse-url-service.js';
30
31
  export * from './pivot-materiality-publisher.js';
31
32
  export * from './pivot-properties-service.js';
32
33
  export * from './quick-search-service.js';
33
34
  export * from './selection-pane-service.js';
34
- export * from './sidebar-service.js';
35
35
  export * from './telemetry-service/index.js';
36
36
  export * from './theme-service.js';
37
37
  export * from './toolbar-service/index.js';
@@ -25,13 +25,13 @@ export * from './linked-doc-creation-service.js';
25
25
  export * from './native-clipboard-service.js';
26
26
  export * from './notification-service.js';
27
27
  export * from './open-doc-config.js';
28
+ export * from './outline-panel-service.js';
28
29
  export * from './page-viewport-service.js';
29
30
  export * from './parse-url-service.js';
30
31
  export * from './pivot-materiality-publisher.js';
31
32
  export * from './pivot-properties-service.js';
32
33
  export * from './quick-search-service.js';
33
34
  export * from './selection-pane-service.js';
34
- export * from './sidebar-service.js';
35
35
  export * from './telemetry-service/index.js';
36
36
  export * from './theme-service.js';
37
37
  export * from './toolbar-service/index.js';
@@ -8,29 +8,29 @@ declare const _StorageSchema: z.ZodObject<{
8
8
  }, "strip", z.ZodTypeAny, {
9
9
  description?: string | null | undefined;
10
10
  title?: string | null | undefined;
11
- image?: string | null | undefined;
12
11
  icon?: string | null | undefined;
12
+ image?: string | null | undefined;
13
13
  }, {
14
14
  description?: string | null | undefined;
15
15
  title?: string | null | undefined;
16
- image?: string | null | undefined;
17
16
  icon?: string | null | undefined;
17
+ image?: string | null | undefined;
18
18
  }>>;
19
19
  expires: z.ZodOptional<z.ZodNumber>;
20
20
  }, "strip", z.ZodTypeAny, {
21
21
  data: Record<string, {
22
22
  description?: string | null | undefined;
23
23
  title?: string | null | undefined;
24
- image?: string | null | undefined;
25
24
  icon?: string | null | undefined;
25
+ image?: string | null | undefined;
26
26
  }>;
27
27
  expires?: number | undefined;
28
28
  }, {
29
29
  data: Record<string, {
30
30
  description?: string | null | undefined;
31
31
  title?: string | null | undefined;
32
- image?: string | null | undefined;
33
32
  icon?: string | null | undefined;
33
+ image?: string | null | undefined;
34
34
  }>;
35
35
  expires?: number | undefined;
36
36
  }>;