kempo 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Icon.js +1 -1
- package/dist/components/Table.js +1 -0
- package/dist/index.js +1 -1
- package/dist/kempo-styles.css +1 -1
- package/dist/kempo-vars.css +1 -1
- package/dist/utils/string.js +1 -1
- package/docs/components/_template.html +46 -0
- package/docs/components/component.html +1 -1
- package/docs/components/table.html +153 -0
- package/docs/icons/edit.svg +1 -0
- package/docs/index.html +3 -0
- package/docs/kempo/components/Icon.js +1 -1
- package/docs/kempo/components/Table.js +1 -0
- package/docs/kempo/index.js +1 -1
- package/docs/kempo/kempo-styles.css +1 -1
- package/docs/kempo/kempo-vars.css +1 -1
- package/docs/kempo/utils/string.js +1 -1
- package/docs/nav-1.inc.html +1 -0
- package/docs/nav.inc.html +1 -0
- package/docs/search.json +11 -0
- package/docs/styles/displays-layouts.html +2 -0
- package/docs/styles/embed-1.html +1 -0
- package/icons/edit.svg +1 -0
- package/package.json +1 -1
- package/scripts/build.js +1 -4
- package/src/components/Icon.js +37 -5
- package/src/components/Table.js +71 -0
- package/src/kempo-styles.css +8 -3
- package/src/kempo-vars.css +2 -0
- package/src/utils/string.js +1 -0
- package/dist/components/CodeEditor.js +0 -1
- package/dist/components/WebSnippetEditor.js +0 -1
- package/dist/kempo.css +0 -1
- package/dist/kempo.js +0 -1
- package/docs/kempo/components/CodeEditor.js +0 -1
- package/docs/kempo/components/WebSnippetEditor.js +0 -1
- package/docs/kempo/kempo.css +0 -1
- package/docs/kempo/kempo.js +0 -1
- package/src/components/CodeEditor.js +0 -144
- package/src/components/WebSnippetEditor.js +0 -159
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import Component from './Component.js';
|
|
2
|
-
import {
|
|
3
|
-
escapeHTML,
|
|
4
|
-
unescapeHTML
|
|
5
|
-
} from '../utils/string.js';
|
|
6
|
-
import './Split.js';
|
|
7
|
-
import './Tabs.js';
|
|
8
|
-
import './CodeEditor.js';
|
|
9
|
-
|
|
10
|
-
const changeHandler = Symbol();
|
|
11
|
-
export default class WebSnippetEditor extends Component {
|
|
12
|
-
constructor(){
|
|
13
|
-
super();
|
|
14
|
-
|
|
15
|
-
this[changeHandler] = () => {
|
|
16
|
-
this.renderResults();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
this.registerAttributes({
|
|
20
|
-
useKempo: false,
|
|
21
|
-
showHtml: true,
|
|
22
|
-
showCss: true,
|
|
23
|
-
showJs: true,
|
|
24
|
-
scripts: ''
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async render(){
|
|
29
|
-
await super.render();
|
|
30
|
-
|
|
31
|
-
const $htmlCode = this.querySelector('pre[for="html"]');
|
|
32
|
-
const $htmlEditor = this.shadowRoot.getElementById('html');
|
|
33
|
-
$htmlEditor.addEventListener('change', this[changeHandler]);
|
|
34
|
-
if($htmlCode){
|
|
35
|
-
$htmlEditor.value = escapeHTML($htmlCode.textContent);
|
|
36
|
-
} else {
|
|
37
|
-
$htmlEditor.value = escapeHTML(`<div>\n \n</div>`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const $cssCode = this.querySelector('pre[for="css"]');
|
|
41
|
-
const $cssEditor = this.shadowRoot.getElementById('css');
|
|
42
|
-
$cssEditor.addEventListener('change', this[changeHandler]);
|
|
43
|
-
if($cssCode){
|
|
44
|
-
$cssEditor.value = $cssCode.textContent;
|
|
45
|
-
} else {
|
|
46
|
-
$cssEditor.value = `div {\n \n}`;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const $jsCode = this.querySelector('pre[for="js"]');
|
|
50
|
-
const $jsEditor = this.shadowRoot.getElementById('js');
|
|
51
|
-
$jsEditor.addEventListener('change', this[changeHandler]);
|
|
52
|
-
if($jsCode){
|
|
53
|
-
$jsEditor.value = $jsCode.textContent;
|
|
54
|
-
} else {
|
|
55
|
-
$jsEditor.value = '';
|
|
56
|
-
}
|
|
57
|
-
this.renderResults();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
renderResults(){
|
|
61
|
-
const html = this.shadowRoot.getElementById('html').value;
|
|
62
|
-
const css = this.shadowRoot.getElementById('css').value;
|
|
63
|
-
const js = this.shadowRoot.getElementById('js').value;
|
|
64
|
-
|
|
65
|
-
const $results = this.shadowRoot.getElementById('results');
|
|
66
|
-
$results.innerHTML = '';
|
|
67
|
-
const $iframe = document.createElement('iframe');
|
|
68
|
-
$iframe.frameBorder = "0";
|
|
69
|
-
$results.appendChild($iframe);
|
|
70
|
-
const iframeDoc = $iframe.contentDocument || $iframe.contentWindow.document;
|
|
71
|
-
iframeDoc.body.innerHTML = `
|
|
72
|
-
${this.useKempo?`<link rel="stylesheet" href="../kempo/kempo-vars.css" /><link rel="stylesheet" href="../kempo/kempo-styles.css" />`:''}
|
|
73
|
-
<style>
|
|
74
|
-
body, html {
|
|
75
|
-
background-color: transparent;
|
|
76
|
-
}
|
|
77
|
-
body {
|
|
78
|
-
overflow-y: auto;
|
|
79
|
-
padding: var(--spacer_q, 4px);
|
|
80
|
-
}
|
|
81
|
-
${css}
|
|
82
|
-
</style>
|
|
83
|
-
${html}
|
|
84
|
-
`;
|
|
85
|
-
if(this.useKempo && this.scripts){
|
|
86
|
-
this.scripts.split(',').forEach( script => {
|
|
87
|
-
const $script = document.createElement('script');
|
|
88
|
-
$script.type = 'module';
|
|
89
|
-
$script.src = script;
|
|
90
|
-
iframeDoc.head.appendChild($script);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
const $script = document.createElement('script');
|
|
94
|
-
$script.textContent = js;
|
|
95
|
-
iframeDoc.head.appendChild($script);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
get shadowTemplate(){
|
|
99
|
-
return /*html*/`
|
|
100
|
-
<k-split id="split">
|
|
101
|
-
<k-tabs class="ml">
|
|
102
|
-
${this.showHtml?`<k-tab for="html">HTML</k-tab>`:''}
|
|
103
|
-
${this.showCss?`<k-tab for="css">CSS</k-tab>`:''}
|
|
104
|
-
${this.showJs?`<k-tab for="js">JS</k-tab>`:''}
|
|
105
|
-
<k-tab-content name="html">
|
|
106
|
-
<k-code-editor
|
|
107
|
-
id="html"
|
|
108
|
-
language="xml"
|
|
109
|
-
class="my"
|
|
110
|
-
></k-code-editor>
|
|
111
|
-
</k-tab-content>
|
|
112
|
-
<k-tab-content name="css">
|
|
113
|
-
<k-code-editor
|
|
114
|
-
id="css"
|
|
115
|
-
language="css"
|
|
116
|
-
class="my"
|
|
117
|
-
></k-code-editor>
|
|
118
|
-
</k-tab-content>
|
|
119
|
-
<k-tab-content name="js">
|
|
120
|
-
<k-code-editor
|
|
121
|
-
id="js"
|
|
122
|
-
language="js"
|
|
123
|
-
class="my"
|
|
124
|
-
></k-code-editor>
|
|
125
|
-
</k-tab-content>
|
|
126
|
-
</k-tabs>
|
|
127
|
-
<div
|
|
128
|
-
id="results"
|
|
129
|
-
slot="right"
|
|
130
|
-
></div>
|
|
131
|
-
</k-split>
|
|
132
|
-
`;
|
|
133
|
-
}
|
|
134
|
-
get shadowStyles(){
|
|
135
|
-
return /*css*/`
|
|
136
|
-
:host {
|
|
137
|
-
--min-height: auto;
|
|
138
|
-
--height: auto;
|
|
139
|
-
--max-height: auto;
|
|
140
|
-
display: block;
|
|
141
|
-
}
|
|
142
|
-
k-tab-content {
|
|
143
|
-
min-height: var(--min-height);
|
|
144
|
-
height: var(--height);
|
|
145
|
-
max-height: var(--max-height);
|
|
146
|
-
}
|
|
147
|
-
k-code-editor {
|
|
148
|
-
max-height: calc(100% - (2 * var(--spacer)));
|
|
149
|
-
}
|
|
150
|
-
#results,
|
|
151
|
-
iframe {
|
|
152
|
-
width: 100%;
|
|
153
|
-
height: 100%;
|
|
154
|
-
background-color: transparent;
|
|
155
|
-
}
|
|
156
|
-
`;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
window.customElements.define('k-web-snippet-editor', WebSnippetEditor);
|