@hyperbook/markdown 0.37.2 → 0.39.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.
@@ -4,7 +4,7 @@
4
4
  }
5
5
 
6
6
  .directive-alert>p {
7
- margin-bottom: 0;
7
+ margin-bottom: 10px;
8
8
  }
9
9
 
10
10
  .directive-alert {
@@ -34,6 +34,10 @@
34
34
  :first-child {
35
35
  margin-top: 0;
36
36
  }
37
+
38
+ :first-child.p {
39
+ margin-top: 10px;
40
+ }
37
41
  }
38
42
 
39
43
  .directive-alert.icon::before {
@@ -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
+ }
@@ -27,6 +27,7 @@ store.version(1).stores({
27
27
  h5p: `id,userData`,
28
28
  geogebra: `id,state`,
29
29
  learningmap: `id,nodes,x,y,zoom`,
30
+ textinput: `id,text`,
30
31
  });
31
32
  var sqlIdeDB = new Dexie("SQL-IDE");
32
33
  sqlIdeDB.version(0.1).stores({
package/dist/index.js CHANGED
@@ -70556,6 +70556,12 @@ var remarkLink_default = (ctx) => () => {
70556
70556
  visit(tree, (node3, index2) => {
70557
70557
  if (typeof index2 === "number" && (node3.type === "link" || node3.type === "linkReference" || node3.type === "image" || node3.type === "imageReference" || node3.type === "definition")) {
70558
70558
  if (node3.url) {
70559
+ if (node3.type === "link" && /^https?:\/\//.test(node3.url)) {
70560
+ if (!node3.data) node3.data = {};
70561
+ if (!node3.data.hProperties) node3.data.hProperties = {};
70562
+ node3.data.hProperties.target = "_blank";
70563
+ node3.data.hProperties.rel = "noopener noreferrer";
70564
+ }
70559
70565
  node3.url = ctx.makeUrl(
70560
70566
  node3.url,
70561
70567
  "public",
@@ -78652,6 +78658,44 @@ var remarkDirectiveLearningmap_default = (ctx) => () => {
78652
78658
  };
78653
78659
  };
78654
78660
 
78661
+ // src/remarkDirectiveTextinput.ts
78662
+ var remarkDirectiveTextinput_default = (ctx) => () => {
78663
+ const name = "textinput";
78664
+ return (tree, file) => {
78665
+ visit(tree, function(node3) {
78666
+ if (isDirective(node3)) {
78667
+ if (node3.name !== name) return;
78668
+ const data = node3.data || (node3.data = {});
78669
+ expectLeafDirective(node3, file, name);
78670
+ registerDirective(file, name, ["client.js"], ["style.css"], []);
78671
+ const {
78672
+ placeholder = "",
78673
+ height = "200px",
78674
+ id = hash(node3)
78675
+ } = node3.attributes || {};
78676
+ data.hName = "div";
78677
+ data.hProperties = {
78678
+ class: "directive-textinput",
78679
+ "data-id": id
78680
+ };
78681
+ data.hChildren = [
78682
+ {
78683
+ type: "element",
78684
+ tagName: "textarea",
78685
+ properties: {
78686
+ class: "textinput",
78687
+ "data-id": id,
78688
+ placeholder,
78689
+ style: `height: ${height}`
78690
+ },
78691
+ children: []
78692
+ }
78693
+ ];
78694
+ }
78695
+ });
78696
+ };
78697
+ };
78698
+
78655
78699
  // src/process.ts
78656
78700
  var remark = (ctx) => {
78657
78701
  i18n.init(ctx.config.language || "en");
@@ -78695,6 +78739,7 @@ var remark = (ctx) => {
78695
78739
  remarkDirectiveJSXGraph_default(ctx),
78696
78740
  remarkDirectiveMultievent_default(ctx),
78697
78741
  remarkDirectiveLearningmap_default(ctx),
78742
+ remarkDirectiveTextinput_default(ctx),
78698
78743
  remarkCode_default(ctx),
78699
78744
  remarkMath,
78700
78745
  /* needs to be last directive */