tiny-markdown-editor 0.2.1 → 0.2.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/TinyMDE.js CHANGED
@@ -378,7 +378,7 @@ class Editor {
378
378
  }
379
379
  }
380
380
  getSelection(getAnchor = false) {
381
- var _a;
381
+ var _a, _b;
382
382
  const selection = window.getSelection();
383
383
  let startNode = getAnchor ? selection.anchorNode : selection.focusNode;
384
384
  if (!startNode)
@@ -403,16 +403,25 @@ class Editor {
403
403
  node = node.parentElement;
404
404
  }
405
405
  let row = 0;
406
- if (node.dataset &&
407
- node.dataset.lineNum &&
408
- (!node.previousSibling ||
409
- (((_a = node.previousSibling.dataset) === null || _a === void 0 ? void 0 : _a.lineNum) !== node.dataset.lineNum))) {
410
- row = parseInt(node.dataset.lineNum);
411
- }
412
- else {
413
- while (node.previousSibling) {
414
- row++;
415
- node = node.previousSibling;
406
+ // If the node doesn't have a previous sibling, it must be the first line
407
+ if (node.previousSibling) {
408
+ const currentLineNumData = (_a = node.dataset) === null || _a === void 0 ? void 0 : _a.lineNum;
409
+ const previousLineNumData = (_b = node.previousSibling.dataset) === null || _b === void 0 ? void 0 : _b.lineNum;
410
+ if (currentLineNumData && previousLineNumData) {
411
+ const currentLineNum = parseInt(currentLineNumData);
412
+ const previousLineNum = parseInt(previousLineNumData);
413
+ if (currentLineNum === previousLineNum + 1) {
414
+ row = currentLineNum;
415
+ }
416
+ else {
417
+ // If the current line is NOT the previous line + 1, then either
418
+ // the current line got split in two or merged with the previous line
419
+ // Either way, we need to recalculate the row number
420
+ while (node.previousSibling) {
421
+ row++;
422
+ node = node.previousSibling;
423
+ }
424
+ }
416
425
  }
417
426
  }
418
427
  return { row: row, col: col };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-markdown-editor",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "TinyMDE: A tiny, ultra low dependency, embeddable HTML/JavaScript Markdown editor.",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -15,7 +15,11 @@
15
15
  "editor"
16
16
  ],
17
17
  "scripts": {
18
- "test": "npx gulp test",
18
+ "test": "npx gulp && npx jest",
19
+ "test:chromium": "npx gulp && npx jest --selectProjects chromium",
20
+ "test:firefox": "npx gulp && npx jest --selectProjects firefox",
21
+ "test:webkit": "npx gulp && npx jest --selectProjects webkit",
22
+ "test:single": "npx gulp test",
19
23
  "build": "npx gulp",
20
24
  "dev": "npx gulp dev",
21
25
  "typecheck": "npx tsc --noEmit",
@@ -44,19 +48,20 @@
44
48
  "@babel/preset-env": "^7.27.2",
45
49
  "@babel/preset-typescript": "^7.27.1",
46
50
  "@octokit/rest": "^22.0.0",
51
+ "@playwright/test": "^1.54.1",
47
52
  "@rollup/plugin-babel": "^6.0.4",
48
53
  "@rollup/plugin-commonjs": "^28.0.3",
49
54
  "@rollup/plugin-node-resolve": "^16.0.1",
50
55
  "@rollup/plugin-typescript": "^12.1.1",
51
56
  "@rollup/stream": "^3.0.1",
52
57
  "@types/jest": "^29.5.14",
58
+ "@typescript-eslint/eslint-plugin": "^8.20.0",
59
+ "@typescript-eslint/parser": "^8.20.0",
53
60
  "autoprefixer": "^10.4.21",
54
61
  "cssnano": "^7.0.7",
55
62
  "del": "^8.0.0",
56
63
  "dotenv": "^16.5.0",
57
64
  "eslint": "^9.28.0",
58
- "@typescript-eslint/eslint-plugin": "^8.20.0",
59
- "@typescript-eslint/parser": "^8.20.0",
60
65
  "express": "^5.1.0",
61
66
  "gulp": "^5.0.1",
62
67
  "gulp-babel": "^8.0.0",
@@ -67,9 +72,8 @@
67
72
  "gulp-typescript": "^6.0.0-alpha.1",
68
73
  "jest": "^29.7.0",
69
74
  "jest-cli": "^29.7.0",
70
- "jest-puppeteer": "^11.0.0",
75
+ "playwright": "^1.54.1",
71
76
  "postcss-import": "^16.1.0",
72
- "puppeteer": "^24.10.0",
73
77
  "rollup": "^4.41.1",
74
78
  "rollup-plugin-eslint": "^7.0.0",
75
79
  "terser": "^5.40.0",