mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-24 05:07:06 +08:00
feat(editor): replace slot with rxjs subject (#10768)
This commit is contained in:
@@ -57,7 +57,7 @@ export class AffineLink extends WithDisposable(ShadowlessElement) {
|
||||
|
||||
e?.preventDefault();
|
||||
|
||||
refNodeSlotsProvider.docLinkClicked.emit({
|
||||
refNodeSlotsProvider.docLinkClicked.next({
|
||||
...referenceInfo,
|
||||
host: this.std.host,
|
||||
});
|
||||
|
||||
+7
-3
@@ -148,7 +148,7 @@ export class AffineReference extends WithDisposable(ShadowlessElement) {
|
||||
readonly open = (event?: Partial<DocLinkClickedEvent>) => {
|
||||
if (!this.config.interactable) return;
|
||||
|
||||
this.std.getOptional(RefNodeSlotsProvider)?.docLinkClicked.emit({
|
||||
this.std.getOptional(RefNodeSlotsProvider)?.docLinkClicked.next({
|
||||
...this.referenceInfo,
|
||||
...event,
|
||||
host: this.std.host,
|
||||
@@ -205,7 +205,9 @@ export class AffineReference extends WithDisposable(ShadowlessElement) {
|
||||
const doc = this.doc;
|
||||
if (doc) {
|
||||
this._disposables.add(
|
||||
doc.workspace.slots.docListUpdated.on(() => this._updateRefMeta(doc))
|
||||
doc.workspace.slots.docListUpdated.subscribe(() =>
|
||||
this._updateRefMeta(doc)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -215,7 +217,9 @@ export class AffineReference extends WithDisposable(ShadowlessElement) {
|
||||
|
||||
// observe yText update
|
||||
this.disposables.add(
|
||||
this.inlineEditor.slots.textChange.on(() => this._updateRefMeta(doc))
|
||||
this.inlineEditor.slots.textChange.subscribe(() =>
|
||||
this._updateRefMeta(doc)
|
||||
)
|
||||
);
|
||||
})
|
||||
.catch(console.error);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { ReferenceInfo } from '@blocksuite/affine-model';
|
||||
import type { OpenDocMode } from '@blocksuite/affine-shared/services';
|
||||
import type { EditorHost } from '@blocksuite/block-std';
|
||||
import type { Slot } from '@blocksuite/global/slot';
|
||||
import type { Subject } from 'rxjs';
|
||||
|
||||
export type DocLinkClickedEvent = ReferenceInfo & {
|
||||
// default is active view
|
||||
@@ -11,5 +11,5 @@ export type DocLinkClickedEvent = ReferenceInfo & {
|
||||
};
|
||||
|
||||
export type RefNodeSlots = {
|
||||
docLinkClicked: Slot<DocLinkClickedEvent>;
|
||||
docLinkClicked: Subject<DocLinkClickedEvent>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user