synthetic-markdown 0.0.5 → 0.0.7
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.cjs.js +17 -6
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +17 -6
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -969,7 +969,6 @@ function detectBlockType(line) {
|
|
|
969
969
|
if (headingMatch) return { type: "heading", level: headingMatch[1].length };
|
|
970
970
|
if (/^>/.test(line)) return { type: "blockQuote" };
|
|
971
971
|
if (/^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/.test(line)) return { type: "thematicBreak" };
|
|
972
|
-
if (/^\s{0,3}(```+|~~~+)/.test(line)) return { type: "codeBlock" };
|
|
973
972
|
const unorderedListMatch = /^\s*([-*+])\s+/.exec(line);
|
|
974
973
|
if (unorderedListMatch) return { type: "listItem", ordered: false };
|
|
975
974
|
const orderedListMatch = /^\s*(\d{1,9})([.)])\s+/.exec(line);
|
|
@@ -980,7 +979,6 @@ function detectBlockType(line) {
|
|
|
980
979
|
listStart: parseInt(orderedListMatch[1], 10)
|
|
981
980
|
};
|
|
982
981
|
}
|
|
983
|
-
if (/^ {4,}[^ ]/.test(line)) return { type: "codeBlock" };
|
|
984
982
|
if (/^\[\^[^\]]+\]:/.test(trimmed)) return { type: "footnote" };
|
|
985
983
|
if (/^\s{0,3}<(?:script|pre|style|textarea)[\s>]/i.test(line) || /^\s{0,3}<!--/.test(line) || /^\s{0,3}<\?/.test(line) || /^\s{0,3}<![A-Z]/.test(line) || /^\s{0,3}<!\[CDATA\[/.test(line) || /^\s{0,3}<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i.test(
|
|
986
984
|
line
|
|
@@ -7636,10 +7634,11 @@ var Element = class extends HTMLElement {
|
|
|
7636
7634
|
this.appliedClasses = [];
|
|
7637
7635
|
this.customClass = "";
|
|
7638
7636
|
this.hasAutofocus = false;
|
|
7637
|
+
this.hasEditable = true;
|
|
7639
7638
|
this.shadowRootElement = this.attachShadow({ mode: "open" });
|
|
7640
7639
|
}
|
|
7641
7640
|
static get observedAttributes() {
|
|
7642
|
-
return ["class", "autofocus"];
|
|
7641
|
+
return ["class", "autofocus", "editable"];
|
|
7643
7642
|
}
|
|
7644
7643
|
get value() {
|
|
7645
7644
|
return this.ast.text;
|
|
@@ -7650,6 +7649,7 @@ var Element = class extends HTMLElement {
|
|
|
7650
7649
|
this.ast.setText(value);
|
|
7651
7650
|
this.renderDOM();
|
|
7652
7651
|
this.setAutoFocus();
|
|
7652
|
+
this.setEditable();
|
|
7653
7653
|
this.hasAcceptedExternalValue = true;
|
|
7654
7654
|
}
|
|
7655
7655
|
}
|
|
@@ -7670,15 +7670,20 @@ var Element = class extends HTMLElement {
|
|
|
7670
7670
|
return;
|
|
7671
7671
|
}
|
|
7672
7672
|
if (name === "autofocus") {
|
|
7673
|
-
this.hasAutofocus =
|
|
7673
|
+
this.hasAutofocus = newValue === "" || newValue === "true" || newValue === "1";
|
|
7674
7674
|
this.setAutoFocus();
|
|
7675
7675
|
return;
|
|
7676
7676
|
}
|
|
7677
|
+
if (name === "editable") {
|
|
7678
|
+
this.hasEditable = newValue === "" || newValue === "true" || newValue === "1";
|
|
7679
|
+
this.setEditable();
|
|
7680
|
+
return;
|
|
7681
|
+
}
|
|
7677
7682
|
}
|
|
7678
7683
|
connectedCallback() {
|
|
7679
7684
|
const attrValue = this.getAttribute("value") ?? "";
|
|
7680
|
-
this.hasAutofocus = this.hasAttribute("autofocus");
|
|
7681
7685
|
this.customClass = (this.getAttribute("class") ?? "").trim();
|
|
7686
|
+
this.hasAutofocus = this.hasAttribute("autofocus");
|
|
7682
7687
|
this.ast.setText(attrValue);
|
|
7683
7688
|
this.addStyles();
|
|
7684
7689
|
this.addDOM();
|
|
@@ -7693,6 +7698,7 @@ var Element = class extends HTMLElement {
|
|
|
7693
7698
|
this.interaction.attach();
|
|
7694
7699
|
this.renderDOM();
|
|
7695
7700
|
this.setAutoFocus();
|
|
7701
|
+
this.setEditable();
|
|
7696
7702
|
}
|
|
7697
7703
|
disconnectedCallback() {
|
|
7698
7704
|
this.interaction?.detach();
|
|
@@ -7715,10 +7721,10 @@ var Element = class extends HTMLElement {
|
|
|
7715
7721
|
if (this.rootElement) return;
|
|
7716
7722
|
const div = document.createElement("div");
|
|
7717
7723
|
div.classList.add("element");
|
|
7718
|
-
div.contentEditable = "true";
|
|
7719
7724
|
this.shadowRootElement.appendChild(div);
|
|
7720
7725
|
this.rootElement = div;
|
|
7721
7726
|
this.applyClass();
|
|
7727
|
+
this.setEditable();
|
|
7722
7728
|
}
|
|
7723
7729
|
applyClass() {
|
|
7724
7730
|
if (!this.rootElement) return;
|
|
@@ -7742,6 +7748,11 @@ var Element = class extends HTMLElement {
|
|
|
7742
7748
|
setAutoFocus() {
|
|
7743
7749
|
if (this.hasAutofocus && this.rootElement && this.select) this.select.autoFocus();
|
|
7744
7750
|
}
|
|
7751
|
+
setEditable() {
|
|
7752
|
+
if (this.rootElement) {
|
|
7753
|
+
this.rootElement.contentEditable = this.hasEditable ? "true" : "false";
|
|
7754
|
+
}
|
|
7755
|
+
}
|
|
7745
7756
|
};
|
|
7746
7757
|
var element_default = Element;
|
|
7747
7758
|
|
package/dist/index.d.cts
CHANGED
|
@@ -14,6 +14,7 @@ declare class Element extends HTMLElement {
|
|
|
14
14
|
private appliedClasses;
|
|
15
15
|
private customClass;
|
|
16
16
|
hasAutofocus: boolean;
|
|
17
|
+
hasEditable: boolean;
|
|
17
18
|
constructor();
|
|
18
19
|
static get observedAttributes(): string[];
|
|
19
20
|
get value(): string;
|
|
@@ -29,6 +30,7 @@ declare class Element extends HTMLElement {
|
|
|
29
30
|
private applyClass;
|
|
30
31
|
private emitChange;
|
|
31
32
|
private setAutoFocus;
|
|
33
|
+
private setEditable;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
declare function defineElement(tag?: string): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ declare class Element extends HTMLElement {
|
|
|
14
14
|
private appliedClasses;
|
|
15
15
|
private customClass;
|
|
16
16
|
hasAutofocus: boolean;
|
|
17
|
+
hasEditable: boolean;
|
|
17
18
|
constructor();
|
|
18
19
|
static get observedAttributes(): string[];
|
|
19
20
|
get value(): string;
|
|
@@ -29,6 +30,7 @@ declare class Element extends HTMLElement {
|
|
|
29
30
|
private applyClass;
|
|
30
31
|
private emitChange;
|
|
31
32
|
private setAutoFocus;
|
|
33
|
+
private setEditable;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
declare function defineElement(tag?: string): void;
|
package/dist/index.esm.js
CHANGED
|
@@ -941,7 +941,6 @@ function detectBlockType(line) {
|
|
|
941
941
|
if (headingMatch) return { type: "heading", level: headingMatch[1].length };
|
|
942
942
|
if (/^>/.test(line)) return { type: "blockQuote" };
|
|
943
943
|
if (/^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/.test(line)) return { type: "thematicBreak" };
|
|
944
|
-
if (/^\s{0,3}(```+|~~~+)/.test(line)) return { type: "codeBlock" };
|
|
945
944
|
const unorderedListMatch = /^\s*([-*+])\s+/.exec(line);
|
|
946
945
|
if (unorderedListMatch) return { type: "listItem", ordered: false };
|
|
947
946
|
const orderedListMatch = /^\s*(\d{1,9})([.)])\s+/.exec(line);
|
|
@@ -952,7 +951,6 @@ function detectBlockType(line) {
|
|
|
952
951
|
listStart: parseInt(orderedListMatch[1], 10)
|
|
953
952
|
};
|
|
954
953
|
}
|
|
955
|
-
if (/^ {4,}[^ ]/.test(line)) return { type: "codeBlock" };
|
|
956
954
|
if (/^\[\^[^\]]+\]:/.test(trimmed)) return { type: "footnote" };
|
|
957
955
|
if (/^\s{0,3}<(?:script|pre|style|textarea)[\s>]/i.test(line) || /^\s{0,3}<!--/.test(line) || /^\s{0,3}<\?/.test(line) || /^\s{0,3}<![A-Z]/.test(line) || /^\s{0,3}<!\[CDATA\[/.test(line) || /^\s{0,3}<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i.test(
|
|
958
956
|
line
|
|
@@ -7608,10 +7606,11 @@ var Element = class extends HTMLElement {
|
|
|
7608
7606
|
this.appliedClasses = [];
|
|
7609
7607
|
this.customClass = "";
|
|
7610
7608
|
this.hasAutofocus = false;
|
|
7609
|
+
this.hasEditable = true;
|
|
7611
7610
|
this.shadowRootElement = this.attachShadow({ mode: "open" });
|
|
7612
7611
|
}
|
|
7613
7612
|
static get observedAttributes() {
|
|
7614
|
-
return ["class", "autofocus"];
|
|
7613
|
+
return ["class", "autofocus", "editable"];
|
|
7615
7614
|
}
|
|
7616
7615
|
get value() {
|
|
7617
7616
|
return this.ast.text;
|
|
@@ -7622,6 +7621,7 @@ var Element = class extends HTMLElement {
|
|
|
7622
7621
|
this.ast.setText(value);
|
|
7623
7622
|
this.renderDOM();
|
|
7624
7623
|
this.setAutoFocus();
|
|
7624
|
+
this.setEditable();
|
|
7625
7625
|
this.hasAcceptedExternalValue = true;
|
|
7626
7626
|
}
|
|
7627
7627
|
}
|
|
@@ -7642,15 +7642,20 @@ var Element = class extends HTMLElement {
|
|
|
7642
7642
|
return;
|
|
7643
7643
|
}
|
|
7644
7644
|
if (name === "autofocus") {
|
|
7645
|
-
this.hasAutofocus =
|
|
7645
|
+
this.hasAutofocus = newValue === "" || newValue === "true" || newValue === "1";
|
|
7646
7646
|
this.setAutoFocus();
|
|
7647
7647
|
return;
|
|
7648
7648
|
}
|
|
7649
|
+
if (name === "editable") {
|
|
7650
|
+
this.hasEditable = newValue === "" || newValue === "true" || newValue === "1";
|
|
7651
|
+
this.setEditable();
|
|
7652
|
+
return;
|
|
7653
|
+
}
|
|
7649
7654
|
}
|
|
7650
7655
|
connectedCallback() {
|
|
7651
7656
|
const attrValue = this.getAttribute("value") ?? "";
|
|
7652
|
-
this.hasAutofocus = this.hasAttribute("autofocus");
|
|
7653
7657
|
this.customClass = (this.getAttribute("class") ?? "").trim();
|
|
7658
|
+
this.hasAutofocus = this.hasAttribute("autofocus");
|
|
7654
7659
|
this.ast.setText(attrValue);
|
|
7655
7660
|
this.addStyles();
|
|
7656
7661
|
this.addDOM();
|
|
@@ -7665,6 +7670,7 @@ var Element = class extends HTMLElement {
|
|
|
7665
7670
|
this.interaction.attach();
|
|
7666
7671
|
this.renderDOM();
|
|
7667
7672
|
this.setAutoFocus();
|
|
7673
|
+
this.setEditable();
|
|
7668
7674
|
}
|
|
7669
7675
|
disconnectedCallback() {
|
|
7670
7676
|
this.interaction?.detach();
|
|
@@ -7687,10 +7693,10 @@ var Element = class extends HTMLElement {
|
|
|
7687
7693
|
if (this.rootElement) return;
|
|
7688
7694
|
const div = document.createElement("div");
|
|
7689
7695
|
div.classList.add("element");
|
|
7690
|
-
div.contentEditable = "true";
|
|
7691
7696
|
this.shadowRootElement.appendChild(div);
|
|
7692
7697
|
this.rootElement = div;
|
|
7693
7698
|
this.applyClass();
|
|
7699
|
+
this.setEditable();
|
|
7694
7700
|
}
|
|
7695
7701
|
applyClass() {
|
|
7696
7702
|
if (!this.rootElement) return;
|
|
@@ -7714,6 +7720,11 @@ var Element = class extends HTMLElement {
|
|
|
7714
7720
|
setAutoFocus() {
|
|
7715
7721
|
if (this.hasAutofocus && this.rootElement && this.select) this.select.autoFocus();
|
|
7716
7722
|
}
|
|
7723
|
+
setEditable() {
|
|
7724
|
+
if (this.rootElement) {
|
|
7725
|
+
this.rootElement.contentEditable = this.hasEditable ? "true" : "false";
|
|
7726
|
+
}
|
|
7727
|
+
}
|
|
7717
7728
|
};
|
|
7718
7729
|
var element_default = Element;
|
|
7719
7730
|
|