-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(plugin-command): add plugin-command package
- Loading branch information
Showing
10 changed files
with
171 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# `@alilc/plugin-command` | ||
|
||
> TODO: description | ||
## Usage | ||
|
||
``` | ||
const pluginCommand = require('@alilc/plugin-command'); | ||
// TODO: DEMONSTRATE API | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"plugins": [ | ||
"@alilc/build-plugin-lce", | ||
"build-plugin-fusion", | ||
["build-plugin-moment-locales", { | ||
"locales": ["zh-cn"] | ||
}] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"@alilc/build-plugin-lce", | ||
{ | ||
"filename": "editor-preset-vision", | ||
"library": "LowcodeEditor", | ||
"libraryTarget": "umd", | ||
"externals": { | ||
"react": "var window.React", | ||
"react-dom": "var window.ReactDOM", | ||
"prop-types": "var window.PropTypes", | ||
"rax": "var window.Rax" | ||
} | ||
} | ||
], | ||
"@alilc/lowcode-test-mate/plugin/index.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "@alilc/lowcode-plugin-command", | ||
"version": "1.3.1", | ||
"description": "> TODO: description", | ||
"author": "liujuping <liujup@foxmail.com>", | ||
"homepage": "https://github.com/alibaba/lowcode-engine#readme", | ||
"license": "ISC", | ||
"main": "lib/plugin-command.js", | ||
"directories": { | ||
"lib": "lib", | ||
"test": "__tests__" | ||
}, | ||
"files": [ | ||
"lib" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/alibaba/lowcode-engine.git" | ||
}, | ||
"scripts": { | ||
"test": "build-scripts test --config build.test.json --jest-passWithNoTests", | ||
"build": "build-scripts build" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/alibaba/lowcode-engine/issues" | ||
}, | ||
"dependencies": { | ||
"@alilc/lowcode-types": "^1.3.1", | ||
"@alilc/lowcode-utils": "^1.3.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { IPublicModelPluginContext, IPublicTypePlugin } from '@alilc/lowcode-types'; | ||
|
||
export const historyCommand: IPublicTypePlugin = (ctx: IPublicModelPluginContext) => { | ||
const { command, project } = ctx; | ||
return { | ||
init() { | ||
command.registerCommand({ | ||
name: 'undo', | ||
description: 'Undo the last operation.', | ||
handler: () => { | ||
const state = project.currentDocument?.history.getState() || 0; | ||
const enable = !!(state & 1); | ||
if (!enable) { | ||
throw new Error('Can not undo.'); | ||
} | ||
project.currentDocument?.history.back(); | ||
}, | ||
}); | ||
|
||
command.registerCommand({ | ||
name: 'redo', | ||
description: 'Redo the last operation.', | ||
handler: () => { | ||
const state = project.currentDocument?.history.getState() || 0; | ||
const enable = !!(state & 2); | ||
if (!enable) { | ||
throw new Error('Can not redo.'); | ||
} | ||
project.currentDocument?.history.forward(); | ||
}, | ||
}); | ||
}, | ||
destroy() { | ||
command.unregisterCommand('history:undo'); | ||
command.unregisterCommand('history:redo'); | ||
}, | ||
}; | ||
}; | ||
|
||
historyCommand.pluginName = '___history_command___'; | ||
historyCommand.meta = { | ||
commandScope: 'history', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { IPublicModelPluginContext, IPublicTypePlugin } from '@alilc/lowcode-types'; | ||
import { nodeCommand } from './node-command'; | ||
import { historyCommand } from './history-command'; | ||
|
||
export const defaultCommand: IPublicTypePlugin = (ctx: IPublicModelPluginContext) => { | ||
const { plugins } = ctx; | ||
|
||
return { | ||
async init() { | ||
await plugins.register(nodeCommand, {}, { autoInit: true }); | ||
await plugins.register(historyCommand, {}, { autoInit: true }); | ||
}, | ||
destroy() { | ||
plugins.delete(nodeCommand.pluginName); | ||
plugins.delete(historyCommand.pluginName); | ||
}, | ||
}; | ||
}; | ||
|
||
defaultCommand.pluginName = '___default_command___'; | ||
defaultCommand.meta = { | ||
commandScope: 'common', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters