mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-01 01:29:31 +08:00
feat(editor): life cycle ext (#10668)
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
||||
import { EMBED_CARD_HEIGHT } from '@blocksuite/affine-shared/consts';
|
||||
import { NotificationProvider } from '@blocksuite/affine-shared/services';
|
||||
import { matchModels, SpecProvider } from '@blocksuite/affine-shared/utils';
|
||||
import { BlockStdScope } from '@blocksuite/block-std';
|
||||
import { BlockStdScope, EditorLifeCycleExtension } from '@blocksuite/block-std';
|
||||
import {
|
||||
type BlockModel,
|
||||
type BlockSnapshot,
|
||||
@@ -351,7 +351,9 @@ export function notifyDocCreated(std: BlockStdScope, doc: Store) {
|
||||
// edit or undo or switch doc, close notify toast
|
||||
const addHandler = doc.history.on('stack-item-added', closeNotify);
|
||||
const popHandler = doc.history.on('stack-item-popped', closeNotify);
|
||||
const disposable = std.host.slots.unmounted.on(closeNotify);
|
||||
const disposable = std
|
||||
.get(EditorLifeCycleExtension)
|
||||
.slots.unmounted.on(closeNotify);
|
||||
|
||||
notification.notify({
|
||||
title: 'Linked doc created',
|
||||
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
TelemetryProvider,
|
||||
ThemeProvider,
|
||||
} from '@blocksuite/affine-shared/services';
|
||||
import { EditorLifeCycleExtension } from '@blocksuite/block-std';
|
||||
import { Bound } from '@blocksuite/global/gfx';
|
||||
import { WithDisposable } from '@blocksuite/global/lit';
|
||||
import {
|
||||
@@ -210,7 +211,9 @@ export class EdgelessChangeNoteButton extends WithDisposable(LitElement) {
|
||||
|
||||
const addHandler = this.doc.history.on('stack-item-added', closeNotify);
|
||||
const popHandler = this.doc.history.on('stack-item-popped', closeNotify);
|
||||
const disposable = this.edgeless.std.host.slots.unmounted.on(closeNotify);
|
||||
const disposable = this.edgeless.std
|
||||
.get(EditorLifeCycleExtension)
|
||||
.slots.unmounted.on(closeNotify);
|
||||
|
||||
const undo = () => {
|
||||
this.doc.undo();
|
||||
|
||||
@@ -15,10 +15,11 @@ import {
|
||||
listenClickAway,
|
||||
stopPropagation,
|
||||
} from '@blocksuite/affine-shared/utils';
|
||||
import type {
|
||||
BlockComponent,
|
||||
BlockStdScope,
|
||||
EditorHost,
|
||||
import {
|
||||
type BlockComponent,
|
||||
type BlockStdScope,
|
||||
type EditorHost,
|
||||
EditorLifeCycleExtension,
|
||||
} from '@blocksuite/block-std';
|
||||
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
|
||||
import { nextTick } from '@blocksuite/global/utils';
|
||||
@@ -256,7 +257,9 @@ export class EmbedCardEditModal extends SignalWatcher(
|
||||
override connectedCallback() {
|
||||
super.connectedCallback();
|
||||
|
||||
this.disposables.add(this.host.slots.unmounted.on(this._hide));
|
||||
this.disposables.add(
|
||||
this.host.std.get(EditorLifeCycleExtension).slots.unmounted.on(this._hide)
|
||||
);
|
||||
this._updateInfo();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { NotificationProvider } from '@blocksuite/affine-shared/services';
|
||||
import type { BlockStdScope } from '@blocksuite/block-std';
|
||||
import {
|
||||
type BlockStdScope,
|
||||
EditorLifeCycleExtension,
|
||||
} from '@blocksuite/block-std';
|
||||
|
||||
import { toast } from '../toast/toast.js';
|
||||
|
||||
@@ -26,7 +29,9 @@ function notify(std: BlockStdScope, title: string, message: string) {
|
||||
// edit or undo or switch doc, close notify toast
|
||||
const addHandler = doc.history.on('stack-item-added', closeNotify);
|
||||
const popHandler = doc.history.on('stack-item-popped', closeNotify);
|
||||
const disposable = host.slots.unmounted.on(closeNotify);
|
||||
const disposable = host.std
|
||||
.get(EditorLifeCycleExtension)
|
||||
.slots.unmounted.on(closeNotify);
|
||||
|
||||
notification.notify({
|
||||
title,
|
||||
|
||||
Reference in New Issue
Block a user