From 25ed0c59979f72a19681477dcf829699a64baa45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=98=E7=9A=AE?= Date: Tue, 15 Mar 2022 09:38:38 +0800 Subject: [PATCH 001/166] Update popup.tsx fix: update http to https --- packages/plugin-manual/src/popup.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/plugin-manual/src/popup.tsx b/packages/plugin-manual/src/popup.tsx index e04d9bc..a24981c 100644 --- a/packages/plugin-manual/src/popup.tsx +++ b/packages/plugin-manual/src/popup.tsx @@ -12,7 +12,7 @@ export function Documents() { useEffect(() => { setLoading(true) - fetch('http://lowcode-engine.cn/api/get_usage') + fetch('https://lowcode-engine.cn/api/get_usage') .then((res) => res.json()) .then((val) => { const menu = val.data.filter((a: any) => !isNaN(parseInt(a.title))) @@ -58,7 +58,7 @@ export function Documents() { )} onClick={() => { - window.open('http://lowcode-engine.cn/doc') + window.open('https://lowcode-engine.cn/doc') }} /> )} onClick={() => { - window.open('http://lowcode-engine.cn/doc?url=engine-ext-changelog') + window.open('https://lowcode-engine.cn/doc?url=engine-ext-changelog') }} /> Date: Fri, 15 Apr 2022 10:30:23 +0800 Subject: [PATCH 002/166] refactor: use a new pane name to prevent conflicting with the plugin default pane name --- .github/CODEOWNERS | 14 ++++++++++++++ packages/plugin-manual/package.json | 2 +- packages/plugin-manual/src/index.tsx | 6 +++--- 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..802307d --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,14 @@ +# ref: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners + +# These owners will be the default owners for everything in +# the repo. Unless a later match takes precedence +* @leoyuan @alvarto + +/packages/plugin-manual/ @alvarto +/packages/base-monaco-editor/ @alvarto +/packages/plugin-code-editor/ @alvarto +/packages/plugin-schema/ @alvarto +/packages/plugin-components-pane/ @mark-ck +/packages/plugin-datasource-pane/ @xingmolu +/packages/plugin-zh-en/ @leoyuan +/packages/plugin-undo-redo/ @leoyuan diff --git a/packages/plugin-manual/package.json b/packages/plugin-manual/package.json index 687eaf2..0442c29 100644 --- a/packages/plugin-manual/package.json +++ b/packages/plugin-manual/package.json @@ -1,7 +1,7 @@ { "name": "@alilc/lowcode-plugin-manual", "author": "humphry.huang9@gmail.com", - "version": "1.0.2", + "version": "1.0.3", "description": "低代码产品使用手册", "main": "lib/index.js", "module": "es/index.js", diff --git a/packages/plugin-manual/src/index.tsx b/packages/plugin-manual/src/index.tsx index b0b28d6..2c90773 100644 --- a/packages/plugin-manual/src/index.tsx +++ b/packages/plugin-manual/src/index.tsx @@ -12,14 +12,14 @@ const PluginManual = (ctx: ILowCodePluginContext) => { dep: [], // 插件对外暴露的数据和方法 exports() { - return { } + return {}; }, // 插件的初始化函数,在引擎初始化之后会立刻调用 init() { // 往引擎增加面板 ctx.skeleton.add({ area: 'leftArea', - name: 'demoPane', + name: 'manualPane', type: 'PanelDock', props: { align: 'bottom', @@ -36,7 +36,7 @@ const PluginManual = (ctx: ILowCodePluginContext) => { width: window.innerWidth - 300, }, footer: false, - }) + }); }, }, }); From 302ee4be1aa3ee3d8aed382abf724e02b8972c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E7=A6=85?= Date: Tue, 19 Apr 2022 22:06:08 +0800 Subject: [PATCH 003/166] feat: add plugin and action for block management --- README.md | 2 + packages/action-block/.gitignore | 104 ++++++++++++++++++ packages/action-block/README.md | 46 ++++++++ packages/action-block/build.json | 17 +++ packages/action-block/package.json | 26 +++++ packages/action-block/src/index.scss | 11 ++ packages/action-block/src/index.tsx | 119 +++++++++++++++++++++ packages/plugin-block/.gitignore | 104 ++++++++++++++++++ packages/plugin-block/README.md | 46 ++++++++ packages/plugin-block/build.json | 17 +++ packages/plugin-block/package.json | 26 +++++ packages/plugin-block/src/card/index.scss | 32 ++++++ packages/plugin-block/src/card/index.tsx | 26 +++++ packages/plugin-block/src/index.tsx | 47 ++++++++ packages/plugin-block/src/pane/index.scss | 13 +++ packages/plugin-block/src/pane/index.tsx | 124 ++++++++++++++++++++++ packages/plugin-block/src/store/index.ts | 30 ++++++ 17 files changed, 790 insertions(+) create mode 100644 packages/action-block/.gitignore create mode 100644 packages/action-block/README.md create mode 100644 packages/action-block/build.json create mode 100644 packages/action-block/package.json create mode 100644 packages/action-block/src/index.scss create mode 100644 packages/action-block/src/index.tsx create mode 100644 packages/plugin-block/.gitignore create mode 100644 packages/plugin-block/README.md create mode 100644 packages/plugin-block/build.json create mode 100644 packages/plugin-block/package.json create mode 100644 packages/plugin-block/src/card/index.scss create mode 100644 packages/plugin-block/src/card/index.tsx create mode 100644 packages/plugin-block/src/index.tsx create mode 100644 packages/plugin-block/src/pane/index.scss create mode 100644 packages/plugin-block/src/pane/index.tsx create mode 100644 packages/plugin-block/src/store/index.ts diff --git a/README.md b/README.md index d23206e..c71cea3 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,5 @@ - plugin-schema - plugin-undo-redo - plugin-zh-cn +- plugin-block +- action-block diff --git a/packages/action-block/.gitignore b/packages/action-block/.gitignore new file mode 100644 index 0000000..77dfbd1 --- /dev/null +++ b/packages/action-block/.gitignore @@ -0,0 +1,104 @@ +# project custom +build +dist +lib +es +package-lock.json +yarn.lock +deploy-space/packages +deploy-space/.env + + +# IDE +.vscode +.idea + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release +lib + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# mac config files +.DS_Store + +# codealike +codealike.json diff --git a/packages/action-block/README.md b/packages/action-block/README.md new file mode 100644 index 0000000..9bda2b0 --- /dev/null +++ b/packages/action-block/README.md @@ -0,0 +1,46 @@ +# 区块管理 - 保存为区块 + +## 区块实体 + +``` + +interface Block { + name: string; + title: string; + schema: string; + screenshot: string; + created_at?: string; + updated_at?: string; +} + +``` + +## 注意 + +使用区块管理需要提前将对应的 API 注册到 engine config 里: + +``` + +interface BlockAPI { + listBlocks: () => Block[]; + createBlock: (Block) => any; +} + +function setupConfig() { + config.set('apiList', { + block: { + listBlocks, + createBlock + }, + }) +} +``` + +# 使用方式 + +``` +import { material } from '@alilc/lowcode-engine'; +import { default as saveAsBlock } from '@alilc/action-block'; + +material.addBuiltinComponentAction(saveAsBlock); +``` \ No newline at end of file diff --git a/packages/action-block/build.json b/packages/action-block/build.json new file mode 100644 index 0000000..d2836c1 --- /dev/null +++ b/packages/action-block/build.json @@ -0,0 +1,17 @@ +{ + "externals": { + "react": "var window.React", + "@alifd/next": "var window.Next", + "@alilc/lowcode-engine": "var window.AliLowCodeEngine" + }, + "plugins": [ + "build-plugin-component", + "build-plugin-fusion", + [ + "build-plugin-moment-locales", + { + "locales": ["zh-cn"] + } + ] + ] +} diff --git a/packages/action-block/package.json b/packages/action-block/package.json new file mode 100644 index 0000000..25e37fa --- /dev/null +++ b/packages/action-block/package.json @@ -0,0 +1,26 @@ +{ + "name": "@alilc/action-block", + "version": "1.0.0-beta.0", + "description": "", + "main": "lib/index.js", + "scripts": { + "start": "build-scripts start", + "build": "build-scripts build", + "prepublishOnly": "npm run build" + }, + "author": "mark.ck", + "license": "MIT", + "dependencies": { + "@alifd/next": "^1.25.31", + "@alilc/lowcode-engine": "^1.0.5", + "html2canvas": "^1.4.1", + "react": "^16.8.1" + }, + "devDependencies": { + "@alib/build-scripts": "^0.1.32", + "build-plugin-component": "^1.10.0", + "build-plugin-fusion": "^0.1.22", + "build-plugin-moment-locales": "^0.1.3" + }, + "homepage": "https://unpkg.com/@alilc/action-block@1.0.0-beta.0/build/index.html" +} diff --git a/packages/action-block/src/index.scss b/packages/action-block/src/index.scss new file mode 100644 index 0000000..1f019fb --- /dev/null +++ b/packages/action-block/src/index.scss @@ -0,0 +1,11 @@ +.block-screenshot { + background: gainsboro; + display: flex; + justify-content: center; + align-items: center; + padding: 10px 0; + + img { + max-width: 80%; + } +} \ No newline at end of file diff --git a/packages/action-block/src/index.tsx b/packages/action-block/src/index.tsx new file mode 100644 index 0000000..02e69eb --- /dev/null +++ b/packages/action-block/src/index.tsx @@ -0,0 +1,119 @@ +import * as React from 'react'; +import { default as html2canvas } from 'html2canvas'; +import { Node, config, event } from '@alilc/lowcode-engine'; +import { Dialog, Form, Input } from '@alifd/next'; +import './index.scss'; + +const FormItem = Form.Item; + +interface SaveAsBlockProps { + node: Node; +} + +function checkBlockAPI () { + const apiList = config.get('apiList') || {}; + const { block: blockAPI } = apiList; + + if (!blockAPI?.createBlock) { + throw new Error('[BlockPane] block api required in engine config.'); + } + + return blockAPI; +} + +let dialog: any; + +const SaveAsBlock = (props: SaveAsBlockProps) => { + const { createBlock } = checkBlockAPI(); + const { node } = props; + const [ src, setSrc ] = React.useState(); + React.useEffect(() => { + const generateImage = async () => { + let dom2 = node.getDOMNode(); + console.log('html2canvas: ', html2canvas); + const canvas = await html2canvas?.(dom2, { scale: 0.5 }); + const dataUrl = canvas.toDataURL(); + setSrc(dataUrl); + }; + + generateImage(); + }, []); + + const save = async (values) => { + const { name, title } = values; + const { schema } = node; + + await createBlock({ + name, + title, + schema: JSON.stringify(schema), + screenshot: src, + }); + dialog?.hide(); + event.emit('BlockChanged'); + } + + return
+
+ + + + + + + +
+ + +
+ +
+ + + 保存 + + 重置 + +
+
+} + + +export default { + name: 'add', + content: { + icon: { + type: 'add', + size: 'xs' + }, + title: '新增', + action(node: Node) { + console.log('node: ', node); + dialog = Dialog.show({ + v2: true, + title: "保存为区块", + content: , + footer: false + }); + }, + }, + important: true, +}; \ No newline at end of file diff --git a/packages/plugin-block/.gitignore b/packages/plugin-block/.gitignore new file mode 100644 index 0000000..77dfbd1 --- /dev/null +++ b/packages/plugin-block/.gitignore @@ -0,0 +1,104 @@ +# project custom +build +dist +lib +es +package-lock.json +yarn.lock +deploy-space/packages +deploy-space/.env + + +# IDE +.vscode +.idea + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release +lib + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# mac config files +.DS_Store + +# codealike +codealike.json diff --git a/packages/plugin-block/README.md b/packages/plugin-block/README.md new file mode 100644 index 0000000..a339eb8 --- /dev/null +++ b/packages/plugin-block/README.md @@ -0,0 +1,46 @@ +# 区块管理 - 区块面板 + +## 区块实体 + +``` + +interface Block { + name: string; + title: string; + schema: string; + screenshot: string; + created_at?: string; + updated_at?: string; +} + +``` + +## 注意 + +使用区块管理需要提前将对应的 API 注册到 engine config 里: + +``` + +interface BlockAPI { + listBlocks: () => Block[]; + createBlock: (Block) => any; +} + +function setupConfig() { + config.set('apiList', { + block: { + listBlocks, + createBlock + }, + }) +} +``` + +# 使用方式 + +``` +import { plugins } from '@alilc/lowcode-engine'; +import BlockPane from '@alilc/lowcode-plugin-block'; + +await plugins.register(BlockPane); +``` \ No newline at end of file diff --git a/packages/plugin-block/build.json b/packages/plugin-block/build.json new file mode 100644 index 0000000..d2836c1 --- /dev/null +++ b/packages/plugin-block/build.json @@ -0,0 +1,17 @@ +{ + "externals": { + "react": "var window.React", + "@alifd/next": "var window.Next", + "@alilc/lowcode-engine": "var window.AliLowCodeEngine" + }, + "plugins": [ + "build-plugin-component", + "build-plugin-fusion", + [ + "build-plugin-moment-locales", + { + "locales": ["zh-cn"] + } + ] + ] +} diff --git a/packages/plugin-block/package.json b/packages/plugin-block/package.json new file mode 100644 index 0000000..2c79be7 --- /dev/null +++ b/packages/plugin-block/package.json @@ -0,0 +1,26 @@ +{ + "name": "@alilc/lowcode-plugin-block", + "version": "1.0.0-beta.0", + "description": "", + "main": "lib/index.js", + "scripts": { + "start": "build-scripts start", + "build": "build-scripts build", + "prepublishOnly": "npm run build" + }, + "author": "mark.ck", + "license": "MIT", + "dependencies": { + "@alifd/next": "^1.25.31", + "@alilc/lowcode-engine": "^1.0.5", + "html2canvas": "^1.4.1", + "react": "^16.8.1" + }, + "devDependencies": { + "@alib/build-scripts": "^0.1.32", + "build-plugin-component": "^1.10.0", + "build-plugin-fusion": "^0.1.22", + "build-plugin-moment-locales": "^0.1.3" + }, + "homepage": "https://unpkg.com/@alilc/lowcode-plugin-block@1.0.0-beta.0/build/index.html" +} diff --git a/packages/plugin-block/src/card/index.scss b/packages/plugin-block/src/card/index.scss new file mode 100644 index 0000000..63b8052 --- /dev/null +++ b/packages/plugin-block/src/card/index.scss @@ -0,0 +1,32 @@ +.block-card { + display: flex; + flex-direction: column; + padding: 14px; + align-items: center; + justify-content: space-between; + width: 50%; + height: 150px; + flex-grow: 0; + flex-shrink: 0; + border-right: 1px solid #eaeaea; + border-top: 1px solid #eaeaea; + border-bottom: 1px solid #eaeaea; + box-shadow: 0 0 0 0 rgb(0 0 0 / 15%); + transition: box-shadow 0.2s ease; + + .next-divider-hoz { + margin-bottom: 0 !important; + } + + .block-card-screenshot { + display: flex; + padding: 10px; + background: gainsboro; + img { + width: 56px; + height: 56px; + object-fit: contain; + } + } + +} \ No newline at end of file diff --git a/packages/plugin-block/src/card/index.tsx b/packages/plugin-block/src/card/index.tsx new file mode 100644 index 0000000..263d962 --- /dev/null +++ b/packages/plugin-block/src/card/index.tsx @@ -0,0 +1,26 @@ +import * as React from 'react'; + +import './index.scss'; + +const { useState, useEffect } = React; + +interface BlockCardProps { + id: string; + title: string; + screenshot: string; +} + +const BlockCard = (props: BlockCardProps) => { + const { id, title, screenshot='https://tianshu.alicdn.com/19307bb5-2881-44ad-82d3-f92e2f44aabb.png' } = props; + + return
+
+ +
+ + {title} + +
; +}; + +export default BlockCard; \ No newline at end of file diff --git a/packages/plugin-block/src/index.tsx b/packages/plugin-block/src/index.tsx new file mode 100644 index 0000000..afd3b29 --- /dev/null +++ b/packages/plugin-block/src/index.tsx @@ -0,0 +1,47 @@ +import * as React from 'react'; +import { ILowCodePluginContext } from '@alilc/lowcode-engine'; +import { default as BlockPane } from './pane'; + +const LowcodePluginCusPlugin = (ctx: ILowCodePluginContext) => { + return { + // 插件名,注册环境下唯一 + name: 'LowcodePluginCusPlugin', + // 依赖的插件(插件名数组) + dep: [], + // 插件对外暴露的数据和方法 + exports() { + return { + data: '你可以把插件的数据这样对外暴露', + func: () => { + console.log('方法也是一样'); + }, + } + }, + // 插件的初始化函数,在引擎初始化之后会立刻调用 + init() { + // 你可以拿到其他插件暴露的方法和属性 + // const { data, func } = ctx.plugins.pluginA; + // func(); + + // console.log(options.name); + + // 往引擎增加面板 + ctx.skeleton.add({ + area: 'leftArea', + name: 'blockPane', + type: 'PanelDock', + props: { + icon: , + description: '区块面板', + }, + content: BlockPane, + }); + + ctx.logger.log('打个日志'); + }, + }; +}; + +LowcodePluginCusPlugin.pluginName = 'BlockPlugin'; + +export default LowcodePluginCusPlugin; diff --git a/packages/plugin-block/src/pane/index.scss b/packages/plugin-block/src/pane/index.scss new file mode 100644 index 0000000..e576c4d --- /dev/null +++ b/packages/plugin-block/src/pane/index.scss @@ -0,0 +1,13 @@ +.block-pane { + overflow-y: scroll; + height: 100%; +} + +.block-pane-loading { + width: 100%; + height: 100%; + display: flex; + justify-content: center; + align-items: center; +} + diff --git a/packages/plugin-block/src/pane/index.tsx b/packages/plugin-block/src/pane/index.tsx new file mode 100644 index 0000000..3f2f6cd --- /dev/null +++ b/packages/plugin-block/src/pane/index.tsx @@ -0,0 +1,124 @@ +import * as React from 'react'; + +import { common, project, config, event } from '@alilc/lowcode-engine'; +import { Loading, Box } from '@alifd/next'; + +import { default as BlockCard } from '../card'; +import { default as store } from '../store'; + +import './index.scss'; + +const { useState, useEffect } = React; + +const DEFAULT_SCREENSHOT = 'https://tianshu.alicdn.com/19307bb5-2881-44ad-82d3-f92e2f44aabb.png'; + +function checkBlockAPI() { + const apiList = config.get('apiList') || {}; + const { block: blockAPI } = apiList; + + if (!blockAPI?.listBlocks) { + throw new Error('[BlockPane] block api required in engine config.'); + } + + return blockAPI; +} + +export interface Block { + +} + +export interface BlockResponse { + code: number; + data: Block[]; +} + +export interface BlockPaneAPI { + listBlocks: () => BlockResponse; +} + +export interface BlockPaneProps { + api: BlockPaneAPI +} + +export const BlockPane = (props: BlockPaneProps) => { + const { listBlocks } = checkBlockAPI(); + const [ blocks, setBlocks ] = useState(); + useEffect(() => { + const fetchBlocks = async () => { + const res = await listBlocks(); + store.init(res); + setBlocks(res); + }; + event.on('common:BlockChanged', () => { + fetchBlocks(); + }) + fetchBlocks(); + + }, []); + + const registerAdditive = (shell: HTMLDivElement | null) => { + console.log('shell: ', shell); + if (!shell || shell.dataset.registered) { + return; + } + + function getSnippetId(elem: any) { + if (!elem) { + return null; + } + while (shell !== elem) { + console.log('elem.classList; ', elem.classList); + if (elem.classList.contains('snippet')) { + return elem.dataset.id; + } + elem = elem.parentNode; + } + return null; + } + + const _dragon = common.designerCabin.dragon + console.log('_dragon: ', _dragon); + if (!_dragon) { + return; + } + + // eslint-disable-next-line + const click = (e: Event) => {}; + + shell.addEventListener('click', click); + + _dragon.from(shell, (e: Event) => { + const doc = project.getCurrentDocument(); + const id = getSnippetId(e.target); + console.log('doc: ', doc); + console.log('id: ', id); + if (!doc || !id) { + return false; + } + + console.log('store.get(id): ', store.get(id)); + + const dragTarget = { + type: 'nodedata', + data: store.get(id), + }; + + return dragTarget; + }); + + shell.dataset.registered = 'true'; + }; + + if (!blocks?.length) { + return
+ } + + return
+ { + blocks.map(item => ) + } + +
; +} + +export default BlockPane; \ No newline at end of file diff --git a/packages/plugin-block/src/store/index.ts b/packages/plugin-block/src/store/index.ts new file mode 100644 index 0000000..140bc53 --- /dev/null +++ b/packages/plugin-block/src/store/index.ts @@ -0,0 +1,30 @@ + + +class BlockStore { + + store; + + constructor() { + this.store = new Map(); + } + + init(blocks) { + blocks.forEach(block => { + const { id, schema } = block; + this.store.set(`${id}`, JSON.parse(schema)); + }); + } + + set(id, snippets) { + this.store.set(id, snippets); + } + + get(id) { + return this.store.get(id); + } + +} + +const singleton = new BlockStore(); + +export default singleton; \ No newline at end of file From 23af4b7fba68b594a91668516478ca569501d9b4 Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Tue, 26 Apr 2022 15:54:50 +0800 Subject: [PATCH 004/166] fix: plugin-schema export issue --- packages/plugin-schema/CHANGELOG.md | 4 ++++ packages/plugin-schema/package.json | 2 +- packages/plugin-schema/src/editor.tsx | 7 ++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/plugin-schema/CHANGELOG.md b/packages/plugin-schema/CHANGELOG.md index 95b1893..e81f8fd 100644 --- a/packages/plugin-schema/CHANGELOG.md +++ b/packages/plugin-schema/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.1 / 2022-04-26 + +* Fix [schema export issue](https://github.com/alibaba/lowcode-engine/issues/367) + ## 1.0.0 / 2022-02-16 * publish following changes diff --git a/packages/plugin-schema/package.json b/packages/plugin-schema/package.json index fde7d55..4aab007 100644 --- a/packages/plugin-schema/package.json +++ b/packages/plugin-schema/package.json @@ -1,7 +1,7 @@ { "name": "@alilc/lowcode-plugin-schema", "author": "alvarto", - "version": "1.0.0", + "version": "1.0.1", "description": "Show schema in lowcode editor", "files": [ "es", diff --git a/packages/plugin-schema/src/editor.tsx b/packages/plugin-schema/src/editor.tsx index 0c65026..e66dedf 100644 --- a/packages/plugin-schema/src/editor.tsx +++ b/packages/plugin-schema/src/editor.tsx @@ -4,6 +4,7 @@ import MonacoEditor from '@alilc/lowcode-plugin-base-monaco-editor'; import { Dialog, Message, Button } from '@alifd/next'; +import { common } from '@alilc/lowcode-engine' import { Project, Skeleton, Event } from '@alilc/lowcode-shell'; import { IEditorInstance } from '@alilc/lowcode-plugin-base-monaco-editor/lib/helper'; @@ -16,7 +17,7 @@ interface PluginCodeDiffProps { export default function PluginSchema({ project, skeleton, event }: PluginCodeDiffProps) { const [editorSize, setEditorSize] = useState({ width: 0, height: 0 }); const [schemaValue, setSchemaValue] = useState(() => { - const schema = project.exportSchema() + const schema = project.exportSchema(common.designerCabin.TransformStage.Save) return schema?.componentsTree?.[0] ? JSON.stringify(schema.componentsTree[0], null, 2) : '' }); const monacoEditorRef = useRef(); @@ -31,7 +32,7 @@ export default function PluginSchema({ project, skeleton, event }: PluginCodeDif useEffect(() => { event.on('skeleton.panel-dock.active', (pluginName) => { if (pluginName == 'LowcodePluginAliLowcodePluginSchema') { - const schema = project.exportSchema() + const schema = project.exportSchema(common.designerCabin.TransformStage.Save) const str = schema?.componentsTree?.[0] ? JSON.stringify(schema.componentsTree[0], null, 2) : '' setSchemaValue(str); } @@ -60,7 +61,7 @@ export default function PluginSchema({ project, skeleton, event }: PluginCodeDif } project.importSchema({ - ...project.exportSchema(), + ...project.exportSchema(common.designerCabin.TransformStage.Save), componentsTree: [json], }); Message.success('Schema Saved!'); From 02ccfcca9b9eac51414f612077c072ea551cd654 Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Thu, 5 May 2022 17:04:19 +0800 Subject: [PATCH 005/166] fix: schema export issue --- packages/plugin-code-editor/CHANGELOG.md | 4 ++++ packages/plugin-code-editor/package.json | 2 +- .../plugin-code-editor/src/pane/index.tsx | 23 ++++++++++--------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/packages/plugin-code-editor/CHANGELOG.md b/packages/plugin-code-editor/CHANGELOG.md index 6784156..2833853 100644 --- a/packages/plugin-code-editor/CHANGELOG.md +++ b/packages/plugin-code-editor/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.2 / 2022-05-05 + +* Fix [schema export issue](https://github.com/alibaba/lowcode-engine/issues/416) + ## 1.0.1 - 修正和 ext 的联动 diff --git a/packages/plugin-code-editor/package.json b/packages/plugin-code-editor/package.json index 9b6de0b..4efc22f 100644 --- a/packages/plugin-code-editor/package.json +++ b/packages/plugin-code-editor/package.json @@ -1,7 +1,7 @@ { "name": "@alilc/lowcode-plugin-code-editor", "author": "59174526@qq.com & humphry.huang9@gmail.com", - "version": "1.0.1", + "version": "1.0.2", "description": "CodeEditor", "files": [ "es", diff --git a/packages/plugin-code-editor/src/pane/index.tsx b/packages/plugin-code-editor/src/pane/index.tsx index 917832a..6f229b5 100644 --- a/packages/plugin-code-editor/src/pane/index.tsx +++ b/packages/plugin-code-editor/src/pane/index.tsx @@ -4,6 +4,7 @@ import { Dialog, Message } from '@alifd/next'; import { JsEditor, CssEditor } from '../components'; import { schema2JsCode, schema2CssCode } from '../utils'; import { WORDS, TAB_KEY } from '../config'; +import { common } from '@alilc/lowcode-engine'; import { FunctionEventParams } from '../types'; import { Project, Event, Skeleton } from '@alilc/lowcode-shell'; @@ -27,7 +28,7 @@ export const CodeEditorPane = memo(({ project, event, skeleton }: CodeEditorPane const cssEditorRef = useRef(null); const saveSchemaRef = useRef<() => void>(); // save code to schema - const [schema, setSchema] = useState(() => project.exportSchema()); + const [schema, setSchema] = useState(() => project.exportSchema(common.designerCabin.TransformStage.Save)); const jsCode = useMemo(() => { return schema2JsCode(schema); @@ -40,7 +41,7 @@ export const CodeEditorPane = memo(({ project, event, skeleton }: CodeEditorPane useEffect(() => { saveSchemaRef.current = () => { try { - const currentSchema = lowcodeProjectRef.current?.exportSchema(); + const currentSchema = lowcodeProjectRef.current?.exportSchema(common.designerCabin.TransformStage.Save); const pageNode = currentSchema.componentsTree[0]; const { state, methods, lifeCycles, originCode = '' } = jsEditorRef.current?.getSchemaFromCode() ?? {}; const css = cssEditorRef.current?.getBeautifiedCSS() ?? cssCode; @@ -48,7 +49,7 @@ export const CodeEditorPane = memo(({ project, event, skeleton }: CodeEditorPane pageNode.methods = methods; pageNode.lifeCycles = lifeCycles; pageNode.originCode = originCode; - + pageNode.css = css; lowcodeProjectRef.current?.importSchema(currentSchema); @@ -69,7 +70,7 @@ export const CodeEditorPane = memo(({ project, event, skeleton }: CodeEditorPane ), onOk: () => { - skeletonRef.current?.showPanel("codeEditor") + skeletonRef.current?.showPanel('codeEditor'); }, }); } @@ -94,8 +95,8 @@ export const CodeEditorPane = memo(({ project, event, skeleton }: CodeEditorPane useEffect(() => { // load schema on open eventRef.current?.on('skeleton.panel-dock.active', (pluginName) => { - if (pluginName == 'codeEditor') { - const schema = lowcodeProjectRef.current?.exportSchema() + if (pluginName === 'codeEditor') { + const schema = lowcodeProjectRef.current?.exportSchema(common.designerCabin.TransformStage.Save); if (!schema) { return; } @@ -106,7 +107,7 @@ export const CodeEditorPane = memo(({ project, event, skeleton }: CodeEditorPane cssEditorRef.current?._updateCode(cssCode); } }); - + // save schema when panel closed eventRef.current?.on('skeleton.panel-dock.unactive', (pluginName) => { if (pluginName === 'codeEditor') { @@ -115,17 +116,17 @@ export const CodeEditorPane = memo(({ project, event, skeleton }: CodeEditorPane }); // focus function by functionName - eventRef.current?.on('common:codeEditor.focusByFunction', (params: FunctionEventParams) => { + eventRef.current?.on('common:codeEditor.focusByFunction', (params) => { setActiveKey(TAB_KEY.JS); setTimeout(() => { - jsEditorRef.current?.focusByFunctionName(params); + jsEditorRef.current?.focusByFunctionName(params as FunctionEventParams); }, 100); }); - eventRef.current?.on('common:codeEditor.addFunction', (params: FunctionEventParams) => { + eventRef.current?.on('common:codeEditor.addFunction', (params) => { setActiveKey(TAB_KEY.JS); setTimeout(() => { - jsEditorRef.current?.addFunction(params); + jsEditorRef.current?.addFunction(params as FunctionEventParams); }, 100); }); }, []); From 55bf1d66ddac1c5840e0cdae902406dd715b6e5d Mon Sep 17 00:00:00 2001 From: twinkle77 <2153165927@qq.com> Date: Tue, 10 May 2022 11:58:44 +0800 Subject: [PATCH 006/166] chore: upgrade lowcode-engine version --- demo/public/index.html | 4 ++-- package.json | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/demo/public/index.html b/demo/public/index.html index 8ef9ceb..9695d3d 100644 --- a/demo/public/index.html +++ b/demo/public/index.html @@ -29,9 +29,9 @@ - + - + diff --git a/package.json b/package.json index c4dfabc..58231d4 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ ] }, "scripts": { + "bootstrap": "lerna bootstrap", "dev": "npm run bootstrap && npm run build && cooking watch -c build/cooking.demo.js -p", "build": "./scripts/build.sh", "clean": "rm -rf ./packages/*/lib ./packages/*/es ./packages/*/dist ./packages/*/build", From a0033a0b0f178a20e1dfa1d5670c4c3e2a6967ca Mon Sep 17 00:00:00 2001 From: twinkle77 <2153165927@qq.com> Date: Tue, 10 May 2022 12:09:19 +0800 Subject: [PATCH 007/166] fix: dataSource pane export schema --- .../plugin-datasource-pane/src/classname-setter/index.tsx | 3 ++- .../src/components/ClassNameView/ClassNameView.tsx | 4 ++-- packages/plugin-datasource-pane/src/pane/index.tsx | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/plugin-datasource-pane/src/classname-setter/index.tsx b/packages/plugin-datasource-pane/src/classname-setter/index.tsx index f515751..c86e79f 100644 --- a/packages/plugin-datasource-pane/src/classname-setter/index.tsx +++ b/packages/plugin-datasource-pane/src/classname-setter/index.tsx @@ -1,6 +1,7 @@ import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { Select } from '@alifd/next'; +import { common } from '@alilc/lowcode-engine'; interface Color { rgb: any; @@ -27,7 +28,7 @@ export default class ClassNameView extends PureComponent { getClassNameList = () => { const { project } = this.context; - const schema = project.exportSchema(); + const schema = project.exportSchema(common.designerCabin.TransformStage.Save); const { css } = schema.componentsTree[0]; const classNameList = []; const re = /\.?\w+[^{]+\{[^}]*\}/g; diff --git a/packages/plugin-datasource-pane/src/components/ClassNameView/ClassNameView.tsx b/packages/plugin-datasource-pane/src/components/ClassNameView/ClassNameView.tsx index ece734e..2e5f1da 100644 --- a/packages/plugin-datasource-pane/src/components/ClassNameView/ClassNameView.tsx +++ b/packages/plugin-datasource-pane/src/components/ClassNameView/ClassNameView.tsx @@ -1,7 +1,7 @@ import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { Select } from '@alifd/next'; - +import { common } from '@alilc/lowcode-engine'; export interface PluginProps { value: string; @@ -30,7 +30,7 @@ export default class ClassNameView extends PureComponent { const { project } = this.context; - const schema = project.exportSchema(); + const schema = project.exportSchema(common.designerCabin.TransformStage.Save); const { css } = schema.componentsTree[0]; const classNameList: string[] = []; const re = /\.?\w+[^{]+\{[^}]*\}/g; diff --git a/packages/plugin-datasource-pane/src/pane/index.tsx b/packages/plugin-datasource-pane/src/pane/index.tsx index 3bea392..096463e 100644 --- a/packages/plugin-datasource-pane/src/pane/index.tsx +++ b/packages/plugin-datasource-pane/src/pane/index.tsx @@ -24,6 +24,7 @@ import { isSchemaValid, correctSchema } from '../utils/schema'; import { createStateService } from '../utils/stateMachine'; import { DataSourcePaneContext } from '../utils/panel-context'; import { mergeTwoObjectListByKey } from '../utils/misc'; +import { common } from '@alilc/lowcode-engine'; import './index.scss'; @@ -119,7 +120,7 @@ export default class DataSourcePanePlugin extends PureComponent< handleSchemaChange = (schema: DataSource) => { const { project, onSchemaChange } = this.props; if (project) { - const docSchema = project.exportSchema(); + const docSchema = project.exportSchema(common.designerCabin.TransformStage.Save); if (!_isEmpty(docSchema)) { _set(docSchema, 'componentsTree[0].dataSource', schema); project.importSchema(docSchema); @@ -148,7 +149,7 @@ export default class DataSourcePanePlugin extends PureComponent< if (!active) return null; - const projectSchema = project.exportSchema() ?? {}; + const projectSchema = project.exportSchema(common.designerCabin.TransformStage.Save) ?? {}; let schema = defaultSchema; if (_isFunction(defaultSchema)) { schema = defaultSchema(); From a87525e401764992c6a50bcd34e2cf9f9dddb95e Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Wed, 11 May 2022 18:49:16 +0800 Subject: [PATCH 008/166] chore: bump into next version --- packages/plugin-datasource-pane/CHANGELOG.md | 3 +++ packages/plugin-datasource-pane/package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 packages/plugin-datasource-pane/CHANGELOG.md diff --git a/packages/plugin-datasource-pane/CHANGELOG.md b/packages/plugin-datasource-pane/CHANGELOG.md new file mode 100644 index 0000000..974ad8a --- /dev/null +++ b/packages/plugin-datasource-pane/CHANGELOG.md @@ -0,0 +1,3 @@ +# 1.0.4 + +- fix https://github.com/alibaba/lowcode-engine/issues/466 diff --git a/packages/plugin-datasource-pane/package.json b/packages/plugin-datasource-pane/package.json index ca342a2..344fb2e 100644 --- a/packages/plugin-datasource-pane/package.json +++ b/packages/plugin-datasource-pane/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-plugin-datasource-pane", - "version": "1.0.3", + "version": "1.0.4", "description": "低代码引擎数据源面板", "main": "lib/index.js", "files": [ From 18a31d1d8e82ec0161291cfc67bbdbb945a08dd0 Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Wed, 11 May 2022 18:55:00 +0800 Subject: [PATCH 009/166] chore: bump into next version --- packages/plugin-datasource-pane/CHANGELOG.md | 2 +- packages/plugin-datasource-pane/package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/plugin-datasource-pane/CHANGELOG.md b/packages/plugin-datasource-pane/CHANGELOG.md index 974ad8a..e9adbe0 100644 --- a/packages/plugin-datasource-pane/CHANGELOG.md +++ b/packages/plugin-datasource-pane/CHANGELOG.md @@ -1,3 +1,3 @@ -# 1.0.4 +# 1.0.5 - fix https://github.com/alibaba/lowcode-engine/issues/466 diff --git a/packages/plugin-datasource-pane/package.json b/packages/plugin-datasource-pane/package.json index 344fb2e..6a0d6d4 100644 --- a/packages/plugin-datasource-pane/package.json +++ b/packages/plugin-datasource-pane/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-plugin-datasource-pane", - "version": "1.0.4", + "version": "1.0.5", "description": "低代码引擎数据源面板", "main": "lib/index.js", "files": [ @@ -73,5 +73,5 @@ "traverse": "^0.6.6", "xstate": "^4.26.0" }, - "homepage": "https://unpkg.com/@alilc/lowcode-plugin-datasource-pane@1.0.3/build/index.html" + "homepage": "https://unpkg.com/@alilc/lowcode-plugin-datasource-pane@1.0.4/build/index.html" } From a84252da9332386c2a1caa462cc30f4b00445b3a Mon Sep 17 00:00:00 2001 From: Exodus Date: Wed, 18 May 2022 16:07:33 +0800 Subject: [PATCH 010/166] fix: missing key --- .../src/components/DataSourceListItem/DataSourceListItem.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/plugin-datasource-pane/src/components/DataSourceListItem/DataSourceListItem.tsx b/packages/plugin-datasource-pane/src/components/DataSourceListItem/DataSourceListItem.tsx index ebc4ac8..3707b65 100644 --- a/packages/plugin-datasource-pane/src/components/DataSourceListItem/DataSourceListItem.tsx +++ b/packages/plugin-datasource-pane/src/components/DataSourceListItem/DataSourceListItem.tsx @@ -189,6 +189,7 @@ export class DataSourceListItem extends Component { } return ( Date: Wed, 8 Jun 2022 11:27:34 +0800 Subject: [PATCH 011/166] feat: add simulator select pane --- packages/plugin-simulator-size/.gitignore | 104 ++++++++++++++ packages/plugin-simulator-size/README.md | 0 packages/plugin-simulator-size/build.json | 19 +++ packages/plugin-simulator-size/package.json | 30 ++++ packages/plugin-simulator-size/src/index.scss | 79 ++++++++++ packages/plugin-simulator-size/src/index.tsx | 136 ++++++++++++++++++ packages/plugin-simulator-size/tsconfig.json | 9 ++ 7 files changed, 377 insertions(+) create mode 100644 packages/plugin-simulator-size/.gitignore create mode 100644 packages/plugin-simulator-size/README.md create mode 100644 packages/plugin-simulator-size/build.json create mode 100644 packages/plugin-simulator-size/package.json create mode 100644 packages/plugin-simulator-size/src/index.scss create mode 100644 packages/plugin-simulator-size/src/index.tsx create mode 100644 packages/plugin-simulator-size/tsconfig.json diff --git a/packages/plugin-simulator-size/.gitignore b/packages/plugin-simulator-size/.gitignore new file mode 100644 index 0000000..b1a02c7 --- /dev/null +++ b/packages/plugin-simulator-size/.gitignore @@ -0,0 +1,104 @@ +# project custom +build +dist +lib +es +package-lock.json +yarn.lock +deploy-space/packages +deploy-space/.env + + +# IDE +.vscode +.idea + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# mac config files +.DS_Store + +# codealike +codealike.json +.node diff --git a/packages/plugin-simulator-size/README.md b/packages/plugin-simulator-size/README.md new file mode 100644 index 0000000..e69de29 diff --git a/packages/plugin-simulator-size/build.json b/packages/plugin-simulator-size/build.json new file mode 100644 index 0000000..2123027 --- /dev/null +++ b/packages/plugin-simulator-size/build.json @@ -0,0 +1,19 @@ +{ + "externals": { + "react": "React", + "moment": "moment", + "react-dom": "ReactDOM", + "prop-types": "PropTypes", + "@alifd/next": "Next", + "@alilc/lowcode-engine": "AliLowCodeEngine" + }, + "plugins": [ + [ + "@alilc/build-plugin-alt", + { + "type": "plugin" + } + ], + "build-plugin-component" + ] +} diff --git a/packages/plugin-simulator-size/package.json b/packages/plugin-simulator-size/package.json new file mode 100644 index 0000000..8ca79c6 --- /dev/null +++ b/packages/plugin-simulator-size/package.json @@ -0,0 +1,30 @@ +{ + "name": "@alilc/lowcode-plugin-simulator-select", + "version": "1.0.0", + "description": "画布切换", + "main": "lib/index.js", + "scripts": { + "start": "build-scripts start", + "build": "build-scripts build --skip-demo", + "prepublishOnly": "npm run build", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "lowcode", + "simulator" + ], + "dependencies": { + "@alifd/next": "^1.25.0" + }, + "devDependencies": { + "@alib/build-scripts": "^0.1.18", + "@alilc/build-plugin-alt": "^1.1.0", + "@alilc/lowcode-engine": "^1.0.0", + "@types/react": "^16.8.1", + "build-plugin-component": "^1.1.0", + "react": "^16.8.1", + "react-dom": "^16.8.1" + }, + "author": "mark.ck", + "license": "ISC" +} diff --git a/packages/plugin-simulator-size/src/index.scss b/packages/plugin-simulator-size/src/index.scss new file mode 100644 index 0000000..2944507 --- /dev/null +++ b/packages/plugin-simulator-size/src/index.scss @@ -0,0 +1,79 @@ +.lp-simulator-pane { + display: flex; + align-items: center; + margin: 0 8px; + .lp-simulator-pane-item { + display: inline-block; + width: 32px; + height: 32px; + border-radius: 3px; + padding: 6px; + margin: 0 4px; + cursor: pointer; + &:hover { + svg { + opacity: 1; + } + } + &.actived { + background: #F2F2F2; + } + } + svg { + opacity: 0.6; + } + + .lp-simulator-width-setter { + position: relative; + width: 105px; + height: 32px; + margin-left: 12px; + + .lp-simulator-width-input { + width: 100%; + border: 1px solid hsla(0,0%,100%,.1); + border-radius: 4px; + font-size: 14px; + .next-input.next-medium .next-input-control { + padding-right: 0; + } + } + + } + +} + +// 根据不同的模拟器切换GUI样式 +.lc-simulator { + + .lc-simulator-device-default { + margin: auto; + } + // mobile + .lc-simulator-device-phone { + top: 16px; + bottom: 16px; + left: 50%; + width: 375px; + transform: translateX(-50%); + margin: auto; + } + // pad + .lc-simulator-device-tablet { + top: 16px; + bottom: 16px; + left: 50%; + width: 768px; + transform: translateX(-50%); + margin: auto; + } + // pc + .lc-simulator-device-desktop { + top: 16px; + right: 16px; + bottom: 16px; + left: 16px; + width: auto; + margin: auto; + } +} \ No newline at end of file diff --git a/packages/plugin-simulator-size/src/index.tsx b/packages/plugin-simulator-size/src/index.tsx new file mode 100644 index 0000000..fba2c5b --- /dev/null +++ b/packages/plugin-simulator-size/src/index.tsx @@ -0,0 +1,136 @@ +import React from 'react'; +import { NumberPicker, Icon } from '@alifd/next'; +import { ILowCodePluginContext, project, material } from '@alilc/lowcode-engine'; + +import './index.scss'; + +const isNewEngineVersion = !!material; + +const devices = [ + { key: 'desktop' }, + { key: 'tablet' }, + { key: 'phone' }, +]; + +const CustomIcon = Icon.createFromIconfontCN({ + scriptUrl: 'https://at.alicdn.com/t/font_2896595_33xhsbg9ux5.js', +}); + +export class SimulatorPane extends React.Component { + static displayName = 'SimulatorPane'; + + state = { + actived: 'desktop', + currentWidth: null + }; + + componentDidMount() { + if (isNewEngineVersion) { + project.onSimulatorRendererReady(() => { + const currentWidth = document.querySelector('.lc-simulator-canvas')?.clientWidth || this.state.currentWidth || 0; + this.setState({ + currentWidth + }); + }); + } else { + // 兼容老版本引擎 + // @ts-ignore + project.onRendererReady(() => { + const currentWidth = document.querySelector('.lc-simulator-canvas')?.clientWidth || this.state.currentWidth || 0; + this.setState({ + currentWidth + }); + }); + } + } + + change = (device: string) => { + const simulator = project.simulator; + // 切换画布 + simulator?.set('device', device); + if (document.querySelector('.lc-simulator-canvas')?.style) { + document.querySelector('.lc-simulator-canvas').style.width = null; + } + setTimeout(() => { + const currentWidth = document.querySelector('.lc-simulator-canvas')?.clientWidth || this.state.currentWidth || 0; + this.setState({ + actived: device, + currentWidth + }); + }, 0); + } + + renderItemSVG(device: string) { + switch (device) { + case 'desktop': + return ; + case 'tablet': + return ; + case 'phone': + return ; + default: + return ; + } + } + + render() { + const currentWidth = this.state.currentWidth || 0; + return ( +
+ { + devices.map((item, index) => { + return ( + + {this.renderItemSVG(item.key)} + + ) + }) + } +
+ { + this.setState({ + currentWidth: value + }); + }} onPressEnter={(event: any) => { + const value = event?.target?.value; + if (document.querySelector('.lc-simulator-canvas')?.style) { + document.querySelector('.lc-simulator-canvas').style.width = `${value}px` + } + this.setState({ + currentWidth: value + }); + }} /> +
+
+ ); + } +} +export default (ctx: ILowCodePluginContext) => { + const simulatorPaneRef = React.createRef(); + + return { + name: 'SimulatorPane', + // 插件的初始化函数,在引擎初始化之后会立刻调用 + init() { + // 往引擎增加工具条 + ctx.skeleton.add({ + area: 'top', + name: 'SimulatorPane', + type: 'Widget', + props: { + description: '切换画布尺寸', + align: "center", + }, + content: ( + + ), + }); + } + }; +}; \ No newline at end of file diff --git a/packages/plugin-simulator-size/tsconfig.json b/packages/plugin-simulator-size/tsconfig.json new file mode 100644 index 0000000..c37b76e --- /dev/null +++ b/packages/plugin-simulator-size/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "lib" + }, + "include": [ + "./src/" + ] +} From 58231ea663cdbb1726a05f0b19a0f32c66df93a7 Mon Sep 17 00:00:00 2001 From: jingyu Date: Thu, 9 Jun 2022 15:41:20 +0800 Subject: [PATCH 012/166] =?UTF-8?q?feat:=20monaco=E5=8D=95=E4=BE=8B?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/base-monaco-editor/src/helper.ts | 27 ++++------ packages/base-monaco-editor/src/index.tsx | 2 + packages/base-monaco-editor/src/monaco.ts | 65 +++++++++++++++++++++++ 3 files changed, 78 insertions(+), 16 deletions(-) create mode 100644 packages/base-monaco-editor/src/monaco.ts diff --git a/packages/base-monaco-editor/src/helper.ts b/packages/base-monaco-editor/src/helper.ts index 475f80a..b5927d1 100644 --- a/packages/base-monaco-editor/src/helper.ts +++ b/packages/base-monaco-editor/src/helper.ts @@ -1,12 +1,7 @@ /* eslint-disable no-empty */ import { useEffect, useState, useRef, CSSProperties } from 'react'; import loader from '@monaco-editor/loader'; - -loader.config({ - paths: { - vs: 'https://g.alicdn.com/code/lib/monaco-editor/0.31.1/min/vs', - }, -}); +import { getMonaco } from './monaco'; type IAmbigousFn = (...args: any[]) => any; @@ -52,7 +47,7 @@ export interface IMonacoInstance { [otherKeys: string]: any; } -type ICodeEditorViewState = { +interface ICodeEditorViewState { contributionsState: any; cursorState: any; viewState: any; @@ -154,7 +149,7 @@ export const useEditor = (type: 'single' | 'diff', props: IGeneralManacoEditorPr const editorWillMountRef = useRef(); const decomposeRef = useRef(false); - const viewStatusRef = useRef>(new Map()) + const viewStatusRef = useRef>(new Map()); useEffect(() => { editorDidMountRef.current = editorDidMount; @@ -185,7 +180,7 @@ export const useEditor = (type: 'single' | 'diff', props: IGeneralManacoEditorPr loader.config(requireConfigRef.current); } - loader.init() + getMonaco(requireConfigRef.current) .then((monaco: any) => { // 兼容旧版本 monaco-editor 写死 MonacoEnvironment 的问题 (window as any).MonacoEnvironment = undefined; @@ -209,7 +204,7 @@ export const useEditor = (type: 'single' | 'diff', props: IGeneralManacoEditorPr monaco, valueRef.current ?? defaultValueRef.current ?? '', languageRef.current, - pathRef.current + pathRef.current, ); editor = monaco.editor.create(containerRef.current, { automaticLayout: true, @@ -268,7 +263,7 @@ export const useEditor = (type: 'single' | 'diff', props: IGeneralManacoEditorPr ? editorRef.current.getModifiedEditor() : editorRef.current; - const nextValue = value ?? defaultValueRef.current ?? '' + const nextValue = value ?? defaultValueRef.current ?? ''; if (editor?.getOption?.(monacoRef.current?.editor.EditorOption.readOnly)) { editor?.setValue(nextValue); } else if (value !== editor?.getValue()) { @@ -330,7 +325,7 @@ export const useEditor = (type: 'single' | 'diff', props: IGeneralManacoEditorPr if (valueRef.current !== null && valueRef.current !== undefined && model.getValue() !== valueRef.current) { model.setValue(valueRef.current); } - + if (model !== editorRef.current.getModel()) { saveViewState && viewStatusRef.current.set(previousPath, editorRef.current.saveViewState()); editorRef.current.setModel(model); @@ -365,9 +360,9 @@ function getOrCreateModel(monaco: IMonacoInstance, value?: string, language?: st } function usePrevious(value: T) { - const ref = useRef() + const ref = useRef(); useEffect(() => { - ref.current = value - }, [value]) - return ref.current + ref.current = value; + }, [value]); + return ref.current; } diff --git a/packages/base-monaco-editor/src/index.tsx b/packages/base-monaco-editor/src/index.tsx index e35581c..5aa3877 100644 --- a/packages/base-monaco-editor/src/index.tsx +++ b/packages/base-monaco-editor/src/index.tsx @@ -9,6 +9,8 @@ import { INITIAL_OPTIONS, } from './helper'; +export * from './monaco'; + const SingleMonacoEditor = (props: ISingleMonacoEditorProps) => { const { onChange, enableOutline, width, height, language, supportFullScreen } = props; const onChangeRef = useRef(onChange); diff --git a/packages/base-monaco-editor/src/monaco.ts b/packages/base-monaco-editor/src/monaco.ts new file mode 100644 index 0000000..a3abe25 --- /dev/null +++ b/packages/base-monaco-editor/src/monaco.ts @@ -0,0 +1,65 @@ +import loader, { Monaco } from '@monaco-editor/loader'; +//@ts-ignore +import isEqual from 'lodash/isEqual'; + +export interface Configure { + singleton?: boolean; +} + +const CONFIGURE_KEY = '__base_monaco_editor_config__'; +const fakeWindow: any = window; + +if (!fakeWindow[CONFIGURE_KEY]) { + fakeWindow[CONFIGURE_KEY] = {}; +} + +export const configuration: Configure = fakeWindow[CONFIGURE_KEY]; + +export const getSingletonMonaco = (() => { + let monaco: Monaco; + let prevOptions: any; + return async (options?: any) => { + if (!monaco || !isEqual(prevOptions, options)) { + const hasConfig = Object.keys(options || {}).length > 0; + loader.config( + hasConfig + ? options + : { + paths: { + vs: 'https://g.alicdn.com/code/lib/monaco-editor/0.33.0/min/vs', + }, + }, + ); + // eslint-disable-next-line require-atomic-updates + monaco = await loader.init(); + // eslint-disable-next-line require-atomic-updates + prevOptions = options; + } + return monaco; + }; +})(); + +export const getCommonMonaco = (config: any): Promise => { + if (config) { + loader.config(config); + } else { + loader.config({ + paths: { + vs: 'https://g.alicdn.com/code/lib/monaco-editor/0.31.1/min/vs', + }, + }); + } + return loader.init(); +}; + +export function getMonaco(config: any) { + const hasConfig = Object.keys(config || {}).length > 0; + const monacoConfig = hasConfig ? config : undefined; + return configuration.singleton + ? getSingletonMonaco(monacoConfig) + : getCommonMonaco(monacoConfig); +} + +export function configure(conf: Configure) { + Object.assign(configuration, conf || {}); +} From ff7a0351eb46e5cb4e0bf776069e8b9a30373e4a Mon Sep 17 00:00:00 2001 From: jingyu Date: Thu, 9 Jun 2022 16:58:40 +0800 Subject: [PATCH 013/166] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20controller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/base-monaco-editor/README.md | 18 +++++++++ packages/base-monaco-editor/src/controller.ts | 39 +++++++++++++++++++ packages/base-monaco-editor/src/index.tsx | 1 + packages/base-monaco-editor/src/monaco.ts | 22 ++--------- 4 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 packages/base-monaco-editor/src/controller.ts diff --git a/packages/base-monaco-editor/README.md b/packages/base-monaco-editor/README.md index 0740b37..49473bb 100644 --- a/packages/base-monaco-editor/README.md +++ b/packages/base-monaco-editor/README.md @@ -125,6 +125,24 @@ function App() { ReactDOM.render(, mountNode); ``` +### Using controller + +```ts +import { controller } from '@alilc/lowcode-plugin-base-monaco-editor'; + +// configure Monaco to be singleton +controller.updateMeta({ singleton: true }); + +// Get all metadata +controller.getMeta(); + +// register a custom method +controller.registerMethod('methodName', (a, b, c) => { }); + +// call custom methods +const ret = controller.call('methodName', a, b, c); +``` + ## Citation This is forked from [monaco-react](https://github.com/suren-atoyan/monaco-react). Thanks for [suren-atoyan](https://github.com/suren-atoyan)'s effort for making monaco editor appoachable. diff --git a/packages/base-monaco-editor/src/controller.ts b/packages/base-monaco-editor/src/controller.ts new file mode 100644 index 0000000..2ebe419 --- /dev/null +++ b/packages/base-monaco-editor/src/controller.ts @@ -0,0 +1,39 @@ +export interface EditorMeta { + singleton: boolean; + [key: string]: any; +} + +export class Controller { + private methodMap: Record; + private meta: EditorMeta; + + constructor() { + this.methodMap = {}; + this.meta = { singleton: false }; + } + + registerMethod(name: string, fn: Function) { + this.methodMap[name] = fn; + } + + call(name: string, ...args: any[]) { + return this.methodMap[name]?.(...args); + } + + updateMeta(obj: Partial) { + Object.assign(this.meta, obj); + } + + getMeta() { + return Object.freeze({ ...this.meta }); + } +} + +const CONFIGURE_KEY = '__base_monaco_editor_controller__'; +const fakeWindow: any = window; + +if (!fakeWindow[CONFIGURE_KEY]) { + fakeWindow[CONFIGURE_KEY] = new Controller(); +} + +export const controller: Controller = fakeWindow[CONFIGURE_KEY]; diff --git a/packages/base-monaco-editor/src/index.tsx b/packages/base-monaco-editor/src/index.tsx index 5aa3877..c1f7e9b 100644 --- a/packages/base-monaco-editor/src/index.tsx +++ b/packages/base-monaco-editor/src/index.tsx @@ -10,6 +10,7 @@ import { } from './helper'; export * from './monaco'; +export * from './controller'; const SingleMonacoEditor = (props: ISingleMonacoEditorProps) => { const { onChange, enableOutline, width, height, language, supportFullScreen } = props; diff --git a/packages/base-monaco-editor/src/monaco.ts b/packages/base-monaco-editor/src/monaco.ts index a3abe25..a873dec 100644 --- a/packages/base-monaco-editor/src/monaco.ts +++ b/packages/base-monaco-editor/src/monaco.ts @@ -1,19 +1,7 @@ import loader, { Monaco } from '@monaco-editor/loader'; //@ts-ignore import isEqual from 'lodash/isEqual'; - -export interface Configure { - singleton?: boolean; -} - -const CONFIGURE_KEY = '__base_monaco_editor_config__'; -const fakeWindow: any = window; - -if (!fakeWindow[CONFIGURE_KEY]) { - fakeWindow[CONFIGURE_KEY] = {}; -} - -export const configuration: Configure = fakeWindow[CONFIGURE_KEY]; +import { controller } from './controller'; export const getSingletonMonaco = (() => { let monaco: Monaco; @@ -52,14 +40,10 @@ export const getCommonMonaco = (config: any): Promise => { return loader.init(); }; -export function getMonaco(config: any) { +export function getMonaco(config?: any) { const hasConfig = Object.keys(config || {}).length > 0; const monacoConfig = hasConfig ? config : undefined; - return configuration.singleton + return controller.getMeta().singleton ? getSingletonMonaco(monacoConfig) : getCommonMonaco(monacoConfig); } - -export function configure(conf: Configure) { - Object.assign(configuration, conf || {}); -} From 598a43ef153a4e96998c1ff67bbd599d24b9eae0 Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Thu, 9 Jun 2022 17:01:20 +0800 Subject: [PATCH 014/166] feat: support singleton mode / upgrade linkage --- .github/CODEOWNERS | 2 +- packages/base-monaco-editor/CHANGELOG.md | 7 + packages/base-monaco-editor/package.json | 4 +- packages/base-monaco-editor/src/helper.ts | 206 ++++++++++------------ packages/base-monaco-editor/src/index.tsx | 32 ++-- packages/base-monaco-editor/src/monaco.ts | 62 +++++++ 6 files changed, 187 insertions(+), 126 deletions(-) create mode 100644 packages/base-monaco-editor/src/monaco.ts diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 802307d..c644ba5 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -5,7 +5,7 @@ * @leoyuan @alvarto /packages/plugin-manual/ @alvarto -/packages/base-monaco-editor/ @alvarto +/packages/base-monaco-editor/ @alvarto @wangshihao111 /packages/plugin-code-editor/ @alvarto /packages/plugin-schema/ @alvarto /packages/plugin-components-pane/ @mark-ck diff --git a/packages/base-monaco-editor/CHANGELOG.md b/packages/base-monaco-editor/CHANGELOG.md index 58196de..2d2c833 100644 --- a/packages/base-monaco-editor/CHANGELOG.md +++ b/packages/base-monaco-editor/CHANGELOG.md @@ -1,3 +1,10 @@ +## 1.1.0-beta.0 + +- 重构 type / path / value 联动,彻底修复 monaco 在多文件模式下覆盖多个 path 值的 bug +- 修复 ts 类型问题 @wangshihao111 +- 添加 configure 方法,支持配置是否开启 monaco 单例模式 @wangshihao111 +- 新增插件参数:`enhancers`,用于强化编辑器功能 @wangshihao111 + ## 1.0.0 - Publish following changes diff --git a/packages/base-monaco-editor/package.json b/packages/base-monaco-editor/package.json index 520741f..db7aecd 100644 --- a/packages/base-monaco-editor/package.json +++ b/packages/base-monaco-editor/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-plugin-base-monaco-editor", - "version": "1.0.0", + "version": "1.1.0-beta.0", "description": "代码编辑组件,monaco-editor 的低代码适配封装", "publishConfig": { "access": "public" @@ -31,7 +31,7 @@ "component" ], "dependencies": { - "@monaco-editor/loader": "^1.2.0", + "@monaco-editor/loader": "1.3.0", "classnames": "^2.3.1" }, "devDependencies": { diff --git a/packages/base-monaco-editor/src/helper.ts b/packages/base-monaco-editor/src/helper.ts index 475f80a..614ee8d 100644 --- a/packages/base-monaco-editor/src/helper.ts +++ b/packages/base-monaco-editor/src/helper.ts @@ -1,70 +1,25 @@ /* eslint-disable no-empty */ -import { useEffect, useState, useRef, CSSProperties } from 'react'; -import loader from '@monaco-editor/loader'; - -loader.config({ - paths: { - vs: 'https://g.alicdn.com/code/lib/monaco-editor/0.31.1/min/vs', - }, -}); - -type IAmbigousFn = (...args: any[]) => any; +import React, { useEffect, useState, useRef, CSSProperties } from 'react'; +import { Monaco } from '@monaco-editor/loader'; +import type { editor as oEditor } from 'monaco-editor'; +import { getMonaco } from './monaco'; // @todo fill type def for monaco editor without refering monaco editor /** * @see https://microsoft.github.io/monaco-editor/api/index.html */ -export interface IEditorInstance { - getModel: IAmbigousFn; - dispose: IAmbigousFn; - getValue: () => string; - onDidChangeModelContent: (input: any) => void; - setTheme: (input: string) => void; - setModelLanguage: (model: any, language: string) => void; - layout: () => void; - setValue: (value: string) => void; - executeEdits: IAmbigousFn; - pushUndoStop: IAmbigousFn; - EditorOption?: Record; - getOption?: (input: string) => any; - onDidFocusEditorText: (...args: any[]) => void; - onDidBlurEditorText: (...args: any[]) => void; - getModifiedEditor?: () => IEditorInstance; - setModel: IAmbigousFn; - revealLineInCenter: IAmbigousFn; - focus: IAmbigousFn; - Range: new(...args: any[]) => any; - getPosition: IAmbigousFn; - setPosition: IAmbigousFn; - deltaDecorations: IAmbigousFn; - addAction: IAmbigousFn; - saveViewState: () => ICodeEditorViewState; - createModel: IAmbigousFn; - [key: string]: any; -} -export interface IMonacoInstance { - editor?: { - create: IAmbigousFn; - [key: string]: any; - }; - KeyCode?: Record; - KeyMod?: Record; - [otherKeys: string]: any; -} +export type IEditorInstance = oEditor.IStandaloneCodeEditor | oEditor.IStandaloneDiffEditor; -type ICodeEditorViewState = { - contributionsState: any; - cursorState: any; - viewState: any; -} +export type EditorEnhancer = + (monaco: Monaco, editorIns: IEditorInstance) => any; export interface IGeneralManacoEditorProps { /** [Monaco editor options](https://microsoft.github.io/monaco-editor/) */ options?: Record; /** callback after monaco's loaded and after editor's loaded */ - editorDidMount?: (monaco: IMonacoInstance, editor: IEditorInstance) => void; + editorDidMount?: (monaco: Monaco, editor: IEditorInstance) => void; /** callback after monaco's loaded and before editor's loaded */ - editorWillMount?: (monaco: IMonacoInstance) => void; + editorWillMount?: (monaco: Monaco) => void; /** path of the current model, useful when creating a multi-model editor */ path?: string; /** whether to save the models' view states between model changes or not */ @@ -89,6 +44,7 @@ export interface IGeneralManacoEditorProps { enableOutline?: boolean; /** style of wrapper */ style?: CSSProperties; + enhancers?: EditorEnhancer[]; } export interface ISingleMonacoEditorProps extends IGeneralManacoEditorProps { @@ -103,16 +59,15 @@ export interface IDiffMonacoEditorProps extends IGeneralManacoEditorProps { const CURRENT_LANGUAGE = ((window as any).locale || window.localStorage.getItem('vdev-locale') || '').replace(/_/, '-') || 'zh-CN'; export const WORD_EDITOR_INITIALIZING = CURRENT_LANGUAGE === 'en-US' ? 'Initializing Editor' : '编辑器初始化中'; -export const INITIAL_OPTIONS = { +export const INITIAL_OPTIONS: oEditor.IStandaloneEditorConstructionOptions = { fontSize: 12, tabSize: 2, fontFamily: 'Menlo, Monaco, Courier New, monospace', - renderIndentGuides: true, folding: true, minimap: { enabled: false, }, - autoIndent: true, + autoIndent: 'advanced', contextmenu: true, useTabStops: true, wordBasedSuggestions: true, @@ -131,9 +86,34 @@ export const INITIAL_OPTIONS = { }, }; -export const useEditor = (type: 'single' | 'diff', props: IGeneralManacoEditorProps) => { +const DIFF_EDITOR_INITIAL_OPTIONS: oEditor.IStandaloneDiffEditorConstructionOptions = { + fontSize: 12, + fontFamily: 'Menlo, Monaco, Courier New, monospace', + folding: true, + minimap: { + enabled: false, + }, + autoIndent: 'advanced', + contextmenu: true, + useTabStops: true, + formatOnPaste: true, + automaticLayout: true, + lineNumbers: 'on', + wordWrap: 'off', + scrollBeyondLastLine: false, + fixedOverflowWidgets: false, + snippetSuggestions: 'top', + scrollbar: { + vertical: 'auto', + horizontal: 'auto', + verticalScrollbarSize: 10, + horizontalScrollbarSize: 10, + }, +}; + +export const useEditor = (type: 'single' | 'diff', props: IGeneralManacoEditorProps) => { const { - editorDidMount, editorWillMount, theme, value, path, language, saveViewState, defaultValue, + editorDidMount, editorWillMount, theme, value, path, language, saveViewState, defaultValue, enhancers, } = props; const [isEditorReady, setIsEditorReady] = useState(false); @@ -146,7 +126,7 @@ export const useEditor = (type: 'single' | 'diff', props: IGeneralManacoEditorPr const previousPath = usePrevious(path); const requireConfigRef = useRef(props.requireConfig); const optionRef = useRef(props.options); - const monacoRef = useRef(); + const monacoRef = useRef(); const editorRef = useRef(); const containerRef = useRef(); const typeRef = useRef(type); @@ -154,7 +134,13 @@ export const useEditor = (type: 'single' | 'diff', props: IGeneralManacoEditorPr const editorWillMountRef = useRef(); const decomposeRef = useRef(false); - const viewStatusRef = useRef>(new Map()) + const viewStatusRef = useRef>(new Map()); + + const enhancersRef = useRef({}); + + useEffect(() => { + enhancersRef.current.enhancers = enhancers; + }, [enhancers]); useEffect(() => { editorDidMountRef.current = editorDidMount; @@ -180,13 +166,8 @@ export const useEditor = (type: 'single' | 'diff', props: IGeneralManacoEditorPr // make sure loader / editor only init once useEffect(() => { setLoading(true); - - if (requireConfigRef.current) { - loader.config(requireConfigRef.current); - } - - loader.init() - .then((monaco: any) => { + getMonaco(requireConfigRef.current) + .then((monaco: Monaco) => { // 兼容旧版本 monaco-editor 写死 MonacoEnvironment 的问题 (window as any).MonacoEnvironment = undefined; if (typeof (window as any).define === 'function' && (window as any).define.amd) { @@ -203,13 +184,13 @@ export const useEditor = (type: 'single' | 'diff', props: IGeneralManacoEditorPr if (!containerRef.current) { return; } - let editor: IEditorInstance; + let editor: oEditor.IStandaloneCodeEditor | oEditor.IStandaloneDiffEditor; if (typeRef.current === 'single') { const model = getOrCreateModel( monaco, valueRef.current ?? defaultValueRef.current ?? '', languageRef.current, - pathRef.current + pathRef.current, ); editor = monaco.editor.create(containerRef.current, { automaticLayout: true, @@ -228,14 +209,14 @@ export const useEditor = (type: 'single' | 'diff', props: IGeneralManacoEditorPr editor = monaco.editor.createDiffEditor(containerRef.current, { automaticLayout: true, - ...INITIAL_OPTIONS, + ...DIFF_EDITOR_INITIAL_OPTIONS, ...optionRef.current, }); editor.setModel({ original: originalModel, modified: modifiedModel }); } - editorRef.current = editor; + enhancersRef.current.enhancers?.forEach((en: any) => en(monaco, editor as any)); try { editorDidMountRef.current?.(monaco, editor); } catch (err) { } @@ -258,30 +239,6 @@ export const useEditor = (type: 'single' | 'diff', props: IGeneralManacoEditorPr monacoRef.current.editor.setTheme(theme); }, [isEditorReady, theme]); - // controlled value - useEffect(() => { - if (!isEditorReady) { - return; - } - - const editor = type === 'diff' - ? editorRef.current.getModifiedEditor() - : editorRef.current; - - const nextValue = value ?? defaultValueRef.current ?? '' - if (editor?.getOption?.(monacoRef.current?.editor.EditorOption.readOnly)) { - editor?.setValue(nextValue); - } else if (value !== editor?.getValue()) { - editor?.executeEdits('', [{ - range: editor?.getModel().getFullModelRange(), - text: nextValue, - forceMoveMarkers: true, - }]); - - editor?.pushUndoStop(); - } - }, [isEditorReady, type, value]); - // focus status useEffect(() => { if (!isEditorReady) { @@ -289,8 +246,8 @@ export const useEditor = (type: 'single' | 'diff', props: IGeneralManacoEditorPr } const editor = type === 'diff' - ? editorRef.current.getModifiedEditor() - : editorRef.current; + ? (editorRef.current as oEditor.IStandaloneDiffEditor).getModifiedEditor() + : editorRef.current as oEditor.IStandaloneCodeEditor; editor?.onDidFocusEditorText(() => { !decomposeRef.current && setFocused(true); }); @@ -306,7 +263,35 @@ export const useEditor = (type: 'single' | 'diff', props: IGeneralManacoEditorPr }; }, []); - // multi-model implementation + // controlled value -- diff mode / without path only + useEffect(() => { + if (!isEditorReady) { + return; + } + + if (type !== 'diff' && !!path) { + return; + } + + const editor = type === 'diff' + ? (editorRef.current as oEditor.IStandaloneDiffEditor).getModifiedEditor() + : editorRef.current as oEditor.IStandaloneCodeEditor; + + const nextValue = value ?? defaultValueRef.current ?? ''; + if (editor?.getOption?.(monacoRef.current?.editor.EditorOption.readOnly)) { + editor?.setValue(nextValue); + } else if (value !== editor?.getValue()) { + editor?.executeEdits('', [{ + range: editor?.getModel().getFullModelRange(), + text: nextValue, + forceMoveMarkers: true, + }]); + + editor?.pushUndoStop(); + } + }, [isEditorReady, path, type, value]); + + // multi-model && controlled value (shouldn't be diff mode) useEffect(() => { if (!isEditorReady) { return; @@ -327,29 +312,30 @@ export const useEditor = (type: 'single' | 'diff', props: IGeneralManacoEditorPr path, ); + const editor = editorRef.current as oEditor.IStandaloneCodeEditor; if (valueRef.current !== null && valueRef.current !== undefined && model.getValue() !== valueRef.current) { model.setValue(valueRef.current); } - if (model !== editorRef.current.getModel()) { - saveViewState && viewStatusRef.current.set(previousPath, editorRef.current.saveViewState()); - editorRef.current.setModel(model); - saveViewState && editorRef.current.restoreViewState(viewStatusRef.current.get(path)); + saveViewState && viewStatusRef.current.set(previousPath, editor.saveViewState()); + editor.setModel(model); + saveViewState && editor.restoreViewState(viewStatusRef.current.get(path)); } - }, [isEditorReady, path, previousPath, type]); + }, [isEditorReady, value, path, previousPath, type]); + let retEditorRef: React.MutableRefObject = editorRef as any; return { isEditorReady, focused, loading, containerRef, monacoRef, - editorRef, + editorRef: retEditorRef, valueRef, } as const; }; -function getOrCreateModel(monaco: IMonacoInstance, value?: string, language?: string, path?: string) { +function getOrCreateModel(monaco: Monaco, value?: string, language?: string, path?: string) { if (path) { const prevModel = monaco .editor @@ -365,9 +351,9 @@ function getOrCreateModel(monaco: IMonacoInstance, value?: string, language?: st } function usePrevious(value: T) { - const ref = useRef() + const ref = useRef(); useEffect(() => { - ref.current = value - }, [value]) - return ref.current + ref.current = value; + }, [value]); + return ref.current; } diff --git a/packages/base-monaco-editor/src/index.tsx b/packages/base-monaco-editor/src/index.tsx index e35581c..8013bf8 100644 --- a/packages/base-monaco-editor/src/index.tsx +++ b/packages/base-monaco-editor/src/index.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; import { useRef, useEffect, useMemo, useState } from 'react'; import classNames from 'classnames'; +import type { editor } from 'monaco-editor'; import { ISingleMonacoEditorProps, WORD_EDITOR_INITIALIZING, @@ -9,6 +10,8 @@ import { INITIAL_OPTIONS, } from './helper'; +export * from './monaco'; + const SingleMonacoEditor = (props: ISingleMonacoEditorProps) => { const { onChange, enableOutline, width, height, language, supportFullScreen } = props; const onChangeRef = useRef(onChange); @@ -23,7 +26,7 @@ const SingleMonacoEditor = (props: ISingleMonacoEditorProps) => { monacoRef, editorRef, valueRef, - } = useEditor('single', props); + } = useEditor('single', props); const subscriptionRef = useRef(null); const className = classNames('ve-code-control', props.className, { @@ -49,9 +52,10 @@ const SingleMonacoEditor = (props: ISingleMonacoEditorProps) => { useEffect(() => { if (isEditorReady) { + const editorInstance = editorRef.current; subscriptionRef.current?.dispose(); - subscriptionRef.current = editorRef.current?.onDidChangeModelContent((event: any) => { - const editorValue = editorRef.current?.getModel().getValue(); + subscriptionRef.current = editorInstance?.onDidChangeModelContent((event: any) => { + const editorValue = editorInstance?.getModel().getValue(); if (valueRef.current !== editorValue) { onChangeRef.current?.(editorValue, event); @@ -62,8 +66,9 @@ const SingleMonacoEditor = (props: ISingleMonacoEditorProps) => { useEffect(() => { return () => { + const editorInstance = editorRef.current; subscriptionRef.current?.dispose(); - editorRef.current?.getModel()?.dispose(); + editorInstance?.getModel()?.dispose(); // eslint-disable-next-line react-hooks/exhaustive-deps editorRef.current?.dispose(); }; @@ -74,10 +79,11 @@ const SingleMonacoEditor = (props: ISingleMonacoEditorProps) => { return; } - monacoRef.current?.editor.setModelLanguage(editorRef.current?.getModel(), language); + monacoRef.current?.editor.setModelLanguage((editorRef.current)?.getModel(), language); }, [editorRef, isEditorReady, language, monacoRef]); const fullScreen = () => { + const editorInstance = editorRef.current; if (!isFullScreen) { setIsFullScreen(true); setFullScreenStyle({ @@ -91,22 +97,22 @@ const SingleMonacoEditor = (props: ISingleMonacoEditorProps) => { zIndex: 9998, }); // 更新小地图配置 - editorRef.current?.updateOptions({ - ...editorRef.current?.getOptions(), + editorInstance?.updateOptions({ + ...editorInstance?.getOptions(), minimap: { enabled: true, }, }); - editorRef.current?.layout(); + editorInstance?.layout(); } else { setIsFullScreen(false); - editorRef.current?.updateOptions({ - ...editorRef.current?.getOptions(), + editorInstance?.updateOptions({ + ...editorInstance?.getOptions(), minimap: { enabled: false, }, }); - editorRef.current?.layout(); + editorInstance?.layout(); } }; @@ -128,7 +134,7 @@ const SingleMonacoEditor = (props: ISingleMonacoEditorProps) => { const DiffMonacoEditor = (props: IDiffMonacoEditorProps) => { const { enableOutline, width, height, language, original } = props; - const { isEditorReady, focused, loading, containerRef, monacoRef, editorRef } = useEditor( + const { isEditorReady, focused, loading, containerRef, monacoRef, editorRef } = useEditor( 'diff', props, ); @@ -146,7 +152,7 @@ const DiffMonacoEditor = (props: IDiffMonacoEditorProps) => { if (!isEditorReady) { return; } - editorRef.current.getModel().original.setValue(original ?? ''); + (editorRef.current).getModel().original.setValue(original ?? ''); }, [editorRef, isEditorReady, original]); useEffect(() => { diff --git a/packages/base-monaco-editor/src/monaco.ts b/packages/base-monaco-editor/src/monaco.ts new file mode 100644 index 0000000..08cc69c --- /dev/null +++ b/packages/base-monaco-editor/src/monaco.ts @@ -0,0 +1,62 @@ +import loader, { Monaco } from '@monaco-editor/loader'; +import isEqual from 'lodash/isEqual'; + +export interface Configure { + singleton?: boolean; +} + +const CONFIGURE_KEY = '__base_monaco_editor_config__'; +const fakeWindow: any = window; + +if (!fakeWindow[CONFIGURE_KEY]) { + fakeWindow[CONFIGURE_KEY] = {}; +} + +export const configuration: Configure = fakeWindow[CONFIGURE_KEY]; + +export const getSingletonMonaco = (() => { + let monaco: Monaco; + let prevOptions: any; + return async (options?: any) => { + if (!monaco || !isEqual(prevOptions, options)) { + const hasConfig = Object.keys(options || {}).length > 0; + loader.config( + hasConfig + ? options + : { + paths: { + vs: 'https://g.alicdn.com/code/lib/monaco-editor/0.33.0/min/vs', + }, + }, + ); + monaco = await loader.init(); + prevOptions = options; + } + return monaco; + }; +})(); + +export const getCommonMonaco = (config: any): Promise => { + if (config) { + loader.config(config); + } else { + loader.config({ + paths: { + vs: 'https://g.alicdn.com/code/lib/monaco-editor/0.31.1/min/vs', + }, + }); + } + return loader.init(); +}; + +export function getMonaco(config: any) { + const hasConfig = Object.keys(config || {}).length > 0; + const monacoConfig = hasConfig ? config : undefined; + return configuration.singleton + ? getSingletonMonaco(monacoConfig) + : getCommonMonaco(monacoConfig); +} + +export function configure(conf: Configure) { + Object.assign(configuration, conf || {}); +} From 36426d876f060695ddaf5a2b71c5254a9a38b5fb Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Thu, 9 Jun 2022 17:06:07 +0800 Subject: [PATCH 015/166] docs: update collaborator --- packages/base-monaco-editor/CHANGELOG.md | 6 +++--- packages/base-monaco-editor/package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/base-monaco-editor/CHANGELOG.md b/packages/base-monaco-editor/CHANGELOG.md index 2d2c833..14549fd 100644 --- a/packages/base-monaco-editor/CHANGELOG.md +++ b/packages/base-monaco-editor/CHANGELOG.md @@ -1,9 +1,9 @@ ## 1.1.0-beta.0 - 重构 type / path / value 联动,彻底修复 monaco 在多文件模式下覆盖多个 path 值的 bug -- 修复 ts 类型问题 @wangshihao111 -- 添加 configure 方法,支持配置是否开启 monaco 单例模式 @wangshihao111 -- 新增插件参数:`enhancers`,用于强化编辑器功能 @wangshihao111 +- 修复 ts 类型问题 [@wangshihao111](https://github.com/wangshihao111) +- 添加 configure 方法,支持配置是否开启 monaco 单例模式 [@wangshihao111](https://github.com/wangshihao111) +- 新增插件参数:`enhancers`,用于强化编辑器功能 [@wangshihao111](https://github.com/wangshihao111) ## 1.0.0 diff --git a/packages/base-monaco-editor/package.json b/packages/base-monaco-editor/package.json index db7aecd..39ea850 100644 --- a/packages/base-monaco-editor/package.json +++ b/packages/base-monaco-editor/package.json @@ -62,5 +62,5 @@ "commit-msg": "f2elint commit-msg-scan" } }, - "homepage": "https://unpkg.com/@alilc/lowcode-plugin-base-monaco-editor@1.0.0/build/index.html" + "homepage": "https://unpkg.com/@alilc/lowcode-plugin-base-monaco-editor@1.1.0-beta.0/build/index.html" } From 262ab7b274eedaaf6166b94f4da0b4eac7e36575 Mon Sep 17 00:00:00 2001 From: jingyu Date: Thu, 9 Jun 2022 19:50:17 +0800 Subject: [PATCH 016/166] =?UTF-8?q?feat:=20=E8=A1=A5=E5=85=85=20changelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/base-monaco-editor/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/base-monaco-editor/CHANGELOG.md b/packages/base-monaco-editor/CHANGELOG.md index 14549fd..0347d4c 100644 --- a/packages/base-monaco-editor/CHANGELOG.md +++ b/packages/base-monaco-editor/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.1.0-beta.1 + +- 添加 controller 实例,可用作中间交换介质,解决与代码编辑相关的插件间的协作问题 [@wangshihao111](https://github.com/wangshihao111) +- 优化 Monaco 单例,元信息保存在 controller 实例内部 [@wangshihao111](https://github.com/wangshihao111) + ## 1.1.0-beta.0 - 重构 type / path / value 联动,彻底修复 monaco 在多文件模式下覆盖多个 path 值的 bug From b655d2d77944c535fd27266f2a505d0fb0c61b52 Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Thu, 9 Jun 2022 20:00:30 +0800 Subject: [PATCH 017/166] feat: bump into next version --- packages/base-monaco-editor/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base-monaco-editor/package.json b/packages/base-monaco-editor/package.json index 39ea850..3a93567 100644 --- a/packages/base-monaco-editor/package.json +++ b/packages/base-monaco-editor/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-plugin-base-monaco-editor", - "version": "1.1.0-beta.0", + "version": "1.1.0-beta.1", "description": "代码编辑组件,monaco-editor 的低代码适配封装", "publishConfig": { "access": "public" From cbe97b29e65f37fd40783dbf186ac40e9ff50715 Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Thu, 9 Jun 2022 20:01:22 +0800 Subject: [PATCH 018/166] docs: update homepage --- packages/base-monaco-editor/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base-monaco-editor/package.json b/packages/base-monaco-editor/package.json index 3a93567..777dd0f 100644 --- a/packages/base-monaco-editor/package.json +++ b/packages/base-monaco-editor/package.json @@ -62,5 +62,5 @@ "commit-msg": "f2elint commit-msg-scan" } }, - "homepage": "https://unpkg.com/@alilc/lowcode-plugin-base-monaco-editor@1.1.0-beta.0/build/index.html" + "homepage": "https://unpkg.com/@alilc/lowcode-plugin-base-monaco-editor@1.1.0-beta.1/build/index.html" } From 7ac165d2be7671aabe595a9b1c61f6d0cf8638c0 Mon Sep 17 00:00:00 2001 From: JackLian Date: Mon, 13 Jun 2022 16:49:16 +0800 Subject: [PATCH 019/166] fix: fix misused doc urls --- demo/src/universal/plugin.tsx | 2 +- packages/plugin-datasource-pane/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/src/universal/plugin.tsx b/demo/src/universal/plugin.tsx index 9fe6614..c79351f 100644 --- a/demo/src/universal/plugin.tsx +++ b/demo/src/universal/plugin.tsx @@ -38,7 +38,7 @@ export default async function registerPlugins() { await plugins.register(Inject); - // plugin API 见 https://yuque.antfin.com/ali-lowcode/docs/cdukce + // plugin API 见 https://lowcode-engine.cn/docV2/ibh9fh SchemaPlugin.pluginName = 'SchemaPlugin'; await plugins.register(SchemaPlugin); diff --git a/packages/plugin-datasource-pane/README.md b/packages/plugin-datasource-pane/README.md index 6fd408d..576385d 100644 --- a/packages/plugin-datasource-pane/README.md +++ b/packages/plugin-datasource-pane/README.md @@ -126,4 +126,4 @@ WIP # 参考 -* [搭建协议规范](https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema) +* [搭建协议规范](https://lowcode-engine.cn/lowcode) \ No newline at end of file From 0d9cec320747ed059aa36695c4a9f894b2437a5d Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Wed, 22 Jun 2022 15:27:09 +0800 Subject: [PATCH 020/166] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/base-monaco-editor/CHANGELOG.md | 4 ++++ packages/base-monaco-editor/package.json | 2 +- packages/base-monaco-editor/src/index.scss | 3 --- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/base-monaco-editor/CHANGELOG.md b/packages/base-monaco-editor/CHANGELOG.md index 0347d4c..ba3d6b0 100644 --- a/packages/base-monaco-editor/CHANGELOG.md +++ b/packages/base-monaco-editor/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.0-beta.2 + +- 去除 `overflow: visible` 样式,避免动作面板遮住按钮 + ## 1.1.0-beta.1 - 添加 controller 实例,可用作中间交换介质,解决与代码编辑相关的插件间的协作问题 [@wangshihao111](https://github.com/wangshihao111) diff --git a/packages/base-monaco-editor/package.json b/packages/base-monaco-editor/package.json index 777dd0f..123082e 100644 --- a/packages/base-monaco-editor/package.json +++ b/packages/base-monaco-editor/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-plugin-base-monaco-editor", - "version": "1.1.0-beta.1", + "version": "1.1.0-beta.2", "description": "代码编辑组件,monaco-editor 的低代码适配封装", "publishConfig": { "access": "public" diff --git a/packages/base-monaco-editor/src/index.scss b/packages/base-monaco-editor/src/index.scss index a263d61..2d09b4b 100644 --- a/packages/base-monaco-editor/src/index.scss +++ b/packages/base-monaco-editor/src/index.scss @@ -4,9 +4,6 @@ border-radius: 3px; min-height: 100px; border: 1px solid transparent; - &.ve-code-control { - overflow: visible; - } } .ve-code-control:hover { From 813e0661a0f9328ef0586b9c3a8eeae300c0c82f Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Wed, 22 Jun 2022 15:28:30 +0800 Subject: [PATCH 021/166] chore: bump into next version --- packages/base-monaco-editor/CHANGELOG.md | 2 +- packages/base-monaco-editor/package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/base-monaco-editor/CHANGELOG.md b/packages/base-monaco-editor/CHANGELOG.md index ba3d6b0..d38b363 100644 --- a/packages/base-monaco-editor/CHANGELOG.md +++ b/packages/base-monaco-editor/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.1.0-beta.2 +## 1.1.0-beta.3 - 去除 `overflow: visible` 样式,避免动作面板遮住按钮 diff --git a/packages/base-monaco-editor/package.json b/packages/base-monaco-editor/package.json index 123082e..3aacff2 100644 --- a/packages/base-monaco-editor/package.json +++ b/packages/base-monaco-editor/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-plugin-base-monaco-editor", - "version": "1.1.0-beta.2", + "version": "1.1.0-beta.3", "description": "代码编辑组件,monaco-editor 的低代码适配封装", "publishConfig": { "access": "public" @@ -62,5 +62,5 @@ "commit-msg": "f2elint commit-msg-scan" } }, - "homepage": "https://unpkg.com/@alilc/lowcode-plugin-base-monaco-editor@1.1.0-beta.1/build/index.html" + "homepage": "https://unpkg.com/@alilc/lowcode-plugin-base-monaco-editor@1.1.0-beta.2/build/index.html" } From 661083bad9b3994b7ea67e0e8ed75de1faae88ed Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Wed, 22 Jun 2022 15:34:26 +0800 Subject: [PATCH 022/166] chore: bump into next version --- packages/base-monaco-editor/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base-monaco-editor/package.json b/packages/base-monaco-editor/package.json index 3aacff2..060a8dd 100644 --- a/packages/base-monaco-editor/package.json +++ b/packages/base-monaco-editor/package.json @@ -62,5 +62,5 @@ "commit-msg": "f2elint commit-msg-scan" } }, - "homepage": "https://unpkg.com/@alilc/lowcode-plugin-base-monaco-editor@1.1.0-beta.2/build/index.html" + "homepage": "https://unpkg.com/@alilc/lowcode-plugin-base-monaco-editor@1.1.0-beta.3/build/index.html" } From e78fe80a36dc5c6d30245f3054625d9abc5c506e Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Wed, 22 Jun 2022 15:46:41 +0800 Subject: [PATCH 023/166] feat: bump into stable version --- packages/base-monaco-editor/CHANGELOG.md | 4 ++++ packages/base-monaco-editor/package.json | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/base-monaco-editor/CHANGELOG.md b/packages/base-monaco-editor/CHANGELOG.md index d38b363..567eab7 100644 --- a/packages/base-monaco-editor/CHANGELOG.md +++ b/packages/base-monaco-editor/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.0 + +- Publish following changes + ## 1.1.0-beta.3 - 去除 `overflow: visible` 样式,避免动作面板遮住按钮 diff --git a/packages/base-monaco-editor/package.json b/packages/base-monaco-editor/package.json index 060a8dd..68c7e88 100644 --- a/packages/base-monaco-editor/package.json +++ b/packages/base-monaco-editor/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-plugin-base-monaco-editor", - "version": "1.1.0-beta.3", + "version": "1.1.0", "description": "代码编辑组件,monaco-editor 的低代码适配封装", "publishConfig": { "access": "public" @@ -62,5 +62,5 @@ "commit-msg": "f2elint commit-msg-scan" } }, - "homepage": "https://unpkg.com/@alilc/lowcode-plugin-base-monaco-editor@1.1.0-beta.3/build/index.html" + "homepage": "https://unpkg.com/@alilc/lowcode-plugin-base-monaco-editor@1.1.0/build/index.html" } From 800f32e88b6963f6a5b18ccc0806d11b7f333a57 Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Thu, 30 Jun 2022 14:42:38 +0800 Subject: [PATCH 024/166] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=20ve-code-edi?= =?UTF-8?q?tor=20=E5=92=8C=20UIPaaS=20=E7=9A=84=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/base-monaco-editor/CHANGELOG.md | 4 ++++ packages/base-monaco-editor/package.json | 2 +- packages/base-monaco-editor/src/index.scss | 20 ++++++++++---------- packages/base-monaco-editor/src/index.tsx | 4 ++-- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/packages/base-monaco-editor/CHANGELOG.md b/packages/base-monaco-editor/CHANGELOG.md index 567eab7..1ca5153 100644 --- a/packages/base-monaco-editor/CHANGELOG.md +++ b/packages/base-monaco-editor/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.1 + +- 避免 UIPaaS 中的样式冲突,将 `.ve-code-control` 替换为 `.lc-code-control` + ## 1.1.0 - Publish following changes diff --git a/packages/base-monaco-editor/package.json b/packages/base-monaco-editor/package.json index 68c7e88..dc493c2 100644 --- a/packages/base-monaco-editor/package.json +++ b/packages/base-monaco-editor/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-plugin-base-monaco-editor", - "version": "1.1.0", + "version": "1.1.1", "description": "代码编辑组件,monaco-editor 的低代码适配封装", "publishConfig": { "access": "public" diff --git a/packages/base-monaco-editor/src/index.scss b/packages/base-monaco-editor/src/index.scss index 2d09b4b..dfe6986 100644 --- a/packages/base-monaco-editor/src/index.scss +++ b/packages/base-monaco-editor/src/index.scss @@ -1,4 +1,4 @@ -.ve-code-control { +.lc-code-control { position: relative; box-sizing: content-box; border-radius: 3px; @@ -6,26 +6,26 @@ border: 1px solid transparent; } -.ve-code-control:hover { +.lc-code-control:hover { border-color: var(--color-field-border-hover, rgba(31, 56, 88, 0.1)); } -.ve-code-control.ve-focused { +.lc-code-control.ve-focused { border-color: var(--color-field-border-active, rgba(31, 56, 88, 0.15)); } -.ve-code-control.ve-outline { +.lc-code-control.ve-outline { border: 1px solid var(--color-field-border, rgba(31, 56, 88, 0.05)) !important; } -.ve-code-control .react-monaco-editor-container { +.lc-code-control .react-monaco-editor-container { min-height: 100px; height: 100%; width: 100%; background: transparent; } -.ve-code-control .base-monaco-full-screen-icon, +.lc-code-control .base-monaco-full-screen-icon, .base-monaco-full-screen-icon-cancel { width: 20px; height: 20px; @@ -47,7 +47,7 @@ right: 138px; } -.ve-code-control .loading { +.lc-code-control .loading { position: absolute; display: flex; align-items: center; @@ -67,7 +67,7 @@ } } -.ve-code-control .syntaxTips { +.lc-code-control .syntaxTips { position: absolute; bottom: 0; left: 0; @@ -81,12 +81,12 @@ box-sizing: border-box; } -.ve-code-control .syntaxTips:hover { +.lc-code-control .syntaxTips:hover { max-height: 50%; overflow: auto; } -.ve-code-control .syntaxTips .infoIcon { +.lc-code-control .syntaxTips .infoIcon { position: absolute; width: 20px; height: 16px; diff --git a/packages/base-monaco-editor/src/index.tsx b/packages/base-monaco-editor/src/index.tsx index 9068cf3..dc5bbe0 100644 --- a/packages/base-monaco-editor/src/index.tsx +++ b/packages/base-monaco-editor/src/index.tsx @@ -30,7 +30,7 @@ const SingleMonacoEditor = (props: ISingleMonacoEditorProps) => { } = useEditor('single', props); const subscriptionRef = useRef(null); - const className = classNames('ve-code-control', props.className, { + const className = classNames('lc-code-control', props.className, { 've-focused': focused, 've-outline': enableOutline, }); @@ -140,7 +140,7 @@ const DiffMonacoEditor = (props: IDiffMonacoEditorProps) => { props, ); - const className = classNames('ve-code-control', props.className, { + const className = classNames('lc-code-control', props.className, { 've-focused': focused, 've-outline': enableOutline, }); From 8d4dde00844da4b7a051160f239aa425840c43a1 Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Thu, 30 Jun 2022 14:43:54 +0800 Subject: [PATCH 025/166] chore: update packagejson --- packages/base-monaco-editor/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base-monaco-editor/package.json b/packages/base-monaco-editor/package.json index dc493c2..bbbf077 100644 --- a/packages/base-monaco-editor/package.json +++ b/packages/base-monaco-editor/package.json @@ -62,5 +62,5 @@ "commit-msg": "f2elint commit-msg-scan" } }, - "homepage": "https://unpkg.com/@alilc/lowcode-plugin-base-monaco-editor@1.1.0/build/index.html" + "homepage": "https://unpkg.com/@alilc/lowcode-plugin-base-monaco-editor@1.1.1/build/index.html" } From 9e7fd0d786894e58ce6714446e3ad10547e4b735 Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Mon, 11 Jul 2022 17:33:18 +0800 Subject: [PATCH 026/166] =?UTF-8?q?fix:=20=E6=BA=90=E7=A0=81=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E9=AB=98=E5=BA=A6=E5=A1=8C=E9=99=B7=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/plugin-code-editor/CHANGELOG.md | 4 ++++ packages/plugin-code-editor/package.json | 4 ++-- packages/plugin-code-editor/src/pane/index.less | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/plugin-code-editor/CHANGELOG.md b/packages/plugin-code-editor/CHANGELOG.md index 2833853..ce9b400 100644 --- a/packages/plugin-code-editor/CHANGELOG.md +++ b/packages/plugin-code-editor/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.3 / 2022-07-11 + +- Fix 源码面板高度塌陷的 [bug](https://github.com/alibaba/lowcode-engine/issues/803) + ## 1.0.2 / 2022-05-05 * Fix [schema export issue](https://github.com/alibaba/lowcode-engine/issues/416) diff --git a/packages/plugin-code-editor/package.json b/packages/plugin-code-editor/package.json index 4efc22f..14ef6d9 100644 --- a/packages/plugin-code-editor/package.json +++ b/packages/plugin-code-editor/package.json @@ -1,7 +1,7 @@ { "name": "@alilc/lowcode-plugin-code-editor", "author": "59174526@qq.com & humphry.huang9@gmail.com", - "version": "1.0.2", + "version": "1.0.3", "description": "CodeEditor", "files": [ "es", @@ -21,7 +21,7 @@ }, "dependencies": { "@alifd/next": "^1.25.13", - "@alilc/lowcode-plugin-base-monaco-editor": "^1.0.0", + "@alilc/lowcode-plugin-base-monaco-editor": "^1.1.1", "@babel/core": "^7.15.8", "@babel/parser": "^7.15.8", "@babel/preset-env": "^7.15.8", diff --git a/packages/plugin-code-editor/src/pane/index.less b/packages/plugin-code-editor/src/pane/index.less index 16f5e99..3956047 100644 --- a/packages/plugin-code-editor/src/pane/index.less +++ b/packages/plugin-code-editor/src/pane/index.less @@ -15,7 +15,7 @@ overflow: hidden; } - .ve-code-control { + .lc-code-control { position: relative; height: calc(100% - 24px); } From ec780a2fb42fa13dc5ca708234ed4f9f4c2ef8a8 Mon Sep 17 00:00:00 2001 From: twinkle77 <2153165927@qq.com> Date: Thu, 4 Aug 2022 17:01:19 +0800 Subject: [PATCH 027/166] fix: support data source import --- demo/src/index.ts | 33 ++++++++++++++++ .../DataSourceImport/DataSourceImport.tsx | 38 +++++++++++++++---- .../src/pane/DataSourcePane.tsx | 7 +++- 3 files changed, 68 insertions(+), 10 deletions(-) diff --git a/demo/src/index.ts b/demo/src/index.ts index d0d58c3..a44f83d 100644 --- a/demo/src/index.ts +++ b/demo/src/index.ts @@ -9,6 +9,39 @@ preference.set('DataSourcePane', { dataSourceTypes: [ { type: 'fetch', + schema: { + type: "object", + properties: { + id: { + type: "string" + }, + type: { + type: "string" + }, + isInit: { + type: "boolean", + }, + options: { + type: "object", + properties: { + method: { + type: "string", + }, + isCors: { + type: "boolean", + }, + timeout: { + type: "integer", + }, + uri: { + type: "string", + }, + }, + required: ["method", "isCors", "timeout", "uri"] + } + }, + required: ["id", "type", "isInit", "options"] + } }, { type: 'jsonp', diff --git a/packages/plugin-datasource-pane/src/components/DataSourceImport/DataSourceImport.tsx b/packages/plugin-datasource-pane/src/components/DataSourceImport/DataSourceImport.tsx index a92125a..f4db433 100644 --- a/packages/plugin-datasource-pane/src/components/DataSourceImport/DataSourceImport.tsx +++ b/packages/plugin-datasource-pane/src/components/DataSourceImport/DataSourceImport.tsx @@ -32,9 +32,18 @@ export class DataSourceImport extends PureComponent< static defaultProps = { defaultValue: [ { - type: 'http', - id: 'test', - }, + type: 'fetch', + isInit: false, + options: { + method: 'GET', + isCors: true, + timeout: 5000, + uri: '/info', + params: {}, + headers: {} + }, + id: 'info' + } ], }; @@ -47,8 +56,10 @@ export class DataSourceImport extends PureComponent< return new Promise((resolve, reject) => { const { isCodeValid, code } = this.state; - if (isCodeValid) reject(new Error('格式有误')); - resolve({ schema: code }); + if (!isCodeValid) reject(new Error('导入格式有误')); + + // 只 resolve 通过 schema 校验的数据 + resolve(this.deriveValue(JSON.parse(code))); }); }; @@ -79,14 +90,25 @@ export class DataSourceImport extends PureComponent< return (result as DataSourceConfig[]).filter((dataSource) => { if (!dataSource.type) return false; + const dataSourceType = dataSourceTypes.find( (type) => type.type === dataSource.type, ); + if (!dataSourceType) return false; - return ajv.validate(dataSourceType.schema, dataSource); + + // 校验失败的数据源,给予用户提示 + const validate = ajv.compile(dataSourceType.schema) + const valid = validate(dataSource) + if (!valid) console.warn(validate.errors) + return valid }); }; + /** + * 看代码是未使用到 + * @deprecated + */ handleComplete = () => { if (this.monacoRef) { if ( @@ -116,8 +138,8 @@ export class DataSourceImport extends PureComponent< } }; - handleEditorDidMount = (isFullscreen: boolean, editor: MonacoEditor, monaco: MonacoEditor) => { - this.monacoRef = monaco?.editor; + handleEditorDidMount = (editor: MonacoEditor, monaco: MonacoEditor) => { + this.monacoRef = editor?.editor; }; render() { diff --git a/packages/plugin-datasource-pane/src/pane/DataSourcePane.tsx b/packages/plugin-datasource-pane/src/pane/DataSourcePane.tsx index 646b8a7..bee17e3 100644 --- a/packages/plugin-datasource-pane/src/pane/DataSourcePane.tsx +++ b/packages/plugin-datasource-pane/src/pane/DataSourcePane.tsx @@ -85,7 +85,8 @@ export class DataSourcePane extends PureComponent< componentDidMount() { this.serviceS = this.context?.stateService?.subscribe?.((state: any) => { this.setState({ current: state }); - if (state.changed && state.value === 'idle') { + // 监听导入成功事件 + if (state.changed && (state.value === 'idle' || state.event?.type === "FINISH_IMPORT")) { // TODO add hook this.props.onSchemaChange?.({ list: state.context.dataSourceList, @@ -221,7 +222,7 @@ export class DataSourcePane extends PureComponent< return; } const repeatedDataSourceList = data.filter( - (item) => !!this.state.current.dataSourceList.find( + (item) => !!this.state.current.context.dataSourceList.find( (dataSource: DataSourceConfig) => dataSource.id === item.id, ), ); @@ -237,6 +238,8 @@ export class DataSourcePane extends PureComponent< return; } importDataSourceList(); + }).catch(err => { + console.warn(err?.message) }); } }; From 518b4e041ab38740335dcdcd5d388940b923d6a1 Mon Sep 17 00:00:00 2001 From: haoziqaq <357229046@qq.com> Date: Tue, 31 May 2022 12:05:06 +0800 Subject: [PATCH 028/166] fix: fixed bug where the panel content overflowed --- packages/plugin-datasource-pane/src/pane/index.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-datasource-pane/src/pane/index.scss b/packages/plugin-datasource-pane/src/pane/index.scss index 4edd53b..a8dd4c6 100644 --- a/packages/plugin-datasource-pane/src/pane/index.scss +++ b/packages/plugin-datasource-pane/src/pane/index.scss @@ -4,7 +4,7 @@ $cls-prefix: "lowcode-plugin-datasource-pane"; .#{$cls-prefix}-container { overflow-y: auto; - margin: 8px; + padding: 8px; height: 100%; >.next-tabs { display: flex; From 1623e8fdfb263c70c0ce33667e8194f41bef7b58 Mon Sep 17 00:00:00 2001 From: twinkle77 <2153165927@qq.com> Date: Thu, 4 Aug 2022 22:53:30 +0800 Subject: [PATCH 029/166] fix: Close https://github.com/alibaba/lowcode-engine/issues/783 --- demo/src/index.ts | 2 +- .../DataSourceForm/DataSourceForm.tsx | 14 ++--- .../components/Forms/component-switch-btn.tsx | 53 ++++++++++++++++++- 3 files changed, 59 insertions(+), 10 deletions(-) diff --git a/demo/src/index.ts b/demo/src/index.ts index a44f83d..d334617 100644 --- a/demo/src/index.ts +++ b/demo/src/index.ts @@ -31,7 +31,7 @@ preference.set('DataSourcePane', { type: "boolean", }, timeout: { - type: "integer", + type: "number", }, uri: { type: "string", diff --git a/packages/plugin-datasource-pane/src/components/DataSourceForm/DataSourceForm.tsx b/packages/plugin-datasource-pane/src/components/DataSourceForm/DataSourceForm.tsx index f3e6c12..95e5f1e 100644 --- a/packages/plugin-datasource-pane/src/components/DataSourceForm/DataSourceForm.tsx +++ b/packages/plugin-datasource-pane/src/components/DataSourceForm/DataSourceForm.tsx @@ -34,6 +34,7 @@ import { generateClassName } from '../../utils/misc'; import { filterXDisplay } from '../../utils/filter-x-display'; import { DataSourceFormProps, DataSourceFormMode } from '../../types'; +import { isJSExpression } from '@alilc/lowcode-types'; const SCHEMA = { type: 'object', @@ -79,8 +80,8 @@ const SCHEMA = { }, params: { title: '请求参数', - type: 'object', - default: {}, + type: 'array', + default: [], 'x-decorator-props': { addonAfter: , }, @@ -117,9 +118,9 @@ const SCHEMA = { }, }, headers: { - type: 'object', + type: 'array', title: '请求头信息', - default: {}, + default: [], 'x-decorator-props': { addonAfter: , }, @@ -218,9 +219,8 @@ export class DataSourceForm extends PureComponent { deriveInitialData = (dataSource: object = {}) => { const { dataSourceType } = this.props; const result: any = _cloneDeep(dataSource); - // TODO - if (_isPlainObject(_get(result, 'options.params'))) { + if (_isPlainObject(_get(result, 'options.params')) && !isJSExpression(_get(result, 'options.params'))) { result.options.params = Object.keys(result.options.params).reduce( (acc: any, cur: any) => { acc.push({ @@ -232,7 +232,7 @@ export class DataSourceForm extends PureComponent { [], ); } - if (_isPlainObject(_get(result, 'options.headers'))) { + if (_isPlainObject(_get(result, 'options.headers')) && !isJSExpression(_get(result, 'options.headers'))) { result.options.headers = Object.keys(result.options.headers).reduce( (acc: any, cur: any) => { acc.push({ diff --git a/packages/plugin-datasource-pane/src/components/Forms/component-switch-btn.tsx b/packages/plugin-datasource-pane/src/components/Forms/component-switch-btn.tsx index e461ef1..6b7e1dd 100644 --- a/packages/plugin-datasource-pane/src/components/Forms/component-switch-btn.tsx +++ b/packages/plugin-datasource-pane/src/components/Forms/component-switch-btn.tsx @@ -5,6 +5,8 @@ import _get from 'lodash/get'; import { connect, mapProps } from '@formily/react'; import cn from 'classnames'; import { generateClassName } from '../../utils/misc'; +import { Field } from '@formily/core' +import { isJSExpression, JSExpression } from '@alilc/lowcode-types'; export interface ComponentSwitchBtnCompProps { className?: string; @@ -12,6 +14,7 @@ export interface ComponentSwitchBtnCompProps { component: string; originalComponent: string; setComponent: (component: string) => void; + field: Field } export interface ComponentSwitchBtnCompState { @@ -34,17 +37,62 @@ class ComponentSwitchBtnCompComp extends PureComponent< componentDidMount() { this.originalComponent = this.props.originalComponent; + + // 表单回调的时候,如果初始值是 expression,那需要切换组件 + if (isJSExpression(this.props.field.value)) { + this.props.setComponent('LowcodeExpression') + this.setState({ currentComponent: 'LowcodeExpression' }); + } } handleSwitch = () => { + const { field, setComponent } = this.props + let nextComponent = null; if (this.state.currentComponent === this.originalComponent) { nextComponent = this.props.component; } else { nextComponent = this.originalComponent; } - this.setState({ currentComponent: nextComponent }); - this.props.setComponent?.(nextComponent); + + let nextValue: number | boolean | string | JSExpression | Array = field.value + + switch(nextComponent) { + case 'Switch': + // expression 转 boolean + if (isJSExpression(nextValue)) { + nextValue = (nextValue && nextValue.value === 'true') || false; + } + break; + case 'NumberPicker': + // expression 转 number + if (isJSExpression(nextValue)) { + const val = +(nextValue && nextValue.value) + nextValue = isNaN(val) ? 0 : val + } + break; + case 'ArrayItems': + // expression 转 array + if (isJSExpression(nextValue)) { + nextValue = [] + } + break; + case 'LowcodeExpression': + // 普通组件转 array + nextValue = { + type: 'JSExpression', + value: nextValue + '', + } + break; + default: // 默认 expression 转 string (Input、Select 组件走这) + if (isJSExpression(nextValue)) { + nextValue = (nextValue && nextValue.value) || '' + } + } + + this.setState({ currentComponent: nextComponent! }); + field.setValue(nextValue) + setComponent?.(nextComponent!); }; render() { @@ -66,6 +114,7 @@ export const ComponentSwitchBtn = connect( ComponentSwitchBtnCompComp, mapProps((props, field) => { return { + field, setComponent: field.setComponent, originalComponent: _get(field, 'component[0]'), }; From 78d46fa5020465417d1fedd3bb6f4de6009cc271 Mon Sep 17 00:00:00 2001 From: twinkle77 <2153165927@qq.com> Date: Fri, 5 Aug 2022 14:33:58 +0800 Subject: [PATCH 030/166] fix: Close https://github.com/alibaba/lowcode-engine/issues/191 --- .../DataSourceForm/DataSourceForm.tsx | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/packages/plugin-datasource-pane/src/components/DataSourceForm/DataSourceForm.tsx b/packages/plugin-datasource-pane/src/components/DataSourceForm/DataSourceForm.tsx index 95e5f1e..7dc035e 100644 --- a/packages/plugin-datasource-pane/src/components/DataSourceForm/DataSourceForm.tsx +++ b/packages/plugin-datasource-pane/src/components/DataSourceForm/DataSourceForm.tsx @@ -1,6 +1,6 @@ // @todo schema default import React, { PureComponent } from 'react'; -import { createForm, registerValidateRules } from '@formily/core'; +import { createForm, registerValidateRules, Form as FormilyForm } from '@formily/core'; import { createSchemaField } from '@formily/react'; import { Space, @@ -183,9 +183,32 @@ const SCHEMA = { /** * 通过是否存在 ID 来决定读写状态 */ -export class DataSourceForm extends PureComponent { +export class DataSourceForm extends PureComponent { + constructor (props) { + super(props) + + this.state = { + form: this.createForm() + } + } + + createForm(): FormilyForm { + return createForm({ + initialValues: this.deriveInitialData(this.props.dataSource), + }) + } + + componentDidUpdate(prevProps: DataSourceFormProps) { + // dataSource 变了,需要更新 form,界面刷新 + if (this.props.dataSource !== prevProps.dataSource) { + this.setState({ + form: this.createForm() + }) + } + } + submit = () => { - return this.form + return this.state.form .submit() .then((formData: any) => { if (_isArray(_get(formData, 'options.params'))) { @@ -459,10 +482,6 @@ export class DataSourceForm extends PureComponent { }; }; - form = createForm({ - initialValues: this.deriveInitialData(this.props.dataSource), - }); - render() { const SchemaField = createSchemaField({ components: { @@ -485,7 +504,7 @@ export class DataSourceForm extends PureComponent { return (
-
+ { return arg; From b1914db33e11698a1a130f1f1d34c7ed07acdef4 Mon Sep 17 00:00:00 2001 From: twinkle77 <2153165927@qq.com> Date: Fri, 5 Aug 2022 16:17:58 +0800 Subject: [PATCH 031/166] fix: https://github.com/alibaba/lowcode-engine/issues/207 --- .../src/components/Forms/form-lazy-obj.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/plugin-datasource-pane/src/components/Forms/form-lazy-obj.tsx b/packages/plugin-datasource-pane/src/components/Forms/form-lazy-obj.tsx index 0c5da9c..45cc7a5 100644 --- a/packages/plugin-datasource-pane/src/components/Forms/form-lazy-obj.tsx +++ b/packages/plugin-datasource-pane/src/components/Forms/form-lazy-obj.tsx @@ -12,6 +12,7 @@ import _pick from 'lodash/pick'; import { JSFunction } from './jsFunction'; import { RemoveBtn } from './form-lazy-obj-remove-btn'; import { generateClassName } from '../../utils/misc'; +import { isJSFunction } from '@alilc/lowcode-types'; const { Item: MenuButtonItem } = MenuButton; @@ -22,11 +23,18 @@ export interface FormLazyObjProps { export const FormLazyObj = observer((props: FormLazyObjProps) => { const { addText = '添加' } = props; + const field = useField(); - const [selectedProperties, setSelectedProperties] = useState([]); + const schema = useFieldSchema(); - useEffect(() => {}, [field]); + const [selectedProperties, setSelectedProperties] = useState(() => { + // 自动回填数据处理函数 + return Object.keys(schema.properties || {}).filter(property => { + return isJSFunction(field.form.values[property]) + }) + }); + const properties = useMemo(() => { return Object.keys(schema.properties || {}) .filter((i) => selectedProperties.indexOf(i) === -1) @@ -69,6 +77,7 @@ export const FormLazyObj = observer((props: FormLazyObjProps) => { }); const schemaJSON = schema.toJSON(); const schemaProperties = _pick(schemaJSON.properties, selectedProperties); + return ( Date: Mon, 8 Aug 2022 14:25:49 +0800 Subject: [PATCH 032/166] feat: filter out duplicate data sources --- demo/src/index.ts | 66 +++++++++---------- .../DataSourceImport/DataSourceImport.tsx | 18 +++-- .../src/utils/stateMachine.ts | 9 ++- 3 files changed, 53 insertions(+), 40 deletions(-) diff --git a/demo/src/index.ts b/demo/src/index.ts index d334617..ba4e8a6 100644 --- a/demo/src/index.ts +++ b/demo/src/index.ts @@ -9,39 +9,39 @@ preference.set('DataSourcePane', { dataSourceTypes: [ { type: 'fetch', - schema: { - type: "object", - properties: { - id: { - type: "string" - }, - type: { - type: "string" - }, - isInit: { - type: "boolean", - }, - options: { - type: "object", - properties: { - method: { - type: "string", - }, - isCors: { - type: "boolean", - }, - timeout: { - type: "number", - }, - uri: { - type: "string", - }, - }, - required: ["method", "isCors", "timeout", "uri"] - } - }, - required: ["id", "type", "isInit", "options"] - } + // schema: { + // type: "object", + // properties: { + // id: { + // type: "string" + // }, + // type: { + // type: "string" + // }, + // isInit: { + // type: "boolean", + // }, + // options: { + // type: "object", + // properties: { + // method: { + // type: "string", + // }, + // isCors: { + // type: "boolean", + // }, + // timeout: { + // type: "number", + // }, + // uri: { + // type: "string", + // }, + // }, + // required: ["method", "isCors", "timeout", "uri"] + // } + // }, + // required: ["id", "type", "isInit", "options"] + // } }, { type: 'jsonp', diff --git a/packages/plugin-datasource-pane/src/components/DataSourceImport/DataSourceImport.tsx b/packages/plugin-datasource-pane/src/components/DataSourceImport/DataSourceImport.tsx index f4db433..cc69379 100644 --- a/packages/plugin-datasource-pane/src/components/DataSourceImport/DataSourceImport.tsx +++ b/packages/plugin-datasource-pane/src/components/DataSourceImport/DataSourceImport.tsx @@ -67,7 +67,7 @@ export class DataSourceImport extends PureComponent< constructor(props: DataSourceImportProps) { super(props); - this.state.code = JSON.stringify(this.deriveValue(this.props.defaultValue)); + this.state.code = JSON.stringify(this.deriveValue(this.props.defaultValue), null, 2); this.handleEditorDidMount = this.handleEditorDidMount.bind(this); this.handleEditorChange = this.handleEditorChange.bind(this); this.handleComplete = this.handleComplete.bind(this); @@ -97,11 +97,17 @@ export class DataSourceImport extends PureComponent< if (!dataSourceType) return false; - // 校验失败的数据源,给予用户提示 - const validate = ajv.compile(dataSourceType.schema) - const valid = validate(dataSource) - if (!valid) console.warn(validate.errors) - return valid + // 向下兼容 + if (dataSourceType.schema) { + // 校验失败的数据源,给予用户提示 + const validate = ajv.compile(dataSourceType.schema) + const valid = validate(dataSource) + if (!valid) console.warn(validate.errors) + return valid + } else { + // 用户不传入 schema 校验规则,默认返回 true + return true + } }); }; diff --git a/packages/plugin-datasource-pane/src/utils/stateMachine.ts b/packages/plugin-datasource-pane/src/utils/stateMachine.ts index 4307e23..15edb12 100644 --- a/packages/plugin-datasource-pane/src/utils/stateMachine.ts +++ b/packages/plugin-datasource-pane/src/utils/stateMachine.ts @@ -161,7 +161,14 @@ export const createStateMachine = (dataSourceList: DataSourceConfig[] = []) => c target: 'idle', actions: assign({ dataSourceList: (context, event) => { - return context.dataSourceList.concat(event.payload); + // 直接 concat 会出现重复 + const filterDataSourceList = context.dataSourceList.filter((item) => { + return !event.payload.find( + (dataSource: DataSourceConfig) => dataSource.id === item.id, + ) + }) + + return filterDataSourceList.concat(event.payload); }, detail: { visible: false, From 2ac24508a224c0ffad776b60d5ce77a9844a06ae Mon Sep 17 00:00:00 2001 From: twinkle77 <2153165927@qq.com> Date: Mon, 8 Aug 2022 14:51:22 +0800 Subject: [PATCH 033/166] Close: https://github.com/alibaba/lowcode-engine/issues/878 --- .../DataSourceExport/DataSourceExport.tsx | 91 +++++++++++-------- 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/packages/plugin-datasource-pane/src/components/DataSourceExport/DataSourceExport.tsx b/packages/plugin-datasource-pane/src/components/DataSourceExport/DataSourceExport.tsx index 40daaa8..bff557a 100644 --- a/packages/plugin-datasource-pane/src/components/DataSourceExport/DataSourceExport.tsx +++ b/packages/plugin-datasource-pane/src/components/DataSourceExport/DataSourceExport.tsx @@ -18,47 +18,44 @@ import { generateClassName } from '../../utils/misc'; // import './import-plugins/code.scss'; export interface DataSourceExportProps { -dataSourceList: DataSourceConfig[]; -dataSourceTypes: DataSourceType[]; + dataSourceList: DataSourceConfig[]; + dataSourceTypes: DataSourceType[]; } export interface DataSourceExportState { -code: string; -isCodeValid: boolean; + code: string; + isCodeValid: boolean; } -export class DataSourceExport extends PureComponent< -DataSourceExportProps, -DataSourceExportState -> { -static defaultProps = { +export class DataSourceExport extends PureComponent { + static defaultProps = { dataSourceList: [], -}; + }; -state = { + state = { code: '', isCodeValid: true, -}; + }; -submit = () => { + submit = () => { return new Promise((resolve, reject) => { const { isCodeValid, code } = this.state; if (isCodeValid) reject(new Error('格式有误')); resolve({ schema: code }); }); -}; + }; -private monacoRef: any; + private monacoRef: any; -constructor(props: DataSourceExportProps) { + constructor(props: DataSourceExportProps) { super(props); - this.state.code = JSON.stringify(this.deriveValue(this.props.dataSourceList)); + this.state.code = JSON.stringify(this.deriveValue(this.props.dataSourceList), null, 2); this.handleEditorDidMount = this.handleEditorDidMount.bind(this); this.handleEditorChange = this.handleEditorChange.bind(this); -} + } -deriveValue = (value: any) => { + deriveValue = (value: any) => { const { dataSourceTypes } = this.props; if (!_isArray(dataSourceTypes) || dataSourceTypes.length === 0) return []; @@ -74,36 +71,50 @@ deriveValue = (value: any) => { const ajv = new Ajv(); return (result as DataSourceConfig[]).filter((dataSource) => { - if (!dataSource.type) return false; - const dataSourceType = dataSourceTypes.find((type) => type.type === dataSource.type); - if (!dataSourceType) return false; - return ajv.validate(dataSourceType.schema, dataSource); + if (!dataSource.type) return false; + + const dataSourceType = dataSourceTypes.find((type) => type.type === dataSource.type); + + if (!dataSourceType) return false; + + // 向下兼容 + if (dataSourceType.schema) { + // 校验失败的数据源,给予用户提示 + const validate = ajv.compile(dataSourceType.schema) + const valid = validate(dataSource) + if (!valid) console.warn(validate.errors) + return valid + } else { + // 用户不传入 schema 校验规则,默认返回 true + return true + } }); -}; + }; -handleCopy = () => { + handleCopy = () => { Message.success('粘贴成功!'); -}; + }; -handleEditorChange = (newValue) => { + handleEditorChange = (newValue) => { if (this.monacoRef) { - if (!this.monacoRef.getModelMarkers().find((marker: editor.IMarker) => marker.owner === 'json')) { + if (!this.monacoRef.getModelMarkers().find((marker: editor.IMarker) => marker.owner === 'json')) { this.setState({ isCodeValid: true, code: newValue }); + } } - } -}; + }; -handleEditorDidMount = (isFullscreen, editor, monaco) => { - this.monacoRef = monaco?.editor; -}; + handleEditorDidMount = (editor: MonacoEditor, monaco: MonacoEditor) => { + this.monacoRef = editor?.editor; + }; -handleReset = () => { -if (this.monacoRef) { - this.monacoRef.getModels()?.[0]?.setValue?.(code); -} -}; + handleReset = () => { + const code = JSON.stringify(this.deriveValue(this.props.dataSourceList), null, 2) + if (this.monacoRef) { + this.monacoRef.getModels()?.[0]?.setValue?.(code); + } + }; -render() { + render() { const { code, isCodeValid } = this.state; // @todo @@ -134,5 +145,5 @@ render() {

); -} + } } From 11e190affec1ecf5e89274a2154b95a2983dad58 Mon Sep 17 00:00:00 2001 From: twinkle77 <2153165927@qq.com> Date: Mon, 8 Aug 2022 15:25:37 +0800 Subject: [PATCH 034/166] fix: drag handler style overlap --- demo/src/index.ts | 35 +------------------ .../DataSourceListItem/DataSourceListItem.tsx | 8 +++-- 2 files changed, 7 insertions(+), 36 deletions(-) diff --git a/demo/src/index.ts b/demo/src/index.ts index ba4e8a6..4607725 100644 --- a/demo/src/index.ts +++ b/demo/src/index.ts @@ -8,40 +8,7 @@ preference.set('DataSourcePane', { importPlugins: [], dataSourceTypes: [ { - type: 'fetch', - // schema: { - // type: "object", - // properties: { - // id: { - // type: "string" - // }, - // type: { - // type: "string" - // }, - // isInit: { - // type: "boolean", - // }, - // options: { - // type: "object", - // properties: { - // method: { - // type: "string", - // }, - // isCors: { - // type: "boolean", - // }, - // timeout: { - // type: "number", - // }, - // uri: { - // type: "string", - // }, - // }, - // required: ["method", "isCors", "timeout", "uri"] - // } - // }, - // required: ["id", "type", "isInit", "options"] - // } + type: 'fetch' }, { type: 'jsonp', diff --git a/packages/plugin-datasource-pane/src/components/DataSourceListItem/DataSourceListItem.tsx b/packages/plugin-datasource-pane/src/components/DataSourceListItem/DataSourceListItem.tsx index 3707b65..52e7e45 100644 --- a/packages/plugin-datasource-pane/src/components/DataSourceListItem/DataSourceListItem.tsx +++ b/packages/plugin-datasource-pane/src/components/DataSourceListItem/DataSourceListItem.tsx @@ -110,6 +110,10 @@ export class DataSourceListItem extends Component { selected, renderInfoTags = defaultRenderInfoTags, } = this.props; + + // 拖拽中,需要向右偏移 8p,避免覆盖 + const offsetStyle = mode === DataSourcePanelMode.SORTING ? { marginLeft: '8px' } : null; + return this.props?.connectDropTarget?.( this.props?.connectDragPreview?.(
{ onChange={this.handleExportCheckChange} /> )} -
+
{
}
-
+
{renderInfoTags(dataSource)?.map?.((tag: DataSourceInfoTag) => { if (tag.tooltip === true) { return ( From ca63e15f5cb6729d139c229fa1ebf6d7a06be5ec Mon Sep 17 00:00:00 2001 From: twinkle77 <2153165927@qq.com> Date: Mon, 8 Aug 2022 19:57:22 +0800 Subject: [PATCH 035/166] chore: upgrade formily --- packages/plugin-datasource-pane/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/plugin-datasource-pane/package.json b/packages/plugin-datasource-pane/package.json index 6a0d6d4..98d9f75 100644 --- a/packages/plugin-datasource-pane/package.json +++ b/packages/plugin-datasource-pane/package.json @@ -58,9 +58,9 @@ "react-dom": "^16.8.1", "@alilc/lowcode-plugin-base-monaco-editor": "^1.0.0", "@alilc/lowcode-types": "^1.0.0-beta.3", - "@formily/core": "^2.0.0-rc.3", - "@formily/next": "^2.0.0-rc.3", - "@formily/react": "^2.0.0-rc.3", + "@formily/core": "^2.1.12", + "@formily/next": "^2.1.12", + "@formily/react": "^2.1.12", "@types/lodash": "^4.14.178", "@xstate/react": "^1.6.1", "ajv": "^6.12.4", From 5d7fe7cc75ecf3bafbb357c8bcab6e3a161cc309 Mon Sep 17 00:00:00 2001 From: liujuping Date: Wed, 10 Aug 2022 11:03:32 +0800 Subject: [PATCH 036/166] feat: publish @alilc/lowcode-plugin-datasource-pane@1.0.6 --- packages/plugin-datasource-pane/package.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/plugin-datasource-pane/package.json b/packages/plugin-datasource-pane/package.json index 98d9f75..eae676c 100644 --- a/packages/plugin-datasource-pane/package.json +++ b/packages/plugin-datasource-pane/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-plugin-datasource-pane", - "version": "1.0.5", + "version": "1.0.6", "description": "低代码引擎数据源面板", "main": "lib/index.js", "files": [ @@ -27,8 +27,8 @@ "@alib/build-scripts": "^0.1.32", "@alifd/theme-lowcode-light": "^0.2.1", "@alilc/build-plugin-alt": "^1.0.0", - "@alilc/lowcode-shell": "^1.0.0", "@alilc/lowcode-engine": "beta", + "@alilc/lowcode-shell": "^1.0.0", "@alilc/lowcode-types": "beta", "@types/babel-types": "^7.0.9", "@types/babel__preset-env": "^7.9.2", @@ -36,6 +36,7 @@ "@types/react-dom": "^16.9.4", "@types/traverse": "^0.6.32", "build-plugin-fusion": "^0.1.9", + "build-plugin-moment-locales": "^0.1.3", "monaco-editor": "^0.21.0" }, "peerDependencies": { @@ -73,5 +74,5 @@ "traverse": "^0.6.6", "xstate": "^4.26.0" }, - "homepage": "https://unpkg.com/@alilc/lowcode-plugin-datasource-pane@1.0.4/build/index.html" + "homepage": "https://unpkg.com/@alilc/lowcode-plugin-datasource-pane@1.0.6/build/index.html" } From 9bb73893c43382f68e0e81ca07e20ad72cc47853 Mon Sep 17 00:00:00 2001 From: dingzhilei <1070504604@qq.com> Date: Thu, 25 Aug 2022 13:45:52 +0800 Subject: [PATCH 037/166] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E6=93=8D=E4=BD=9C=E8=87=AA=E5=AE=9A=E4=B9=89=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin-datasource-pane/src/pane/DataSourcePane.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/plugin-datasource-pane/src/pane/DataSourcePane.tsx b/packages/plugin-datasource-pane/src/pane/DataSourcePane.tsx index bee17e3..fabf5a1 100644 --- a/packages/plugin-datasource-pane/src/pane/DataSourcePane.tsx +++ b/packages/plugin-datasource-pane/src/pane/DataSourcePane.tsx @@ -282,7 +282,15 @@ export class DataSourcePane extends PureComponent< } else if (current.matches('detail.import')) { // TODO // pluginName - content = ; + // content = ; + const currentPluginName = current.context.detail.data.pluginName.name; + const { importPlugins } = this.props + const importPlugin = importPlugins?.find((item) => item.name === currentPluginName) + + const Component = (importPlugin ? importPlugin.component : ImportDetail) as React.ElementType + + content = ; + } else if (current.matches('detail.export')) { // TODO content = ( From 9a469c86d668a6c11f1407f39f6d7628fecb0d9b Mon Sep 17 00:00:00 2001 From: dingzhilei <1070504604@qq.com> Date: Thu, 25 Aug 2022 16:41:54 +0800 Subject: [PATCH 038/166] =?UTF-8?q?style:=20=E4=BB=A3=E7=A0=81=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pane/DataSourcePane.tsx | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/packages/plugin-datasource-pane/src/pane/DataSourcePane.tsx b/packages/plugin-datasource-pane/src/pane/DataSourcePane.tsx index fabf5a1..3f1999f 100644 --- a/packages/plugin-datasource-pane/src/pane/DataSourcePane.tsx +++ b/packages/plugin-datasource-pane/src/pane/DataSourcePane.tsx @@ -72,11 +72,11 @@ export class DataSourcePane extends PureComponent< listMode: DataSourcePanelMode.NORMAL, }; - detailRef? = createRef(); + detailRef?= createRef(); - exportRef? = createRef(); + exportRef?= createRef(); - importRef? = createRef(); + importRef?= createRef(); private send = (...args: any[]) => { this.context.stateService.send(...args); @@ -86,7 +86,7 @@ export class DataSourcePane extends PureComponent< this.serviceS = this.context?.stateService?.subscribe?.((state: any) => { this.setState({ current: state }); // 监听导入成功事件 - if (state.changed && (state.value === 'idle' || state.event?.type === "FINISH_IMPORT")) { + if (state.changed && (state.value === 'idle' || state.event?.type === 'FINISH_IMPORT')) { // TODO add hook this.props.onSchemaChange?.({ list: state.context.dataSourceList, @@ -223,8 +223,8 @@ export class DataSourcePane extends PureComponent< } const repeatedDataSourceList = data.filter( (item) => !!this.state.current.context.dataSourceList.find( - (dataSource: DataSourceConfig) => dataSource.id === item.id, - ), + (dataSource: DataSourceConfig) => dataSource.id === item.id, + ), ); if (repeatedDataSourceList.length > 0) { Dialog.confirm({ @@ -239,14 +239,14 @@ export class DataSourcePane extends PureComponent< } importDataSourceList(); }).catch(err => { - console.warn(err?.message) + console.warn(err?.message); }); } }; renderDetail = () => { const { current } = this.state; - const { dataSourceTypes = [] } = this.props; + const { dataSourceTypes = [], importPlugins = [], exportPlugins = [], formComponents = [] } = this.props; let content = null; if (current.matches('detail.edit')) { @@ -282,15 +282,11 @@ export class DataSourcePane extends PureComponent< } else if (current.matches('detail.import')) { // TODO // pluginName - // content = ; const currentPluginName = current.context.detail.data.pluginName.name; - const { importPlugins } = this.props - const importPlugin = importPlugins?.find((item) => item.name === currentPluginName) - - const Component = (importPlugin ? importPlugin.component : ImportDetail) as React.ElementType - + const importPlugin = importPlugins?.find((item) => item.name === currentPluginName); + const Component = (importPlugin ? importPlugin.component : ImportDetail) as React.ElementType; content = ; - + } else if (current.matches('detail.export')) { // TODO content = ( @@ -333,7 +329,7 @@ export class DataSourcePane extends PureComponent< className = '', helpLink = '', dataSourceTypes = [], - importPlugins, + importPlugins = [], } = this.props; const { current, listMode } = this.state; @@ -390,10 +386,10 @@ export class DataSourcePane extends PureComponent< dataSource={current.context.dataSourceList.filter((i: DataSourceConfig) => { return ( i.id.indexOf(current.context.dataSourceListFilter.keyword) !== - -1 && + -1 && (!current.context.dataSourceListFilter.dataSourceType || current.context.dataSourceListFilter.dataSourceType === - i.type) + i.type) ); })} onOperationClick={this.handleOperationClick} From cef626774e55e93eb278a56304d72932a8722583 Mon Sep 17 00:00:00 2001 From: dingzhilei <1070504604@qq.com> Date: Thu, 25 Aug 2022 16:48:41 +0800 Subject: [PATCH 039/166] =?UTF-8?q?style:=20=E4=BB=A3=E7=A0=81=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin-datasource-pane/src/pane/DataSourcePane.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/plugin-datasource-pane/src/pane/DataSourcePane.tsx b/packages/plugin-datasource-pane/src/pane/DataSourcePane.tsx index 3f1999f..aef0d81 100644 --- a/packages/plugin-datasource-pane/src/pane/DataSourcePane.tsx +++ b/packages/plugin-datasource-pane/src/pane/DataSourcePane.tsx @@ -72,11 +72,11 @@ export class DataSourcePane extends PureComponent< listMode: DataSourcePanelMode.NORMAL, }; - detailRef?= createRef(); + detailRef ?= createRef(); - exportRef?= createRef(); + exportRef ?= createRef(); - importRef?= createRef(); + importRef ?= createRef(); private send = (...args: any[]) => { this.context.stateService.send(...args); @@ -282,7 +282,7 @@ export class DataSourcePane extends PureComponent< } else if (current.matches('detail.import')) { // TODO // pluginName - const currentPluginName = current.context.detail.data.pluginName.name; + const currentPluginName = current.context.detail?.data?.pluginName?.name; const importPlugin = importPlugins?.find((item) => item.name === currentPluginName); const Component = (importPlugin ? importPlugin.component : ImportDetail) as React.ElementType; content = ; From 6d9681da088b877ddc02bf95fd7de86a5ea9b943 Mon Sep 17 00:00:00 2001 From: dingzhilei <1070504604@qq.com> Date: Thu, 25 Aug 2022 20:09:25 +0800 Subject: [PATCH 040/166] =?UTF-8?q?docs:=20=E6=95=B0=E6=8D=AE=E6=BA=90?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E5=AF=BC=E5=85=A5=E6=8F=92=E4=BB=B6=20Readme?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/plugin-datasource-pane/README.md | 99 ++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/packages/plugin-datasource-pane/README.md b/packages/plugin-datasource-pane/README.md index 576385d..42a853b 100644 --- a/packages/plugin-datasource-pane/README.md +++ b/packages/plugin-datasource-pane/README.md @@ -89,7 +89,104 @@ type DataSourceType = { ## 定制导入插件 -WIP +### 导入组件示例 + +导入组件引入方式参考 pluginProps +``` +import { DataSourceImportPluginTest } from './DataSourceImportPluginTest'; + +{ + ... + importPlugins: [ + { + name: '这里可以导入', + title: '这里可以导入', + component: DataSourceImportPluginTest, + componentProps: { + onImport: (res) => { + console.log('ceshi ') + + }, + onCancel: () => { + console.log('ceshi2 ') + + } + } + } + ], + exportPlugins: [], + formComponents: { }, + ... +} + +// DataSourceImportPluginTest.jsx + +/** + * 源码导入插件 + * @todo editor 关联 types,并提供详细的出错信息 + */ +import React, { PureComponent } from 'react'; +import { Button } from '@alifd/next'; +import _noop from 'lodash/noop'; +import _isArray from 'lodash/isArray'; +import _last from 'lodash/last'; +import _isPlainObject from 'lodash/isPlainObject'; +import { RuntimeDataSourceConfig as DataSourceConfig } from '@alilc/lowcode-datasource-types'; +import { JSONSchema6 } from 'json-schema'; +import type { ComponentType } from 'react'; +export interface DataSourceType { + type: string; + schema: JSONSchema6; + plugin?: ComponentType; +} +export interface DataSourcePaneImportPluginComponentProps { + dataSourceTypes: DataSourceType[]; + onImport?: (dataSourceList: DataSourceConfig[]) => void; + onCancel?: () => void; +} +export interface DataSourceImportPluginCodeProps + extends DataSourcePaneImportPluginComponentProps { + defaultValue?: DataSourceConfig[]; +} +export interface DataSourceImportPluginCodeState { + code: string; + isCodeValid: boolean; +} +export class DataSourceImportPluginCode extends PureComponent< + DataSourceImportPluginCodeProps, + DataSourceImportPluginCodeState +> { + handleComplete = () => { + console.log('确认') + }; + onCancel = () => { + console.log('取消') + }; + render() { + return ( +
+ 此处代码可以自定义 +

+ + +

+
+ ); + } +} + +``` + +具体的 component 可参考 DataSourceImportPluginCode + [查看](https://github.com/alibaba/lowcode-plugins/blob/main/packages/plugin-datasource-pane/src/components/DataSourceImportPluginCode/DataSourceImportPluginCode.tsx) + + demo 截图 + ![Alt](https://user-images.githubusercontent.com/14235113/186659341-dff511e8-f032-423c-8be7-e0cc281f3964.png) + + + ## 定制导出插件 From 92eb18ecc7179374df43c44106dde7703f279415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LeoYuan=20=E8=A2=81=E5=8A=9B=E7=9A=93?= Date: Tue, 27 Sep 2022 18:18:40 +0800 Subject: [PATCH 041/166] refactor: support inject mode for plugin-datasource-pane --- packages/plugin-datasource-pane/build.js | 23 ++++++++++++++++++++ packages/plugin-datasource-pane/build.json | 12 ---------- packages/plugin-datasource-pane/package.json | 4 ++-- 3 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 packages/plugin-datasource-pane/build.js delete mode 100644 packages/plugin-datasource-pane/build.json diff --git a/packages/plugin-datasource-pane/build.js b/packages/plugin-datasource-pane/build.js new file mode 100644 index 0000000..fc2fa16 --- /dev/null +++ b/packages/plugin-datasource-pane/build.js @@ -0,0 +1,23 @@ +module.exports = { + plugins: [ + 'build-plugin-component', + 'build-plugin-fusion', + [ + 'build-plugin-moment-locales', + { + locales: ['zh-cn'], + }, + ], + [ + '@alilc/build-plugin-alt', + { + type: 'plugin', + // 开启注入调试模式,see:https://www.yuque.com/lce/doc/ulvlkz + inject: true, + // 配置要打开的页面,在注入调试模式下,不配置此项的话不会打开浏览器 + // 支持直接使用官方 demo 项目:https://lowcode-engine.cn/demo/index.html + openUrl: 'https://lowcode-engine.cn/demo/index.html?debug', + }, + ], + ], +}; diff --git a/packages/plugin-datasource-pane/build.json b/packages/plugin-datasource-pane/build.json deleted file mode 100644 index b2fe2de..0000000 --- a/packages/plugin-datasource-pane/build.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "plugins": [ - "build-plugin-component", - "build-plugin-fusion", - [ - "build-plugin-moment-locales", - { - "locales": ["zh-cn"] - } - ] - ] -} diff --git a/packages/plugin-datasource-pane/package.json b/packages/plugin-datasource-pane/package.json index eae676c..f3cf576 100644 --- a/packages/plugin-datasource-pane/package.json +++ b/packages/plugin-datasource-pane/package.json @@ -7,7 +7,7 @@ "lib" ], "scripts": { - "start": "build-scripts start", + "start": "build-scripts start --config build.js", "build": "build-scripts build", "test": "ava", "test:snapshot": "ava --update-snapshots" @@ -26,7 +26,7 @@ "devDependencies": { "@alib/build-scripts": "^0.1.32", "@alifd/theme-lowcode-light": "^0.2.1", - "@alilc/build-plugin-alt": "^1.0.0", + "@alilc/build-plugin-alt": "^1.2.2", "@alilc/lowcode-engine": "beta", "@alilc/lowcode-shell": "^1.0.0", "@alilc/lowcode-types": "beta", From 6b142d99ac608fb17ef0b0c7dd7cdd66a702e40f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LeoYuan=20=E8=A2=81=E5=8A=9B=E7=9A=93?= Date: Tue, 27 Sep 2022 17:55:13 +0800 Subject: [PATCH 042/166] refactor: use standard APIs of LCE --- packages/plugin-simulator-size/build.js | 24 +++++++ packages/plugin-simulator-size/build.json | 19 ----- packages/plugin-simulator-size/package.json | 6 +- packages/plugin-simulator-size/src/index.scss | 4 +- packages/plugin-simulator-size/src/index.tsx | 71 +++++++++---------- 5 files changed, 62 insertions(+), 62 deletions(-) create mode 100644 packages/plugin-simulator-size/build.js delete mode 100644 packages/plugin-simulator-size/build.json diff --git a/packages/plugin-simulator-size/build.js b/packages/plugin-simulator-size/build.js new file mode 100644 index 0000000..912cf3e --- /dev/null +++ b/packages/plugin-simulator-size/build.js @@ -0,0 +1,24 @@ +module.exports = { + externals: { + react: 'React', + moment: 'moment', + 'react-dom': 'ReactDOM', + 'prop-types': 'PropTypes', + '@alifd/next': 'Next', + '@alilc/lowcode-engine': 'AliLowCodeEngine' + }, + plugins: [ + [ + '@alilc/build-plugin-alt', + { + type: 'plugin', + // 开启注入调试模式,see:https://www.yuque.com/lce/doc/ulvlkz + inject: true, + // 配置要打开的页面,在注入调试模式下,不配置此项的话不会打开浏览器 + // 支持直接使用官方 demo 项目:https://lowcode-engine.cn/demo/index.html + openUrl: 'https://lowcode-engine.cn/demo/index.html?debug', + } + ], + 'build-plugin-component' + ] +} diff --git a/packages/plugin-simulator-size/build.json b/packages/plugin-simulator-size/build.json deleted file mode 100644 index 2123027..0000000 --- a/packages/plugin-simulator-size/build.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "externals": { - "react": "React", - "moment": "moment", - "react-dom": "ReactDOM", - "prop-types": "PropTypes", - "@alifd/next": "Next", - "@alilc/lowcode-engine": "AliLowCodeEngine" - }, - "plugins": [ - [ - "@alilc/build-plugin-alt", - { - "type": "plugin" - } - ], - "build-plugin-component" - ] -} diff --git a/packages/plugin-simulator-size/package.json b/packages/plugin-simulator-size/package.json index 8ca79c6..ebe4b04 100644 --- a/packages/plugin-simulator-size/package.json +++ b/packages/plugin-simulator-size/package.json @@ -4,7 +4,7 @@ "description": "画布切换", "main": "lib/index.js", "scripts": { - "start": "build-scripts start", + "start": "build-scripts start --config build.js", "build": "build-scripts build --skip-demo", "prepublishOnly": "npm run build", "test": "echo \"Error: no test specified\" && exit 1" @@ -18,7 +18,7 @@ }, "devDependencies": { "@alib/build-scripts": "^0.1.18", - "@alilc/build-plugin-alt": "^1.1.0", + "@alilc/build-plugin-alt": "^1.2.2", "@alilc/lowcode-engine": "^1.0.0", "@types/react": "^16.8.1", "build-plugin-component": "^1.1.0", @@ -26,5 +26,5 @@ "react-dom": "^16.8.1" }, "author": "mark.ck", - "license": "ISC" + "license": "MIT" } diff --git a/packages/plugin-simulator-size/src/index.scss b/packages/plugin-simulator-size/src/index.scss index 2944507..ca671ae 100644 --- a/packages/plugin-simulator-size/src/index.scss +++ b/packages/plugin-simulator-size/src/index.scss @@ -1,7 +1,7 @@ .lp-simulator-pane { display: flex; align-items: center; - margin: 0 8px; + margin: 0 80px; .lp-simulator-pane-item { display: inline-block; width: 32px; @@ -15,7 +15,7 @@ opacity: 1; } } - &.actived { + &.active { background: #F2F2F2; } } diff --git a/packages/plugin-simulator-size/src/index.tsx b/packages/plugin-simulator-size/src/index.tsx index fba2c5b..73e9e24 100644 --- a/packages/plugin-simulator-size/src/index.tsx +++ b/packages/plugin-simulator-size/src/index.tsx @@ -1,13 +1,11 @@ import React from 'react'; import { NumberPicker, Icon } from '@alifd/next'; -import { ILowCodePluginContext, project, material } from '@alilc/lowcode-engine'; +import { ILowCodePluginContext, project, isOpenSource } from '@alilc/lowcode-engine'; import './index.scss'; -const isNewEngineVersion = !!material; - const devices = [ - { key: 'desktop' }, + { key: 'default' }, { key: 'tablet' }, { key: 'phone' }, ]; @@ -16,36 +14,27 @@ const CustomIcon = Icon.createFromIconfontCN({ scriptUrl: 'https://at.alicdn.com/t/font_2896595_33xhsbg9ux5.js', }); -export class SimulatorPane extends React.Component { - static displayName = 'SimulatorPane'; +export class SimulatorResizePane extends React.Component { + static displayName = 'SimulatorResizePane'; state = { - actived: 'desktop', + active: 'default', currentWidth: null }; componentDidMount() { - if (isNewEngineVersion) { - project.onSimulatorRendererReady(() => { - const currentWidth = document.querySelector('.lc-simulator-canvas')?.clientWidth || this.state.currentWidth || 0; - this.setState({ - currentWidth - }); - }); - } else { - // 兼容老版本引擎 - // @ts-ignore - project.onRendererReady(() => { - const currentWidth = document.querySelector('.lc-simulator-canvas')?.clientWidth || this.state.currentWidth || 0; - this.setState({ - currentWidth - }); + // @ts-ignore + const onSimulatorRendererReady = (project.onSimulatorRendererReady || project.onRendererReady).bind(project); + onSimulatorRendererReady(() => { + const currentWidth = document.querySelector('.lc-simulator-canvas')?.clientWidth || this.state.currentWidth || 0; + this.setState({ + currentWidth }); - } + }); } change = (device: string) => { - const simulator = project.simulator; + const simulator = project.simulatorHost; // 切换画布 simulator?.set('device', device); if (document.querySelector('.lc-simulator-canvas')?.style) { @@ -54,7 +43,7 @@ export class SimulatorPane extends React.Component { setTimeout(() => { const currentWidth = document.querySelector('.lc-simulator-canvas')?.clientWidth || this.state.currentWidth || 0; this.setState({ - actived: device, + active: device, currentWidth }); }, 0); @@ -62,7 +51,7 @@ export class SimulatorPane extends React.Component { renderItemSVG(device: string) { switch (device) { - case 'desktop': + case 'default': return ; case 'tablet': return ; @@ -82,7 +71,7 @@ export class SimulatorPane extends React.Component { return ( {this.renderItemSVG(item.key)} @@ -97,9 +86,12 @@ export class SimulatorPane extends React.Component { }); }} onPressEnter={(event: any) => { const value = event?.target?.value; - if (document.querySelector('.lc-simulator-canvas')?.style) { - document.querySelector('.lc-simulator-canvas').style.width = `${value}px` - } + const simulator = project.simulatorHost; + simulator?.set('deviceStyle', { + canvas: { + width: `${value}px`, + } + }) this.setState({ currentWidth: value }); @@ -109,28 +101,31 @@ export class SimulatorPane extends React.Component { ); } } -export default (ctx: ILowCodePluginContext) => { - const simulatorPaneRef = React.createRef(); +const plugin = (ctx: ILowCodePluginContext) => { + const SimulatorResizePaneRef = React.createRef(); return { - name: 'SimulatorPane', // 插件的初始化函数,在引擎初始化之后会立刻调用 init() { // 往引擎增加工具条 ctx.skeleton.add({ - area: 'top', - name: 'SimulatorPane', + area: 'topArea', + name: 'SimulatorResizePane', type: 'Widget', props: { description: '切换画布尺寸', align: "center", }, content: ( - ), }); } }; -}; \ No newline at end of file +}; + +plugin.pluginName = 'SimulatorResizePane'; + +export default plugin; \ No newline at end of file From 8a8e5159cea65fb1caae0127d280ef3151fd03d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LeoYuan=20=E8=A2=81=E5=8A=9B=E7=9A=93?= Date: Wed, 28 Sep 2022 09:50:47 +0800 Subject: [PATCH 043/166] refactor: support inject debug mode for plugin-code-editor --- packages/plugin-code-editor/build.js | 22 ++++++++++++++++++++ packages/plugin-code-editor/build.json | 14 ------------- packages/plugin-code-editor/package.json | 4 ++-- packages/plugin-datasource-pane/package.json | 2 +- packages/plugin-simulator-size/package.json | 2 +- 5 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 packages/plugin-code-editor/build.js delete mode 100644 packages/plugin-code-editor/build.json diff --git a/packages/plugin-code-editor/build.js b/packages/plugin-code-editor/build.js new file mode 100644 index 0000000..9bcddea --- /dev/null +++ b/packages/plugin-code-editor/build.js @@ -0,0 +1,22 @@ +module.exports = { + plugins: [ + [ + 'build-plugin-fusion', + { + themePackage: '@alifd/theme-lowcode-light', + }, + ], + [ + '@alilc/build-plugin-alt', + { + type: 'plugin', + // 开启注入调试模式,see:https://www.yuque.com/lce/doc/ulvlkz + inject: true, + // 配置要打开的页面,在注入调试模式下,不配置此项的话不会打开浏览器 + // 支持直接使用官方 demo 项目:https://lowcode-engine.cn/demo/index.html + // openUrl: 'https://lowcode-engine.cn/demo/index.html?debug', + }, + ], + './build.plugin.js', + ], +}; diff --git a/packages/plugin-code-editor/build.json b/packages/plugin-code-editor/build.json deleted file mode 100644 index f9c8757..0000000 --- a/packages/plugin-code-editor/build.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "plugins": [ - [ - "build-plugin-fusion", - { - "themePackage": "@alifd/theme-lowcode-light" - } - ], - ["@alilc/build-plugin-alt", { - "type": "plugin" - }], - "./build.plugin.js" - ] -} diff --git a/packages/plugin-code-editor/package.json b/packages/plugin-code-editor/package.json index 14ef6d9..cb99343 100644 --- a/packages/plugin-code-editor/package.json +++ b/packages/plugin-code-editor/package.json @@ -12,9 +12,9 @@ "types": "lib/index.d.ts", "README": "README.md", "scripts": { - "start": "build-scripts start", + "start": "build-scripts start --config build.js", "prepublishOnly": "npm run build", - "build": "build-scripts build" + "build": "build-scripts build --skip-demo --config build.js" }, "publishConfig": { "access": "public" diff --git a/packages/plugin-datasource-pane/package.json b/packages/plugin-datasource-pane/package.json index f3cf576..c883cc4 100644 --- a/packages/plugin-datasource-pane/package.json +++ b/packages/plugin-datasource-pane/package.json @@ -8,7 +8,7 @@ ], "scripts": { "start": "build-scripts start --config build.js", - "build": "build-scripts build", + "build": "build-scripts build --config build.js", "test": "ava", "test:snapshot": "ava --update-snapshots" }, diff --git a/packages/plugin-simulator-size/package.json b/packages/plugin-simulator-size/package.json index ebe4b04..dd5e697 100644 --- a/packages/plugin-simulator-size/package.json +++ b/packages/plugin-simulator-size/package.json @@ -5,7 +5,7 @@ "main": "lib/index.js", "scripts": { "start": "build-scripts start --config build.js", - "build": "build-scripts build --skip-demo", + "build": "build-scripts build --skip-demo --config build.js", "prepublishOnly": "npm run build", "test": "echo \"Error: no test specified\" && exit 1" }, From 879215ee35e11285a60278f6206ba0ab5e75d75a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LeoYuan=20=E8=A2=81=E5=8A=9B=E7=9A=93?= Date: Wed, 28 Sep 2022 14:55:43 +0800 Subject: [PATCH 044/166] feat: get options from the second parameter of PluginCreator --- packages/plugin-datasource-pane/src/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/plugin-datasource-pane/src/index.tsx b/packages/plugin-datasource-pane/src/index.tsx index 9347532..21f8935 100644 --- a/packages/plugin-datasource-pane/src/index.tsx +++ b/packages/plugin-datasource-pane/src/index.tsx @@ -13,7 +13,7 @@ export interface Options { } // TODO: 2.0插件传参修改,不支持直接options: Options -const plugin = (ctx: ILowCodePluginContext) => { +const plugin = (ctx: ILowCodePluginContext, options: Options) => { return { name: 'com.alibaba.lowcode.datasource.pane', width: 300, @@ -25,8 +25,8 @@ const plugin = (ctx: ILowCodePluginContext) => { }, // 插件的初始化函数,在引擎初始化之后会立刻调用 init() { - const dataSourceTypes = ctx.preference.getPreferenceValue('dataSourceTypes'); - const importPlugins = ctx.preference.getPreferenceValue('importPlugins'); + const dataSourceTypes = ctx.preference.getPreferenceValue('dataSourceTypes') || options.dataSourceTypes; + const importPlugins = ctx.preference.getPreferenceValue('importPlugins') || options.importPlugins; const schemaDock = ctx.skeleton.add({ area: 'leftArea', name: 'dataSourcePane', From e0276882934330189190203c523a037b8790b355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LeoYuan=20=E8=A2=81=E5=8A=9B=E7=9A=93?= Date: Wed, 28 Sep 2022 15:18:36 +0800 Subject: [PATCH 045/166] chore(datasource-pane): bump 1.0.7 --- packages/plugin-datasource-pane/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-datasource-pane/package.json b/packages/plugin-datasource-pane/package.json index c883cc4..38a797f 100644 --- a/packages/plugin-datasource-pane/package.json +++ b/packages/plugin-datasource-pane/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-plugin-datasource-pane", - "version": "1.0.6", + "version": "1.0.7", "description": "低代码引擎数据源面板", "main": "lib/index.js", "files": [ From bded42604466fdc4c990234ffff29a78becb29a6 Mon Sep 17 00:00:00 2001 From: liujuping Date: Tue, 8 Nov 2022 16:25:51 +0800 Subject: [PATCH 046/166] chore(release): publish lowcode-plugin-simulator-select 1.0.2 --- packages/plugin-simulator-size/package.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/plugin-simulator-size/package.json b/packages/plugin-simulator-size/package.json index dd5e697..844278c 100644 --- a/packages/plugin-simulator-size/package.json +++ b/packages/plugin-simulator-size/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-plugin-simulator-select", - "version": "1.0.0", + "version": "1.0.2", "description": "画布切换", "main": "lib/index.js", "scripts": { @@ -26,5 +26,10 @@ "react-dom": "^16.8.1" }, "author": "mark.ck", + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-simulator-size" + }, "license": "MIT" } From 0982f9f9183d7f3f55a8f15d43cf4fba12b36104 Mon Sep 17 00:00:00 2001 From: JackLian Date: Thu, 10 Nov 2022 17:32:05 +0800 Subject: [PATCH 047/166] feat: add plugin plugin-set-ref-prop --- packages/action-block/.gitignore | 104 -------------------- packages/plugin-block/.gitignore | 104 -------------------- packages/plugin-code-editor/.gitignore | 104 -------------------- packages/plugin-components-pane/.gitignore | 26 ----- packages/plugin-datasource-pane/.gitignore | 104 -------------------- packages/plugin-manual/.gitignore | 43 --------- packages/plugin-schema/.gitignore | 43 --------- packages/plugin-set-ref-prop/CHANGELOG.md | 0 packages/plugin-set-ref-prop/README.md | 27 ++++++ packages/plugin-set-ref-prop/build.json | 17 ++++ packages/plugin-set-ref-prop/package.json | 34 +++++++ packages/plugin-set-ref-prop/src/index.tsx | 79 +++++++++++++++ packages/plugin-set-ref-prop/tsconfig.json | 9 ++ packages/plugin-simulator-size/.gitignore | 104 -------------------- packages/plugin-undo-redo/.gitignore | 104 -------------------- packages/plugin-zh-en/.gitignore | 106 --------------------- 16 files changed, 166 insertions(+), 842 deletions(-) delete mode 100644 packages/action-block/.gitignore delete mode 100644 packages/plugin-block/.gitignore delete mode 100644 packages/plugin-code-editor/.gitignore delete mode 100644 packages/plugin-components-pane/.gitignore delete mode 100644 packages/plugin-datasource-pane/.gitignore delete mode 100644 packages/plugin-manual/.gitignore delete mode 100644 packages/plugin-schema/.gitignore create mode 100644 packages/plugin-set-ref-prop/CHANGELOG.md create mode 100644 packages/plugin-set-ref-prop/README.md create mode 100644 packages/plugin-set-ref-prop/build.json create mode 100644 packages/plugin-set-ref-prop/package.json create mode 100644 packages/plugin-set-ref-prop/src/index.tsx create mode 100644 packages/plugin-set-ref-prop/tsconfig.json delete mode 100644 packages/plugin-simulator-size/.gitignore delete mode 100644 packages/plugin-undo-redo/.gitignore delete mode 100644 packages/plugin-zh-en/.gitignore diff --git a/packages/action-block/.gitignore b/packages/action-block/.gitignore deleted file mode 100644 index 77dfbd1..0000000 --- a/packages/action-block/.gitignore +++ /dev/null @@ -1,104 +0,0 @@ -# project custom -build -dist -lib -es -package-lock.json -yarn.lock -deploy-space/packages -deploy-space/.env - - -# IDE -.vscode -.idea - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release -lib - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env -.env.test - -# parcel-bundler cache (https://parceljs.org/) -.cache - -# next.js build output -.next - -# nuxt.js build output -.nuxt - -# vuepress build output -.vuepress/dist - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# mac config files -.DS_Store - -# codealike -codealike.json diff --git a/packages/plugin-block/.gitignore b/packages/plugin-block/.gitignore deleted file mode 100644 index 77dfbd1..0000000 --- a/packages/plugin-block/.gitignore +++ /dev/null @@ -1,104 +0,0 @@ -# project custom -build -dist -lib -es -package-lock.json -yarn.lock -deploy-space/packages -deploy-space/.env - - -# IDE -.vscode -.idea - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release -lib - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env -.env.test - -# parcel-bundler cache (https://parceljs.org/) -.cache - -# next.js build output -.next - -# nuxt.js build output -.nuxt - -# vuepress build output -.vuepress/dist - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# mac config files -.DS_Store - -# codealike -codealike.json diff --git a/packages/plugin-code-editor/.gitignore b/packages/plugin-code-editor/.gitignore deleted file mode 100644 index 77dfbd1..0000000 --- a/packages/plugin-code-editor/.gitignore +++ /dev/null @@ -1,104 +0,0 @@ -# project custom -build -dist -lib -es -package-lock.json -yarn.lock -deploy-space/packages -deploy-space/.env - - -# IDE -.vscode -.idea - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release -lib - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env -.env.test - -# parcel-bundler cache (https://parceljs.org/) -.cache - -# next.js build output -.next - -# nuxt.js build output -.nuxt - -# vuepress build output -.vuepress/dist - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# mac config files -.DS_Store - -# codealike -codealike.json diff --git a/packages/plugin-components-pane/.gitignore b/packages/plugin-components-pane/.gitignore deleted file mode 100644 index 8523c97..0000000 --- a/packages/plugin-components-pane/.gitignore +++ /dev/null @@ -1,26 +0,0 @@ -# See https://help.github.com/ignore-files/ for more about ignoring files. - -# dependencies -node_modules/ - -# production -build/ -dist/ -tmp/ -lib/ -es/ - -# misc -.idea/ -.happypack -.DS_Store -*.swp -*.dia~ -.ice - -npm-debug.log* -yarn-debug.log* -yarn-error.log* -index.module.scss.d.ts - -node_modules diff --git a/packages/plugin-datasource-pane/.gitignore b/packages/plugin-datasource-pane/.gitignore deleted file mode 100644 index 77dfbd1..0000000 --- a/packages/plugin-datasource-pane/.gitignore +++ /dev/null @@ -1,104 +0,0 @@ -# project custom -build -dist -lib -es -package-lock.json -yarn.lock -deploy-space/packages -deploy-space/.env - - -# IDE -.vscode -.idea - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release -lib - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env -.env.test - -# parcel-bundler cache (https://parceljs.org/) -.cache - -# next.js build output -.next - -# nuxt.js build output -.nuxt - -# vuepress build output -.vuepress/dist - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# mac config files -.DS_Store - -# codealike -codealike.json diff --git a/packages/plugin-manual/.gitignore b/packages/plugin-manual/.gitignore deleted file mode 100644 index 7d916c2..0000000 --- a/packages/plugin-manual/.gitignore +++ /dev/null @@ -1,43 +0,0 @@ -node_modules/ -build/ -es/ -lib/ -.idea/ -.vscode/ -jsconfig.json -typings.json -typings/ -~* - -# Packages # -############ -# it's better to unpack these files and commit the raw source -# git has its own built in compression methods -*.7z -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip - -# Logs and databases # -###################### -*.log -*.sql -*.sqlite - -# OS generated files # -###################### -.DS_Store -*.swp -.DS_Store? -._* -.Spotlight-V100 -.Trashes -ehthumbs.db -Thumbs.db -.lock -package-lock.json -.vdev diff --git a/packages/plugin-schema/.gitignore b/packages/plugin-schema/.gitignore deleted file mode 100644 index 10239e7..0000000 --- a/packages/plugin-schema/.gitignore +++ /dev/null @@ -1,43 +0,0 @@ -node_modules/ -build/ -es/ -lib/ -.idea/ -.vscode/ -jsconfig.json -typings.json -typings/ -~* - -# Packages # -############ -# it's better to unpack these files and commit the raw source -# git has its own built in compression methods -*.7z -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip - -# Logs and databases # -###################### -*.log -*.sql -*.sqlite - -# OS generated files # -###################### -.DS_Store - *.swp -.DS_Store? -._* -.Spotlight-V100 -.Trashes -ehthumbs.db -Thumbs.db -.lock -package-lock.json -.vdev diff --git a/packages/plugin-set-ref-prop/CHANGELOG.md b/packages/plugin-set-ref-prop/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/packages/plugin-set-ref-prop/README.md b/packages/plugin-set-ref-prop/README.md new file mode 100644 index 0000000..409106d --- /dev/null +++ b/packages/plugin-set-ref-prop/README.md @@ -0,0 +1,27 @@ +# @alilc/lowcode-plugin-zh-cn [![][npm-image]][npm-url] +为设计提供在高级设置面板中设置ref-id的能力 +plugin for setting ref-id. + +--- + +## 使用 + +### 注册插件 +```jsx +import { plugins } from '@alilc/lowcode-engine'; +import SetRefPropPlugin from '@alilc/lowcode-plugin-set-ref-prop'; + +// 注册到引擎 +plugins.register(SetRefPropPlugin); +``` + +### 插件属性 & 方法 + +无对外暴露的属性和方法 + +### 依赖插件 + +该插件依赖以下插件: + +| 插件名 | 包名 | +| --- | --- | diff --git a/packages/plugin-set-ref-prop/build.json b/packages/plugin-set-ref-prop/build.json new file mode 100644 index 0000000..1767fef --- /dev/null +++ b/packages/plugin-set-ref-prop/build.json @@ -0,0 +1,17 @@ +{ + "plugins": [ + [ + "@alilc/build-plugin-alt", + { + "type": "plugin", + "inject": true + } + ], + [ + "build-plugin-fusion", + { + "themePackage": "@alifd/theme-lowcode-light" + } + ] + ] +} diff --git a/packages/plugin-set-ref-prop/package.json b/packages/plugin-set-ref-prop/package.json new file mode 100644 index 0000000..8f15c9b --- /dev/null +++ b/packages/plugin-set-ref-prop/package.json @@ -0,0 +1,34 @@ +{ + "name": "@alilc/lowcode-plugin-set-ref-prop", + "version": "1.0.0", + "description": "alibaba lowcode editor plugin for setting ref-id", + "files": [ + "es", + "lib" + ], + "main": "lib/index.js", + "module": "es/index.js", + "scripts": { + "start": "build-scripts start", + "build": "build-scripts build", + "prepublishOnly": "npm run build" + }, + "dependencies": { + "@alilc/lowcode-types": "^1.0.0", + "@alilc/lowcode-utils": "^1.0.0", + "react": "^16.8.1", + "react-dom": "^16.8.1", + "uuid": "^8.3.2" + }, + "devDependencies": { + "@alib/build-scripts": "^0.1.3", + "@alilc/build-plugin-alt": "^1.0.0", + "@alilc/lowcode-engine": "^1.0.0", + "@types/react": "^16.9.13", + "@types/react-dom": "^16.9.4", + "build-plugin-fusion": "^0.1.22" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/plugin-set-ref-prop/src/index.tsx b/packages/plugin-set-ref-prop/src/index.tsx new file mode 100644 index 0000000..b51ad2b --- /dev/null +++ b/packages/plugin-set-ref-prop/src/index.tsx @@ -0,0 +1,79 @@ +import { TransformedComponentMetadata, FieldConfig } from '@alilc/lowcode-types'; +import { v4 as uuidv4 } from 'uuid'; +import { material } from '@alilc/lowcode-engine'; + +function addonCombine(metadata: TransformedComponentMetadata) { + const { componentName, configure = {} } = metadata; + + const isRoot: boolean = componentName === 'Page' || componentName === 'Component'; + + if (isRoot) { + return metadata; + } + + let advancedGroup: FieldConfig | undefined; + + const refItem: FieldConfig = { + title: { + label: 'refId', + tip: '用于获取组件实例,调用物料内部方法', + icon: '', + }, + name: 'ref', + setter: { + componentName: 'StringSetter', + }, + defaultValue: () => { + const uuid = uuidv4().replace('-', '').substring(0, 8); + return `${componentName.toLowerCase()}-${uuid}`; + }, + extraProps: { + display: 'block', + supportVariable: false, + }, + }; + + if (!configure.combined) { + configure.combined = []; + } + + advancedGroup = configure.combined?.filter(d => d.name === '#advanced')[0]; + + if (!advancedGroup) { + advancedGroup = { + name: '#advanced', + title: { type: 'i18n', 'zh-CN': '高级', 'en-US': 'Advanced' }, + items: [ + refItem, + ], + }; + + configure.combined.push(advancedGroup); + } + + if (!advancedGroup.items) { + advancedGroup.items = [refItem]; + } + + const advanceItems: FieldConfig[] = advancedGroup.items || []; + + if (!advanceItems || !advanceItems.length || !advanceItems?.filter(d => d.name === 'ref').length) { + advanceItems.push(refItem); + } + + return { + ...metadata, + configure, + }; +} + +const SetRefPropPlugin = () => { + return { + init() { + material.registerMetadataTransducer(addonCombine, 110, 'register-ref-prop'); + }, + }; +}; + +SetRefPropPlugin.pluginName = 'SetRefPropPlugin'; +export default SetRefPropPlugin; \ No newline at end of file diff --git a/packages/plugin-set-ref-prop/tsconfig.json b/packages/plugin-set-ref-prop/tsconfig.json new file mode 100644 index 0000000..c37b76e --- /dev/null +++ b/packages/plugin-set-ref-prop/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "lib" + }, + "include": [ + "./src/" + ] +} diff --git a/packages/plugin-simulator-size/.gitignore b/packages/plugin-simulator-size/.gitignore deleted file mode 100644 index b1a02c7..0000000 --- a/packages/plugin-simulator-size/.gitignore +++ /dev/null @@ -1,104 +0,0 @@ -# project custom -build -dist -lib -es -package-lock.json -yarn.lock -deploy-space/packages -deploy-space/.env - - -# IDE -.vscode -.idea - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env -.env.test - -# parcel-bundler cache (https://parceljs.org/) -.cache - -# next.js build output -.next - -# nuxt.js build output -.nuxt - -# vuepress build output -.vuepress/dist - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# mac config files -.DS_Store - -# codealike -codealike.json -.node diff --git a/packages/plugin-undo-redo/.gitignore b/packages/plugin-undo-redo/.gitignore deleted file mode 100644 index 77dfbd1..0000000 --- a/packages/plugin-undo-redo/.gitignore +++ /dev/null @@ -1,104 +0,0 @@ -# project custom -build -dist -lib -es -package-lock.json -yarn.lock -deploy-space/packages -deploy-space/.env - - -# IDE -.vscode -.idea - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release -lib - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env -.env.test - -# parcel-bundler cache (https://parceljs.org/) -.cache - -# next.js build output -.next - -# nuxt.js build output -.nuxt - -# vuepress build output -.vuepress/dist - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# mac config files -.DS_Store - -# codealike -codealike.json diff --git a/packages/plugin-zh-en/.gitignore b/packages/plugin-zh-en/.gitignore deleted file mode 100644 index 2073a21..0000000 --- a/packages/plugin-zh-en/.gitignore +++ /dev/null @@ -1,106 +0,0 @@ -# project custom -build -dist -packages/*/lib/ -packages/*/es/ -packages/*/dist/ -packages/*/output/ -package-lock.json -yarn.lock -deploy-space/packages -deploy-space/.env - - -# IDE -.vscode -.idea - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release -lib - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env -.env.test - -# parcel-bundler cache (https://parceljs.org/) -.cache - -# next.js build output -.next - -# nuxt.js build output -.nuxt - -# vuepress build output -.vuepress/dist - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# mac config files -.DS_Store - -# codealike -codealike.json From 071831125bc563a670218effe20ff239e288f16c Mon Sep 17 00:00:00 2001 From: JackLian Date: Thu, 10 Nov 2022 17:45:47 +0800 Subject: [PATCH 048/166] chore: add repo info --- packages/plugin-set-ref-prop/package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/plugin-set-ref-prop/package.json b/packages/plugin-set-ref-prop/package.json index 8f15c9b..b569466 100644 --- a/packages/plugin-set-ref-prop/package.json +++ b/packages/plugin-set-ref-prop/package.json @@ -2,6 +2,11 @@ "name": "@alilc/lowcode-plugin-set-ref-prop", "version": "1.0.0", "description": "alibaba lowcode editor plugin for setting ref-id", + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-set-ref-prop" + }, "files": [ "es", "lib" From 199fc5c5067e748423a6c5c4dc8d23adc65e0fc9 Mon Sep 17 00:00:00 2001 From: JackLian Date: Thu, 10 Nov 2022 18:06:54 +0800 Subject: [PATCH 049/166] chore: add repo info --- packages/action-block/package.json | 5 +++++ packages/base-monaco-editor/package.json | 7 ++++++- packages/plugin-block/package.json | 7 ++++++- packages/plugin-code-editor/package.json | 7 ++++++- packages/plugin-components-pane/package.json | 5 +++++ packages/plugin-datasource-pane/package.json | 7 ++++++- packages/plugin-manual/package.json | 7 ++++++- packages/plugin-schema/package.json | 7 ++++++- packages/plugin-undo-redo/package.json | 5 +++++ packages/plugin-zh-en/package.json | 5 +++++ 10 files changed, 56 insertions(+), 6 deletions(-) diff --git a/packages/action-block/package.json b/packages/action-block/package.json index 25e37fa..80aaf97 100644 --- a/packages/action-block/package.json +++ b/packages/action-block/package.json @@ -3,6 +3,11 @@ "version": "1.0.0-beta.0", "description": "", "main": "lib/index.js", + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/action-block" + }, "scripts": { "start": "build-scripts start", "build": "build-scripts build", diff --git a/packages/base-monaco-editor/package.json b/packages/base-monaco-editor/package.json index bbbf077..c6153a3 100644 --- a/packages/base-monaco-editor/package.json +++ b/packages/base-monaco-editor/package.json @@ -62,5 +62,10 @@ "commit-msg": "f2elint commit-msg-scan" } }, - "homepage": "https://unpkg.com/@alilc/lowcode-plugin-base-monaco-editor@1.1.1/build/index.html" + "homepage": "https://unpkg.com/@alilc/lowcode-plugin-base-monaco-editor@1.1.1/build/index.html", + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/base-monaco-editor" + } } diff --git a/packages/plugin-block/package.json b/packages/plugin-block/package.json index 2c79be7..6c27ed4 100644 --- a/packages/plugin-block/package.json +++ b/packages/plugin-block/package.json @@ -22,5 +22,10 @@ "build-plugin-fusion": "^0.1.22", "build-plugin-moment-locales": "^0.1.3" }, - "homepage": "https://unpkg.com/@alilc/lowcode-plugin-block@1.0.0-beta.0/build/index.html" + "homepage": "https://unpkg.com/@alilc/lowcode-plugin-block@1.0.0-beta.0/build/index.html", + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-block" + } } diff --git a/packages/plugin-code-editor/package.json b/packages/plugin-code-editor/package.json index cb99343..d16a232 100644 --- a/packages/plugin-code-editor/package.json +++ b/packages/plugin-code-editor/package.json @@ -49,5 +49,10 @@ "@types/react-dom": "^16.9.4", "build-plugin-fusion": "^0.1.22" }, - "license": "MIT" + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-code-editor" + } } diff --git a/packages/plugin-components-pane/package.json b/packages/plugin-components-pane/package.json index 33b0615..28e9134 100644 --- a/packages/plugin-components-pane/package.json +++ b/packages/plugin-components-pane/package.json @@ -57,5 +57,10 @@ "classnames": "^2.3.1", "lodash.debounce": "^4.0.8", "react": "^16.0.0" + }, + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-components-pane" } } diff --git a/packages/plugin-datasource-pane/package.json b/packages/plugin-datasource-pane/package.json index 38a797f..fe5a1db 100644 --- a/packages/plugin-datasource-pane/package.json +++ b/packages/plugin-datasource-pane/package.json @@ -74,5 +74,10 @@ "traverse": "^0.6.6", "xstate": "^4.26.0" }, - "homepage": "https://unpkg.com/@alilc/lowcode-plugin-datasource-pane@1.0.6/build/index.html" + "homepage": "https://unpkg.com/@alilc/lowcode-plugin-datasource-pane@1.0.6/build/index.html", + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-datasource-pane" + } } diff --git a/packages/plugin-manual/package.json b/packages/plugin-manual/package.json index 0442c29..84a6bfd 100644 --- a/packages/plugin-manual/package.json +++ b/packages/plugin-manual/package.json @@ -30,5 +30,10 @@ "build-plugin-fusion": "^0.1.19", "@alilc/build-plugin-alt": "^1.0.0" }, - "license": "MIT" + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-manual" + } } diff --git a/packages/plugin-schema/package.json b/packages/plugin-schema/package.json index 4aab007..80c15ed 100644 --- a/packages/plugin-schema/package.json +++ b/packages/plugin-schema/package.json @@ -37,5 +37,10 @@ "@types/react": "^16.0.3", "build-plugin-fusion": "^0.1.19" }, - "license": "MIT" + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-schema" + } } diff --git a/packages/plugin-undo-redo/package.json b/packages/plugin-undo-redo/package.json index cacf19a..670306a 100644 --- a/packages/plugin-undo-redo/package.json +++ b/packages/plugin-undo-redo/package.json @@ -34,5 +34,10 @@ }, "publishConfig": { "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-undo-redo" } } diff --git a/packages/plugin-zh-en/package.json b/packages/plugin-zh-en/package.json index 5c8c057..dcde3fe 100644 --- a/packages/plugin-zh-en/package.json +++ b/packages/plugin-zh-en/package.json @@ -29,5 +29,10 @@ }, "publishConfig": { "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-zh-en" } } From f02abc63327f52c977e1da7ffc90b5ae80cf7b47 Mon Sep 17 00:00:00 2001 From: JackLian Date: Thu, 10 Nov 2022 19:10:51 +0800 Subject: [PATCH 050/166] chore: add types to package.json --- packages/plugin-set-ref-prop/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/plugin-set-ref-prop/package.json b/packages/plugin-set-ref-prop/package.json index b569466..8b5a5fe 100644 --- a/packages/plugin-set-ref-prop/package.json +++ b/packages/plugin-set-ref-prop/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-plugin-set-ref-prop", - "version": "1.0.0", + "version": "1.0.1", "description": "alibaba lowcode editor plugin for setting ref-id", "repository": { "type": "git", @@ -12,6 +12,7 @@ "lib" ], "main": "lib/index.js", + "types": "lib/index.d.ts", "module": "es/index.js", "scripts": { "start": "build-scripts start", From 857c49745dad4f973349928e4f619dfc02316194 Mon Sep 17 00:00:00 2001 From: sy296565890 <85245446+sy296565890@users.noreply.github.com> Date: Thu, 17 Nov 2022 14:18:17 +0800 Subject: [PATCH 051/166] Update JsEditor.tsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 接入编辑器=>方法 2.2=> 使用 skeletonCabin.Workbench 方式初始化, 编辑index.js 源码时 光标总是在输入之前 --- .../plugin-code-editor/src/components/JSEditor/JsEditor.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx b/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx index c84a816..f71ba23 100644 --- a/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx +++ b/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx @@ -250,7 +250,10 @@ export class JsEditor extends PureComponent { const pos = monacoEditor.getPosition(); this.setState({ errorInfo, hasError, code: newCode, errorLocation }, () => { - monacoEditor.setPosition(pos); + if(hasError) { + pos.column += 1; + monacoEditor.setPosition(pos); + } // update error decorations if (this.lastErrorDecoration) { From de6c4c02f1c32b9a7249ce8bfce7f8f5995a1cfa Mon Sep 17 00:00:00 2001 From: sy296565890 <85245446+sy296565890@users.noreply.github.com> Date: Thu, 17 Nov 2022 14:47:58 +0800 Subject: [PATCH 052/166] Update JsEditor.tsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit monacoEditor.setPosition(pos); 多余的代码 导致每次输入或粘贴之后 光标总是停留在之前的位置 --- .../src/components/JSEditor/JsEditor.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx b/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx index f71ba23..6eb275a 100644 --- a/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx +++ b/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx @@ -248,13 +248,9 @@ export class JsEditor extends PureComponent { return; } - const pos = monacoEditor.getPosition(); + // const pos = monacoEditor.getPosition(); this.setState({ errorInfo, hasError, code: newCode, errorLocation }, () => { - if(hasError) { - pos.column += 1; - monacoEditor.setPosition(pos); - } - + // monacoEditor.setPosition(pos); // update error decorations if (this.lastErrorDecoration) { monacoEditor.deltaDecorations( From 18dbe579310afdc230bd13bd5874019bbe3a6afd Mon Sep 17 00:00:00 2001 From: JackLian Date: Fri, 18 Nov 2022 09:42:12 +0800 Subject: [PATCH 053/166] fix: remove useless demo folder --- demo/build.json | 38 --- demo/build.plugin.js | 58 ----- demo/package.json | 45 ---- demo/public/assets.json | 139 ----------- demo/public/favicon.png | Bin 3612 -> 0 bytes demo/public/index.html | 41 ---- demo/public/mock-pages.json | 1 - demo/public/mock/info.json | 3 - demo/public/preview.html | 25 -- demo/public/schema.json | 291 ----------------------- demo/src/index.ts | 36 --- demo/src/preview.tsx | 63 ----- demo/src/sample-plugins/logo/index.scss | 11 - demo/src/sample-plugins/logo/index.tsx | 18 -- demo/src/setters/behavior-setter.tsx | 27 --- demo/src/setters/custom-setter.tsx | 12 - demo/src/universal/global.scss | 55 ----- demo/src/universal/plugin.tsx | 272 --------------------- demo/src/universal/utils.ts | 298 ------------------------ demo/tsconfig.json | 44 ---- 20 files changed, 1477 deletions(-) delete mode 100644 demo/build.json delete mode 100644 demo/build.plugin.js delete mode 100644 demo/package.json delete mode 100644 demo/public/assets.json delete mode 100644 demo/public/favicon.png delete mode 100644 demo/public/index.html delete mode 100644 demo/public/mock-pages.json delete mode 100644 demo/public/mock/info.json delete mode 100644 demo/public/preview.html delete mode 100644 demo/public/schema.json delete mode 100644 demo/src/index.ts delete mode 100644 demo/src/preview.tsx delete mode 100644 demo/src/sample-plugins/logo/index.scss delete mode 100644 demo/src/sample-plugins/logo/index.tsx delete mode 100644 demo/src/setters/behavior-setter.tsx delete mode 100644 demo/src/setters/custom-setter.tsx delete mode 100644 demo/src/universal/global.scss delete mode 100644 demo/src/universal/plugin.tsx delete mode 100644 demo/src/universal/utils.ts delete mode 100644 demo/tsconfig.json diff --git a/demo/build.json b/demo/build.json deleted file mode 100644 index 11f88e5..0000000 --- a/demo/build.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "entry": { - "index": "src/index" - }, - "vendor": false, - "devServer": { - "hot": false - }, - "publicPath": "public", - "externals": { - "react": "var window.React", - "react-dom": "var window.ReactDOM", - "prop-types": "var window.PropTypes", - "@alifd/next": "var window.Next", - "@alilc/lowcode-engine": "var window.AliLowCodeEngine", - "@alilc/lowcode-editor-core": "var window.AliLowCodeEngine.common.editorCabin", - "@alilc/lowcode-editor-skeleton": "var window.AliLowCodeEngine.common.skeletonCabin", - "@alilc/lowcode-designer": "var window.AliLowCodeEngine.common.designerCabin", - "@alilc/lowcode-engine-ext": "var window.AliLowCodeEngineExt", - "@ali/lowcode-engine": "var window.AliLowCodeEngine", - "moment": "var window.moment", - "lodash": "var window._" - }, - "plugins": [ - [ - "build-plugin-react-app" - ], - [ - "build-plugin-moment-locales", - { - "locales": [ - "zh-cn" - ] - } - ], - "./build.plugin.js" - ] -} diff --git a/demo/build.plugin.js b/demo/build.plugin.js deleted file mode 100644 index 12882de..0000000 --- a/demo/build.plugin.js +++ /dev/null @@ -1,58 +0,0 @@ -const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); - -const HtmlWebpackPlugin = require('html-webpack-plugin'); - -module.exports = ({ onGetWebpackConfig }) => { - onGetWebpackConfig((config) => { - config.resolve.plugin('tsconfigpaths').use(TsconfigPathsPlugin, [ - { - configFile: './tsconfig.json', - }, - ]); - - config.merge({ - node: { - fs: 'empty', - }, - }); - config.merge({ - entry: { - index: require.resolve('./src/index.ts'), - preview: require.resolve('./src/preview.tsx'), - }, - }); - config - .plugin('index') - .use(HtmlWebpackPlugin, [ - { - inject: false, - templateParameters: { - }, - template: require.resolve('./public/index.html'), - filename: 'index.html', - }, - ]); - config - .plugin('preview') - .use(HtmlWebpackPlugin, [ - { - inject: false, - templateParameters: { - }, - template: require.resolve('./public/preview.html'), - filename: 'preview.html', - }, - ]); - - config.plugins.delete('hot'); - config.devServer.hot(false); - - config.module // fixes https://github.com/graphql/graphql-js/issues/1272 - .rule('mjs$') - .test(/\.mjs$/) - .include - .add(/node_modules/) - .end() - .type('javascript/auto'); - }); -}; diff --git a/demo/package.json b/demo/package.json deleted file mode 100644 index 6d61e11..0000000 --- a/demo/package.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "@alilc/lowcode-plugins-demo", - "version": "1.0.0", - "description": "Low-Code Engine 低代码搭建引擎 Demo 项目", - "repository": "git@github.com:alibaba/lowcode-demo.git", - "license": "MIT", - "main": "index.js", - "scripts": { - "start": "build-scripts start --disable-reload", - "build": "build-scripts build", - "pub": "node ./scripts/watchdog.js && npm pub" - }, - "files": [ - "build" - ], - "config": {}, - "dependencies": { - "@alilc/lowcode-plugin-code-editor": "^1.0.1", - "@alilc/lowcode-plugin-code-generator": "^1.0.1", - "@alilc/lowcode-plugin-components-pane": "^1.0.2", - "@alilc/lowcode-plugin-datasource-pane": "1.0.0", - "@alilc/lowcode-plugin-inject": "^1.0.0", - "@alilc/lowcode-plugin-manual": "^1.0.0", - "@alilc/lowcode-plugin-schema": "^1.0.0", - "@alilc/lowcode-plugin-simulator-select": "^1.0.0", - "@alilc/lowcode-plugin-undo-redo": "^1.0.0", - "@alilc/lowcode-plugin-zh-en": "^1.0.0", - "@alilc/lowcode-react-renderer": "^1.0.0", - "@alilc/lowcode-setter-behavior": "^1.0.0", - "@alilc/lowcode-setter-title": "^1.0.2" - }, - "devDependencies": { - "@alilc/lowcode-engine": "^1.0.0", - "@alilc/lowcode-types": "^1.0.0", - "@alib/build-scripts": "^0.1.18", - "@types/events": "^3.0.0", - "@types/react": "^16.8.3", - "@types/react-dom": "^16.8.2", - "@types/streamsaver": "^2.0.0", - "build-plugin-fusion": "^0.1.0", - "build-plugin-moment-locales": "^0.1.0", - "build-plugin-react-app": "^1.1.2", - "tsconfig-paths-webpack-plugin": "^3.2.0" - } -} diff --git a/demo/public/assets.json b/demo/public/assets.json deleted file mode 100644 index 3cd9173..0000000 --- a/demo/public/assets.json +++ /dev/null @@ -1,139 +0,0 @@ -{ - "packages": [ - { - "package": "moment", - "version": "2.24.0", - "urls": [ - "https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js" - ], - "library": "moment" - }, - { - "package": "lodash", - "library": "_", - "urls": [ - "https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js" - ] - }, - { - "title": "fusion组件库", - "package": "@alifd/next", - "version": "1.24.18", - "urls": [ - "https://g.alicdn.com/code/lib/alifd__next/1.24.18/next.min.css", - "https://g.alicdn.com/code/lib/alifd__next/1.24.18/next-with-locales.min.js" - ], - "library": "Next" - }, - { - "title": "NextTable", - "package": "NextTable", - "version": "1.0.1", - "urls": [ - "https://g.alicdn.com/fusion-platform/pro-table/1.0.1/next-table.js", - "https://g.alicdn.com/fusion-platform/pro-table/1.0.1/next-table.css" - ], - "library": "NextTable" - }, - { - "package": "@alilc/lowcode-materials", - "version": "1.0.2-beta.1", - "library": "AlilcLowcodeMaterials", - "urls": [ - "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/dist/AlilcLowcodeMaterials.js", - "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/dist/AlilcLowcodeMaterials.css" - ], - "editUrls": [ - "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/build/lowcode/view.js", - "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/build/lowcode/view.css" - ] - }, - { - "package": "@alifd/pro-layout", - "version": "1.0.1-beta.6", - "library": "AlifdProLayout", - "urls": [ - "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/dist/AlifdProLayout.js", - "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/dist/AlifdProLayout.css" - ], - "editUrls": [ - "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/build/lowcode/view.js", - "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/build/lowcode/view.css" - ] - }, - { - "package": "@alifd/fusion-ui", - "version": "1.0.5-beta.1", - "library": "AlifdFusionUi", - "urls": [ - "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/dist/AlifdFusionUi.js", - "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/dist/AlifdFusionUi.css" - ], - "editUrls": [ - "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/build/lowcode/view.js", - "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/build/lowcode/view.css" - ] - } - ], - "components": [ - { - "exportName": "AlilcLowcodeMaterialsMeta", - "npm": { - "package": "@alilc/lowcode-materials" - }, - "url": "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/build/lowcode/meta.js", - "urls": { - "default": "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/build/lowcode/meta.js", - "design": "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/build/lowcode/meta.design.js" - } - }, - { - "exportName": "AlifdProLayoutMeta", - "npm": { - "package": "@alifd/pro-layout", - "version": "1.0.1-beta.6" - }, - "url": "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/build/lowcode/meta.js", - "urls": { - "default": "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/build/lowcode/meta.js", - "design": "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/build/lowcode/meta.design.js" - } - }, - { - "exportName": "AlifdFusionUiMeta", - "npm": { - "package": "@alifd/fusion-ui" - }, - "url": "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/build/lowcode/meta.js", - "urls": { - "default": "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/build/lowcode/meta.js", - "design": "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/build/lowcode/meta.design.js" - } - } - ], - "sort": { - "groupList": [ - "精选组件", - "原子组件" - ], - "categoryList": [ - "基础元素", - "布局容器类", - "表格类", - "表单详情类", - "帮助类", - "对话框类", - "业务类", - "通用", - "引导", - "信息输入", - "信息展示", - "信息反馈" - ] - }, - "groupList": [ - "精选组件", - "原子组件" - ], - "ignoreComponents": {} -} diff --git a/demo/public/favicon.png b/demo/public/favicon.png deleted file mode 100644 index 307ffbd82dba398d6db6459102bff331eef7df6b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3612 zcmV+%4&(8OP)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91TA%{}1ONa40RR91S^xk507-m{w*UYQhDk(0RCodHT?>#D#Towp*}H|i z+dTn!mde8i1wu-BR8XSvS)#mzvO>hDgg^x>qli)9_Kq+LcPJ3Bu+SK-ynID85>dgJ zf)ItMP%%POG)f4F%3HbJz2lbM?R>q<9(%hpvoo`^$1F!z?agfW|Ns5>H@$y%|NT!N z)9I8O0kys}9V_WeB7QCjaV`-)%ss()2JZ3U%EY}OCKh25^exJF;@jsa+eD=m&vNcs z+8Bi@I#8tHdjNF^fEtX}4+gmB!oBs2;z-h|Ic09)=5q&i}FecJ(A2&TE=5fm5G(0gxyZEdH6iu2h_ zJ5PO}Rndte;mJhtI{@%`&ZB5b;y0%*&~w8>C>pyHqyEk4y=A80C>Rkpo_d2}APn0Z z`vpM$ZW1@AMzs8%!l?uF-0&cZ#+Q(YU7a5!1>j~nT>L<*4QEp%S__bGgNbmbDHL?D zc!5q%(PmRq>|XRi*kE^<2+iLE7c0;;;j#2>=t+RvRkLC4%RE$EJ$gCjzI#K9DHglS zeOMZ5R79pjJ=zx_zkpTT#fD9CW1*mZ$u+$jl}p#DIy8xzBJUR^$g&*@ZFlD=odQ`E zK8ge%$2fOuDyulJJixs`2f{tzOEWnqjtV>cMgWq9ydk)0#$pb)OGC2 zyd5S;I^_@Jm(l@C^gfV%VZr9$OrMgxyy6}LKnkatcPA59cwD{W7OGqAKlB1Ib~J_y8w|V z(BsGFq%}`aO$#gQ+ynI7-~fuz1~k&So~-aRs`dZcJSL!&e(UPcGF)d^;?pO-3_x#k z&U92aoJAbJ4vzIcP_j3Es=aY-kL$P40h^Wh2!VU$OZ3`ZRN~o1W#zjmz=tRh9t>Z_ z>u9BOATvK;8Dt3-vw)s60d`MZ^Xu76A?oGdoDeJj*iI_;)*=lf;8d5p7NY@_$GR+x z$|Opy^BHmQR*dw6F$l$ts0_#@IJscGzkIqrLKORm9_ zztJAZQU#|$hDhewd4Vj|Qn?=J)XH1ii4{5CB$7R#tLn#5{1{ehG&Cj1HCN`ZskY)x zNAxN6{RU61$+j$o*QI!^104v>1oNuo95f}yRoB%CJL`l>Du*EE@3urSA0SWp))cQb zpaUV;W3eQ~?9yvu-s+fcEdFg%)=TN;%RJEP(ep7|cpmoHJdaHc^I{X?i@f-=n3a85 zS!ObXcs`xX9B8WWV&(KQ7(1pjyYk-Su|Lz$YLKuK|G|5x&c88ToH?K)p(>b+@1!%j z_FlxhJE|Mg*_P$8cp-C~$PIK&us+@u)9l)7QFbbQk(&@iM-USUU$Y~z z(@$d;<#r>8PM8k)(u@$+wtb8wySYs6ehcd55XeDd&+J^yJpuH=@H`NopNrvic?JTk z%%{4FuQPJ9z9#3<~?2N zQD&F{Spucd2jL%~HxD_DnneVdUZn+?!I(_2(c-5jX-|`-5MaW_ZRw2ES2I@$^hIU} zPt&9!Ab1KbDBGEqlk--=G$*Ga&ncx%5%6+a=zqy-ljZbolU1fROV6|!fjRfvX}^Nu z@L{+EUHnRuon{q;=NsbE3E0_=*pZG{oXU-`)6=llkJ=H?Hh9nx70)E9E!$9Bm&2;z=LrvB2-VO*34&C5jyZdzE$Q1+DZ*F{8q%WHYTlza1|{p z3#rcMNCdzMr;-yb^p<}J(-U(-)Jd1Yw9F}xWm}vDT8_vpcAs>R@>M{-j!{=>V+UNn zVrPL))WiSMudWD6n4hCs-_M-Zv;aWkJ(QwNa!bm0M`k#e6V0&4E`?wy@F}co(!2pRl&bu%6DZ}elcXU z^H%`u2B%du)uRQi#7jV-XHofakfj=lqa){QDx`?zn)$_$8ExuO2sLv8odkKy)2Muc zh61+;3S=u*Te%7gns+tm-Jc~Q+3j&aYeS%6E>OPZcj&znwd;~mrcoSurjb0#beNV# zjS_cf#o5{T>f^1|1v&|G__qN0R%2wubU{nYvS{Y}wjy8!zLO$LOs&_W@#-iBNjdNd z!=R8PgyKx1y^}TJto1#OsgewqES|*FIz2iG@+=uhqYa)GWL@?y6rHA?tyM(5eDZa< z)tY5)%#4e|_vqswBO+2vHHATkZ-{QjI63hTl{9Gc22CCr^HAp>2Q%_uQOvKIr6P=(QnL6x-x1jUm>r*5A3!InnSvDC$&IC3sHSD&_svj zDiL7kND|}`YvA{bXA_n;Fb)03O40qti8uPQ36P`m;e;c-lfM@>4ekNxZ@Ft4h+{1Z zkR-UxNzkkXI1-||IV1Dtyw7lcIL0+t0>iZDoEWVeGm?)y_NF0Ss_+S%aImLwFm`W- zvlo+-HX+xPp1~GY%sTSVjPcA0FY%XasxeJ z+g%C3?6$dG6VY{R+ta|UnEHkH2)ciBY>OL-nU?~%Wok1G@Miq5B zX!tM;xRXV3u)lsIQP7`8D&!!057B-MzI1n5!HHWOZjB(G)=BcT#g0BK)(V%5f$q6; zN?uhU&G{i*9dOdD*b1ju;#cE<$< z0&o(5UJ~32rh|9mS92|??LXI3!>N2-psAr`9xBN>{nJ$BSSisfSc&gAU$gjlCVU?4 z^nb1jOh-WzZ-Drrg|y4*>g$`1PKQRN6PmscV+Qx?c$nXA1}q$ejlP~~!A@NwdCFEn z5>6gaxCa0FZYkUW8h(U=RH{7~iaSfbPo4%KW-;xD&-^tEe4+G#FH1%UIX5sZc_*tR zJtJNK)4}{cdFXbU@6$I~={h)guWdTQzH2Sj!4xH-JVGx{jO73sD=r?%w0Kia`Dd0n zXF6o;xAb9neZy$JztusOZPfZV8PepGabK+9{gy0CdE9B`g}50qGU8c zep{a=tt5F2F&<2wNgmA2%B2ZM5f04GQ<`mdZ5!P=@-pr7?xNC2uNIPV!V&#`cUPJHzcr5%K8(PTA^(8r%Hd@r^OOPu)!m&GEUkz-rMJJ8ESi2>fK*KG6 zRLqJD$JrH+K=37)0&Pd%UrnU|cQL`MrkCJrPI~*&2xKGqMnp8NOUpEOo0#H>mJizu zC-Wz8NKKXJHk%=D4H`|LWyQRRzQSdKMJ3jP{?0TWI67!NK>ll5p7~oAU*RDSG0l*$ z#k7dJ`5x3ea>ukRhY59owpUNZ985VX!Fvln*d zf&lGk3j)CjFdxqWOzD7XnV2`?o$RT!p#7&U3*7h3{Xk31 - - - - - - 阿里低代码引擎 Demo - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - diff --git a/demo/public/mock-pages.json b/demo/public/mock-pages.json deleted file mode 100644 index 8e20f2f..0000000 --- a/demo/public/mock-pages.json +++ /dev/null @@ -1 +0,0 @@ -{"success":true,"content":[{"gmtModified":"2021-03-06 00:40:54","formUuid":"FORM-6X866SC1KM4O4BLF3U7879QB0EMT2Z3TGIWLKW","parentNavUuid":"NAV-SYSTEM-PARENT-UUID","hidden":"n","navUuid":"FORM-6X866SC1KM4O4BLF3U7879QB0EMT2Z3TGIWLKW","navType":"PAGE","isIndex":"n","isNew":"n","gmtCreate":"2021-03-06 00:27:26","title":{"en_US":"页面1","zh_CN":"页面1","type":"i18n"},"relateUuid":"FORM-6X866SC1KM4O4BLF3U7879QB0EMT2Z3TGIWLKW","parentId":0,"listOrder":0,"id":556103}]} \ No newline at end of file diff --git a/demo/public/mock/info.json b/demo/public/mock/info.json deleted file mode 100644 index 006209b..0000000 --- a/demo/public/mock/info.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "info": "Hello AliLowCode!!" -} \ No newline at end of file diff --git a/demo/public/preview.html b/demo/public/preview.html deleted file mode 100644 index 798b156..0000000 --- a/demo/public/preview.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 预览低代码 - - - - -
- - - - - - - - - - diff --git a/demo/public/schema.json b/demo/public/schema.json deleted file mode 100644 index 4877ead..0000000 --- a/demo/public/schema.json +++ /dev/null @@ -1,291 +0,0 @@ -{ - "componentName": "Page", - "id": "node_dockcviv8fo1", - "props": { - "ref": "outerView", - "style": { - "height": "100%" - } - }, - "fileName": "/", - "dataSource": { - "list": [ - { - "type": "fetch", - "isInit": true, - "options": { - "params": {}, - "method": "GET", - "isCors": true, - "timeout": 5000, - "headers": {}, - "uri": "mock/info.json" - }, - "id": "info" - } - ] - }, - "state": { - "text": { - "type": "JSExpression", - "value": "\"outer\"" - }, - "isShowDialog": { - "type": "JSExpression", - "value": "false" - } - }, - "css": "body {\n font-size: 12px;\n}\n\n.button {\n width: 100px;\n color: #ff00ff\n}", - "lifeCycles": { - "componentDidMount": { - "type": "JSFunction", - "value": "function componentDidMount() {\n console.log('did mount');\n}" - }, - "componentWillUnmount": { - "type": "JSFunction", - "value": "function componentWillUnmount() {\n console.log('will unmount');\n}" - } - }, - "methods": { - "testFunc": { - "type": "JSFunction", - "value": "function testFunc() {\n console.log('test func');\n}" - }, - "onClick": { - "type": "JSFunction", - "value": "function onClick() {\n this.setState({\n isShowDialog: true\n });\n}" - }, - "closeDialog": { - "type": "JSFunction", - "value": "function closeDialog() {\n this.setState({\n isShowDialog: false\n });\n}" - } - }, - "originCode": "class LowcodeComponent extends Component {\n state = {\n \"text\": \"outer\",\n \"isShowDialog\": false\n }\n componentDidMount() {\n console.log('did mount');\n }\n componentWillUnmount() {\n console.log('will unmount');\n }\n testFunc() {\n console.log('test func');\n }\n onClick() {\n this.setState({\n isShowDialog: true\n })\n }\n closeDialog() {\n this.setState({\n isShowDialog: false\n })\n }\n}", - "hidden": false, - "title": "", - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextPage", - "id": "node_ockzs2vw431", - "props": { - "headerDivider": true, - "minHeight": "100vh", - "presetNav": true, - "presetAside": true, - "footer": false, - "nav": false, - "aside": false, - "placeholderStyle": { - "gridRowEnd": "span 1", - "gridColumnEnd": "span 12" - }, - "headerProps": { - "background": "surface" - }, - "header": { - "type": "JSSlot", - "value": [ - { - "componentName": "NextPageHeader", - "id": "node_ockzs2vw433", - "props": {}, - "title": "页面头部", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextRowColContainer", - "id": "node_ockzs2vw434", - "props": { - "rowGap": 20, - "colGap": 20 - }, - "title": "行列容器", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextRow", - "id": "node_ockzs2vw435", - "props": {}, - "title": "行", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextCol", - "id": "node_ockzs2vw436", - "props": { - "colSpan": 1 - }, - "title": "列", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextP", - "id": "node_ockzvfoetv17", - "props": { - "wrap": false, - "type": "body2", - "verAlign": "middle", - "textSpacing": true, - "align": "left" - }, - "docId": "dockzvfoetv", - "title": "段落", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextText", - "id": "node_ockzvfoetv18", - "props": { - "type": "h5", - "children": { - "type": "JSExpression", - "value": "this.state.info?.info", - "mock": "标题标题" - }, - "mark": false, - "code": false, - "delete": false, - "underline": false, - "strong": false - }, - "docId": "dockzvfoetv", - "hidden": false, - "title": "", - "isLocked": false, - "condition": true, - "conditionGroup": "" - } - ] - } - ] - } - ] - } - ] - } - ] - } - ], - "title": "header" - }, - "isTab": false, - "contentAlignCenter": false, - "contentProps": { - "style": { - "background": "rgba(255,255,255,0)" - } - } - }, - "title": "页面", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextBlock", - "id": "node_ockzs2vw437", - "props": { - "placeholderStyle": { - "height": "100%" - }, - "noPadding": false, - "noBorder": false, - "title": "区域标题", - "rowGap": 20, - "colGap": 20, - "background": "surface", - "layoutmode": "O", - "strict": true, - "colSpan": 12, - "rowSpan": 1, - "mode": "transparent", - "childTotalColumns": 12 - }, - "title": "区域", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextBlockCell", - "id": "node_ockzs2vw438", - "props": { - "colSpan": 12, - "rowSpan": 1, - "mode": "procard", - "isAutoContainer": true, - "title": "区块标题" - }, - "hidden": false, - "title": "", - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextRowColContainer", - "id": "node_ockzs2vw439", - "props": { - "rowGap": 20, - "colGap": 20 - }, - "title": "行列容器", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextRow", - "id": "node_ockzs2vw43a", - "props": {}, - "title": "行", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextCol", - "id": "node_ockzs2vw43b", - "props": { - "colSpan": 1 - }, - "title": "列", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "" - } - ] - } - ] - } - ] - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/demo/src/index.ts b/demo/src/index.ts deleted file mode 100644 index 4607725..0000000 --- a/demo/src/index.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { init } from '@alilc/lowcode-engine'; -import registerPlugins from './universal/plugin'; -import './universal/global.scss'; - - -const preference = new Map(); -preference.set('DataSourcePane', { - importPlugins: [], - dataSourceTypes: [ - { - type: 'fetch' - }, - { - type: 'jsonp', - } - ] -}); - -(async function main() { - await registerPlugins(); - - init(document.getElementById('lce-container')!, { - // designMode: 'live', - // locale: 'zh-CN', - enableCondition: true, - enableCanvasLock: true, - // 默认绑定变量 - supportVariableGlobally: true, - // simulatorUrl 在当 engine-core.js 同一个路径下时是不需要配置的!!! - // 这里因为用的是 unpkg,在不同 npm 包,engine-core.js 和 react-simulator-renderer.js 是不同路径 - simulatorUrl: [ - 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@beta/dist/css/react-simulator-renderer.css', - 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@beta/dist/js/react-simulator-renderer.js' - ] - }, preference); -})(); diff --git a/demo/src/preview.tsx b/demo/src/preview.tsx deleted file mode 100644 index 27627ff..0000000 --- a/demo/src/preview.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import ReactDOM from 'react-dom'; -import React, { useState } from 'react'; -import { Loading } from '@alifd/next'; -import { buildComponents, assetBundle, AssetLevel, AssetLoader } from '@alilc/lowcode-utils'; -import ReactRenderer from '@alilc/lowcode-react-renderer'; -import { injectComponents } from '@alilc/lowcode-plugin-inject'; - -const SamplePreview = () => { - const [data, setData] = useState({}); - - async function init() { - const packages = JSON.parse(window.localStorage.getItem('packages') || ''); - const projectSchema = JSON.parse(window.localStorage.getItem('projectSchema') || ''); - const { componentsMap: componentsMapArray, componentsTree } = projectSchema; - const componentsMap: any = {}; - componentsMapArray.forEach((component: any) => { - componentsMap[component.componentName] = component; - }); - const schema = componentsTree[0]; - - const libraryMap = {}; - const libraryAsset = []; - packages.forEach(({ package: _package, library, urls, renderUrls }) => { - libraryMap[_package] = library; - if (renderUrls) { - libraryAsset.push(renderUrls); - } else if (urls) { - libraryAsset.push(urls); - } - }); - - const vendors = [assetBundle(libraryAsset, AssetLevel.Library)]; - - // TODO asset may cause pollution - const assetLoader = new AssetLoader(); - await assetLoader.load(libraryAsset); - const components = await injectComponents(buildComponents(libraryMap, componentsMap)); - - setData({ - schema, - components, - }); - } - - const { schema, components } = data; - - if (!schema || !components) { - init(); - return ; - } - - return ( -
- -
- ); -}; - -ReactDOM.render(, document.getElementById('ice-container')); diff --git a/demo/src/sample-plugins/logo/index.scss b/demo/src/sample-plugins/logo/index.scss deleted file mode 100644 index 3140ac3..0000000 --- a/demo/src/sample-plugins/logo/index.scss +++ /dev/null @@ -1,11 +0,0 @@ -.lowcode-plugin-logo { - .logo { - display: block; - width: 139px; - height: 26px; - cursor: pointer; - background-size: contain; - background-position: center; - background-repeat: no-repeat; - } -} diff --git a/demo/src/sample-plugins/logo/index.tsx b/demo/src/sample-plugins/logo/index.tsx deleted file mode 100644 index ff4bbe2..0000000 --- a/demo/src/sample-plugins/logo/index.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import './index.scss'; -import { PluginProps } from '@alilc/lowcode-types'; - -export interface IProps { - logo?: string; - href?: string; -} - -const Logo: React.FC = (props): React.ReactElement => { - return ( -
- -
- ); -}; - -export default Logo; diff --git a/demo/src/setters/behavior-setter.tsx b/demo/src/setters/behavior-setter.tsx deleted file mode 100644 index 1ab0114..0000000 --- a/demo/src/setters/behavior-setter.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import * as React from 'react'; -import BehaviorSetter from '@alilc/lowcode-setter-behavior'; - - -const defaultExtraBehaviorActions: any[] = []; -class LocalBehaviorSetter extends React.Component { - render() { - // ignore url && responseFormatter props, use default ones - const { url: propsUrl, responseFormatter: propsFormatter, extraBehaviorActions: propsExtraBehaviorActions = [], ...otherProps } = this.props; - const url = 'https://hn.algolia.com/api/v1/search?query'; - const responseFormatter = (response) => response.hits.map((item) => ({ - label: item.title, - value: item.author - })); - const extraBehaviorActions = propsExtraBehaviorActions.concat(defaultExtraBehaviorActions); - return ( - - ); - } -} - -export default LocalBehaviorSetter; diff --git a/demo/src/setters/custom-setter.tsx b/demo/src/setters/custom-setter.tsx deleted file mode 100644 index 0383473..0000000 --- a/demo/src/setters/custom-setter.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import React, { Component } from 'react'; // import classNames from 'classnames'; - -class CustomSetter extends Component { - render() { - const { defaultValue, value, onChange } = this.props; - const { editor } = this.props.field; - - return
hello world
; - } -} - -export default CustomSetter; diff --git a/demo/src/universal/global.scss b/demo/src/universal/global.scss deleted file mode 100644 index 02906a3..0000000 --- a/demo/src/universal/global.scss +++ /dev/null @@ -1,55 +0,0 @@ -body { - font-family: PingFangSC-Regular, Roboto, Helvetica Neue, Helvetica, Tahoma, Arial, PingFang SC-Light, Microsoft YaHei; - font-size: 12px; - * { - box-sizing: border-box; - } -} - -body, #lce-container { - position: fixed; - left: 0; - right: 0; - bottom: 0; - top: 0; - box-sizing: border-box; - padding: 0; - margin: 0; - overflow: hidden; - text-rendering: optimizeLegibility; - -webkit-user-select: none; - -webkit-user-drag: none; - -webkit-text-size-adjust: none; - -webkit-touch-callout: none; - -webkit-font-smoothing: antialiased; - #engine { - width: 100%; - height: 100%; - } -} - -html { - min-width: 1024px; -} - -.save-sample { - width: 80px; - height: 30px; - background-color: #5584FF; - border: none; - outline: none; - border-radius: 4px; - color: white; - cursor: pointer; -} - -.load-assets { - width: 100px; - height: 30px; - background-color: #5584FF; - border: none; - outline: none; - border-radius: 4px; - color: white; - cursor: pointer; -} diff --git a/demo/src/universal/plugin.tsx b/demo/src/universal/plugin.tsx deleted file mode 100644 index c79351f..0000000 --- a/demo/src/universal/plugin.tsx +++ /dev/null @@ -1,272 +0,0 @@ -import React from 'react'; -import { - ILowCodePluginContext, - plugins, - skeleton, - project, - setters, -} from '@alilc/lowcode-engine'; -import { Button } from '@alifd/next'; -import UndoRedoPlugin from '@alilc/lowcode-plugin-undo-redo'; -import ComponentsPane from '@alilc/lowcode-plugin-components-pane'; -import ZhEnPlugin from '@alilc/lowcode-plugin-zh-en'; -import CodeGenPlugin from '@alilc/lowcode-plugin-code-generator'; -import DataSourcePanePlugin from '../../../packages/plugin-datasource-pane/src'; -import SchemaPlugin from '@alilc/lowcode-plugin-schema'; -import CodeEditor from "@alilc/lowcode-plugin-code-editor"; -import ManualPlugin from "@alilc/lowcode-plugin-manual"; -import Inject, { injectAssets } from '@alilc/lowcode-plugin-inject'; -import SimulatorResizer from '@alilc/lowcode-plugin-simulator-select'; - -// 注册到引擎 -import TitleSetter from '@alilc/lowcode-setter-title'; -import BehaviorSetter from '../setters/behavior-setter'; -import CustomSetter from '../setters/custom-setter'; -import Logo from '../sample-plugins/logo'; - -import { - loadIncrementalAssets, - getPageSchema, - saveSchema, - resetSchema, - preview, -} from './utils'; -import assets from '../../public/assets.json' - -export default async function registerPlugins() { - await plugins.register(ManualPlugin); - - await plugins.register(Inject); - - // plugin API 见 https://lowcode-engine.cn/docV2/ibh9fh - SchemaPlugin.pluginName = 'SchemaPlugin'; - await plugins.register(SchemaPlugin); - - SimulatorResizer.pluginName = 'SimulatorResizer'; - plugins.register(SimulatorResizer); - - const editorInit = (ctx: ILowCodePluginContext) => { - return { - name: 'editor-init', - async init() { - // 修改面包屑组件的分隔符属性setter - // const assets = await ( - // await fetch( - // `https://alifd.alicdn.com/npm/@alilc/lowcode-materials/build/lowcode/assets-prod.json` - // ) - // ).json(); - // 设置物料描述 - const { material, project } = ctx; - - material.setAssets(await injectAssets(assets)); - - const schema = await getPageSchema(); - - // 加载 schema - project.openDocument(schema); - }, - }; - } - editorInit.pluginName = 'editorInit'; - await plugins.register(editorInit); - - const builtinPluginRegistry = (ctx: ILowCodePluginContext) => { - return { - name: 'builtin-plugin-registry', - async init() { - const { skeleton } = ctx; - // 注册 logo 面板 - skeleton.add({ - area: 'topArea', - type: 'Widget', - name: 'logo', - content: Logo, - contentProps: { - logo: 'https://img.alicdn.com/imgextra/i4/O1CN013w2bmQ25WAIha4Hx9_!!6000000007533-55-tps-137-26.svg', - href: '/', - }, - props: { - align: 'left', - }, - }); - - // 注册组件面板 - const componentsPane = skeleton.add({ - area: 'leftArea', - type: 'PanelDock', - name: 'componentsPane', - content: ComponentsPane, - contentProps: {}, - props: { - align: 'top', - icon: 'zujianku', - description: '组件库', - }, - }); - componentsPane?.disable?.(); - project.onSimulatorRendererReady(() => { - componentsPane?.enable?.(); - }) - }, - }; - } - builtinPluginRegistry.pluginName = 'builtinPluginRegistry'; - await plugins.register(builtinPluginRegistry); - - // 设置内置 setter 和事件绑定、插件绑定面板 - const setterRegistry = (ctx: ILowCodePluginContext) => { - const { setterMap, pluginMap } = window.AliLowCodeEngineExt; - return { - name: 'ext-setters-registry', - async init() { - const { setters, skeleton } = ctx; - // 注册setterMap - setters.registerSetter(setterMap); - // 注册插件 - // 注册事件绑定面板 - skeleton.add({ - area: 'centerArea', - type: 'Widget', - content: pluginMap.EventBindDialog, - name: 'eventBindDialog', - props: {}, - }); - - // 注册变量绑定面板 - skeleton.add({ - area: 'centerArea', - type: 'Widget', - content: pluginMap.VariableBindDialog, - name: 'variableBindDialog', - props: {}, - }); - }, - }; - } - setterRegistry.pluginName = 'setterRegistry'; - await plugins.register(setterRegistry); - - // 注册回退/前进 - await plugins.register(UndoRedoPlugin); - - // 注册中英文切换 - await plugins.register(ZhEnPlugin); - - const loadAssetsSample = (ctx: ILowCodePluginContext) => { - return { - name: 'loadAssetsSample', - async init() { - const { skeleton } = ctx; - - skeleton.add({ - name: 'loadAssetsSample', - area: 'topArea', - type: 'Widget', - props: { - align: 'right', - width: 80, - }, - content: ( - - ), - }); - }, - }; - }; - loadAssetsSample.pluginName = 'loadAssetsSample'; - await plugins.register(loadAssetsSample); - - // 注册保存面板 - const saveSample = (ctx: ILowCodePluginContext) => { - return { - name: 'saveSample', - async init() { - const { skeleton, hotkey } = ctx; - - skeleton.add({ - name: 'saveSample', - area: 'topArea', - type: 'Widget', - props: { - align: 'right', - }, - content: ( - - ), - }); - skeleton.add({ - name: 'resetSchema', - area: 'topArea', - type: 'Widget', - props: { - align: 'right', - }, - content: ( - - ), - }); - hotkey.bind('command+s', (e) => { - e.preventDefault(); - saveSchema(); - }); - }, - }; - } - saveSample.pluginName = 'saveSample'; - await plugins.register(saveSample); - - DataSourcePanePlugin.pluginName = 'DataSourcePane'; - await plugins.register(DataSourcePanePlugin); - - CodeEditor.pluginName = 'CodeEditor'; - await plugins.register(CodeEditor); - - // 注册出码插件 - CodeGenPlugin.pluginName = 'CodeGenPlugin'; - await plugins.register(CodeGenPlugin); - - const previewSample = (ctx: ILowCodePluginContext) => { - return { - name: 'previewSample', - async init() { - const { skeleton } = ctx; - skeleton.add({ - name: 'previewSample', - area: 'topArea', - type: 'Widget', - props: { - align: 'right', - }, - content: ( - - ), - }); - }, - }; - }; - previewSample.pluginName = 'previewSample'; - await plugins.register(previewSample); - - const customSetter = (ctx: ILowCodePluginContext) => { - return { - name: '___registerCustomSetter___', - async init() { - const { setters } = ctx; - - setters.registerSetter('TitleSetter', TitleSetter); - setters.registerSetter('BehaviorSetter', BehaviorSetter); - setters.registerSetter('CustomSetter', CustomSetter); - }, - }; - } - customSetter.pluginName = 'customSetter'; - await plugins.register(customSetter); -}; diff --git a/demo/src/universal/utils.ts b/demo/src/universal/utils.ts deleted file mode 100644 index 9baf0f8..0000000 --- a/demo/src/universal/utils.ts +++ /dev/null @@ -1,298 +0,0 @@ -import { material, project } from '@alilc/lowcode-engine'; -import { filterPackages } from '@alilc/lowcode-plugin-inject' -import { Message, Dialog } from '@alifd/next'; - -export const loadIncrementalAssets = () => { - material?.onChangeAssets(() => { - Message.success('[MCBreadcrumb] 物料加载成功'); - }); - - material.loadIncrementalAssets({ - packages: [ - { - title: 'MCBreadcrumb', - package: 'mc-breadcrumb', - version: '1.0.0', - urls: [ - 'https://unpkg.alibaba-inc.com/mc-breadcrumb@1.0.0/dist/MCBreadcrumb.js', - 'https://unpkg.alibaba-inc.com/mc-breadcrumb@1.0.0/dist/MCBreadcrumb.css', - ], - library: 'MCBreadcrumb', - }, - ], - components: [ - { - componentName: 'MCBreadcrumb', - title: 'MCBreadcrumb', - docUrl: '', - screenshot: '', - npm: { - package: 'mc-breadcrumb', - version: '1.0.0', - exportName: 'MCBreadcrumb', - main: 'lib/index.js', - destructuring: false, - subName: '', - }, - props: [ - { - name: 'prefix', - propType: 'string', - description: '样式类名的品牌前缀', - defaultValue: 'next-', - }, - { - name: 'title', - propType: 'string', - description: '标题', - defaultValue: 'next-', - }, - { - name: 'rtl', - propType: 'bool', - }, - { - name: 'children', - propType: { - type: 'instanceOf', - value: 'node', - }, - description: '面包屑子节点,需传入 Breadcrumb.Item', - }, - { - name: 'maxNode', - propType: { - type: 'oneOfType', - value: [ - 'number', - { - type: 'oneOf', - value: ['auto'], - }, - ], - }, - description: - '面包屑最多显示个数,超出部分会被隐藏, 设置为 auto 会自动根据父元素的宽度适配。', - defaultValue: 100, - }, - { - name: 'separator', - propType: { - type: 'instanceOf', - value: 'node', - }, - description: '分隔符,可以是文本或 Icon', - }, - { - name: 'component', - propType: { - type: 'oneOfType', - value: ['string', 'func'], - }, - description: '设置标签类型', - defaultValue: 'nav', - }, - { - name: 'className', - propType: 'any', - }, - { - name: 'style', - propType: 'object', - }, - ], - configure: { - component: { - isContainer: true, - isModel: true, - rootSelector: 'div.MCBreadcrumb', - }, - }, - }, - ], - - componentList: [ - { - title: '常用', - icon: '', - children: [ - { - componentName: 'MCBreadcrumb', - title: 'MC面包屑', - icon: '', - package: 'mc-breadcrumb', - library: 'MCBreadcrumb', - snippets: [ - { - title: 'MC面包屑', - screenshot: - 'https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_breadcrumb.png', - schema: { - componentName: 'MCBreadcrumb', - props: { - title: '物料中心', - prefix: 'next-', - maxNode: 100, - }, - }, - }, - ], - }, - ], - }, - ], - }); -}; - -export const preview = () => { - saveSchema(); - setTimeout(() => { - window.open(`./preview.html${location.search}`); - }, 500); -}; - -export const saveSchema = async () => { - window.localStorage.setItem( - 'projectSchema', - JSON.stringify(project.exportSchema()) - ); - const packages = await filterPackages(material.getAssets().packages); - window.localStorage.setItem( - 'packages', - JSON.stringify(packages) - ); - Message.success('成功保存到本地'); -}; - -export const resetSchema = async () => { - try { - await new Promise((resolve, reject) => { - Dialog.confirm({ - content: '确定要重置吗?您所有的修改都将消失!', - onOk: () => { - resolve(); - }, - onCancel: () => { - reject() - }, - }) - }) - } catch(err) { - return - } - - let schema - try { - schema = await request('./schema.json') - } catch(err) { - schema = { - componentName: 'Page', - fileName: 'sample', - } - } - - window.localStorage.setItem( - 'projectSchema', - JSON.stringify({ - componentsTree: [schema], - componentsMap: material.componentsMap, - version: '1.0.0', - i18n: {}, - }) - ); - - project.getCurrentDocument()?.importSchema(schema); - project.simulatorHost?.rerender(); - Message.success('成功重置页面'); -} - -export const getPageSchema = async () => { - const schema = JSON.parse( - window.localStorage.getItem('projectSchema') || '{}' - ); - - const pageSchema = schema?.componentsTree?.[0]; - - if (pageSchema) { - return pageSchema; - } - return await request('./schema.json'); -}; - -function request( - dataAPI: string, - method = 'GET', - data?: object | string, - headers?: object, - otherProps?: any, -): Promise { - return new Promise((resolve, reject): void => { - if (otherProps && otherProps.timeout) { - setTimeout((): void => { - reject(new Error('timeout')); - }, otherProps.timeout); - } - fetch(dataAPI, { - method, - credentials: 'include', - headers, - body: data, - ...otherProps, - }) - .then((response: Response): any => { - switch (response.status) { - case 200: - case 201: - case 202: - return response.json(); - case 204: - if (method === 'DELETE') { - return { - success: true, - }; - } else { - return { - __success: false, - code: response.status, - }; - } - case 400: - case 401: - case 403: - case 404: - case 406: - case 410: - case 422: - case 500: - return response - .json() - .then((res: object): any => { - return { - __success: false, - code: response.status, - data: res, - }; - }) - .catch((): object => { - return { - __success: false, - code: response.status, - }; - }); - default: - return null; - } - }) - .then((json: any): void => { - if (json && json.__success !== false) { - resolve(json); - } else { - delete json.__success; - reject(json); - } - }) - .catch((err: Error): void => { - reject(err); - }); - }); -} \ No newline at end of file diff --git a/demo/tsconfig.json b/demo/tsconfig.json deleted file mode 100644 index 23314ab..0000000 --- a/demo/tsconfig.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "compilerOptions": { - "baseUrl": ".", - "declaration": true, - "lib": ["es2015", "dom"], - // Target latest version of ECMAScript. - "target": "esnext", - // Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. - "module": "esnext", - // Search under node_modules for non-relative imports. - "moduleResolution": "node", - // Process & infer types from .js files. - "allowJs": true, - // Report errors in .js files. - "checkJs": false, - // Don't emit; allow Babel to transform files. - // "noEmit": true, - // Enable strictest settings like strictNullChecks & noImplicitAny. - "strict": true, - // Allow default imports from modules with no default export. This does not affect code emit, just typechecking. - "allowSyntheticDefaultImports": true, - // Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. - "esModuleInterop": true, - // Specify JSX code generation: 'preserve', 'react-native', or 'react'. - "jsx": "preserve", - // Import emit helpers (e.g. __extends, __rest, etc..) from tslib - "importHelpers": true, - // Enables experimental support for ES7 decorators. - "experimentalDecorators": true, - // Generates corresponding .map file. - "sourceMap": true, - // Disallow inconsistently-cased references to the same file. - "forceConsistentCasingInFileNames": true, - // Allow json import - "resolveJsonModule": true, - // skip type checking of declaration files - "skipLibCheck": true, - "outDir": "lib" - }, - "include": [ - "./src/" - ], - "exclude": ["**/test", "**/lib", "**/es", "node_modules"] -} From 9bdc7fd1033169314d0b8cfefdd6c9c0f41a82e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LeoYuan=20=E8=A2=81=E5=8A=9B=E7=9A=93?= Date: Wed, 16 Nov 2022 14:29:30 +0800 Subject: [PATCH 054/166] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BB=8E=20sc?= =?UTF-8?q?hema2code=20=E6=97=B6,=20state=20=E6=81=A2=E5=A4=8D=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 14 ++++++-- packages/plugin-code-editor/.editorconfig | 13 ++++++++ packages/plugin-code-editor/.eslintignore | 7 ++++ packages/plugin-code-editor/.eslintrc.js | 11 +++++++ packages/plugin-code-editor/CHANGELOG.md | 4 +++ packages/plugin-code-editor/package.json | 2 +- .../src/config/default-code.ts | 2 +- packages/plugin-code-editor/src/index.tsx | 6 ++-- .../plugin-code-editor/src/types/methods.ts | 11 ++++--- .../plugin-code-editor/src/types/state.ts | 6 ++-- .../src/{typeings.d.ts => typings.d.ts} | 0 .../plugin-code-editor/src/utils/evaluate.ts | 32 +++++++++++++++++++ .../src/utils/get-methods.ts | 3 +- .../src/utils/schema-to-code.ts | 31 +++++++++--------- .../src/utils/state-parser.ts | 3 +- .../plugin-code-editor/src/utils/transform.ts | 1 - 16 files changed, 111 insertions(+), 35 deletions(-) create mode 100644 packages/plugin-code-editor/.editorconfig create mode 100644 packages/plugin-code-editor/.eslintignore create mode 100644 packages/plugin-code-editor/.eslintrc.js rename packages/plugin-code-editor/src/{typeings.d.ts => typings.d.ts} (100%) create mode 100644 packages/plugin-code-editor/src/utils/evaluate.ts diff --git a/.eslintrc.js b/.eslintrc.js index f1b6c7b..b22d43b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -31,6 +31,16 @@ module.exports = { '@typescript-eslint/indent': 0, 'import/no-cycle': 0, '@typescript-eslint/no-shadow': 0, - 'max-len': ["error", {"code": 180}] - } + 'max-len': ['error', { code: 180 }], + 'comma-dangle': [ + 'warn', + { + objects: 'always', + arrays: 'always', + imports: 'never', + functions: 'never', + }, + ], + semi: ['error', 'always'], + }, }; diff --git a/packages/plugin-code-editor/.editorconfig b/packages/plugin-code-editor/.editorconfig new file mode 100644 index 0000000..3192996 --- /dev/null +++ b/packages/plugin-code-editor/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +quote_type = single + +[*.md] +trim_trailing_whitespace = false diff --git a/packages/plugin-code-editor/.eslintignore b/packages/plugin-code-editor/.eslintignore new file mode 100644 index 0000000..36c1703 --- /dev/null +++ b/packages/plugin-code-editor/.eslintignore @@ -0,0 +1,7 @@ +node_modules/ +build/ +dist/ +**/*.min.js +**/*-min.js +**/*.bundle.js +*.js diff --git a/packages/plugin-code-editor/.eslintrc.js b/packages/plugin-code-editor/.eslintrc.js new file mode 100644 index 0000000..0245b1d --- /dev/null +++ b/packages/plugin-code-editor/.eslintrc.js @@ -0,0 +1,11 @@ +module.exports = { + extends: [ + 'eslint-config-ali/typescript/react', + 'prettier', + 'prettier/@typescript-eslint', + 'prettier/react', + ], + rules: { + 'no-param-reassign': 0, + }, +}; diff --git a/packages/plugin-code-editor/CHANGELOG.md b/packages/plugin-code-editor/CHANGELOG.md index ce9b400..110aac0 100644 --- a/packages/plugin-code-editor/CHANGELOG.md +++ b/packages/plugin-code-editor/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.4 / 2022-11-18 + +- 修复从 schema2code 时, state 恢复错误的问题 + ## 1.0.3 / 2022-07-11 - Fix 源码面板高度塌陷的 [bug](https://github.com/alibaba/lowcode-engine/issues/803) diff --git a/packages/plugin-code-editor/package.json b/packages/plugin-code-editor/package.json index d16a232..e507c0d 100644 --- a/packages/plugin-code-editor/package.json +++ b/packages/plugin-code-editor/package.json @@ -1,7 +1,7 @@ { "name": "@alilc/lowcode-plugin-code-editor", "author": "59174526@qq.com & humphry.huang9@gmail.com", - "version": "1.0.3", + "version": "1.0.4", "description": "CodeEditor", "files": [ "es", diff --git a/packages/plugin-code-editor/src/config/default-code.ts b/packages/plugin-code-editor/src/config/default-code.ts index 3765874..bf7ea44 100644 --- a/packages/plugin-code-editor/src/config/default-code.ts +++ b/packages/plugin-code-editor/src/config/default-code.ts @@ -1,5 +1,5 @@ export const defaultCode = ` - export default class LowcodeComponent extends Component { + export default class Page extends Component { // 可以在 state 中定义搭建所需要的 State state = { test: 1, diff --git a/packages/plugin-code-editor/src/index.tsx b/packages/plugin-code-editor/src/index.tsx index 766a74c..d7caf4c 100644 --- a/packages/plugin-code-editor/src/index.tsx +++ b/packages/plugin-code-editor/src/index.tsx @@ -14,7 +14,7 @@ const plugin = (ctx: ILowCodePluginContext) => { }, // 插件的初始化函数,在引擎初始化之后会立刻调用 init() { - const schemaDock = ctx.skeleton.add({ + const codeEditorDock = ctx.skeleton.add({ area: 'leftArea', name: 'codeEditor', type: 'PanelDock', @@ -35,9 +35,9 @@ const plugin = (ctx: ILowCodePluginContext) => { ), }); - schemaDock && schemaDock.disable(); + codeEditorDock && codeEditorDock.disable(); project.onSimulatorRendererReady(() => { - schemaDock.enable(); + codeEditorDock.enable(); }); }, }; diff --git a/packages/plugin-code-editor/src/types/methods.ts b/packages/plugin-code-editor/src/types/methods.ts index 2e62f08..093941f 100644 --- a/packages/plugin-code-editor/src/types/methods.ts +++ b/packages/plugin-code-editor/src/types/methods.ts @@ -1,7 +1,8 @@ +import { JSFunction, JSExpression } from '@alilc/lowcode-types'; +export type Method = JSExpression | JSFunction & { + source: string; +} + export interface Methods { - [key: string]: { - type: 'JSFunction'; - value: string; - originalCode: string; - }; + [key: string]: Method; } diff --git a/packages/plugin-code-editor/src/types/state.ts b/packages/plugin-code-editor/src/types/state.ts index d994852..ff85180 100644 --- a/packages/plugin-code-editor/src/types/state.ts +++ b/packages/plugin-code-editor/src/types/state.ts @@ -1,6 +1,6 @@ import { JSExpression } from '@alilc/lowcode-types'; -export interface IState extends JSExpression{ - // 原始代码 - originCode: string; +export interface IState extends JSExpression { + // 原始代码 + source: string; } \ No newline at end of file diff --git a/packages/plugin-code-editor/src/typeings.d.ts b/packages/plugin-code-editor/src/typings.d.ts similarity index 100% rename from packages/plugin-code-editor/src/typeings.d.ts rename to packages/plugin-code-editor/src/typings.d.ts diff --git a/packages/plugin-code-editor/src/utils/evaluate.ts b/packages/plugin-code-editor/src/utils/evaluate.ts new file mode 100644 index 0000000..d4b7db7 --- /dev/null +++ b/packages/plugin-code-editor/src/utils/evaluate.ts @@ -0,0 +1,32 @@ +interface Expr { + type: string; + value: string | number; + extType?: string; +} + +type ExprType = Expr | string; + +function getExprStr(expr: ExprType) { + if (typeof expr === 'string') { + return expr; + } + return expr && (expr as Expr).value; +} + +function getEvalExpressionStr(expr: ExprType): string | undefined { + const exprStr = getExprStr(expr); + if (exprStr == undefined) { + return exprStr; + } else if (exprStr === '') { + return undefined; + } + return `(function(){return (${exprStr})}).call($scope)`; +} + +export function evaluate(expr: ExprType) { + const evalExprStr = getEvalExpressionStr(expr); + const code = `with($scope || {}) { return ${evalExprStr} }`; + const fn = new Function('$scope', code); + // 暂时不传递 $scope + return fn(); +} diff --git a/packages/plugin-code-editor/src/utils/get-methods.ts b/packages/plugin-code-editor/src/utils/get-methods.ts index 72579f7..cd890b2 100644 --- a/packages/plugin-code-editor/src/utils/get-methods.ts +++ b/packages/plugin-code-editor/src/utils/get-methods.ts @@ -54,8 +54,7 @@ export const getMethods = (ast: Node) => { methods[name] = { type: 'JSFunction', value: compiledCode, - // 这里的 originalCode 直接放在全局,不挂在局部 - // originalCode: codeStr, + source: codeStr, }; }, }); diff --git a/packages/plugin-code-editor/src/utils/schema-to-code.ts b/packages/plugin-code-editor/src/utils/schema-to-code.ts index 166ae6b..75bddbb 100644 --- a/packages/plugin-code-editor/src/utils/schema-to-code.ts +++ b/packages/plugin-code-editor/src/utils/schema-to-code.ts @@ -1,14 +1,14 @@ - import { js_beautify, css_beautify } from 'js-beautify'; -import { isJSExpression, ProjectSchema, RootSchema, JSFunction, JSExpression } from '@alilc/lowcode-types'; +import { isJSExpression, ProjectSchema, RootSchema } from '@alilc/lowcode-types'; import { Dialog } from '@alifd/next'; import { IState } from '../types'; -import { defaultStateCode, WORDS } from '../config'; +import { WORDS } from '../config'; +import type { Method } from '../types/methods'; const js_beautify_config = { indent_size: 2, indent_empty_lines: true, e4x: true }; const initCode = (componentSchema: RootSchema | undefined) => { - const code = `class LowcodeComponent extends Component { + const code = `class Page extends Component { ${initStateCode(componentSchema)} ${initLifeCycleCode(componentSchema)} ${initMethodsCode(componentSchema)} @@ -30,23 +30,24 @@ export const schema2CssCode = (schema: ProjectSchema) => { }; export const beautifyCSS = (input?: string): string => { - return input ? css_beautify(input, { indent_size: 2 }) : '' + return input ? css_beautify(input, { indent_size: 2 }) : ''; } function initStateCode(componentSchema: RootSchema | undefined) { if (componentSchema?.state) { - let states: Record = {}; + let statesStr = 'state = {\n'; let needNotice = false; - Object.keys(componentSchema.state).forEach((item) => { - const state = componentSchema.state?.[item]; + Object.keys(componentSchema.state).forEach((key) => { + const state = componentSchema.state?.[key]; if (typeof state === 'object' && isJSExpression(state)) { - states[item] = (state as IState).originCode || state.value; // 兼容历史数据 - if (!(state as IState).originCode) { + if (!(state as IState).source) { needNotice = true; } + statesStr += `"${key}": ${(state as IState).source || state.value},\n`; } else { - states[item] = state; // 兼容历史数据 + statesStr += `"${key}": ${typeof state === 'string' ? '"' + state + '"' : state},,\n`; } + }); if (needNotice) { Dialog.alert({ @@ -54,10 +55,10 @@ function initStateCode(componentSchema: RootSchema | undefined) { content: WORDS.irreparableState, }); } - return `state = ${JSON.stringify(states)}`; + statesStr += '}'; + return statesStr; } - return defaultStateCode; } function initLifeCycleCode(componentSchema: RootSchema | undefined) { @@ -100,10 +101,10 @@ function initMethodsCode(componentSchema: RootSchema | undefined) { } } -function createFunctionCode(functionName: string, functionNode: JSFunction | JSExpression) { +function createFunctionCode(functionName: string, functionNode: Method) { if (functionNode?.type === 'JSExpression' || functionNode?.type === 'JSFunction') { // 读取原始代码 - let functionCode = functionNode.originalCode; + let functionCode = functionNode.source; if (functionCode) { functionCode = functionCode.replace(/function/, ''); } else { diff --git a/packages/plugin-code-editor/src/utils/state-parser.ts b/packages/plugin-code-editor/src/utils/state-parser.ts index 439e964..872eb2b 100644 --- a/packages/plugin-code-editor/src/utils/state-parser.ts +++ b/packages/plugin-code-editor/src/utils/state-parser.ts @@ -18,7 +18,6 @@ export const stateParser = (ast: Node) => { // get state identifier or literal if (path.isIdentifier({ name: 'state' }) || path.isLiteral({ value: 'state' })) { const properties = path.container?.value?.properties; - // console.log('properties', properties); if (properties) { properties.forEach((property) => { // creat empty AST @@ -26,7 +25,7 @@ export const stateParser = (ast: Node) => { code.program.body.push(t.variableDeclaration('var', [ t.variableDeclarator(t.identifier('name'), property.value), ])); - + const codeStr = babelTransformFromAst(code).code; const compiledCode = transformJS(codeStr, defaultBabelConfig).code; if (compiledCode) { diff --git a/packages/plugin-code-editor/src/utils/transform.ts b/packages/plugin-code-editor/src/utils/transform.ts index 7f18e94..faed277 100644 --- a/packages/plugin-code-editor/src/utils/transform.ts +++ b/packages/plugin-code-editor/src/utils/transform.ts @@ -1,4 +1,3 @@ - import { transform } from './babel'; import { TransformResult } from '../types'; From 982f9b55d951893078156bb7cb063731a2284d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LeoYuan=20=E8=A2=81=E5=8A=9B=E7=9A=93?= Date: Fri, 18 Nov 2022 11:06:07 +0800 Subject: [PATCH 055/166] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=20skipDemo=20?= =?UTF-8?q?=E7=9A=84=E5=91=BD=E4=BB=A4=E8=A1=8C=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/plugin-code-editor/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-code-editor/package.json b/packages/plugin-code-editor/package.json index e507c0d..3afea15 100644 --- a/packages/plugin-code-editor/package.json +++ b/packages/plugin-code-editor/package.json @@ -14,7 +14,7 @@ "scripts": { "start": "build-scripts start --config build.js", "prepublishOnly": "npm run build", - "build": "build-scripts build --skip-demo --config build.js" + "build": "build-scripts build --config build.js" }, "publishConfig": { "access": "public" From dfa5bf15b45517b1425947b83484f778c6b44631 Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Fri, 18 Nov 2022 11:05:09 +0800 Subject: [PATCH 056/166] docs: update CHANGELOG.md --- packages/plugin-code-editor/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/plugin-code-editor/CHANGELOG.md b/packages/plugin-code-editor/CHANGELOG.md index 110aac0..4fc51e2 100644 --- a/packages/plugin-code-editor/CHANGELOG.md +++ b/packages/plugin-code-editor/CHANGELOG.md @@ -1,6 +1,7 @@ ## 1.0.4 / 2022-11-18 -- 修复从 schema2code 时, state 恢复错误的问题 +- Fix 修正输入 / 粘贴时光标位置错误的 bug +- Fix 修复当上下文没有 originCode 时,通过 schema 中的局部 source 字段无法恢复 state 的问题 ## 1.0.3 / 2022-07-11 From b39f4a48596d060ffa1ef3ba21250ecc29474dc6 Mon Sep 17 00:00:00 2001 From: JackLian Date: Fri, 25 Nov 2022 11:06:11 +0800 Subject: [PATCH 057/166] feat(plugin-schema): add isProjectSchema option --- packages/plugin-schema/README.md | 23 +++++++++++++----- packages/plugin-schema/build.json | 3 ++- packages/plugin-schema/package.json | 2 +- packages/plugin-schema/src/editor.tsx | 35 ++++++++++++++++----------- packages/plugin-schema/src/index.tsx | 26 ++++++++++++++------ 5 files changed, 60 insertions(+), 29 deletions(-) diff --git a/packages/plugin-schema/README.md b/packages/plugin-schema/README.md index 555ba4c..93af452 100644 --- a/packages/plugin-schema/README.md +++ b/packages/plugin-schema/README.md @@ -1,12 +1,14 @@ # lowcode-plugin-@alilc/lowcode-plugin-schema [![][npm-image]][npm-url] -show lowcode schema diff +show lowcode schema +查看低代码引擎 schema --- ## 使用 ### 注册插件 +#### 展示页面级 schema ```jsx import { plugins } from '@alilc/lowcode-engine'; import LowcodePluginAliLowcodePluginSchema from '@alilc/lowcode-plugin-schema'; @@ -14,12 +16,21 @@ import LowcodePluginAliLowcodePluginSchema from '@alilc/lowcode-plugin-schema'; // 注册到引擎 plugins.register(LowcodePluginAliLowcodePluginSchema); ``` +#### 展示项目级 schema +```jsx +import { plugins } from '@alilc/lowcode-engine'; +import LowcodePluginAliLowcodePluginSchema from '@alilc/lowcode-plugin-schema'; + +// 注册到引擎 +plugins.register(LowcodePluginAliLowcodePluginSchema, { isProjectSchema: true }); +``` ### 插件属性 & 方法 -无对外暴露的属性和方法 -### 依赖插件 -该插件依赖以下插件: +#### isProjectSchema +- description: '是否是项目级 schema' +- type: 'boolean' +- default: false -| 插件名 | 包名 | -| --- | --- | +### 依赖插件 +暂无 diff --git a/packages/plugin-schema/build.json b/packages/plugin-schema/build.json index 6a51f0c..05778dd 100644 --- a/packages/plugin-schema/build.json +++ b/packages/plugin-schema/build.json @@ -3,7 +3,8 @@ [ "@alilc/build-plugin-alt", { - "type": "plugin" + "type": "plugin", + "inject": true } ], [ diff --git a/packages/plugin-schema/package.json b/packages/plugin-schema/package.json index 80c15ed..93aa42a 100644 --- a/packages/plugin-schema/package.json +++ b/packages/plugin-schema/package.json @@ -1,7 +1,7 @@ { "name": "@alilc/lowcode-plugin-schema", "author": "alvarto", - "version": "1.0.1", + "version": "1.0.2", "description": "Show schema in lowcode editor", "files": [ "es", diff --git a/packages/plugin-schema/src/editor.tsx b/packages/plugin-schema/src/editor.tsx index e66dedf..2bf382d 100644 --- a/packages/plugin-schema/src/editor.tsx +++ b/packages/plugin-schema/src/editor.tsx @@ -12,13 +12,16 @@ interface PluginCodeDiffProps { project: Project; skeleton: Skeleton; event: Event; + // 是否显示项目级 schema + showProjectSchema: boolean; } -export default function PluginSchema({ project, skeleton, event }: PluginCodeDiffProps) { +export default function PluginSchema({ project, skeleton, event, showProjectSchema = false }: PluginCodeDiffProps) { const [editorSize, setEditorSize] = useState({ width: 0, height: 0 }); const [schemaValue, setSchemaValue] = useState(() => { - const schema = project.exportSchema(common.designerCabin.TransformStage.Save) - return schema?.componentsTree?.[0] ? JSON.stringify(schema.componentsTree[0], null, 2) : '' + const schema = project.exportSchema(common.designerCabin.TransformStage.Save); + const schemaToShow = showProjectSchema? schema : schema?.componentsTree?.[0]; + return schemaToShow? JSON.stringify(schemaToShow, null, 2) : ''; }); const monacoEditorRef = useRef(); @@ -44,7 +47,7 @@ export default function PluginSchema({ project, skeleton, event }: PluginCodeDif window.addEventListener('resize', resize); return () => { window.removeEventListener('resize', resize); - } + }; }, [resize]); const onSave = () => { @@ -52,20 +55,24 @@ export default function PluginSchema({ project, skeleton, event }: PluginCodeDif content: 'Are you 100% sure? Lowcode editor may crash.', footerActions: ['cancel', 'ok'], onOk: () => { - let json + let json; try { - json = JSON.parse(monacoEditorRef.current?.getValue() ?? schemaValue) + json = JSON.parse(monacoEditorRef.current?.getValue() ?? schemaValue); } catch (err) { - Message.error('Cannot save schema. Schema Parse Error.' + err.message) + Message.error('Cannot save schema. Schema Parse Error.' + err.message); return; } - - project.importSchema({ - ...project.exportSchema(common.designerCabin.TransformStage.Save), - componentsTree: [json], - }); + if (showProjectSchema) { + // 当前操作项目级 schema + project.importSchema(json); + } else { + // 当前操作页面级 schema + project.importSchema({ + ...project.exportSchema(common.designerCabin.TransformStage.Save), + componentsTree: [json], + }); + } Message.success('Schema Saved!'); - skeleton.hidePanel('LowcodePluginAliLowcodePluginSchema'); } }); @@ -96,7 +103,7 @@ export default function PluginSchema({ project, skeleton, event }: PluginCodeDif contextMenuGroupId: 'navigation', contextMenuOrder: 1.5, run: onSave, - }); + }); }} /> diff --git a/packages/plugin-schema/src/index.tsx b/packages/plugin-schema/src/index.tsx index ae7bcef..e52acbd 100644 --- a/packages/plugin-schema/src/index.tsx +++ b/packages/plugin-schema/src/index.tsx @@ -2,14 +2,12 @@ import * as React from 'react'; import { ILowCodePluginContext } from '@alilc/lowcode-engine'; import PluginSchema from './editor'; -const plugin = (ctx: ILowCodePluginContext) => { +const plugin = (ctx: ILowCodePluginContext, options: any) => { return { - // 插件名,注册环境下唯一 - name: 'LowcodePluginAliLowcodePluginSchema', - // 依赖的插件(插件名数组) - dep: [], // 插件的初始化函数,在引擎初始化之后会立刻调用 init() { + const isProjectSchema = (options && options['isProjectSchema']) === true; + // 往引擎增加面板 ctx.skeleton.add({ area: 'leftArea', @@ -28,6 +26,7 @@ const plugin = (ctx: ILowCodePluginContext) => { project={ctx.project} skeleton={ctx.skeleton} event={ctx.event} + showProjectSchema={isProjectSchema} /> ), }) @@ -35,6 +34,19 @@ const plugin = (ctx: ILowCodePluginContext) => { }; }; -plugin.pluginName = 'LowcodePluginAliLowcodePluginSchema' +plugin.pluginName = 'LowcodePluginAliLowcodePluginSchema'; +plugin.meta = { + preferenceDeclaration: { + title: 'schema 面板配置', + properties: [ + { + key: 'isProjectSchema', + type: 'boolean', + description: '是否是项目级 schema', + default: false, + }, + ], + }, +}; -export default plugin +export default plugin; From 4a807e6e97bc5f8f72c448ce8c7e07f5ea176d23 Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Mon, 28 Nov 2022 16:53:10 +0800 Subject: [PATCH 058/166] fix: uipass compatibility --- packages/plugin-code-editor/CHANGELOG.md | 4 ++++ .../plugin-code-editor/src/utils/schema-to-code.ts | 11 ----------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/packages/plugin-code-editor/CHANGELOG.md b/packages/plugin-code-editor/CHANGELOG.md index 4fc51e2..a8f5cba 100644 --- a/packages/plugin-code-editor/CHANGELOG.md +++ b/packages/plugin-code-editor/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.5 / 2022-11-28 + +- Fix 修正 UIPaaS 中针对 source 的异常提示问题 + ## 1.0.4 / 2022-11-18 - Fix 修正输入 / 粘贴时光标位置错误的 bug diff --git a/packages/plugin-code-editor/src/utils/schema-to-code.ts b/packages/plugin-code-editor/src/utils/schema-to-code.ts index 75bddbb..986ed9a 100644 --- a/packages/plugin-code-editor/src/utils/schema-to-code.ts +++ b/packages/plugin-code-editor/src/utils/schema-to-code.ts @@ -36,25 +36,14 @@ export const beautifyCSS = (input?: string): string => { function initStateCode(componentSchema: RootSchema | undefined) { if (componentSchema?.state) { let statesStr = 'state = {\n'; - let needNotice = false; Object.keys(componentSchema.state).forEach((key) => { const state = componentSchema.state?.[key]; if (typeof state === 'object' && isJSExpression(state)) { - if (!(state as IState).source) { - needNotice = true; - } statesStr += `"${key}": ${(state as IState).source || state.value},\n`; } else { statesStr += `"${key}": ${typeof state === 'string' ? '"' + state + '"' : state},,\n`; } - }); - if (needNotice) { - Dialog.alert({ - title: WORDS.title, - content: WORDS.irreparableState, - }); - } statesStr += '}'; return statesStr; } From 6e098619bb312d8917f6a3262cb195424850972d Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Mon, 28 Nov 2022 16:54:09 +0800 Subject: [PATCH 059/166] chore: bump into next version --- packages/plugin-code-editor/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-code-editor/package.json b/packages/plugin-code-editor/package.json index 3afea15..1233684 100644 --- a/packages/plugin-code-editor/package.json +++ b/packages/plugin-code-editor/package.json @@ -1,7 +1,7 @@ { "name": "@alilc/lowcode-plugin-code-editor", "author": "59174526@qq.com & humphry.huang9@gmail.com", - "version": "1.0.4", + "version": "1.0.5", "description": "CodeEditor", "files": [ "es", From 6782bfb654d0e2229b1b02749514a96fd2e3fc5e Mon Sep 17 00:00:00 2001 From: JackLian Date: Fri, 2 Dec 2022 19:58:27 +0800 Subject: [PATCH 060/166] feat(manual): adjust manual, use manual on lowcode-engine.cn --- packages/plugin-manual/build.json | 3 +- packages/plugin-manual/package.json | 2 +- packages/plugin-manual/src/index.tsx | 24 +--- packages/plugin-manual/src/popup.tsx | 158 --------------------------- 4 files changed, 4 insertions(+), 183 deletions(-) delete mode 100644 packages/plugin-manual/src/popup.tsx diff --git a/packages/plugin-manual/build.json b/packages/plugin-manual/build.json index 1edfc2f..1767fef 100644 --- a/packages/plugin-manual/build.json +++ b/packages/plugin-manual/build.json @@ -3,7 +3,8 @@ [ "@alilc/build-plugin-alt", { - "type": "plugin" + "type": "plugin", + "inject": true } ], [ diff --git a/packages/plugin-manual/package.json b/packages/plugin-manual/package.json index 84a6bfd..522ea29 100644 --- a/packages/plugin-manual/package.json +++ b/packages/plugin-manual/package.json @@ -1,7 +1,7 @@ { "name": "@alilc/lowcode-plugin-manual", "author": "humphry.huang9@gmail.com", - "version": "1.0.3", + "version": "1.0.4", "description": "低代码产品使用手册", "main": "lib/index.js", "module": "es/index.js", diff --git a/packages/plugin-manual/src/index.tsx b/packages/plugin-manual/src/index.tsx index 2c90773..bb57695 100644 --- a/packages/plugin-manual/src/index.tsx +++ b/packages/plugin-manual/src/index.tsx @@ -1,20 +1,8 @@ -import * as React from 'react'; import { ILowCodePluginContext } from '@alilc/lowcode-engine'; import { IconQuestion } from './icon'; -import { Dialog } from '@alifd/next'; -import { Documents } from './popup'; const PluginManual = (ctx: ILowCodePluginContext) => { return { - // 插件名,注册环境下唯一 - name: 'PluginManual', - // 依赖的插件(插件名数组) - dep: [], - // 插件对外暴露的数据和方法 - exports() { - return {}; - }, - // 插件的初始化函数,在引擎初始化之后会立刻调用 init() { // 往引擎增加面板 ctx.skeleton.add({ @@ -26,17 +14,7 @@ const PluginManual = (ctx: ILowCodePluginContext) => { icon: IconQuestion, description: '如何使用', onClick() { - Dialog.show({ - title: '低代码产品使用文档', - content: ( - - ), - height: window.innerHeight - 100 + 'px', - style: { - width: window.innerWidth - 300, - }, - footer: false, - }); + window.open('https://lowcode-engine.cn/site/docs/demoUsage/intro', '_blank').focus(); }, }, }); diff --git a/packages/plugin-manual/src/popup.tsx b/packages/plugin-manual/src/popup.tsx deleted file mode 100644 index 3710ddc..0000000 --- a/packages/plugin-manual/src/popup.tsx +++ /dev/null @@ -1,158 +0,0 @@ -import * as React from 'react'; -import { useEffect, useState } from 'react'; -import { material } from '@alilc/lowcode-engine'; -import { Tree, Tag, Loading } from '@alifd/next'; - -import { IconBug, IconLink } from './icon'; - -export function Documents() { - const [menu, setMenu] = useState([] as Array<{ title: string, url: string }>) - const [loading, setLoading] = useState(false) - const [selection, setSelection] = useState([] as string[]) - - useEffect(() => { - setLoading(true) - fetch('https://lowcode-engine.cn/api/get_usage') - .then((res) => res.json()) - .then((val) => { - const menu = val.data.filter((a: any) => !isNaN(parseInt(a.title))) - menu.sort((a: any, b: any) => parseInt(a.title) > parseInt(b.title) ? 1 : -1) - setMenu(menu) - setSelection(menu.length ? ['0'] : []) - }) - .catch(err => console.error(err)) - .finally(() => { - setLoading(false) - }) - }, []) - - return ( - -
-
- {!loading && ( - { - if (Array.isArray(newSelection) && newSelection.length > 0) { - setSelection(newSelection) - } - }} - isNodeBlock={{ - defaultPadingLeft: 1, - indent: 1, - }} - style={{ lineHeight: '26px' }} - > - {menu.map((item, index) => ( - - ))} - - - {IconLink} - 低代码引擎技术文档 - - )} - onClick={() => { - window.open('https://lowcode-engine.cn/doc') - }} - /> - - {IconLink} - engine - - {getVerionOf('ali-lowcode/ali-lowcode-engine') ?? (window as any).AliLowCodeEngine.version ?? '-'} - - - )} - onClick={() => { - window.open('https://lowcode-engine.cn/doc?url=engine-changelog') - }} - /> - - {IconLink} - ext - - {getVerionOf('ali-lowcode/lowcode-engine-ext') ?? (window as any).AliLowCodeEngineExt.version ?? '-'} - - - )} - onClick={() => { - window.open('https://lowcode-engine.cn/doc?url=engine-ext-changelog') - }} - /> - - {IconBug} - 提交 bug - - )} - onClick={() => { - const assets = material.getAssets() - const message = `## 复现截图 - -## 复现流程与链接 - -## 期望结果 - -## 环境信息 - -- 引擎版本 ${getVerionOf('ali-lowcode/ali-lowcode-engine') ?? (window as any).AliLowCodeEngine.version ?? '-'} -- ext 版本 ${getVerionOf('ali-lowcode/lowcode-engine-ext') ?? (window as any).AliLowCodeEngineExt.version ?? '-'} -- 物料 -${assets.packages - .filter((item: any) => !!item.package) - .map((item: any) => (` - ${item.package}${item.version ? '@' + item.version : ''}`.replace(/@/g, '﹫'))) - .join('\n') -}` - window.open(`https://github.com/alibaba/lowcode-engine/issues/new?body=${ - encodeURIComponent(message) - }`) - }} - /> - - - )} -
- {menu[+selection[0]]?.url && ( -