rme 0.3.0-beta.32 → 0.3.0-beta.34
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.d.ts +5 -2
- package/dist/index.mjs +92 -30
- package/dist/index.mjs.map +3 -3
- package/package.json +9 -8
package/dist/index.d.ts
CHANGED
|
@@ -382,6 +382,7 @@ declare class MarkdownParseState {
|
|
|
382
382
|
private marks;
|
|
383
383
|
private tokenHandlers;
|
|
384
384
|
private contextStack;
|
|
385
|
+
private contextTokenStack;
|
|
385
386
|
stack: StackItem[];
|
|
386
387
|
constructor(schema: Schema, tokenHandlers: TokenHandlers);
|
|
387
388
|
top(): StackItem;
|
|
@@ -394,9 +395,11 @@ declare class MarkdownParseState {
|
|
|
394
395
|
addNode(type: NodeType, attrs?: Record<string, any>, content?: Node[]): Node;
|
|
395
396
|
openNode(type: NodeType, attrs?: Record<string, any>): void;
|
|
396
397
|
closeNode(): Node;
|
|
397
|
-
openContext(context: ParserRuleContext): void;
|
|
398
|
+
openContext(context: ParserRuleContext, token: Token$1): void;
|
|
398
399
|
closeContext(): void;
|
|
400
|
+
closeContextToken(): Token$1 | undefined;
|
|
399
401
|
topContext(): ParserRuleContext | undefined;
|
|
402
|
+
topContextToken(): Token$1 | undefined;
|
|
400
403
|
}
|
|
401
404
|
declare class MarkdownParser {
|
|
402
405
|
private schema;
|
|
@@ -676,7 +679,7 @@ declare class LineListExtension extends NodeExtension {
|
|
|
676
679
|
fromMarkdown(): readonly [{
|
|
677
680
|
readonly type: ParserRuleType.free;
|
|
678
681
|
readonly token: "list_item_open";
|
|
679
|
-
readonly handler: (state: MarkdownParseState) => void;
|
|
682
|
+
readonly handler: (state: MarkdownParseState, token: Token) => void;
|
|
680
683
|
}, {
|
|
681
684
|
readonly type: ParserRuleType.free;
|
|
682
685
|
readonly token: "list_checkbox";
|
package/dist/index.mjs
CHANGED
|
@@ -564,7 +564,24 @@ var FlatListStyles = css`
|
|
|
564
564
|
content: counter(prosemirror-flat-list-counter, decimal) '. ';
|
|
565
565
|
font-variant-numeric: tabular-nums;
|
|
566
566
|
}
|
|
567
|
-
|
|
567
|
+
|
|
568
|
+
/*
|
|
569
|
+
If the node has a custom order number, set the counter to that value.
|
|
570
|
+
Otherwise, increment the counter normally.
|
|
571
|
+
*/
|
|
572
|
+
&[data-list-order] {
|
|
573
|
+
@supports (counter-set: prosemirror-flat-list-counter 1) {
|
|
574
|
+
counter-set: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
@supports not (counter-set: prosemirror-flat-list-counter 1) {
|
|
578
|
+
counter-reset: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
&:not([data-list-order]) {
|
|
583
|
+
counter-increment: prosemirror-flat-list-counter;
|
|
584
|
+
}
|
|
568
585
|
|
|
569
586
|
/*
|
|
570
587
|
Reset the counter for the first list node in the sequence or when
|
|
@@ -572,19 +589,6 @@ var FlatListStyles = css`
|
|
|
572
589
|
*/
|
|
573
590
|
&:first-child {
|
|
574
591
|
counter-reset: prosemirror-flat-list-counter;
|
|
575
|
-
|
|
576
|
-
/*
|
|
577
|
-
If the first list node has a custom order number, set the counter to that value.
|
|
578
|
-
*/
|
|
579
|
-
&[data-list-order] {
|
|
580
|
-
@supports (counter-set: prosemirror-flat-list-counter 1) {
|
|
581
|
-
counter-set: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
@supports not (counter-set: prosemirror-flat-list-counter 1) {
|
|
585
|
-
counter-increment: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
592
|
}
|
|
589
593
|
}
|
|
590
594
|
|
|
@@ -625,7 +629,7 @@ var FlatListStyles = css`
|
|
|
625
629
|
Reset counter when an ordered list follows a non-list element.
|
|
626
630
|
This handles the case where there's a paragraph break (e.g., h3) between lists.
|
|
627
631
|
*/
|
|
628
|
-
:not(.prosemirror-flat-list) + .prosemirror-flat-list[data-list-kind='ordered'] {
|
|
632
|
+
:not(.prosemirror-flat-list[data-list-kind='ordered']) + .prosemirror-flat-list[data-list-kind='ordered'] {
|
|
629
633
|
counter-reset: prosemirror-flat-list-counter;
|
|
630
634
|
|
|
631
635
|
&[data-list-order] {
|
|
@@ -2495,15 +2499,35 @@ var rule = (state) => {
|
|
|
2495
2499
|
const tokens = state.tokens;
|
|
2496
2500
|
const tokensLength = tokens.length;
|
|
2497
2501
|
for (let i = tokensLength - 3; i >= 0; i--) {
|
|
2498
|
-
|
|
2502
|
+
const curToken = tokens[i];
|
|
2503
|
+
if (curToken.type === "ordered_list_open") {
|
|
2504
|
+
curToken.attrs?.some(([name, value]) => {
|
|
2505
|
+
if (name === "start") {
|
|
2506
|
+
const startNum = parseInt(value, 10);
|
|
2507
|
+
if (!isNaN(startNum) && startNum >= 1) {
|
|
2508
|
+
curToken.attrPush(["order", value]);
|
|
2509
|
+
}
|
|
2510
|
+
return true;
|
|
2511
|
+
}
|
|
2512
|
+
return false;
|
|
2513
|
+
});
|
|
2514
|
+
}
|
|
2515
|
+
if (isBulletListItemToken(curToken) && isParagraphOpenToken(tokens[i + 1]) && isInlineToken(tokens[i + 2])) {
|
|
2499
2516
|
const inlineToken = tokens[i + 2];
|
|
2500
2517
|
const match = /^\[([ |x])\]\s?/.exec(inlineToken.content);
|
|
2501
2518
|
if (match) {
|
|
2502
2519
|
const checked = match[1] === "x";
|
|
2503
|
-
|
|
2504
|
-
inlineToken.
|
|
2505
|
-
|
|
2506
|
-
|
|
2520
|
+
const checkboxPrefix = match[0];
|
|
2521
|
+
inlineToken.content = inlineToken.content.slice(checkboxPrefix.length);
|
|
2522
|
+
if (inlineToken.children && inlineToken.children.length > 0) {
|
|
2523
|
+
const firstTextChild = inlineToken.children.find((child) => child.type === "text");
|
|
2524
|
+
if (firstTextChild) {
|
|
2525
|
+
const originalContent = firstTextChild.content;
|
|
2526
|
+
if (originalContent.startsWith(checkboxPrefix)) {
|
|
2527
|
+
firstTextChild.content = originalContent.slice(checkboxPrefix.length);
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2507
2531
|
const checkboxToken = new Token("list_checkbox", "input", 0);
|
|
2508
2532
|
checkboxToken.attrPush(["type", "checkbox"]);
|
|
2509
2533
|
if (checked) {
|
|
@@ -3175,6 +3199,7 @@ var MarkdownParseState = class {
|
|
|
3175
3199
|
this.schema = schema;
|
|
3176
3200
|
this.stack = [{ type: schema.topNodeType, content: [] }];
|
|
3177
3201
|
this.contextStack = [];
|
|
3202
|
+
this.contextTokenStack = [];
|
|
3178
3203
|
this.marks = Mark.none;
|
|
3179
3204
|
this.tokenHandlers = tokenHandlers;
|
|
3180
3205
|
}
|
|
@@ -3244,15 +3269,23 @@ var MarkdownParseState = class {
|
|
|
3244
3269
|
}
|
|
3245
3270
|
return this.addNode(info.type, info.attrs, info.content);
|
|
3246
3271
|
}
|
|
3247
|
-
openContext(context) {
|
|
3272
|
+
openContext(context, token) {
|
|
3248
3273
|
this.contextStack.push(context);
|
|
3274
|
+
this.contextTokenStack.push(token);
|
|
3249
3275
|
}
|
|
3250
3276
|
closeContext() {
|
|
3251
3277
|
this.contextStack.pop();
|
|
3278
|
+
this.contextTokenStack.pop();
|
|
3279
|
+
}
|
|
3280
|
+
closeContextToken() {
|
|
3281
|
+
return this.contextTokenStack.pop();
|
|
3252
3282
|
}
|
|
3253
3283
|
topContext() {
|
|
3254
3284
|
return this.contextStack[this.contextStack.length - 1];
|
|
3255
3285
|
}
|
|
3286
|
+
topContextToken() {
|
|
3287
|
+
return this.contextTokenStack[this.contextTokenStack.length - 1];
|
|
3288
|
+
}
|
|
3256
3289
|
};
|
|
3257
3290
|
function withoutTrailingNewline(str) {
|
|
3258
3291
|
return str.endsWith("\n") ? str.slice(0, str.length - 1) : str;
|
|
@@ -3280,8 +3313,8 @@ function buildBlockTokenHandler(parserRule, handlers, schema) {
|
|
|
3280
3313
|
}
|
|
3281
3314
|
}
|
|
3282
3315
|
function buildContextTokenHandler(parserRule, handlers) {
|
|
3283
|
-
handlers[parserRule.token + "_open"] = (state) => {
|
|
3284
|
-
state.openContext(parserRule.context);
|
|
3316
|
+
handlers[parserRule.token + "_open"] = (state, tok) => {
|
|
3317
|
+
state.openContext(parserRule.context, tok);
|
|
3285
3318
|
};
|
|
3286
3319
|
handlers[parserRule.token + "_close"] = (state) => {
|
|
3287
3320
|
state.closeContext();
|
|
@@ -9638,10 +9671,25 @@ var LineListExtension = class extends NodeExtension8 {
|
|
|
9638
9671
|
{
|
|
9639
9672
|
type: 4 /* free */,
|
|
9640
9673
|
token: "list_item_open",
|
|
9641
|
-
handler: (state) => {
|
|
9674
|
+
handler: (state, token) => {
|
|
9642
9675
|
switch (state.topContext()) {
|
|
9643
9676
|
case "ordered_list":
|
|
9644
|
-
state.
|
|
9677
|
+
const token2 = state.topContextToken();
|
|
9678
|
+
let startOrder;
|
|
9679
|
+
if (token2?.type === "ordered_list_open") {
|
|
9680
|
+
token2?.attrs?.some(([name, value]) => {
|
|
9681
|
+
if (name === "order") {
|
|
9682
|
+
startOrder = parseInt(value, 10);
|
|
9683
|
+
state.closeContextToken();
|
|
9684
|
+
return true;
|
|
9685
|
+
}
|
|
9686
|
+
return false;
|
|
9687
|
+
});
|
|
9688
|
+
}
|
|
9689
|
+
state.openNode(this.type, {
|
|
9690
|
+
kind: "ordered",
|
|
9691
|
+
order: startOrder
|
|
9692
|
+
});
|
|
9645
9693
|
break;
|
|
9646
9694
|
case "bullet_list":
|
|
9647
9695
|
state.openNode(this.type, { kind: "bullet" });
|
|
@@ -9688,14 +9736,15 @@ var LineListExtension = class extends NodeExtension8 {
|
|
|
9688
9736
|
const attrs = node.attrs;
|
|
9689
9737
|
let firstDelim = "";
|
|
9690
9738
|
if (attrs.kind === "ordered") {
|
|
9691
|
-
|
|
9739
|
+
const order = attrs.order != null ? attrs.order : counter;
|
|
9740
|
+
firstDelim = `${order}. `;
|
|
9692
9741
|
} else if (attrs.kind === "task") {
|
|
9693
9742
|
firstDelim = attrs.checked ? "- [x] " : "- [ ] ";
|
|
9694
9743
|
} else if (attrs.kind === "bullet") {
|
|
9695
9744
|
firstDelim = "- ";
|
|
9696
9745
|
}
|
|
9697
9746
|
state.wrapBlock(
|
|
9698
|
-
"
|
|
9747
|
+
" ",
|
|
9699
9748
|
firstDelim,
|
|
9700
9749
|
node,
|
|
9701
9750
|
() => state.renderContent(node)
|
|
@@ -11021,7 +11070,6 @@ var ReferenceDefinitionExtension = class extends NodeExtension12 {
|
|
|
11021
11070
|
token: "reference_def",
|
|
11022
11071
|
hasOpenClose: true,
|
|
11023
11072
|
getAttrs: (token) => {
|
|
11024
|
-
console.log("token11", token);
|
|
11025
11073
|
return {
|
|
11026
11074
|
label: token.attrs?.[0]?.[1] || "",
|
|
11027
11075
|
href: token.attrs?.[1]?.[1] || "",
|
|
@@ -11636,7 +11684,16 @@ var MarkdownSerializerState = class {
|
|
|
11636
11684
|
if (parent.forEach) {
|
|
11637
11685
|
parent.forEach((node, offset, index) => {
|
|
11638
11686
|
if (isOrderedListNode(node)) {
|
|
11639
|
-
|
|
11687
|
+
const prevSibling = index > 0 ? parent.child(index - 1) : null;
|
|
11688
|
+
if (prevSibling && !isOrderedListNode(prevSibling)) {
|
|
11689
|
+
counter = 0;
|
|
11690
|
+
}
|
|
11691
|
+
const attrs = node.attrs;
|
|
11692
|
+
if (attrs.order != null) {
|
|
11693
|
+
counter = attrs.order;
|
|
11694
|
+
} else {
|
|
11695
|
+
counter += 1;
|
|
11696
|
+
}
|
|
11640
11697
|
} else {
|
|
11641
11698
|
counter = 0;
|
|
11642
11699
|
}
|
|
@@ -11644,7 +11701,12 @@ var MarkdownSerializerState = class {
|
|
|
11644
11701
|
});
|
|
11645
11702
|
} else {
|
|
11646
11703
|
if (isOrderedListNode(parent)) {
|
|
11647
|
-
|
|
11704
|
+
const attrs = parent.attrs;
|
|
11705
|
+
if (attrs.order != null) {
|
|
11706
|
+
counter = attrs.order;
|
|
11707
|
+
} else {
|
|
11708
|
+
counter += 1;
|
|
11709
|
+
}
|
|
11648
11710
|
} else {
|
|
11649
11711
|
counter = 0;
|
|
11650
11712
|
}
|