markdown-up 3.3.0 → 3.3.2
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/lib/app.js +5 -1
- package/lib/lineChart.js +3 -3
- package/lib/script.js +8 -0
- package/lib/scriptLibrary.js +20 -16
- package/package.json +2 -2
package/lib/app.js
CHANGED
|
@@ -75,6 +75,9 @@ enum MarkdownUpView
|
|
|
75
75
|
* The MarkdownUp application options
|
|
76
76
|
*
|
|
77
77
|
* @typedef {Object} MarkdownUpOptions
|
|
78
|
+
* @property {?Object.<string, function>} [codeBlocks = null] - The
|
|
79
|
+
* [code block]{@link https://craigahobbs.github.io/markdown-model/module-lib_elements.html#~CodeBlockFn}
|
|
80
|
+
* render function map
|
|
78
81
|
* @property {?boolean} [darkMode = false] - If true, use dark mode by default
|
|
79
82
|
* @property {?number} [fontSize = 12] - The font size, in points
|
|
80
83
|
* @property {?Object} [globals = null] - Global script runtime variables
|
|
@@ -101,6 +104,7 @@ export class MarkdownUp {
|
|
|
101
104
|
this.params = null;
|
|
102
105
|
this.paramsLocal = null;
|
|
103
106
|
this.paramsSession = null;
|
|
107
|
+
this.codeBlocks = (options !== null ? options.codeBlocks : null) ?? null;
|
|
104
108
|
this.darkMode = (options !== null ? options.darkMode : null) ??
|
|
105
109
|
(this.window.matchMedia && this.window.matchMedia('(prefers-color-scheme: dark)').matches);
|
|
106
110
|
this.fontSize = (options !== null ? options.fontSize : null) ?? 12;
|
|
@@ -403,7 +407,7 @@ export class MarkdownUp {
|
|
|
403
407
|
// Create the markdown options object
|
|
404
408
|
const urlFn = (url) => this.modifyURL(url);
|
|
405
409
|
const markdownOptions = {
|
|
406
|
-
'codeBlocks': {},
|
|
410
|
+
'codeBlocks': this.codeBlocks ?? {},
|
|
407
411
|
urlFn,
|
|
408
412
|
'headerIds': true,
|
|
409
413
|
'usedHeaderIds': new Set()
|
package/lib/lineChart.js
CHANGED
|
@@ -61,10 +61,10 @@ struct LineChartAxisTicks
|
|
|
61
61
|
optional int(>= 0) count
|
|
62
62
|
|
|
63
63
|
# The value of the first tick mark. Default is the minimum axis value.
|
|
64
|
-
optional
|
|
64
|
+
optional any start
|
|
65
65
|
|
|
66
66
|
# The value of the last tick mark. Default is the maximum axis value.
|
|
67
|
-
optional
|
|
67
|
+
optional any end
|
|
68
68
|
|
|
69
69
|
# The number of tick mark labels to skip after a rendered label
|
|
70
70
|
optional int(> 0) skip
|
|
@@ -74,7 +74,7 @@ struct LineChartAxisTicks
|
|
|
74
74
|
struct LineChartAxisAnnotation
|
|
75
75
|
|
|
76
76
|
# The axis value
|
|
77
|
-
|
|
77
|
+
any value
|
|
78
78
|
|
|
79
79
|
# The annotation label
|
|
80
80
|
optional string label
|
package/lib/script.js
CHANGED
|
@@ -134,6 +134,7 @@ export class MarkdownScriptRuntime {
|
|
|
134
134
|
this.windowLocation = null;
|
|
135
135
|
this.windowResize = null;
|
|
136
136
|
this.windowTimeout = null;
|
|
137
|
+
this.eventQueue = Promise.resolve();
|
|
137
138
|
|
|
138
139
|
// Drawing-path and Markdown function state
|
|
139
140
|
this.drawingPath = null;
|
|
@@ -170,6 +171,13 @@ export class MarkdownScriptRuntime {
|
|
|
170
171
|
}
|
|
171
172
|
|
|
172
173
|
|
|
174
|
+
// Handle a runtime event
|
|
175
|
+
eventHandle(callback) {
|
|
176
|
+
this.eventQueue = this.eventQueue.then(callback);
|
|
177
|
+
return this.eventQueue;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
173
181
|
// Reset the runtime elements
|
|
174
182
|
resetElements() {
|
|
175
183
|
let elements = null;
|
package/lib/scriptLibrary.js
CHANGED
|
@@ -1021,15 +1021,17 @@ function windowSetResize(args, options) {
|
|
|
1021
1021
|
const [callback] = valueArgsValidate(windowSetResizeArgs, args);
|
|
1022
1022
|
const {runtime} = options;
|
|
1023
1023
|
runtime.windowResize = async () => {
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
options.
|
|
1024
|
+
await runtime.eventHandle(async () => {
|
|
1025
|
+
options.statementCount = 0;
|
|
1026
|
+
try {
|
|
1027
|
+
await callback([], options);
|
|
1028
|
+
} catch ({message}) {
|
|
1029
|
+
if (options.debug) {
|
|
1030
|
+
options.logFn(`MarkdownUp: Error executing windowSetResize callback: ${message}`);
|
|
1031
|
+
}
|
|
1030
1032
|
}
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
+
options.runtimeUpdateFn();
|
|
1034
|
+
});
|
|
1033
1035
|
};
|
|
1034
1036
|
}
|
|
1035
1037
|
|
|
@@ -1048,15 +1050,17 @@ function windowSetTimeout(args, options) {
|
|
|
1048
1050
|
const {runtime} = options;
|
|
1049
1051
|
runtime.windowTimeout = [
|
|
1050
1052
|
async () => {
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
options.
|
|
1053
|
+
await runtime.eventHandle(async () => {
|
|
1054
|
+
options.statementCount = 0;
|
|
1055
|
+
try {
|
|
1056
|
+
await callback([], options);
|
|
1057
|
+
} catch ({message}) {
|
|
1058
|
+
if (options.debug) {
|
|
1059
|
+
options.logFn(`MarkdownUp: Error executing windowSetTimeout callback: ${message}`);
|
|
1060
|
+
}
|
|
1057
1061
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1062
|
+
options.runtimeUpdateFn();
|
|
1063
|
+
});
|
|
1060
1064
|
},
|
|
1061
1065
|
delay
|
|
1062
1066
|
];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "markdown-up",
|
|
4
|
-
"version": "3.3.
|
|
4
|
+
"version": "3.3.2",
|
|
5
5
|
"description": "MarkdownUp is a Markdown viewer",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"markdown",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"c8": "~10.1",
|
|
33
|
-
"eslint": "~9.
|
|
33
|
+
"eslint": "~9.15",
|
|
34
34
|
"jsdoc": "~4.0",
|
|
35
35
|
"jsdom": "~25.0"
|
|
36
36
|
}
|