-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
278 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Publish Beta NPM Packages | ||
on: push | ||
workflow_dispatch: | ||
inputs: | ||
packagePath: | ||
description: 'Path to the package (e.g., action-block)' | ||
required: true | ||
betaVersion: | ||
description: 'Beta version number (e.g., 1.0.1-beta.0)' | ||
required: true | ||
|
||
jobs: | ||
publish-package: | ||
runs-on: ubuntu-latest | ||
if: >- | ||
github.actor == 'JackLian' || github.actor == 'liujuping' | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16' # 或者您希望的任何版本 | ||
|
||
- name: Install Dependencies and Publish | ||
run: | | ||
git config --local user.email "action@github.com" | ||
git config --local user.name "GitHub Action" | ||
cd packages | ||
cd ${{ github.event.inputs.packagePath }} | ||
npm install | ||
# 假设您使用 npm 来修改版本和发布 | ||
npm run build | ||
npm version ${{ github.event.inputs.betaVersion }} | ||
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc | ||
npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # 确保在您的 GitHub 仓库的 Secrets 中设置了 NPM_TOKEN |
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,50 @@ | ||
name: Publish NPM Packages | ||
on: push | ||
workflow_dispatch: | ||
inputs: | ||
packagePath: | ||
description: 'Path to the package (e.g., action-block)' | ||
required: true | ||
versionType: | ||
description: 'Version update type (major, minor, patch)' | ||
required: true | ||
default: 'patch' | ||
|
||
jobs: | ||
publish-package: | ||
runs-on: ubuntu-latest | ||
if: >- | ||
github.ref == 'refs/heads/main' && | ||
(github.actor == 'JackLian' || github.actor == 'liujuping') | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16' # 或者您希望的任何版本 | ||
|
||
- name: Install Dependencies and Publish | ||
run: | | ||
git config --local user.email "action@github.com" | ||
git config --local user.name "GitHub Action" | ||
cd packages | ||
cd ${{ github.event.inputs.packagePath }} | ||
npm install | ||
# 假设您使用 npm 来修改版本和发布 | ||
npm run build | ||
npm version patch | ||
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc | ||
npm publish | ||
echo "::set-output name=PACKAGE_NAME::$(node -p "require('./package.json').name")" | ||
echo "::set-output name=PACKAGE_VERSION::$(node -p "require('./package.json').version")" | ||
git tag -a "${{ steps.package_info.outputs.PACKAGE_NAME }}@${{ steps.package_info.outputs.PACKAGE_VERSION }}" -m "Release ${{ steps.package_info.outputs.PACKAGE_NAME }} version ${{ steps.package_info.outputs.PACKAGE_VERSION }}" | ||
git push origin "${{ steps.package_info.outputs.PACKAGE_NAME }}@${{ steps.package_info.outputs.PACKAGE_VERSION }}" | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # 确保在您的 GitHub 仓库的 Secrets 中设置了 NPM_TOKEN |
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-alt", | ||
{ | ||
"type": "plugin" | ||
} | ||
], | ||
[ | ||
"build-plugin-fusion", | ||
{ | ||
"themePackage": "@alifd/theme-lowcode-light" | ||
} | ||
], | ||
["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,44 @@ | ||
{ | ||
"name": "@alilc/lowcode-plugin-test", | ||
"version": "1.0.0", | ||
"description": "alibaba lowcode editor test plugin", | ||
"files": [ | ||
"es", | ||
"lib" | ||
], | ||
"main": "lib/index.js", | ||
"module": "es/index.js", | ||
"scripts": { | ||
"start": "build-scripts start", | ||
"build": "build-scripts build", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"keywords": [ | ||
"lowcode", | ||
"editor" | ||
], | ||
"dependencies": { | ||
"@alilc/lowcode-utils": "^1.0.0", | ||
"@alilc/lowcode-types": "^1.1.9", | ||
"react": "^16.8.1", | ||
"react-dom": "^16.8.1" | ||
}, | ||
"devDependencies": { | ||
"@alib/build-scripts": "^0.1.3", | ||
"@alilc/build-plugin-alt": "^1.0.1", | ||
"@alilc/lowcode-engine": "^1.0.0", | ||
"@types/react": "^16.9.13", | ||
"@types/react-dom": "^16.9.4", | ||
"build-plugin-fusion": "^0.1.22", | ||
"build-plugin-moment-locales": "^0.1.0" | ||
}, | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org/", | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/alibaba/lowcode-plugins.git", | ||
"directory": "packages/plugin-undo-redo" | ||
} | ||
} |
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,115 @@ | ||
import React, { PureComponent } from 'react'; | ||
import { project } from '@alilc/lowcode-engine'; | ||
import { Button, Icon } from '@alifd/next'; | ||
import { PluginProps, IPublicTypeDisposable } from '@alilc/lowcode-types'; | ||
|
||
export interface IProps extends PluginProps { | ||
logo?: string; | ||
} | ||
|
||
export interface IState { | ||
undoEnable: boolean; | ||
redoEnable: boolean; | ||
} | ||
|
||
class Test extends PureComponent<IProps, IState> { | ||
static displayName = 'Test'; | ||
|
||
private history: any; | ||
private changeDocumentDispose?: IPublicTypeDisposable; | ||
private changeStateDispose?: IPublicTypeDisposable; | ||
constructor(props: any) { | ||
super(props); | ||
this.state = { | ||
undoEnable: false, | ||
redoEnable: false, | ||
}; | ||
this.init(); | ||
} | ||
|
||
init = (): void => { | ||
this.changeDocumentDispose = project.onChangeDocument(doc => { | ||
this.history = doc.history; | ||
this.updateState(this.history?.getState() || 0); | ||
this.changeStateDispose?.(); | ||
this.changeStateDispose = this.history.onChangeState(() => { | ||
this.updateState(this.history?.getState() || 0); | ||
}); | ||
}); | ||
}; | ||
|
||
updateState = (state: number): void => { | ||
this.setState({ | ||
undoEnable: !!(state & 1), | ||
redoEnable: !!(state & 2), | ||
}); | ||
}; | ||
|
||
handleUndoClick = (): void => { | ||
this.history.back(); | ||
}; | ||
|
||
handleRedoClick = (): void => { | ||
this.history.forward(); | ||
}; | ||
|
||
componentWillUnmount() { | ||
this.changeDocumentDispose?.(); | ||
this.changeStateDispose?.(); | ||
} | ||
|
||
render(): React.ReactNode { | ||
const { undoEnable, redoEnable } = this.state; | ||
return ( | ||
<div className="lowcode-plugin-undo-redo"> | ||
<Button | ||
size="medium" | ||
data-tip="撤销" | ||
data-dir="bottom" | ||
onClick={this.handleUndoClick} | ||
ghost | ||
disabled={!undoEnable} | ||
> | ||
<Icon type="houtui" /> | ||
</Button> | ||
<Button | ||
size="medium" | ||
data-tip="恢复" | ||
data-dir="bottom" | ||
onClick={this.handleRedoClick} | ||
ghost | ||
disabled={!redoEnable} | ||
> | ||
<Icon type="qianjin" /> | ||
</Button> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
const plugin = (ctx: any) => { | ||
return { | ||
// 插件名,注册环境下唯一 | ||
name: 'PluginTest', | ||
// 依赖的插件(插件名数组) | ||
dep: [], | ||
// 插件的初始化函数,在引擎初始化之后会立刻调用 | ||
init() { | ||
// 往引擎增加面板 | ||
ctx.skeleton.add({ | ||
area: 'topArea', | ||
type: 'Widget', | ||
name: 'undoRedo', | ||
content: Test, | ||
props: { | ||
align: 'right', | ||
width: 88, | ||
}, | ||
}) | ||
}, | ||
}; | ||
}; | ||
|
||
plugin.pluginName = 'PluginTest' | ||
|
||
export default plugin |
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 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "lib" | ||
}, | ||
"include": [ | ||
"./src/" | ||
] | ||
} |