markdown-up 1.8.10 → 1.8.11
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/README.md +4 -7
- package/lib/script.js +3 -2
- package/lib/scriptLibrary.js +27 -25
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -81,9 +81,6 @@ helloCount = if(vCount != null, vCount, 3)
|
|
|
81
81
|
width = 200
|
|
82
82
|
height = 60
|
|
83
83
|
borderSize = 5
|
|
84
|
-
borderColor = 'red'
|
|
85
|
-
fillColor = 'blue'
|
|
86
|
-
textColor = 'white'
|
|
87
84
|
|
|
88
85
|
# Render the more/less menu
|
|
89
86
|
markdownPrint( \
|
|
@@ -94,20 +91,20 @@ markdownPrint( \
|
|
|
94
91
|
|
|
95
92
|
# Render many hellos
|
|
96
93
|
ixHello = 0
|
|
97
|
-
|
|
94
|
+
while ixHello < helloCount do
|
|
98
95
|
# Render the hello title
|
|
99
96
|
helloTitle = 'Hello #' + (ixHello + 1)
|
|
100
97
|
markdownPrint('', '## ' + helloTitle)
|
|
101
98
|
|
|
102
99
|
# Render the hello drawing
|
|
103
100
|
setDrawingSize(width, height)
|
|
104
|
-
drawStyle(
|
|
101
|
+
drawStyle('red', borderSize, 'blue')
|
|
105
102
|
drawRect(0.5 * borderSize, 0.5 * borderSize, width - borderSize, height - borderSize)
|
|
106
|
-
drawTextStyle(0.67 * height,
|
|
103
|
+
drawTextStyle(0.67 * height, 'white', true)
|
|
107
104
|
drawText(helloTitle, 0.5 * width, 0.55 * height)
|
|
108
105
|
|
|
109
106
|
ixHello = ixHello + 1
|
|
110
|
-
|
|
107
|
+
endwhile
|
|
111
108
|
~~~
|
|
112
109
|
```
|
|
113
110
|
|
package/lib/script.js
CHANGED
|
@@ -65,10 +65,11 @@ export async function markdownScriptCodeBlock(codeBlock, options) {
|
|
|
65
65
|
// Run the calc-script linter?
|
|
66
66
|
if ('logFn' in options) {
|
|
67
67
|
const warnings = lintScript(script);
|
|
68
|
+
const warningPrefix = `MarkdownUp: Script static analysis...`;
|
|
68
69
|
if (warnings.length === 0) {
|
|
69
|
-
options.logFn(
|
|
70
|
+
options.logFn(`${warningPrefix} OK`);
|
|
70
71
|
} else {
|
|
71
|
-
options.logFn(
|
|
72
|
+
options.logFn(`${warningPrefix} ${warnings.length} warning${warnings.length > 1 ? 's' : ''}:`);
|
|
72
73
|
for (const warning of warnings) {
|
|
73
74
|
options.logFn(`MarkdownUp: ${warning}`);
|
|
74
75
|
}
|
package/lib/scriptLibrary.js
CHANGED
|
@@ -760,8 +760,7 @@ function elementModelWrapCallbacks(elements, options) {
|
|
|
760
760
|
}
|
|
761
761
|
|
|
762
762
|
// Element callback attribute must be map of event => callback
|
|
763
|
-
|
|
764
|
-
if (elementEvents !== null && typeof elementEvents === 'object') {
|
|
763
|
+
if ('callback' in elements) {
|
|
765
764
|
// Get the callback data, if any
|
|
766
765
|
let callbackData = null;
|
|
767
766
|
if ('callbackData' in elements) {
|
|
@@ -770,29 +769,32 @@ function elementModelWrapCallbacks(elements, options) {
|
|
|
770
769
|
}
|
|
771
770
|
|
|
772
771
|
// Wrap the event handler function
|
|
773
|
-
elements.callback
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
element
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
eventArgs
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
// Call the event handler
|
|
785
|
-
options.statementCount = 0;
|
|
786
|
-
try {
|
|
787
|
-
await elementEventCallback(eventArgs, options);
|
|
788
|
-
} catch ({message}) {
|
|
789
|
-
if ('logFn' in options) {
|
|
790
|
-
options.logFn(`MarkdownUp: Error executing elementModelRender callback: ${message}`);
|
|
772
|
+
const elementEvents = elements.callback;
|
|
773
|
+
if (elementEvents !== null) {
|
|
774
|
+
elements.callback = (element) => {
|
|
775
|
+
// On element render, add a listener for each event
|
|
776
|
+
for (const [elementEvent, elementEventCallback] of Object.entries(elementEvents)) {
|
|
777
|
+
element.addEventListener(elementEvent, async (event) => {
|
|
778
|
+
// Determine the event callback args
|
|
779
|
+
const eventArgs = [];
|
|
780
|
+
if (elementEvent === 'keydown' || elementEvent === 'keypress' || elementEvent === 'keyup') {
|
|
781
|
+
eventArgs.push(event.keyCode);
|
|
791
782
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
783
|
+
eventArgs.push(callbackData);
|
|
784
|
+
|
|
785
|
+
// Call the event handler
|
|
786
|
+
options.statementCount = 0;
|
|
787
|
+
try {
|
|
788
|
+
await elementEventCallback(eventArgs, options);
|
|
789
|
+
} catch ({message}) {
|
|
790
|
+
if ('logFn' in options) {
|
|
791
|
+
options.logFn(`MarkdownUp: Error executing elementModelRender callback: ${message}`);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
options.runtimeUpdateFn();
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
}
|
|
797
799
|
}
|
|
798
800
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "markdown-up",
|
|
4
|
-
"version": "1.8.
|
|
4
|
+
"version": "1.8.11",
|
|
5
5
|
"description": "MarkdownUp is a Markdown viewer",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"markdown",
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
"test": "ava -v test/"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"calc-script": "~1.
|
|
25
|
+
"calc-script": "~1.4",
|
|
26
26
|
"element-model": "~1.1",
|
|
27
27
|
"markdown-model": "~1.7",
|
|
28
28
|
"schema-markdown": "~1.2",
|
|
29
29
|
"schema-markdown-doc": "~1.5"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"ava": "~5.
|
|
33
|
-
"c8": "~7.
|
|
34
|
-
"eslint": "~8.
|
|
32
|
+
"ava": "~5.2",
|
|
33
|
+
"c8": "~7.13",
|
|
34
|
+
"eslint": "~8.35",
|
|
35
35
|
"jsdoc": "~4.0",
|
|
36
36
|
"jsdom": "~21.1"
|
|
37
37
|
}
|