MCPcopy Create free account
hub / github.com/alibaba/lowcode-engine / init

Function init

packages/plugin-command/src/history-command.ts:6–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4 const { command, project } = ctx;
5 return {
6 init() {
7 command.registerCommand({
8 name: 'undo',
9 description: 'Undo the last operation.',
10 handler: () => {
11 const state = project.currentDocument?.history.getState() || 0;
12 const enable = !!(state & 1);
13 if (!enable) {
14 throw new Error('Can not undo.');
15 }
16 project.currentDocument?.history.back();
17 },
18 });
19
20 command.registerCommand({
21 name: 'redo',
22 description: 'Redo the last operation.',
23 handler: () => {
24 const state = project.currentDocument?.history.getState() || 0;
25 const enable = !!(state & 2);
26 if (!enable) {
27 throw new Error('Can not redo.');
28 }
29 project.currentDocument?.history.forward();
30 },
31 });
32 },
33 destroy() {
34 command.unregisterCommand('history:undo');
35 command.unregisterCommand('history:redo');

Callers

nothing calls this directly

Calls 4

registerCommandMethod · 0.65
getStateMethod · 0.65
backMethod · 0.65
forwardMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…