mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 14:27:02 +08:00
feat(editor): replace slot with rxjs subject (#10768)
This commit is contained in:
@@ -233,8 +233,11 @@ export class SlashMenu extends WithDisposable(LitElement) {
|
||||
if (isComposition) {
|
||||
this._updateFilteredItems();
|
||||
} else {
|
||||
this.inlineEditor.slots.renderComplete.once(
|
||||
this._updateFilteredItems
|
||||
const subscription = this.inlineEditor.slots.renderComplete.subscribe(
|
||||
() => {
|
||||
subscription.unsubscribe();
|
||||
this._updateFilteredItems();
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -251,7 +254,12 @@ export class SlashMenu extends WithDisposable(LitElement) {
|
||||
if (curRange.index < this._startRange.index) {
|
||||
this.abortController.abort();
|
||||
}
|
||||
this.inlineEditor.slots.renderComplete.once(this._updateFilteredItems);
|
||||
const subscription = this.inlineEditor.slots.renderComplete.subscribe(
|
||||
() => {
|
||||
subscription.unsubscribe();
|
||||
this._updateFilteredItems();
|
||||
}
|
||||
);
|
||||
},
|
||||
onAbort: () => this.abortController.abort(),
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
} from '@blocksuite/affine-rich-text';
|
||||
import type { UIEventStateContext } from '@blocksuite/block-std';
|
||||
import { TextSelection, WidgetComponent } from '@blocksuite/block-std';
|
||||
import { DisposableGroup } from '@blocksuite/global/slot';
|
||||
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||
import { InlineEditor } from '@blocksuite/inline';
|
||||
import debounce from 'lodash-es/debounce';
|
||||
|
||||
@@ -93,8 +93,16 @@ export class AffineSlashMenuWidget extends WidgetComponent {
|
||||
) => {
|
||||
const inlineRangeApplyCallback = (callback: () => void) => {
|
||||
// the inline ranged updated in compositionEnd event before this event callback
|
||||
if (isCompositionEnd) callback();
|
||||
else inlineEditor.slots.inlineRangeSync.once(callback);
|
||||
if (isCompositionEnd) {
|
||||
callback();
|
||||
} else {
|
||||
const subscription = inlineEditor.slots.inlineRangeSync.subscribe(
|
||||
() => {
|
||||
subscription.unsubscribe();
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
if (this.block.model.flavour !== 'affine:page') {
|
||||
|
||||
Reference in New Issue
Block a user