chore: merge blocksuite source code (#9213)

This commit is contained in:
Mirone
2024-12-20 15:38:06 +08:00
committed by GitHub
parent 2c9ef916f4
commit 30200ff86d
2031 changed files with 238888 additions and 229 deletions
@@ -0,0 +1,56 @@
import { UIEventState, UIEventStateContext } from '../base.js';
import type { UIEventDispatcher } from '../dispatcher.js';
import { ClipboardEventState } from '../state/clipboard.js';
import { EventScopeSourceType, EventSourceState } from '../state/source.js';
export class ClipboardControl {
private _copy = (event: ClipboardEvent) => {
const clipboardEventState = new ClipboardEventState({
event,
});
this._dispatcher.run(
'copy',
this._createContext(event, clipboardEventState)
);
};
private _cut = (event: ClipboardEvent) => {
const clipboardEventState = new ClipboardEventState({
event,
});
this._dispatcher.run(
'cut',
this._createContext(event, clipboardEventState)
);
};
private _paste = (event: ClipboardEvent) => {
const clipboardEventState = new ClipboardEventState({
event,
});
this._dispatcher.run(
'paste',
this._createContext(event, clipboardEventState)
);
};
constructor(private _dispatcher: UIEventDispatcher) {}
private _createContext(event: Event, clipboardState: ClipboardEventState) {
return UIEventStateContext.from(
new UIEventState(event),
new EventSourceState({
event,
sourceType: EventScopeSourceType.Selection,
}),
clipboardState
);
}
listen() {
this._dispatcher.disposables.addFromEvent(document, 'cut', this._cut);
this._dispatcher.disposables.addFromEvent(document, 'copy', this._copy);
this._dispatcher.disposables.addFromEvent(document, 'paste', this._paste);
}
}