mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-18 10:31:50 +08:00
chore(editor): cleanup dead code (#9904)
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
export * from './crud-extension';
|
export * from './crud-extension';
|
||||||
export * from './legacy-slot-extension';
|
export * from './legacy-slot-extension';
|
||||||
|
export * from './query';
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"name": "@blocksuite/affine-widget-edgeless-auto-connect",
|
||||||
|
"description": "Affine edgeless auto connect widget.",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc",
|
||||||
|
"test:unit": "nx vite:test --run --passWithNoTests",
|
||||||
|
"test:unit:coverage": "nx vite:test --run --coverage",
|
||||||
|
"test:e2e": "playwright test"
|
||||||
|
},
|
||||||
|
"sideEffects": false,
|
||||||
|
"keywords": [],
|
||||||
|
"author": "toeverything",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@blocksuite/affine-block-note": "workspace:*",
|
||||||
|
"@blocksuite/affine-block-surface": "workspace:*",
|
||||||
|
"@blocksuite/affine-components": "workspace:*",
|
||||||
|
"@blocksuite/affine-model": "workspace:*",
|
||||||
|
"@blocksuite/affine-shared": "workspace:*",
|
||||||
|
"@blocksuite/block-std": "workspace:*",
|
||||||
|
"@blocksuite/global": "workspace:*",
|
||||||
|
"@preact/signals-core": "^1.8.0",
|
||||||
|
"@toeverything/theme": "^1.1.7",
|
||||||
|
"lit": "^3.2.0"
|
||||||
|
},
|
||||||
|
"exports": {
|
||||||
|
".": "./src/index.ts",
|
||||||
|
"./effects": "./src/effects.ts"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src",
|
||||||
|
"dist",
|
||||||
|
"!src/__tests__",
|
||||||
|
"!dist/__tests__"
|
||||||
|
],
|
||||||
|
"version": "0.19.0"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import {
|
||||||
|
AFFINE_EDGELESS_AUTO_CONNECT_WIDGET,
|
||||||
|
EdgelessAutoConnectWidget,
|
||||||
|
} from '.';
|
||||||
|
|
||||||
|
export function effects() {
|
||||||
|
customElements.define(
|
||||||
|
AFFINE_EDGELESS_AUTO_CONNECT_WIDGET,
|
||||||
|
EdgelessAutoConnectWidget
|
||||||
|
);
|
||||||
|
}
|
||||||
+50
-32
@@ -1,4 +1,8 @@
|
|||||||
import { EdgelessLegacySlotIdentifier } from '@blocksuite/affine-block-surface';
|
import {
|
||||||
|
EdgelessCRUDIdentifier,
|
||||||
|
EdgelessLegacySlotIdentifier,
|
||||||
|
isNoteBlock,
|
||||||
|
} from '@blocksuite/affine-block-surface';
|
||||||
import {
|
import {
|
||||||
AutoConnectLeftIcon,
|
AutoConnectLeftIcon,
|
||||||
AutoConnectRightIcon,
|
AutoConnectRightIcon,
|
||||||
@@ -18,17 +22,16 @@ import {
|
|||||||
stopPropagation,
|
stopPropagation,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import { WidgetComponent } from '@blocksuite/block-std';
|
import { WidgetComponent } from '@blocksuite/block-std';
|
||||||
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
|
import {
|
||||||
|
type GfxController,
|
||||||
|
GfxControllerIdentifier,
|
||||||
|
} from '@blocksuite/block-std/gfx';
|
||||||
import { Bound } from '@blocksuite/global/utils';
|
import { Bound } from '@blocksuite/global/utils';
|
||||||
import { css, html, nothing, type TemplateResult } from 'lit';
|
import { css, html, nothing, type TemplateResult } from 'lit';
|
||||||
import { state } from 'lit/decorators.js';
|
import { state } from 'lit/decorators.js';
|
||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
import type { EdgelessRootBlockComponent } from '../../edgeless/edgeless-root-block.js';
|
|
||||||
import type { EdgelessRootService } from '../../edgeless/edgeless-root-service.js';
|
|
||||||
import { isNoteBlock } from '../../edgeless/utils/query.js';
|
|
||||||
|
|
||||||
const PAGE_VISIBLE_INDEX_LABEL_WIDTH = 44;
|
const PAGE_VISIBLE_INDEX_LABEL_WIDTH = 44;
|
||||||
const PAGE_VISIBLE_INDEX_LABEL_HEIGHT = 24;
|
const PAGE_VISIBLE_INDEX_LABEL_HEIGHT = 24;
|
||||||
const EDGELESS_ONLY_INDEX_LABEL_WIDTH = 24;
|
const EDGELESS_ONLY_INDEX_LABEL_WIDTH = 24;
|
||||||
@@ -113,11 +116,7 @@ function isAutoConnectElement(element: unknown): element is AutoConnectElement {
|
|||||||
export const AFFINE_EDGELESS_AUTO_CONNECT_WIDGET =
|
export const AFFINE_EDGELESS_AUTO_CONNECT_WIDGET =
|
||||||
'affine-edgeless-auto-connect-widget';
|
'affine-edgeless-auto-connect-widget';
|
||||||
|
|
||||||
export class EdgelessAutoConnectWidget extends WidgetComponent<
|
export class EdgelessAutoConnectWidget extends WidgetComponent<RootBlockModel> {
|
||||||
RootBlockModel,
|
|
||||||
EdgelessRootBlockComponent,
|
|
||||||
EdgelessRootService
|
|
||||||
> {
|
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
.page-visible-index-label {
|
.page-visible-index-label {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@@ -174,6 +173,22 @@ export class EdgelessAutoConnectWidget extends WidgetComponent<
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
private get _gfx(): GfxController {
|
||||||
|
return this.std.get(GfxControllerIdentifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
private get _crud() {
|
||||||
|
return this.std.get(EdgelessCRUDIdentifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
private get _viewport() {
|
||||||
|
return this._gfx.viewport;
|
||||||
|
}
|
||||||
|
|
||||||
|
private get _selection() {
|
||||||
|
return this._gfx.selection;
|
||||||
|
}
|
||||||
|
|
||||||
private readonly _updateLabels = () => {
|
private readonly _updateLabels = () => {
|
||||||
const service = this.service;
|
const service = this.service;
|
||||||
if (!service.doc.root) return;
|
if (!service.doc.root) return;
|
||||||
@@ -195,7 +210,7 @@ export class EdgelessAutoConnectWidget extends WidgetComponent<
|
|||||||
|
|
||||||
note.children.forEach(model => {
|
note.children.forEach(model => {
|
||||||
if (matchFlavours(model, ['affine:surface-ref'])) {
|
if (matchFlavours(model, ['affine:surface-ref'])) {
|
||||||
const reference = service.crud.getElementById(model.reference);
|
const reference = this._crud.getElementById(model.reference);
|
||||||
|
|
||||||
if (!isAutoConnectElement(reference)) return;
|
if (!isAutoConnectElement(reference)) return;
|
||||||
|
|
||||||
@@ -224,7 +239,7 @@ export class EdgelessAutoConnectWidget extends WidgetComponent<
|
|||||||
_edgelessOnlyNotesSet,
|
_edgelessOnlyNotesSet,
|
||||||
note => note.id,
|
note => note.id,
|
||||||
note => {
|
note => {
|
||||||
const { viewport } = this.service;
|
const viewport = this._viewport;
|
||||||
const { zoom } = viewport;
|
const { zoom } = viewport;
|
||||||
const bound = Bound.deserialize(note.xywh);
|
const bound = Bound.deserialize(note.xywh);
|
||||||
const [left, right] = viewport.toViewCoord(bound.x, bound.y);
|
const [left, right] = viewport.toViewCoord(bound.x, bound.y);
|
||||||
@@ -275,11 +290,11 @@ export class EdgelessAutoConnectWidget extends WidgetComponent<
|
|||||||
.map(block => block.model) as SurfaceRefBlockModel[];
|
.map(block => block.model) as SurfaceRefBlockModel[];
|
||||||
|
|
||||||
const getVisibility = () => {
|
const getVisibility = () => {
|
||||||
const { selectedElements } = service.selection;
|
const { selectedElements } = this._selection;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
selectedElements.length === 1 &&
|
selectedElements.length === 1 &&
|
||||||
!service.selection.editing &&
|
!this._selection.editing &&
|
||||||
(isNoteBlock(selectedElements[0]) ||
|
(isNoteBlock(selectedElements[0]) ||
|
||||||
surfaceRefs.some(ref => ref.reference === selectedElements[0].id))
|
surfaceRefs.some(ref => ref.reference === selectedElements[0].id))
|
||||||
) {
|
) {
|
||||||
@@ -292,7 +307,7 @@ export class EdgelessAutoConnectWidget extends WidgetComponent<
|
|||||||
};
|
};
|
||||||
|
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
service.selection.slots.updated.on(() => {
|
this._selection.slots.updated.on(() => {
|
||||||
getVisibility();
|
getVisibility();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -323,16 +338,19 @@ export class EdgelessAutoConnectWidget extends WidgetComponent<
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
this._disposables.add(
|
const surface = this._gfx.surface;
|
||||||
service.surface.elementUpdated.on(payload => {
|
if (surface) {
|
||||||
if (
|
this._disposables.add(
|
||||||
payload.props['xywh'] &&
|
surface.elementUpdated.on(payload => {
|
||||||
surfaceRefs.some(ref => ref.reference === payload.id)
|
if (
|
||||||
) {
|
payload.props['xywh'] &&
|
||||||
this.requestUpdate();
|
surfaceRefs.some(ref => ref.reference === payload.id)
|
||||||
}
|
) {
|
||||||
})
|
this.requestUpdate();
|
||||||
);
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _navigateToNext() {
|
private _navigateToNext() {
|
||||||
@@ -341,11 +359,11 @@ export class EdgelessAutoConnectWidget extends WidgetComponent<
|
|||||||
this._index = this._index + 1;
|
this._index = this._index + 1;
|
||||||
const element = elements[this._index];
|
const element = elements[this._index];
|
||||||
const bound = Bound.deserialize(element.xywh);
|
const bound = Bound.deserialize(element.xywh);
|
||||||
this.service.selection.set({
|
this._selection.set({
|
||||||
elements: [element.id],
|
elements: [element.id],
|
||||||
editing: false,
|
editing: false,
|
||||||
});
|
});
|
||||||
this.service.viewport.setViewportByBound(bound, [80, 80, 80, 80], true);
|
this._viewport.setViewportByBound(bound, [80, 80, 80, 80], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _navigateToPrev() {
|
private _navigateToPrev() {
|
||||||
@@ -354,15 +372,15 @@ export class EdgelessAutoConnectWidget extends WidgetComponent<
|
|||||||
this._index = this._index - 1;
|
this._index = this._index - 1;
|
||||||
const element = elements[this._index];
|
const element = elements[this._index];
|
||||||
const bound = Bound.deserialize(element.xywh);
|
const bound = Bound.deserialize(element.xywh);
|
||||||
this.service.selection.set({
|
this._selection.set({
|
||||||
elements: [element.id],
|
elements: [element.id],
|
||||||
editing: false,
|
editing: false,
|
||||||
});
|
});
|
||||||
this.service.viewport.setViewportByBound(bound, [80, 80, 80, 80], true);
|
this._viewport.setViewportByBound(bound, [80, 80, 80, 80], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _NavigatorComponent(elements: AutoConnectElement[]) {
|
private _NavigatorComponent(elements: AutoConnectElement[]) {
|
||||||
const { viewport } = this.service;
|
const viewport = this._viewport;
|
||||||
const { zoom } = viewport;
|
const { zoom } = viewport;
|
||||||
const className = `navigator ${this._index >= 0 ? 'show' : 'hidden'}`;
|
const className = `navigator ${this._index >= 0 ? 'show' : 'hidden'}`;
|
||||||
const element = elements[this._index];
|
const element = elements[this._index];
|
||||||
@@ -405,7 +423,7 @@ export class EdgelessAutoConnectWidget extends WidgetComponent<
|
|||||||
elements: AutoConnectElement[],
|
elements: AutoConnectElement[],
|
||||||
counts: number[]
|
counts: number[]
|
||||||
) {
|
) {
|
||||||
const { viewport } = this.service;
|
const viewport = this._viewport;
|
||||||
const { zoom } = viewport;
|
const { zoom } = viewport;
|
||||||
let index = 0;
|
let index = 0;
|
||||||
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"rootDir": "./src",
|
||||||
|
"outDir": "./dist",
|
||||||
|
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
|
||||||
|
},
|
||||||
|
"include": ["./src"],
|
||||||
|
"references": [
|
||||||
|
{ "path": "../block-note" },
|
||||||
|
{ "path": "../block-surface" },
|
||||||
|
{ "path": "../components" },
|
||||||
|
{ "path": "../model" },
|
||||||
|
{ "path": "../shared" },
|
||||||
|
{ "path": "../../framework/block-std" },
|
||||||
|
{ "path": "../../framework/global" }
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -35,6 +35,7 @@
|
|||||||
"@blocksuite/affine-model": "workspace:*",
|
"@blocksuite/affine-model": "workspace:*",
|
||||||
"@blocksuite/affine-shared": "workspace:*",
|
"@blocksuite/affine-shared": "workspace:*",
|
||||||
"@blocksuite/affine-widget-drag-handle": "workspace:*",
|
"@blocksuite/affine-widget-drag-handle": "workspace:*",
|
||||||
|
"@blocksuite/affine-widget-edgeless-auto-connect": "workspace:*",
|
||||||
"@blocksuite/affine-widget-frame-title": "workspace:*",
|
"@blocksuite/affine-widget-frame-title": "workspace:*",
|
||||||
"@blocksuite/affine-widget-remote-selection": "workspace:*",
|
"@blocksuite/affine-widget-remote-selection": "workspace:*",
|
||||||
"@blocksuite/affine-widget-scroll-anchoring": "workspace:*",
|
"@blocksuite/affine-widget-scroll-anchoring": "workspace:*",
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import { effects as componentToggleButtonEffects } from '@blocksuite/affine-comp
|
|||||||
import { ToggleSwitch } from '@blocksuite/affine-components/toggle-switch';
|
import { ToggleSwitch } from '@blocksuite/affine-components/toggle-switch';
|
||||||
import { effects as componentToolbarEffects } from '@blocksuite/affine-components/toolbar';
|
import { effects as componentToolbarEffects } from '@blocksuite/affine-components/toolbar';
|
||||||
import { effects as widgetDragHandleEffects } from '@blocksuite/affine-widget-drag-handle/effects';
|
import { effects as widgetDragHandleEffects } from '@blocksuite/affine-widget-drag-handle/effects';
|
||||||
|
import { effects as widgetEdgelessAutoConnectEffects } from '@blocksuite/affine-widget-edgeless-auto-connect/effects';
|
||||||
import { effects as widgetFrameTitleEffects } from '@blocksuite/affine-widget-frame-title/effects';
|
import { effects as widgetFrameTitleEffects } from '@blocksuite/affine-widget-frame-title/effects';
|
||||||
import { effects as widgetRemoteSelectionEffects } from '@blocksuite/affine-widget-remote-selection/effects';
|
import { effects as widgetRemoteSelectionEffects } from '@blocksuite/affine-widget-remote-selection/effects';
|
||||||
import { effects as widgetScrollAnchoringEffects } from '@blocksuite/affine-widget-scroll-anchoring/effects';
|
import { effects as widgetScrollAnchoringEffects } from '@blocksuite/affine-widget-scroll-anchoring/effects';
|
||||||
@@ -152,10 +153,6 @@ import {
|
|||||||
AIPanelGenerating,
|
AIPanelGenerating,
|
||||||
AIPanelInput,
|
AIPanelInput,
|
||||||
} from './root-block/widgets/ai-panel/components/index.js';
|
} from './root-block/widgets/ai-panel/components/index.js';
|
||||||
import {
|
|
||||||
AFFINE_EDGELESS_AUTO_CONNECT_WIDGET,
|
|
||||||
EdgelessAutoConnectWidget,
|
|
||||||
} from './root-block/widgets/edgeless-auto-connect/edgeless-auto-connect.js';
|
|
||||||
import { EdgelessCopilotPanel } from './root-block/widgets/edgeless-copilot-panel/index.js';
|
import { EdgelessCopilotPanel } from './root-block/widgets/edgeless-copilot-panel/index.js';
|
||||||
import { AFFINE_EDGELESS_ZOOM_TOOLBAR_WIDGET } from './root-block/widgets/edgeless-zoom-toolbar/index.js';
|
import { AFFINE_EDGELESS_ZOOM_TOOLBAR_WIDGET } from './root-block/widgets/edgeless-zoom-toolbar/index.js';
|
||||||
import { ZoomBarToggleButton } from './root-block/widgets/edgeless-zoom-toolbar/zoom-bar-toggle-button.js';
|
import { ZoomBarToggleButton } from './root-block/widgets/edgeless-zoom-toolbar/zoom-bar-toggle-button.js';
|
||||||
@@ -223,6 +220,7 @@ export function effects() {
|
|||||||
widgetEdgelessElementToolbarEffects();
|
widgetEdgelessElementToolbarEffects();
|
||||||
widgetRemoteSelectionEffects();
|
widgetRemoteSelectionEffects();
|
||||||
widgetDragHandleEffects();
|
widgetDragHandleEffects();
|
||||||
|
widgetEdgelessAutoConnectEffects();
|
||||||
dataViewEffects();
|
dataViewEffects();
|
||||||
|
|
||||||
customElements.define('affine-page-root', PageRootBlockComponent);
|
customElements.define('affine-page-root', PageRootBlockComponent);
|
||||||
@@ -392,10 +390,6 @@ export function effects() {
|
|||||||
AffineEdgelessZoomToolbarWidget
|
AffineEdgelessZoomToolbarWidget
|
||||||
);
|
);
|
||||||
customElements.define(AFFINE_SURFACE_REF_TOOLBAR, AffineSurfaceRefToolbar);
|
customElements.define(AFFINE_SURFACE_REF_TOOLBAR, AffineSurfaceRefToolbar);
|
||||||
customElements.define(
|
|
||||||
AFFINE_EDGELESS_AUTO_CONNECT_WIDGET,
|
|
||||||
EdgelessAutoConnectWidget
|
|
||||||
);
|
|
||||||
customElements.define(AFFINE_FORMAT_BAR_WIDGET, AffineFormatBarWidget);
|
customElements.define(AFFINE_FORMAT_BAR_WIDGET, AffineFormatBarWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,6 +3,7 @@ import {
|
|||||||
type ConnectionOverlay,
|
type ConnectionOverlay,
|
||||||
ConnectorPathGenerator,
|
ConnectorPathGenerator,
|
||||||
EdgelessCRUDIdentifier,
|
EdgelessCRUDIdentifier,
|
||||||
|
isNoteBlock,
|
||||||
Overlay,
|
Overlay,
|
||||||
OverlayIdentifier,
|
OverlayIdentifier,
|
||||||
type RoughCanvas,
|
type RoughCanvas,
|
||||||
@@ -44,7 +45,6 @@ import { classMap } from 'lit/directives/class-map.js';
|
|||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
import type { EdgelessRootBlockComponent } from '../../edgeless-root-block.js';
|
import type { EdgelessRootBlockComponent } from '../../edgeless-root-block.js';
|
||||||
import { isNoteBlock } from '../../utils/query.js';
|
|
||||||
import { mountShapeTextEditor } from '../../utils/text.js';
|
import { mountShapeTextEditor } from '../../utils/text.js';
|
||||||
import type { SelectedRect } from '../rects/edgeless-selected-rect.js';
|
import type { SelectedRect } from '../rects/edgeless-selected-rect.js';
|
||||||
import { EdgelessAutoCompletePanel } from './auto-complete-panel.js';
|
import { EdgelessAutoCompletePanel } from './auto-complete-panel.js';
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { isNoteBlock } from '@blocksuite/affine-block-surface';
|
||||||
import { SmallScissorsIcon } from '@blocksuite/affine-components/icons';
|
import { SmallScissorsIcon } from '@blocksuite/affine-components/icons';
|
||||||
import { DEFAULT_NOTE_HEIGHT } from '@blocksuite/affine-model';
|
import { DEFAULT_NOTE_HEIGHT } from '@blocksuite/affine-model';
|
||||||
import { EDGELESS_BLOCK_CHILD_PADDING } from '@blocksuite/affine-shared/consts';
|
import { EDGELESS_BLOCK_CHILD_PADDING } from '@blocksuite/affine-shared/consts';
|
||||||
@@ -22,7 +23,6 @@ import type {
|
|||||||
NoteBlockModel,
|
NoteBlockModel,
|
||||||
RootBlockModel,
|
RootBlockModel,
|
||||||
} from '../../../../index.js';
|
} from '../../../../index.js';
|
||||||
import { isNoteBlock } from '../../utils/query.js';
|
|
||||||
|
|
||||||
const DIVIDING_LINE_OFFSET = 4;
|
const DIVIDING_LINE_OFFSET = 4;
|
||||||
const NEW_NOTE_GAP = 40;
|
const NEW_NOTE_GAP = 40;
|
||||||
|
|||||||
+1
-1
@@ -8,6 +8,7 @@ import {
|
|||||||
} from '@blocksuite/affine-block-embed';
|
} from '@blocksuite/affine-block-embed';
|
||||||
import {
|
import {
|
||||||
CanvasElementType,
|
CanvasElementType,
|
||||||
|
isNoteBlock,
|
||||||
normalizeShapeBound,
|
normalizeShapeBound,
|
||||||
OverlayIdentifier,
|
OverlayIdentifier,
|
||||||
TextUtils,
|
TextUtils,
|
||||||
@@ -91,7 +92,6 @@ import {
|
|||||||
isFrameBlock,
|
isFrameBlock,
|
||||||
isImageBlock,
|
isImageBlock,
|
||||||
isMindmapNode,
|
isMindmapNode,
|
||||||
isNoteBlock,
|
|
||||||
} from '../../utils/query.js';
|
} from '../../utils/query.js';
|
||||||
import {
|
import {
|
||||||
HandleDirection,
|
HandleDirection,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { insertLinkByQuickSearchCommand } from '@blocksuite/affine-block-bookmark';
|
import { insertLinkByQuickSearchCommand } from '@blocksuite/affine-block-bookmark';
|
||||||
import { EdgelessTextBlockComponent } from '@blocksuite/affine-block-edgeless-text';
|
import { EdgelessTextBlockComponent } from '@blocksuite/affine-block-edgeless-text';
|
||||||
|
import { isNoteBlock } from '@blocksuite/affine-block-surface';
|
||||||
import { toast } from '@blocksuite/affine-components/toast';
|
import { toast } from '@blocksuite/affine-components/toast';
|
||||||
import {
|
import {
|
||||||
ConnectorElementModel,
|
ConnectorElementModel,
|
||||||
@@ -45,7 +46,7 @@ import {
|
|||||||
} from './utils/consts.js';
|
} from './utils/consts.js';
|
||||||
import { deleteElements } from './utils/crud.js';
|
import { deleteElements } from './utils/crud.js';
|
||||||
import { getNextShapeType } from './utils/hotkey-utils.js';
|
import { getNextShapeType } from './utils/hotkey-utils.js';
|
||||||
import { isCanvasElement, isNoteBlock } from './utils/query.js';
|
import { isCanvasElement } from './utils/query.js';
|
||||||
import {
|
import {
|
||||||
mountConnectorLabelEditor,
|
mountConnectorLabelEditor,
|
||||||
mountShapeTextEditor,
|
mountShapeTextEditor,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
ThemeService,
|
ThemeService,
|
||||||
} from '@blocksuite/affine-shared/services';
|
} from '@blocksuite/affine-shared/services';
|
||||||
import { AFFINE_DRAG_HANDLE_WIDGET } from '@blocksuite/affine-widget-drag-handle';
|
import { AFFINE_DRAG_HANDLE_WIDGET } from '@blocksuite/affine-widget-drag-handle';
|
||||||
|
import { AFFINE_EDGELESS_AUTO_CONNECT_WIDGET } from '@blocksuite/affine-widget-edgeless-auto-connect';
|
||||||
import { AFFINE_FRAME_TITLE_WIDGET } from '@blocksuite/affine-widget-frame-title';
|
import { AFFINE_FRAME_TITLE_WIDGET } from '@blocksuite/affine-widget-frame-title';
|
||||||
import {
|
import {
|
||||||
AFFINE_DOC_REMOTE_SELECTION_WIDGET,
|
AFFINE_DOC_REMOTE_SELECTION_WIDGET,
|
||||||
@@ -25,7 +26,6 @@ import { literal, unsafeStatic } from 'lit/static-html.js';
|
|||||||
|
|
||||||
import { ExportManagerExtension } from '../../_common/export-manager/export-manager.js';
|
import { ExportManagerExtension } from '../../_common/export-manager/export-manager.js';
|
||||||
import { RootBlockAdapterExtensions } from '../adapters/extension.js';
|
import { RootBlockAdapterExtensions } from '../adapters/extension.js';
|
||||||
import { AFFINE_EDGELESS_AUTO_CONNECT_WIDGET } from '../widgets/edgeless-auto-connect/edgeless-auto-connect.js';
|
|
||||||
import { AFFINE_EDGELESS_ZOOM_TOOLBAR_WIDGET } from '../widgets/edgeless-zoom-toolbar/index.js';
|
import { AFFINE_EDGELESS_ZOOM_TOOLBAR_WIDGET } from '../widgets/edgeless-zoom-toolbar/index.js';
|
||||||
import { EDGELESS_ELEMENT_TOOLBAR_WIDGET } from '../widgets/element-toolbar/index.js';
|
import { EDGELESS_ELEMENT_TOOLBAR_WIDGET } from '../widgets/element-toolbar/index.js';
|
||||||
import { AFFINE_EMBED_CARD_TOOLBAR_WIDGET } from '../widgets/embed-card-toolbar/embed-card-toolbar.js';
|
import { AFFINE_EMBED_CARD_TOOLBAR_WIDGET } from '../widgets/embed-card-toolbar/embed-card-toolbar.js';
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { insertEdgelessTextCommand } from '@blocksuite/affine-block-edgeless-text';
|
import { insertEdgelessTextCommand } from '@blocksuite/affine-block-edgeless-text';
|
||||||
import {
|
import {
|
||||||
ConnectorUtils,
|
ConnectorUtils,
|
||||||
|
isNoteBlock,
|
||||||
OverlayIdentifier,
|
OverlayIdentifier,
|
||||||
} from '@blocksuite/affine-block-surface';
|
} from '@blocksuite/affine-block-surface';
|
||||||
import { focusTextModel } from '@blocksuite/affine-components/rich-text';
|
import { focusTextModel } from '@blocksuite/affine-components/rich-text';
|
||||||
@@ -56,7 +57,6 @@ import {
|
|||||||
isCanvasElement,
|
isCanvasElement,
|
||||||
isEdgelessTextBlock,
|
isEdgelessTextBlock,
|
||||||
isFrameBlock,
|
isFrameBlock,
|
||||||
isNoteBlock,
|
|
||||||
} from '../utils/query.js';
|
} from '../utils/query.js';
|
||||||
import type { EdgelessSnapManager } from '../utils/snap-manager.js';
|
import type { EdgelessSnapManager } from '../utils/snap-manager.js';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { isNoteBlock } from '@blocksuite/affine-block-surface';
|
||||||
import type {
|
import type {
|
||||||
EdgelessTextBlockModel,
|
EdgelessTextBlockModel,
|
||||||
EmbedSyncedDocModel,
|
EmbedSyncedDocModel,
|
||||||
@@ -22,7 +23,6 @@ import {
|
|||||||
isEmbedSyncedDocBlock,
|
isEmbedSyncedDocBlock,
|
||||||
isFrameBlock,
|
isFrameBlock,
|
||||||
isImageBlock,
|
isImageBlock,
|
||||||
isNoteBlock,
|
|
||||||
} from './query.js';
|
} from './query.js';
|
||||||
|
|
||||||
const offset = 10;
|
const offset = 10;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
import { isNoteBlock } from '@blocksuite/affine-block-surface';
|
||||||
|
|
||||||
import type { Connectable } from '../../../_common/utils/index.js';
|
import type { Connectable } from '../../../_common/utils/index.js';
|
||||||
import type { EdgelessRootBlockComponent } from '../index.js';
|
import type { EdgelessRootBlockComponent } from '../index.js';
|
||||||
import { isConnectable, isNoteBlock } from './query.js';
|
import { isConnectable } from './query.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use deleteElementsV2 instead.
|
* Use deleteElementsV2 instead.
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import {
|
|||||||
type FrameBlockModel,
|
type FrameBlockModel,
|
||||||
type ImageBlockModel,
|
type ImageBlockModel,
|
||||||
MindmapElementModel,
|
MindmapElementModel,
|
||||||
type NoteBlockModel,
|
|
||||||
ShapeElementModel,
|
ShapeElementModel,
|
||||||
TextElementModel,
|
TextElementModel,
|
||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
@@ -46,12 +45,6 @@ export function isMindmapNode(
|
|||||||
return element?.group instanceof MindmapElementModel;
|
return element?.group instanceof MindmapElementModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isNoteBlock(
|
|
||||||
element: BlockModel | BlockSuite.EdgelessModel | null
|
|
||||||
): element is NoteBlockModel {
|
|
||||||
return !!element && 'flavour' in element && element.flavour === 'affine:note';
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isEdgelessTextBlock(
|
export function isEdgelessTextBlock(
|
||||||
element: BlockModel | BlockSuite.EdgelessModel | null
|
element: BlockModel | BlockSuite.EdgelessModel | null
|
||||||
): element is EdgelessTextBlockModel {
|
): element is EdgelessTextBlockModel {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { BuiltInEmbedModel } from '@blocksuite/affine-block-bookmark';
|
import type { BuiltInEmbedModel } from '@blocksuite/affine-block-bookmark';
|
||||||
|
import { isNoteBlock } from '@blocksuite/affine-block-surface';
|
||||||
import { ConnectorCWithArrowIcon } from '@blocksuite/affine-components/icons';
|
import { ConnectorCWithArrowIcon } from '@blocksuite/affine-components/icons';
|
||||||
import {
|
import {
|
||||||
cloneGroups,
|
cloneGroups,
|
||||||
@@ -47,7 +48,6 @@ import {
|
|||||||
isEmbeddedBlock,
|
isEmbeddedBlock,
|
||||||
isFrameBlock,
|
isFrameBlock,
|
||||||
isImageBlock,
|
isImageBlock,
|
||||||
isNoteBlock,
|
|
||||||
} from '../../edgeless/utils/query.js';
|
} from '../../edgeless/utils/query.js';
|
||||||
import { renderAddFrameButton } from './add-frame-button.js';
|
import { renderAddFrameButton } from './add-frame-button.js';
|
||||||
import { renderAddGroupButton } from './add-group-button.js';
|
import { renderAddGroupButton } from './add-group-button.js';
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import type { SurfaceBlockComponent } from '@blocksuite/affine-block-surface';
|
import {
|
||||||
|
isNoteBlock,
|
||||||
|
type SurfaceBlockComponent,
|
||||||
|
} from '@blocksuite/affine-block-surface';
|
||||||
import { MenuContext } from '@blocksuite/affine-components/toolbar';
|
import { MenuContext } from '@blocksuite/affine-components/toolbar';
|
||||||
import { getSelectedModelsCommand } from '@blocksuite/affine-shared/commands';
|
import { getSelectedModelsCommand } from '@blocksuite/affine-shared/commands';
|
||||||
import {
|
import {
|
||||||
@@ -17,7 +20,6 @@ import {
|
|||||||
isEmbedSyncedDocBlock,
|
isEmbedSyncedDocBlock,
|
||||||
isFrameBlock,
|
isFrameBlock,
|
||||||
isImageBlock,
|
isImageBlock,
|
||||||
isNoteBlock,
|
|
||||||
} from '../../../edgeless/utils/query.js';
|
} from '../../../edgeless/utils/query.js';
|
||||||
|
|
||||||
export class ElementToolbarMoreMenuContext extends MenuContext {
|
export class ElementToolbarMoreMenuContext extends MenuContext {
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
import { getSurfaceBlock } from '@blocksuite/affine-block-surface';
|
import { getSurfaceBlock, isNoteBlock } from '@blocksuite/affine-block-surface';
|
||||||
import type { FrameBlockModel, NoteBlockModel } from '@blocksuite/affine-model';
|
import type { FrameBlockModel, NoteBlockModel } from '@blocksuite/affine-model';
|
||||||
import { NoteDisplayMode } from '@blocksuite/affine-model';
|
import { NoteDisplayMode } from '@blocksuite/affine-model';
|
||||||
import { DocModeProvider } from '@blocksuite/affine-shared/services';
|
import { DocModeProvider } from '@blocksuite/affine-shared/services';
|
||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
mapFrameIds,
|
mapFrameIds,
|
||||||
sortEdgelessElements,
|
sortEdgelessElements,
|
||||||
} from '../../../edgeless/utils/clone-utils.js';
|
} from '../../../edgeless/utils/clone-utils.js';
|
||||||
import { isFrameBlock, isNoteBlock } from '../../../edgeless/utils/query.js';
|
import { isFrameBlock } from '../../../edgeless/utils/query.js';
|
||||||
|
|
||||||
function addBlocksToDoc(targetDoc: Store, model: BlockModel, parentId: string) {
|
function addBlocksToDoc(targetDoc: Store, model: BlockModel, parentId: string) {
|
||||||
// Add current block to linked doc
|
// Add current block to linked doc
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
{ "path": "../affine/model" },
|
{ "path": "../affine/model" },
|
||||||
{ "path": "../affine/shared" },
|
{ "path": "../affine/shared" },
|
||||||
{ "path": "../affine/widget-drag-handle" },
|
{ "path": "../affine/widget-drag-handle" },
|
||||||
|
{ "path": "../affine/widget-edgeless-auto-connect" },
|
||||||
{ "path": "../affine/widget-frame-title" },
|
{ "path": "../affine/widget-frame-title" },
|
||||||
{ "path": "../affine/widget-remote-selection" },
|
{ "path": "../affine/widget-remote-selection" },
|
||||||
{ "path": "../affine/widget-scroll-anchoring" },
|
{ "path": "../affine/widget-scroll-anchoring" },
|
||||||
|
|||||||
@@ -1,137 +0,0 @@
|
|||||||
export const demoScript = `import * as THREE from "three";
|
|
||||||
import {OrbitControls} from "three/addons/controls/OrbitControls.js";
|
|
||||||
|
|
||||||
|
|
||||||
let scene = new THREE.Scene();
|
|
||||||
let camera = new THREE.PerspectiveCamera(30, innerWidth / innerHeight, 1, 1000);
|
|
||||||
camera.position.set(0, 10, 10).setLength(17);
|
|
||||||
let renderer = new THREE.WebGLRenderer({antialias: true});
|
|
||||||
renderer.setSize(innerWidth, innerHeight);
|
|
||||||
document.body.appendChild(renderer.domElement);
|
|
||||||
|
|
||||||
window.addEventListener("resize", event => {
|
|
||||||
camera.aspect = innerWidth / innerHeight;
|
|
||||||
camera.updateProjectionMatrix();
|
|
||||||
renderer.setSize(innerWidth, innerHeight);
|
|
||||||
})
|
|
||||||
|
|
||||||
let controls = new OrbitControls(camera, renderer.domElement);
|
|
||||||
controls.enableDamping = true;
|
|
||||||
|
|
||||||
let gu = {
|
|
||||||
time: {value: 0}
|
|
||||||
}
|
|
||||||
|
|
||||||
let params = {
|
|
||||||
instanceCount: {value: 10},
|
|
||||||
instanceLength: {value: 1.75},
|
|
||||||
instanceGap: {value: 0.5},
|
|
||||||
profileFactor: {value: 1.5}
|
|
||||||
}
|
|
||||||
|
|
||||||
let ig = new THREE.InstancedBufferGeometry().copy(new THREE.BoxGeometry(1, 1, 1, 100, 1, 1).translate(0.5, 0, 0));
|
|
||||||
ig.instanceCount = params.instanceCount.value;
|
|
||||||
|
|
||||||
let m = new THREE.MeshBasicMaterial({
|
|
||||||
vertexColors: true,
|
|
||||||
onBeforeCompile: shader => {
|
|
||||||
shader.uniforms.time = gu.time;
|
|
||||||
shader.uniforms.instanceCount = params.instanceCount;
|
|
||||||
shader.uniforms.instanceLength = params.instanceLength;
|
|
||||||
shader.uniforms.instanceGap = params.instanceGap;
|
|
||||||
shader.uniforms.profileFactor = params.profileFactor;
|
|
||||||
shader.vertexShader = \`
|
|
||||||
uniform float time;
|
|
||||||
|
|
||||||
uniform float instanceCount;
|
|
||||||
uniform float instanceLength;
|
|
||||||
uniform float instanceGap;
|
|
||||||
|
|
||||||
uniform float profileFactor;
|
|
||||||
|
|
||||||
varying float noGrid;
|
|
||||||
|
|
||||||
mat2 rot(float a){return mat2(cos(a), sin(a), -sin(a), cos(a));}
|
|
||||||
|
|
||||||
\${shader.vertexShader}
|
|
||||||
\`.replace(
|
|
||||||
\`#include <begin_vertex>\`,
|
|
||||||
\`#include <begin_vertex>
|
|
||||||
|
|
||||||
float t = time * 0.1;
|
|
||||||
|
|
||||||
float iID = float(gl_InstanceID);
|
|
||||||
|
|
||||||
float instanceTotalLength = instanceLength + instanceGap;
|
|
||||||
float instanceFactor = instanceLength / instanceTotalLength;
|
|
||||||
|
|
||||||
float circleLength = instanceTotalLength * instanceCount;
|
|
||||||
float circleRadius = circleLength / PI2;
|
|
||||||
|
|
||||||
float partAngle = PI2 / instanceCount;
|
|
||||||
float boxAngle = partAngle * instanceFactor;
|
|
||||||
|
|
||||||
float partTurn = PI / instanceCount;
|
|
||||||
float boxTurn = partTurn * instanceFactor;
|
|
||||||
|
|
||||||
float startAngle = t + partAngle * iID;
|
|
||||||
float startTurn = t * 0.5 + partTurn * iID;
|
|
||||||
|
|
||||||
float angleFactor = position.x;
|
|
||||||
|
|
||||||
float angle = startAngle + boxAngle * angleFactor;
|
|
||||||
float turn = startTurn + boxTurn * angleFactor;
|
|
||||||
|
|
||||||
vec3 pos = vec3(0, position.y, position.z);
|
|
||||||
pos.yz *= rot(turn);
|
|
||||||
pos.yz *= profileFactor;
|
|
||||||
pos.z += circleRadius;
|
|
||||||
pos.xz *= rot(angle);
|
|
||||||
|
|
||||||
transformed = pos;
|
|
||||||
float nZ = floor(abs(normal.z) + 0.1);
|
|
||||||
float nX = floor(abs(normal.x) + 0.1);
|
|
||||||
noGrid = 1. - nX;
|
|
||||||
vColor = vec3(nZ == 1. ? 0.1 : nX == 1. ? 0. : 0.01);
|
|
||||||
\`
|
|
||||||
);
|
|
||||||
//console.log(shader.vertexShader);
|
|
||||||
shader.fragmentShader = \`
|
|
||||||
varying float noGrid;
|
|
||||||
|
|
||||||
float lines(vec2 coord, float thickness){
|
|
||||||
vec2 grid = abs(fract(coord - 0.5) - 0.5) / fwidth(coord) / thickness;
|
|
||||||
float line = min(grid.x, grid.y);
|
|
||||||
return 1.0 - min(line, 1.0);
|
|
||||||
}
|
|
||||||
\${shader.fragmentShader}
|
|
||||||
\`.replace(
|
|
||||||
\`#include <color_fragment>\`,
|
|
||||||
\`#include <color_fragment>
|
|
||||||
|
|
||||||
float multiply = vColor.r > 0.05 ? 3. : 2.;
|
|
||||||
float edges = lines(vUv, 3.);
|
|
||||||
float grid = min(noGrid, lines(vUv * multiply, 1.));
|
|
||||||
diffuseColor.rgb = mix(diffuseColor.rgb, vec3(1), max(edges, grid));
|
|
||||||
\`
|
|
||||||
)
|
|
||||||
//console.log(shader.fragmentShader)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
m.defines = {"USE_UV": ""};
|
|
||||||
|
|
||||||
let o = new THREE.Mesh(ig, m);
|
|
||||||
scene.add(o)
|
|
||||||
o.rotation.z = -Math.PI * 0.25;
|
|
||||||
|
|
||||||
let clock = new THREE.Clock();
|
|
||||||
let t = 0;
|
|
||||||
|
|
||||||
renderer.setAnimationLoop(()=>{
|
|
||||||
let dt = clock.getDelta();
|
|
||||||
t += dt;
|
|
||||||
gu.time.value = t;
|
|
||||||
controls.update();
|
|
||||||
renderer.render(scene, camera);
|
|
||||||
})
|
|
||||||
`;
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
import { ShadowlessElement } from '@blocksuite/block-std';
|
|
||||||
import { css, html } from 'lit';
|
|
||||||
import { customElement } from 'lit/decorators.js';
|
|
||||||
|
|
||||||
@customElement('side-panel')
|
|
||||||
export class SidePanel extends ShadowlessElement {
|
|
||||||
static override styles = css`
|
|
||||||
side-panel {
|
|
||||||
width: 395px;
|
|
||||||
background-color: var(--affine-background-secondary-color);
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
height: 100%;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
currentContent: HTMLElement | null = null;
|
|
||||||
|
|
||||||
hideContent() {
|
|
||||||
if (this.currentContent) {
|
|
||||||
this.style.display = 'none';
|
|
||||||
this.currentContent.remove();
|
|
||||||
this.currentContent = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override render(): unknown {
|
|
||||||
return html``;
|
|
||||||
}
|
|
||||||
|
|
||||||
showContent(ele: HTMLElement) {
|
|
||||||
if (this.currentContent) {
|
|
||||||
this.currentContent.remove();
|
|
||||||
}
|
|
||||||
this.style.display = 'block';
|
|
||||||
this.currentContent = ele;
|
|
||||||
this.append(ele);
|
|
||||||
}
|
|
||||||
|
|
||||||
toggle(ele: HTMLElement) {
|
|
||||||
if (this.currentContent !== ele) {
|
|
||||||
this.showContent(ele);
|
|
||||||
} else {
|
|
||||||
this.hideContent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,6 @@ import '@shoelace-style/shoelace/dist/components/tooltip/tooltip.js';
|
|||||||
import '@shoelace-style/shoelace/dist/themes/light.css';
|
import '@shoelace-style/shoelace/dist/themes/light.css';
|
||||||
import '@shoelace-style/shoelace/dist/themes/dark.css';
|
import '@shoelace-style/shoelace/dist/themes/dark.css';
|
||||||
import './left-side-panel.js';
|
import './left-side-panel.js';
|
||||||
import './side-panel.js';
|
|
||||||
|
|
||||||
import { NotionHtmlAdapter } from '@blocksuite/affine-shared/adapters';
|
import { NotionHtmlAdapter } from '@blocksuite/affine-shared/adapters';
|
||||||
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
|
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
|
||||||
@@ -65,7 +64,6 @@ import type { CustomOutlinePanel } from './custom-outline-panel.js';
|
|||||||
import type { CustomOutlineViewer } from './custom-outline-viewer.js';
|
import type { CustomOutlineViewer } from './custom-outline-viewer.js';
|
||||||
import type { DocsPanel } from './docs-panel.js';
|
import type { DocsPanel } from './docs-panel.js';
|
||||||
import type { LeftSidePanel } from './left-side-panel.js';
|
import type { LeftSidePanel } from './left-side-panel.js';
|
||||||
import type { SidePanel } from './side-panel.js';
|
|
||||||
|
|
||||||
const basePath =
|
const basePath =
|
||||||
'https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.11.2/dist';
|
'https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.11.2/dist';
|
||||||
@@ -1046,9 +1044,6 @@ export class StarterDebugMenu extends ShadowlessElement {
|
|||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor readonly = false;
|
accessor readonly = false;
|
||||||
|
|
||||||
@property({ attribute: false })
|
|
||||||
accessor sidePanel!: SidePanel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
|||||||
@@ -1,17 +1,10 @@
|
|||||||
import type {
|
|
||||||
PeekOptions,
|
|
||||||
PeekViewService,
|
|
||||||
} from '@blocksuite/affine-components/peek';
|
|
||||||
import { PeekViewExtension } from '@blocksuite/affine-components/peek';
|
|
||||||
import type { EditorSetting } from '@blocksuite/affine-shared/services';
|
import type { EditorSetting } from '@blocksuite/affine-shared/services';
|
||||||
import { BlockComponent } from '@blocksuite/block-std';
|
|
||||||
import {
|
import {
|
||||||
ColorScheme,
|
ColorScheme,
|
||||||
type DocMode,
|
type DocMode,
|
||||||
type DocModeProvider,
|
type DocModeProvider,
|
||||||
GeneralSettingSchema,
|
GeneralSettingSchema,
|
||||||
type GenerateDocUrlService,
|
type GenerateDocUrlService,
|
||||||
matchFlavours,
|
|
||||||
type NotificationService,
|
type NotificationService,
|
||||||
type ParseDocUrlService,
|
type ParseDocUrlService,
|
||||||
type ReferenceParams,
|
type ReferenceParams,
|
||||||
@@ -22,9 +15,6 @@ import { Slot } from '@blocksuite/global/utils';
|
|||||||
import type { AffineEditorContainer } from '@blocksuite/presets';
|
import type { AffineEditorContainer } from '@blocksuite/presets';
|
||||||
import { type Workspace } from '@blocksuite/store';
|
import { type Workspace } from '@blocksuite/store';
|
||||||
import { Signal, signal } from '@preact/signals-core';
|
import { Signal, signal } from '@preact/signals-core';
|
||||||
import type { TemplateResult } from 'lit';
|
|
||||||
|
|
||||||
import type { AttachmentViewerPanel } from './components/attachment-viewer-panel.js';
|
|
||||||
|
|
||||||
function getModeFromStorage() {
|
function getModeFromStorage() {
|
||||||
const mapJson = localStorage.getItem('playground:docMode');
|
const mapJson = localStorage.getItem('playground:docMode');
|
||||||
@@ -154,37 +144,6 @@ export const themeExtension: ThemeExtension = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export function mockPeekViewExtension(
|
|
||||||
attachmentViewerPanel: AttachmentViewerPanel
|
|
||||||
) {
|
|
||||||
return PeekViewExtension({
|
|
||||||
peek(
|
|
||||||
element: {
|
|
||||||
target: HTMLElement;
|
|
||||||
docId: string;
|
|
||||||
blockIds?: string[];
|
|
||||||
template?: TemplateResult;
|
|
||||||
},
|
|
||||||
options?: PeekOptions
|
|
||||||
) {
|
|
||||||
const { target } = element;
|
|
||||||
|
|
||||||
if (
|
|
||||||
target instanceof BlockComponent &&
|
|
||||||
matchFlavours(target.model, ['affine:attachment'])
|
|
||||||
) {
|
|
||||||
attachmentViewerPanel.open(target.model);
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
alert('Peek view not implemented in playground');
|
|
||||||
console.log('peek', element, options);
|
|
||||||
|
|
||||||
return Promise.resolve();
|
|
||||||
},
|
|
||||||
} satisfies PeekViewService);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function mockGenerateDocUrlService(collection: Workspace) {
|
export function mockGenerateDocUrlService(collection: Workspace) {
|
||||||
const generateDocUrlService: GenerateDocUrlService = {
|
const generateDocUrlService: GenerateDocUrlService = {
|
||||||
generateDocUrl: (docId: string, params?: ReferenceParams) => {
|
generateDocUrl: (docId: string, params?: ReferenceParams) => {
|
||||||
|
|||||||
@@ -73,14 +73,6 @@ async function main() {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
// test if blocksuite can run in a web worker, SEE: tests/worker.spec.ts
|
|
||||||
// window.testWorker = new Worker(
|
|
||||||
// new URL('./utils/test-worker.ts', import.meta.url),
|
|
||||||
// {
|
|
||||||
// type: 'module',
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import { CustomOutlinePanel } from '../../_common/components/custom-outline-pane
|
|||||||
import { CustomOutlineViewer } from '../../_common/components/custom-outline-viewer.js';
|
import { CustomOutlineViewer } from '../../_common/components/custom-outline-viewer.js';
|
||||||
import { DocsPanel } from '../../_common/components/docs-panel.js';
|
import { DocsPanel } from '../../_common/components/docs-panel.js';
|
||||||
import { LeftSidePanel } from '../../_common/components/left-side-panel.js';
|
import { LeftSidePanel } from '../../_common/components/left-side-panel.js';
|
||||||
import { SidePanel } from '../../_common/components/side-panel.js';
|
|
||||||
import { StarterDebugMenu } from '../../_common/components/starter-debug-menu.js';
|
import { StarterDebugMenu } from '../../_common/components/starter-debug-menu.js';
|
||||||
import {
|
import {
|
||||||
getDocFromUrlParams,
|
getDocFromUrlParams,
|
||||||
@@ -85,7 +84,6 @@ export async function mountDefaultDocEditor(collection: Workspace) {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// mockPeekViewExtension(attachmentViewerPanel),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const pageSpecs = SpecProvider.getInstance().getSpec('page');
|
const pageSpecs = SpecProvider.getInstance().getSpec('page');
|
||||||
@@ -136,8 +134,6 @@ export async function mountDefaultDocEditor(collection: Workspace) {
|
|||||||
const framePanel = new CustomFramePanel();
|
const framePanel = new CustomFramePanel();
|
||||||
framePanel.editor = editor;
|
framePanel.editor = editor;
|
||||||
|
|
||||||
const sidePanel = new SidePanel();
|
|
||||||
|
|
||||||
const leftSidePanel = new LeftSidePanel();
|
const leftSidePanel = new LeftSidePanel();
|
||||||
|
|
||||||
const docsPanel = new DocsPanel();
|
const docsPanel = new DocsPanel();
|
||||||
@@ -152,7 +148,6 @@ export async function mountDefaultDocEditor(collection: Workspace) {
|
|||||||
debugMenu.outlinePanel = outlinePanel;
|
debugMenu.outlinePanel = outlinePanel;
|
||||||
debugMenu.outlineViewer = outlineViewer;
|
debugMenu.outlineViewer = outlineViewer;
|
||||||
debugMenu.framePanel = framePanel;
|
debugMenu.framePanel = framePanel;
|
||||||
debugMenu.sidePanel = sidePanel;
|
|
||||||
debugMenu.leftSidePanel = leftSidePanel;
|
debugMenu.leftSidePanel = leftSidePanel;
|
||||||
debugMenu.docsPanel = docsPanel;
|
debugMenu.docsPanel = docsPanel;
|
||||||
debugMenu.commentPanel = commentPanel;
|
debugMenu.commentPanel = commentPanel;
|
||||||
@@ -161,7 +156,6 @@ export async function mountDefaultDocEditor(collection: Workspace) {
|
|||||||
document.body.append(outlinePanel);
|
document.body.append(outlinePanel);
|
||||||
document.body.append(outlineViewer);
|
document.body.append(outlineViewer);
|
||||||
document.body.append(framePanel);
|
document.body.append(framePanel);
|
||||||
document.body.append(sidePanel);
|
|
||||||
document.body.append(leftSidePanel);
|
document.body.append(leftSidePanel);
|
||||||
document.body.append(debugMenu);
|
document.body.append(debugMenu);
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
// This file is used to test blocksuite can run in a web worker. SEE: tests/worker.spec.ts
|
|
||||||
|
|
||||||
import '@blocksuite/store';
|
|
||||||
// import '@blocksuite/block-std'; // seems not working
|
|
||||||
import '@blocksuite/blocks/schemas';
|
|
||||||
|
|
||||||
globalThis.onmessage = event => {
|
|
||||||
const { data } = event;
|
|
||||||
if (data === 'ping') {
|
|
||||||
postMessage('pong');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -157,6 +157,7 @@ async function initEmptyEditor({
|
|||||||
const outlineViewer = document.createElement(
|
const outlineViewer = document.createElement(
|
||||||
'custom-outline-viewer'
|
'custom-outline-viewer'
|
||||||
);
|
);
|
||||||
|
const leftSidePanel = document.createElement('left-side-panel');
|
||||||
// @ts-expect-error set test editor
|
// @ts-expect-error set test editor
|
||||||
docsPanel.editor = editor;
|
docsPanel.editor = editor;
|
||||||
// @ts-expect-error set test editor
|
// @ts-expect-error set test editor
|
||||||
@@ -177,7 +178,6 @@ async function initEmptyEditor({
|
|||||||
debugMenu.outlineViewer = outlineViewer;
|
debugMenu.outlineViewer = outlineViewer;
|
||||||
// @ts-expect-error set test outlinePanel
|
// @ts-expect-error set test outlinePanel
|
||||||
debugMenu.outlinePanel = outlinePanel;
|
debugMenu.outlinePanel = outlinePanel;
|
||||||
const leftSidePanel = document.createElement('left-side-panel');
|
|
||||||
// @ts-expect-error set test leftSidePanel
|
// @ts-expect-error set test leftSidePanel
|
||||||
debugMenu.leftSidePanel = leftSidePanel;
|
debugMenu.leftSidePanel = leftSidePanel;
|
||||||
document.body.append(debugMenu);
|
document.body.append(debugMenu);
|
||||||
|
|||||||
@@ -312,6 +312,19 @@ export const PackageList = [
|
|||||||
'blocksuite/framework/store',
|
'blocksuite/framework/store',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
location: 'blocksuite/affine/widget-edgeless-auto-connect',
|
||||||
|
name: '@blocksuite/affine-widget-edgeless-auto-connect',
|
||||||
|
workspaceDependencies: [
|
||||||
|
'blocksuite/affine/block-note',
|
||||||
|
'blocksuite/affine/block-surface',
|
||||||
|
'blocksuite/affine/components',
|
||||||
|
'blocksuite/affine/model',
|
||||||
|
'blocksuite/affine/shared',
|
||||||
|
'blocksuite/framework/block-std',
|
||||||
|
'blocksuite/framework/global',
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
location: 'blocksuite/affine/widget-frame-title',
|
location: 'blocksuite/affine/widget-frame-title',
|
||||||
name: '@blocksuite/affine-widget-frame-title',
|
name: '@blocksuite/affine-widget-frame-title',
|
||||||
@@ -370,6 +383,7 @@ export const PackageList = [
|
|||||||
'blocksuite/affine/model',
|
'blocksuite/affine/model',
|
||||||
'blocksuite/affine/shared',
|
'blocksuite/affine/shared',
|
||||||
'blocksuite/affine/widget-drag-handle',
|
'blocksuite/affine/widget-drag-handle',
|
||||||
|
'blocksuite/affine/widget-edgeless-auto-connect',
|
||||||
'blocksuite/affine/widget-frame-title',
|
'blocksuite/affine/widget-frame-title',
|
||||||
'blocksuite/affine/widget-remote-selection',
|
'blocksuite/affine/widget-remote-selection',
|
||||||
'blocksuite/affine/widget-scroll-anchoring',
|
'blocksuite/affine/widget-scroll-anchoring',
|
||||||
@@ -751,6 +765,7 @@ export type PackageName =
|
|||||||
| '@blocksuite/affine-model'
|
| '@blocksuite/affine-model'
|
||||||
| '@blocksuite/affine-shared'
|
| '@blocksuite/affine-shared'
|
||||||
| '@blocksuite/affine-widget-drag-handle'
|
| '@blocksuite/affine-widget-drag-handle'
|
||||||
|
| '@blocksuite/affine-widget-edgeless-auto-connect'
|
||||||
| '@blocksuite/affine-widget-frame-title'
|
| '@blocksuite/affine-widget-frame-title'
|
||||||
| '@blocksuite/affine-widget-remote-selection'
|
| '@blocksuite/affine-widget-remote-selection'
|
||||||
| '@blocksuite/affine-widget-scroll-anchoring'
|
| '@blocksuite/affine-widget-scroll-anchoring'
|
||||||
|
|||||||
@@ -73,6 +73,7 @@
|
|||||||
{ "path": "./blocksuite/affine/model" },
|
{ "path": "./blocksuite/affine/model" },
|
||||||
{ "path": "./blocksuite/affine/shared" },
|
{ "path": "./blocksuite/affine/shared" },
|
||||||
{ "path": "./blocksuite/affine/widget-drag-handle" },
|
{ "path": "./blocksuite/affine/widget-drag-handle" },
|
||||||
|
{ "path": "./blocksuite/affine/widget-edgeless-auto-connect" },
|
||||||
{ "path": "./blocksuite/affine/widget-frame-title" },
|
{ "path": "./blocksuite/affine/widget-frame-title" },
|
||||||
{ "path": "./blocksuite/affine/widget-remote-selection" },
|
{ "path": "./blocksuite/affine/widget-remote-selection" },
|
||||||
{ "path": "./blocksuite/affine/widget-scroll-anchoring" },
|
{ "path": "./blocksuite/affine/widget-scroll-anchoring" },
|
||||||
|
|||||||
@@ -3791,6 +3791,23 @@ __metadata:
|
|||||||
languageName: unknown
|
languageName: unknown
|
||||||
linkType: soft
|
linkType: soft
|
||||||
|
|
||||||
|
"@blocksuite/affine-widget-edgeless-auto-connect@workspace:*, @blocksuite/affine-widget-edgeless-auto-connect@workspace:blocksuite/affine/widget-edgeless-auto-connect":
|
||||||
|
version: 0.0.0-use.local
|
||||||
|
resolution: "@blocksuite/affine-widget-edgeless-auto-connect@workspace:blocksuite/affine/widget-edgeless-auto-connect"
|
||||||
|
dependencies:
|
||||||
|
"@blocksuite/affine-block-note": "workspace:*"
|
||||||
|
"@blocksuite/affine-block-surface": "workspace:*"
|
||||||
|
"@blocksuite/affine-components": "workspace:*"
|
||||||
|
"@blocksuite/affine-model": "workspace:*"
|
||||||
|
"@blocksuite/affine-shared": "workspace:*"
|
||||||
|
"@blocksuite/block-std": "workspace:*"
|
||||||
|
"@blocksuite/global": "workspace:*"
|
||||||
|
"@preact/signals-core": "npm:^1.8.0"
|
||||||
|
"@toeverything/theme": "npm:^1.1.7"
|
||||||
|
lit: "npm:^3.2.0"
|
||||||
|
languageName: unknown
|
||||||
|
linkType: soft
|
||||||
|
|
||||||
"@blocksuite/affine-widget-frame-title@workspace:*, @blocksuite/affine-widget-frame-title@workspace:blocksuite/affine/widget-frame-title":
|
"@blocksuite/affine-widget-frame-title@workspace:*, @blocksuite/affine-widget-frame-title@workspace:blocksuite/affine/widget-frame-title":
|
||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@blocksuite/affine-widget-frame-title@workspace:blocksuite/affine/widget-frame-title"
|
resolution: "@blocksuite/affine-widget-frame-title@workspace:blocksuite/affine/widget-frame-title"
|
||||||
@@ -3903,6 +3920,7 @@ __metadata:
|
|||||||
"@blocksuite/affine-model": "workspace:*"
|
"@blocksuite/affine-model": "workspace:*"
|
||||||
"@blocksuite/affine-shared": "workspace:*"
|
"@blocksuite/affine-shared": "workspace:*"
|
||||||
"@blocksuite/affine-widget-drag-handle": "workspace:*"
|
"@blocksuite/affine-widget-drag-handle": "workspace:*"
|
||||||
|
"@blocksuite/affine-widget-edgeless-auto-connect": "workspace:*"
|
||||||
"@blocksuite/affine-widget-frame-title": "workspace:*"
|
"@blocksuite/affine-widget-frame-title": "workspace:*"
|
||||||
"@blocksuite/affine-widget-remote-selection": "workspace:*"
|
"@blocksuite/affine-widget-remote-selection": "workspace:*"
|
||||||
"@blocksuite/affine-widget-scroll-anchoring": "workspace:*"
|
"@blocksuite/affine-widget-scroll-anchoring": "workspace:*"
|
||||||
|
|||||||
Reference in New Issue
Block a user