@hyperbook/markdown 0.17.1 → 0.19.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.
- package/dist/assets/directive-abc-music/abcjs-basic-min.js +3 -0
- package/dist/assets/directive-abc-music/client.js +46 -0
- package/dist/assets/directive-abc-music/style.css +193 -0
- package/dist/index.js +76 -8
- package/dist/index.js.map +4 -4
- package/dist/remarkDirectiveAbcMusic.d.ts +5 -0
- package/package.json +4 -3
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
hyperbook.abc = (function () {
|
|
2
|
+
const els = document.querySelectorAll(".directive-abc-music");
|
|
3
|
+
|
|
4
|
+
for (let el of els) {
|
|
5
|
+
const tuneEl = el.getElementsByClassName("tune")[0];
|
|
6
|
+
const playerEl = el.getElementsByClassName("player")[0];
|
|
7
|
+
|
|
8
|
+
const tune = atob(el.getAttribute("data-tune"));
|
|
9
|
+
const editor = el.getAttribute("data-editor");
|
|
10
|
+
|
|
11
|
+
if (editor == "true") {
|
|
12
|
+
const editorEl = el.getElementsByClassName("editor")[0];
|
|
13
|
+
editorEl.value = tune;
|
|
14
|
+
let editor = new ABCJS.Editor(editorEl.id, {
|
|
15
|
+
canvas_id: tuneEl,
|
|
16
|
+
synth: {
|
|
17
|
+
el: playerEl,
|
|
18
|
+
options: {
|
|
19
|
+
displayRestart: true,
|
|
20
|
+
displayPlay: true,
|
|
21
|
+
displayProgress: true,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
abcjsParams: {
|
|
25
|
+
responsive: "resize",
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
const visualObj = ABCJS.renderAbc(tuneEl, tune, {
|
|
30
|
+
responsive: "resize",
|
|
31
|
+
})[0];
|
|
32
|
+
if (ABCJS.synth.supportsAudio()) {
|
|
33
|
+
var synthControl = new ABCJS.synth.SynthController();
|
|
34
|
+
synthControl.load(playerEl, null, {
|
|
35
|
+
displayRestart: true,
|
|
36
|
+
displayPlay: true,
|
|
37
|
+
displayProgress: true,
|
|
38
|
+
});
|
|
39
|
+
synthControl.setTune(visualObj, false);
|
|
40
|
+
} else {
|
|
41
|
+
playerEl.innerHTML =
|
|
42
|
+
"<div class='audio-error'>Audio is not supported in this browser.</div>";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
})();
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
.directive-abc-music .editor {
|
|
2
|
+
width: 100%;
|
|
3
|
+
margin-bottom: 8px;
|
|
4
|
+
font-family: hyperbook-code, monospace;
|
|
5
|
+
height: 150px;
|
|
6
|
+
line-height: 1.2;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.abcjs-inline-audio {
|
|
10
|
+
height: 26px;
|
|
11
|
+
padding: 0 5px;
|
|
12
|
+
border-radius: 3px;
|
|
13
|
+
background-color: #424242;
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.abcjs-inline-audio.abcjs-disabled {
|
|
20
|
+
opacity: 0.5;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.abcjs-inline-audio .abcjs-btn {
|
|
24
|
+
display: block;
|
|
25
|
+
width: 28px;
|
|
26
|
+
height: 34px;
|
|
27
|
+
margin-right: 2px;
|
|
28
|
+
padding: 7px 4px;
|
|
29
|
+
|
|
30
|
+
background: none !important;
|
|
31
|
+
border: 1px solid transparent;
|
|
32
|
+
box-sizing: border-box;
|
|
33
|
+
line-height: 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.abcjs-btn g {
|
|
37
|
+
fill: #f4f4f4;
|
|
38
|
+
stroke: #f4f4f4;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.abcjs-inline-audio .abcjs-btn:hover g {
|
|
42
|
+
fill: #cccccc;
|
|
43
|
+
stroke: #cccccc;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.abcjs-inline-audio .abcjs-midi-selection.abcjs-pushed {
|
|
47
|
+
border: 1px solid #cccccc;
|
|
48
|
+
background-color: #666666;
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.abcjs-inline-audio .abcjs-midi-loop.abcjs-pushed {
|
|
53
|
+
border: 1px solid #cccccc;
|
|
54
|
+
background-color: #666666;
|
|
55
|
+
box-sizing: border-box;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.abcjs-inline-audio .abcjs-midi-reset.abcjs-pushed {
|
|
59
|
+
border: 1px solid #cccccc;
|
|
60
|
+
background-color: #666666;
|
|
61
|
+
box-sizing: border-box;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.abcjs-inline-audio .abcjs-midi-start .abcjs-pause-svg {
|
|
65
|
+
display: none;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.abcjs-inline-audio .abcjs-midi-start .abcjs-loading-svg {
|
|
69
|
+
display: none;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.abcjs-inline-audio .abcjs-midi-start.abcjs-pushed .abcjs-play-svg {
|
|
73
|
+
display: none;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.abcjs-inline-audio .abcjs-midi-start.abcjs-loading .abcjs-play-svg {
|
|
77
|
+
display: none;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.abcjs-inline-audio .abcjs-midi-start.abcjs-pushed .abcjs-pause-svg {
|
|
81
|
+
display: block;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.abcjs-inline-audio .abcjs-midi-progress-background {
|
|
85
|
+
background-color: #424242;
|
|
86
|
+
height: 10px;
|
|
87
|
+
border-radius: 5px;
|
|
88
|
+
border: 2px solid #cccccc;
|
|
89
|
+
margin: 0 8px 0 15px;
|
|
90
|
+
position: relative;
|
|
91
|
+
flex: 1;
|
|
92
|
+
padding: 0;
|
|
93
|
+
box-sizing: border-box;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.abcjs-inline-audio .abcjs-midi-progress-indicator {
|
|
97
|
+
width: 20px;
|
|
98
|
+
margin-left: -10px; /* half of the width */
|
|
99
|
+
height: 14px;
|
|
100
|
+
background-color: #f4f4f4;
|
|
101
|
+
position: absolute;
|
|
102
|
+
display: inline-block;
|
|
103
|
+
border-radius: 6px;
|
|
104
|
+
top: -4px;
|
|
105
|
+
left: 0;
|
|
106
|
+
box-sizing: border-box;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.abcjs-inline-audio .abcjs-midi-clock {
|
|
110
|
+
margin-left: 4px;
|
|
111
|
+
margin-top: 1px;
|
|
112
|
+
margin-right: 2px;
|
|
113
|
+
display: inline-block;
|
|
114
|
+
font-family: sans-serif;
|
|
115
|
+
font-size: 16px;
|
|
116
|
+
box-sizing: border-box;
|
|
117
|
+
color: #f4f4f4;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.abcjs-inline-audio .abcjs-tempo-wrapper {
|
|
121
|
+
font-size: 10px;
|
|
122
|
+
color: #f4f4f4;
|
|
123
|
+
box-sizing: border-box;
|
|
124
|
+
display: flex;
|
|
125
|
+
align-items: center;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.abcjs-inline-audio .abcjs-midi-tempo {
|
|
129
|
+
border-radius: 2px;
|
|
130
|
+
border: none;
|
|
131
|
+
margin: 0 2px 0 4px;
|
|
132
|
+
width: 42px;
|
|
133
|
+
padding-left: 2px;
|
|
134
|
+
box-sizing: border-box;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.abcjs-inline-audio .abcjs-loading .abcjs-loading-svg {
|
|
138
|
+
display: inherit;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.abcjs-inline-audio .abcjs-loading {
|
|
142
|
+
outline: none;
|
|
143
|
+
animation-name: abcjs-spin;
|
|
144
|
+
animation-duration: 1s;
|
|
145
|
+
animation-iteration-count: infinite;
|
|
146
|
+
animation-timing-function: linear;
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
.abcjs-inline-audio .abcjs-loading-svg circle {
|
|
150
|
+
stroke: #f4f4f4;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@keyframes abcjs-spin {
|
|
154
|
+
from {transform:rotate(0deg);}
|
|
155
|
+
to {transform:rotate(360deg);}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* Adding the class "abcjs-large" will make the control easier on a touch device. */
|
|
159
|
+
.abcjs-large .abcjs-inline-audio {
|
|
160
|
+
height: 52px;
|
|
161
|
+
}
|
|
162
|
+
.abcjs-large .abcjs-btn {
|
|
163
|
+
width: 56px;
|
|
164
|
+
height: 52px;
|
|
165
|
+
font-size: 28px;
|
|
166
|
+
padding: 6px 8px;
|
|
167
|
+
}
|
|
168
|
+
.abcjs-large .abcjs-midi-progress-background {
|
|
169
|
+
height: 20px;
|
|
170
|
+
border: 4px solid #cccccc;
|
|
171
|
+
}
|
|
172
|
+
.abcjs-large .abcjs-midi-progress-indicator {
|
|
173
|
+
height: 28px;
|
|
174
|
+
top: -8px;
|
|
175
|
+
width: 40px;
|
|
176
|
+
}
|
|
177
|
+
.abcjs-large .abcjs-midi-clock {
|
|
178
|
+
font-size: 32px;
|
|
179
|
+
margin-right: 10px;
|
|
180
|
+
margin-left: 10px;
|
|
181
|
+
margin-top: -1px;
|
|
182
|
+
}
|
|
183
|
+
.abcjs-large .abcjs-midi-tempo {
|
|
184
|
+
font-size: 20px;
|
|
185
|
+
width: 50px;
|
|
186
|
+
}
|
|
187
|
+
.abcjs-large .abcjs-tempo-wrapper {
|
|
188
|
+
font-size: 20px;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.abcjs-css-warning {
|
|
192
|
+
display: none;
|
|
193
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -63162,7 +63162,15 @@ var remarkDirectiveTabs_default = (ctx) => () => {
|
|
|
63162
63162
|
let first = true;
|
|
63163
63163
|
node3.children.filter(isDirective).forEach((node4) => {
|
|
63164
63164
|
expectContainerDirective(node4, file, "tab");
|
|
63165
|
-
let { title, id: tabId = hash(node4) } = node4.attributes || {};
|
|
63165
|
+
let { title = "", id: tabId = hash(node4) } = node4.attributes || {};
|
|
63166
|
+
let tree2 = remark(ctx).parse(title);
|
|
63167
|
+
remarkGemoji()(tree2);
|
|
63168
|
+
let hastTree = toHast(tree2);
|
|
63169
|
+
if (hastTree.type === "root" && hastTree.children[0]?.type === "element" && hastTree.children[0]?.tagName === "p") {
|
|
63170
|
+
hastTree = hastTree.children[0];
|
|
63171
|
+
hastTree.tagName = "span";
|
|
63172
|
+
}
|
|
63173
|
+
console.log(JSON.stringify(hastTree, null, 2));
|
|
63166
63174
|
tabTitleElements.push({
|
|
63167
63175
|
type: "element",
|
|
63168
63176
|
tagName: "button",
|
|
@@ -63171,12 +63179,7 @@ var remarkDirectiveTabs_default = (ctx) => () => {
|
|
|
63171
63179
|
"data-tabs-id": tabsId,
|
|
63172
63180
|
class: "tab" + (first ? " active" : "")
|
|
63173
63181
|
},
|
|
63174
|
-
children: [
|
|
63175
|
-
{
|
|
63176
|
-
type: "text",
|
|
63177
|
-
value: title || ""
|
|
63178
|
-
}
|
|
63179
|
-
]
|
|
63182
|
+
children: hastTree.children || []
|
|
63180
63183
|
});
|
|
63181
63184
|
tabContentElements.push({
|
|
63182
63185
|
type: "element",
|
|
@@ -72460,10 +72463,75 @@ var remarkDirectiveGeogebra_default = (ctx) => () => {
|
|
|
72460
72463
|
};
|
|
72461
72464
|
};
|
|
72462
72465
|
|
|
72466
|
+
// src/remarkDirectiveAbcMusic.ts
|
|
72467
|
+
var remarkDirectiveAbcMusic_default = (ctx) => () => {
|
|
72468
|
+
const name = "abc-music";
|
|
72469
|
+
return (tree, file) => {
|
|
72470
|
+
visit(tree, function(node3) {
|
|
72471
|
+
if (node3.type === "code" && node3.lang === "abcjs") {
|
|
72472
|
+
const data = node3.data || (node3.data = {});
|
|
72473
|
+
node3.type = "directive";
|
|
72474
|
+
node3.lang = "";
|
|
72475
|
+
expectContainerDirective(node3, file, name);
|
|
72476
|
+
registerDirective(
|
|
72477
|
+
file,
|
|
72478
|
+
name,
|
|
72479
|
+
["abcjs-basic-min.js", "client.js"],
|
|
72480
|
+
["style.css"]
|
|
72481
|
+
);
|
|
72482
|
+
console.log(node3);
|
|
72483
|
+
const value = node3.value || toString2(node3.children);
|
|
72484
|
+
const editor = node3.meta?.includes("editor");
|
|
72485
|
+
console.log(editor);
|
|
72486
|
+
data.hName = "div";
|
|
72487
|
+
data.hProperties = {
|
|
72488
|
+
class: "directive-abc-music",
|
|
72489
|
+
"data-tune": Buffer.from(value).toString("base64"),
|
|
72490
|
+
"data-editor": editor ? "true" : "false"
|
|
72491
|
+
};
|
|
72492
|
+
data.hChildren = [
|
|
72493
|
+
{
|
|
72494
|
+
type: "element",
|
|
72495
|
+
tagName: "div",
|
|
72496
|
+
properties: {
|
|
72497
|
+
class: "tune"
|
|
72498
|
+
},
|
|
72499
|
+
children: [
|
|
72500
|
+
{
|
|
72501
|
+
type: "text",
|
|
72502
|
+
value
|
|
72503
|
+
}
|
|
72504
|
+
]
|
|
72505
|
+
},
|
|
72506
|
+
...editor ? [
|
|
72507
|
+
{
|
|
72508
|
+
type: "element",
|
|
72509
|
+
tagName: "textarea",
|
|
72510
|
+
properties: {
|
|
72511
|
+
class: "editor",
|
|
72512
|
+
id: hash(node3),
|
|
72513
|
+
spellcheck: "false"
|
|
72514
|
+
}
|
|
72515
|
+
}
|
|
72516
|
+
] : [],
|
|
72517
|
+
{
|
|
72518
|
+
type: "element",
|
|
72519
|
+
tagName: "div",
|
|
72520
|
+
properties: {
|
|
72521
|
+
class: "player"
|
|
72522
|
+
}
|
|
72523
|
+
}
|
|
72524
|
+
];
|
|
72525
|
+
}
|
|
72526
|
+
});
|
|
72527
|
+
};
|
|
72528
|
+
};
|
|
72529
|
+
|
|
72463
72530
|
// src/process.ts
|
|
72464
72531
|
var remark = (ctx) => {
|
|
72465
72532
|
const remarkPlugins = [
|
|
72466
72533
|
remarkRemoveComments,
|
|
72534
|
+
remarkGemoji,
|
|
72467
72535
|
remarkDirective,
|
|
72468
72536
|
dist_default,
|
|
72469
72537
|
remarkDirectivePagelist_default(ctx),
|
|
@@ -72490,12 +72558,12 @@ var remark = (ctx) => {
|
|
|
72490
72558
|
remarkDirectiveSlideshow_default(ctx),
|
|
72491
72559
|
remarkDirectiveScratchblock_default(ctx),
|
|
72492
72560
|
remarkDirectiveMermaid_default(ctx),
|
|
72561
|
+
remarkDirectiveAbcMusic_default(ctx),
|
|
72493
72562
|
remarkDirectiveExcalidraw_default(ctx),
|
|
72494
72563
|
remarkDirectiveStruktog_default(ctx),
|
|
72495
72564
|
remarkDirectiveGeogebra_default(ctx),
|
|
72496
72565
|
remarkCode_default(ctx),
|
|
72497
72566
|
remarkMath,
|
|
72498
|
-
remarkGemoji,
|
|
72499
72567
|
remarkUnwrapImages,
|
|
72500
72568
|
/* needs to be last directive */
|
|
72501
72569
|
remarkDirectiveProtect_default(ctx),
|