From 010d72a4360363eae2c85dcc87451f616c958bab Mon Sep 17 00:00:00 2001 From: Jimmy Liu Date: Sat, 29 Feb 2020 13:37:51 +0800 Subject: [PATCH 01/25] remove ionic --- .../lib/components/code-diff-editor/test/basic/index.html | 5 ----- .../src/lib/components/code-editor/test/basic/index.html | 5 ----- .../components/code-editor/test/cdn-from-config/index.html | 4 ---- .../src/lib/components/code-editor/test/cdn/index.html | 4 ---- .../lib/components/code-editor/test/json-value/index.html | 5 ----- .../src/lib/components/elements-editor/test/basic/index.html | 5 ----- .../lib/components/elements-editor/test/preview/index.html | 5 ----- .../src/lib/components/elements-form/test/basic/index.html | 5 ----- .../lib/components/elements-preview/test/basic/index.html | 5 ----- .../src/lib/components/elements-view/test/basic/index.html | 5 ----- .../lib/components/elements-view/test/code-editor/index.html | 5 ----- libs/elements/src/lib/components/img/test/basic/index.html | 5 ----- .../src/lib/components/text-editor/test/basic/index.html | 5 ----- libs/elements/src/lib/components/text-editor/text-editor.tsx | 2 +- .../src/lib/components/tree-node/test/basic/index.html | 5 ----- libs/elements/src/lib/components/tree/test/basic/index.html | 5 ----- libs/elements/src/lib/interfaces/input.interface.ts | 3 +++ libs/elements/stencil.dev.config.ts | 4 ---- 18 files changed, 4 insertions(+), 78 deletions(-) create mode 100644 libs/elements/src/lib/interfaces/input.interface.ts diff --git a/libs/elements/src/lib/components/code-diff-editor/test/basic/index.html b/libs/elements/src/lib/components/code-diff-editor/test/basic/index.html index c5098d251..ab07b6b96 100644 --- a/libs/elements/src/lib/components/code-diff-editor/test/basic/index.html +++ b/libs/elements/src/lib/components/code-diff-editor/test/basic/index.html @@ -5,11 +5,6 @@ Stencil Component Starter - - - - - diff --git a/libs/elements/src/lib/components/code-editor/test/basic/index.html b/libs/elements/src/lib/components/code-editor/test/basic/index.html index fc9c21cc0..0952af85f 100644 --- a/libs/elements/src/lib/components/code-editor/test/basic/index.html +++ b/libs/elements/src/lib/components/code-editor/test/basic/index.html @@ -5,11 +5,6 @@ Stencil Component Starter - - - - - diff --git a/libs/elements/src/lib/components/code-editor/test/cdn-from-config/index.html b/libs/elements/src/lib/components/code-editor/test/cdn-from-config/index.html index d8dd23b72..fe82cf25d 100644 --- a/libs/elements/src/lib/components/code-editor/test/cdn-from-config/index.html +++ b/libs/elements/src/lib/components/code-editor/test/cdn-from-config/index.html @@ -4,10 +4,6 @@ Stencil Component Starter - - - - diff --git a/libs/elements/src/lib/components/code-editor/test/cdn/index.html b/libs/elements/src/lib/components/code-editor/test/cdn/index.html index a6c824ed0..4eac7a045 100644 --- a/libs/elements/src/lib/components/code-editor/test/cdn/index.html +++ b/libs/elements/src/lib/components/code-editor/test/cdn/index.html @@ -4,10 +4,6 @@ Stencil Component Starter - - - - diff --git a/libs/elements/src/lib/components/code-editor/test/json-value/index.html b/libs/elements/src/lib/components/code-editor/test/json-value/index.html index c1527a505..599bea990 100644 --- a/libs/elements/src/lib/components/code-editor/test/json-value/index.html +++ b/libs/elements/src/lib/components/code-editor/test/json-value/index.html @@ -5,11 +5,6 @@ Stencil Component Starter - - - - - diff --git a/libs/elements/src/lib/components/elements-editor/test/basic/index.html b/libs/elements/src/lib/components/elements-editor/test/basic/index.html index bd54a0dd0..dd2371d47 100644 --- a/libs/elements/src/lib/components/elements-editor/test/basic/index.html +++ b/libs/elements/src/lib/components/elements-editor/test/basic/index.html @@ -5,11 +5,6 @@ Stencil Component Starter - - - - - diff --git a/libs/elements/src/lib/components/elements-editor/test/preview/index.html b/libs/elements/src/lib/components/elements-editor/test/preview/index.html index 0337b3203..ed6916006 100644 --- a/libs/elements/src/lib/components/elements-editor/test/preview/index.html +++ b/libs/elements/src/lib/components/elements-editor/test/preview/index.html @@ -5,11 +5,6 @@ Stencil Component Starter - - - - - diff --git a/libs/elements/src/lib/components/elements-form/test/basic/index.html b/libs/elements/src/lib/components/elements-form/test/basic/index.html index 6bc389e32..f0b86c218 100644 --- a/libs/elements/src/lib/components/elements-form/test/basic/index.html +++ b/libs/elements/src/lib/components/elements-form/test/basic/index.html @@ -5,11 +5,6 @@ Stencil Component Starter - - - - - diff --git a/libs/elements/src/lib/components/elements-preview/test/basic/index.html b/libs/elements/src/lib/components/elements-preview/test/basic/index.html index 33f758af4..676781d1e 100644 --- a/libs/elements/src/lib/components/elements-preview/test/basic/index.html +++ b/libs/elements/src/lib/components/elements-preview/test/basic/index.html @@ -5,11 +5,6 @@ Stencil Component Starter - - - - - diff --git a/libs/elements/src/lib/components/elements-view/test/basic/index.html b/libs/elements/src/lib/components/elements-view/test/basic/index.html index 637d1f9ff..c3321fa63 100644 --- a/libs/elements/src/lib/components/elements-view/test/basic/index.html +++ b/libs/elements/src/lib/components/elements-view/test/basic/index.html @@ -5,11 +5,6 @@ Stencil Component Starter - - - - - diff --git a/libs/elements/src/lib/components/elements-view/test/code-editor/index.html b/libs/elements/src/lib/components/elements-view/test/code-editor/index.html index 40ee7f4fd..4346d89e6 100644 --- a/libs/elements/src/lib/components/elements-view/test/code-editor/index.html +++ b/libs/elements/src/lib/components/elements-view/test/code-editor/index.html @@ -5,11 +5,6 @@ Stencil Component Starter - - - - - diff --git a/libs/elements/src/lib/components/img/test/basic/index.html b/libs/elements/src/lib/components/img/test/basic/index.html index c73f171dd..87b4aff92 100644 --- a/libs/elements/src/lib/components/img/test/basic/index.html +++ b/libs/elements/src/lib/components/img/test/basic/index.html @@ -5,11 +5,6 @@ Stencil Component Starter - - - - - diff --git a/libs/elements/src/lib/components/text-editor/test/basic/index.html b/libs/elements/src/lib/components/text-editor/test/basic/index.html index d5a9572da..181e883ff 100644 --- a/libs/elements/src/lib/components/text-editor/test/basic/index.html +++ b/libs/elements/src/lib/components/text-editor/test/basic/index.html @@ -5,11 +5,6 @@ Stencil Component Starter - - - - - diff --git a/libs/elements/src/lib/components/text-editor/text-editor.tsx b/libs/elements/src/lib/components/text-editor/text-editor.tsx index cfdc70ab7..e38ede3e5 100644 --- a/libs/elements/src/lib/components/text-editor/text-editor.tsx +++ b/libs/elements/src/lib/components/text-editor/text-editor.tsx @@ -1,11 +1,11 @@ import toNumber from 'lodash/toNumber'; import { renderHiddenInput } from '@aiao/elements-cdk'; -import { InputChangeEventDetail } from '@ionic/core'; import { Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core'; import { config } from '../../global/config'; import { getSelectionElements, restoreRange, saveRange } from '../../utils/selection'; +import { InputChangeEventDetail } from '../../interfaces/input.interface'; // https://developer.mozilla.org/zh-CN/docs/Web/API/Document/execCommand diff --git a/libs/elements/src/lib/components/tree-node/test/basic/index.html b/libs/elements/src/lib/components/tree-node/test/basic/index.html index e76af16b4..d2175f6e6 100644 --- a/libs/elements/src/lib/components/tree-node/test/basic/index.html +++ b/libs/elements/src/lib/components/tree-node/test/basic/index.html @@ -5,11 +5,6 @@ Stencil Component Starter - - - - - diff --git a/libs/elements/src/lib/components/tree/test/basic/index.html b/libs/elements/src/lib/components/tree/test/basic/index.html index 9aaacdfbe..bd1d80bfb 100644 --- a/libs/elements/src/lib/components/tree/test/basic/index.html +++ b/libs/elements/src/lib/components/tree/test/basic/index.html @@ -5,11 +5,6 @@ Stencil Component Starter - - - - - diff --git a/libs/elements/src/lib/interfaces/input.interface.ts b/libs/elements/src/lib/interfaces/input.interface.ts new file mode 100644 index 000000000..426bb10d8 --- /dev/null +++ b/libs/elements/src/lib/interfaces/input.interface.ts @@ -0,0 +1,3 @@ +export interface InputChangeEventDetail { + value: string | undefined | null; +} diff --git a/libs/elements/stencil.dev.config.ts b/libs/elements/stencil.dev.config.ts index 0f5ad5b5c..7af34c7d2 100644 --- a/libs/elements/stencil.dev.config.ts +++ b/libs/elements/stencil.dev.config.ts @@ -16,10 +16,6 @@ export const config: Config = { } ], copy: [ - { - src: resolve(__dirname, '../../', 'node_modules/@ionic/core'), - dest: resolve(__dirname, 'vendors/ionic') - }, { src: resolve(__dirname, '../../', 'dist/libs/image-storage'), dest: resolve(__dirname, 'vendors/image-storage') From 01caf82a6ca5dd7b6cb9c9178dd11fbf4ade7f09 Mon Sep 17 00:00:00 2001 From: Jimmy Liu Date: Sat, 29 Feb 2020 15:38:47 +0800 Subject: [PATCH 02/25] update --- .../code-diff-editor/test/basic/index.html | 7 ++++ .../code-editor/test/basic/index.html | 14 +++++-- .../test/cdn-from-config/index.html | 7 ++++ .../code-editor/test/cdn/index.html | 7 ++++ .../code-editor/test/json-value/index.html | 7 ++++ .../elements-editor/test/basic/index.html | 10 +++-- .../elements-editor/test/preview/index.html | 23 ++++------- .../elements-view/elements-view.tsx | 30 ++++++++++++-- .../elements-view/test/basic/index.html | 8 +++- .../elements-view/test/code-editor/index.html | 41 ++++--------------- 10 files changed, 93 insertions(+), 61 deletions(-) diff --git a/libs/elements/src/lib/components/code-diff-editor/test/basic/index.html b/libs/elements/src/lib/components/code-diff-editor/test/basic/index.html index ab07b6b96..f1110cc8f 100644 --- a/libs/elements/src/lib/components/code-diff-editor/test/basic/index.html +++ b/libs/elements/src/lib/components/code-diff-editor/test/basic/index.html @@ -16,6 +16,13 @@ + diff --git a/libs/elements/src/lib/components/code-editor/test/basic/index.html b/libs/elements/src/lib/components/code-editor/test/basic/index.html index 0952af85f..9e02115e8 100644 --- a/libs/elements/src/lib/components/code-editor/test/basic/index.html +++ b/libs/elements/src/lib/components/code-editor/test/basic/index.html @@ -18,11 +18,17 @@ - css - typescript - format - + + + + + diff --git a/libs/elements/src/lib/components/code-editor/test/cdn/index.html b/libs/elements/src/lib/components/code-editor/test/cdn/index.html index 4eac7a045..132771be6 100644 --- a/libs/elements/src/lib/components/code-editor/test/cdn/index.html +++ b/libs/elements/src/lib/components/code-editor/test/cdn/index.html @@ -15,6 +15,13 @@ + diff --git a/libs/elements/src/lib/components/code-editor/test/json-value/index.html b/libs/elements/src/lib/components/code-editor/test/json-value/index.html index 599bea990..7345b110f 100644 --- a/libs/elements/src/lib/components/code-editor/test/json-value/index.html +++ b/libs/elements/src/lib/components/code-editor/test/json-value/index.html @@ -16,6 +16,13 @@ + diff --git a/libs/elements/src/lib/components/elements-editor/test/basic/index.html b/libs/elements/src/lib/components/elements-editor/test/basic/index.html index dd2371d47..34a822cd8 100644 --- a/libs/elements/src/lib/components/elements-editor/test/basic/index.html +++ b/libs/elements/src/lib/components/elements-editor/test/basic/index.html @@ -16,6 +16,11 @@ + @@ -37,14 +42,11 @@ editor.view = view; editor.value = [ { - tag: 'ion-button', + tag: 'button', innerText: 'button', class: { a: true }, - attributes: { - mode: 'ios' - }, style: { minWidth: '200px' } diff --git a/libs/elements/src/lib/components/elements-editor/test/preview/index.html b/libs/elements/src/lib/components/elements-editor/test/preview/index.html index ed6916006..c31db1a00 100644 --- a/libs/elements/src/lib/components/elements-editor/test/preview/index.html +++ b/libs/elements/src/lib/components/elements-editor/test/preview/index.html @@ -16,6 +16,11 @@ + @@ -34,30 +39,16 @@ ]; editor.value = [ { - tag: 'ion-button', + tag: 'button', innerText: 'button', class: { a: true }, - attributes: { - mode: 'ios' - }, style: { minWidth: '200px' } }, - { - tag: 'h1' - }, - { - tag: 'div', - children: [ - { - tag: 'h1', - innerText: 'true' - } - ] - }, + { tag: 'h1' }, { tag: 'aiao-img', attributes: { diff --git a/libs/elements/src/lib/components/elements-view/elements-view.tsx b/libs/elements/src/lib/components/elements-view/elements-view.tsx index b4f1e3529..afc04b2b1 100644 --- a/libs/elements/src/lib/components/elements-view/elements-view.tsx +++ b/libs/elements/src/lib/components/elements-view/elements-view.tsx @@ -1,18 +1,40 @@ import { Component, ComponentInterface, Element, h, Host, Prop } from '@stencil/core'; +import { config } from '../../global/config'; +import { IDomSanitizer } from '../../interfaces/context.interface'; @Component({ tag: 'aiao-elements-view', styleUrl: './elements-view.scss', - shadow: false, - scoped: true + shadow: true }) export class ElementsView implements ComponentInterface { @Element() el!: HTMLAiaoElementsViewElement; + domSanitizer: IDomSanitizer = config.get('domSanitizer'); + @Prop() html: string; + @Prop() css: string; + @Prop() js: string; render() { - this.el.innerHTML = this.html || ''; - return ; + let { html, css, js } = this; + if (this.domSanitizer) { + if (html) { + html = this.domSanitizer.bypassSecurityTrustHtml(html); + } + if (css) { + css = this.domSanitizer.bypassSecurityTrustStyle(css); + } + if (js) { + js = this.domSanitizer.bypassSecurityTrustScript(js); + } + } + return ( + + {css && } + {js && } +
+
+ ); } } diff --git a/libs/elements/src/lib/components/elements-view/test/basic/index.html b/libs/elements/src/lib/components/elements-view/test/basic/index.html index c3321fa63..a4537c11f 100644 --- a/libs/elements/src/lib/components/elements-view/test/basic/index.html +++ b/libs/elements/src/lib/components/elements-view/test/basic/index.html @@ -18,6 +18,12 @@ - + + diff --git a/libs/elements/src/lib/components/elements-view/test/code-editor/index.html b/libs/elements/src/lib/components/elements-view/test/code-editor/index.html index 4346d89e6..fd3454eb6 100644 --- a/libs/elements/src/lib/components/elements-view/test/code-editor/index.html +++ b/libs/elements/src/lib/components/elements-view/test/code-editor/index.html @@ -17,6 +17,11 @@