@pageboard/html 0.12.7 → 0.12.8

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/embed.js CHANGED
@@ -40,7 +40,7 @@ exports.embed = {
40
40
  };
41
41
  },
42
42
  tag: 'iframe,element-embed',
43
- html: `<element-embed data-src="[url|meta:source][query|as:query]" id="[id]" title="[url|meta:title]" style="padding-bottom:calc([url|meta:height] / [url|meta:width] * 100%)">
43
+ html: `<element-embed data-url="[url]" data-query="[query|as:query]" id="[id]">
44
44
  <a aria-hidden="true" class="linkable" href="[$loc.pathname][$loc.search][id|pre:%23]">[linkable|prune:*]#</a>
45
45
  <iframe loading="lazy" allowfullscreen frameborder="0" scrolling="no"></iframe>
46
46
  </element-embed>`,
@@ -6,7 +6,7 @@ exports.fieldset = {
6
6
  context: 'form//',
7
7
  properties: {
8
8
  name: {
9
- title: 'Show if input named',
9
+ title: 'Show if input[name]',
10
10
  type: 'string',
11
11
  format: 'singleline',
12
12
  nullable: true,
@@ -29,7 +29,7 @@ exports.fieldset = {
29
29
  }
30
30
  },
31
31
  contents: "fieldset_legend block+",
32
- html: '<fieldset class="[plain]" data-name="[name|split:.|slice:1|join:.]" data-value="[value]" is="element-fieldset"></fieldset>',
32
+ html: '<fieldset class="[plain]" data-name="[name]" data-value="[value]" is="element-fieldset"></fieldset>',
33
33
  scripts: ["../ui/fieldset.js"],
34
34
  stylesheets: ['../ui/fieldset.css']
35
35
  };
package/elements/image.js CHANGED
@@ -132,8 +132,6 @@ 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]"
137
135
  data-crop="[crop.x|or:50];[crop.y|or:50];[crop.width|or:100];[crop.height|or:100];[crop.zoom|or:100]"
138
136
  >
139
137
  <div block-content="legend"></div>
@@ -281,8 +279,6 @@ exports.inlineImage = {
281
279
  tag: "img",
282
280
  html: `<img is="element-img"
283
281
  data-src="[url]"
284
- data-width="[url|meta:width]"
285
- data-height="[url|meta:height]"
286
282
  data-crop="[crop.x];[crop.y];[crop.width];[crop.height];[crop.zoom]"
287
283
  alt="" class="ui inline image
288
284
  [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]" width="[url|meta:width]" height="[url|meta:height]"></video>`,
70
+ muted="[muted]" controls="[controls]"></video>`,
71
71
  scripts: [
72
72
  '../ui/media.js'
73
73
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pageboard/html",
3
- "version": "0.12.7",
3
+ "version": "0.12.8",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -1,5 +1,6 @@
1
1
  Page.extend('element-embed', class HTMLElementEmbedHelper {
2
- patch(state) {
2
+ paint(state) {
3
+ if (!state.scope.$write) return;
3
4
  const { editor } = state.scope;
4
5
  if (!editor) return;
5
6
  const id = editor.slug(this.title).slice(0, 32);
package/ui/embed.js CHANGED
@@ -1,6 +1,7 @@
1
1
  class HTMLElementEmbed extends Page.Element {
2
2
  static defaults = {
3
- src: null,
3
+ url: null,
4
+ query: null,
4
5
  hash: null
5
6
  };
6
7
  static revealRatio = 0.2;
@@ -12,6 +13,16 @@ class HTMLElementEmbed extends Page.Element {
12
13
  get currentSrc() {
13
14
  return this.querySelector('iframe')?.src ?? "about:blank";
14
15
  }
16
+ patch(state) {
17
+ const meta = state.scope.$hrefs?.[this.options.url];
18
+ if (meta) {
19
+ this.title = meta.title;
20
+ this.setAttribute('data-src', meta.source);
21
+ this.style.paddingBottom = `calc(${meta.height} / ${meta.width} * 100%)`;
22
+ } else {
23
+ console.warn("Missing href", this.options.url);
24
+ }
25
+ }
15
26
  consent(state) {
16
27
  const consent = state.scope.$consent;
17
28
  this.classList.toggle('denied', consent == "no");
@@ -26,7 +37,7 @@ class HTMLElementEmbed extends Page.Element {
26
37
 
27
38
  const opts = this.options;
28
39
  const prev = Page.parse(this.currentSrc);
29
- const cur = Page.parse(opts.src || "about:blank");
40
+ const cur = Page.parse(this.dataset.src || "about:blank");
30
41
  cur.hash = opts.hash;
31
42
  const curSrc = cur.toString();
32
43
 
package/ui/form.js CHANGED
@@ -316,9 +316,11 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
316
316
  const form = this;
317
317
  form.classList.add('loading');
318
318
 
319
- await Promise.all(Array.from(form.elements).filter(node => {
320
- return Boolean(node.presubmit);
321
- }).map(input => input.presubmit()));
319
+ await Promise.all(
320
+ Array.from(form.elements)
321
+ .filter(node => Boolean(node.presubmit) && !node.disabled)
322
+ .map(input => input.presubmit(state))
323
+ );
322
324
 
323
325
  const { scope } = state;
324
326
  scope.$request = form.read(true);
package/ui/input-file.js CHANGED
@@ -52,7 +52,7 @@ class HTMLElementInputFile extends Page.create(HTMLInputElement) {
52
52
  }
53
53
  }
54
54
 
55
- presubmit() {
55
+ presubmit(state) {
56
56
  if (this.#defer) return this.#defer;
57
57
  if (!this.files.length) return Promise.resolve();
58
58
  const field = this.closest('.field');
package/ui/media.js CHANGED
@@ -31,6 +31,18 @@ class HTMLElementVideo extends HTMLElementMediaConstructor(Page.create(HTMLVideo
31
31
  static defaults = {
32
32
  dataSrc: null
33
33
  };
34
+ patch(state) {
35
+ super.patch(state);
36
+ const { url } = this.options;
37
+ const meta = state.scope.$hrefs?.[url];
38
+ if (meta) {
39
+ this.title = meta.title;
40
+ this.width = meta.width;
41
+ this.height = meta.height;
42
+ } else {
43
+ console.warn("Missing href", url);
44
+ }
45
+ }
34
46
  }
35
47
  Page.define('element-video', HTMLElementVideo, 'video');
36
48