@aicayzer/inkkit 0.0.11 → 0.0.13

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/dist/editor.js CHANGED
@@ -1374,9 +1374,10 @@ export class InkKitEditor {
1374
1374
  this.assertAlive();
1375
1375
  const container = this.viewportContainer ?? this.root;
1376
1376
  const top = container.scrollTop, left = container.scrollLeft;
1377
- const focused = this.literalSurface
1378
- ? this.plain.ownerDocument.activeElement === this.plain
1379
- : this.editor.ctx.get(editorViewCtx).hasFocus();
1377
+ const active = this.root.ownerDocument.activeElement;
1378
+ if (active === this.plain ||
1379
+ active === this.editor.ctx.get(editorViewCtx).dom)
1380
+ active.blur();
1380
1381
  this.ready = false;
1381
1382
  this.cancelExports();
1382
1383
  this.mediaPolicy();
@@ -1401,12 +1402,6 @@ export class InkKitEditor {
1401
1402
  this.updateSurface();
1402
1403
  this.ready = true;
1403
1404
  this.mediaPolicy();
1404
- if (focused) {
1405
- if (this.literalSurface)
1406
- this.plain.focus({ preventScroll: true });
1407
- else
1408
- this.editor.ctx.get(editorViewCtx).focus();
1409
- }
1410
1405
  container.scrollTop = top;
1411
1406
  container.scrollLeft = left;
1412
1407
  this.events.stateChanged(this.literalSurface
@@ -33,7 +33,7 @@ export function parseLinkedSyntax(raw, inTable = false) {
33
33
  }
34
34
  else {
35
35
  if ('[]'.includes(character) ||
36
- character.charCodeAt(0) < 32 ||
36
+ (character.charCodeAt(0) < 32 && character !== '\t') ||
37
37
  character === '\u007f')
38
38
  return undefined;
39
39
  parts[section] += character;
@@ -45,18 +45,28 @@ export function parseLinkedSyntax(raw, inTable = false) {
45
45
  parts.target.trimStart().startsWith('^') ||
46
46
  parts.fragment.trimStart().startsWith('^'))
47
47
  return undefined;
48
+ const size = /^[ \t]*(\d{1,5})(?:x(\d{1,5}))?[ \t]*$/.exec(parts.alias);
48
49
  if (embed &&
49
50
  (!parts.target.trim() ||
50
- (hasAlias && (!/^\d{1,5}$/.test(parts.alias) || Number(parts.alias) < 1))))
51
+ (hasAlias &&
52
+ (!size ||
53
+ Number(size[1]) < 1 ||
54
+ (size[2] != null && Number(size[2]) < 1)))))
51
55
  return undefined;
56
+ const target = embed ? parts.target.trim() : parts.target;
57
+ const fragment = hasFragment
58
+ ? embed
59
+ ? parts.fragment.trim()
60
+ : parts.fragment
61
+ : null;
52
62
  return {
53
63
  raw,
54
- target: parts.target,
55
- fragment: hasFragment ? parts.fragment : null,
64
+ target,
65
+ fragment,
56
66
  label: !embed && hasAlias
57
67
  ? parts.alias
58
- : parts.target + (hasFragment ? `#${parts.fragment}` : ''),
59
- width: embed && hasAlias ? Number(parts.alias) : null,
68
+ : target + (fragment != null ? `#${fragment}` : ''),
69
+ width: embed && hasAlias ? Number(size[1]) : null,
60
70
  embed,
61
71
  inTable,
62
72
  };
@@ -67,7 +77,7 @@ function linkedTokenizer(embed) {
67
77
  let index = 0, raw = '';
68
78
  return opening;
69
79
  function consume(code) {
70
- raw += String.fromCodePoint(code);
80
+ raw += code === -2 ? '\t' : code === -1 ? ' ' : String.fromCodePoint(code);
71
81
  effects.consume(code);
72
82
  }
73
83
  function opening(code) {
@@ -80,7 +90,9 @@ function linkedTokenizer(embed) {
80
90
  return index === prefix.length ? body : opening;
81
91
  }
82
92
  function body(code) {
83
- if (code === null || code < 32 || code === 91)
93
+ if (code === null ||
94
+ (code < 32 && code !== -2 && code !== -1 && code !== 9) ||
95
+ code === 91)
84
96
  return nok(code);
85
97
  consume(code);
86
98
  if (code === 92)
@@ -161,7 +173,7 @@ export function namedFileMarkdown(node, inTable = false) {
161
173
  if (authoredInTable)
162
174
  raw = fromTable(raw);
163
175
  if (original != null)
164
- raw = raw.replace(/\|\d{1,5}\]\]$/, ']]');
176
+ raw = raw.replace(/\|[ \t]*\d{1,5}(?:x\d{1,5})?[ \t]*\]\]$/, ']]');
165
177
  if (width != null)
166
178
  raw = `${raw.slice(0, -2)}|${width}]]`;
167
179
  return inTable ? toTable(raw) : raw;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aicayzer/inkkit",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "A preserving Markdown editor for offline web views and the web",
5
5
  "license": "MIT",
6
6
  "type": "module",