markdown-komponents 0.3.1 → 0.3.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/index.html +10 -0
- package/kotlin-kotlin-stdlib.mjs +103 -3
- package/kotlin-kotlin-stdlib.mjs.map +1 -1
- package/markdown-komponents.mjs +63 -56
- package/markdown-komponents.mjs.map +1 -1
- package/package.json +1 -1
package/markdown-komponents.mjs
CHANGED
|
@@ -35,8 +35,12 @@ import {
|
|
|
35
35
|
ArrayList3it5z8td81qkl as ArrayList,
|
|
36
36
|
repeat2w4c6j8zoq09o as repeat,
|
|
37
37
|
trimIndent1qytc1wvt8suh as trimIndent,
|
|
38
|
+
trimStart5ewg8zf6cs5u as trimStart,
|
|
39
|
+
trimEnd17pt8cbotbalj as trimEnd,
|
|
40
|
+
takeLast2r8kr8e6g6hi7 as takeLast,
|
|
38
41
|
indexOfwa4w6635jewi as indexOf_0,
|
|
39
42
|
replace3le3ie7l9k8aq as replace,
|
|
43
|
+
removeSuffix3d61x5lsuvuho as removeSuffix,
|
|
40
44
|
drop3na99dw9feawf as drop,
|
|
41
45
|
RegexOption_MULTILINE_getInstance3caq4fchu5vfw as RegexOption_MULTILINE_getInstance,
|
|
42
46
|
startsWith26w8qjqapeeq6 as startsWith,
|
|
@@ -1528,6 +1532,23 @@ class InlineElement extends MarkdownComponent {
|
|
|
1528
1532
|
getMarkdown() {
|
|
1529
1533
|
return getMarkdownWithTextForElement(this);
|
|
1530
1534
|
}
|
|
1535
|
+
wrapMarkdownContentIn(marker) {
|
|
1536
|
+
var content = getMarkdownWithTextForElement(this);
|
|
1537
|
+
// Inline function 'kotlin.text.trim' call
|
|
1538
|
+
var trimmed = toString_0(trim(isCharSequence(content) ? content : THROW_CCE()));
|
|
1539
|
+
// Inline function 'kotlin.text.isEmpty' call
|
|
1540
|
+
if (charSequenceLength(trimmed) === 0)
|
|
1541
|
+
return marker + marker;
|
|
1542
|
+
var tmp = content.length;
|
|
1543
|
+
// Inline function 'kotlin.text.trimStart' call
|
|
1544
|
+
var tmp$ret$2 = toString_0(trimStart(isCharSequence(content) ? content : THROW_CCE()));
|
|
1545
|
+
var leading = take(content, tmp - tmp$ret$2.length | 0);
|
|
1546
|
+
var tmp_0 = content.length;
|
|
1547
|
+
// Inline function 'kotlin.text.trimEnd' call
|
|
1548
|
+
var tmp$ret$3 = toString_0(trimEnd(isCharSequence(content) ? content : THROW_CCE()));
|
|
1549
|
+
var trailing = takeLast(content, tmp_0 - tmp$ret$3.length | 0);
|
|
1550
|
+
return leading + marker + trimmed + marker + trailing;
|
|
1551
|
+
}
|
|
1531
1552
|
mergeWithPrevious(currentSelection) {
|
|
1532
1553
|
var tmp = this.parentNode;
|
|
1533
1554
|
var tmp0_safe_receiver = tmp instanceof MarkdownComponent ? tmp : null;
|
|
@@ -1602,8 +1623,40 @@ class ListItem extends ContainerElement {
|
|
|
1602
1623
|
return '';
|
|
1603
1624
|
}
|
|
1604
1625
|
tn() {
|
|
1605
|
-
var
|
|
1606
|
-
|
|
1626
|
+
var line = '';
|
|
1627
|
+
var nestedBlocks = '';
|
|
1628
|
+
// Inline function 'kotlin.collections.forEach' call
|
|
1629
|
+
var _iterator__ex2g4s = asList(this.childNodes).p();
|
|
1630
|
+
while (_iterator__ex2g4s.q()) {
|
|
1631
|
+
var element = _iterator__ex2g4s.r();
|
|
1632
|
+
var markdownElement = asMarkdownElement(element);
|
|
1633
|
+
var tmp;
|
|
1634
|
+
if (isInterface(element, MarkdownElementWithLevel)) {
|
|
1635
|
+
tmp = !(markdownElement == null);
|
|
1636
|
+
} else {
|
|
1637
|
+
tmp = false;
|
|
1638
|
+
}
|
|
1639
|
+
if (tmp)
|
|
1640
|
+
nestedBlocks = nestedBlocks + removeSuffix(markdownElement.getMarkdown(), '\n');
|
|
1641
|
+
else {
|
|
1642
|
+
if (!(markdownElement == null))
|
|
1643
|
+
line = line + markdownElement.getMarkdown();
|
|
1644
|
+
else {
|
|
1645
|
+
var tmp_0 = line;
|
|
1646
|
+
var tmp0_safe_receiver = element.textContent;
|
|
1647
|
+
var tmp_1;
|
|
1648
|
+
if (tmp0_safe_receiver == null) {
|
|
1649
|
+
tmp_1 = null;
|
|
1650
|
+
} else {
|
|
1651
|
+
// Inline function 'kotlin.text.trim' call
|
|
1652
|
+
tmp_1 = toString_0(trim(isCharSequence(tmp0_safe_receiver) ? tmp0_safe_receiver : THROW_CCE()));
|
|
1653
|
+
}
|
|
1654
|
+
var tmp1_elvis_lhs = tmp_1;
|
|
1655
|
+
line = tmp_0 + (tmp1_elvis_lhs == null ? '' : tmp1_elvis_lhs);
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
return line + '\n' + nestedBlocks;
|
|
1607
1660
|
}
|
|
1608
1661
|
normalizeContent() {
|
|
1609
1662
|
this.normalize();
|
|
@@ -1903,9 +1956,7 @@ class MarkdownEmphasis extends InlineElement {
|
|
|
1903
1956
|
element(tmp, 'i', MarkdownEmphasis$lambda);
|
|
1904
1957
|
}
|
|
1905
1958
|
getMarkdown() {
|
|
1906
|
-
|
|
1907
|
-
var this_0 = super.getMarkdown();
|
|
1908
|
-
return '*' + toString_0(trim(isCharSequence(this_0) ? this_0 : THROW_CCE())) + '*';
|
|
1959
|
+
return this.wrapMarkdownContentIn('*');
|
|
1909
1960
|
}
|
|
1910
1961
|
containsMarkdownTextContent() {
|
|
1911
1962
|
return true;
|
|
@@ -2442,9 +2493,7 @@ class MarkdownStrike extends InlineElement {
|
|
|
2442
2493
|
element(tmp, 'del', MarkdownStrike$lambda);
|
|
2443
2494
|
}
|
|
2444
2495
|
getMarkdown() {
|
|
2445
|
-
|
|
2446
|
-
var this_0 = super.getMarkdown();
|
|
2447
|
-
return '~~' + toString_0(trim(isCharSequence(this_0) ? this_0 : THROW_CCE())) + '~~';
|
|
2496
|
+
return this.wrapMarkdownContentIn('~~');
|
|
2448
2497
|
}
|
|
2449
2498
|
containsMarkdownTextContent() {
|
|
2450
2499
|
return true;
|
|
@@ -2465,9 +2514,7 @@ class MarkdownStrong extends InlineElement {
|
|
|
2465
2514
|
slot(this_0);
|
|
2466
2515
|
}
|
|
2467
2516
|
getMarkdown() {
|
|
2468
|
-
|
|
2469
|
-
var this_0 = super.getMarkdown();
|
|
2470
|
-
return '**' + toString_0(trim(isCharSequence(this_0) ? this_0 : THROW_CCE())) + '**';
|
|
2517
|
+
return this.wrapMarkdownContentIn('**');
|
|
2471
2518
|
}
|
|
2472
2519
|
mergeSameSiblings() {
|
|
2473
2520
|
return true;
|
|
@@ -4885,9 +4932,9 @@ function svgFor($this, icon) {
|
|
|
4885
4932
|
case 'break':
|
|
4886
4933
|
return '<svg viewBox="0 0 24 24" fill="currentColor" stroke="none">\n <rect x="3" y="11" width="18" height="2.5"/>\n <\/svg>';
|
|
4887
4934
|
case 'insert-photo':
|
|
4888
|
-
return '<svg viewBox="0
|
|
4935
|
+
return '<svg viewBox="0 -960 960 960" fill="currentColor" stroke="none">\n <path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z"/>\n <\/svg>';
|
|
4889
4936
|
case 'insert-link':
|
|
4890
|
-
return '<svg viewBox="0
|
|
4937
|
+
return '<svg viewBox="0 -960 960 960" fill="currentColor" stroke="none">\n <path d="M440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm200 160v-80h160q50 0 85-35t35-85q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 83-58.5 141.5T680-280H520Z"/>\n <\/svg>';
|
|
4891
4938
|
case 'code-block':
|
|
4892
4939
|
return '<svg viewBox="0 0 24 24" fill="currentColor" stroke="none">\n <text x="12" y="17" text-anchor="middle" font-size="12" font-family="monospace"></><\/text>\n <\/svg>';
|
|
4893
4940
|
case 'quote':
|
|
@@ -4904,26 +4951,6 @@ function Heading$renderHeading$lambda($this$element) {
|
|
|
4904
4951
|
slot($this$element);
|
|
4905
4952
|
return Unit_instance;
|
|
4906
4953
|
}
|
|
4907
|
-
function ListItem$getMarkdownWithTextForElement$lambda(child) {
|
|
4908
|
-
var tmp0_safe_receiver = asMarkdownElement(child);
|
|
4909
|
-
var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.getMarkdown();
|
|
4910
|
-
var tmp;
|
|
4911
|
-
if (tmp1_elvis_lhs == null) {
|
|
4912
|
-
var tmp2_safe_receiver = child.textContent;
|
|
4913
|
-
var tmp_0;
|
|
4914
|
-
if (tmp2_safe_receiver == null) {
|
|
4915
|
-
tmp_0 = null;
|
|
4916
|
-
} else {
|
|
4917
|
-
// Inline function 'kotlin.text.trim' call
|
|
4918
|
-
tmp_0 = toString_0(trim(isCharSequence(tmp2_safe_receiver) ? tmp2_safe_receiver : THROW_CCE()));
|
|
4919
|
-
}
|
|
4920
|
-
var tmp3_elvis_lhs = tmp_0;
|
|
4921
|
-
tmp = (tmp3_elvis_lhs == null ? '' : tmp3_elvis_lhs) + '\n';
|
|
4922
|
-
} else {
|
|
4923
|
-
tmp = tmp1_elvis_lhs;
|
|
4924
|
-
}
|
|
4925
|
-
return tmp;
|
|
4926
|
-
}
|
|
4927
4954
|
function MarkdownComponent$getMarkdown$lambda(child) {
|
|
4928
4955
|
var tmp0_safe_receiver = asMarkdownElement(child);
|
|
4929
4956
|
var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.getMarkdown();
|
|
@@ -5251,30 +5278,10 @@ function MarkdownParagraph$getMarkdown$lambda(child) {
|
|
|
5251
5278
|
tmp_0 = null;
|
|
5252
5279
|
} else {
|
|
5253
5280
|
// Inline function 'kotlin.text.replace' call
|
|
5254
|
-
tmp_0 = Regex.
|
|
5255
|
-
}
|
|
5256
|
-
var tmp1_safe_receiver = tmp_0;
|
|
5257
|
-
var tmp_1;
|
|
5258
|
-
if (tmp1_safe_receiver == null) {
|
|
5259
|
-
tmp_1 = null;
|
|
5260
|
-
} else {
|
|
5261
|
-
// Inline function 'kotlin.text.isEmpty' call
|
|
5262
|
-
tmp_1 = charSequenceLength(tmp1_safe_receiver) === 0;
|
|
5263
|
-
}
|
|
5264
|
-
if (tmp_1 === true) {
|
|
5265
|
-
tmp = '';
|
|
5266
|
-
} else {
|
|
5267
|
-
var tmp2_safe_receiver = child.textContent;
|
|
5268
|
-
var tmp_2;
|
|
5269
|
-
if (tmp2_safe_receiver == null) {
|
|
5270
|
-
tmp_2 = null;
|
|
5271
|
-
} else {
|
|
5272
|
-
// Inline function 'kotlin.text.replace' call
|
|
5273
|
-
tmp_2 = Regex.j8('^\\s+', RegexOption_MULTILINE_getInstance()).o8(tmp2_safe_receiver, ' ');
|
|
5274
|
-
}
|
|
5275
|
-
var tmp3_elvis_lhs = tmp_2;
|
|
5276
|
-
tmp = tmp3_elvis_lhs == null ? '' : tmp3_elvis_lhs;
|
|
5281
|
+
tmp_0 = Regex.j8('^\\s+', RegexOption_MULTILINE_getInstance()).o8(tmp0_safe_receiver, ' ');
|
|
5277
5282
|
}
|
|
5283
|
+
var tmp1_elvis_lhs = tmp_0;
|
|
5284
|
+
tmp = tmp1_elvis_lhs == null ? '' : tmp1_elvis_lhs;
|
|
5278
5285
|
}
|
|
5279
5286
|
return tmp;
|
|
5280
5287
|
}
|