markdown-up 2.3.3 → 2.3.5

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,13 +194,17 @@ export class MarkdownUp {
194
194
  return;
195
195
  }
196
196
 
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
- 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);
197
+ // URL hash ID?
198
+ const hashId = getHashID(this.window.location.hash);
199
+ if (!isError && hashId !== null) {
200
+ // Special "top" hash ID?
201
+ if (hashId === 'top' && this.window.document.getElementById(this.window.location.hash.slice(1)) === null) {
202
+ this.window.scrollTo(0, 0);
203
+ } else {
204
+ // Re-navigate to scroll to the hash ID since it was just rendered. The re-render is
205
+ // short-circuited by the unchanged hash param check above.
206
+ this.window.location.href = this.window.location.hash;
207
+ }
204
208
  }
205
209
  }
206
210
 
@@ -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;
@@ -514,14 +516,14 @@ export const markdownScriptFunctions = {
514
516
  // $function: markdownParse
515
517
  // $group: Markdown
516
518
  // $doc: Parse Markdown text
517
- // $arg lines: The Markdown text lines (may contain nested arrays of un-split lines)
519
+ // $arg lines...: The Markdown text lines (may contain nested arrays of un-split lines)
518
520
  // $return: The [Markdown model](https://craigahobbs.github.io/markdown-model/model/#var.vName='Markdown')
519
521
  'markdownParse': (lines) => parseMarkdown(lines.flat()),
520
522
 
521
523
  // $function: markdownPrint
522
524
  // $group: Markdown
523
525
  // $doc: Render Markdown text
524
- // $arg lines: The Markdown text lines (may contain nested arrays of un-split lines)
526
+ // $arg lines...: The Markdown text lines (may contain nested arrays of un-split lines)
525
527
  'markdownPrint': (lines, options) => {
526
528
  const {runtime} = options;
527
529
  runtime.setMarkdown();
@@ -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.3",
4
+ "version": "2.3.5",
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
  }