@lukso/web-components 1.160.4 → 1.161.1
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.
|
@@ -534,6 +534,24 @@ exports.LuksoMarkdownEditor = class LuksoMarkdownEditor extends shared_tailwindE
|
|
|
534
534
|
this.accessibilityCheckTimeout = null;
|
|
535
535
|
}, this.ACCESSIBILITY_CHECK_DELAY);
|
|
536
536
|
}
|
|
537
|
+
/**
|
|
538
|
+
* Clean up empty color spans from the value.
|
|
539
|
+
* This removes spans like <span style="color: #xxx"></span> with no content.
|
|
540
|
+
*/
|
|
541
|
+
cleanupEmptyColorSpans() {
|
|
542
|
+
const emptyColorSpanRegex = /<span style="color: [^"]+"><\/span>/g;
|
|
543
|
+
const cleanedValue = this.value.replace(emptyColorSpanRegex, "");
|
|
544
|
+
if (cleanedValue !== this.value) {
|
|
545
|
+
this.value = cleanedValue;
|
|
546
|
+
const textarea = this.textareaEl?.shadowRoot?.querySelector("textarea");
|
|
547
|
+
if (textarea) {
|
|
548
|
+
const currentPos = textarea.selectionStart ?? 0;
|
|
549
|
+
textarea.value = cleanedValue;
|
|
550
|
+
const newPos = Math.min(currentPos, cleanedValue.length);
|
|
551
|
+
textarea.setSelectionRange(newPos, newPos);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
537
555
|
/**
|
|
538
556
|
* Unified helper that ensures both active format state and change events are properly
|
|
539
557
|
* emitted after any value mutation. This replaces the scattered updateActiveFormats()
|
|
@@ -542,6 +560,7 @@ exports.LuksoMarkdownEditor = class LuksoMarkdownEditor extends shared_tailwindE
|
|
|
542
560
|
* @param event - Optional event that triggered the change
|
|
543
561
|
*/
|
|
544
562
|
emitChangeAndRefresh(event) {
|
|
563
|
+
this.cleanupEmptyColorSpans();
|
|
545
564
|
this.updateActiveFormats();
|
|
546
565
|
this.dispatchChange(event);
|
|
547
566
|
this.scheduleAccessibilityCheck();
|
|
@@ -831,9 +850,27 @@ exports.LuksoMarkdownEditor = class LuksoMarkdownEditor extends shared_tailwindE
|
|
|
831
850
|
}
|
|
832
851
|
this.value = before + transformed + after;
|
|
833
852
|
textarea.value = before + transformed + after;
|
|
834
|
-
|
|
853
|
+
let selStart;
|
|
854
|
+
let selEnd;
|
|
855
|
+
if (alignment === "left" || existingMatch && existingMatch[1] === alignment || this.getNestedAlignment(selected) === alignment) {
|
|
856
|
+
selStart = before.length;
|
|
857
|
+
selEnd = before.length + transformed.length;
|
|
858
|
+
} else {
|
|
859
|
+
const openTagMatch = transformed.match(
|
|
860
|
+
/<div style="text-align: (center|right);">([^<]*)<\/div>/
|
|
861
|
+
);
|
|
862
|
+
if (openTagMatch) {
|
|
863
|
+
const innerContent = openTagMatch[2];
|
|
864
|
+
const tagStart = transformed.indexOf(">") + 1;
|
|
865
|
+
selStart = before.length + tagStart;
|
|
866
|
+
selEnd = selStart + innerContent.length;
|
|
867
|
+
} else {
|
|
868
|
+
selStart = before.length;
|
|
869
|
+
selEnd = before.length + transformed.length;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
835
872
|
requestAnimationFrame(() => {
|
|
836
|
-
textarea.setSelectionRange(
|
|
873
|
+
textarea.setSelectionRange(selStart, selEnd);
|
|
837
874
|
this.emitChangeAndRefresh();
|
|
838
875
|
});
|
|
839
876
|
});
|
|
@@ -1331,7 +1368,7 @@ exports.LuksoMarkdownEditor = class LuksoMarkdownEditor extends shared_tailwindE
|
|
|
1331
1368
|
this.value = before + wrapped + after;
|
|
1332
1369
|
textarea.value = before + wrapped + after;
|
|
1333
1370
|
const selStart = before.length + newColorTagOpen.length;
|
|
1334
|
-
const selEnd = selStart + (selected ? selected.length :
|
|
1371
|
+
const selEnd = selStart + (selected ? selected.length : 0);
|
|
1335
1372
|
requestAnimationFrame(() => {
|
|
1336
1373
|
textarea.setSelectionRange(selStart, selEnd);
|
|
1337
1374
|
this.emitChangeAndRefresh();
|
|
@@ -60,6 +60,11 @@ export declare class LuksoMarkdownEditor extends LuksoMarkdownEditor_base {
|
|
|
60
60
|
* Schedule accessibility check with debouncing
|
|
61
61
|
*/
|
|
62
62
|
private scheduleAccessibilityCheck;
|
|
63
|
+
/**
|
|
64
|
+
* Clean up empty color spans from the value.
|
|
65
|
+
* This removes spans like <span style="color: #xxx"></span> with no content.
|
|
66
|
+
*/
|
|
67
|
+
private cleanupEmptyColorSpans;
|
|
63
68
|
/**
|
|
64
69
|
* Unified helper that ensures both active format state and change events are properly
|
|
65
70
|
* emitted after any value mutation. This replaces the scattered updateActiveFormats()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/lukso-markdown-editor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAA;AAYxD,OAAO,6BAA6B,CAAA;AACpC,OAAO,6BAA6B,CAAA;AACpC,OAAO,2BAA2B,CAAA;AAClC,OAAO,2BAA2B,CAAA;AAClC,OAAO,yBAAyB,CAAA;AAChC,OAAO,6BAA6B,CAAA;AACpC,OAAO,6BAA6B,CAAA;AACpC,OAAO,oCAAoC,CAAA;AAC3C,OAAO,4BAA4B,CAAA;AAEnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;;AAO/C,qBACa,mBAAoB,SAAQ,wBAA4B;IAEnE,KAAK,SAAK;IAGV,IAAI,SAAK;IAGT,KAAK,SAAK;IAGV,WAAW,SAAK;IAGhB,KAAK,SAAK;IAGV,WAAW,UAAQ;IAGnB,UAAU,UAAQ;IAGlB,UAAU,UAAQ;IAE0C,cAAc,UACnE;IAGP,SAAS,UAAQ;IAGjB,IAAI,EAAE,SAAS,CAAU;IAGzB,SAAS,UAAQ;IAGjB,IAAI,SAAI;IAGR,WAAW,SAAK;IAOhB,sBAAsB,SAAmC;IAGzD,gBAAgB,SAA6B;IAGpC,OAAO,CAAC,wBAAwB,CAG1B;IAGN,OAAO,CAAC,qBAAqB,CAAQ;I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iBAAiB,EAAE,cAAc;IAe9C,OAAO,CAAC,iBAAiB,EAAE,cAAc;IAczC,oBAAoB;IAepB,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,mBAAmB;IAQ3B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAehC,OAAO,CAAC,cAAc;IA+BtB,OAAO,CAAC,eAAe;IAmZvB,OAAO,CAAC,8BAA8B;IAuCtC,MAAM;CAiEP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,uBAAuB,EAAE,mBAAmB,CAAA;KAC7C;CACF"}
|
|
@@ -530,6 +530,24 @@ let LuksoMarkdownEditor = class extends TailwindStyledElement(style) {
|
|
|
530
530
|
this.accessibilityCheckTimeout = null;
|
|
531
531
|
}, this.ACCESSIBILITY_CHECK_DELAY);
|
|
532
532
|
}
|
|
533
|
+
/**
|
|
534
|
+
* Clean up empty color spans from the value.
|
|
535
|
+
* This removes spans like <span style="color: #xxx"></span> with no content.
|
|
536
|
+
*/
|
|
537
|
+
cleanupEmptyColorSpans() {
|
|
538
|
+
const emptyColorSpanRegex = /<span style="color: [^"]+"><\/span>/g;
|
|
539
|
+
const cleanedValue = this.value.replace(emptyColorSpanRegex, "");
|
|
540
|
+
if (cleanedValue !== this.value) {
|
|
541
|
+
this.value = cleanedValue;
|
|
542
|
+
const textarea = this.textareaEl?.shadowRoot?.querySelector("textarea");
|
|
543
|
+
if (textarea) {
|
|
544
|
+
const currentPos = textarea.selectionStart ?? 0;
|
|
545
|
+
textarea.value = cleanedValue;
|
|
546
|
+
const newPos = Math.min(currentPos, cleanedValue.length);
|
|
547
|
+
textarea.setSelectionRange(newPos, newPos);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
533
551
|
/**
|
|
534
552
|
* Unified helper that ensures both active format state and change events are properly
|
|
535
553
|
* emitted after any value mutation. This replaces the scattered updateActiveFormats()
|
|
@@ -538,6 +556,7 @@ let LuksoMarkdownEditor = class extends TailwindStyledElement(style) {
|
|
|
538
556
|
* @param event - Optional event that triggered the change
|
|
539
557
|
*/
|
|
540
558
|
emitChangeAndRefresh(event) {
|
|
559
|
+
this.cleanupEmptyColorSpans();
|
|
541
560
|
this.updateActiveFormats();
|
|
542
561
|
this.dispatchChange(event);
|
|
543
562
|
this.scheduleAccessibilityCheck();
|
|
@@ -827,9 +846,27 @@ let LuksoMarkdownEditor = class extends TailwindStyledElement(style) {
|
|
|
827
846
|
}
|
|
828
847
|
this.value = before + transformed + after;
|
|
829
848
|
textarea.value = before + transformed + after;
|
|
830
|
-
|
|
849
|
+
let selStart;
|
|
850
|
+
let selEnd;
|
|
851
|
+
if (alignment === "left" || existingMatch && existingMatch[1] === alignment || this.getNestedAlignment(selected) === alignment) {
|
|
852
|
+
selStart = before.length;
|
|
853
|
+
selEnd = before.length + transformed.length;
|
|
854
|
+
} else {
|
|
855
|
+
const openTagMatch = transformed.match(
|
|
856
|
+
/<div style="text-align: (center|right);">([^<]*)<\/div>/
|
|
857
|
+
);
|
|
858
|
+
if (openTagMatch) {
|
|
859
|
+
const innerContent = openTagMatch[2];
|
|
860
|
+
const tagStart = transformed.indexOf(">") + 1;
|
|
861
|
+
selStart = before.length + tagStart;
|
|
862
|
+
selEnd = selStart + innerContent.length;
|
|
863
|
+
} else {
|
|
864
|
+
selStart = before.length;
|
|
865
|
+
selEnd = before.length + transformed.length;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
831
868
|
requestAnimationFrame(() => {
|
|
832
|
-
textarea.setSelectionRange(
|
|
869
|
+
textarea.setSelectionRange(selStart, selEnd);
|
|
833
870
|
this.emitChangeAndRefresh();
|
|
834
871
|
});
|
|
835
872
|
});
|
|
@@ -1327,7 +1364,7 @@ let LuksoMarkdownEditor = class extends TailwindStyledElement(style) {
|
|
|
1327
1364
|
this.value = before + wrapped + after;
|
|
1328
1365
|
textarea.value = before + wrapped + after;
|
|
1329
1366
|
const selStart = before.length + newColorTagOpen.length;
|
|
1330
|
-
const selEnd = selStart + (selected ? selected.length :
|
|
1367
|
+
const selEnd = selStart + (selected ? selected.length : 0);
|
|
1331
1368
|
requestAnimationFrame(() => {
|
|
1332
1369
|
textarea.setSelectionRange(selStart, selEnd);
|
|
1333
1370
|
this.emitChangeAndRefresh();
|