@riebeckite/plugin-ux 0.0.3 → 0.0.6

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/client.js CHANGED
@@ -200,7 +200,9 @@ function setupTocScrollSpy() {
200
200
  scheduleOnScroll(updateActive);
201
201
  }
202
202
  function setupCodeCopy(config) {
203
- const blocks = Array.from(document.querySelectorAll("pre > code"));
203
+ const blocks = Array.from(
204
+ document.querySelectorAll("pre > code")
205
+ );
204
206
  for (const code of blocks) {
205
207
  const pre = code.parentElement;
206
208
  if (!pre || pre.dataset.rbUxCopy === "true") continue;
package/dist/index.js CHANGED
@@ -6,6 +6,9 @@ import {
6
6
  isPublished
7
7
  } from "@riebeckite/core";
8
8
 
9
+ // src/inject.ts
10
+ import { escapeScriptJson } from "@riebeckite/core";
11
+
9
12
  // src/options.ts
10
13
  var UX_CONFIG_ELEMENT_ID = "rb-ux-config";
11
14
  var UX_CONFIG_ATTRIBUTE = "data-rb-ux-config";
@@ -41,7 +44,7 @@ function normalizeLabel(value, fallback) {
41
44
 
42
45
  // src/inject.ts
43
46
  function renderUxConfigElement(config) {
44
- const json = JSON.stringify(config).replace(/</g, "\\u003c").replace(/>/g, "\\u003e");
47
+ const json = escapeScriptJson(JSON.stringify(config));
45
48
  return `<script type="application/json" id="${UX_CONFIG_ELEMENT_ID}" ${UX_CONFIG_ATTRIBUTE}>${json}</script>`;
46
49
  }
47
50
  function injectUxConfig(html, config) {
@@ -4,7 +4,8 @@ import { type UxResolvedConfig } from "./options.js";
4
4
  *
5
5
  * Client initializers are static and receive no plugin options, so the build
6
6
  * injects this element into the article HTML and reads it back at runtime.
7
- * `<` and `>` are escaped so labels can never terminate the script element.
7
+ * `escapeScriptJson` neutralizes `<`, `>`, `&`, U+2028 and U+2029 so labels
8
+ * can never terminate the script element.
8
9
  */
9
10
  export declare function renderUxConfigElement(config: UxResolvedConfig): string;
10
11
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-ux",
3
- "version": "0.0.3",
3
+ "version": "0.0.6",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "./style.css": "./style.css"
22
22
  },
23
23
  "dependencies": {
24
- "@riebeckite/core": "0.0.3"
24
+ "@riebeckite/core": "0.0.6"
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public"
package/style.css CHANGED
@@ -1,127 +1,123 @@
1
- .rb-ux__progress {
2
- position: fixed;
3
- inset-block-start: 0;
4
- inset-inline: 0;
5
- z-index: 60;
6
- height: 3px;
7
- pointer-events: none;
8
- background: color-mix(
9
- in srgb,
10
- var(--rb-color-ink, #1c1a17) 8%,
11
- transparent
12
- );
13
- }
14
-
15
- .rb-ux__progress-bar {
16
- display: block;
17
- width: 100%;
18
- height: 100%;
19
- transform: scaleX(0);
20
- transform-origin: left center;
21
- background: var(--rb-color-accent, #686868);
22
- transition: transform 100ms linear;
23
- }
24
-
25
- .rb-ux__back-to-top {
26
- position: fixed;
27
- inset-block-end: 1.5rem;
28
- inset-inline-end: 1.5rem;
29
- z-index: 60;
30
- display: grid;
31
- place-items: center;
32
- width: 2.75rem;
33
- height: 2.75rem;
34
- padding: 0;
35
- border: 1px solid
36
- var(--rb-color-border-strong, var(--rb-color-border, #d0ccc4));
37
- border-radius: 999px;
38
- background: var(--rb-color-surface, var(--rb-color-paper, #ffffff));
39
- color: var(--rb-color-ink, #1c1a17);
40
- font-size: 1.15rem;
41
- line-height: 1;
42
- cursor: pointer;
43
- opacity: 0;
44
- visibility: hidden;
45
- transform: translateY(0.5rem);
46
- transition:
47
- opacity 150ms ease,
48
- transform 150ms ease,
49
- visibility 150ms ease;
50
- }
51
-
52
- .rb-ux__back-to-top--visible {
53
- opacity: 1;
54
- visibility: visible;
55
- transform: none;
56
- }
57
-
58
- .rb-ux__back-to-top:hover {
59
- background: var(--rb-color-surface-hover, var(--rb-color-surface, #f4f2ee));
60
- }
61
-
62
- .rb-ux__back-to-top:focus-visible {
63
- outline: 2px solid var(--rb-color-accent, #686868);
64
- outline-offset: 2px;
65
- }
66
-
67
- .rb-ux__toc-active {
68
- color: var(--rb-color-accent, #686868);
69
- font-weight: 600;
70
- }
71
-
72
- .rb-ux__code {
73
- position: relative;
74
- }
75
-
76
- .rb-ux__copy {
77
- position: absolute;
78
- inset-block-start: 0.5rem;
79
- inset-inline-end: 0.5rem;
80
- z-index: 1;
81
- padding: 0.2rem 0.5rem;
82
- border: 1px solid
83
- var(--rb-color-border, color-mix(in srgb, currentColor 20%, transparent));
84
- border-radius: 4px;
85
- background: var(--rb-color-surface, var(--rb-color-paper, #ffffff));
86
- color: var(--rb-color-muted, #69645c);
87
- font-size: 0.75rem;
88
- line-height: 1.4;
89
- cursor: pointer;
90
- opacity: 0.9;
91
- transition:
92
- opacity 120ms ease,
93
- color 120ms ease,
94
- border-color 120ms ease;
95
- }
96
-
97
- .rb-ux__copy:hover,
98
- .rb-ux__copy:focus-visible {
99
- opacity: 1;
100
- color: var(--rb-color-ink, #1c1a17);
101
- }
102
-
103
- .rb-ux__copy:focus-visible {
104
- outline: 2px solid var(--rb-color-accent, #686868);
105
- outline-offset: 2px;
106
- }
107
-
108
- .rb-ux__copy--copied {
109
- color: var(--rb-color-accent, #686868);
110
- border-color: var(--rb-color-accent, #686868);
111
- }
112
-
113
- @media (prefers-reduced-motion: reduce) {
114
- .rb-ux__progress-bar,
115
- .rb-ux__back-to-top,
116
- .rb-ux__copy {
117
- transition: none;
118
- }
119
- }
120
-
121
- @media print {
122
- .rb-ux__progress,
123
- .rb-ux__back-to-top,
124
- .rb-ux__copy {
125
- display: none;
126
- }
127
- }
1
+ .rb-ux__progress {
2
+ position: fixed;
3
+ inset-block-start: 0;
4
+ inset-inline: 0;
5
+ z-index: 60;
6
+ height: 3px;
7
+ pointer-events: none;
8
+ background: color-mix(in srgb, var(--rb-color-ink, #1c1a17) 8%, transparent);
9
+ }
10
+
11
+ .rb-ux__progress-bar {
12
+ display: block;
13
+ width: 100%;
14
+ height: 100%;
15
+ transform: scaleX(0);
16
+ transform-origin: left center;
17
+ background: var(--rb-color-accent, #686868);
18
+ transition: transform 100ms linear;
19
+ }
20
+
21
+ .rb-ux__back-to-top {
22
+ position: fixed;
23
+ inset-block-end: 1.5rem;
24
+ inset-inline-end: 1.5rem;
25
+ z-index: 60;
26
+ display: grid;
27
+ place-items: center;
28
+ width: 2.75rem;
29
+ height: 2.75rem;
30
+ padding: 0;
31
+ border: 1px solid
32
+ var(--rb-color-border-strong, var(--rb-color-border, #d0ccc4));
33
+ border-radius: 999px;
34
+ background: var(--rb-color-surface, var(--rb-color-paper, #ffffff));
35
+ color: var(--rb-color-ink, #1c1a17);
36
+ font-size: 1.15rem;
37
+ line-height: 1;
38
+ cursor: pointer;
39
+ opacity: 0;
40
+ visibility: hidden;
41
+ transform: translateY(0.5rem);
42
+ transition:
43
+ opacity 150ms ease,
44
+ transform 150ms ease,
45
+ visibility 150ms ease;
46
+ }
47
+
48
+ .rb-ux__back-to-top--visible {
49
+ opacity: 1;
50
+ visibility: visible;
51
+ transform: none;
52
+ }
53
+
54
+ .rb-ux__back-to-top:hover {
55
+ background: var(--rb-color-surface-hover, var(--rb-color-surface, #f4f2ee));
56
+ }
57
+
58
+ .rb-ux__back-to-top:focus-visible {
59
+ outline: 2px solid var(--rb-color-accent, #686868);
60
+ outline-offset: 2px;
61
+ }
62
+
63
+ .rb-ux__toc-active {
64
+ color: var(--rb-color-accent, #686868);
65
+ font-weight: 600;
66
+ }
67
+
68
+ .rb-ux__code {
69
+ position: relative;
70
+ }
71
+
72
+ .rb-ux__copy {
73
+ position: absolute;
74
+ inset-block-start: 0.5rem;
75
+ inset-inline-end: 0.5rem;
76
+ z-index: 1;
77
+ padding: 0.2rem 0.5rem;
78
+ border: 1px solid
79
+ var(--rb-color-border, color-mix(in srgb, currentColor 20%, transparent));
80
+ border-radius: 4px;
81
+ background: var(--rb-color-surface, var(--rb-color-paper, #ffffff));
82
+ color: var(--rb-color-muted, #69645c);
83
+ font-size: 0.75rem;
84
+ line-height: 1.4;
85
+ cursor: pointer;
86
+ opacity: 0.9;
87
+ transition:
88
+ opacity 120ms ease,
89
+ color 120ms ease,
90
+ border-color 120ms ease;
91
+ }
92
+
93
+ .rb-ux__copy:hover,
94
+ .rb-ux__copy:focus-visible {
95
+ opacity: 1;
96
+ color: var(--rb-color-ink, #1c1a17);
97
+ }
98
+
99
+ .rb-ux__copy:focus-visible {
100
+ outline: 2px solid var(--rb-color-accent, #686868);
101
+ outline-offset: 2px;
102
+ }
103
+
104
+ .rb-ux__copy--copied {
105
+ color: var(--rb-color-accent, #686868);
106
+ border-color: var(--rb-color-accent, #686868);
107
+ }
108
+
109
+ @media (prefers-reduced-motion: reduce) {
110
+ .rb-ux__progress-bar,
111
+ .rb-ux__back-to-top,
112
+ .rb-ux__copy {
113
+ transition: none;
114
+ }
115
+ }
116
+
117
+ @media print {
118
+ .rb-ux__progress,
119
+ .rb-ux__back-to-top,
120
+ .rb-ux__copy {
121
+ display: none;
122
+ }
123
+ }