@formicoidea/labre-core 0.45.0 → 0.46.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.
- package/dist/_pkgs/affine-block-callout/commands/turn-callout-into.d.ts +43 -0
- package/dist/_pkgs/affine-block-callout/commands/turn-callout-into.js +109 -0
- package/dist/_pkgs/affine-block-callout/configs/toolbar.d.ts +65 -0
- package/dist/_pkgs/affine-block-callout/configs/toolbar.js +178 -0
- package/dist/_pkgs/affine-block-callout/view.js +7 -1
- package/dist/_pkgs/affine-block-frame/commands.d.ts +27 -0
- package/dist/_pkgs/affine-block-frame/commands.js +49 -0
- package/dist/_pkgs/affine-block-frame/frame-manager.d.ts +11 -6
- package/dist/_pkgs/affine-block-frame/frame-manager.js +10 -5
- package/dist/_pkgs/affine-block-frame/frame-order.d.ts +43 -0
- package/dist/_pkgs/affine-block-frame/frame-order.js +93 -0
- package/dist/_pkgs/affine-block-frame/index.d.ts +2 -0
- package/dist/_pkgs/affine-block-frame/index.js +2 -0
- package/dist/_pkgs/affine-block-frame/present/frame-order-menu.d.ts +10 -2
- package/dist/_pkgs/affine-block-frame/present/frame-order-menu.js +32 -18
- package/dist/_pkgs/affine-block-frame/view.js +6 -0
- package/dist/_pkgs/affine-block-note/configs/toolbar.d.ts +19 -0
- package/dist/_pkgs/affine-block-note/configs/toolbar.js +38 -23
- package/dist/_pkgs/affine-block-note/translations.d.ts +2 -0
- package/dist/_pkgs/affine-block-note/translations.js +14 -1
- package/dist/_pkgs/affine-block-root/configs/toolbar.js +31 -2
- package/dist/_pkgs/affine-block-root/translations.d.ts +7 -2
- package/dist/_pkgs/affine-block-root/translations.js +10 -13
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.d.ts +20 -9
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.js +57 -20
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.d.ts +6 -8
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.js +21 -8
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.d.ts +1 -1
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.js +1 -1
- package/dist/_pkgs/affine-components/portal/portal.d.ts +1 -1
- package/dist/_pkgs/affine-foundation/view.d.ts +8 -8
- package/dist/_pkgs/affine-fragment-frame-panel/body/frame-panel-body.d.ts +34 -2
- package/dist/_pkgs/affine-fragment-frame-panel/body/frame-panel-body.js +194 -81
- package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.d.ts +7 -4
- package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.js +9 -24
- package/dist/_pkgs/affine-fragment-frame-panel/index.d.ts +1 -0
- package/dist/_pkgs/affine-fragment-frame-panel/index.js +1 -0
- package/dist/_pkgs/affine-model/utils/types.d.ts +2 -2
- package/dist/_pkgs/affine-shared/services/edit-props-store.d.ts +4 -4
- package/dist/_pkgs/affine-shared/services/font-loader/config.d.ts +2 -2
- package/dist/_pkgs/affine-shared/services/font-loader/font-loader-service.d.ts +3 -3
- package/dist/_pkgs/affine-shared/services/index.d.ts +1 -1
- package/dist/_pkgs/affine-shared/services/index.js +1 -1
- package/dist/_pkgs/affine-shared/services/link-preview-service/link-preview-storage.d.ts +4 -4
- package/dist/_pkgs/affine-shared/services/outline-panel-service.d.ts +31 -0
- package/dist/_pkgs/affine-shared/services/outline-panel-service.js +17 -0
- package/dist/_pkgs/affine-shared/services/translation-service/chrome.d.ts +11 -0
- package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +19 -0
- package/dist/_pkgs/affine-shared/utils/index.d.ts +1 -0
- package/dist/_pkgs/affine-shared/utils/index.js +1 -0
- package/dist/_pkgs/affine-shared/utils/panel-reorder-drag.d.ts +85 -0
- package/dist/_pkgs/affine-shared/utils/panel-reorder-drag.js +162 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.d.ts +7 -6
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.js +11 -8
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.d.ts +31 -15
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.js +178 -142
- package/dist/_pkgs/std/scope/std-scope.d.ts +1 -1
- package/dist/commands.js +2 -0
- package/dist/host-panels.d.ts +90 -0
- package/dist/host-panels.js +111 -0
- package/package.json +5 -1
- package/dist/_pkgs/affine-fragment-frame-panel/utils/drag.d.ts +0 -27
- package/dist/_pkgs/affine-fragment-frame-panel/utils/drag.js +0 -96
- package/dist/_pkgs/affine-shared/services/sidebar-service.d.ts +0 -8
- package/dist/_pkgs/affine-shared/services/sidebar-service.js +0 -7
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { type FramePreview } from './_pkgs/affine-fragment-frame-panel/index.js';
|
|
2
|
+
import type { FrameBlockModel } from './_pkgs/affine-model/index.js';
|
|
3
|
+
import type { BlockStdScope } from './_pkgs/std/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* `@labre/affine/host-panels` — the verbs a host's own panel calls (ADR 0034
|
|
6
|
+
* §4, docs/integrate/08-host-panels.md).
|
|
7
|
+
*
|
|
8
|
+
* A host that draws its own artefact catalogue, selection pane or slide list
|
|
9
|
+
* needs a handful of editor verbs: list a framework's artefacts, arm one, run
|
|
10
|
+
* a command, read the canvas stack, list the frames in presentation order,
|
|
11
|
+
* select a model, frame it in the viewport. They existed before this module,
|
|
12
|
+
* spread over four packages and three levels of abstraction (`armArtefact` in
|
|
13
|
+
* the edgeless toolbar widget, `selectionPaneTree` in the surface block, the
|
|
14
|
+
* command registry in `std`, the frame order in the frame block), and no page
|
|
15
|
+
* named them together. This module gathers them, so a host imports one entry
|
|
16
|
+
* and never a widget package.
|
|
17
|
+
*
|
|
18
|
+
* **Why a façade and not a seam.** A seam is the editor asking the host for
|
|
19
|
+
* something (show a panel, open a document); its absence needs a degraded
|
|
20
|
+
* behaviour and a row in the seams table. Here the direction is the other way:
|
|
21
|
+
* the host calls the editor, and nothing degrades — a host that draws no panel
|
|
22
|
+
* simply calls nothing. So: plain named functions over an `std`, no class, no
|
|
23
|
+
* object holding state, no registration. The library's own panels and a
|
|
24
|
+
* host's call the same functions and the same commands, which is what keeps
|
|
25
|
+
* their behaviour the same; every WRITE goes through a core command run by
|
|
26
|
+
* `runCommand` (`canvas.frame.reorder`, `canvas.element.reorder`, …), so the
|
|
27
|
+
* read-only refusal, the no-op check, the single undo step and the telemetry
|
|
28
|
+
* happen once whoever draws the pixels.
|
|
29
|
+
*
|
|
30
|
+
* **No Lit type is named here.** `lit` is only a dev dependency of
|
|
31
|
+
* `@labre/affine`, and a host that draws its panel in React must be able to
|
|
32
|
+
* type its calls without it (`host-panels-signature.unit.spec.ts` reads this
|
|
33
|
+
* file). `getCommandIcon` still returns what the icon tables hold; a host
|
|
34
|
+
* renders it with Lit's `render` or uses its own icons.
|
|
35
|
+
*
|
|
36
|
+
* **This module only widens.** A function, a parameter or a return type a
|
|
37
|
+
* host calls keeps its 0.46 shape in every minor: a new parameter is optional,
|
|
38
|
+
* a return never gains `null` (`host-panels-signature.unit.spec.ts`, which
|
|
39
|
+
* `yarn build` typechecks; docs/lessons.md 33). A verb a host panel needs and
|
|
40
|
+
* cannot find here is a gap in this module, not a reason to import a widget
|
|
41
|
+
* package.
|
|
42
|
+
*
|
|
43
|
+
* ponytail: `frameList` is a plain read, not a signal of the frame list; a
|
|
44
|
+
* host follows reorders through `std.store.slots.blockUpdated` (08 says how).
|
|
45
|
+
* A signal of the frame list is the upgrade path if two hosts ask.
|
|
46
|
+
*/
|
|
47
|
+
export { type AnyCommandDescriptor, type CommandInvocation, type CommandOwner, type CommandSurface, getCommandIcon, getCommandsForSurface, getRegisteredCommands, runCommand, } from './_pkgs/std/index.js';
|
|
48
|
+
export { armArtefact } from './_pkgs/affine-widget-edgeless-toolbar/index.js';
|
|
49
|
+
export { type SelectionPaneNode, selectionPaneTree, } from './_pkgs/affine-block-surface/index.js';
|
|
50
|
+
export { frameCommands, type ReorderFramesParams, reorderFramesParams, } from './_pkgs/affine-block-frame/index.js';
|
|
51
|
+
/**
|
|
52
|
+
* The document's frames in presentation order, first slide first — the order
|
|
53
|
+
* `canvas.frame.reorder` writes and the presentation walks. Works in page mode
|
|
54
|
+
* too: the frame manager is registered with the frame block in both.
|
|
55
|
+
*/
|
|
56
|
+
export declare function frameList(std: BlockStdScope): FrameBlockModel[];
|
|
57
|
+
/**
|
|
58
|
+
* Select `ids` on the canvas, the way a click on a panel row does: the
|
|
59
|
+
* selection replaces the current one and nothing enters text editing. Edgeless
|
|
60
|
+
* only — page mode shows no canvas selection.
|
|
61
|
+
*/
|
|
62
|
+
export declare function selectModels(std: BlockStdScope, ids: readonly string[]): void;
|
|
63
|
+
/**
|
|
64
|
+
* Move the viewport, smoothly, so model `id` fills it within `padding`
|
|
65
|
+
* (top, right, bottom, left, in screen pixels) — the frame panel's "fit to
|
|
66
|
+
* frame". `false` when no canvas model has that id; nothing moves then.
|
|
67
|
+
*
|
|
68
|
+
* It never switches the editor's mode: the host knows which mode it shows, and
|
|
69
|
+
* a host in page mode switches first (`DocModeProvider`).
|
|
70
|
+
*/
|
|
71
|
+
export declare function fitToModel(std: BlockStdScope, id: string, padding?: [number, number, number, number]): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* The live preview of a frame the library's own frame panel draws on each
|
|
74
|
+
* card: a read-only mini editor clipped to the frame's bounds, repainted as
|
|
75
|
+
* the frame's content changes. Not a picture — a host that wants a static
|
|
76
|
+
* thumbnail renders one through `ExportManager` instead.
|
|
77
|
+
*
|
|
78
|
+
* Returns the element ready to be appended; `width` and `height` are the
|
|
79
|
+
* preview box in CSS pixels (the panel's card is 280 × 166), `fillScreen`
|
|
80
|
+
* covers the box instead of containing the frame. One mini editor per
|
|
81
|
+
* preview: mount only the cards on screen. The element is defined by the
|
|
82
|
+
* frame panel's view extension, so it renders nothing in an assembly where the
|
|
83
|
+
* `frame` flag is off (ADR 0009) — the same assembly where there is no frame
|
|
84
|
+
* to preview.
|
|
85
|
+
*/
|
|
86
|
+
export declare function createFramePreview(std: BlockStdScope, frame: FrameBlockModel, options?: {
|
|
87
|
+
width?: number;
|
|
88
|
+
height?: number;
|
|
89
|
+
fillScreen?: boolean;
|
|
90
|
+
}): FramePreview;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { EdgelessFrameManagerIdentifier } from './_pkgs/affine-block-frame/index.js';
|
|
2
|
+
import { AFFINE_FRAME_PREVIEW, } from './_pkgs/affine-fragment-frame-panel/index.js';
|
|
3
|
+
import { GfxControllerIdentifier } from './_pkgs/std/gfx/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* `@labre/affine/host-panels` — the verbs a host's own panel calls (ADR 0034
|
|
6
|
+
* §4, docs/integrate/08-host-panels.md).
|
|
7
|
+
*
|
|
8
|
+
* A host that draws its own artefact catalogue, selection pane or slide list
|
|
9
|
+
* needs a handful of editor verbs: list a framework's artefacts, arm one, run
|
|
10
|
+
* a command, read the canvas stack, list the frames in presentation order,
|
|
11
|
+
* select a model, frame it in the viewport. They existed before this module,
|
|
12
|
+
* spread over four packages and three levels of abstraction (`armArtefact` in
|
|
13
|
+
* the edgeless toolbar widget, `selectionPaneTree` in the surface block, the
|
|
14
|
+
* command registry in `std`, the frame order in the frame block), and no page
|
|
15
|
+
* named them together. This module gathers them, so a host imports one entry
|
|
16
|
+
* and never a widget package.
|
|
17
|
+
*
|
|
18
|
+
* **Why a façade and not a seam.** A seam is the editor asking the host for
|
|
19
|
+
* something (show a panel, open a document); its absence needs a degraded
|
|
20
|
+
* behaviour and a row in the seams table. Here the direction is the other way:
|
|
21
|
+
* the host calls the editor, and nothing degrades — a host that draws no panel
|
|
22
|
+
* simply calls nothing. So: plain named functions over an `std`, no class, no
|
|
23
|
+
* object holding state, no registration. The library's own panels and a
|
|
24
|
+
* host's call the same functions and the same commands, which is what keeps
|
|
25
|
+
* their behaviour the same; every WRITE goes through a core command run by
|
|
26
|
+
* `runCommand` (`canvas.frame.reorder`, `canvas.element.reorder`, …), so the
|
|
27
|
+
* read-only refusal, the no-op check, the single undo step and the telemetry
|
|
28
|
+
* happen once whoever draws the pixels.
|
|
29
|
+
*
|
|
30
|
+
* **No Lit type is named here.** `lit` is only a dev dependency of
|
|
31
|
+
* `@labre/affine`, and a host that draws its panel in React must be able to
|
|
32
|
+
* type its calls without it (`host-panels-signature.unit.spec.ts` reads this
|
|
33
|
+
* file). `getCommandIcon` still returns what the icon tables hold; a host
|
|
34
|
+
* renders it with Lit's `render` or uses its own icons.
|
|
35
|
+
*
|
|
36
|
+
* **This module only widens.** A function, a parameter or a return type a
|
|
37
|
+
* host calls keeps its 0.46 shape in every minor: a new parameter is optional,
|
|
38
|
+
* a return never gains `null` (`host-panels-signature.unit.spec.ts`, which
|
|
39
|
+
* `yarn build` typechecks; docs/lessons.md 33). A verb a host panel needs and
|
|
40
|
+
* cannot find here is a gap in this module, not a reason to import a widget
|
|
41
|
+
* package.
|
|
42
|
+
*
|
|
43
|
+
* ponytail: `frameList` is a plain read, not a signal of the frame list; a
|
|
44
|
+
* host follows reorders through `std.store.slots.blockUpdated` (08 says how).
|
|
45
|
+
* A signal of the frame list is the upgrade path if two hosts ask.
|
|
46
|
+
*/
|
|
47
|
+
export { getCommandIcon, getCommandsForSurface, getRegisteredCommands, runCommand, } from './_pkgs/std/index.js';
|
|
48
|
+
export { armArtefact } from './_pkgs/affine-widget-edgeless-toolbar/index.js';
|
|
49
|
+
export { selectionPaneTree, } from './_pkgs/affine-block-surface/index.js';
|
|
50
|
+
export { frameCommands, reorderFramesParams, } from './_pkgs/affine-block-frame/index.js';
|
|
51
|
+
/**
|
|
52
|
+
* The document's frames in presentation order, first slide first — the order
|
|
53
|
+
* `canvas.frame.reorder` writes and the presentation walks. Works in page mode
|
|
54
|
+
* too: the frame manager is registered with the frame block in both.
|
|
55
|
+
*/
|
|
56
|
+
export function frameList(std) {
|
|
57
|
+
return std.get(EdgelessFrameManagerIdentifier).frames;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Select `ids` on the canvas, the way a click on a panel row does: the
|
|
61
|
+
* selection replaces the current one and nothing enters text editing. Edgeless
|
|
62
|
+
* only — page mode shows no canvas selection.
|
|
63
|
+
*/
|
|
64
|
+
export function selectModels(std, ids) {
|
|
65
|
+
std.get(GfxControllerIdentifier).selection.set({
|
|
66
|
+
elements: [...ids],
|
|
67
|
+
editing: false,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Move the viewport, smoothly, so model `id` fills it within `padding`
|
|
72
|
+
* (top, right, bottom, left, in screen pixels) — the frame panel's "fit to
|
|
73
|
+
* frame". `false` when no canvas model has that id; nothing moves then.
|
|
74
|
+
*
|
|
75
|
+
* It never switches the editor's mode: the host knows which mode it shows, and
|
|
76
|
+
* a host in page mode switches first (`DocModeProvider`).
|
|
77
|
+
*/
|
|
78
|
+
export function fitToModel(std, id, padding = [0, 0, 0, 0]) {
|
|
79
|
+
const gfx = std.get(GfxControllerIdentifier);
|
|
80
|
+
const model = gfx.getElementById(id);
|
|
81
|
+
if (!model?.elementBound)
|
|
82
|
+
return false;
|
|
83
|
+
gfx.viewport.setViewportByBound(model.elementBound, padding, true);
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The live preview of a frame the library's own frame panel draws on each
|
|
88
|
+
* card: a read-only mini editor clipped to the frame's bounds, repainted as
|
|
89
|
+
* the frame's content changes. Not a picture — a host that wants a static
|
|
90
|
+
* thumbnail renders one through `ExportManager` instead.
|
|
91
|
+
*
|
|
92
|
+
* Returns the element ready to be appended; `width` and `height` are the
|
|
93
|
+
* preview box in CSS pixels (the panel's card is 280 × 166), `fillScreen`
|
|
94
|
+
* covers the box instead of containing the frame. One mini editor per
|
|
95
|
+
* preview: mount only the cards on screen. The element is defined by the
|
|
96
|
+
* frame panel's view extension, so it renders nothing in an assembly where the
|
|
97
|
+
* `frame` flag is off (ADR 0009) — the same assembly where there is no frame
|
|
98
|
+
* to preview.
|
|
99
|
+
*/
|
|
100
|
+
export function createFramePreview(std, frame, options = {}) {
|
|
101
|
+
const preview = document.createElement(AFFINE_FRAME_PREVIEW);
|
|
102
|
+
preview.std = std;
|
|
103
|
+
preview.frame = frame;
|
|
104
|
+
if (options.width !== undefined)
|
|
105
|
+
preview.surfaceWidth = options.width;
|
|
106
|
+
if (options.height !== undefined)
|
|
107
|
+
preview.surfaceHeight = options.height;
|
|
108
|
+
if (options.fillScreen !== undefined)
|
|
109
|
+
preview.fillScreen = options.fillScreen;
|
|
110
|
+
return preview;
|
|
111
|
+
}
|
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.
|
|
4
|
+
"version": "0.46.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"author": "lajola",
|
|
@@ -818,6 +818,10 @@
|
|
|
818
818
|
"types": "./dist/commands.d.ts",
|
|
819
819
|
"import": "./dist/commands.js"
|
|
820
820
|
},
|
|
821
|
+
"./host-panels": {
|
|
822
|
+
"types": "./dist/host-panels.d.ts",
|
|
823
|
+
"import": "./dist/host-panels.js"
|
|
824
|
+
},
|
|
821
825
|
"./frameworks": {
|
|
822
826
|
"types": "./dist/frameworks.d.ts",
|
|
823
827
|
"import": "./dist/frameworks.js"
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { FrameBlockModel } from '../../affine-model/index.js';
|
|
2
|
-
import type { FramePanelBody } from '../body/frame-panel-body.js';
|
|
3
|
-
import { FrameCard } from '../card/frame-card.js';
|
|
4
|
-
/**
|
|
5
|
-
* start drag frame cards
|
|
6
|
-
* @param frames frames to drag
|
|
7
|
-
*/
|
|
8
|
-
export declare function startDragging(frames: {
|
|
9
|
-
frame: FrameBlockModel;
|
|
10
|
-
element: FrameCard;
|
|
11
|
-
cardIndex: number;
|
|
12
|
-
frameIndex: string;
|
|
13
|
-
}[], options: {
|
|
14
|
-
width: number;
|
|
15
|
-
onDragEnd?: (insertIndex?: number) => void;
|
|
16
|
-
onDragMove?: (insertIdx?: number, indicatorTranslateY?: number) => void;
|
|
17
|
-
framePanelBody: HTMLElement;
|
|
18
|
-
frameListContainer: HTMLElement;
|
|
19
|
-
frameElementHeight: number;
|
|
20
|
-
document: Document;
|
|
21
|
-
domHost: Document | HTMLElement;
|
|
22
|
-
container: FramePanelBody;
|
|
23
|
-
start: {
|
|
24
|
-
x: number;
|
|
25
|
-
y: number;
|
|
26
|
-
};
|
|
27
|
-
}): void;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { on, once } from '../../affine-shared/utils/index.js';
|
|
2
|
-
import { FrameCard } from '../card/frame-card.js';
|
|
3
|
-
/**
|
|
4
|
-
* start drag frame cards
|
|
5
|
-
* @param frames frames to drag
|
|
6
|
-
*/
|
|
7
|
-
export function startDragging(frames, options) {
|
|
8
|
-
const { document, domHost, container, onDragMove, onDragEnd, frameElementHeight, framePanelBody, frameListContainer, start, } = options;
|
|
9
|
-
const cardElements = frames
|
|
10
|
-
.slice(frames.length - 2, frames.length)
|
|
11
|
-
.map((frame, idx, arr) => {
|
|
12
|
-
const el = new FrameCard();
|
|
13
|
-
el.frame = frame.frame;
|
|
14
|
-
el.cardIndex = frame.cardIndex;
|
|
15
|
-
el.frameIndex = frame.frameIndex;
|
|
16
|
-
el.status = 'dragging';
|
|
17
|
-
el.stackOrder = arr.length - 1 - idx;
|
|
18
|
-
el.pos = start;
|
|
19
|
-
el.width = options.width;
|
|
20
|
-
el.std = container.editorHost.std;
|
|
21
|
-
if (frames.length > 1 && el.stackOrder === 0)
|
|
22
|
-
el.draggingCardNumber = frames.length;
|
|
23
|
-
return el;
|
|
24
|
-
});
|
|
25
|
-
const maskElement = createMaskElement(document);
|
|
26
|
-
const listContainerRect = framePanelBody.getBoundingClientRect();
|
|
27
|
-
const children = Array.from(frameListContainer.children);
|
|
28
|
-
const computedStyle = getComputedStyle(frameListContainer);
|
|
29
|
-
const frameListContainerGap = parseInt(computedStyle.getPropertyValue('gap')) ?? 16;
|
|
30
|
-
let idx;
|
|
31
|
-
let indicatorTranslateY;
|
|
32
|
-
container.renderRoot.append(maskElement);
|
|
33
|
-
container.renderRoot.append(...cardElements);
|
|
34
|
-
const insideListContainer = (e) => {
|
|
35
|
-
return (e.clientX >= listContainerRect.left &&
|
|
36
|
-
e.clientX <= listContainerRect.right &&
|
|
37
|
-
e.clientY >= listContainerRect.top &&
|
|
38
|
-
e.clientY <= listContainerRect.bottom);
|
|
39
|
-
};
|
|
40
|
-
const disposeMove = on(container, 'mousemove', e => {
|
|
41
|
-
cardElements.forEach(el => {
|
|
42
|
-
el.pos = {
|
|
43
|
-
x: e.clientX,
|
|
44
|
-
y: e.clientY,
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
if (!insideListContainer(e)) {
|
|
48
|
-
idx = undefined;
|
|
49
|
-
onDragMove?.(idx, 0);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
idx = 0;
|
|
53
|
-
for (const card of children) {
|
|
54
|
-
if (!card.frame)
|
|
55
|
-
break;
|
|
56
|
-
const topBoundary = listContainerRect.top +
|
|
57
|
-
card.offsetTop -
|
|
58
|
-
framePanelBody.scrollTop -
|
|
59
|
-
frameListContainerGap / 2;
|
|
60
|
-
const midBoundary = topBoundary + card.offsetHeight / 2;
|
|
61
|
-
const bottomBoundary = topBoundary + card.offsetHeight + frameListContainerGap;
|
|
62
|
-
if (e.clientY >= topBoundary && e.clientY <= bottomBoundary) {
|
|
63
|
-
idx = e.clientY > midBoundary ? idx + 1 : idx;
|
|
64
|
-
indicatorTranslateY =
|
|
65
|
-
idx * (frameElementHeight + frameListContainerGap) -
|
|
66
|
-
frameListContainerGap / 2;
|
|
67
|
-
onDragMove?.(idx, indicatorTranslateY);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
++idx;
|
|
71
|
-
}
|
|
72
|
-
onDragMove?.(idx);
|
|
73
|
-
});
|
|
74
|
-
let ended = false;
|
|
75
|
-
const dragEnd = () => {
|
|
76
|
-
if (ended)
|
|
77
|
-
return;
|
|
78
|
-
ended = true;
|
|
79
|
-
cardElements.forEach(child => child.remove());
|
|
80
|
-
maskElement.remove();
|
|
81
|
-
disposeMove();
|
|
82
|
-
onDragEnd?.(idx);
|
|
83
|
-
};
|
|
84
|
-
once(domHost, 'mouseup', dragEnd);
|
|
85
|
-
}
|
|
86
|
-
function createMaskElement(doc) {
|
|
87
|
-
const mask = doc.createElement('div');
|
|
88
|
-
mask.style.height = '100vh';
|
|
89
|
-
mask.style.width = '100vw';
|
|
90
|
-
mask.style.position = 'fixed';
|
|
91
|
-
mask.style.left = '0';
|
|
92
|
-
mask.style.top = '0';
|
|
93
|
-
mask.style.zIndex = 'calc(var(--affine-z-index-popover, 0) + 3)';
|
|
94
|
-
mask.style.cursor = 'grabbing';
|
|
95
|
-
return mask;
|
|
96
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ExtensionType } from '../../store/index.js';
|
|
2
|
-
export interface SidebarService {
|
|
3
|
-
open: (tabId?: string) => void;
|
|
4
|
-
close: () => void;
|
|
5
|
-
getTabIds: () => string[];
|
|
6
|
-
}
|
|
7
|
-
export declare const SidebarExtensionIdentifier: import("../../global/di/types.js").ServiceIdentifier<SidebarService> & (<U extends SidebarService = SidebarService>(variant: import("../../global/di/types.js").ServiceVariant) => import("../../global/di/types.js").ServiceIdentifier<U>);
|
|
8
|
-
export declare const SidebarExtension: (service: SidebarService) => ExtensionType;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createIdentifier } from '../../global/di/index.js';
|
|
2
|
-
export const SidebarExtensionIdentifier = createIdentifier('AffineSidebarExtension');
|
|
3
|
-
export const SidebarExtension = (service) => ({
|
|
4
|
-
setup: di => {
|
|
5
|
-
di.addImpl(SidebarExtensionIdentifier, () => service);
|
|
6
|
-
},
|
|
7
|
-
});
|