markdown-up 2.3.2 → 2.3.4

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 CHANGED
@@ -194,10 +194,13 @@ export class MarkdownUp {
194
194
  return;
195
195
  }
196
196
 
197
- // If the window location hash exists in the document, re-navigate there since it was just rendered.
198
- // After the first render, re-render is short-circuited by the unchanged hash param check above.
199
- if (!isError && this.window.document.getElementById(this.window.location.hash.slice(1)) !== null) {
197
+ // If there is a URL hash ID, re-navigate to go there since it was just rendered.
198
+ // The re-render is short-circuited by the unchanged hash param check above.
199
+ if (!isError && getHashID(this.window.location.hash) !== null) {
200
200
  this.window.location.href = this.window.location.hash;
201
+ } else {
202
+ // Otherwise, scroll to the top of the page
203
+ this.window.scrollTo(0, 0);
201
204
  }
202
205
  }
203
206
 
@@ -347,10 +350,6 @@ export class MarkdownUp {
347
350
  // Menu "burger"
348
351
  this.burgerElements(),
349
352
 
350
- // Add a top hash ID, if necessary
351
- Object.keys(this.params).length === 0
352
- ? null : {'html': 'div', 'attr': {'id': encodeQueryString(this.params), 'style': 'display=none'}},
353
-
354
353
  // Render the markdown
355
354
  await markdownElementsAsync(markdownModel, {
356
355
  'codeBlocks': {
@@ -452,8 +452,10 @@ export const markdownScriptFunctions = {
452
452
  // $doc: Render an [element model](https://github.com/craigahobbs/element-model#readme)
453
453
  // $doc:
454
454
  // $doc: **Note:** Element model "callback" members are a map of event name (e.g., "click") to
455
- // $doc: event callback function. Data can be passed to the callback functions by setting a
456
- // $doc: "callbackData" member.
455
+ // $doc: event callback function. The following events have callback arguments:
456
+ // $doc: - **keydown** - keyCode
457
+ // $doc: - **keypress** - keyCode
458
+ // $doc: - **keyup** - keyCode
457
459
  // $arg element: The [element model](https://github.com/craigahobbs/element-model#readme)
458
460
  'elementModelRender': ([elements], options) => {
459
461
  const {runtime} = options;
@@ -681,13 +683,6 @@ function elementModelWrapCallbacks(elements, options) {
681
683
 
682
684
  // Element callback attribute must be map of event => callback
683
685
  if ('callback' in elements) {
684
- // Get the callback data, if any
685
- let callbackData = null;
686
- if ('callbackData' in elements) {
687
- ({callbackData} = elements);
688
- delete elements.callbackData;
689
- }
690
-
691
686
  // Wrap the event handler function
692
687
  const elementEvents = elements.callback;
693
688
  if (elementEvents !== null) {
@@ -700,7 +695,6 @@ function elementModelWrapCallbacks(elements, options) {
700
695
  if (elementEvent === 'keydown' || elementEvent === 'keypress' || elementEvent === 'keyup') {
701
696
  eventArgs.push(event.keyCode);
702
697
  }
703
- eventArgs.push(callbackData);
704
698
 
705
699
  // Call the event handler
706
700
  options.statementCount = 0;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "markdown-up",
4
- "version": "2.3.2",
4
+ "version": "2.3.4",
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": "~8.0",
33
- "eslint": "~8.50",
33
+ "eslint": "~8.52",
34
34
  "jsdoc": "~4.0",
35
35
  "jsdom": "~22.1"
36
36
  }