hyperbook 0.63.1 → 0.64.0
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.
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
hyperbook.textinput = (function () {
|
|
2
|
+
// Debounce helper to reduce database writes
|
|
3
|
+
const debounce = (func, wait) => {
|
|
4
|
+
let timeout;
|
|
5
|
+
return function executedFunction(...args) {
|
|
6
|
+
const later = () => {
|
|
7
|
+
clearTimeout(timeout);
|
|
8
|
+
func(...args);
|
|
9
|
+
};
|
|
10
|
+
clearTimeout(timeout);
|
|
11
|
+
timeout = setTimeout(later, wait);
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const init = (root) => {
|
|
16
|
+
let allTextInputs = root.querySelectorAll(".directive-textinput textarea[data-id]");
|
|
17
|
+
|
|
18
|
+
allTextInputs.forEach((textarea) => {
|
|
19
|
+
const id = textarea.getAttribute("data-id");
|
|
20
|
+
|
|
21
|
+
// Load saved text from store
|
|
22
|
+
store.textinput.get(id).then((result) => {
|
|
23
|
+
if (result && result.text) {
|
|
24
|
+
textarea.value = result.text;
|
|
25
|
+
}
|
|
26
|
+
}).catch((error) => {
|
|
27
|
+
console.error("Failed to load textinput from store:", error);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Save text to store on input with debouncing
|
|
31
|
+
const saveToStore = debounce(() => {
|
|
32
|
+
store.textinput.put({
|
|
33
|
+
id: id,
|
|
34
|
+
text: textarea.value,
|
|
35
|
+
}).catch((error) => {
|
|
36
|
+
console.error("Failed to save textinput to store:", error);
|
|
37
|
+
});
|
|
38
|
+
}, 500);
|
|
39
|
+
|
|
40
|
+
textarea.addEventListener("input", saveToStore);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
init(document.body);
|
|
45
|
+
|
|
46
|
+
// Observe for new textinputs added to the DOM
|
|
47
|
+
const observer = new MutationObserver((mutations) => {
|
|
48
|
+
mutations.forEach((mutation) => {
|
|
49
|
+
mutation.addedNodes.forEach((node) => {
|
|
50
|
+
if (node.nodeType === 1) {
|
|
51
|
+
// Element node
|
|
52
|
+
init(node);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
init,
|
|
62
|
+
};
|
|
63
|
+
})();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.directive-textinput {
|
|
2
|
+
margin: 1rem 0;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.directive-textinput textarea {
|
|
6
|
+
width: 100%;
|
|
7
|
+
padding: 0.75rem;
|
|
8
|
+
font-family: inherit;
|
|
9
|
+
font-size: 1rem;
|
|
10
|
+
border: 1px solid var(--color-nav-border, #ccc);
|
|
11
|
+
border-radius: 4px;
|
|
12
|
+
resize: vertical;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
transition: border-color 0.2s;
|
|
15
|
+
background-color: var(--color-background, white);
|
|
16
|
+
color: var(--color-text, black);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.directive-textinput textarea:focus {
|
|
20
|
+
outline: none;
|
|
21
|
+
border-color: var(--color-brand, #007864);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.directive-textinput textarea::placeholder {
|
|
25
|
+
color: var(--color-text-deactivated, #999);
|
|
26
|
+
opacity: 1;
|
|
27
|
+
}
|
package/dist/assets/store.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -166048,7 +166048,7 @@ var remarkDirectiveSqlIde_default = (ctx) => () => {
|
|
|
166048
166048
|
children: [
|
|
166049
166049
|
{
|
|
166050
166050
|
type: "raw",
|
|
166051
|
-
value: `{'id': '${id}', 'databaseURL': '${ctx.makeUrl(db || "", "public")}'}`
|
|
166051
|
+
value: `{'id': '${id}', 'databaseURL': '${ctx.makeUrl(db || "", "public", ctx.navigation.current || void 0)}'}`
|
|
166052
166052
|
},
|
|
166053
166053
|
...codes,
|
|
166054
166054
|
{
|
|
@@ -167229,7 +167229,7 @@ var rehypeHtmlStructure_default = (ctx) => () => {
|
|
|
167229
167229
|
properties: {
|
|
167230
167230
|
rel: "icon",
|
|
167231
167231
|
type: "image/x-icon",
|
|
167232
|
-
href: makeUrl(["favicon.ico"], "public")
|
|
167232
|
+
href: makeUrl(["/favicon.ico"], "public")
|
|
167233
167233
|
},
|
|
167234
167234
|
children: []
|
|
167235
167235
|
},
|
|
@@ -168694,7 +168694,11 @@ var remarkImage_default = (ctx) => () => {
|
|
|
168694
168694
|
tagName: "img",
|
|
168695
168695
|
properties: {
|
|
168696
168696
|
...figureProps,
|
|
168697
|
-
src:
|
|
168697
|
+
src: ctx.makeUrl(
|
|
168698
|
+
node3.url,
|
|
168699
|
+
"public",
|
|
168700
|
+
ctx.navigation.current || void 0
|
|
168701
|
+
),
|
|
168698
168702
|
alt: node3.alt,
|
|
168699
168703
|
onclick: `hyperbook.toggleLightbox(this)`
|
|
168700
168704
|
},
|
|
@@ -183317,6 +183321,44 @@ var remarkDirectiveLearningmap_default = (ctx) => () => {
|
|
|
183317
183321
|
};
|
|
183318
183322
|
};
|
|
183319
183323
|
|
|
183324
|
+
// src/remarkDirectiveTextinput.ts
|
|
183325
|
+
var remarkDirectiveTextinput_default = (ctx) => () => {
|
|
183326
|
+
const name = "textinput";
|
|
183327
|
+
return (tree, file) => {
|
|
183328
|
+
visit(tree, function(node3) {
|
|
183329
|
+
if (isDirective(node3)) {
|
|
183330
|
+
if (node3.name !== name) return;
|
|
183331
|
+
const data = node3.data || (node3.data = {});
|
|
183332
|
+
expectLeafDirective(node3, file, name);
|
|
183333
|
+
registerDirective(file, name, ["client.js"], ["style.css"], []);
|
|
183334
|
+
const {
|
|
183335
|
+
placeholder = "",
|
|
183336
|
+
height = "200px",
|
|
183337
|
+
id = hash(node3)
|
|
183338
|
+
} = node3.attributes || {};
|
|
183339
|
+
data.hName = "div";
|
|
183340
|
+
data.hProperties = {
|
|
183341
|
+
class: "directive-textinput",
|
|
183342
|
+
"data-id": id
|
|
183343
|
+
};
|
|
183344
|
+
data.hChildren = [
|
|
183345
|
+
{
|
|
183346
|
+
type: "element",
|
|
183347
|
+
tagName: "textarea",
|
|
183348
|
+
properties: {
|
|
183349
|
+
class: "textinput",
|
|
183350
|
+
"data-id": id,
|
|
183351
|
+
placeholder,
|
|
183352
|
+
style: `height: ${height}`
|
|
183353
|
+
},
|
|
183354
|
+
children: []
|
|
183355
|
+
}
|
|
183356
|
+
];
|
|
183357
|
+
}
|
|
183358
|
+
});
|
|
183359
|
+
};
|
|
183360
|
+
};
|
|
183361
|
+
|
|
183320
183362
|
// src/process.ts
|
|
183321
183363
|
var remark = (ctx) => {
|
|
183322
183364
|
i18n.init(ctx.config.language || "en");
|
|
@@ -183360,6 +183402,7 @@ var remark = (ctx) => {
|
|
|
183360
183402
|
remarkDirectiveJSXGraph_default(ctx),
|
|
183361
183403
|
remarkDirectiveMultievent_default(ctx),
|
|
183362
183404
|
remarkDirectiveLearningmap_default(ctx),
|
|
183405
|
+
remarkDirectiveTextinput_default(ctx),
|
|
183363
183406
|
remarkCode_default(ctx),
|
|
183364
183407
|
remarkMath,
|
|
183365
183408
|
/* needs to be last directive */
|
|
@@ -183441,7 +183484,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"application/1d-interleaved-parityfec
|
|
|
183441
183484
|
/***/ ((module) => {
|
|
183442
183485
|
|
|
183443
183486
|
"use strict";
|
|
183444
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"hyperbook","version":"0.
|
|
183487
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"hyperbook","version":"0.64.0","author":"Mike Barkmin","homepage":"https://github.com/openpatch/hyperbook#readme","license":"MIT","bin":{"hyperbook":"./dist/index.js"},"files":["dist"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/openpatch/hyperbook.git","directory":"packages/hyperbook"},"bugs":{"url":"https://github.com/openpatch/hyperbook/issues"},"engines":{"node":">=12.22.0"},"scripts":{"version":"pnpm build","lint":"tsc --noEmit","dev":"ncc build ./index.ts -w -o dist/","build":"rimraf dist && ncc build ./index.ts -o ./dist/ --no-cache --no-source-map-register --external favicons --external sharp && node postbuild.mjs"},"dependencies":{"favicons":"^7.2.0"},"devDependencies":{"@hyperbook/fs":"workspace:*","@hyperbook/markdown":"workspace:*","@hyperbook/types":"workspace:*","@pnpm/exportable-manifest":"1000.0.6","@types/archiver":"6.0.3","@types/async-retry":"1.4.9","@types/cross-spawn":"6.0.6","@types/lunr":"^2.3.7","@types/prompts":"2.4.9","@types/tar":"6.1.13","@types/ws":"^8.5.14","@vercel/ncc":"0.38.3","archiver":"7.0.1","async-retry":"1.3.3","chalk":"5.4.1","chokidar":"4.0.3","commander":"12.1.0","cpy":"11.1.0","cross-spawn":"7.0.6","domutils":"^3.2.2","extract-zip":"^2.0.1","got":"12.6.0","htmlparser2":"^10.0.0","lunr":"^2.3.9","lunr-languages":"^1.14.0","mime":"^4.0.6","prompts":"2.4.2","rimraf":"6.0.1","tar":"7.4.3","update-check":"1.5.4","ws":"^8.18.0"}}');
|
|
183445
183488
|
|
|
183446
183489
|
/***/ })
|
|
183447
183490
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyperbook",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.64.0",
|
|
4
4
|
"author": "Mike Barkmin",
|
|
5
5
|
"homepage": "https://github.com/openpatch/hyperbook#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"tar": "7.4.3",
|
|
57
57
|
"update-check": "1.5.4",
|
|
58
58
|
"ws": "^8.18.0",
|
|
59
|
-
"@hyperbook/
|
|
60
|
-
"@hyperbook/
|
|
61
|
-
"@hyperbook/
|
|
59
|
+
"@hyperbook/fs": "0.20.0",
|
|
60
|
+
"@hyperbook/markdown": "0.38.0",
|
|
61
|
+
"@hyperbook/types": "0.18.0"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"version": "pnpm build",
|