@meowdown/core 0.67.1 → 0.67.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/dist/index.js +46 -17
- package/dist/style.css +4 -0
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -190,7 +190,9 @@ function computeRevealDecorations(state, mode) {
|
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
192
|
if (ranges.length === 0) return;
|
|
193
|
-
const decorations = ranges.map((range) =>
|
|
193
|
+
const decorations = ranges.map((range) => {
|
|
194
|
+
return Decoration.inline(range.from, range.to, { class: "show" });
|
|
195
|
+
});
|
|
194
196
|
return DecorationSet.create(state.doc, decorations);
|
|
195
197
|
}
|
|
196
198
|
function defineMarkMode(mode) {
|
|
@@ -962,11 +964,13 @@ function headingFromDOM() {
|
|
|
962
964
|
4,
|
|
963
965
|
5,
|
|
964
966
|
6
|
|
965
|
-
].map((level) =>
|
|
966
|
-
level,
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
967
|
+
].map((level) => {
|
|
968
|
+
return createSourceTextRule(`h${level}`, "heading", (dom) => ({
|
|
969
|
+
level,
|
|
970
|
+
setextUnderline: parsePositiveInteger(dom.getAttribute("data-setext-underline")) ?? null,
|
|
971
|
+
closingHashes: parsePositiveInteger(dom.getAttribute("data-closing-hashes")) ?? null
|
|
972
|
+
}));
|
|
973
|
+
});
|
|
970
974
|
}
|
|
971
975
|
function defineSetextUnderlineAttr() {
|
|
972
976
|
return defineNodeAttr({
|
|
@@ -4428,11 +4432,13 @@ function toggleInline(spec) {
|
|
|
4428
4432
|
return false;
|
|
4429
4433
|
});
|
|
4430
4434
|
const remove = segments.length > 0 && segments.every((segment) => segment.active);
|
|
4431
|
-
const edits = segments.filter((segment) => remove || !segment.active).flatMap((segment) =>
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4435
|
+
const edits = segments.filter((segment) => remove || !segment.active).flatMap((segment) => {
|
|
4436
|
+
return toggleInlineEdits(segment.text, segment.from, segment.to, spec, remove).map((edit) => ({
|
|
4437
|
+
from: edit.from + segment.base,
|
|
4438
|
+
to: edit.to + segment.base,
|
|
4439
|
+
insert: edit.insert
|
|
4440
|
+
}));
|
|
4441
|
+
});
|
|
4436
4442
|
if (edits.length === 0) return false;
|
|
4437
4443
|
if (dispatch) {
|
|
4438
4444
|
const tr = state.tr;
|
|
@@ -4513,7 +4519,9 @@ function lastMarkRunIn(state, range, markName) {
|
|
|
4513
4519
|
* the `mdLinkUri` run locates the `( )` body.
|
|
4514
4520
|
*/
|
|
4515
4521
|
function getLinkUnitAt(state, pos) {
|
|
4516
|
-
const unit = getMarkRangeAt(state, pos, "mdPack", (mark) =>
|
|
4522
|
+
const unit = getMarkRangeAt(state, pos, "mdPack", (mark) => {
|
|
4523
|
+
return mark.attrs.key.startsWith("link-");
|
|
4524
|
+
});
|
|
4517
4525
|
if (!unit) return;
|
|
4518
4526
|
const attrs = unit.mark.attrs;
|
|
4519
4527
|
const unitRange = {
|
|
@@ -5737,7 +5745,8 @@ function tryCoordsAtPos(view, pos, side) {
|
|
|
5737
5745
|
let coords;
|
|
5738
5746
|
try {
|
|
5739
5747
|
coords = view.coordsAtPos(pos, side);
|
|
5740
|
-
} catch {
|
|
5748
|
+
} catch (error) {
|
|
5749
|
+
console.warn(`[meowdown] Failed to get caret coords at pos ${pos}:`, error);
|
|
5741
5750
|
return;
|
|
5742
5751
|
}
|
|
5743
5752
|
return isPointRect(coords) ? void 0 : coords;
|
|
@@ -5758,9 +5767,12 @@ function findNativeCaretRect(view) {
|
|
|
5758
5767
|
if (!view.dom.contains(selection.anchorNode)) return void 0;
|
|
5759
5768
|
const range = selection.getRangeAt(0).cloneRange();
|
|
5760
5769
|
range.collapse(true);
|
|
5770
|
+
return findLastRangeRect(range);
|
|
5771
|
+
}
|
|
5772
|
+
function findLastRangeRect(range) {
|
|
5761
5773
|
const rects = Array.from(range.getClientRects()).filter((rect) => rect.height > 0);
|
|
5762
|
-
if (rects.length === 0) return void 0;
|
|
5763
5774
|
const rect = rects[rects.length - 1];
|
|
5775
|
+
if (rect == null) return void 0;
|
|
5764
5776
|
return {
|
|
5765
5777
|
left: rect.left,
|
|
5766
5778
|
top: rect.top,
|
|
@@ -5773,18 +5785,35 @@ function findCoordsCaretRect(view) {
|
|
|
5773
5785
|
const runBefore = getHiddenRunBefore(state, head);
|
|
5774
5786
|
const runAfter = getHiddenRunAfter(state, head);
|
|
5775
5787
|
const afterLineBreak = isAfterLineBreak($head);
|
|
5776
|
-
const
|
|
5777
|
-
const probes = [[head,
|
|
5788
|
+
const previousLineTop = afterLineBreak ? tryCoordsAtPos(view, head, -1)?.top : void 0;
|
|
5789
|
+
const probes = afterLineBreak ? [[head, false]] : [[head, runBefore == null], [head, runBefore != null]];
|
|
5778
5790
|
if (runBefore != null) probes.push([runBefore.from, true]);
|
|
5779
5791
|
if (runAfter != null) probes.push([runAfter.to, false]);
|
|
5780
5792
|
for (const [pos, beforeSide] of probes) {
|
|
5781
5793
|
const coords = tryCoordsAtPos(view, pos, beforeSide ? -1 : 1);
|
|
5782
|
-
if (coords
|
|
5794
|
+
if (coords == null || coords.bottom <= coords.top) continue;
|
|
5795
|
+
if (pos === head && previousLineTop != null && coords.top <= previousLineTop) continue;
|
|
5796
|
+
return {
|
|
5783
5797
|
left: coords.left,
|
|
5784
5798
|
top: coords.top,
|
|
5785
5799
|
height: coords.bottom - coords.top
|
|
5786
5800
|
};
|
|
5787
5801
|
}
|
|
5802
|
+
if (previousLineTop != null) {
|
|
5803
|
+
const collapsed = findCollapsedRangeRect(view, head);
|
|
5804
|
+
if (collapsed != null && collapsed.top > previousLineTop) return collapsed;
|
|
5805
|
+
}
|
|
5806
|
+
}
|
|
5807
|
+
function findCollapsedRangeRect(view, pos) {
|
|
5808
|
+
try {
|
|
5809
|
+
const { node, offset } = view.domAtPos(pos, 0);
|
|
5810
|
+
const range = view.dom.ownerDocument.createRange();
|
|
5811
|
+
range.setStart(node, offset);
|
|
5812
|
+
range.collapse(true);
|
|
5813
|
+
return findLastRangeRect(range);
|
|
5814
|
+
} catch {
|
|
5815
|
+
return;
|
|
5816
|
+
}
|
|
5788
5817
|
}
|
|
5789
5818
|
function findAtomCaretRect(view) {
|
|
5790
5819
|
const state = view.state;
|
package/dist/style.css
CHANGED
|
@@ -691,6 +691,10 @@
|
|
|
691
691
|
display: contents;
|
|
692
692
|
}
|
|
693
693
|
|
|
694
|
+
.ProseMirror .md-pack[data-key="noLink"] {
|
|
695
|
+
display: inline;
|
|
696
|
+
}
|
|
697
|
+
|
|
694
698
|
.ProseMirror[data-mark-mode="hide"], .ProseMirror[data-mark-mode="focus"] {
|
|
695
699
|
& .md-mark, & .md-link-uri, & .md-link-title {
|
|
696
700
|
letter-spacing: 0;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meowdown/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.67.
|
|
4
|
+
"version": "0.67.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"remark-stringify": "^11.0.0",
|
|
44
44
|
"unicode-by-name": "^0.2.0",
|
|
45
45
|
"unified": "^11.0.5",
|
|
46
|
-
"@meowdown/markdown": "^0.67.
|
|
46
|
+
"@meowdown/markdown": "^0.67.2"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@ocavue/tsconfig": "^0.7.1",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"diffable-html-snapshot": "^0.3.0",
|
|
57
57
|
"tsdown": "^0.23.0-beta.2",
|
|
58
58
|
"vitest": "^4.1.11",
|
|
59
|
+
"vitest-browser-commands": "^0.4.1",
|
|
59
60
|
"@meowdown/vitest": "0.0.0"
|
|
60
61
|
},
|
|
61
62
|
"publishConfig": {
|