markdown-up 3.12.0 → 3.12.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/dataTable.js CHANGED
@@ -79,7 +79,7 @@ enum DataTableDatetimeFormat
79
79
  * Validate a data table model
80
80
  *
81
81
  * @param {Object} dataTable - The
82
- * [data table model]{@link https://craigahobbs.github.io/markdown-up/library/model.html#var.vName='DataTable'}
82
+ * [data table model]{@link https://craigahobbs.github.io/bare-script/library/model.html#var.vName='DataTable'}
83
83
  * @returns {Object}
84
84
  * @throws [ValidationError]{@link https://craigahobbs.github.io/schema-markdown-js/module-lib_schema.ValidationError.html}
85
85
  */
@@ -104,7 +104,7 @@ export function validateDataTable(dataTable) {
104
104
  *
105
105
  * @param {Object[]} data - The data array
106
106
  * @param {?Object} [dataTable = null] - The
107
- * [data table model]{@link https://craigahobbs.github.io/markdown-up/library/model.html#var.vName='DataTable'}
107
+ * [data table model]{@link https://craigahobbs.github.io/bare-script/library/model.html#var.vName='DataTable'}
108
108
  * @param {?Object} [options = null] - The [data table options]{@link module:lib/dataTable~DataTableOptions}
109
109
  * @returns {Object} The data table [element model]{@link https://github.com/craigahobbs/element-model#readme}
110
110
  */
package/lib/lineChart.js CHANGED
@@ -101,7 +101,7 @@ enum LineChartDatetimeFormat
101
101
  * Validate a line chart model
102
102
  *
103
103
  * @param {Object} lineChart - The
104
- * [line chart model]{@link https://craigahobbs.github.io/markdown-up/library/model.html#var.vName='LineChart'}
104
+ * [line chart model]{@link https://craigahobbs.github.io/bare-script/library/model.html#var.vName='LineChart'}
105
105
  * @returns {Object}
106
106
  * @throws [ValidationError]{@link https://craigahobbs.github.io/schema-markdown-js/module-lib_schema.ValidationError.html}
107
107
  */
@@ -174,7 +174,7 @@ const chartLineWidth = 3;
174
174
  *
175
175
  * @param {Object[]} data - The data array
176
176
  * @param {Object} lineChart - The
177
- * [line chart model]{@link https://craigahobbs.github.io/markdown-up/library/model.html#var.vName='LineChart'}
177
+ * [line chart model]{@link https://craigahobbs.github.io/bare-script/library/model.html#var.vName='LineChart'}
178
178
  * @param {?Object} [options = null] - The [line chart options]{@link module:lib/lineChart~LineChartOptions}
179
179
  * @returns {Object} The line chart [element model]{@link https://github.com/craigahobbs/element-model#readme}
180
180
  */
@@ -4,11 +4,8 @@
4
4
  import {dataTableElements, validateDataTable} from './dataTable.js';
5
5
  import {escapeMarkdownText, getMarkdownTitle, parseMarkdown} from 'markdown-model/lib/parser.js';
6
6
  import {lineChartElements, validateLineChart} from './lineChart.js';
7
+ import {markdownElements, markdownHeaderId as markdownModelHeaderId} from 'markdown-model/lib/elements.js';
7
8
  import {valueArgsModel, valueArgsValidate} from 'bare-script/lib/value.js';
8
- import {encodeQueryString} from 'schema-markdown/lib/encode.js';
9
- import {markdownHeaderId as markdownModelHeaderId} from 'markdown-model/lib/elements.js';
10
- import {parseSchemaMarkdown} from 'schema-markdown/lib/parser.js';
11
- import {schemaMarkdownDoc} from 'schema-markdown-doc/lib/schemaMarkdownDoc.js';
12
9
  import {validateElements} from 'element-model/lib/elementModel.js';
13
10
 
14
11
 
@@ -141,8 +138,17 @@ const documentSetFocusArgs = valueArgsModel([
141
138
  // $doc:
142
139
  // $doc: myAppMain()
143
140
  // $doc: ```
144
- // $arg callback: The keydown event callback function that takes a single
145
- // $arg callback: [key event object](model.html#var.vName='DocumentKeyEvent') argument, `event`.
141
+ // $arg callback: The keydown event callback function, which takes a single `event` object that has
142
+ // $arg callback: the following attributes:
143
+ // $arg callback: - `key` - The key value (e.g., "a", "Enter", "ArrowUp")
144
+ // $arg callback: - `code` - The physical key code (e.g., "KeyA", "Enter")
145
+ // $arg callback: - `keyCode` - The legacy numeric code (e.g., 65 for 'a')
146
+ // $arg callback: - `ctrlKey` - If true, the control key is pressed
147
+ // $arg callback: - `altKey` - If true, the alt key is pressed
148
+ // $arg callback: - `shiftKey` - If true, the shift key is pressed
149
+ // $arg callback: - `metaKey` - If true, the cmd key is pressed
150
+ // $arg callback: - `repeat` - If true, the key is held down
151
+ // $arg callback: - `location` - 0=standard, 1=left, 2=right
146
152
  function documentSetKeyDown(args, options) {
147
153
  const [callback] = valueArgsValidate(documentSetKeyDownArgs, args);
148
154
  const {runtime} = options;
@@ -180,42 +186,6 @@ const documentSetKeyDownArgs = valueArgsModel([
180
186
  ]);
181
187
 
182
188
 
183
- export const documentKeyEventTypes = parseSchemaMarkdown(`\
184
- group "Events"
185
-
186
-
187
- # A document key event object
188
- struct DocumentKeyEvent
189
-
190
- # The key value (e.g., "a", "Enter", "ArrowUp")
191
- string key
192
-
193
- # The physical key code (e.g., "KeyA", "Enter")
194
- string code
195
-
196
- # The legacy numeric code (e.g., 65 for 'a')
197
- string keyCode
198
-
199
- # If true, the control key is pressed
200
- bool ctrlKey
201
-
202
- # If true, the alt key is pressed
203
- bool altKey
204
-
205
- # If true, the shift key is pressed
206
- bool shiftKey
207
-
208
- # If true, the cmd key is pressed
209
- bool metaKey
210
-
211
- # If true, the key is held down
212
- bool repeat
213
-
214
- # 0=standard, 1=left, 2=right
215
- int location
216
- `);
217
-
218
-
219
189
  // $function: documentSetReset
220
190
  // $group: Document
221
191
  // $doc: Set the document reset element
@@ -883,6 +853,33 @@ const localStorageSetArgs = valueArgsModel([
883
853
  //
884
854
 
885
855
 
856
+ // $function: markdownElements
857
+ // $group: Markdown
858
+ // $doc: Generate an element model from a Markdown model
859
+ // $arg markdownModel: The [Markdown model](https://craigahobbs.github.io/markdown-model/model/#var.vName='Markdown')
860
+ // $arg generic: Optional (default is false). If true, render markdown elements in a generic context.
861
+ // $return: The rendered Markdown [element model](https://github.com/craigahobbs/element-model#readme)
862
+ function markdownElementsFn(args, options) {
863
+ const [markdownModel, generic] = valueArgsValidate(markdownElementsArgs, args);
864
+
865
+ // Create the markdown-model options
866
+ const markdownOptions = {'headerIds': true};
867
+ if (!generic) {
868
+ markdownOptions.urlFn = options.markdownOptions.urlFn;
869
+ markdownOptions.usedHeaderIds = options.markdownOptions.usedHeaderIds;
870
+ if ('copyFn' in options.markdownOptions) {
871
+ markdownOptions.copyFn = options.markdownOptions.copyFn;
872
+ }
873
+ }
874
+ return markdownElements(markdownModel, markdownOptions);
875
+ }
876
+
877
+ const markdownElementsArgs = valueArgsModel([
878
+ {'name': 'markdownModel', 'type': 'object'},
879
+ {'name': 'generic', 'type': 'boolean', 'default': false}
880
+ ]);
881
+
882
+
886
883
  // $function: markdownEscape
887
884
  // $group: Markdown
888
885
  // $doc: Escape text for inclusion in Markdown text
@@ -949,44 +946,6 @@ const markdownTitleArgs = valueArgsModel([
949
946
  ]);
950
947
 
951
948
 
952
- //
953
- // Schema functions
954
- //
955
-
956
-
957
- // $function: schemaElements
958
- // $group: Schema
959
- // $doc: Get a schema type's documentation [element model](https://github.com/craigahobbs/element-model#readme).
960
- // $doc: Render the element model with the [elementModelRender](#var.vName='elementModelRender') function.
961
- // $arg types: The [type model](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='Types')
962
- // $arg typeName: The type name
963
- // $arg actionURLs: Optional (default is null). The
964
- // $arg actionURLs: [action URL overrides](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='ActionURL').
965
- // $arg actionCustom: Optional (default is false). If true, the action has a custom response.
966
- // $return: The schema type's documentation [element model](https://github.com/craigahobbs/element-model#readme)
967
- function schemaElements(args, options) {
968
- const [types, typeName, actionURLs = null, actionCustom] = valueArgsValidate(schemaElementsArgs, args);
969
- const schemaOptions = {
970
- 'params': encodeQueryString(options.params),
971
- 'markdownOptions': options.markdownOptions
972
- };
973
- if (actionURLs !== null) {
974
- schemaOptions.actionURLs = actionURLs;
975
- }
976
- if (actionCustom) {
977
- schemaOptions.actionCustom = true;
978
- }
979
- return schemaMarkdownDoc(types, typeName, schemaOptions);
980
- }
981
-
982
- const schemaElementsArgs = valueArgsModel([
983
- {'name': 'types', 'type': 'object'},
984
- {'name': 'typeName', 'type': 'string'},
985
- {'name': 'actionURLs', 'type': 'array', 'nullable': true},
986
- {'name': 'actionCustom', 'type': 'boolean', 'default': false}
987
- ]);
988
-
989
-
990
949
  //
991
950
  // Session storage functions
992
951
  //
@@ -1085,13 +1044,16 @@ async function windowClipboardRead(args, options) {
1085
1044
  // $group: Window
1086
1045
  // $doc: Write text to the clipboard
1087
1046
  // $arg text: The text to write
1047
+ // $arg type: The clipboard content type (default is "text/plain")
1088
1048
  async function windowClipboardWrite(args, options) {
1089
- const [text] = valueArgsValidate(windowClipboardWriteArgs, args);
1090
- await options.window.navigator.clipboard.writeText(text);
1049
+ const [text, type] = valueArgsValidate(windowClipboardWriteArgs, args);
1050
+ const blob = new Blob([text], {type});
1051
+ await options.window.navigator.clipboard.write([new options.window.ClipboardItem({[type]: blob})]);
1091
1052
  }
1092
1053
 
1093
1054
  const windowClipboardWriteArgs = valueArgsModel([
1094
- {'name': 'text', 'type': 'string'}
1055
+ {'name': 'text', 'type': 'string'},
1056
+ {'name': 'type', 'type': 'string', 'default': 'text/plain'}
1095
1057
  ]);
1096
1058
 
1097
1059
 
@@ -1223,12 +1185,12 @@ export const markdownScriptFunctions = {
1223
1185
  localStorageGet,
1224
1186
  localStorageRemove,
1225
1187
  localStorageSet,
1188
+ 'markdownElements': markdownElementsFn,
1226
1189
  markdownEscape,
1227
1190
  markdownHeaderId,
1228
1191
  markdownParse,
1229
1192
  markdownPrint,
1230
1193
  markdownTitle,
1231
- schemaElements,
1232
1194
  sessionStorageClear,
1233
1195
  sessionStorageGet,
1234
1196
  sessionStorageRemove,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "markdown-up",
4
- "version": "3.12.0",
4
+ "version": "3.12.2",
5
5
  "description": "MarkdownUp is a Markdown viewer",
6
6
  "keywords": [
7
7
  "markdown",
@@ -25,13 +25,12 @@
25
25
  "bare-script": "~3.8",
26
26
  "element-model": "~1.2",
27
27
  "markdown-model": "~2.2",
28
- "schema-markdown": "~1.2",
29
- "schema-markdown-doc": "~2.1"
28
+ "schema-markdown": "~1.2"
30
29
  },
31
30
  "devDependencies": {
32
31
  "c8": "~10.1",
33
- "eslint": "~9.36",
32
+ "eslint": "~9.39",
34
33
  "jsdoc": "~4.0",
35
- "jsdom": "~27.0"
34
+ "jsdom": "~27.4"
36
35
  }
37
36
  }