@pageboard/html 0.14.26 → 0.14.28

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
@@ -4,9 +4,11 @@ exports.embed = {
4
4
  icon: '<i class="external square alternate icon"></i>',
5
5
  properties: {
6
6
  id: {
7
+ title: 'Link name',
8
+ description: 'Target for anchors',
7
9
  nullable: true,
8
10
  type: 'string',
9
- pattern: /^[a-z0-9-]*$/.source
11
+ format: 'grant'
10
12
  },
11
13
  linkable: {
12
14
  title: 'Show hash link',
@@ -53,4 +55,3 @@ exports.embed = {
53
55
  '../ui/linkable.css'
54
56
  ]
55
57
  };
56
- exports.editor?.scripts.push('../ui/embed-helper.js');
@@ -32,9 +32,11 @@ exports.heading = {
32
32
  }]
33
33
  },
34
34
  id: {
35
+ title: 'Link name',
36
+ description: 'Target for anchors',
35
37
  nullable: true,
36
38
  type: 'string',
37
- pattern: /^[a-z0-9-]*$/.source
39
+ format: 'grant'
38
40
  },
39
41
  linkable: {
40
42
  title: 'Show hash link',
@@ -60,6 +62,7 @@ exports.heading = {
60
62
  </hn>`,
61
63
  parse: function (dom) {
62
64
  return {
65
+ id: dom.getAttribute('id') || null,
63
66
  level: parseInt(dom.nodeName.substring(1))
64
67
  };
65
68
  },
@@ -71,7 +74,6 @@ exports.heading = {
71
74
  '../ui/heading.js'
72
75
  ]
73
76
  };
74
- exports.editor?.scripts.push('../ui/heading-helper.js');
75
77
 
76
78
  exports.heading_nolink = {
77
79
  ...exports.heading,
package/elements/link.js CHANGED
@@ -31,13 +31,20 @@ exports.link = {
31
31
  name: 'datalist',
32
32
  url: '/.api/languages'
33
33
  }
34
- }
34
+ },
35
+ id: {
36
+ title: 'Link name',
37
+ description: 'Target for anchors',
38
+ nullable: true,
39
+ type: 'string',
40
+ format: 'grant'
41
+ },
35
42
  },
36
43
  contents: "text*",
37
44
  inline: true,
38
45
  group: "inline",
39
46
  tag: 'a:not([block-type]),a[block-type="link"]',
40
- html: '<a href="[url]" hreflang="[lang]" class="[button|alt:ui button]"></a>',
47
+ html: '<a href="[url]" hreflang="[lang]" class="[button|alt:ui button]" id="[id]"></a>',
41
48
  stylesheets: [
42
49
  '../ui/components/button.css'
43
50
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pageboard/html",
3
- "version": "0.14.26",
3
+ "version": "0.14.28",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "repository": {
package/ui/form.js CHANGED
@@ -312,7 +312,7 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
312
312
  }
313
313
 
314
314
  const scope = state.scope.copy();
315
- scope.$request = form.read(true);
315
+ scope.$request = form.read(true, e.submitter);
316
316
  try {
317
317
  const prelist = Array.from(form.elements)
318
318
  .filter(node => Boolean(node.presubmit) && !node.disabled);
package/ui/linkable.css CHANGED
@@ -1,5 +1,6 @@
1
1
  [block-type][id] > a.linkable[aria-hidden="true"] {
2
2
  display: block;
3
3
  position: absolute;
4
- left: -2ch;
4
+ left: -1ch;
5
+ text-decoration: none;
5
6
  }
@@ -1,11 +0,0 @@
1
- Page.extend('element-embed', class HTMLElementEmbedHelper {
2
- paint(state) {
3
- if (!state.scope.$write) return;
4
- const { editor } = state.scope;
5
- if (!editor) return;
6
- const id = editor.slug(this.title).slice(0, 32);
7
- if (id != this.id) {
8
- editor.blocks.mutate(this, { id });
9
- }
10
- }
11
- });
@@ -1,37 +0,0 @@
1
- class HTMLElementHeadingHelper extends Page.create(HTMLHeadingElement) {
2
- setup(state) {
3
- this.willSync = state.debounce(() => this.sync(state.scope), 100);
4
- this.observer = new MutationObserver(records => {
5
- if (records.some(mut => {
6
- return mut.type == "characterData" || mut.type == "childList" && mut.addedNodes.length;
7
- })) this.willSync();
8
- });
9
- this.observer.observe(this, {
10
- childList: true,
11
- subtree: true,
12
- characterData: true
13
- });
14
- }
15
- close() {
16
- if (this.observer) this.observer.disconnect();
17
- }
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);
23
- const id = txt.length <= 64 ? txt : null;
24
- if (id != this.id) {
25
- editor.blocks.mutate(this, { id });
26
- }
27
- }
28
- }
29
-
30
-
31
- for (let i = 1; i <= 6; i++) {
32
- Page.define(
33
- `h${i}-helper`,
34
- class extends HTMLElementHeadingHelper { },
35
- `h${i}`
36
- );
37
- }