From 882682fa811d45cacc29d97507f8fbcb11fd72f2 Mon Sep 17 00:00:00 2001 From: qkiroc Date: Wed, 8 Feb 2023 20:44:17 +0800 Subject: [PATCH 1/6] =?UTF-8?q?amis-saas-9428=20=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E7=8A=B6=E6=80=81=E7=BB=A7=E6=89=BF=E5=B8=B8?= =?UTF-8?q?=E8=A7=84=E6=80=81=EF=BC=88=E9=BB=98=E8=AE=A4=E9=99=A4=E9=A2=9C?= =?UTF-8?q?=E8=89=B2=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ifeb310cd92769a11015b56879a3986e7aa481788 --- packages/amis-editor-core/src/util.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/amis-editor-core/src/util.ts b/packages/amis-editor-core/src/util.ts index f66ec4bfe..d5f528c18 100644 --- a/packages/amis-editor-core/src/util.ts +++ b/packages/amis-editor-core/src/util.ts @@ -695,12 +695,13 @@ export function filterSchemaForEditor(schema: any): any { mapped[key] = filtered; // 组件切换状态修改classname - if (/[C|c]lassName/.test(key) && schema.editorState) { - mapped[key] = mapped[key] - ? mapped[key] + ' ' + schema.editorState - : schema.editorState; - modified = true; - } + // TODO:切换状态暂时先不改变组件的样式 + // if (/[C|c]lassName/.test(key) && schema.editorState) { + // mapped[key] = mapped[key] + // ? mapped[key] + ' ' + schema.editorState + // : schema.editorState; + // modified = true; + // } if (filtered !== value) { modified = true; From 1f6722ccff915b30f864f616f7cac82ab5276543 Mon Sep 17 00:00:00 2001 From: qkiroc Date: Fri, 10 Feb 2023 14:17:34 +0800 Subject: [PATCH 2/6] =?UTF-8?q?amis-saas-9428=20=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E7=8A=B6=E6=80=81=E7=BB=A7=E6=89=BF=E5=B8=B8?= =?UTF-8?q?=E8=A7=84=E6=80=81=EF=BC=88=E9=BB=98=E8=AE=A4=E9=99=A4=E9=A2=9C?= =?UTF-8?q?=E8=89=B2=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I251eca020b051f9fe42cf516c02baef7c9433360 --- packages/amis-editor-core/src/store/editor.ts | 6 ++++-- packages/amis-editor-core/src/util.ts | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/amis-editor-core/src/store/editor.ts b/packages/amis-editor-core/src/store/editor.ts index 2287a6444..da1e46f7e 100644 --- a/packages/amis-editor-core/src/store/editor.ts +++ b/packages/amis-editor-core/src/store/editor.ts @@ -12,7 +12,8 @@ import { needDefaultWidth, guid, reGenerateID, - addStyleClassName + addStyleClassName, + setThemeDefaultData } from '../../src/util'; import { InsertEventContext, @@ -504,7 +505,8 @@ export const MainStore = types getValueOf(id: string) { const schema = JSONGetById(self.schema, id); - const res = JSONPipeOut(schema, false); + const data = JSONPipeOut(schema, false); + const res = setThemeDefaultData(data); return res; }, diff --git a/packages/amis-editor-core/src/util.ts b/packages/amis-editor-core/src/util.ts index d5f528c18..96e6105b1 100644 --- a/packages/amis-editor-core/src/util.ts +++ b/packages/amis-editor-core/src/util.ts @@ -9,6 +9,7 @@ import isPlainObject from 'lodash/isPlainObject'; import isNumber from 'lodash/isNumber'; import type {Schema} from 'amis'; import {SchemaObject} from 'amis/lib/Schema'; +import {cloneDeep} from 'lodash'; const { guid, @@ -39,6 +40,8 @@ export { createObject }; +export let themeConfig: any = {}; + export function __uri(id: string) { return id; } @@ -1030,3 +1033,15 @@ export function needDefaultWidth(elemType: string) { } return false; } + +// 设置主题数据 +export function setThemeConfig(config: any) { + themeConfig = config; +} + +// 将主题数据传入组件的schema +export function setThemeDefaultData(data: any) { + const schemaData = cloneDeep(data); + schemaData.themeConfig = themeConfig; + return schemaData; +} From f48053c30209623b46905425e171b035988c5b18 Mon Sep 17 00:00:00 2001 From: hongyang03 Date: Thu, 23 Feb 2023 11:16:30 +0800 Subject: [PATCH 3/6] =?UTF-8?q?amis-saas-9429=20=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E5=A4=96=E8=A7=82=E7=BB=A7=E6=89=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ief1c25788164b1c24855bfee6863df6740696f2f --- packages/amis-editor-core/package.json | 3 ++- packages/amis-editor-core/src/util.ts | 10 ++++++++-- packages/amis-editor-core/tsconfig.json | 6 +++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/amis-editor-core/package.json b/packages/amis-editor-core/package.json index 2616ebeac..02fcf4f2a 100644 --- a/packages/amis-editor-core/package.json +++ b/packages/amis-editor-core/package.json @@ -93,8 +93,9 @@ "amis-core": "*", "amis-formula": "*", "amis-ui": "*", + "amis-theme-editor-helper": "*", "i18n-runtime": "*", "react": ">=16.8.6", "react-dom": ">=16.8.6" } -} \ No newline at end of file +} diff --git a/packages/amis-editor-core/src/util.ts b/packages/amis-editor-core/src/util.ts index 96e6105b1..6a4734dce 100644 --- a/packages/amis-editor-core/src/util.ts +++ b/packages/amis-editor-core/src/util.ts @@ -9,7 +9,8 @@ import isPlainObject from 'lodash/isPlainObject'; import isNumber from 'lodash/isNumber'; import type {Schema} from 'amis'; import {SchemaObject} from 'amis/lib/Schema'; -import {cloneDeep} from 'lodash'; +import {assign, cloneDeep} from 'lodash'; +import {getGlobalData} from 'amis-theme-editor-helper'; const { guid, @@ -710,7 +711,11 @@ export function filterSchemaForEditor(schema: any): any { modified = true; } }); - return modified ? mapped : schema; + const finalSchema = modified ? mapped : schema; + if (finalSchema?.type) { + return setThemeDefaultData(finalSchema); + } + return finalSchema; } return schema; @@ -1043,5 +1048,6 @@ export function setThemeConfig(config: any) { export function setThemeDefaultData(data: any) { const schemaData = cloneDeep(data); schemaData.themeConfig = themeConfig; + assign(schemaData, getGlobalData(themeConfig)); return schemaData; } diff --git a/packages/amis-editor-core/tsconfig.json b/packages/amis-editor-core/tsconfig.json index 276f20046..cd7e8ad74 100644 --- a/packages/amis-editor-core/tsconfig.json +++ b/packages/amis-editor-core/tsconfig.json @@ -10,5 +10,9 @@ ] }, "include": ["src/**/*"], - "references": [] + "references": [ + { + "path": "../amis-theme-editor-helper" + } + ] } From 4f863775784736bc1f3250156d08d483d6d566d1 Mon Sep 17 00:00:00 2001 From: qkiroc Date: Wed, 8 Mar 2023 15:07:35 +0800 Subject: [PATCH 4/6] =?UTF-8?q?amis-saas-9428=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=A4=96=E8=A7=82=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie9ce769332d4ca27127e9cd791d3d086727edabf --- packages/amis-editor-core/scss/editor.scss | 2 +- .../{_theme_classname.scss => _theme-css-code.scss} | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) rename packages/amis-editor-core/scss/style-control/{_theme_classname.scss => _theme-css-code.scss} (88%) diff --git a/packages/amis-editor-core/scss/editor.scss b/packages/amis-editor-core/scss/editor.scss index 584571831..54928693b 100644 --- a/packages/amis-editor-core/scss/editor.scss +++ b/packages/amis-editor-core/scss/editor.scss @@ -44,7 +44,7 @@ @import './style-control/background'; @import './style-control/size'; @import './style-control/style-common'; -@import './style-control/theme_classname'; +@import './style-control/theme-css-code'; @keyframes growing { 0% { diff --git a/packages/amis-editor-core/scss/style-control/_theme_classname.scss b/packages/amis-editor-core/scss/style-control/_theme-css-code.scss similarity index 88% rename from packages/amis-editor-core/scss/style-control/_theme_classname.scss rename to packages/amis-editor-core/scss/style-control/_theme-css-code.scss index e77ee9762..12631e5f2 100644 --- a/packages/amis-editor-core/scss/style-control/_theme_classname.scss +++ b/packages/amis-editor-core/scss/style-control/_theme-css-code.scss @@ -1,14 +1,13 @@ -.ThemeClassName { +.ThemeCssCode { position: relative; &-button { - position: absolute; - left: px2rem(-38px); + width: 100%; } .is-group { overflow: auto; } } -.ThemeClassName-editor { +.ThemeCssCode-editor { height: auto; width: px2rem(400px); padding: px2rem(16px); From 44262f8544c9afc4acfee44c0fb6eb439a639256 Mon Sep 17 00:00:00 2001 From: qkiroc Date: Thu, 9 Mar 2023 12:36:12 +0800 Subject: [PATCH 5/6] =?UTF-8?q?amis-saas-9428=20=E5=A4=96=E8=A7=82?= =?UTF-8?q?=E6=BA=90=E7=A0=81=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6913a1a93bd8e3f22aa360929bb288a676f53e67 --- .../scss/style-control/_theme-css-code.scss | 3 +++ packages/amis-editor-core/src/store/editor.ts | 3 ++- packages/amis-editor-core/src/util.ts | 9 +++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/amis-editor-core/scss/style-control/_theme-css-code.scss b/packages/amis-editor-core/scss/style-control/_theme-css-code.scss index 12631e5f2..aa1d2ea2d 100644 --- a/packages/amis-editor-core/scss/style-control/_theme-css-code.scss +++ b/packages/amis-editor-core/scss/style-control/_theme-css-code.scss @@ -7,6 +7,9 @@ overflow: auto; } } +.icon-theme-css { + margin-right: 10px; +} .ThemeCssCode-editor { height: auto; width: px2rem(400px); diff --git a/packages/amis-editor-core/src/store/editor.ts b/packages/amis-editor-core/src/store/editor.ts index da1e46f7e..4a152c1b2 100644 --- a/packages/amis-editor-core/src/store/editor.ts +++ b/packages/amis-editor-core/src/store/editor.ts @@ -524,7 +524,8 @@ export const MainStore = types key !== '$$commonSchema') || typeof props === 'function' || // pipeIn 和 pipeOut key.substring(0, 2) === '__' || - key === 'css' || + // key === 'themeCss' || + key === 'editorPath' || key === 'editorState') // 样式不需要出现做json中, ); }, diff --git a/packages/amis-editor-core/src/util.ts b/packages/amis-editor-core/src/util.ts index 6a4734dce..6b5343668 100644 --- a/packages/amis-editor-core/src/util.ts +++ b/packages/amis-editor-core/src/util.ts @@ -202,15 +202,16 @@ export function JSONPipeOut( } /** - * 如果存在css属性,则给对应的className加上name + * 如果存在themeCss属性,则给对应的className加上name */ export function addStyleClassName(obj: Schema) { - const css = obj.css; - if (!obj.css) { + const themeCss = obj.themeCss || obj.css; + // page暂时不做处理 + if (!themeCss || obj.type === 'page') { return obj; } let toUpdate: any = {}; - Object.keys(css).forEach(key => { + Object.keys(themeCss).forEach(key => { if (key !== '$$id') { let classname = `${key}-${obj.id.replace('u:', '')}`; if (!obj[key]) { From 9d70ab1c56672b766f83dfdcd263d3293afdf81f Mon Sep 17 00:00:00 2001 From: qkiroc Date: Thu, 16 Mar 2023 19:37:48 +0800 Subject: [PATCH 6/6] =?UTF-8?q?amis-saas-10220=20=E5=A4=96=E8=A7=82?= =?UTF-8?q?=E6=BA=90=E7=A0=81=E7=BC=96=E8=BE=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I36dcfaa22c811dda6d970f0c508abdb792daf1fa --- .../scss/style-control/_theme-css-code.scss | 37 ++++++++++++++++++- packages/amis-editor-core/src/store/editor.ts | 2 +- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/packages/amis-editor-core/scss/style-control/_theme-css-code.scss b/packages/amis-editor-core/scss/style-control/_theme-css-code.scss index aa1d2ea2d..7f7b43a1c 100644 --- a/packages/amis-editor-core/scss/style-control/_theme-css-code.scss +++ b/packages/amis-editor-core/scss/style-control/_theme-css-code.scss @@ -12,7 +12,7 @@ } .ThemeCssCode-editor { height: auto; - width: px2rem(400px); + width: px2rem(460px); padding: px2rem(16px); position: relative; &-title { @@ -32,6 +32,41 @@ &-content { height: px2rem(500px); width: 100%; + &-header { + display: flex; + margin-bottom: px2rem(10px); + border-bottom: 1px solid #e8e9eb; + + &-title { + margin-right: px2rem(30px); + cursor: pointer; + padding-bottom: px2rem(10px); + } + &-title--active { + color: #2468f2; + border-bottom: 2px solid #2468f2; + } + } + &-main { + overflow: auto; + height: px2rem(460px); + } + &-body--hidden { + display: none; + } + &-body { + margin-bottom: px2rem(10px); + &-title { + margin-bottom: px2rem(10px); + margin-left: px2rem(16px); + font-size: 12px; + } + &-editor { + height: 200px; + margin-bottom: px2rem(10px); + border-bottom: 1px solid #e8e9eb; + } + } } } .editorPanel-inner { diff --git a/packages/amis-editor-core/src/store/editor.ts b/packages/amis-editor-core/src/store/editor.ts index 4a152c1b2..1ee87cb1f 100644 --- a/packages/amis-editor-core/src/store/editor.ts +++ b/packages/amis-editor-core/src/store/editor.ts @@ -524,7 +524,7 @@ export const MainStore = types key !== '$$commonSchema') || typeof props === 'function' || // pipeIn 和 pipeOut key.substring(0, 2) === '__' || - // key === 'themeCss' || + key === 'themeCss' || key === 'editorPath' || key === 'editorState') // 样式不需要出现做json中, );