@limetech/lime-elements 40.12.1 → 40.12.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/CHANGELOG.md +8 -0
- package/dist/cjs/lime-elements.cjs.js +1 -1
- package/dist/cjs/limel-file-viewer.cjs.entry.js +75 -12
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +280 -121
- package/dist/cjs/limel-text-editor.cjs.entry.js +4 -7
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.js +196 -4
- package/dist/collection/components/text-editor/text-editor.js +5 -7
- package/dist/esm/lime-elements.js +1 -1
- package/dist/esm/limel-file-viewer.entry.js +75 -12
- package/dist/esm/limel-prosemirror-adapter.entry.js +280 -121
- package/dist/esm/limel-text-editor.entry.js +4 -7
- package/dist/esm/loader.js +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/p-074275f4.entry.js +1 -0
- package/dist/lime-elements/p-b609552e.entry.js +1 -0
- package/dist/lime-elements/{p-e247e9fe.entry.js → p-fb15f608.entry.js} +1 -1
- package/dist/types/components/text-editor/prosemirror-adapter/prosemirror-adapter.d.ts +34 -0
- package/dist/types/components/text-editor/text-editor.d.ts +1 -3
- package/dist/types/components.d.ts +53 -0
- package/package.json +3 -3
- package/dist/lime-elements/p-0e662a3c.entry.js +0 -1
- package/dist/lime-elements/p-5a15606a.entry.js +0 -1
|
@@ -18460,114 +18460,141 @@ function list (state, startLine, endLine, silent) {
|
|
|
18460
18460
|
return true
|
|
18461
18461
|
}
|
|
18462
18462
|
|
|
18463
|
-
|
|
18464
|
-
|
|
18465
|
-
let max = state.eMarks[startLine];
|
|
18466
|
-
let nextLine = startLine + 1;
|
|
18467
|
-
|
|
18468
|
-
// if it's indented more than 3 spaces, it should be a code block
|
|
18469
|
-
if (state.sCount[startLine] - state.blkIndent >= 4) { return false }
|
|
18463
|
+
// CommonMark limits reference labels to 999 Unicode code points.
|
|
18464
|
+
const MAX_LABEL_LENGTH = 999;
|
|
18470
18465
|
|
|
18471
|
-
|
|
18466
|
+
function countCodePoints (str) {
|
|
18467
|
+
let length = str.length;
|
|
18472
18468
|
|
|
18473
|
-
|
|
18474
|
-
const
|
|
18469
|
+
for (let i = 0; i < str.length - 1; i++) {
|
|
18470
|
+
const high = str.charCodeAt(i);
|
|
18471
|
+
if (high < 0xD800 || high > 0xDBFF) { continue }
|
|
18475
18472
|
|
|
18476
|
-
|
|
18477
|
-
|
|
18478
|
-
|
|
18473
|
+
const low = str.charCodeAt(i + 1);
|
|
18474
|
+
if (low >= 0xDC00 && low <= 0xDFFF) {
|
|
18475
|
+
length--;
|
|
18476
|
+
i++;
|
|
18479
18477
|
}
|
|
18478
|
+
}
|
|
18480
18479
|
|
|
18481
|
-
|
|
18480
|
+
return length
|
|
18481
|
+
}
|
|
18482
18482
|
|
|
18483
|
-
|
|
18484
|
-
|
|
18485
|
-
|
|
18483
|
+
// Exclusive end offset of the line, after its newline if present
|
|
18484
|
+
function lineEnd (state, line) {
|
|
18485
|
+
return Math.min(state.eMarks[line] + 1, state.src.length)
|
|
18486
|
+
}
|
|
18486
18487
|
|
|
18487
|
-
|
|
18488
|
-
|
|
18489
|
-
|
|
18490
|
-
|
|
18491
|
-
|
|
18492
|
-
|
|
18493
|
-
|
|
18494
|
-
|
|
18495
|
-
|
|
18496
|
-
|
|
18497
|
-
|
|
18498
|
-
|
|
18499
|
-
|
|
18500
|
-
|
|
18501
|
-
}
|
|
18502
|
-
}
|
|
18488
|
+
// Returns -1 if the reference can't continue on this line
|
|
18489
|
+
function getNextLinePos (state, nextLine) {
|
|
18490
|
+
const endLine = state.lineMax;
|
|
18491
|
+
|
|
18492
|
+
if (nextLine >= endLine || state.isEmpty(nextLine)) {
|
|
18493
|
+
// empty line or end of input
|
|
18494
|
+
return -1
|
|
18495
|
+
}
|
|
18496
|
+
|
|
18497
|
+
let isContinuation = false;
|
|
18498
|
+
|
|
18499
|
+
// this would be a code block normally, but after paragraph
|
|
18500
|
+
// it's considered a lazy continuation regardless of what's there
|
|
18501
|
+
if (state.sCount[nextLine] - state.blkIndent > 3) { isContinuation = true; }
|
|
18503
18502
|
|
|
18504
|
-
|
|
18505
|
-
|
|
18506
|
-
|
|
18507
|
-
|
|
18503
|
+
// quirk for blockquotes, this line should already be checked by that rule
|
|
18504
|
+
if (state.sCount[nextLine] < 0) { isContinuation = true; }
|
|
18505
|
+
|
|
18506
|
+
if (!isContinuation) {
|
|
18507
|
+
const terminatorRules = state.md.block.ruler.getRules('reference');
|
|
18508
|
+
const oldParentType = state.parentType;
|
|
18509
|
+
state.parentType = 'reference';
|
|
18510
|
+
|
|
18511
|
+
// Some tags can terminate paragraph without empty line.
|
|
18512
|
+
let terminate = false;
|
|
18513
|
+
for (let i = 0, l = terminatorRules.length; i < l; i++) {
|
|
18514
|
+
if (terminatorRules[i](state, nextLine, endLine, true)) {
|
|
18515
|
+
terminate = true;
|
|
18516
|
+
break
|
|
18508
18517
|
}
|
|
18509
18518
|
}
|
|
18510
18519
|
|
|
18511
|
-
|
|
18512
|
-
|
|
18513
|
-
|
|
18514
|
-
|
|
18515
|
-
|
|
18520
|
+
state.parentType = oldParentType;
|
|
18521
|
+
if (terminate) {
|
|
18522
|
+
// terminated by another block
|
|
18523
|
+
return -1
|
|
18524
|
+
}
|
|
18516
18525
|
}
|
|
18517
18526
|
|
|
18518
|
-
|
|
18527
|
+
return state.bMarks[nextLine] + state.tShift[nextLine]
|
|
18528
|
+
}
|
|
18529
|
+
|
|
18530
|
+
function reference (state, startLine, _endLine, silent) {
|
|
18531
|
+
const src = state.src;
|
|
18532
|
+
let pos = state.bMarks[startLine] + state.tShift[startLine];
|
|
18533
|
+
let nextLine = startLine + 1;
|
|
18534
|
+
|
|
18535
|
+
// if it's indented more than 3 spaces, it should be a code block
|
|
18536
|
+
if (state.sCount[startLine] - state.blkIndent >= 4) { return false }
|
|
18537
|
+
|
|
18538
|
+
if (src.charCodeAt(pos) !== 0x5B/* [ */) { return false }
|
|
18539
|
+
|
|
18540
|
+
// Scan the source directly: indexing a string after each appended line
|
|
18541
|
+
// can make V8 copy the accumulated prefix on every continuation.
|
|
18542
|
+
let max = lineEnd(state, startLine);
|
|
18519
18543
|
|
|
18520
|
-
|
|
18544
|
+
let rawLabel = '';
|
|
18521
18545
|
let labelEnd = -1;
|
|
18546
|
+
let segmentStart = ++pos;
|
|
18522
18547
|
|
|
18523
|
-
|
|
18524
|
-
|
|
18525
|
-
|
|
18526
|
-
|
|
18527
|
-
|
|
18548
|
+
while (pos < max) {
|
|
18549
|
+
if (rawLabel.length + pos - segmentStart > MAX_LABEL_LENGTH * 2) { return false }
|
|
18550
|
+
|
|
18551
|
+
let ch = src.charCodeAt(pos);
|
|
18552
|
+
if (ch === 0x5B /* [ */) { return false }
|
|
18553
|
+
if (ch === 0x5D /* ] */) {
|
|
18528
18554
|
labelEnd = pos;
|
|
18529
18555
|
break
|
|
18530
|
-
} else if (ch === 0x0A /* \n */) {
|
|
18531
|
-
const lineContent = getNextLine(nextLine);
|
|
18532
|
-
if (lineContent !== null) {
|
|
18533
|
-
str += lineContent;
|
|
18534
|
-
max = str.length;
|
|
18535
|
-
nextLine++;
|
|
18536
|
-
}
|
|
18537
|
-
} else if (ch === 0x5C /* \ */) {
|
|
18538
|
-
pos++;
|
|
18539
|
-
if (pos < max && str.charCodeAt(pos) === 0x0A) {
|
|
18540
|
-
const lineContent = getNextLine(nextLine);
|
|
18541
|
-
if (lineContent !== null) {
|
|
18542
|
-
str += lineContent;
|
|
18543
|
-
max = str.length;
|
|
18544
|
-
nextLine++;
|
|
18545
|
-
}
|
|
18546
|
-
}
|
|
18547
18556
|
}
|
|
18557
|
+
if (ch === 0x5C /* \ */) { ch = src.charCodeAt(++pos); }
|
|
18558
|
+
|
|
18559
|
+
if (ch === 0x0A /* \n */ && pos < max) {
|
|
18560
|
+
const nextPos = getNextLinePos(state, nextLine);
|
|
18561
|
+
if (nextPos < 0) { return false }
|
|
18562
|
+
rawLabel += src.slice(segmentStart, max);
|
|
18563
|
+
pos = segmentStart = nextPos;
|
|
18564
|
+
max = lineEnd(state, nextLine++);
|
|
18565
|
+
continue
|
|
18566
|
+
}
|
|
18567
|
+
pos++;
|
|
18548
18568
|
}
|
|
18549
18569
|
|
|
18550
|
-
if (labelEnd < 0 ||
|
|
18570
|
+
if (labelEnd < 0 || src.charCodeAt(labelEnd + 1) !== 0x3A/* : */) { return false }
|
|
18571
|
+
|
|
18572
|
+
rawLabel += src.slice(segmentStart, labelEnd);
|
|
18573
|
+
|
|
18574
|
+
if (rawLabel.length > MAX_LABEL_LENGTH && countCodePoints(rawLabel) > MAX_LABEL_LENGTH) {
|
|
18575
|
+
return false
|
|
18576
|
+
}
|
|
18551
18577
|
|
|
18552
18578
|
// [label]: destination 'title'
|
|
18553
18579
|
// ^^^ skip optional whitespace here
|
|
18554
|
-
|
|
18555
|
-
|
|
18580
|
+
pos = labelEnd + 2;
|
|
18581
|
+
while (pos < max) {
|
|
18582
|
+
const ch = src.charCodeAt(pos);
|
|
18556
18583
|
if (ch === 0x0A) {
|
|
18557
|
-
const
|
|
18558
|
-
if (
|
|
18559
|
-
|
|
18560
|
-
|
|
18561
|
-
|
|
18562
|
-
|
|
18563
|
-
} else
|
|
18584
|
+
const nextPos = getNextLinePos(state, nextLine);
|
|
18585
|
+
if (nextPos < 0) { break }
|
|
18586
|
+
pos = nextPos;
|
|
18587
|
+
max = lineEnd(state, nextLine++);
|
|
18588
|
+
} else if (isSpace(ch)) {
|
|
18589
|
+
pos++;
|
|
18590
|
+
} else {
|
|
18564
18591
|
break
|
|
18565
18592
|
}
|
|
18566
18593
|
}
|
|
18567
18594
|
|
|
18568
18595
|
// [label]: destination 'title'
|
|
18569
18596
|
// ^^^^^^^^^^^ parse this
|
|
18570
|
-
const destRes = state.md.helpers.parseLinkDestination(
|
|
18597
|
+
const destRes = state.md.helpers.parseLinkDestination(src, pos, max);
|
|
18571
18598
|
if (!destRes.ok) { return false }
|
|
18572
18599
|
|
|
18573
18600
|
const href = state.md.normalizeLink(destRes.str);
|
|
@@ -18577,76 +18604,77 @@ function reference (state, startLine, _endLine, silent) {
|
|
|
18577
18604
|
|
|
18578
18605
|
// save cursor state, we could require to rollback later
|
|
18579
18606
|
const destEndPos = pos;
|
|
18607
|
+
const destEndMax = max;
|
|
18580
18608
|
const destEndLineNo = nextLine;
|
|
18581
18609
|
|
|
18582
18610
|
// [label]: destination 'title'
|
|
18583
18611
|
// ^^^ skipping those spaces
|
|
18584
|
-
|
|
18585
|
-
|
|
18586
|
-
const ch = str.charCodeAt(pos);
|
|
18612
|
+
while (pos < max) {
|
|
18613
|
+
const ch = src.charCodeAt(pos);
|
|
18587
18614
|
if (ch === 0x0A) {
|
|
18588
|
-
const
|
|
18589
|
-
if (
|
|
18590
|
-
|
|
18591
|
-
|
|
18592
|
-
|
|
18593
|
-
|
|
18594
|
-
} else
|
|
18615
|
+
const nextPos = getNextLinePos(state, nextLine);
|
|
18616
|
+
if (nextPos < 0) { break }
|
|
18617
|
+
pos = nextPos;
|
|
18618
|
+
max = lineEnd(state, nextLine++);
|
|
18619
|
+
} else if (isSpace(ch)) {
|
|
18620
|
+
pos++;
|
|
18621
|
+
} else {
|
|
18595
18622
|
break
|
|
18596
18623
|
}
|
|
18597
18624
|
}
|
|
18598
18625
|
|
|
18599
18626
|
// [label]: destination 'title'
|
|
18600
18627
|
// ^^^^^^^ parse this
|
|
18601
|
-
|
|
18628
|
+
const titleStart = pos;
|
|
18629
|
+
let titleRes = state.md.helpers.parseLinkTitle(src, pos, max);
|
|
18602
18630
|
while (titleRes.can_continue) {
|
|
18603
|
-
const
|
|
18604
|
-
if (
|
|
18605
|
-
|
|
18606
|
-
|
|
18607
|
-
|
|
18608
|
-
nextLine++;
|
|
18609
|
-
titleRes = state.md.helpers.parseLinkTitle(str, pos, max, titleRes);
|
|
18631
|
+
const nextPos = getNextLinePos(state, nextLine);
|
|
18632
|
+
if (nextPos < 0) break
|
|
18633
|
+
pos = nextPos;
|
|
18634
|
+
max = lineEnd(state, nextLine++);
|
|
18635
|
+
titleRes = state.md.helpers.parseLinkTitle(src, pos, max, titleRes);
|
|
18610
18636
|
}
|
|
18611
18637
|
let title;
|
|
18612
18638
|
|
|
18613
|
-
if (
|
|
18639
|
+
if (titleStart !== destEndPos && titleRes.ok) {
|
|
18614
18640
|
title = titleRes.str;
|
|
18615
18641
|
pos = titleRes.pos;
|
|
18616
18642
|
} else {
|
|
18617
18643
|
title = '';
|
|
18618
18644
|
pos = destEndPos;
|
|
18645
|
+
max = destEndMax;
|
|
18619
18646
|
nextLine = destEndLineNo;
|
|
18620
18647
|
}
|
|
18621
18648
|
|
|
18622
18649
|
// skip trailing spaces until the rest of the line
|
|
18623
18650
|
while (pos < max) {
|
|
18624
|
-
const ch =
|
|
18651
|
+
const ch = src.charCodeAt(pos);
|
|
18625
18652
|
if (!isSpace(ch)) { break }
|
|
18626
18653
|
pos++;
|
|
18627
18654
|
}
|
|
18628
18655
|
|
|
18629
|
-
if (pos < max &&
|
|
18656
|
+
if (pos < max && src.charCodeAt(pos) !== 0x0A) {
|
|
18630
18657
|
if (title) {
|
|
18631
18658
|
// garbage at the end of the line after title,
|
|
18632
18659
|
// but it could still be a valid reference if we roll back
|
|
18633
18660
|
title = '';
|
|
18634
18661
|
pos = destEndPos;
|
|
18662
|
+
max = destEndMax;
|
|
18635
18663
|
nextLine = destEndLineNo;
|
|
18636
18664
|
while (pos < max) {
|
|
18637
|
-
const ch =
|
|
18665
|
+
const ch = src.charCodeAt(pos);
|
|
18638
18666
|
if (!isSpace(ch)) { break }
|
|
18639
18667
|
pos++;
|
|
18640
18668
|
}
|
|
18641
18669
|
}
|
|
18642
18670
|
}
|
|
18643
18671
|
|
|
18644
|
-
if (pos < max &&
|
|
18672
|
+
if (pos < max && src.charCodeAt(pos) !== 0x0A) {
|
|
18645
18673
|
// garbage at the end of the line
|
|
18646
18674
|
return false
|
|
18647
18675
|
}
|
|
18648
18676
|
|
|
18649
|
-
const label = normalizeReference(
|
|
18677
|
+
const label = normalizeReference(rawLabel);
|
|
18650
18678
|
if (!label) {
|
|
18651
18679
|
// CommonMark 0.20 disallows empty labels
|
|
18652
18680
|
return false
|
|
@@ -18750,13 +18778,6 @@ const attribute = '(?:\\s+' + attr_name + '(?:\\s*=\\s*' + attr_value + ')?)';
|
|
|
18750
18778
|
const open_tag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>';
|
|
18751
18779
|
|
|
18752
18780
|
const close_tag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>';
|
|
18753
|
-
const comment = '<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->';
|
|
18754
|
-
const processing = '<[?][\\s\\S]*?[?]>';
|
|
18755
|
-
const declaration = '<![A-Za-z][^>]*>';
|
|
18756
|
-
const cdata = '<!\\[CDATA\\[[\\s\\S]*?\\]\\]>';
|
|
18757
|
-
|
|
18758
|
-
const HTML_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + '|' + comment +
|
|
18759
|
-
'|' + processing + '|' + declaration + '|' + cdata + ')');
|
|
18760
18781
|
const HTML_OPEN_CLOSE_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + ')');
|
|
18761
18782
|
|
|
18762
18783
|
// HTML block
|
|
@@ -19171,6 +19192,10 @@ function StateInline (src, md, env, outTokens) {
|
|
|
19171
19192
|
this.backticks = {};
|
|
19172
19193
|
this.backticksScanned = false;
|
|
19173
19194
|
|
|
19195
|
+
// Set when html comment / PI / declaration / CDATA has no terminator,
|
|
19196
|
+
// to skip further scans of these constructs
|
|
19197
|
+
this.skipHtmlSpecial = false;
|
|
19198
|
+
|
|
19174
19199
|
// Counter used to disable inline linkify-it execution
|
|
19175
19200
|
// inside <a> and markdown links
|
|
19176
19201
|
this.linkLevel = 0;
|
|
@@ -20265,6 +20290,43 @@ function isLetter (ch) {
|
|
|
20265
20290
|
return (lc >= 0x61/* a */) && (lc <= 0x7a/* z */)
|
|
20266
20291
|
}
|
|
20267
20292
|
|
|
20293
|
+
// Comment, processing instruction, declaration or CDATA: fixed opener,
|
|
20294
|
+
// then everything up to the first terminator. Returns end position or -1.
|
|
20295
|
+
function scanSpecial (state, pos) {
|
|
20296
|
+
const src = state.src;
|
|
20297
|
+
let start;
|
|
20298
|
+
let terminator;
|
|
20299
|
+
|
|
20300
|
+
if (src.startsWith('<!--', pos)) {
|
|
20301
|
+
if (src.startsWith('>', pos + 4)) { return pos + 5 }
|
|
20302
|
+
if (src.startsWith('->', pos + 4)) { return pos + 6 }
|
|
20303
|
+
start = pos + 4;
|
|
20304
|
+
terminator = '-->';
|
|
20305
|
+
} else if (src.startsWith('<![CDATA[', pos)) {
|
|
20306
|
+
start = pos + 9;
|
|
20307
|
+
terminator = ']]>';
|
|
20308
|
+
} else if (src.charCodeAt(pos + 1) === 0x3F/* ? */) {
|
|
20309
|
+
start = pos + 2;
|
|
20310
|
+
terminator = '?>';
|
|
20311
|
+
} else if (isLetter(src.charCodeAt(pos + 2))) {
|
|
20312
|
+
start = pos + 3;
|
|
20313
|
+
terminator = '>';
|
|
20314
|
+
} else {
|
|
20315
|
+
return -1
|
|
20316
|
+
}
|
|
20317
|
+
|
|
20318
|
+
if (state.skipHtmlSpecial) { return -1 }
|
|
20319
|
+
|
|
20320
|
+
const end = src.indexOf(terminator, start);
|
|
20321
|
+
if (end < 0) {
|
|
20322
|
+
// One flag for all constructs to keep code simple. Valid constructs after
|
|
20323
|
+
// an unclosed one in the same paragraph become text, that's acceptable.
|
|
20324
|
+
state.skipHtmlSpecial = true;
|
|
20325
|
+
return -1
|
|
20326
|
+
}
|
|
20327
|
+
return end + terminator.length
|
|
20328
|
+
}
|
|
20329
|
+
|
|
20268
20330
|
function html_inline (state, silent) {
|
|
20269
20331
|
if (!state.md.options.html) { return false }
|
|
20270
20332
|
|
|
@@ -20276,26 +20338,28 @@ function html_inline (state, silent) {
|
|
|
20276
20338
|
return false
|
|
20277
20339
|
}
|
|
20278
20340
|
|
|
20279
|
-
|
|
20341
|
+
let end;
|
|
20280
20342
|
const ch = state.src.charCodeAt(pos + 1);
|
|
20281
|
-
|
|
20282
|
-
|
|
20283
|
-
|
|
20284
|
-
|
|
20343
|
+
|
|
20344
|
+
if (ch === 0x21/* ! */ || ch === 0x3F/* ? */) {
|
|
20345
|
+
end = scanSpecial(state, pos);
|
|
20346
|
+
} else if (ch === 0x2F/* / */ || isLetter(ch)) {
|
|
20347
|
+
const match = state.src.slice(pos).match(HTML_OPEN_CLOSE_TAG_RE);
|
|
20348
|
+
end = match ? pos + match[0].length : -1;
|
|
20349
|
+
} else {
|
|
20285
20350
|
return false
|
|
20286
20351
|
}
|
|
20287
20352
|
|
|
20288
|
-
|
|
20289
|
-
if (!match) { return false }
|
|
20353
|
+
if (end < 0) { return false }
|
|
20290
20354
|
|
|
20291
20355
|
if (!silent) {
|
|
20292
20356
|
const token = state.push('html_inline', '', 0);
|
|
20293
|
-
token.content =
|
|
20357
|
+
token.content = state.src.slice(pos, end);
|
|
20294
20358
|
|
|
20295
20359
|
if (isLinkOpen(token.content)) state.linkLevel++;
|
|
20296
20360
|
if (isLinkClose(token.content)) state.linkLevel--;
|
|
20297
20361
|
}
|
|
20298
|
-
state.pos
|
|
20362
|
+
state.pos = end;
|
|
20299
20363
|
return true
|
|
20300
20364
|
}
|
|
20301
20365
|
|
|
@@ -28318,6 +28382,15 @@ const ProsemirrorAdapter = class {
|
|
|
28318
28382
|
* Specifies the visual appearance of the editor.
|
|
28319
28383
|
*/
|
|
28320
28384
|
this.ui = 'standard';
|
|
28385
|
+
/**
|
|
28386
|
+
* Set to `true` to indicate that the editable area is required.
|
|
28387
|
+
*/
|
|
28388
|
+
this.required = false;
|
|
28389
|
+
/**
|
|
28390
|
+
* Set to `true` to indicate that the current value of the editable area
|
|
28391
|
+
* is invalid.
|
|
28392
|
+
*/
|
|
28393
|
+
this.invalid = false;
|
|
28321
28394
|
this.actionBarItems = [];
|
|
28322
28395
|
this.link = { href: 'https://' };
|
|
28323
28396
|
/**
|
|
@@ -28328,6 +28401,7 @@ const ProsemirrorAdapter = class {
|
|
|
28328
28401
|
this.transactionFired = false;
|
|
28329
28402
|
this.lastClickedPos = null;
|
|
28330
28403
|
this.focusRestoreTimeout = null;
|
|
28404
|
+
this.hadFocusWhenDisabled = false;
|
|
28331
28405
|
this.metadata = { images: [], links: [] };
|
|
28332
28406
|
/**
|
|
28333
28407
|
* Used to stop change event emitting as result of getting updated value from consumer
|
|
@@ -28346,6 +28420,7 @@ const ProsemirrorAdapter = class {
|
|
|
28346
28420
|
}
|
|
28347
28421
|
return newItem;
|
|
28348
28422
|
};
|
|
28423
|
+
this.isEditable = () => !this.disabled;
|
|
28349
28424
|
this.updateActiveActionBarItems = (activeTypes, allowedTypes) => {
|
|
28350
28425
|
this.actionBarItems = getTextEditorMenuItems()
|
|
28351
28426
|
.map(this.getTranslatedItem)
|
|
@@ -28391,8 +28466,7 @@ const ProsemirrorAdapter = class {
|
|
|
28391
28466
|
this.handleCancelLinkMenu = (event) => {
|
|
28392
28467
|
event.preventDefault();
|
|
28393
28468
|
event.stopPropagation();
|
|
28394
|
-
this.
|
|
28395
|
-
this.link = { text: '', href: 'https://' };
|
|
28469
|
+
this.closeLinkMenu();
|
|
28396
28470
|
};
|
|
28397
28471
|
this.handleSaveLinkMenu = () => {
|
|
28398
28472
|
this.isLinkMenuOpen = false;
|
|
@@ -28509,6 +28583,20 @@ const ProsemirrorAdapter = class {
|
|
|
28509
28583
|
}
|
|
28510
28584
|
await this.updateView('');
|
|
28511
28585
|
}
|
|
28586
|
+
watchEditableAttributes() {
|
|
28587
|
+
this.updateEditableProps();
|
|
28588
|
+
}
|
|
28589
|
+
watchDisabled(disabled) {
|
|
28590
|
+
var _a;
|
|
28591
|
+
if (disabled) {
|
|
28592
|
+
this.hadFocusWhenDisabled = !!((_a = this.view) === null || _a === void 0 ? void 0 : _a.hasFocus());
|
|
28593
|
+
this.closeLinkMenu();
|
|
28594
|
+
}
|
|
28595
|
+
this.updateEditableProps();
|
|
28596
|
+
if (!disabled) {
|
|
28597
|
+
this.restoreFocus();
|
|
28598
|
+
}
|
|
28599
|
+
}
|
|
28512
28600
|
watchValue(newValue) {
|
|
28513
28601
|
if (!this.view) {
|
|
28514
28602
|
return;
|
|
@@ -28568,13 +28656,19 @@ const ProsemirrorAdapter = class {
|
|
|
28568
28656
|
(_e = this.view) === null || _e === void 0 ? void 0 : _e.destroy();
|
|
28569
28657
|
}
|
|
28570
28658
|
render() {
|
|
28571
|
-
return (index$1.h(index$1.Host, { key: '
|
|
28659
|
+
return (index$1.h(index$1.Host, { key: 'eff663aa0d2c0ce2906fc160a70691e78dbda774', onFocus: this.handleFocus }, index$1.h("div", { key: '71111267b9098261ca843516ae067443c7f40740', id: "editor" }), this.renderToolbar(), this.renderLinkMenu()));
|
|
28572
28660
|
}
|
|
28573
28661
|
renderToolbar() {
|
|
28574
28662
|
if (this.actionBarItems.length === 0 || this.ui === 'no-toolbar') {
|
|
28575
28663
|
return;
|
|
28576
28664
|
}
|
|
28577
|
-
return (index$1.h("div", { class: "toolbar" }, index$1.h("limel-action-bar", { ref: (el) => (this.actionBarElement = el), accessibleLabel: translations.translations.get('editor-menu.toolbar', this.language), actions: this.
|
|
28665
|
+
return (index$1.h("div", { class: "toolbar" }, index$1.h("limel-action-bar", { ref: (el) => (this.actionBarElement = el), accessibleLabel: translations.translations.get('editor-menu.toolbar', this.language), actions: this.getToolbarItems(), onItemSelected: this.handleActionBarItem })));
|
|
28666
|
+
}
|
|
28667
|
+
getToolbarItems() {
|
|
28668
|
+
if (!this.disabled) {
|
|
28669
|
+
return this.actionBarItems;
|
|
28670
|
+
}
|
|
28671
|
+
return this.actionBarItems.map((item) => isItem.isItem(item) ? Object.assign(Object.assign({}, item), { disabled: true }) : item);
|
|
28578
28672
|
}
|
|
28579
28673
|
renderLinkMenu() {
|
|
28580
28674
|
if (!this.isLinkMenuOpen) {
|
|
@@ -28614,6 +28708,8 @@ const ProsemirrorAdapter = class {
|
|
|
28614
28708
|
this.view = new EditorView(this.host.shadowRoot.querySelector('#editor'), {
|
|
28615
28709
|
state: this.createEditorState(initialDoc),
|
|
28616
28710
|
dispatchTransaction: this.handleTransaction,
|
|
28711
|
+
attributes: this.getEditableAttributes(),
|
|
28712
|
+
editable: this.isEditable,
|
|
28617
28713
|
});
|
|
28618
28714
|
this.view.dom.addEventListener('blur', this.handleBlur);
|
|
28619
28715
|
this.view.dom.addEventListener('mousedown', this.handleMouseDown);
|
|
@@ -28623,6 +28719,47 @@ const ProsemirrorAdapter = class {
|
|
|
28623
28719
|
// Initialize lastEmittedValue to prevent false change events
|
|
28624
28720
|
this.lastEmittedValue = this.contentConverter.serialize(this.view, this.schema);
|
|
28625
28721
|
}
|
|
28722
|
+
updateEditableProps() {
|
|
28723
|
+
var _a;
|
|
28724
|
+
(_a = this.view) === null || _a === void 0 ? void 0 : _a.setProps({
|
|
28725
|
+
attributes: this.getEditableAttributes(),
|
|
28726
|
+
editable: this.isEditable,
|
|
28727
|
+
});
|
|
28728
|
+
}
|
|
28729
|
+
restoreFocus() {
|
|
28730
|
+
var _a;
|
|
28731
|
+
const shouldRestore = this.hadFocusWhenDisabled &&
|
|
28732
|
+
document.activeElement === document.body;
|
|
28733
|
+
this.hadFocusWhenDisabled = false;
|
|
28734
|
+
if (shouldRestore) {
|
|
28735
|
+
(_a = this.view) === null || _a === void 0 ? void 0 : _a.focus();
|
|
28736
|
+
}
|
|
28737
|
+
}
|
|
28738
|
+
getEditableAttributes() {
|
|
28739
|
+
const attributes = {
|
|
28740
|
+
role: 'textbox',
|
|
28741
|
+
'aria-multiline': 'true',
|
|
28742
|
+
};
|
|
28743
|
+
if (this.accessibleLabel) {
|
|
28744
|
+
attributes['aria-label'] = this.accessibleLabel;
|
|
28745
|
+
}
|
|
28746
|
+
if (this.accessibleDescription) {
|
|
28747
|
+
attributes['aria-description'] = this.accessibleDescription;
|
|
28748
|
+
}
|
|
28749
|
+
if (this.accessiblePlaceholder) {
|
|
28750
|
+
attributes['aria-placeholder'] = this.accessiblePlaceholder;
|
|
28751
|
+
}
|
|
28752
|
+
if (this.required) {
|
|
28753
|
+
attributes['aria-required'] = 'true';
|
|
28754
|
+
}
|
|
28755
|
+
if (this.invalid) {
|
|
28756
|
+
attributes['aria-invalid'] = 'true';
|
|
28757
|
+
}
|
|
28758
|
+
if (this.disabled) {
|
|
28759
|
+
attributes['aria-disabled'] = 'true';
|
|
28760
|
+
}
|
|
28761
|
+
return attributes;
|
|
28762
|
+
}
|
|
28626
28763
|
initializeSchema() {
|
|
28627
28764
|
return buildEditorSchema({
|
|
28628
28765
|
customElements: this.customElements,
|
|
@@ -28704,9 +28841,31 @@ const ProsemirrorAdapter = class {
|
|
|
28704
28841
|
this.imageRemoved.emit(image);
|
|
28705
28842
|
}
|
|
28706
28843
|
}
|
|
28844
|
+
closeLinkMenu() {
|
|
28845
|
+
this.isLinkMenuOpen = false;
|
|
28846
|
+
this.link = { text: '', href: 'https://' };
|
|
28847
|
+
}
|
|
28707
28848
|
static get delegatesFocus() { return true; }
|
|
28708
28849
|
get host() { return index$1.getElement(this); }
|
|
28709
28850
|
static get watchers() { return {
|
|
28851
|
+
"accessibleLabel": [{
|
|
28852
|
+
"watchEditableAttributes": 0
|
|
28853
|
+
}],
|
|
28854
|
+
"accessibleDescription": [{
|
|
28855
|
+
"watchEditableAttributes": 0
|
|
28856
|
+
}],
|
|
28857
|
+
"accessiblePlaceholder": [{
|
|
28858
|
+
"watchEditableAttributes": 0
|
|
28859
|
+
}],
|
|
28860
|
+
"required": [{
|
|
28861
|
+
"watchEditableAttributes": 0
|
|
28862
|
+
}],
|
|
28863
|
+
"invalid": [{
|
|
28864
|
+
"watchEditableAttributes": 0
|
|
28865
|
+
}],
|
|
28866
|
+
"disabled": [{
|
|
28867
|
+
"watchDisabled": 0
|
|
28868
|
+
}],
|
|
28710
28869
|
"value": [{
|
|
28711
28870
|
"watchValue": 0
|
|
28712
28871
|
}]
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-BlsqxTB1.js');
|
|
4
|
-
var randomString = require('./random-string-CFCtFh5l.js');
|
|
5
4
|
|
|
6
5
|
const textEditorCss = () => `@charset "UTF-8";*{box-sizing:border-box}:host(limel-text-editor){--limel-notched-outline-z-index:2;--limel-prosemirror-adapter-toolbar-opacity:0.6;--limel-text-editor-padding:0.25rem 1rem 0.75rem 1rem;--limel-prosemirror-adapter-toolbar-grid-template-rows:1fr;--limel-prosemirror-adapter-toolbar-grid-template-rows-transition-duration:0.3s;--limel-prosemirror-adapter-toolbar-transition-timing-function:cubic-bezier( 0.19, 0.23, 0.26, 0.89 );position:relative;isolation:isolate;display:flex;flex-direction:column;width:100%;min-width:5rem;min-height:5rem;height:100%;max-height:var(--text-editor-max-height, calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)) - 4rem));padding:1px}:host(limel-text-editor) limel-notched-outline{height:100%}:host(limel-text-editor:focus-within),:host(limel-text-editor:not([ui=minimal]):hover){--limel-prosemirror-adapter-toolbar-opacity:1}:host(limel-text-editor[ui=minimal]:not(:focus-within)){--limel-prosemirror-adapter-toolbar-grid-template-rows:0fr;--limel-prosemirror-adapter-toolbar-grid-template-rows-transition-duration:0.46s;--limel-prosemirror-adapter-action-bar-padding-top-bottom:0;--limel-prosemirror-adapter-toolbar-opacity:0}:host(limel-text-editor[ui=minimal]:not(:focus-within)),:host(limel-text-editor[ui=no-toolbar]){--limel-text-editor-padding:0.75rem 1rem 0.75rem 1rem;--limel-text-editor-placeholder-top:0;min-height:2.5rem}:host(limel-text-editor[ui=minimal]:not(:focus-within)) limel-prosemirror-adapter,:host(limel-text-editor[ui=no-toolbar]) limel-prosemirror-adapter{min-height:2.5rem}:host(limel-text-editor:focus-within) .placeholder,:host(limel-text-editor:focus) .placeholder{opacity:0}:host(limel-text-editor[disabled]:not([disabled=false])) limel-prosemirror-adapter{cursor:not-allowed;opacity:0.4;pointer-events:none}:host(limel-text-editor[readonly]:not([readonly=false])){--limel-text-editor-padding:0.75rem 1rem 0.75rem 1rem;--limel-text-editor-placeholder-top:0}:host(limel-text-editor[readonly]:not([readonly=false])) limel-markdown{display:block;padding:var(--limel-text-editor-padding);overflow-y:auto;-webkit-overflow-scrolling:touch;height:100%}:host(limel-text-editor[readonly]:not([readonly=false])) limel-markdown:before,:host(limel-text-editor[readonly]:not([readonly=false])) limel-markdown:after{z-index:1;pointer-events:none;content:"";display:block;position:absolute;width:100%}:host(limel-text-editor[readonly]:not([readonly=false])) limel-markdown:after{height:1.75rem;top:0;background:linear-gradient(var(--text-editor-fade-out-background-color, rgb(var(--contrast-100))), transparent)}:host(limel-text-editor[readonly]:not([readonly=false])) limel-markdown:before{height:2rem;bottom:-0.25rem;background:linear-gradient(transparent, var(--text-editor-fade-out-background-color, rgb(var(--contrast-100))))}.placeholder{transition-property:top;transition-duration:var(--limel-prosemirror-adapter-toolbar-grid-template-rows-transition-duration);transition-timing-function:var(--limel-prosemirror-adapter-toolbar-transition-timing-function);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;pointer-events:none;position:absolute;top:var(--limel-text-editor-placeholder-top, 2.25rem);left:0;right:0;padding:var(--limel-text-editor-padding);font-style:italic;font-size:var(--limel-theme-default-font-size);color:rgb(var(--contrast-900))}limel-prosemirror-adapter{flex-grow:1;min-width:0;min-height:5rem;height:100%;max-height:100%;overflow:hidden auto;-webkit-overflow-scrolling:touch}:host(limel-text-editor:focus),:host(limel-text-editor:focus-visible),:host(limel-text-editor:focus-within){--limel-h-l-grid-template-rows-transition-speed:0.46s;--limel-h-l-grid-template-rows:1fr}:host(limel-text-editor){--limel-h-l-grid-template-rows-transition-speed:0.3s;--limel-h-l-grid-template-rows:0fr}:host(limel-text-editor:focus) limel-helper-line,:host(limel-text-editor:focus-visible) limel-helper-line,:host(limel-text-editor:focus-within) limel-helper-line,:host(limel-text-editor:hover) limel-helper-line{will-change:grid-template-rows}:host(limel-text-editor[allow-resize]) limel-prosemirror-adapter{resize:vertical}`;
|
|
7
6
|
|
|
@@ -100,7 +99,7 @@ const TextEditor = class {
|
|
|
100
99
|
if (!this.helperText) {
|
|
101
100
|
return;
|
|
102
101
|
}
|
|
103
|
-
return (index.h("limel-helper-line", { helperText: this.helperText,
|
|
102
|
+
return (index.h("limel-helper-line", { helperText: this.helperText, invalid: this.isInvalid() }));
|
|
104
103
|
};
|
|
105
104
|
this.isInvalid = () => {
|
|
106
105
|
if (this.readonly) {
|
|
@@ -127,8 +126,6 @@ const TextEditor = class {
|
|
|
127
126
|
event.stopPropagation();
|
|
128
127
|
this.imageRemoved.emit(event.detail);
|
|
129
128
|
};
|
|
130
|
-
this.helperTextId = randomString.createRandomString();
|
|
131
|
-
this.editorId = randomString.createRandomString();
|
|
132
129
|
}
|
|
133
130
|
/**
|
|
134
131
|
* Emits any pending `change` event immediately, instead of waiting
|
|
@@ -164,13 +161,13 @@ const TextEditor = class {
|
|
|
164
161
|
await ((_a = this.adapterElement) === null || _a === void 0 ? void 0 : _a.clear());
|
|
165
162
|
}
|
|
166
163
|
render() {
|
|
167
|
-
return (index.h(index.Host, { key: '
|
|
164
|
+
return (index.h(index.Host, { key: '5b5b70f3c96deae4375ae371c7ee5607ef0efb9b' }, index.h("limel-notched-outline", { key: '825ec7fc78846020315d4f06bd9d7cb64e22e043', label: this.label, required: this.required, invalid: this.invalid, disabled: this.disabled, readonly: this.readonly, hasValue: !!this.value, hasFloatingLabel: true }, this.renderEditor(), this.renderPlaceholder()), this.renderHelperLine()));
|
|
168
165
|
}
|
|
169
166
|
renderEditor() {
|
|
170
167
|
if (this.readonly) {
|
|
171
|
-
return
|
|
168
|
+
return index.h("limel-markdown", { slot: "content", value: this.value });
|
|
172
169
|
}
|
|
173
|
-
return (index.h("limel-prosemirror-adapter", { ref: (el) => (this.adapterElement = el), slot: "content",
|
|
170
|
+
return (index.h("limel-prosemirror-adapter", { ref: (el) => (this.adapterElement = el), slot: "content", accessibleLabel: this.label || this.placeholder, accessibleDescription: this.helperText, contentType: this.contentType, onChange: this.handleChange, onImagePasted: this.handleImagePasted, onImageRemoved: this.handleImageRemoved, onMetadataChange: this.handleMetadataChange, customElements: this.customElements, inlineImages: this.inlineImages, value: this.value, accessiblePlaceholder: this.placeholder, required: this.required, invalid: this.invalid, language: this.language, triggerCharacters: this.triggers, disabled: this.disabled, ui: this.ui }));
|
|
174
171
|
}
|
|
175
172
|
renderPlaceholder() {
|
|
176
173
|
if (!this.placeholder || this.value) {
|