@pageboard/html 0.12.0 → 0.12.2
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/elements/form.js +1 -1
- package/elements/heading.js +4 -10
- package/elements/image.js +4 -0
- package/elements/media.js +1 -1
- package/elements/sitemap.js +1 -7
- package/elements/tab.js +2 -8
- package/package.json +1 -1
- package/ui/form.js +1 -1
- package/ui/heading-helper.js +7 -8
- package/ui/image.js +2 -10
- package/ui/layout.js +0 -8
- package/ui/media.js +0 -5
- package/ui/sitemap-helper.js +10 -4
- package/ui/sitemap.js +5 -5
- package/ui/transition.css +15 -17
- package/ui/transition.js +7 -7
package/elements/form.js
CHANGED
|
@@ -47,7 +47,7 @@ exports.query_form = {
|
|
|
47
47
|
contents: 'block+',
|
|
48
48
|
tag: 'form[method="get"]',
|
|
49
49
|
html: `<form is="element-form" method="get" name="[name]"
|
|
50
|
-
action="[redirection
|
|
50
|
+
action="[redirection|urltpl:url:parameters]"
|
|
51
51
|
autocomplete="off" class="ui form"></form>`,
|
|
52
52
|
stylesheets: [
|
|
53
53
|
'../lib/components/form.css',
|
package/elements/heading.js
CHANGED
|
@@ -55,8 +55,8 @@ exports.heading = {
|
|
|
55
55
|
group: "block",
|
|
56
56
|
icon: '<i class="icon header"></i>',
|
|
57
57
|
tag: 'h1,h2,h3,h4,h5,h6',
|
|
58
|
-
html: `<h[level] class="ui [align|or:left] aligned header" is="h[level]-helper" id="[id]" entitled="[entitled]">
|
|
59
|
-
<a aria-hidden="true" href="[$loc.pathname][$loc.search][id|pre
|
|
58
|
+
html: `<h[level] class="ui [align|or:left] aligned header" is="h[level]-helper" id="[id][linkable|prune:-]" entitled="[entitled]">
|
|
59
|
+
<a aria-hidden="true" href="[$loc.pathname][$loc.search][id|pre:%23]">[linkable|prune:*]#</a>
|
|
60
60
|
<div block-content="text">Heading</div>
|
|
61
61
|
</hn>`,
|
|
62
62
|
parse: function (dom) {
|
|
@@ -69,15 +69,9 @@ exports.heading = {
|
|
|
69
69
|
],
|
|
70
70
|
scripts: [
|
|
71
71
|
'../ui/heading.js'
|
|
72
|
-
]
|
|
73
|
-
resources: {
|
|
74
|
-
helper: '../ui/heading-helper.js'
|
|
75
|
-
},
|
|
76
|
-
install: function (scope) {
|
|
77
|
-
if (scope.$write) Pageboard.load.js(this.resources.helper, scope);
|
|
78
|
-
}
|
|
72
|
+
]
|
|
79
73
|
};
|
|
80
|
-
|
|
74
|
+
exports.editor.scripts.push('../ui/heading-helper.js');
|
|
81
75
|
|
|
82
76
|
exports.heading_nolink = {
|
|
83
77
|
...exports.heading,
|
package/elements/image.js
CHANGED
|
@@ -132,6 +132,8 @@ exports.image = {
|
|
|
132
132
|
class="[display.fit|or:none] [display.horizontal|or:] [display.vertical|or:]"
|
|
133
133
|
alt="[alt]"
|
|
134
134
|
data-src="[url]"
|
|
135
|
+
data-width="[url|meta:width]"
|
|
136
|
+
data-height="[url|meta:height]"
|
|
135
137
|
data-crop="[crop.x|or:50];[crop.y|or:50];[crop.width|or:100];[crop.height|or:100];[crop.zoom|or:100]"
|
|
136
138
|
>
|
|
137
139
|
<div block-content="legend"></div>
|
|
@@ -279,6 +281,8 @@ exports.inlineImage = {
|
|
|
279
281
|
tag: "img",
|
|
280
282
|
html: `<img is="element-img"
|
|
281
283
|
data-src="[url]"
|
|
284
|
+
data-width="[url|meta:width]"
|
|
285
|
+
data-height="[url|meta:height]"
|
|
282
286
|
data-crop="[crop.x];[crop.y];[crop.width];[crop.height];[crop.zoom]"
|
|
283
287
|
alt="" class="ui inline image
|
|
284
288
|
[display.avatar]
|
package/elements/media.js
CHANGED
|
@@ -67,7 +67,7 @@ exports.video = {
|
|
|
67
67
|
},
|
|
68
68
|
html: `<video is="element-video" data-src="[url]" class="[display.fit|or:none]"
|
|
69
69
|
preload="metadata" autoplay="[autoplay]" loop="[loop]"
|
|
70
|
-
muted="[muted]" controls="[controls]"></video>`,
|
|
70
|
+
muted="[muted]" controls="[controls]" width="[url|meta:width]" height="[url|meta:height]"></video>`,
|
|
71
71
|
scripts: [
|
|
72
72
|
'../ui/media.js'
|
|
73
73
|
],
|
package/elements/sitemap.js
CHANGED
|
@@ -19,12 +19,6 @@ exports.sitemap = {
|
|
|
19
19
|
scripts: [
|
|
20
20
|
'../ui/sitemap.js'
|
|
21
21
|
],
|
|
22
|
-
resources: {
|
|
23
|
-
helper: '../ui/sitemap-helper.js'
|
|
24
|
-
},
|
|
25
|
-
install: function(scope) {
|
|
26
|
-
if (scope.$write) Pageboard.load.js(this.resources.helper, scope);
|
|
27
|
-
},
|
|
28
22
|
itemModel: function(name, leaf) {
|
|
29
23
|
const schema = exports[name];
|
|
30
24
|
return {
|
|
@@ -65,6 +59,6 @@ exports.sitemap = {
|
|
|
65
59
|
};
|
|
66
60
|
}
|
|
67
61
|
};
|
|
68
|
-
|
|
62
|
+
exports.editor.scripts.push('../ui/sitemap-helper.js');
|
|
69
63
|
exports.sitepage = exports.sitemap.itemModel('page', false);
|
|
70
64
|
exports.siteredirection = exports.sitemap.itemModel('redirection', true);
|
package/elements/tab.js
CHANGED
|
@@ -30,15 +30,9 @@ exports.tabs = {
|
|
|
30
30
|
],
|
|
31
31
|
scripts: [
|
|
32
32
|
'../ui/tab.js'
|
|
33
|
-
]
|
|
34
|
-
resources: {
|
|
35
|
-
helper: '../ui/tab-helper.js'
|
|
36
|
-
},
|
|
37
|
-
install: function(scope) {
|
|
38
|
-
if (scope.$write) Pageboard.load.js(this.resources.helper, scope);
|
|
39
|
-
}
|
|
33
|
+
]
|
|
40
34
|
};
|
|
41
|
-
|
|
35
|
+
exports.editor.scripts.push('../ui/tab-helper.js');
|
|
42
36
|
|
|
43
37
|
exports.tab_item = {
|
|
44
38
|
title: "Item",
|
package/package.json
CHANGED
package/ui/form.js
CHANGED
|
@@ -323,7 +323,7 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
|
|
|
323
323
|
scope.$request = form.read(true);
|
|
324
324
|
form.disable();
|
|
325
325
|
|
|
326
|
-
const res = await
|
|
326
|
+
const res = await state.fetch(form.method, Page.format({
|
|
327
327
|
pathname: form.getAttribute('action'),
|
|
328
328
|
query: state.query
|
|
329
329
|
}), scope.$request).catch(err => err);
|
package/ui/heading-helper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class HTMLElementHeadingHelper extends Page.create(HTMLHeadingElement) {
|
|
2
2
|
setup(state) {
|
|
3
|
-
this.willSync = state.debounce(() => this.sync(), 100);
|
|
3
|
+
this.willSync = state.debounce(() => this.sync(state.scope), 100);
|
|
4
4
|
this.observer = new MutationObserver(records => {
|
|
5
5
|
if (records.some(mut => {
|
|
6
6
|
return mut.type == "characterData" || mut.type == "childList" && mut.addedNodes.length;
|
|
@@ -15,13 +15,14 @@ class HTMLElementHeadingHelper extends Page.create(HTMLHeadingElement) {
|
|
|
15
15
|
close() {
|
|
16
16
|
if (this.observer) this.observer.disconnect();
|
|
17
17
|
}
|
|
18
|
-
sync() {
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
21
|
-
|
|
18
|
+
sync(scope) {
|
|
19
|
+
const { editor } = scope;
|
|
20
|
+
if (!editor) return;
|
|
21
|
+
if (this.firstElementChild?.nodeName != "A") return;
|
|
22
|
+
const txt = editor.slug(this.textContent);
|
|
22
23
|
const id = txt.length <= 64 ? txt : null;
|
|
23
24
|
if (id != this.id) {
|
|
24
|
-
|
|
25
|
+
editor.blocks.mutate(this, { id });
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
}
|
|
@@ -34,5 +35,3 @@ for (let i = 1; i <= 6; i++) {
|
|
|
34
35
|
`h${i}`
|
|
35
36
|
);
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
|
package/ui/image.js
CHANGED
|
@@ -93,16 +93,8 @@ const HTMLElementImageConstructor = Superclass => class extends Superclass {
|
|
|
93
93
|
if (this.currentSrc != this.options.src) {
|
|
94
94
|
this.classList.remove('error');
|
|
95
95
|
}
|
|
96
|
-
this.dataset.width
|
|
97
|
-
this.dataset.height
|
|
98
|
-
if (this.options.src) {
|
|
99
|
-
const loc = Page.parse(this.options.src);
|
|
100
|
-
const meta = state.scope.$hrefs?.[loc.pathname];
|
|
101
|
-
if (meta) {
|
|
102
|
-
this.dataset.width = meta.width;
|
|
103
|
-
this.dataset.height = meta.height;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
96
|
+
this.dataset.width ??= this.constructor.defaultWidth || "";
|
|
97
|
+
this.dataset.height ??= this.constructor.defaultHeight || "";
|
|
106
98
|
const { w, h } = this.dimensions;
|
|
107
99
|
if (w) this.image.width = w || this.dataset.width;
|
|
108
100
|
if (h) this.image.height = h || this.dataset.height;
|
package/ui/layout.js
CHANGED
|
@@ -11,14 +11,6 @@ class HTMLElementLayout extends Page.create(HTMLDivElement) {
|
|
|
11
11
|
get fit() {
|
|
12
12
|
return this.options.size || 'none';
|
|
13
13
|
}
|
|
14
|
-
patch(state) {
|
|
15
|
-
if (!this.options.src) return;
|
|
16
|
-
const loc = Page.parse(this.options.src);
|
|
17
|
-
const meta = state.scope.$hrefs?.[loc.pathname] ?? {};
|
|
18
|
-
if (!meta || !meta.width || !meta.height) return;
|
|
19
|
-
this.dataset.width = meta.width;
|
|
20
|
-
this.dataset.height = meta.height;
|
|
21
|
-
}
|
|
22
14
|
reveal(state) {
|
|
23
15
|
this.style.backgroundRepeat = this.options.repeat;
|
|
24
16
|
this.style.backgroundSize = this.options.size;
|
package/ui/media.js
CHANGED
|
@@ -3,11 +3,6 @@ const HTMLElementMediaConstructor = Superclass => class extends Superclass {
|
|
|
3
3
|
|
|
4
4
|
patch(state) {
|
|
5
5
|
this.classList.remove('error', 'loading');
|
|
6
|
-
const loc = Page.parse(this.options.src);
|
|
7
|
-
const meta = state.scope.$hrefs?.[loc.pathname] ?? {};
|
|
8
|
-
if (!meta || !meta.width || !meta.height) return;
|
|
9
|
-
this.width = meta.width;
|
|
10
|
-
this.height = meta.height;
|
|
11
6
|
}
|
|
12
7
|
reveal(state) {
|
|
13
8
|
const curSrc = this.options.src;
|
package/ui/sitemap-helper.js
CHANGED
|
@@ -5,7 +5,7 @@ class HTMLElementSitepage extends Page.Element {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
patch(state) {
|
|
8
|
-
if (this.isConnected) this.syncBlock();
|
|
8
|
+
if (this.isConnected) this.syncBlock(state.scope);
|
|
9
9
|
}
|
|
10
10
|
setup(state) {
|
|
11
11
|
const content = this.querySelector('[block-content="children"]');
|
|
@@ -45,9 +45,9 @@ class HTMLElementSitepage extends Page.Element {
|
|
|
45
45
|
this.updating = false;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
syncBlock() {
|
|
48
|
+
syncBlock(scope) {
|
|
49
49
|
if (!this.parentNode || this.matches('element-sitemap')) return;
|
|
50
|
-
const editor =
|
|
50
|
+
const editor = scope.editor;
|
|
51
51
|
if (!editor || editor.closed) return;
|
|
52
52
|
const block = editor.blocks.get(this.getAttribute('block-id'));
|
|
53
53
|
if (!block.data) block.data = {};
|
|
@@ -63,5 +63,11 @@ class HTMLElementSitepage extends Page.Element {
|
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
Page.define('element-sitepage', HTMLElementSitepage);
|
|
66
|
-
|
|
66
|
+
|
|
67
|
+
Page.setup(state => {
|
|
68
|
+
if (!state.scope.$write) return;
|
|
69
|
+
state.finish(() => {
|
|
70
|
+
Page.extend('element-sitemap', HTMLElementSitepage);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
67
73
|
|
package/ui/sitemap.js
CHANGED
|
@@ -57,13 +57,13 @@ class HTMLElementSitemap extends Page.Element {
|
|
|
57
57
|
// workaround... build is called a second time with pagecut-placeholder set
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
const res = await
|
|
61
|
-
const scope =
|
|
62
|
-
|
|
60
|
+
const res = await state.fetch('get', `/.api/pages`);
|
|
61
|
+
const scope = state.scope.copy();
|
|
62
|
+
await scope.import(res);
|
|
63
63
|
const tree = this.constructor.transformResponse(res);
|
|
64
|
-
const node =
|
|
64
|
+
const node = scope.render({
|
|
65
65
|
item: tree
|
|
66
|
-
}
|
|
66
|
+
});
|
|
67
67
|
// only change block content
|
|
68
68
|
const src = node.firstElementChild;
|
|
69
69
|
const dst = this.firstElementChild;
|
package/ui/transition.css
CHANGED
|
@@ -1,47 +1,45 @@
|
|
|
1
1
|
/* async progress bar and error signal */
|
|
2
2
|
|
|
3
|
-
body::
|
|
3
|
+
body::before {
|
|
4
4
|
content: "";
|
|
5
5
|
position:fixed;
|
|
6
6
|
display:block;
|
|
7
7
|
left:0;
|
|
8
|
-
top:
|
|
8
|
+
top:0px;
|
|
9
9
|
width:0%;
|
|
10
10
|
height:0;
|
|
11
11
|
opacity:0.7;
|
|
12
12
|
background: #4486cc;
|
|
13
13
|
box-shadow: 0 0 5px rgb(99 162 235 / 70%);
|
|
14
|
-
z-index:
|
|
14
|
+
z-index:10000000;
|
|
15
15
|
}
|
|
16
|
-
html[data-stage] > body::
|
|
16
|
+
html[data-stage] > body::before {
|
|
17
17
|
transition-property:width;
|
|
18
|
-
transition-duration:
|
|
18
|
+
transition-duration:0.5s;
|
|
19
19
|
transition-timing-function:linear;
|
|
20
20
|
}
|
|
21
|
-
html[data-stage="
|
|
22
|
-
html[data-stage="ready"] > body::
|
|
23
|
-
html[data-stage="
|
|
24
|
-
html[data-stage="error"] > body::
|
|
21
|
+
html[data-stage="route"] > body::before,
|
|
22
|
+
html[data-stage="ready"] > body::before,
|
|
23
|
+
html[data-stage="paint"] > body::before,
|
|
24
|
+
html[data-stage="error"] > body::before {
|
|
25
25
|
height:2px;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
html[data-stage="
|
|
28
|
+
html[data-stage="route"] > body::before {
|
|
29
|
+
width:25%;
|
|
30
|
+
}
|
|
31
|
+
html[data-stage="ready"] > body::before {
|
|
29
32
|
width:50%;
|
|
30
33
|
}
|
|
31
|
-
html[data-stage="
|
|
32
|
-
html[data-stage="setup"] > body::after {
|
|
34
|
+
html[data-stage="paint"] > body::before {
|
|
33
35
|
width:100%;
|
|
34
36
|
}
|
|
35
|
-
html[data-stage="error"] > body::
|
|
37
|
+
html[data-stage="error"] > body::before {
|
|
36
38
|
display:block;
|
|
37
39
|
width:100%;
|
|
38
40
|
background:#c33;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
html.transition > body::after {
|
|
42
|
-
display:none !important;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
43
|
/* transitions */
|
|
46
44
|
html.transition {
|
|
47
45
|
width:100%;
|
package/ui/transition.js
CHANGED
|
@@ -5,19 +5,19 @@ Object.defineProperty(document, 'body', {
|
|
|
5
5
|
}
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
-
Page.
|
|
8
|
+
Page.route(state => {
|
|
9
9
|
const root = document.documentElement;
|
|
10
10
|
function dtr(state) {
|
|
11
11
|
root.dataset.stage = state.stage;
|
|
12
|
-
if (state.stage == "
|
|
13
|
-
setTimeout(() => root.removeAttribute('data-stage'),
|
|
12
|
+
if (state.stage == "paint") {
|
|
13
|
+
setTimeout(() => root.removeAttribute('data-stage'), 700);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
dtr(state);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
state.ready(dtr);
|
|
18
|
+
state.patch(dtr);
|
|
19
|
+
state.paint(dtr);
|
|
20
|
+
state.catch(dtr);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
class Transition {
|