mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-23 04:51:49 +08:00
feat(editor): replace slot with rxjs subject (#10768)
This commit is contained in:
@@ -53,7 +53,8 @@
|
|||||||
"@blocksuite/global": "workspace:*",
|
"@blocksuite/global": "workspace:*",
|
||||||
"@blocksuite/inline": "workspace:*",
|
"@blocksuite/inline": "workspace:*",
|
||||||
"@blocksuite/store": "workspace:*",
|
"@blocksuite/store": "workspace:*",
|
||||||
"@blocksuite/sync": "workspace:*"
|
"@blocksuite/sync": "workspace:*",
|
||||||
|
"rxjs": "^7.8.1"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts",
|
".": "./src/index.ts",
|
||||||
@@ -67,7 +68,7 @@
|
|||||||
"./global/di": "./src/global/di.ts",
|
"./global/di": "./src/global/di.ts",
|
||||||
"./global/types": "./src/global/types.ts",
|
"./global/types": "./src/global/types.ts",
|
||||||
"./global/gfx": "./src/global/gfx.ts",
|
"./global/gfx": "./src/global/gfx.ts",
|
||||||
"./global/slot": "./src/global/slot.ts",
|
"./global/disposable": "./src/global/disposable.ts",
|
||||||
"./global/lit": "./src/global/lit.ts",
|
"./global/lit": "./src/global/lit.ts",
|
||||||
"./store": "./src/store/index.ts",
|
"./store": "./src/store/index.ts",
|
||||||
"./store/test": "./src/store/test.ts",
|
"./store/test": "./src/store/test.ts",
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from '@blocksuite/global/disposable';
|
||||||
@@ -1 +0,0 @@
|
|||||||
export * from '@blocksuite/global/slot';
|
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
"file-type": "^20.0.0",
|
"file-type": "^20.0.0",
|
||||||
"lit": "^3.2.0",
|
"lit": "^3.2.0",
|
||||||
"minimatch": "^10.0.1",
|
"minimatch": "^10.0.1",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.model.propsUpdated.on(({ key }) => {
|
this.model.propsUpdated.subscribe(({ key }) => {
|
||||||
if (key === 'sourceId') {
|
if (key === 'sourceId') {
|
||||||
// Reset the blob url when the sourceId is changed
|
// Reset the blob url when the sourceId is changed
|
||||||
if (this.blobUrl) {
|
if (this.blobUrl) {
|
||||||
|
|||||||
@@ -22,14 +22,14 @@ export class AttachmentEdgelessBlockComponent extends toGfxBlockComponent(
|
|||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
|
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.slots.elementResizeStart.on(() => {
|
this.slots.elementResizeStart.subscribe(() => {
|
||||||
this._isResizing = true;
|
this._isResizing = true;
|
||||||
this._showOverlay = true;
|
this._showOverlay = true;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.slots.elementResizeEnd.on(() => {
|
this.slots.elementResizeEnd.subscribe(() => {
|
||||||
this._isResizing = false;
|
this._isResizing = false;
|
||||||
this._showOverlay =
|
this._showOverlay =
|
||||||
this._isResizing || this._isDragging || !this.selected$.peek();
|
this._isResizing || this._isDragging || !this.selected$.peek();
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
"@toeverything/theme": "^1.1.12",
|
"@toeverything/theme": "^1.1.12",
|
||||||
"lit": "^3.2.0",
|
"lit": "^3.2.0",
|
||||||
"minimatch": "^10.0.1",
|
"minimatch": "^10.0.1",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"yjs": "^13.6.23",
|
"yjs": "^13.6.23",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export class BookmarkBlockComponent extends CaptionedBlockComponent<BookmarkBloc
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.model.propsUpdated.on(({ key }) => {
|
this.model.propsUpdated.subscribe(({ key }) => {
|
||||||
if (key === 'url') {
|
if (key === 'url') {
|
||||||
this.refreshData();
|
this.refreshData();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export class BookmarkCard extends WithDisposable(ShadowlessElement) {
|
|||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
|
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.bookmark.model.propsUpdated.on(() => {
|
this.bookmark.model.propsUpdated.subscribe(() => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
"emoji-mart": "^5.6.0",
|
"emoji-mart": "^5.6.0",
|
||||||
"lit": "^3.2.0",
|
"lit": "^3.2.0",
|
||||||
"minimatch": "^10.0.1",
|
"minimatch": "^10.0.1",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
"@types/mdast": "^4.0.4",
|
"@types/mdast": "^4.0.4",
|
||||||
"lit": "^3.2.0",
|
"lit": "^3.2.0",
|
||||||
"minimatch": "^10.0.1",
|
"minimatch": "^10.0.1",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"shiki": "^3.0.0",
|
"shiki": "^3.0.0",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
Clipboard,
|
Clipboard,
|
||||||
type UIEventHandler,
|
type UIEventHandler,
|
||||||
} from '@blocksuite/block-std';
|
} from '@blocksuite/block-std';
|
||||||
import { DisposableGroup } from '@blocksuite/global/slot';
|
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||||
|
|
||||||
export class CodeClipboardController {
|
export class CodeClipboardController {
|
||||||
private _clipboard!: Clipboard;
|
private _clipboard!: Clipboard;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
"@types/mdast": "^4.0.4",
|
"@types/mdast": "^4.0.4",
|
||||||
"lit": "^3.2.0",
|
"lit": "^3.2.0",
|
||||||
"minimatch": "^10.0.1",
|
"minimatch": "^10.0.1",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { PropertyMetaConfig } from '@blocksuite/data-view';
|
import type { PropertyMetaConfig } from '@blocksuite/data-view';
|
||||||
import type { Disposable } from '@blocksuite/global/slot';
|
import type { DisposableMember } from '@blocksuite/global/disposable';
|
||||||
import type { Block, BlockModel } from '@blocksuite/store';
|
import type { Block, BlockModel } from '@blocksuite/store';
|
||||||
|
|
||||||
type PropertyMeta<
|
type PropertyMeta<
|
||||||
@@ -14,7 +14,7 @@ type PropertyMeta<
|
|||||||
setColumnData?: (block: T, data: ColumnData) => void;
|
setColumnData?: (block: T, data: ColumnData) => void;
|
||||||
get: (block: T) => Value;
|
get: (block: T) => Value;
|
||||||
set?: (block: T, value: Value) => void;
|
set?: (block: T, value: Value) => void;
|
||||||
updated: (block: T, callback: () => void) => Disposable;
|
updated: (block: T, callback: () => void) => DisposableMember;
|
||||||
};
|
};
|
||||||
export type BlockMeta<T extends BlockModel = BlockModel> = {
|
export type BlockMeta<T extends BlockModel = BlockModel> = {
|
||||||
selector: (block: Block) => boolean;
|
selector: (block: Block) => boolean;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ todoMeta.addProperty({
|
|||||||
block.checked = value ?? false;
|
block.checked = value ?? false;
|
||||||
},
|
},
|
||||||
updated: (block, callback) => {
|
updated: (block, callback) => {
|
||||||
return block.propsUpdated.on(({ key }) => {
|
return block.propsUpdated.subscribe(({ key }) => {
|
||||||
if (key === 'checked') {
|
if (key === 'checked') {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ todoMeta.addProperty({
|
|||||||
metaConfig: propertyPresets.textPropertyConfig,
|
metaConfig: propertyPresets.textPropertyConfig,
|
||||||
get: block => block.doc.meta?.title ?? '',
|
get: block => block.doc.meta?.title ?? '',
|
||||||
updated: (block, callback) => {
|
updated: (block, callback) => {
|
||||||
return block.doc.workspace.slots.docListUpdated.on(() => {
|
return block.doc.workspace.slots.docListUpdated.subscribe(() => {
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import type { EditorHost } from '@blocksuite/block-std';
|
|||||||
import { DataSourceBase, type PropertyMetaConfig } from '@blocksuite/data-view';
|
import { DataSourceBase, type PropertyMetaConfig } from '@blocksuite/data-view';
|
||||||
import { propertyPresets } from '@blocksuite/data-view/property-presets';
|
import { propertyPresets } from '@blocksuite/data-view/property-presets';
|
||||||
import { BlockSuiteError } from '@blocksuite/global/exceptions';
|
import { BlockSuiteError } from '@blocksuite/global/exceptions';
|
||||||
import { Slot } from '@blocksuite/global/slot';
|
|
||||||
import type { Block, Store } from '@blocksuite/store';
|
import type { Block, Store } from '@blocksuite/store';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
import type { BlockMeta } from './block-meta/base.js';
|
import type { BlockMeta } from './block-meta/base.js';
|
||||||
import { blockMetaMap } from './block-meta/index.js';
|
import { blockMetaMap } from './block-meta/index.js';
|
||||||
@@ -37,7 +37,7 @@ export class BlockQueryDataSource extends DataSourceBase {
|
|||||||
docDisposeMap = new Map<string, () => void>();
|
docDisposeMap = new Map<string, () => void>();
|
||||||
|
|
||||||
slots = {
|
slots = {
|
||||||
update: new Slot(),
|
update: new Subject(),
|
||||||
};
|
};
|
||||||
|
|
||||||
private get blocks() {
|
private get blocks() {
|
||||||
@@ -83,13 +83,13 @@ export class BlockQueryDataSource extends DataSourceBase {
|
|||||||
this.workspace.docs.forEach(doc => {
|
this.workspace.docs.forEach(doc => {
|
||||||
this.listenToDoc(doc.getStore());
|
this.listenToDoc(doc.getStore());
|
||||||
});
|
});
|
||||||
this.workspace.slots.docCreated.on(id => {
|
this.workspace.slots.docCreated.subscribe(id => {
|
||||||
const doc = this.workspace.getDoc(id);
|
const doc = this.workspace.getDoc(id);
|
||||||
if (doc) {
|
if (doc) {
|
||||||
this.listenToDoc(doc);
|
this.listenToDoc(doc);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.workspace.slots.docRemoved.on(id => {
|
this.workspace.slots.docRemoved.subscribe(id => {
|
||||||
this.docDisposeMap.get(id)?.();
|
this.docDisposeMap.get(id)?.();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ export class BlockQueryDataSource extends DataSourceBase {
|
|||||||
listenToDoc(doc: Store) {
|
listenToDoc(doc: Store) {
|
||||||
this.docDisposeMap.set(
|
this.docDisposeMap.set(
|
||||||
doc.id,
|
doc.id,
|
||||||
doc.slots.blockUpdated.on(v => {
|
doc.slots.blockUpdated.subscribe(v => {
|
||||||
if (v.type === 'add') {
|
if (v.type === 'add') {
|
||||||
const blockById = doc.getBlock(v.id);
|
const blockById = doc.getBlock(v.id);
|
||||||
if (blockById && this.meta.selector(blockById)) {
|
if (blockById && this.meta.selector(blockById)) {
|
||||||
@@ -158,8 +158,8 @@ export class BlockQueryDataSource extends DataSourceBase {
|
|||||||
} else if (v.type === 'delete') {
|
} else if (v.type === 'delete') {
|
||||||
this.blockMap.delete(v.id);
|
this.blockMap.delete(v.id);
|
||||||
}
|
}
|
||||||
this.slots.update.emit();
|
this.slots.update.next(undefined);
|
||||||
}).dispose
|
}).unsubscribe
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
"date-fns": "^4.0.0",
|
"date-fns": "^4.0.0",
|
||||||
"lit": "^3.2.0",
|
"lit": "^3.2.0",
|
||||||
"minimatch": "^10.0.1",
|
"minimatch": "^10.0.1",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"yjs": "^13.6.21",
|
"yjs": "^13.6.21",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ export class LinkCell extends BaseCellRenderer<string> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std.getOptional(RefNodeSlotsProvider)?.docLinkClicked.emit({
|
std.getOptional(RefNodeSlotsProvider)?.docLinkClicked.next({
|
||||||
pageId: this.docId$.value,
|
pageId: this.docId$.value,
|
||||||
host: std.host,
|
host: std.host,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -339,8 +339,10 @@ export class RichTextCell extends BaseCellRenderer<Text> {
|
|||||||
effect(() => {
|
effect(() => {
|
||||||
const editor = this.inlineEditor$.value;
|
const editor = this.inlineEditor$.value;
|
||||||
if (editor) {
|
if (editor) {
|
||||||
const disposable = editor.slots.keydown.on(this._handleKeyDown);
|
const disposable = editor.slots.keydown.subscribe(
|
||||||
return () => disposable.dispose();
|
this._handleKeyDown
|
||||||
|
);
|
||||||
|
return () => disposable.unsubscribe();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
"@types/mdast": "^4.0.4",
|
"@types/mdast": "^4.0.4",
|
||||||
"lit": "^3.2.0",
|
"lit": "^3.2.0",
|
||||||
"minimatch": "^10.0.1",
|
"minimatch": "^10.0.1",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
"@toeverything/theme": "^1.1.12",
|
"@toeverything/theme": "^1.1.12",
|
||||||
"lit": "^3.2.0",
|
"lit": "^3.2.0",
|
||||||
"minimatch": "^10.0.1",
|
"minimatch": "^10.0.1",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export const insertEdgelessTextCommand: Command<
|
|||||||
elements: [textId],
|
elements: [textId],
|
||||||
editing: true,
|
editing: true,
|
||||||
});
|
});
|
||||||
const disposable = selection.slots.updated.on(() => {
|
const disposable = selection.slots.updated.subscribe(() => {
|
||||||
const editing = selection.editing;
|
const editing = selection.editing;
|
||||||
const id = selection.selectedIds[0];
|
const id = selection.selectedIds[0];
|
||||||
if (!editing || id !== textId) {
|
if (!editing || id !== textId) {
|
||||||
@@ -63,7 +63,7 @@ export const insertEdgelessTextCommand: Command<
|
|||||||
textBlock.model.hasMaxWidth = true;
|
textBlock.model.hasMaxWidth = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
disposable.dispose();
|
disposable.unsubscribe();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -91,7 +91,8 @@ export const insertEdgelessTextCommand: Command<
|
|||||||
signal: abortController.signal,
|
signal: abortController.signal,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
paragraph.model.deleted.once(() => {
|
const subscription = paragraph.model.deleted.subscribe(() => {
|
||||||
|
subscription.unsubscribe();
|
||||||
abortController.abort();
|
abortController.abort();
|
||||||
});
|
});
|
||||||
edgelessText.addEventListener(
|
edgelessText.addEventListener(
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
|
|||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
|
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.model.propsUpdated.on(({ key }) => {
|
this.model.propsUpdated.subscribe(({ key }) => {
|
||||||
this.updateComplete
|
this.updateComplete
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const command = this.std.command;
|
const command = this.std.command;
|
||||||
@@ -137,7 +137,7 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
|
|||||||
const edgelessSelection = this.gfx.selection;
|
const edgelessSelection = this.gfx.selection;
|
||||||
|
|
||||||
disposables.add(
|
disposables.add(
|
||||||
edgelessSelection.slots.updated.on(() => {
|
edgelessSelection.slots.updated.subscribe(() => {
|
||||||
if (edgelessSelection.has(this.model.id) && edgelessSelection.editing) {
|
if (edgelessSelection.has(this.model.id) && edgelessSelection.editing) {
|
||||||
this._editing = true;
|
this._editing = true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
"lit": "^3.2.0",
|
"lit": "^3.2.0",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"minimatch": "^10.0.1",
|
"minimatch": "^10.0.1",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"yjs": "^13.6.21",
|
"yjs": "^13.6.21",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ export function notifyDocCreated(std: BlockStdScope, doc: Store) {
|
|||||||
const clear = () => {
|
const clear = () => {
|
||||||
doc.history.off('stack-item-added', addHandler);
|
doc.history.off('stack-item-added', addHandler);
|
||||||
doc.history.off('stack-item-popped', popHandler);
|
doc.history.off('stack-item-popped', popHandler);
|
||||||
disposable.dispose();
|
disposable.unsubscribe();
|
||||||
};
|
};
|
||||||
const closeNotify = () => {
|
const closeNotify = () => {
|
||||||
abortController.abort();
|
abortController.abort();
|
||||||
@@ -353,7 +353,7 @@ export function notifyDocCreated(std: BlockStdScope, doc: Store) {
|
|||||||
const popHandler = doc.history.on('stack-item-popped', closeNotify);
|
const popHandler = doc.history.on('stack-item-popped', closeNotify);
|
||||||
const disposable = std
|
const disposable = std
|
||||||
.get(EditorLifeCycleExtension)
|
.get(EditorLifeCycleExtension)
|
||||||
.slots.unmounted.on(closeNotify);
|
.slots.unmounted.subscribe(closeNotify);
|
||||||
|
|
||||||
notification.notify({
|
notification.notify({
|
||||||
title: 'Linked doc created',
|
title: 'Linked doc created',
|
||||||
|
|||||||
@@ -54,14 +54,14 @@ export function toEdgelessEmbedBlock<
|
|||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
|
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.edgelessSlots.elementResizeStart.on(() => {
|
this.edgelessSlots.elementResizeStart.subscribe(() => {
|
||||||
this._isResizing = true;
|
this._isResizing = true;
|
||||||
this._showOverlay = true;
|
this._showOverlay = true;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.edgelessSlots.elementResizeEnd.on(() => {
|
this.edgelessSlots.elementResizeEnd.subscribe(() => {
|
||||||
this._isResizing = false;
|
this._isResizing = false;
|
||||||
this._showOverlay =
|
this._showOverlay =
|
||||||
this._isResizing || this._isDragging || !this.selected$.peek();
|
this._isResizing || this._isDragging || !this.selected$.peek();
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export class EmbedFigmaBlockComponent extends EmbedBlockComponent<EmbedFigmaMode
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.model.propsUpdated.on(({ key }) => {
|
this.model.propsUpdated.subscribe(({ key }) => {
|
||||||
if (key === 'url') {
|
if (key === 'url') {
|
||||||
this.refreshData();
|
this.refreshData();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ export class EmbedGithubBlockComponent extends EmbedBlockComponent<
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.model.propsUpdated.on(({ key }) => {
|
this.model.propsUpdated.subscribe(({ key }) => {
|
||||||
if (key === 'url') {
|
if (key === 'url') {
|
||||||
this.refreshData();
|
this.refreshData();
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-6
@@ -73,12 +73,17 @@ const linkedDocSlashMenuConfig: SlashMenuConfig = {
|
|||||||
insertContent(std.host, model, triggerKey);
|
insertContent(std.host, model, triggerKey);
|
||||||
|
|
||||||
const inlineEditor = getInlineEditorByModel(std.host, model);
|
const inlineEditor = getInlineEditorByModel(std.host, model);
|
||||||
// Wait for range to be updated
|
if (inlineEditor) {
|
||||||
inlineEditor?.slots.inlineRangeSync.once(() => {
|
// Wait for range to be updated
|
||||||
// TODO(@L-Sun): make linked-doc-widget as extension
|
const subscription = inlineEditor.slots.inlineRangeSync.subscribe(
|
||||||
// @ts-expect-error same as above
|
() => {
|
||||||
linkedDocWidget.show({ addTriggerKey: true });
|
// TODO(@L-Sun): make linked-doc-widget as extension
|
||||||
});
|
subscription.unsubscribe();
|
||||||
|
// @ts-expect-error same as above
|
||||||
|
linkedDocWidget.show({ addTriggerKey: true });
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
+7
-6
@@ -87,7 +87,8 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
|
|||||||
|
|
||||||
if (!this.isError && !linkedDoc.root) {
|
if (!this.isError && !linkedDoc.root) {
|
||||||
await new Promise<void>(resolve => {
|
await new Promise<void>(resolve => {
|
||||||
linkedDoc.slots.rootAdded.once(() => {
|
const subscription = linkedDoc.slots.rootAdded.subscribe(() => {
|
||||||
|
subscription.unsubscribe();
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -203,7 +204,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
|
|||||||
openMode?: OpenDocMode;
|
openMode?: OpenDocMode;
|
||||||
event?: MouseEvent;
|
event?: MouseEvent;
|
||||||
} = {}) => {
|
} = {}) => {
|
||||||
this.std.getOptional(RefNodeSlotsProvider)?.docLinkClicked.emit({
|
this.std.getOptional(RefNodeSlotsProvider)?.docLinkClicked.next({
|
||||||
...this.referenceInfo$.peek(),
|
...this.referenceInfo$.peek(),
|
||||||
openMode,
|
openMode,
|
||||||
event,
|
event,
|
||||||
@@ -285,7 +286,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
|
|||||||
const linkedDoc = this.linkedDoc;
|
const linkedDoc = this.linkedDoc;
|
||||||
if (linkedDoc) {
|
if (linkedDoc) {
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
linkedDoc.workspace.slots.docListUpdated.on(() => {
|
linkedDoc.workspace.slots.docListUpdated.subscribe(() => {
|
||||||
this._load().catch(e => {
|
this._load().catch(e => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
this.isError = true;
|
this.isError = true;
|
||||||
@@ -295,7 +296,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
|
|||||||
// Should throttle the blockUpdated event to avoid too many re-renders
|
// Should throttle the blockUpdated event to avoid too many re-renders
|
||||||
// Because the blockUpdated event is triggered too frequently at some cases
|
// Because the blockUpdated event is triggered too frequently at some cases
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
linkedDoc.slots.blockUpdated.on(
|
linkedDoc.slots.blockUpdated.subscribe(
|
||||||
throttle(payload => {
|
throttle(payload => {
|
||||||
if (
|
if (
|
||||||
payload.type === 'update' &&
|
payload.type === 'update' &&
|
||||||
@@ -318,7 +319,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
|
|||||||
|
|
||||||
this._setDocUpdatedAt();
|
this._setDocUpdatedAt();
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.doc.workspace.slots.docListUpdated.on(() => {
|
this.doc.workspace.slots.docListUpdated.subscribe(() => {
|
||||||
this._setDocUpdatedAt();
|
this._setDocUpdatedAt();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -337,7 +338,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.model.propsUpdated.on(({ key }) => {
|
this.model.propsUpdated.subscribe(({ key }) => {
|
||||||
if (key === 'style') {
|
if (key === 'style') {
|
||||||
this._cardStyle = this.model.style;
|
this._cardStyle = this.model.style;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ export class EmbedLoomBlockComponent extends EmbedBlockComponent<
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.model.propsUpdated.on(({ key }) => {
|
this.model.propsUpdated.subscribe(({ key }) => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
if (key === 'url') {
|
if (key === 'url') {
|
||||||
this.refreshData();
|
this.refreshData();
|
||||||
|
|||||||
+4
-3
@@ -99,20 +99,21 @@ export class EmbedSyncedDocCard extends WithDisposable(ShadowlessElement) {
|
|||||||
if (syncedDoc.root) {
|
if (syncedDoc.root) {
|
||||||
renderLinkedDocInCard(this);
|
renderLinkedDocInCard(this);
|
||||||
} else {
|
} else {
|
||||||
syncedDoc.slots.rootAdded.once(() => {
|
const subscription = syncedDoc.slots.rootAdded.subscribe(() => {
|
||||||
|
subscription.unsubscribe();
|
||||||
renderLinkedDocInCard(this);
|
renderLinkedDocInCard(this);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
syncedDoc.workspace.slots.docListUpdated.on(() => {
|
syncedDoc.workspace.slots.docListUpdated.subscribe(() => {
|
||||||
renderLinkedDocInCard(this);
|
renderLinkedDocInCard(this);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
// Should throttle the blockUpdated event to avoid too many re-renders
|
// Should throttle the blockUpdated event to avoid too many re-renders
|
||||||
// Because the blockUpdated event is triggered too frequently at some cases
|
// Because the blockUpdated event is triggered too frequently at some cases
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
syncedDoc.slots.blockUpdated.on(
|
syncedDoc.slots.blockUpdated.subscribe(
|
||||||
throttle(payload => {
|
throttle(payload => {
|
||||||
if (this._dragging) {
|
if (this._dragging) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
+9
-6
@@ -129,7 +129,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
|
|||||||
|
|
||||||
override mounted(): void {
|
override mounted(): void {
|
||||||
const { view } = this.std;
|
const { view } = this.std;
|
||||||
view.viewUpdated.on(payload => {
|
view.viewUpdated.subscribe(payload => {
|
||||||
if (
|
if (
|
||||||
payload.type !== 'block' ||
|
payload.type !== 'block' ||
|
||||||
payload.view.model.flavour !== 'affine:embed-synced-doc'
|
payload.view.model.flavour !== 'affine:embed-synced-doc'
|
||||||
@@ -355,7 +355,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
|
|||||||
|
|
||||||
this.std
|
this.std
|
||||||
.getOptional(RefNodeSlotsProvider)
|
.getOptional(RefNodeSlotsProvider)
|
||||||
?.docLinkClicked.emit({ ...event, pageId, host: this.host });
|
?.docLinkClicked.next({ ...event, pageId, host: this.host });
|
||||||
};
|
};
|
||||||
|
|
||||||
refreshData = () => {
|
refreshData = () => {
|
||||||
@@ -464,7 +464,10 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
|
|||||||
|
|
||||||
if (!this._error && !syncedDoc.root) {
|
if (!this._error && !syncedDoc.root) {
|
||||||
await new Promise<void>(resolve => {
|
await new Promise<void>(resolve => {
|
||||||
syncedDoc.slots.rootAdded.once(() => resolve());
|
const subscription = syncedDoc.slots.rootAdded.subscribe(() => {
|
||||||
|
subscription.unsubscribe();
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,7 +507,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
|
|||||||
this.contentEditable = 'false';
|
this.contentEditable = 'false';
|
||||||
|
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.model.propsUpdated.on(({ key }) => {
|
this.model.propsUpdated.subscribe(({ key }) => {
|
||||||
if (key === 'pageId' || key === 'style') {
|
if (key === 'pageId' || key === 'style') {
|
||||||
this._load().catch(e => {
|
this._load().catch(e => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
@@ -516,7 +519,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
|
|||||||
|
|
||||||
this._setDocUpdatedAt();
|
this._setDocUpdatedAt();
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.doc.workspace.slots.docListUpdated.on(() => {
|
this.doc.workspace.slots.docListUpdated.subscribe(() => {
|
||||||
this._setDocUpdatedAt();
|
this._setDocUpdatedAt();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -535,7 +538,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
|
|||||||
|
|
||||||
this.syncedDoc &&
|
this.syncedDoc &&
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.syncedDoc.slots.blockUpdated.on(() => {
|
this.syncedDoc.slots.blockUpdated.subscribe(() => {
|
||||||
this._isEmptySyncedDoc = isEmptyDoc(this.syncedDoc, this.editorMode);
|
this._isEmptySyncedDoc = isEmptyDoc(this.syncedDoc, this.editorMode);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ export class EmbedYoutubeBlockComponent extends EmbedBlockComponent<
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.model.propsUpdated.on(({ key }) => {
|
this.model.propsUpdated.subscribe(({ key }) => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
if (key === 'url') {
|
if (key === 'url') {
|
||||||
this.refreshData();
|
this.refreshData();
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
"@types/mdast": "^4.0.4",
|
"@types/mdast": "^4.0.4",
|
||||||
"lit": "^3.2.0",
|
"lit": "^3.2.0",
|
||||||
"minimatch": "^10.0.1",
|
"minimatch": "^10.0.1",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"yjs": "^13.6.21",
|
"yjs": "^13.6.21",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ export class FrameBlockComponent extends GfxBlockComponent<FrameBlockModel> {
|
|||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
|
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.doc.slots.blockUpdated.on(({ type, id }) => {
|
this.doc.slots.blockUpdated.subscribe(({ type, id }) => {
|
||||||
if (id === this.model.id && type === 'update') {
|
if (id === this.model.id && type === 'update') {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.gfx.viewport.viewportUpdated.on(() => {
|
this.gfx.viewport.viewportUpdated.subscribe(() => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
isGfxGroupCompatibleModel,
|
isGfxGroupCompatibleModel,
|
||||||
renderableInEdgeless,
|
renderableInEdgeless,
|
||||||
} from '@blocksuite/block-std/gfx';
|
} from '@blocksuite/block-std/gfx';
|
||||||
|
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||||
import {
|
import {
|
||||||
Bound,
|
Bound,
|
||||||
@@ -20,7 +21,6 @@ import {
|
|||||||
type IVec,
|
type IVec,
|
||||||
type SerializedXYWH,
|
type SerializedXYWH,
|
||||||
} from '@blocksuite/global/gfx';
|
} from '@blocksuite/global/gfx';
|
||||||
import { DisposableGroup } from '@blocksuite/global/slot';
|
|
||||||
import { type BlockModel, Text } from '@blocksuite/store';
|
import { type BlockModel, Text } from '@blocksuite/store';
|
||||||
import * as Y from 'yjs';
|
import * as Y from 'yjs';
|
||||||
|
|
||||||
@@ -98,11 +98,12 @@ export class FrameOverlay extends Overlay {
|
|||||||
if (highlightOutline) this._frame = frame;
|
if (highlightOutline) this._frame = frame;
|
||||||
if (highlightElementsInBound) this._innerElements = innerElements;
|
if (highlightElementsInBound) this._innerElements = innerElements;
|
||||||
|
|
||||||
this._disposable.add(
|
const subscription = frame.deleted.subscribe(() => {
|
||||||
frame.deleted.once(() => {
|
subscription.unsubscribe();
|
||||||
this.clear();
|
this.clear();
|
||||||
})
|
});
|
||||||
);
|
|
||||||
|
this._disposable.add(subscription);
|
||||||
this._renderer?.refresh();
|
this._renderer?.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,7 +224,7 @@ export class EdgelessFrameManager extends GfxExtension {
|
|||||||
const { surface: surfaceModel, doc } = this.gfx;
|
const { surface: surfaceModel, doc } = this.gfx;
|
||||||
|
|
||||||
this._disposable.add(
|
this._disposable.add(
|
||||||
surfaceModel.elementAdded.on(({ id, local }) => {
|
surfaceModel.elementAdded.subscribe(({ id, local }) => {
|
||||||
const element = surfaceModel.getElementById(id);
|
const element = surfaceModel.getElementById(id);
|
||||||
if (element && local) {
|
if (element && local) {
|
||||||
const frame = this.getFrameFromPoint(element.elementBound.center);
|
const frame = this.getFrameFromPoint(element.elementBound.center);
|
||||||
@@ -249,7 +250,7 @@ export class EdgelessFrameManager extends GfxExtension {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this._disposable.add(
|
this._disposable.add(
|
||||||
doc.slots.blockUpdated.on(payload => {
|
doc.slots.blockUpdated.subscribe(payload => {
|
||||||
if (
|
if (
|
||||||
payload.type === 'add' &&
|
payload.type === 'add' &&
|
||||||
payload.model instanceof GfxBlockElementModel &&
|
payload.model instanceof GfxBlockElementModel &&
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
"file-type": "^20.0.0",
|
"file-type": "^20.0.0",
|
||||||
"lit": "^3.2.0",
|
"lit": "^3.2.0",
|
||||||
"minimatch": "^10.0.1",
|
"minimatch": "^10.0.1",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ export class ImageBlockPageComponent extends WithDisposable(ShadowlessElement) {
|
|||||||
private _handleSelection() {
|
private _handleSelection() {
|
||||||
const selection = this._host.selection;
|
const selection = this._host.selection;
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
selection.slots.changed.on(selList => {
|
selection.slots.changed.subscribe(selList => {
|
||||||
this._isSelected = selList.some(
|
this._isSelected = selList.some(
|
||||||
sel => sel.blockId === this.block.blockId && sel.is(ImageSelection)
|
sel => sel.blockId === this.block.blockId && sel.is(ImageSelection)
|
||||||
);
|
);
|
||||||
@@ -199,7 +199,7 @@ export class ImageBlockPageComponent extends WithDisposable(ShadowlessElement) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this._model.propsUpdated.on(() => {
|
this._model.propsUpdated.subscribe(() => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export class ImageBlockComponent extends CaptionedBlockComponent<ImageBlockModel
|
|||||||
this.refreshData();
|
this.refreshData();
|
||||||
this.contentEditable = 'false';
|
this.contentEditable = 'false';
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.model.propsUpdated.on(({ key }) => {
|
this.model.propsUpdated.subscribe(({ key }) => {
|
||||||
if (key === 'sourceId') {
|
if (key === 'sourceId') {
|
||||||
this.refreshData();
|
this.refreshData();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export class ImageEdgelessBlockComponent extends GfxBlockComponent<ImageBlockMod
|
|||||||
this.refreshData();
|
this.refreshData();
|
||||||
this.contentEditable = 'false';
|
this.contentEditable = 'false';
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.model.propsUpdated.on(({ key }) => {
|
this.model.propsUpdated.subscribe(({ key }) => {
|
||||||
if (key === 'sourceId') {
|
if (key === 'sourceId') {
|
||||||
this.refreshData();
|
this.refreshData();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
"lit": "^3.2.0",
|
"lit": "^3.2.0",
|
||||||
"minimatch": "^10.0.1",
|
"minimatch": "^10.0.1",
|
||||||
"remark-math": "^6.0.0",
|
"remark-math": "^6.0.0",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
"@types/mdast": "^4.0.4",
|
"@types/mdast": "^4.0.4",
|
||||||
"lit": "^3.2.0",
|
"lit": "^3.2.0",
|
||||||
"minimatch": "^10.0.1",
|
"minimatch": "^10.0.1",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
"@vanilla-extract/css": "^1.17.0",
|
"@vanilla-extract/css": "^1.17.0",
|
||||||
"lit": "^3.2.0",
|
"lit": "^3.2.0",
|
||||||
"minimatch": "^10.0.1",
|
"minimatch": "^10.0.1",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ export class EdgelessNoteBlockComponent extends toGfxBlockComponent(
|
|||||||
|
|
||||||
this._editing = selection.has(this.model.id) && selection.editing;
|
this._editing = selection.has(this.model.id) && selection.editing;
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
selection.slots.updated.on(() => {
|
selection.slots.updated.subscribe(() => {
|
||||||
if (selection.has(this.model.id) && selection.editing) {
|
if (selection.has(this.model.id) && selection.editing) {
|
||||||
this._editing = true;
|
this._editing = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -147,7 +147,7 @@ export class EdgelessNoteBlockComponent extends toGfxBlockComponent(
|
|||||||
const selection = this.gfx.selection;
|
const selection = this.gfx.selection;
|
||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
this.edgelessSlots.elementResizeStart.on(() => {
|
this.edgelessSlots.elementResizeStart.subscribe(() => {
|
||||||
if (selection.selectedElements.includes(this.model)) {
|
if (selection.selectedElements.includes(this.model)) {
|
||||||
this._isResizing = true;
|
this._isResizing = true;
|
||||||
}
|
}
|
||||||
@@ -155,7 +155,7 @@ export class EdgelessNoteBlockComponent extends toGfxBlockComponent(
|
|||||||
);
|
);
|
||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
this.edgelessSlots.elementResizeEnd.on(() => {
|
this.edgelessSlots.elementResizeEnd.subscribe(() => {
|
||||||
this._isResizing = false;
|
this._isResizing = false;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
"@types/mdast": "^4.0.4",
|
"@types/mdast": "^4.0.4",
|
||||||
"lit": "^3.2.0",
|
"lit": "^3.2.0",
|
||||||
"minimatch": "^10.0.1",
|
"minimatch": "^10.0.1",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -60,6 +60,7 @@
|
|||||||
"lit": "^3.2.0",
|
"lit": "^3.2.0",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"minimatch": "^10.0.1",
|
"minimatch": "^10.0.1",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"simple-xml-to-json": "^1.2.2",
|
"simple-xml-to-json": "^1.2.2",
|
||||||
"yjs": "^13.6.21",
|
"yjs": "^13.6.21",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
retainFirstModelCommand,
|
retainFirstModelCommand,
|
||||||
} from '@blocksuite/affine-shared/commands';
|
} from '@blocksuite/affine-shared/commands';
|
||||||
import type { UIEventHandler } from '@blocksuite/block-std';
|
import type { UIEventHandler } from '@blocksuite/block-std';
|
||||||
import { DisposableGroup } from '@blocksuite/global/slot';
|
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||||
import type { BlockSnapshot, Store } from '@blocksuite/store';
|
import type { BlockSnapshot, Store } from '@blocksuite/store';
|
||||||
|
|
||||||
import { ReadOnlyClipboard } from './readonly-clipboard';
|
import { ReadOnlyClipboard } from './readonly-clipboard';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
getSelectedModelsCommand,
|
getSelectedModelsCommand,
|
||||||
} from '@blocksuite/affine-shared/commands';
|
} from '@blocksuite/affine-shared/commands';
|
||||||
import type { BlockComponent, UIEventHandler } from '@blocksuite/block-std';
|
import type { BlockComponent, UIEventHandler } from '@blocksuite/block-std';
|
||||||
import { DisposableGroup } from '@blocksuite/global/slot';
|
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||||
|
|
||||||
import { ClipboardAdapter } from './adapter.js';
|
import { ClipboardAdapter } from './adapter.js';
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import {
|
|||||||
type SerializedElement,
|
type SerializedElement,
|
||||||
SortOrder,
|
SortOrder,
|
||||||
} from '@blocksuite/block-std/gfx';
|
} from '@blocksuite/block-std/gfx';
|
||||||
|
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||||
import {
|
import {
|
||||||
Bound,
|
Bound,
|
||||||
@@ -57,7 +58,6 @@ import {
|
|||||||
type SerializedXYWH,
|
type SerializedXYWH,
|
||||||
Vec,
|
Vec,
|
||||||
} from '@blocksuite/global/gfx';
|
} from '@blocksuite/global/gfx';
|
||||||
import { DisposableGroup } from '@blocksuite/global/slot';
|
|
||||||
import { assertType } from '@blocksuite/global/utils';
|
import { assertType } from '@blocksuite/global/utils';
|
||||||
import {
|
import {
|
||||||
type BlockSnapshot,
|
type BlockSnapshot,
|
||||||
|
|||||||
+1
-1
@@ -568,7 +568,7 @@ export class EdgelessAutoCompletePanel extends WithDisposable(LitElement) {
|
|||||||
|
|
||||||
override firstUpdated() {
|
override firstUpdated() {
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.edgeless.service.viewport.viewportUpdated.on(() =>
|
this.edgeless.service.viewport.viewportUpdated.subscribe(() =>
|
||||||
this.requestUpdate()
|
this.requestUpdate()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
+2
-2
@@ -25,10 +25,10 @@ import {
|
|||||||
import { handleNativeRangeAtPoint } from '@blocksuite/affine-shared/utils';
|
import { handleNativeRangeAtPoint } from '@blocksuite/affine-shared/utils';
|
||||||
import { type BlockStdScope, stdContext } from '@blocksuite/block-std';
|
import { type BlockStdScope, stdContext } from '@blocksuite/block-std';
|
||||||
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
|
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
|
||||||
|
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||||
import type { Bound, IVec } from '@blocksuite/global/gfx';
|
import type { Bound, IVec } from '@blocksuite/global/gfx';
|
||||||
import { Vec } from '@blocksuite/global/gfx';
|
import { Vec } from '@blocksuite/global/gfx';
|
||||||
import { WithDisposable } from '@blocksuite/global/lit';
|
import { WithDisposable } from '@blocksuite/global/lit';
|
||||||
import { DisposableGroup } from '@blocksuite/global/slot';
|
|
||||||
import {
|
import {
|
||||||
ArrowUpBigIcon,
|
ArrowUpBigIcon,
|
||||||
PlusIcon,
|
PlusIcon,
|
||||||
@@ -670,7 +670,7 @@ export class EdgelessAutoComplete extends WithDisposable(LitElement) {
|
|||||||
const { _disposables, edgeless } = this;
|
const { _disposables, edgeless } = this;
|
||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
this.gfx.selection.slots.updated.on(() => {
|
this.gfx.selection.slots.updated.subscribe(() => {
|
||||||
this._autoCompleteOverlay.linePoints = [];
|
this._autoCompleteOverlay.linePoints = [];
|
||||||
this._autoCompleteOverlay.renderShape = null;
|
this._autoCompleteOverlay.renderShape = null;
|
||||||
})
|
})
|
||||||
|
|||||||
+5
-5
@@ -9,9 +9,9 @@ import {
|
|||||||
stdContext,
|
stdContext,
|
||||||
} from '@blocksuite/block-std';
|
} from '@blocksuite/block-std';
|
||||||
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
|
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
|
||||||
|
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||||
import { Vec } from '@blocksuite/global/gfx';
|
import { Vec } from '@blocksuite/global/gfx';
|
||||||
import { WithDisposable } from '@blocksuite/global/lit';
|
import { WithDisposable } from '@blocksuite/global/lit';
|
||||||
import { DisposableGroup } from '@blocksuite/global/slot';
|
|
||||||
import type { Store } from '@blocksuite/store';
|
import type { Store } from '@blocksuite/store';
|
||||||
import { consume } from '@lit/context';
|
import { consume } from '@lit/context';
|
||||||
import { css, html, LitElement } from 'lit';
|
import { css, html, LitElement } from 'lit';
|
||||||
@@ -63,11 +63,11 @@ export class EdgelessConnectorHandle extends WithDisposable(LitElement) {
|
|||||||
const edgeless = this.edgeless;
|
const edgeless = this.edgeless;
|
||||||
|
|
||||||
this._disposables.addFromEvent(this._startHandler, 'pointerdown', e => {
|
this._disposables.addFromEvent(this._startHandler, 'pointerdown', e => {
|
||||||
edgeless.slots.elementResizeStart.emit();
|
edgeless.slots.elementResizeStart.next();
|
||||||
this._capPointerDown(e, 'source');
|
this._capPointerDown(e, 'source');
|
||||||
});
|
});
|
||||||
this._disposables.addFromEvent(this._endHandler, 'pointerdown', e => {
|
this._disposables.addFromEvent(this._endHandler, 'pointerdown', e => {
|
||||||
edgeless.slots.elementResizeStart.emit();
|
edgeless.slots.elementResizeStart.next();
|
||||||
this._capPointerDown(e, 'target');
|
this._capPointerDown(e, 'target');
|
||||||
});
|
});
|
||||||
this._disposables.add(() => {
|
this._disposables.add(() => {
|
||||||
@@ -96,7 +96,7 @@ export class EdgelessConnectorHandle extends WithDisposable(LitElement) {
|
|||||||
_disposables.dispose();
|
_disposables.dispose();
|
||||||
this._disposables = new DisposableGroup();
|
this._disposables = new DisposableGroup();
|
||||||
this._bindEvent();
|
this._bindEvent();
|
||||||
edgeless.slots.elementResizeEnd.emit();
|
edgeless.slots.elementResizeEnd.next();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ export class EdgelessConnectorHandle extends WithDisposable(LitElement) {
|
|||||||
const { viewport } = edgeless.service;
|
const { viewport } = edgeless.service;
|
||||||
|
|
||||||
this._lastZoom = viewport.zoom;
|
this._lastZoom = viewport.zoom;
|
||||||
edgeless.service.viewport.viewportUpdated.on(() => {
|
edgeless.service.viewport.viewportUpdated.subscribe(() => {
|
||||||
if (viewport.zoom !== this._lastZoom) {
|
if (viewport.zoom !== this._lastZoom) {
|
||||||
this._lastZoom = viewport.zoom;
|
this._lastZoom = viewport.zoom;
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import { TelemetryProvider } from '@blocksuite/affine-shared/services';
|
|||||||
import { getRectByBlockComponent } from '@blocksuite/affine-shared/utils';
|
import { getRectByBlockComponent } 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 { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
|
||||||
|
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||||
import { deserializeXYWH, Point, serializeXYWH } from '@blocksuite/global/gfx';
|
import { deserializeXYWH, Point, serializeXYWH } from '@blocksuite/global/gfx';
|
||||||
import { DisposableGroup } from '@blocksuite/global/slot';
|
|
||||||
import { ScissorsIcon } from '@blocksuite/icons/lit';
|
import { ScissorsIcon } from '@blocksuite/icons/lit';
|
||||||
import { css, html, nothing, type PropertyValues } from 'lit';
|
import { css, html, nothing, type PropertyValues } from 'lit';
|
||||||
import { state } from 'lit/decorators.js';
|
import { state } from 'lit/decorators.js';
|
||||||
@@ -267,13 +267,13 @@ export class NoteSlicer extends WidgetComponent<
|
|||||||
this._updateDivingLineAndBlockIds();
|
this._updateDivingLineAndBlockIds();
|
||||||
|
|
||||||
disposables.add(
|
disposables.add(
|
||||||
block.slots.elementResizeStart.on(() => {
|
block.slots.elementResizeStart.subscribe(() => {
|
||||||
this._isResizing = true;
|
this._isResizing = true;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
disposables.add(
|
disposables.add(
|
||||||
block.slots.elementResizeEnd.on(() => {
|
block.slots.elementResizeEnd.subscribe(() => {
|
||||||
this._isResizing = false;
|
this._isResizing = false;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -289,14 +289,14 @@ export class NoteSlicer extends WidgetComponent<
|
|||||||
);
|
);
|
||||||
|
|
||||||
disposables.add(
|
disposables.add(
|
||||||
gfx.viewport.viewportUpdated.on(() => {
|
gfx.viewport.viewportUpdated.subscribe(() => {
|
||||||
this._hidden = true;
|
this._hidden = true;
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
disposables.add(
|
disposables.add(
|
||||||
gfx.selection.slots.updated.on(() => {
|
gfx.selection.slots.updated.subscribe(() => {
|
||||||
this._enableNoteSlicer = false;
|
this._enableNoteSlicer = false;
|
||||||
this._updateSlicedNote();
|
this._updateSlicedNote();
|
||||||
|
|
||||||
@@ -307,7 +307,7 @@ export class NoteSlicer extends WidgetComponent<
|
|||||||
);
|
);
|
||||||
|
|
||||||
disposables.add(
|
disposables.add(
|
||||||
block.slots.toggleNoteSlicer.on(() => {
|
block.slots.toggleNoteSlicer.subscribe(() => {
|
||||||
this._enableNoteSlicer = !this._enableNoteSlicer;
|
this._enableNoteSlicer = !this._enableNoteSlicer;
|
||||||
|
|
||||||
if (this.selectedRectEle && this._enableNoteSlicer) {
|
if (this.selectedRectEle && this._enableNoteSlicer) {
|
||||||
@@ -411,7 +411,7 @@ export class NoteSlicer extends WidgetComponent<
|
|||||||
if (this._anchorNote) {
|
if (this._anchorNote) {
|
||||||
this._noteDisposables = new DisposableGroup();
|
this._noteDisposables = new DisposableGroup();
|
||||||
this._noteDisposables.add(
|
this._noteDisposables.add(
|
||||||
this._anchorNote.propsUpdated.on(({ key }) => {
|
this._anchorNote.propsUpdated.subscribe(({ key }) => {
|
||||||
if (key === 'children' || key === 'xywh') {
|
if (key === 'children' || key === 'xywh') {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { ShapeStyle } from '@blocksuite/affine-model';
|
import { ShapeStyle } from '@blocksuite/affine-model';
|
||||||
import { Slot } from '@blocksuite/global/slot';
|
|
||||||
import { css, html, LitElement } from 'lit';
|
import { css, html, LitElement } from 'lit';
|
||||||
import { property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
import type { ShapeTool } from '../../gfx-tool/shape-tool.js';
|
import type { ShapeTool } from '../../gfx-tool/shape-tool.js';
|
||||||
import { ShapeComponentConfig } from '../toolbar/shape/shape-menu-config.js';
|
import { ShapeComponentConfig } from '../toolbar/shape/shape-menu-config.js';
|
||||||
@@ -18,16 +18,16 @@ export class EdgelessShapePanel extends LitElement {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
slots = {
|
slots = {
|
||||||
select: new Slot<ShapeTool['activatedOption']['shapeName']>(),
|
select: new Subject<ShapeTool['activatedOption']['shapeName']>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
private _onSelect(value: ShapeTool['activatedOption']['shapeName']) {
|
private _onSelect(value: ShapeTool['activatedOption']['shapeName']) {
|
||||||
this.selectedShape = value;
|
this.selectedShape = value;
|
||||||
this.slots.select.emit(value);
|
this.slots.select.next(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
override disconnectedCallback(): void {
|
override disconnectedCallback(): void {
|
||||||
this.slots.select.dispose();
|
this.slots.select.complete();
|
||||||
super.disconnectedCallback();
|
super.disconnectedCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+30
-28
@@ -55,13 +55,13 @@ import {
|
|||||||
deserializeXYWH,
|
deserializeXYWH,
|
||||||
normalizeDegAngle,
|
normalizeDegAngle,
|
||||||
} from '@blocksuite/global/gfx';
|
} from '@blocksuite/global/gfx';
|
||||||
import { type Disposable, Slot } from '@blocksuite/global/slot';
|
|
||||||
import { assertType } from '@blocksuite/global/utils';
|
import { assertType } from '@blocksuite/global/utils';
|
||||||
import { css, html, nothing } from 'lit';
|
import { css, html, nothing } from 'lit';
|
||||||
import { state } from 'lit/decorators.js';
|
import { state } from 'lit/decorators.js';
|
||||||
import { ifDefined } from 'lit/directives/if-defined.js';
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
import clamp from 'lodash-es/clamp';
|
import clamp from 'lodash-es/clamp';
|
||||||
|
import { Subject, type Subscription } from 'rxjs';
|
||||||
|
|
||||||
import type { EdgelessRootBlockComponent } from '../../edgeless-root-block.js';
|
import type { EdgelessRootBlockComponent } from '../../edgeless-root-block.js';
|
||||||
import {
|
import {
|
||||||
@@ -447,13 +447,13 @@ export class EdgelessSelectedRectWidget extends WidgetComponent<
|
|||||||
private _dragEndCallback: (() => void)[] = [];
|
private _dragEndCallback: (() => void)[] = [];
|
||||||
|
|
||||||
private readonly _initSelectedSlot = () => {
|
private readonly _initSelectedSlot = () => {
|
||||||
this._propDisposables.forEach(disposable => disposable.dispose());
|
this._propDisposables.forEach(disposable => disposable.unsubscribe());
|
||||||
this._propDisposables = [];
|
this._propDisposables = [];
|
||||||
|
|
||||||
this.selection.selectedElements.forEach(element => {
|
this.selection.selectedElements.forEach(element => {
|
||||||
if ('flavour' in element) {
|
if ('flavour' in element) {
|
||||||
this._propDisposables.push(
|
this._propDisposables.push(
|
||||||
element.propsUpdated.on(() => {
|
element.propsUpdated.subscribe(() => {
|
||||||
this._updateOnElementChange(element.id);
|
this._updateOnElementChange(element.id);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -462,7 +462,7 @@ export class EdgelessSelectedRectWidget extends WidgetComponent<
|
|||||||
};
|
};
|
||||||
|
|
||||||
private readonly _onDragEnd = () => {
|
private readonly _onDragEnd = () => {
|
||||||
this.slots.dragEnd.emit();
|
this.slots.dragEnd.next();
|
||||||
|
|
||||||
this.doc.transact(() => {
|
this.doc.transact(() => {
|
||||||
this._dragEndCallback.forEach(cb => cb());
|
this._dragEndCallback.forEach(cb => cb());
|
||||||
@@ -478,7 +478,7 @@ export class EdgelessSelectedRectWidget extends WidgetComponent<
|
|||||||
this._scaleDirection = undefined;
|
this._scaleDirection = undefined;
|
||||||
this._updateMode();
|
this._updateMode();
|
||||||
|
|
||||||
this.block.slots.elementResizeEnd.emit();
|
this.block.slots.elementResizeEnd.next();
|
||||||
|
|
||||||
this.frameOverlay.clear();
|
this.frameOverlay.clear();
|
||||||
};
|
};
|
||||||
@@ -494,7 +494,7 @@ export class EdgelessSelectedRectWidget extends WidgetComponent<
|
|||||||
>,
|
>,
|
||||||
direction: HandleDirection
|
direction: HandleDirection
|
||||||
) => {
|
) => {
|
||||||
this.slots.dragMove.emit();
|
this.slots.dragMove.next();
|
||||||
|
|
||||||
const { gfx } = this;
|
const { gfx } = this;
|
||||||
|
|
||||||
@@ -557,7 +557,7 @@ export class EdgelessSelectedRectWidget extends WidgetComponent<
|
|||||||
};
|
};
|
||||||
|
|
||||||
private readonly _onDragRotate = (center: IPoint, delta: number) => {
|
private readonly _onDragRotate = (center: IPoint, delta: number) => {
|
||||||
this.slots.dragRotate.emit();
|
this.slots.dragRotate.next();
|
||||||
|
|
||||||
const { selection } = this;
|
const { selection } = this;
|
||||||
const m = new DOMMatrix()
|
const m = new DOMMatrix()
|
||||||
@@ -602,12 +602,12 @@ export class EdgelessSelectedRectWidget extends WidgetComponent<
|
|||||||
};
|
};
|
||||||
|
|
||||||
private readonly _onDragStart = () => {
|
private readonly _onDragStart = () => {
|
||||||
this.slots.dragStart.emit();
|
this.slots.dragStart.next();
|
||||||
|
|
||||||
const rotation = this._resizeManager.rotation;
|
const rotation = this._resizeManager.rotation;
|
||||||
|
|
||||||
this._dragEndCallback = [];
|
this._dragEndCallback = [];
|
||||||
this.block.slots.elementResizeStart.emit();
|
this.block.slots.elementResizeStart.next();
|
||||||
this.selection.selectedElements.forEach(el => {
|
this.selection.selectedElements.forEach(el => {
|
||||||
el.stash('xywh');
|
el.stash('xywh');
|
||||||
|
|
||||||
@@ -644,7 +644,7 @@ export class EdgelessSelectedRectWidget extends WidgetComponent<
|
|||||||
this._updateResizeManagerState(true);
|
this._updateResizeManagerState(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
private _propDisposables: Disposable[] = [];
|
private _propDisposables: Subscription[] = [];
|
||||||
|
|
||||||
private readonly _resizeManager: HandleResizeManager;
|
private readonly _resizeManager: HandleResizeManager;
|
||||||
|
|
||||||
@@ -836,10 +836,10 @@ export class EdgelessSelectedRectWidget extends WidgetComponent<
|
|||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
readonly slots = {
|
readonly slots = {
|
||||||
dragStart: new Slot(),
|
dragStart: new Subject<void>(),
|
||||||
dragMove: new Slot(),
|
dragMove: new Subject<void>(),
|
||||||
dragRotate: new Slot(),
|
dragRotate: new Subject<void>(),
|
||||||
dragEnd: new Slot(),
|
dragEnd: new Subject<void>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
get dragDirection() {
|
get dragDirection() {
|
||||||
@@ -1307,39 +1307,41 @@ export class EdgelessSelectedRectWidget extends WidgetComponent<
|
|||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
// viewport zooming / scrolling
|
// viewport zooming / scrolling
|
||||||
gfx.viewport.viewportUpdated.on(this._updateOnViewportChange)
|
gfx.viewport.viewportUpdated.subscribe(this._updateOnViewportChange)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (gfx.surface) {
|
if (gfx.surface) {
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
gfx.surface.elementAdded.on(this._updateOnElementChange)
|
gfx.surface.elementAdded.subscribe(this._updateOnElementChange)
|
||||||
);
|
);
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
gfx.surface.elementRemoved.on(this._updateOnElementChange)
|
gfx.surface.elementRemoved.subscribe(this._updateOnElementChange)
|
||||||
);
|
);
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
gfx.surface.elementUpdated.on(this._updateOnElementChange)
|
gfx.surface.elementUpdated.subscribe(this._updateOnElementChange)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
this.doc.slots.blockUpdated.on(this._updateOnElementChange)
|
this.doc.slots.blockUpdated.subscribe(this._updateOnElementChange)
|
||||||
);
|
|
||||||
|
|
||||||
_disposables.add(selection.slots.updated.on(this._updateOnSelectionChange));
|
|
||||||
|
|
||||||
_disposables.add(
|
|
||||||
block.slots.readonlyUpdated.on(() => this.requestUpdate())
|
|
||||||
);
|
);
|
||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
block.slots.elementResizeStart.on(() => (this._isResizing = true))
|
selection.slots.updated.subscribe(this._updateOnSelectionChange)
|
||||||
|
);
|
||||||
|
|
||||||
|
_disposables.add(
|
||||||
|
block.slots.readonlyUpdated.subscribe(() => this.requestUpdate())
|
||||||
|
);
|
||||||
|
|
||||||
|
_disposables.add(
|
||||||
|
block.slots.elementResizeStart.subscribe(() => (this._isResizing = true))
|
||||||
);
|
);
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
block.slots.elementResizeEnd.on(() => (this._isResizing = false))
|
block.slots.elementResizeEnd.subscribe(() => (this._isResizing = false))
|
||||||
);
|
);
|
||||||
_disposables.add(() => {
|
_disposables.add(() => {
|
||||||
this._propDisposables.forEach(disposable => disposable.dispose());
|
this._propDisposables.forEach(disposable => disposable.unsubscribe());
|
||||||
});
|
});
|
||||||
|
|
||||||
this.block.handleEvent(
|
this.block.handleEvent(
|
||||||
|
|||||||
+3
-3
@@ -127,7 +127,7 @@ export class EdgelessConnectorLabelEditor extends WithDisposable(
|
|||||||
if (!this.inlineEditor) return;
|
if (!this.inlineEditor) return;
|
||||||
this.inlineEditor.selectAll();
|
this.inlineEditor.selectAll();
|
||||||
|
|
||||||
this.inlineEditor.slots.renderComplete.on(() => {
|
this.inlineEditor.slots.renderComplete.subscribe(() => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -153,13 +153,13 @@ export class EdgelessConnectorLabelEditor extends WithDisposable(
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
edgeless.service.surface.elementUpdated.on(({ id }) => {
|
edgeless.service.surface.elementUpdated.subscribe(({ id }) => {
|
||||||
if (id === connector.id) this.requestUpdate();
|
if (id === connector.id) this.requestUpdate();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
edgeless.service.viewport.viewportUpdated.on(() => {
|
edgeless.service.viewport.viewportUpdated.subscribe(() => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
+2
-2
@@ -69,7 +69,7 @@ export class EdgelessFrameTitleEditor extends WithDisposable(
|
|||||||
|
|
||||||
this.inlineEditor.selectAll();
|
this.inlineEditor.selectAll();
|
||||||
|
|
||||||
this.inlineEditor.slots.renderComplete.on(() => {
|
this.inlineEditor.slots.renderComplete.subscribe(() => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ export class EdgelessFrameTitleEditor extends WithDisposable(
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.edgeless.service.viewport.viewportUpdated.on(() => {
|
this.edgeless.service.viewport.viewportUpdated.subscribe(() => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
+2
-2
@@ -54,7 +54,7 @@ export class EdgelessGroupTitleEditor extends WithDisposable(
|
|||||||
|
|
||||||
this.group.showTitle = false;
|
this.group.showTitle = false;
|
||||||
|
|
||||||
this.inlineEditor.slots.renderComplete.on(() => {
|
this.inlineEditor.slots.renderComplete.subscribe(() => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ export class EdgelessGroupTitleEditor extends WithDisposable(
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.edgeless.service.viewport.viewportUpdated.on(() => {
|
this.edgeless.service.viewport.viewportUpdated.subscribe(() => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
+2
-2
@@ -178,7 +178,7 @@ export class EdgelessShapeTextEditor extends WithDisposable(ShadowlessElement) {
|
|||||||
this.element.textDisplay = false;
|
this.element.textDisplay = false;
|
||||||
|
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.edgeless.service.viewport.viewportUpdated.on(() => {
|
this.edgeless.service.viewport.viewportUpdated.subscribe(() => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
this.updateComplete
|
this.updateComplete
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -208,7 +208,7 @@ export class EdgelessShapeTextEditor extends WithDisposable(ShadowlessElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.inlineEditor.slots.renderComplete.on(() => {
|
this.inlineEditor.slots.renderComplete.subscribe(() => {
|
||||||
this._updateElementWH();
|
this._updateElementWH();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-1
@@ -386,7 +386,7 @@ export class EdgelessDraggableElementController<T>
|
|||||||
|
|
||||||
hostConnected() {
|
hostConnected() {
|
||||||
this.host.disposables.add(
|
this.host.disposables.add(
|
||||||
this.options.service.viewport.viewportUpdated.on(({ zoom }) => {
|
this.options.service.viewport.viewportUpdated.subscribe(({ zoom }) => {
|
||||||
this._updateOverlayScale(zoom);
|
this._updateOverlayScale(zoom);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-1
@@ -121,7 +121,7 @@ export class EdgelessSlideMenu extends WithDisposable(LitElement) {
|
|||||||
this._toggleSlideButton();
|
this._toggleSlideButton();
|
||||||
});
|
});
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.toolbarSlots.resize.on(() => this._toggleSlideButton())
|
this.toolbarSlots.resize.subscribe(() => this._toggleSlideButton())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import type { ColorScheme } from '@blocksuite/affine-model';
|
import type { ColorScheme } from '@blocksuite/affine-model';
|
||||||
import type { Slot } from '@blocksuite/global/slot';
|
|
||||||
import { createContext } from '@lit/context';
|
import { createContext } from '@lit/context';
|
||||||
|
import type { Subject } from 'rxjs';
|
||||||
|
|
||||||
import type { EdgelessToolbarWidget } from './edgeless-toolbar.js';
|
import type { EdgelessToolbarWidget } from './edgeless-toolbar.js';
|
||||||
|
|
||||||
export interface EdgelessToolbarSlots {
|
export interface EdgelessToolbarSlots {
|
||||||
resize: Slot<{ w: number; h: number }>;
|
resize: Subject<{ w: number; h: number }>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const edgelessToolbarSlotsContext = createContext<EdgelessToolbarSlots>(
|
export const edgelessToolbarSlotsContext = createContext<EdgelessToolbarSlots>(
|
||||||
|
|||||||
+7
-7
@@ -16,7 +16,6 @@ import {
|
|||||||
import { stopPropagation } from '@blocksuite/affine-shared/utils';
|
import { stopPropagation } 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 { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
|
||||||
import { Slot } from '@blocksuite/global/slot';
|
|
||||||
import {
|
import {
|
||||||
ArrowLeftSmallIcon,
|
ArrowLeftSmallIcon,
|
||||||
ArrowRightSmallIcon,
|
ArrowRightSmallIcon,
|
||||||
@@ -30,6 +29,7 @@ import { css, html, nothing, unsafeCSS } from 'lit';
|
|||||||
import { query, state } from 'lit/decorators.js';
|
import { query, state } from 'lit/decorators.js';
|
||||||
import { cache } from 'lit/directives/cache.js';
|
import { cache } from 'lit/directives/cache.js';
|
||||||
import debounce from 'lodash-es/debounce';
|
import debounce from 'lodash-es/debounce';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
import type { EdgelessRootBlockComponent } from '../../edgeless-root-block.js';
|
import type { EdgelessRootBlockComponent } from '../../edgeless-root-block.js';
|
||||||
import type { MenuPopper } from './common/create-popper.js';
|
import type { MenuPopper } from './common/create-popper.js';
|
||||||
@@ -238,7 +238,7 @@ export class EdgelessToolbarWidget extends WidgetComponent<
|
|||||||
({ w }: { w: number }) => {
|
({ w }: { w: number }) => {
|
||||||
if (!this.isConnected) return;
|
if (!this.isConnected) return;
|
||||||
|
|
||||||
this.slots.resize.emit({ w, h: TOOLBAR_HEIGHT });
|
this.slots.resize.next({ w, h: TOOLBAR_HEIGHT });
|
||||||
this.containerWidth = w;
|
this.containerWidth = w;
|
||||||
|
|
||||||
if (this._denseSeniorTools) {
|
if (this._denseSeniorTools) {
|
||||||
@@ -273,7 +273,7 @@ export class EdgelessToolbarWidget extends WidgetComponent<
|
|||||||
|
|
||||||
private readonly _slotsProvider = new ContextProvider(this, {
|
private readonly _slotsProvider = new ContextProvider(this, {
|
||||||
context: edgelessToolbarSlotsContext,
|
context: edgelessToolbarSlotsContext,
|
||||||
initialValue: { resize: new Slot() } satisfies EdgelessToolbarSlots,
|
initialValue: { resize: new Subject() } satisfies EdgelessToolbarSlots,
|
||||||
});
|
});
|
||||||
|
|
||||||
private readonly _themeProvider = new ContextProvider(this, {
|
private readonly _themeProvider = new ContextProvider(this, {
|
||||||
@@ -605,22 +605,22 @@ export class EdgelessToolbarWidget extends WidgetComponent<
|
|||||||
const { _disposables, block, gfx } = this;
|
const { _disposables, block, gfx } = this;
|
||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
gfx.viewport.viewportUpdated.on(() => this.requestUpdate())
|
gfx.viewport.viewportUpdated.subscribe(() => this.requestUpdate())
|
||||||
);
|
);
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
block.slots.readonlyUpdated.on(() => {
|
block.slots.readonlyUpdated.subscribe(() => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
block.slots.toolbarLocked.on(disabled => {
|
block.slots.toolbarLocked.subscribe(disabled => {
|
||||||
this.toggleAttribute('disabled', disabled);
|
this.toggleAttribute('disabled', disabled);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
// This state from `editPropsStore` is not reactive,
|
// This state from `editPropsStore` is not reactive,
|
||||||
// if the value is updated outside of this component, it will not be reflected.
|
// if the value is updated outside of this component, it will not be reflected.
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
this.std.get(EditPropsStore).slots.storageUpdated.on(({ key }) => {
|
this.std.get(EditPropsStore).slots.storageUpdated.subscribe(({ key }) => {
|
||||||
if (key === 'presentHideToolbar') {
|
if (key === 'presentHideToolbar') {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import { EdgelessCRUDIdentifier } from '@blocksuite/affine-block-surface';
|
import { EdgelessCRUDIdentifier } from '@blocksuite/affine-block-surface';
|
||||||
import { generateKeyBetweenV2 } from '@blocksuite/block-std/gfx';
|
import { generateKeyBetweenV2 } from '@blocksuite/block-std/gfx';
|
||||||
|
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||||
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
|
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
|
||||||
import { DisposableGroup } from '@blocksuite/global/slot';
|
|
||||||
import { css, html, LitElement, nothing } from 'lit';
|
import { css, html, LitElement, nothing } from 'lit';
|
||||||
import { property, query, state } from 'lit/decorators.js';
|
import { property, query, state } from 'lit/decorators.js';
|
||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
|
|||||||
+3
-3
@@ -73,7 +73,7 @@ export class EdgelessNavigatorSettingButton extends WithDisposable(LitElement) {
|
|||||||
|
|
||||||
private readonly _onBlackBackgroundChange = (checked: boolean) => {
|
private readonly _onBlackBackgroundChange = (checked: boolean) => {
|
||||||
this.blackBackground = checked;
|
this.blackBackground = checked;
|
||||||
this.edgeless.slots.navigatorSettingUpdated.emit({
|
this.edgeless.slots.navigatorSettingUpdated.next({
|
||||||
blackBackground: this.blackBackground,
|
blackBackground: this.blackBackground,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -134,7 +134,7 @@ export class EdgelessNavigatorSettingButton extends WithDisposable(LitElement) {
|
|||||||
<div class="text">Black background</div>
|
<div class="text">Black background</div>
|
||||||
|
|
||||||
<toggle-switch
|
<toggle-switch
|
||||||
.on=${this.blackBackground}
|
.subscribe=${this.blackBackground}
|
||||||
.onChange=${this._onBlackBackgroundChange}
|
.onChange=${this._onBlackBackgroundChange}
|
||||||
>
|
>
|
||||||
</toggle-switch>
|
</toggle-switch>
|
||||||
@@ -144,7 +144,7 @@ export class EdgelessNavigatorSettingButton extends WithDisposable(LitElement) {
|
|||||||
<div class="text">Hide toolbar</div>
|
<div class="text">Hide toolbar</div>
|
||||||
|
|
||||||
<toggle-switch
|
<toggle-switch
|
||||||
.on=${this.hideToolbar}
|
.subscribe=${this.hideToolbar}
|
||||||
.onChange=${(checked: boolean) => {
|
.onChange=${(checked: boolean) => {
|
||||||
this.onHideToolbarChange && this.onHideToolbarChange(checked);
|
this.onHideToolbarChange && this.onHideToolbarChange(checked);
|
||||||
}}
|
}}
|
||||||
|
|||||||
+3
-3
@@ -197,7 +197,7 @@ export class PresentationToolbar extends EdgelessToolbarToolMixin(
|
|||||||
}
|
}
|
||||||
|
|
||||||
viewport.setViewportByBound(bound, [0, 0, 0, 0], false);
|
viewport.setViewportByBound(bound, [0, 0, 0, 0], false);
|
||||||
this.edgeless.slots.navigatorFrameChanged.emit(
|
this.edgeless.slots.navigatorFrameChanged.next(
|
||||||
this._frames[this._currentFrameIndex]
|
this._frames[this._currentFrameIndex]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -278,7 +278,7 @@ export class PresentationToolbar extends EdgelessToolbarToolMixin(
|
|||||||
this._bindHotKey();
|
this._bindHotKey();
|
||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
edgeless.slots.navigatorSettingUpdated.on(({ fillScreen }) => {
|
edgeless.slots.navigatorSettingUpdated.subscribe(({ fillScreen }) => {
|
||||||
if (fillScreen !== undefined) {
|
if (fillScreen !== undefined) {
|
||||||
this._navigatorMode = fillScreen ? 'fill' : 'fit';
|
this._navigatorMode = fillScreen ? 'fill' : 'fit';
|
||||||
}
|
}
|
||||||
@@ -307,7 +307,7 @@ export class PresentationToolbar extends EdgelessToolbarToolMixin(
|
|||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => this._moveToCurrentFrame(), 400);
|
setTimeout(() => this._moveToCurrentFrame(), 400);
|
||||||
this.edgeless.slots.fullScreenToggled.emit();
|
this.edgeless.slots.fullScreenToggled.next();
|
||||||
});
|
});
|
||||||
|
|
||||||
this._navigatorMode =
|
this._navigatorMode =
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ import {
|
|||||||
once,
|
once,
|
||||||
requestConnectedFrame,
|
requestConnectedFrame,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import { DisposableGroup } from '@blocksuite/global/slot';
|
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||||
import { css, html, LitElement } from 'lit';
|
import { css, html, LitElement } from 'lit';
|
||||||
import { query } from 'lit/decorators.js';
|
import { query } from 'lit/decorators.js';
|
||||||
|
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ export class EdgelessPageKeyboardManager extends PageKeyboardManager {
|
|||||||
NoteBlockModel,
|
NoteBlockModel,
|
||||||
])
|
])
|
||||||
) {
|
) {
|
||||||
rootComponent.slots.toggleNoteSlicer.emit();
|
rootComponent.slots.toggleNoteSlicer.next();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
f: () => {
|
f: () => {
|
||||||
@@ -173,7 +173,7 @@ export class EdgelessPageKeyboardManager extends PageKeyboardManager {
|
|||||||
elements.length === 1 &&
|
elements.length === 1 &&
|
||||||
isNoteBlock(elements[0])
|
isNoteBlock(elements[0])
|
||||||
) {
|
) {
|
||||||
rootComponent.slots.toggleNoteSlicer.emit();
|
rootComponent.slots.toggleNoteSlicer.next();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'@': () => {
|
'@': () => {
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ export class EdgelessRootBlockComponent extends BlockComponent<
|
|||||||
});
|
});
|
||||||
|
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.gfx.layer.slots.layerUpdated.on(() => updateLayers())
|
this.gfx.layer.slots.layerUpdated.subscribe(() => updateLayers())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,7 +426,7 @@ export class EdgelessRootBlockComponent extends BlockComponent<
|
|||||||
const dy = simulateHorizontalScroll ? 0 : e.deltaY / viewport.zoom;
|
const dy = simulateHorizontalScroll ? 0 : e.deltaY / viewport.zoom;
|
||||||
|
|
||||||
viewport.applyDeltaCenter(dx, dy);
|
viewport.applyDeltaCenter(dx, dy);
|
||||||
viewport.viewportMoved.emit([dx, dy]);
|
viewport.viewportMoved.next([dx, dy]);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -520,14 +520,14 @@ export class EdgelessRootBlockComponent extends BlockComponent<
|
|||||||
this.gfx.tool.setTool('default');
|
this.gfx.tool.setTool('default');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.gfx.viewport.elementReady.emit(this.gfxViewportElm);
|
this.gfx.viewport.elementReady.next(this.gfxViewportElm);
|
||||||
|
|
||||||
requestConnectedFrame(() => {
|
requestConnectedFrame(() => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.gfx.viewport.viewportUpdated.on(() => {
|
this.gfx.viewport.viewportUpdated.subscribe(() => {
|
||||||
this._refreshLayerViewport();
|
this._refreshLayerViewport();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ export class EdgelessRootPreviewBlockComponent extends BlockComponent<
|
|||||||
});
|
});
|
||||||
|
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this._gfx.layer.slots.layerUpdated.on(() => updateLayers())
|
this._gfx.layer.slots.layerUpdated.subscribe(() => updateLayers())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ export class EdgelessRootPreviewBlockComponent extends BlockComponent<
|
|||||||
this._initLayerUpdateEffect();
|
this._initLayerUpdateEffect();
|
||||||
|
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this._gfx.viewport.viewportUpdated.on(() => {
|
this._gfx.viewport.viewportUpdated.subscribe(() => {
|
||||||
this._refreshLayerViewport();
|
this._refreshLayerViewport();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ export class EdgelessRootService extends RootService implements SurfaceContext {
|
|||||||
effect(() => {
|
effect(() => {
|
||||||
if (readonly !== doc.readonly) {
|
if (readonly !== doc.readonly) {
|
||||||
readonly = doc.readonly;
|
readonly = doc.readonly;
|
||||||
slots.readonlyUpdated.emit(readonly);
|
slots.readonlyUpdated.next(readonly);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ import {
|
|||||||
isGfxGroupCompatibleModel,
|
isGfxGroupCompatibleModel,
|
||||||
type PointTestOptions,
|
type PointTestOptions,
|
||||||
} from '@blocksuite/block-std/gfx';
|
} from '@blocksuite/block-std/gfx';
|
||||||
|
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||||
import type { IVec } from '@blocksuite/global/gfx';
|
import type { IVec } from '@blocksuite/global/gfx';
|
||||||
import { Bound, getCommonBoundWithRotation, Vec } from '@blocksuite/global/gfx';
|
import { Bound, getCommonBoundWithRotation, Vec } from '@blocksuite/global/gfx';
|
||||||
import { DisposableGroup } from '@blocksuite/global/slot';
|
|
||||||
import { noop } from '@blocksuite/global/utils';
|
import { noop } from '@blocksuite/global/utils';
|
||||||
import { effect } from '@preact/signals-core';
|
import { effect } from '@preact/signals-core';
|
||||||
import clamp from 'lodash-es/clamp';
|
import clamp from 'lodash-es/clamp';
|
||||||
@@ -598,7 +598,7 @@ export class DefaultTool extends BaseTool {
|
|||||||
// If the viewport updates when dragging, should update the dragging area and selection
|
// If the viewport updates when dragging, should update the dragging area and selection
|
||||||
if (this.dragType === DefaultModeDragType.Selecting) {
|
if (this.dragType === DefaultModeDragType.Selecting) {
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.gfx.viewport.viewportUpdated.on(() => {
|
this.gfx.viewport.viewportUpdated.subscribe(() => {
|
||||||
if (
|
if (
|
||||||
this.dragType === DefaultModeDragType.Selecting &&
|
this.dragType === DefaultModeDragType.Selecting &&
|
||||||
this.controller.dragging$.peek() &&
|
this.controller.dragging$.peek() &&
|
||||||
@@ -613,7 +613,7 @@ export class DefaultTool extends BaseTool {
|
|||||||
|
|
||||||
if (this.dragType === DefaultModeDragType.ContentMoving) {
|
if (this.dragType === DefaultModeDragType.ContentMoving) {
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.gfx.viewport.viewportMoved.on(delta => {
|
this.gfx.viewport.viewportMoved.subscribe(delta => {
|
||||||
if (
|
if (
|
||||||
this.dragType === DefaultModeDragType.ContentMoving &&
|
this.dragType === DefaultModeDragType.ContentMoving &&
|
||||||
this.controller.dragging$.peek() &&
|
this.controller.dragging$.peek() &&
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export class NoteTool extends BaseTool<NoteToolOption> {
|
|||||||
endY = startY + (endY > startY ? m : -m);
|
endY = startY + (endY > startY ? m : -m);
|
||||||
}
|
}
|
||||||
|
|
||||||
_draggingNoteOverlay.slots.draggingNoteUpdated.emit({
|
_draggingNoteOverlay.slots.draggingNoteUpdated.next({
|
||||||
xywh: [
|
xywh: [
|
||||||
Math.min(startX, endX),
|
Math.min(startX, endX),
|
||||||
Math.min(startY, endY),
|
Math.min(startY, endY),
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import type { SlotBlockPayload, TemplateJob } from './template.js';
|
|||||||
export const replaceIdMiddleware = (job: TemplateJob) => {
|
export const replaceIdMiddleware = (job: TemplateJob) => {
|
||||||
const regeneratedIdMap = new Map<string, string>();
|
const regeneratedIdMap = new Map<string, string>();
|
||||||
|
|
||||||
job.slots.beforeInsert.on(payload => {
|
job.slots.beforeInsert.subscribe(payload => {
|
||||||
switch (payload.type) {
|
switch (payload.type) {
|
||||||
case 'block':
|
case 'block':
|
||||||
regenerateBlockId(payload.data);
|
regenerateBlockId(payload.data);
|
||||||
@@ -134,7 +134,7 @@ export const createInsertPlaceMiddleware = (targetPlace: Bound) => {
|
|||||||
y: number;
|
y: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
job.slots.beforeInsert.on(blockData => {
|
job.slots.beforeInsert.subscribe(blockData => {
|
||||||
if (blockData.type === 'template') {
|
if (blockData.type === 'template') {
|
||||||
templateBound = blockData.bound;
|
templateBound = blockData.bound;
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ export const createStickerMiddleware = (
|
|||||||
getIndex: () => string
|
getIndex: () => string
|
||||||
) => {
|
) => {
|
||||||
return (job: TemplateJob) => {
|
return (job: TemplateJob) => {
|
||||||
job.slots.beforeInsert.on(blockData => {
|
job.slots.beforeInsert.subscribe(blockData => {
|
||||||
if (blockData.type === 'block') {
|
if (blockData.type === 'block') {
|
||||||
changeInserPosition(blockData.data.blockJson);
|
changeInserPosition(blockData.data.blockJson);
|
||||||
}
|
}
|
||||||
@@ -238,7 +238,7 @@ export const createRegenerateIndexMiddleware = (
|
|||||||
generateIndex: () => string
|
generateIndex: () => string
|
||||||
) => {
|
) => {
|
||||||
return (job: TemplateJob) => {
|
return (job: TemplateJob) => {
|
||||||
job.slots.beforeInsert.on(blockData => {
|
job.slots.beforeInsert.subscribe(blockData => {
|
||||||
if (blockData.type === 'template') {
|
if (blockData.type === 'template') {
|
||||||
generateIndexMap();
|
generateIndexMap();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import type {
|
|||||||
} from '@blocksuite/affine-block-surface';
|
} from '@blocksuite/affine-block-surface';
|
||||||
import type { ConnectorElementModel } from '@blocksuite/affine-model';
|
import type { ConnectorElementModel } from '@blocksuite/affine-model';
|
||||||
import { Bound, getCommonBound } from '@blocksuite/global/gfx';
|
import { Bound, getCommonBound } from '@blocksuite/global/gfx';
|
||||||
import { Slot } from '@blocksuite/global/slot';
|
|
||||||
import { assertType } from '@blocksuite/global/utils';
|
import { assertType } from '@blocksuite/global/utils';
|
||||||
import {
|
import {
|
||||||
type BlockModel,
|
type BlockModel,
|
||||||
@@ -14,6 +13,7 @@ import {
|
|||||||
type SnapshotNode,
|
type SnapshotNode,
|
||||||
type Transformer,
|
type Transformer,
|
||||||
} from '@blocksuite/store';
|
} from '@blocksuite/store';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
import type * as Y from 'yjs';
|
import type * as Y from 'yjs';
|
||||||
/**
|
/**
|
||||||
* Those block contains other block's id
|
* Those block contains other block's id
|
||||||
@@ -73,7 +73,7 @@ export class TemplateJob {
|
|||||||
model: SurfaceBlockModel;
|
model: SurfaceBlockModel;
|
||||||
|
|
||||||
slots = {
|
slots = {
|
||||||
beforeInsert: new Slot<
|
beforeInsert: new Subject<
|
||||||
| SlotBlockPayload
|
| SlotBlockPayload
|
||||||
| {
|
| {
|
||||||
type: 'template';
|
type: 'template';
|
||||||
@@ -255,7 +255,7 @@ export class TemplateJob {
|
|||||||
index,
|
index,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.slots.beforeInsert.emit({ type: 'block', data: slotData });
|
this.slots.beforeInsert.next({ type: 'block', data: slotData });
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* merge block should not be converted to model data
|
* merge block should not be converted to model data
|
||||||
@@ -340,7 +340,7 @@ export class TemplateJob {
|
|||||||
|
|
||||||
const templateBound = this._getTemplateBound();
|
const templateBound = this._getTemplateBound();
|
||||||
|
|
||||||
this.slots.beforeInsert.emit({
|
this.slots.beforeInsert.next({
|
||||||
type: 'template',
|
type: 'template',
|
||||||
template: template,
|
template: template,
|
||||||
bound: templateBound,
|
bound: templateBound,
|
||||||
|
|||||||
@@ -12,11 +12,12 @@ import {
|
|||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
import { ThemeProvider } from '@blocksuite/affine-shared/services';
|
import { ThemeProvider } from '@blocksuite/affine-shared/services';
|
||||||
import type { GfxController, GfxToolsMap } from '@blocksuite/block-std/gfx';
|
import type { GfxController, GfxToolsMap } from '@blocksuite/block-std/gfx';
|
||||||
|
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||||
import type { XYWH } from '@blocksuite/global/gfx';
|
import type { XYWH } from '@blocksuite/global/gfx';
|
||||||
import { Bound } from '@blocksuite/global/gfx';
|
import { Bound } from '@blocksuite/global/gfx';
|
||||||
import { DisposableGroup, Slot } from '@blocksuite/global/slot';
|
|
||||||
import { assertType, noop } from '@blocksuite/global/utils';
|
import { assertType, noop } from '@blocksuite/global/utils';
|
||||||
import { effect } from '@preact/signals-core';
|
import { effect } from '@preact/signals-core';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
import type { ShapeTool } from '../gfx-tool/shape-tool.js';
|
import type { ShapeTool } from '../gfx-tool/shape-tool.js';
|
||||||
import {
|
import {
|
||||||
@@ -237,7 +238,7 @@ class ToolOverlay extends Overlay {
|
|||||||
this.globalAlpha = 0;
|
this.globalAlpha = 0;
|
||||||
this.gfx = gfx;
|
this.gfx = gfx;
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.gfx.viewport.viewportUpdated.on(() => {
|
this.gfx.viewport.viewportUpdated.subscribe(() => {
|
||||||
// when viewport is updated, we should keep the overlay in the same position
|
// when viewport is updated, we should keep the overlay in the same position
|
||||||
// to get last mouse position and convert it to model coordinates
|
// to get last mouse position and convert it to model coordinates
|
||||||
const pos = this.gfx.tool.lastMousePos$.value;
|
const pos = this.gfx.tool.lastMousePos$.value;
|
||||||
@@ -444,7 +445,7 @@ export class DraggingNoteOverlay extends NoteOverlay {
|
|||||||
height: number;
|
height: number;
|
||||||
|
|
||||||
slots: {
|
slots: {
|
||||||
draggingNoteUpdated: Slot<{ xywh: XYWH }>;
|
draggingNoteUpdated: Subject<{ xywh: XYWH }>;
|
||||||
};
|
};
|
||||||
|
|
||||||
width: number;
|
width: number;
|
||||||
@@ -452,14 +453,14 @@ export class DraggingNoteOverlay extends NoteOverlay {
|
|||||||
constructor(gfx: GfxController, background: Color) {
|
constructor(gfx: GfxController, background: Color) {
|
||||||
super(gfx, background);
|
super(gfx, background);
|
||||||
this.slots = {
|
this.slots = {
|
||||||
draggingNoteUpdated: new Slot<{
|
draggingNoteUpdated: new Subject<{
|
||||||
xywh: XYWH;
|
xywh: XYWH;
|
||||||
}>(),
|
}>(),
|
||||||
};
|
};
|
||||||
this.width = 0;
|
this.width = 0;
|
||||||
this.height = 0;
|
this.height = 0;
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.slots.draggingNoteUpdated.on(({ xywh }) => {
|
this.slots.draggingNoteUpdated.subscribe(({ xywh }) => {
|
||||||
[this.x, this.y, this.width, this.height] = xywh;
|
[this.x, this.y, this.width, this.height] = xywh;
|
||||||
(this.gfx.surfaceComponent as SurfaceBlockComponent).refresh();
|
(this.gfx.surfaceComponent as SurfaceBlockComponent).refresh();
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ export class PageRootBlockComponent extends BlockComponent<
|
|||||||
(entries: ResizeObserverEntry[]) => {
|
(entries: ResizeObserverEntry[]) => {
|
||||||
for (const { target } of entries) {
|
for (const { target } of entries) {
|
||||||
if (target === viewportElement) {
|
if (target === viewportElement) {
|
||||||
viewportService.emit(viewport);
|
viewportService.next(viewport);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -416,7 +416,7 @@ export class PageRootBlockComponent extends BlockComponent<
|
|||||||
);
|
);
|
||||||
noteModels.forEach(note => {
|
noteModels.forEach(note => {
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
note.propsUpdated.on(({ key }) => {
|
note.propsUpdated.subscribe(({ key }) => {
|
||||||
if (key === 'displayMode') {
|
if (key === 'displayMode') {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,13 +42,13 @@ export class EdgelessNavigatorBlackBackgroundWidget extends WidgetComponent<Root
|
|||||||
override firstUpdated() {
|
override firstUpdated() {
|
||||||
const { _disposables, gfx } = this;
|
const { _disposables, gfx } = this;
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
this._slots.navigatorFrameChanged.on(frame => {
|
this._slots.navigatorFrameChanged.subscribe(frame => {
|
||||||
this.frame = frame;
|
this.frame = frame;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
this._slots.navigatorSettingUpdated.on(({ blackBackground }) => {
|
this._slots.navigatorSettingUpdated.subscribe(({ blackBackground }) => {
|
||||||
if (blackBackground !== undefined) {
|
if (blackBackground !== undefined) {
|
||||||
this.std
|
this.std
|
||||||
.get(EditPropsStore)
|
.get(EditPropsStore)
|
||||||
@@ -76,7 +76,7 @@ export class EdgelessNavigatorBlackBackgroundWidget extends WidgetComponent<Root
|
|||||||
);
|
);
|
||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
this._slots.fullScreenToggled.on(
|
this._slots.fullScreenToggled.subscribe(
|
||||||
() =>
|
() =>
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export class AffineEdgelessZoomToolbarWidget extends WidgetComponent<
|
|||||||
const slots = std.get(EdgelessLegacySlotIdentifier);
|
const slots = std.get(EdgelessLegacySlotIdentifier);
|
||||||
|
|
||||||
disposables.add(
|
disposables.add(
|
||||||
slots.navigatorSettingUpdated.on(({ hideToolbar }) => {
|
slots.navigatorSettingUpdated.subscribe(({ hideToolbar }) => {
|
||||||
if (hideToolbar !== undefined) {
|
if (hideToolbar !== undefined) {
|
||||||
this._hide = hideToolbar;
|
this._hide = hideToolbar;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -69,7 +69,7 @@ export class ZoomBarToggleButton extends WithDisposable(LitElement) {
|
|||||||
override firstUpdated() {
|
override firstUpdated() {
|
||||||
const { disposables } = this;
|
const { disposables } = this;
|
||||||
disposables.add(
|
disposables.add(
|
||||||
this.edgeless.slots.readonlyUpdated.on(() => {
|
this.edgeless.slots.readonlyUpdated.subscribe(() => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
+2
-2
@@ -130,12 +130,12 @@ export class EdgelessZoomToolbar extends WithDisposable(LitElement) {
|
|||||||
override firstUpdated() {
|
override firstUpdated() {
|
||||||
const { disposables } = this;
|
const { disposables } = this;
|
||||||
disposables.add(
|
disposables.add(
|
||||||
this.edgeless.service.viewport.viewportUpdated.on(() =>
|
this.edgeless.service.viewport.viewportUpdated.subscribe(() =>
|
||||||
this.requestUpdate()
|
this.requestUpdate()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
disposables.add(
|
disposables.add(
|
||||||
this.edgeless.slots.readonlyUpdated.on(() => {
|
this.edgeless.slots.readonlyUpdated.subscribe(() => {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ export class EdgelessAlignButton extends WithDisposable(LitElement) {
|
|||||||
|
|
||||||
override firstUpdated() {
|
override firstUpdated() {
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.edgeless.service.selection.slots.updated.on(() =>
|
this.edgeless.service.selection.slots.updated.subscribe(() =>
|
||||||
this.requestUpdate()
|
this.requestUpdate()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
+3
-3
@@ -159,7 +159,7 @@ export class EdgelessChangeNoteButton extends WithDisposable(LitElement) {
|
|||||||
const surfaceService = this.edgeless.service;
|
const surfaceService = this.edgeless.service;
|
||||||
if (!surfaceService) return;
|
if (!surfaceService) return;
|
||||||
|
|
||||||
this.edgeless.slots.toggleNoteSlicer.emit();
|
this.edgeless.slots.toggleNoteSlicer.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _setCollapse() {
|
private _setCollapse() {
|
||||||
@@ -201,7 +201,7 @@ export class EdgelessChangeNoteButton extends WithDisposable(LitElement) {
|
|||||||
const clear = () => {
|
const clear = () => {
|
||||||
this.doc.history.off('stack-item-added', addHandler);
|
this.doc.history.off('stack-item-added', addHandler);
|
||||||
this.doc.history.off('stack-item-popped', popHandler);
|
this.doc.history.off('stack-item-popped', popHandler);
|
||||||
disposable.dispose();
|
disposable.unsubscribe();
|
||||||
};
|
};
|
||||||
const closeNotify = () => {
|
const closeNotify = () => {
|
||||||
abortController.abort();
|
abortController.abort();
|
||||||
@@ -212,7 +212,7 @@ export class EdgelessChangeNoteButton extends WithDisposable(LitElement) {
|
|||||||
const popHandler = this.doc.history.on('stack-item-popped', closeNotify);
|
const popHandler = this.doc.history.on('stack-item-popped', closeNotify);
|
||||||
const disposable = this.edgeless.std
|
const disposable = this.edgeless.std
|
||||||
.get(EditorLifeCycleExtension)
|
.get(EditorLifeCycleExtension)
|
||||||
.slots.unmounted.on(closeNotify);
|
.slots.unmounted.subscribe(closeNotify);
|
||||||
|
|
||||||
const undo = () => {
|
const undo = () => {
|
||||||
this.doc.undo();
|
this.doc.undo();
|
||||||
|
|||||||
+1
-1
@@ -232,7 +232,7 @@ export class EdgelessChangeShapeButton extends WithDisposable(LitElement) {
|
|||||||
const _disposables = this._disposables;
|
const _disposables = this._disposables;
|
||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
this._shapePanel.slots.select.on(shapeName => {
|
this._shapePanel.slots.select.subscribe(shapeName => {
|
||||||
this.edgeless.doc.captureSync();
|
this.edgeless.doc.captureSync();
|
||||||
this.elements.forEach(element => {
|
this.elements.forEach(element => {
|
||||||
this.crud.updateElement(element.id, {
|
this.crud.updateElement(element.id, {
|
||||||
|
|||||||
@@ -361,13 +361,13 @@ export class EdgelessElementToolbarWidget extends WidgetComponent<
|
|||||||
this.moreGroups = getMoreMenuConfig(this.std).configure(this.moreGroups);
|
this.moreGroups = getMoreMenuConfig(this.std).configure(this.moreGroups);
|
||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
edgeless.service.viewport.viewportUpdated.on(() => {
|
edgeless.service.viewport.viewportUpdated.subscribe(() => {
|
||||||
this._recalculatePosition();
|
this._recalculatePosition();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
this.selection.slots.updated.on(() => {
|
this.selection.slots.updated.subscribe(() => {
|
||||||
if (
|
if (
|
||||||
this.selection.selectedIds.length === 0 ||
|
this.selection.selectedIds.length === 0 ||
|
||||||
this.selection.editing ||
|
this.selection.editing ||
|
||||||
@@ -383,18 +383,18 @@ export class EdgelessElementToolbarWidget extends WidgetComponent<
|
|||||||
);
|
);
|
||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
this.edgeless.service.surface.elementAdded.on(
|
this.edgeless.service.surface.elementAdded.subscribe(
|
||||||
this._updateOnSelectedChange
|
this._updateOnSelectedChange
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
this.edgeless.service.surface.elementUpdated.on(
|
this.edgeless.service.surface.elementUpdated.subscribe(
|
||||||
this._updateOnSelectedChange
|
this._updateOnSelectedChange
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
this.doc.slots.blockUpdated.on(this._updateOnSelectedChange)
|
this.doc.slots.blockUpdated.subscribe(this._updateOnSelectedChange)
|
||||||
);
|
);
|
||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
@@ -410,19 +410,19 @@ export class EdgelessElementToolbarWidget extends WidgetComponent<
|
|||||||
);
|
);
|
||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
edgeless.slots.elementResizeStart.on(() => {
|
edgeless.slots.elementResizeStart.subscribe(() => {
|
||||||
this._dragging = true;
|
this._dragging = true;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
edgeless.slots.elementResizeEnd.on(() => {
|
edgeless.slots.elementResizeEnd.subscribe(() => {
|
||||||
this._dragging = false;
|
this._dragging = false;
|
||||||
this._recalculatePosition();
|
this._recalculatePosition();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
_disposables.add(
|
_disposables.add(
|
||||||
edgeless.slots.readonlyUpdated.on(() => this.requestUpdate())
|
edgeless.slots.readonlyUpdated.subscribe(() => this.requestUpdate())
|
||||||
);
|
);
|
||||||
|
|
||||||
this.updateComplete
|
this.updateComplete
|
||||||
|
|||||||
@@ -359,13 +359,18 @@ const pageToolGroup: KeyboardToolPanelGroup = {
|
|||||||
|
|
||||||
const inlineEditor = getInlineEditorByModel(std.host, currentModel);
|
const inlineEditor = getInlineEditorByModel(std.host, currentModel);
|
||||||
// Wait for range to be updated
|
// Wait for range to be updated
|
||||||
inlineEditor?.slots.inlineRangeSync.once(() => {
|
if (inlineEditor) {
|
||||||
linkedDocWidget.show({
|
const subscription = inlineEditor.slots.inlineRangeSync.subscribe(
|
||||||
mode: 'mobile',
|
() => {
|
||||||
addTriggerKey: true,
|
subscription.unsubscribe();
|
||||||
});
|
linkedDocWidget.show({
|
||||||
closeToolPanel();
|
mode: 'mobile',
|
||||||
});
|
addTriggerKey: true,
|
||||||
|
});
|
||||||
|
closeToolPanel();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.run();
|
.run();
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
import { type VirtualKeyboardProvider } from '@blocksuite/affine-shared/services';
|
import { type VirtualKeyboardProvider } from '@blocksuite/affine-shared/services';
|
||||||
import type { BlockStdScope, ShadowlessElement } from '@blocksuite/block-std';
|
import type { BlockStdScope, ShadowlessElement } from '@blocksuite/block-std';
|
||||||
import { DisposableGroup } from '@blocksuite/global/slot';
|
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||||
import { effect, type Signal } from '@preact/signals-core';
|
import { effect, type Signal } from '@preact/signals-core';
|
||||||
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
||||||
|
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ export class AffineLinkedDocWidget extends WidgetComponent<
|
|||||||
private _watchViewportChange() {
|
private _watchViewportChange() {
|
||||||
const gfx = this.std.get(GfxControllerIdentifier);
|
const gfx = this.std.get(GfxControllerIdentifier);
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
gfx.viewport.viewportUpdated.on(() => {
|
gfx.viewport.viewportUpdated.subscribe(() => {
|
||||||
this._updateInputRects();
|
this._updateInputRects();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -273,7 +273,7 @@ export class AffineLinkedDocWidget extends WidgetComponent<
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const disposable = inlineEditor.slots.renderComplete.on(() => {
|
const disposable = inlineEditor.slots.renderComplete.subscribe(() => {
|
||||||
this._updateInputRects();
|
this._updateInputRects();
|
||||||
});
|
});
|
||||||
this._context = {
|
this._context = {
|
||||||
@@ -283,7 +283,7 @@ export class AffineLinkedDocWidget extends WidgetComponent<
|
|||||||
triggerKey: primaryTriggerKey,
|
triggerKey: primaryTriggerKey,
|
||||||
config: this.config,
|
config: this.config,
|
||||||
close: () => {
|
close: () => {
|
||||||
disposable.dispose();
|
disposable.unsubscribe();
|
||||||
this._inputRects$.value = [];
|
this._inputRects$.value = [];
|
||||||
this._mode$.value = 'none';
|
this._mode$.value = 'none';
|
||||||
this._context = null;
|
this._context = null;
|
||||||
|
|||||||
@@ -183,9 +183,11 @@ export class LinkedDocPopover extends SignalWatcher(
|
|||||||
if (isComposition) {
|
if (isComposition) {
|
||||||
this._updateLinkedDocGroup().catch(console.error);
|
this._updateLinkedDocGroup().catch(console.error);
|
||||||
} else {
|
} else {
|
||||||
this.context.inlineEditor.slots.renderComplete.once(
|
const subscription =
|
||||||
this._updateLinkedDocGroup
|
this.context.inlineEditor.slots.renderComplete.subscribe(() => {
|
||||||
);
|
subscription.unsubscribe();
|
||||||
|
this._updateLinkedDocGroup().catch(console.error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPaste: () => {
|
onPaste: () => {
|
||||||
@@ -201,9 +203,11 @@ export class LinkedDocPopover extends SignalWatcher(
|
|||||||
if (curRange.index < this.context.startRange.index) {
|
if (curRange.index < this.context.startRange.index) {
|
||||||
this.context.close();
|
this.context.close();
|
||||||
}
|
}
|
||||||
this.context.inlineEditor.slots.renderComplete.once(
|
const subscription =
|
||||||
this._updateLinkedDocGroup
|
this.context.inlineEditor.slots.renderComplete.subscribe(() => {
|
||||||
);
|
subscription.unsubscribe();
|
||||||
|
this._updateLinkedDocGroup().catch(console.error);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onMove: step => {
|
onMove: step => {
|
||||||
const itemLen = this._flattenActionList.length;
|
const itemLen = this._flattenActionList.length;
|
||||||
@@ -332,7 +336,9 @@ export class LinkedDocPopover extends SignalWatcher(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const gfx = this.context.std.get(GfxControllerIdentifier);
|
const gfx = this.context.std.get(GfxControllerIdentifier);
|
||||||
this.disposables.add(gfx.viewport.viewportUpdated.on(updatePosition));
|
this.disposables.add(
|
||||||
|
gfx.viewport.viewportUpdated.subscribe(updatePosition)
|
||||||
|
);
|
||||||
|
|
||||||
updatePosition();
|
updatePosition();
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-8
@@ -196,20 +196,28 @@ export class AffineMobileLinkedDocMenu extends SignalWatcher(
|
|||||||
if (isComposition) {
|
if (isComposition) {
|
||||||
this._updateLinkedDocGroup().catch(console.error);
|
this._updateLinkedDocGroup().catch(console.error);
|
||||||
} else {
|
} else {
|
||||||
inlineEditor.slots.renderComplete.once(this._updateLinkedDocGroup);
|
const subscription = inlineEditor.slots.renderComplete.subscribe(
|
||||||
|
() => {
|
||||||
|
subscription.unsubscribe();
|
||||||
|
this._updateLinkedDocGroup().catch(console.error);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDelete: () => {
|
onDelete: () => {
|
||||||
inlineEditor.slots.renderComplete.once(() => {
|
const subscription = inlineEditor.slots.renderComplete.subscribe(
|
||||||
const curRange = inlineEditor.getInlineRange();
|
() => {
|
||||||
|
subscription.unsubscribe();
|
||||||
|
const curRange = inlineEditor.getInlineRange();
|
||||||
|
|
||||||
if (!this.context.startRange || !curRange) return;
|
if (!this.context.startRange || !curRange) return;
|
||||||
|
|
||||||
if (curRange.index < this.context.startRange.index) {
|
if (curRange.index < this.context.startRange.index) {
|
||||||
this.context.close();
|
this.context.close();
|
||||||
|
}
|
||||||
|
this._updateLinkedDocGroup().catch(console.error);
|
||||||
}
|
}
|
||||||
this._updateLinkedDocGroup().catch(console.error);
|
);
|
||||||
});
|
|
||||||
},
|
},
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
this._firstActionItem?.action()?.catch(console.error);
|
this._firstActionItem?.action()?.catch(console.error);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
"lit": "^3.2.0",
|
"lit": "^3.2.0",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"nanoid": "^5.0.7",
|
"nanoid": "^5.0.7",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export class SurfaceRefGenericBlockPortal extends WithDisposable(
|
|||||||
|
|
||||||
override firstUpdated() {
|
override firstUpdated() {
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.model.propsUpdated.on(() => this.requestUpdate())
|
this.model.propsUpdated.subscribe(() => this.requestUpdate())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export class SurfaceRefNotePortal extends WithDisposable(ShadowlessElement) {
|
|||||||
|
|
||||||
override firstUpdated() {
|
override firstUpdated() {
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.model.propsUpdated.on(() => this.requestUpdate())
|
this.model.propsUpdated.subscribe(() => this.requestUpdate())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,13 +36,13 @@ import {
|
|||||||
type GfxModel,
|
type GfxModel,
|
||||||
GfxPrimitiveElementModel,
|
GfxPrimitiveElementModel,
|
||||||
} from '@blocksuite/block-std/gfx';
|
} from '@blocksuite/block-std/gfx';
|
||||||
|
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||||
import {
|
import {
|
||||||
Bound,
|
Bound,
|
||||||
deserializeXYWH,
|
deserializeXYWH,
|
||||||
type SerializedXYWH,
|
type SerializedXYWH,
|
||||||
} from '@blocksuite/global/gfx';
|
} from '@blocksuite/global/gfx';
|
||||||
import { DisposableGroup } from '@blocksuite/global/slot';
|
|
||||||
import { DeleteIcon, EdgelessIcon, FrameIcon } from '@blocksuite/icons/lit';
|
import { DeleteIcon, EdgelessIcon, FrameIcon } from '@blocksuite/icons/lit';
|
||||||
import type { BaseSelection, Store } from '@blocksuite/store';
|
import type { BaseSelection, Store } from '@blocksuite/store';
|
||||||
import { css, html, nothing, type TemplateResult } from 'lit';
|
import { css, html, nothing, type TemplateResult } from 'lit';
|
||||||
@@ -376,7 +376,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
|
|||||||
init();
|
init();
|
||||||
|
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.model.propsUpdated.on(payload => {
|
this.model.propsUpdated.subscribe(payload => {
|
||||||
if (
|
if (
|
||||||
payload.key === 'reference' &&
|
payload.key === 'reference' &&
|
||||||
this.model.reference !== this._referencedModel?.id
|
this.model.reference !== this._referencedModel?.id
|
||||||
@@ -388,7 +388,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
|
|||||||
|
|
||||||
if (surfaceModel && this._referencedModel instanceof SurfaceElementModel) {
|
if (surfaceModel && this._referencedModel instanceof SurfaceElementModel) {
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
surfaceModel.elementRemoved.on(({ id }) => {
|
surfaceModel.elementRemoved.subscribe(({ id }) => {
|
||||||
if (this.model.reference === id) {
|
if (this.model.reference === id) {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@@ -398,7 +398,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
|
|||||||
|
|
||||||
if (this._referencedModel instanceof GfxBlockElementModel) {
|
if (this._referencedModel instanceof GfxBlockElementModel) {
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.doc.slots.blockUpdated.on(({ type, id }) => {
|
this.doc.slots.blockUpdated.subscribe(({ type, id }) => {
|
||||||
if (type === 'delete' && id === this.model.reference) {
|
if (type === 'delete' && id === this.model.reference) {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@@ -410,7 +410,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
|
|||||||
private _initSelection() {
|
private _initSelection() {
|
||||||
const selection = this.host.selection;
|
const selection = this.host.selection;
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
selection.slots.changed.on(selList => {
|
selection.slots.changed.subscribe(selList => {
|
||||||
this._focused = selList.some(
|
this._focused = selList.some(
|
||||||
sel => sel.blockId === this.blockId && sel.is(BlockSelection)
|
sel => sel.blockId === this.blockId && sel.is(BlockSelection)
|
||||||
);
|
);
|
||||||
@@ -424,16 +424,16 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
|
|||||||
static override readonly key = 'surfaceRefViewportInitializer';
|
static override readonly key = 'surfaceRefViewportInitializer';
|
||||||
|
|
||||||
override mounted() {
|
override mounted() {
|
||||||
const disposable = this.std.view.viewUpdated.on(payload => {
|
const disposable = this.std.view.viewUpdated.subscribe(payload => {
|
||||||
if (payload.type !== 'block') return;
|
if (payload.type !== 'block') return;
|
||||||
if (
|
if (
|
||||||
payload.method === 'add' &&
|
payload.method === 'add' &&
|
||||||
matchModels(payload.view.model, [RootBlockModel])
|
matchModels(payload.view.model, [RootBlockModel])
|
||||||
) {
|
) {
|
||||||
disposable.dispose();
|
disposable.unsubscribe();
|
||||||
queueMicrotask(() => refreshViewport());
|
queueMicrotask(() => refreshViewport());
|
||||||
const gfx = this.std.get(GfxControllerIdentifier);
|
const gfx = this.std.get(GfxControllerIdentifier);
|
||||||
gfx.viewport.sizeUpdated.on(() => {
|
gfx.viewport.sizeUpdated.subscribe(() => {
|
||||||
refreshViewport();
|
refreshViewport();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -475,7 +475,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
|
|||||||
);
|
);
|
||||||
} else if (referenceElement instanceof GfxPrimitiveElementModel) {
|
} else if (referenceElement instanceof GfxPrimitiveElementModel) {
|
||||||
_disposable.add(
|
_disposable.add(
|
||||||
surfaceModel.elementUpdated.on(({ id, oldValues }) => {
|
surfaceModel.elementUpdated.subscribe(({ id, oldValues }) => {
|
||||||
if (
|
if (
|
||||||
id === referenceId &&
|
id === referenceId &&
|
||||||
oldValues.xywh !== referenceElement.xywh
|
oldValues.xywh !== referenceElement.xywh
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"nanoid": "^5.0.7",
|
"nanoid": "^5.0.7",
|
||||||
"pdf-lib": "^1.17.1",
|
"pdf-lib": "^1.17.1",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
"yjs": "^13.6.21",
|
"yjs": "^13.6.21",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,40 +1,39 @@
|
|||||||
import type { FrameBlockModel } from '@blocksuite/affine-model';
|
import type { FrameBlockModel } from '@blocksuite/affine-model';
|
||||||
import { createIdentifier } from '@blocksuite/global/di';
|
import { createIdentifier } from '@blocksuite/global/di';
|
||||||
import { Slot } from '@blocksuite/global/slot';
|
|
||||||
import type { ExtensionType } from '@blocksuite/store';
|
import type { ExtensionType } from '@blocksuite/store';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
export const EdgelessLegacySlotIdentifier = createIdentifier<{
|
export const EdgelessLegacySlotIdentifier = createIdentifier<{
|
||||||
readonlyUpdated: Slot<boolean>;
|
readonlyUpdated: Subject<boolean>;
|
||||||
navigatorSettingUpdated: Slot<{
|
navigatorSettingUpdated: Subject<{
|
||||||
hideToolbar?: boolean;
|
hideToolbar?: boolean;
|
||||||
blackBackground?: boolean;
|
blackBackground?: boolean;
|
||||||
fillScreen?: boolean;
|
fillScreen?: boolean;
|
||||||
}>;
|
}>;
|
||||||
navigatorFrameChanged: Slot<FrameBlockModel>;
|
navigatorFrameChanged: Subject<FrameBlockModel>;
|
||||||
fullScreenToggled: Slot;
|
fullScreenToggled: Subject<void>;
|
||||||
|
|
||||||
elementResizeStart: Slot;
|
elementResizeStart: Subject<void>;
|
||||||
elementResizeEnd: Slot;
|
elementResizeEnd: Subject<void>;
|
||||||
toggleNoteSlicer: Slot;
|
toggleNoteSlicer: Subject<void>;
|
||||||
|
|
||||||
toolbarLocked: Slot<boolean>;
|
toolbarLocked: Subject<boolean>;
|
||||||
}>('AffineEdgelessLegacySlotService');
|
}>('AffineEdgelessLegacySlotService');
|
||||||
|
|
||||||
export const EdgelessLegacySlotExtension: ExtensionType = {
|
export const EdgelessLegacySlotExtension: ExtensionType = {
|
||||||
setup: di => {
|
setup: di => {
|
||||||
di.addImpl(EdgelessLegacySlotIdentifier, () => ({
|
di.addImpl(EdgelessLegacySlotIdentifier, () => ({
|
||||||
readonlyUpdated: new Slot<boolean>(),
|
readonlyUpdated: new Subject<boolean>(),
|
||||||
navigatorSettingUpdated: new Slot<{
|
navigatorSettingUpdated: new Subject<{
|
||||||
hideToolbar?: boolean;
|
hideToolbar?: boolean;
|
||||||
blackBackground?: boolean;
|
blackBackground?: boolean;
|
||||||
fillScreen?: boolean;
|
fillScreen?: boolean;
|
||||||
}>(),
|
}>(),
|
||||||
navigatorFrameChanged: new Slot<FrameBlockModel>(),
|
navigatorFrameChanged: new Subject<FrameBlockModel>(),
|
||||||
fullScreenToggled: new Slot(),
|
fullScreenToggled: new Subject(),
|
||||||
elementResizeStart: new Slot(),
|
elementResizeStart: new Subject(),
|
||||||
elementResizeEnd: new Slot(),
|
elementResizeEnd: new Subject(),
|
||||||
toggleNoteSlicer: new Slot(),
|
toggleNoteSlicer: new Subject(),
|
||||||
toolbarLocked: new Slot<boolean>(),
|
toolbarLocked: new Subject<boolean>(),
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ import type {
|
|||||||
SurfaceBlockModel,
|
SurfaceBlockModel,
|
||||||
Viewport,
|
Viewport,
|
||||||
} from '@blocksuite/block-std/gfx';
|
} from '@blocksuite/block-std/gfx';
|
||||||
|
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||||
import type { IBound } from '@blocksuite/global/gfx';
|
import type { IBound } from '@blocksuite/global/gfx';
|
||||||
import { getBoundWithRotation, intersects } from '@blocksuite/global/gfx';
|
import { getBoundWithRotation, intersects } from '@blocksuite/global/gfx';
|
||||||
import { DisposableGroup, Slot } from '@blocksuite/global/slot';
|
|
||||||
import last from 'lodash-es/last';
|
import last from 'lodash-es/last';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
import type { SurfaceElementModel } from '../element-model/base.js';
|
import type { SurfaceElementModel } from '../element-model/base.js';
|
||||||
import { RoughCanvas } from '../utils/rough/canvas.js';
|
import { RoughCanvas } from '../utils/rough/canvas.js';
|
||||||
@@ -58,7 +59,7 @@ export class CanvasRenderer {
|
|||||||
|
|
||||||
provider: Partial<EnvProvider>;
|
provider: Partial<EnvProvider>;
|
||||||
|
|
||||||
stackingCanvasUpdated = new Slot<{
|
stackingCanvasUpdated = new Subject<{
|
||||||
canvases: HTMLCanvasElement[];
|
canvases: HTMLCanvasElement[];
|
||||||
added: HTMLCanvasElement[];
|
added: HTMLCanvasElement[];
|
||||||
removed: HTMLCanvasElement[];
|
removed: HTMLCanvasElement[];
|
||||||
@@ -175,14 +176,14 @@ export class CanvasRenderer {
|
|||||||
payload.removed = currentCanvases.slice(diff);
|
payload.removed = currentCanvases.slice(diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.stackingCanvasUpdated.emit(payload);
|
this.stackingCanvasUpdated.next(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.refresh();
|
this.refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.layerManager.slots.layerUpdated.on(() => {
|
this.layerManager.slots.layerUpdated.subscribe(() => {
|
||||||
updateStackingCanvas();
|
updateStackingCanvas();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -194,13 +195,13 @@ export class CanvasRenderer {
|
|||||||
let sizeUpdatedRafId: number | null = null;
|
let sizeUpdatedRafId: number | null = null;
|
||||||
|
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.viewport.viewportUpdated.on(() => {
|
this.viewport.viewportUpdated.subscribe(() => {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this.viewport.sizeUpdated.on(() => {
|
this.viewport.sizeUpdated.subscribe(() => {
|
||||||
if (sizeUpdatedRafId) return;
|
if (sizeUpdatedRafId) return;
|
||||||
sizeUpdatedRafId = requestConnectedFrame(() => {
|
sizeUpdatedRafId = requestConnectedFrame(() => {
|
||||||
sizeUpdatedRafId = null;
|
sizeUpdatedRafId = null;
|
||||||
@@ -319,20 +320,24 @@ export class CanvasRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _watchSurface(surfaceModel: SurfaceBlockModel) {
|
private _watchSurface(surfaceModel: SurfaceBlockModel) {
|
||||||
const slots = [
|
this._disposables.add(
|
||||||
'elementAdded',
|
surfaceModel.elementAdded.subscribe(() => this.refresh())
|
||||||
'elementRemoved',
|
);
|
||||||
'localElementAdded',
|
this._disposables.add(
|
||||||
'localElementDeleted',
|
surfaceModel.elementRemoved.subscribe(() => this.refresh())
|
||||||
'localElementUpdated',
|
);
|
||||||
] as const;
|
this._disposables.add(
|
||||||
|
surfaceModel.localElementAdded.subscribe(() => this.refresh())
|
||||||
slots.forEach(slotName => {
|
);
|
||||||
this._disposables.add(surfaceModel[slotName].on(() => this.refresh()));
|
this._disposables.add(
|
||||||
});
|
surfaceModel.localElementDeleted.subscribe(() => this.refresh())
|
||||||
|
);
|
||||||
|
this._disposables.add(
|
||||||
|
surfaceModel.localElementUpdated.subscribe(() => this.refresh())
|
||||||
|
);
|
||||||
|
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
surfaceModel.elementUpdated.on(payload => {
|
surfaceModel.elementUpdated.subscribe(payload => {
|
||||||
// ignore externalXYWH update cause it's updated by the renderer
|
// ignore externalXYWH update cause it's updated by the renderer
|
||||||
if (payload.props['externalXYWH']) return;
|
if (payload.props['externalXYWH']) return;
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ import {
|
|||||||
type Viewport,
|
type Viewport,
|
||||||
} from '@blocksuite/block-std/gfx';
|
} from '@blocksuite/block-std/gfx';
|
||||||
import { Bound } from '@blocksuite/global/gfx';
|
import { Bound } from '@blocksuite/global/gfx';
|
||||||
import type { Slot } from '@blocksuite/global/slot';
|
|
||||||
import { css, html } from 'lit';
|
import { css, html } from 'lit';
|
||||||
import { query } from 'lit/decorators.js';
|
import { query } from 'lit/decorators.js';
|
||||||
|
import type { Subject } from 'rxjs';
|
||||||
|
|
||||||
import { ConnectorElementModel } from './element-model/index.js';
|
import { ConnectorElementModel } from './element-model/index.js';
|
||||||
import { CanvasRenderer } from './renderer/canvas-renderer.js';
|
import { CanvasRenderer } from './renderer/canvas-renderer.js';
|
||||||
@@ -28,7 +28,7 @@ export interface SurfaceContext {
|
|||||||
selection: {
|
selection: {
|
||||||
selectedIds: string[];
|
selectedIds: string[];
|
||||||
slots: {
|
slots: {
|
||||||
updated: Slot<SurfaceSelection[]>;
|
updated: Subject<SurfaceSelection[]>;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -191,7 +191,7 @@ export class SurfaceBlockComponent extends BlockComponent<
|
|||||||
this._renderer.dispose();
|
this._renderer.dispose();
|
||||||
});
|
});
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
this._renderer.stackingCanvasUpdated.on(payload => {
|
this._renderer.stackingCanvasUpdated.subscribe(payload => {
|
||||||
if (payload.added.length) {
|
if (payload.added.length) {
|
||||||
this._surfaceContainer.append(...payload.added);
|
this._surfaceContainer.append(...payload.added);
|
||||||
}
|
}
|
||||||
@@ -204,7 +204,7 @@ export class SurfaceBlockComponent extends BlockComponent<
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
this._disposables.add(
|
this._disposables.add(
|
||||||
gfx.selection.slots.updated.on(() => {
|
gfx.selection.slots.updated.subscribe(() => {
|
||||||
this._renderer.refresh();
|
this._renderer.refresh();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import type {
|
|||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
import type { SurfaceBlockProps } from '@blocksuite/block-std/gfx';
|
import type { SurfaceBlockProps } from '@blocksuite/block-std/gfx';
|
||||||
import { SurfaceBlockModel as BaseSurfaceModel } from '@blocksuite/block-std/gfx';
|
import { SurfaceBlockModel as BaseSurfaceModel } from '@blocksuite/block-std/gfx';
|
||||||
import { DisposableGroup } from '@blocksuite/global/slot';
|
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||||
import { BlockSchemaExtension, defineBlockSchema } from '@blocksuite/store';
|
import { BlockSchemaExtension, defineBlockSchema } from '@blocksuite/store';
|
||||||
import * as Y from 'yjs';
|
import * as Y from 'yjs';
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user