-
Notifications
You must be signed in to change notification settings - Fork 0
/
cm.html
101 lines (89 loc) · 2.46 KB
/
cm.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CM</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<script type="module">
import { createElement, render, Component } from 'https://esm.sh/preact';
import {html} from 'https://esm.sh/htm/preact';
// cell class
class BlockTableCell extends Component {
render(props) {
return html`
<div class="block-table-cell">
${props.children}
</div>`;
}
}
// Row Class
class BlockTableRow extends Component {
render(props) {
return html`
<div class="block-table-row">
<${BlockTableCell}>cell 1<//>
<${BlockTableCell}>cell 2<//>
</div>`;
}
}
// block header Class
class BlockTableHeader extends Component {
onBlockNameEdited(e) {
console.log('block name edited: ' + e.target.innerText);
}
render(props) {
console.log(props);
return html`
<div class="block-table-header" contentEditable="plaintext-only" onInput="${this.onBlockNameEdited}">
${props.name}
</div>`;
}
}
// Block Class
class BlockTable extends Component {
state = {
"definitions": [
{
"title": "Block Name",
"id": "blockName",
"plugins": {
"xwalk": {
"page": {
"resourceType:": "core/franklin/components/block/v1/block",
"template": {
"name": "Block Name",
"model": "blockNameModelId"
}
}
}
}
}
],
"models": [
{
"id": "blockNameModelId",
"fields": []
}
],
"filters":[]
}
render() {
return html`
<div class="block-table">
<${BlockTableHeader} name=${this.state.definitions[0].title} />
<${BlockTableRow}/>
<${BlockTableRow}/>
</div>`;
}
}
render(html`<${BlockTable}/>`, document.getElementById('section'));
</script>
<main>
<div id="section">
</div>
</main>
</body>
</html>