@usememos/editor 26.10.4 → 26.10.5
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.js +18 -7
- package/dist/index.js.map +2 -2
- package/dist/types/markdown/serialize.d.ts +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4005,21 +4005,27 @@ function representableInline(inline3) {
|
|
|
4005
4005
|
endRun();
|
|
4006
4006
|
for (const [from, to] of removals) spans = setMarkInRange(spans, from, to, mark, false);
|
|
4007
4007
|
}
|
|
4008
|
-
return
|
|
4008
|
+
return dropLineEdgeSpaces(spans);
|
|
4009
4009
|
}
|
|
4010
4010
|
var isPlainSpan = (s) => !s.link && !s.image && !s.token && !s.marks.includes("code") && !s.marks.includes("html");
|
|
4011
|
-
function
|
|
4011
|
+
function dropLineEdgeSpaces(spans) {
|
|
4012
4012
|
const text = spans.map((s) => s.text).join("");
|
|
4013
|
-
if (!/[ \t](\n|$)/.test(text)) return spans;
|
|
4013
|
+
if (!/[ \t](\n|$)|(^|\n)[ \t]/.test(text)) return spans;
|
|
4014
4014
|
const plain2 = [];
|
|
4015
4015
|
for (const s of spans) for (let i = 0; i < s.text.length; i++) plain2.push(isPlainSpan(s));
|
|
4016
4016
|
const removals = [];
|
|
4017
4017
|
let lineStart = 0;
|
|
4018
4018
|
for (let i = 0; i <= text.length; i++) {
|
|
4019
4019
|
if (i < text.length && text[i] !== "\n") continue;
|
|
4020
|
+
const space = (k) => (text[k] === " " || text[k] === " ") && plain2[k];
|
|
4021
|
+
let to = lineStart;
|
|
4022
|
+
while (to < i && space(to)) to++;
|
|
4020
4023
|
let from = i;
|
|
4021
|
-
while (from > lineStart && (
|
|
4022
|
-
if (
|
|
4024
|
+
while (from > lineStart && space(from - 1)) from--;
|
|
4025
|
+
if (to < from) {
|
|
4026
|
+
if (to > lineStart) removals.push([lineStart, to]);
|
|
4027
|
+
if (from < i) removals.push([from, i]);
|
|
4028
|
+
}
|
|
4023
4029
|
lineStart = i + 1;
|
|
4024
4030
|
}
|
|
4025
4031
|
let out = spans;
|
|
@@ -6967,8 +6973,13 @@ var Editor = class {
|
|
|
6967
6973
|
applyRuntime(options) {
|
|
6968
6974
|
const root = this.root;
|
|
6969
6975
|
if ("placeholder" in options) {
|
|
6970
|
-
if (options.placeholder)
|
|
6971
|
-
|
|
6976
|
+
if (options.placeholder) {
|
|
6977
|
+
root.style.setProperty("--mbe-placeholder", JSON.stringify(options.placeholder));
|
|
6978
|
+
root.setAttribute("aria-placeholder", options.placeholder);
|
|
6979
|
+
} else {
|
|
6980
|
+
root.style.removeProperty("--mbe-placeholder");
|
|
6981
|
+
root.removeAttribute("aria-placeholder");
|
|
6982
|
+
}
|
|
6972
6983
|
this.runtime = { ...this.runtime, placeholder: options.placeholder };
|
|
6973
6984
|
}
|
|
6974
6985
|
if ("attributes" in options) {
|