@vectojs/core 1.6.2 → 1.7.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.
- package/dist/index.js +20 -5
- package/dist/index.mjs +20 -5
- package/dist/tree/Entity.d.ts +8 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -480,6 +480,18 @@ var Scene = (_class2 = class _Scene {
|
|
|
480
480
|
this.a11yRoot.style.pointerEvents = "none";
|
|
481
481
|
this.a11yRoot.style.overflow = "hidden";
|
|
482
482
|
this.a11yRoot.style.zIndex = "10";
|
|
483
|
+
this.a11yRoot.style.userSelect = "text";
|
|
484
|
+
this.a11yRoot.addEventListener("mousedown", (e) => {
|
|
485
|
+
const target = e.target;
|
|
486
|
+
if (target !== this.a11yRoot && target.closest("[data-vecto-content]") && getComputedStyle(target.closest("[data-vecto-content]")).pointerEvents === "auto") {
|
|
487
|
+
this.a11yRoot.style.pointerEvents = "auto";
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
const endDrag = () => {
|
|
491
|
+
if (this.a11yRoot) this.a11yRoot.style.pointerEvents = "none";
|
|
492
|
+
};
|
|
493
|
+
this.a11yRoot.addEventListener("mouseup", endDrag);
|
|
494
|
+
this.a11yRoot.addEventListener("mouseleave", endDrag);
|
|
483
495
|
if (canvas.parentElement) {
|
|
484
496
|
canvas.parentElement.appendChild(this.a11yRoot);
|
|
485
497
|
}
|
|
@@ -1077,8 +1089,9 @@ var Scene = (_class2 = class _Scene {
|
|
|
1077
1089
|
s.margin = "0";
|
|
1078
1090
|
s.padding = "0";
|
|
1079
1091
|
s.color = "transparent";
|
|
1092
|
+
s.forcedColorAdjust = "none";
|
|
1093
|
+
s.setProperty("-webkit-text-fill-color", "transparent");
|
|
1080
1094
|
s.whiteSpace = "pre-wrap";
|
|
1081
|
-
s.overflow = "hidden";
|
|
1082
1095
|
s.zIndex = "0";
|
|
1083
1096
|
el.addEventListener(
|
|
1084
1097
|
"wheel",
|
|
@@ -1106,24 +1119,26 @@ var Scene = (_class2 = class _Scene {
|
|
|
1106
1119
|
const lineFont = _nullishCoalesce(_nullishCoalesce(line.font, () => ( projection.font)), () => ( ""));
|
|
1107
1120
|
const lineHeight2 = _nullishCoalesce(_nullishCoalesce(line.lineHeight, () => ( projection.lineHeight)), () => ( 16));
|
|
1108
1121
|
lineElement.style.position = "absolute";
|
|
1122
|
+
lineElement.dir = "auto";
|
|
1109
1123
|
lineElement.style.left = `${line.x}px`;
|
|
1110
1124
|
lineElement.style.top = `${line.y + line.baseline - _chunkDFNK6OV6js.cssLineBoxBaseline.call(void 0, lineFont, lineHeight2)}px`;
|
|
1111
1125
|
lineElement.style.whiteSpace = "pre";
|
|
1112
1126
|
if (lineFont) lineElement.style.font = lineFont;
|
|
1113
1127
|
lineElement.style.lineHeight = `${lineHeight2}px`;
|
|
1128
|
+
const separator = _nullishCoalesce(line.separatorAfter, () => ( (index < lines.length - 1 ? "\n" : "")));
|
|
1114
1129
|
if (line.runs && line.runs.length > 0) {
|
|
1115
|
-
for (
|
|
1130
|
+
for (let runIndex = 0; runIndex < line.runs.length; runIndex++) {
|
|
1131
|
+
const run = line.runs[runIndex];
|
|
1116
1132
|
const runElement = document.createElement("span");
|
|
1117
|
-
runElement.textContent = run.text;
|
|
1133
|
+
runElement.textContent = run.text + (runIndex === line.runs.length - 1 ? separator : "");
|
|
1118
1134
|
if (run.font) runElement.style.font = run.font;
|
|
1119
1135
|
runElement.style.lineHeight = `${lineHeight2}px`;
|
|
1120
1136
|
lineElement.appendChild(runElement);
|
|
1121
1137
|
}
|
|
1122
1138
|
} else {
|
|
1123
|
-
lineElement.textContent = line.text;
|
|
1139
|
+
lineElement.textContent = line.text + separator;
|
|
1124
1140
|
}
|
|
1125
1141
|
el.appendChild(lineElement);
|
|
1126
|
-
if (index < lines.length - 1) el.appendChild(document.createTextNode("\n"));
|
|
1127
1142
|
}
|
|
1128
1143
|
el.dataset.vectoProjectionLines = signature;
|
|
1129
1144
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -480,6 +480,18 @@ var Scene = class _Scene {
|
|
|
480
480
|
this.a11yRoot.style.pointerEvents = "none";
|
|
481
481
|
this.a11yRoot.style.overflow = "hidden";
|
|
482
482
|
this.a11yRoot.style.zIndex = "10";
|
|
483
|
+
this.a11yRoot.style.userSelect = "text";
|
|
484
|
+
this.a11yRoot.addEventListener("mousedown", (e) => {
|
|
485
|
+
const target = e.target;
|
|
486
|
+
if (target !== this.a11yRoot && target.closest("[data-vecto-content]") && getComputedStyle(target.closest("[data-vecto-content]")).pointerEvents === "auto") {
|
|
487
|
+
this.a11yRoot.style.pointerEvents = "auto";
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
const endDrag = () => {
|
|
491
|
+
if (this.a11yRoot) this.a11yRoot.style.pointerEvents = "none";
|
|
492
|
+
};
|
|
493
|
+
this.a11yRoot.addEventListener("mouseup", endDrag);
|
|
494
|
+
this.a11yRoot.addEventListener("mouseleave", endDrag);
|
|
483
495
|
if (canvas.parentElement) {
|
|
484
496
|
canvas.parentElement.appendChild(this.a11yRoot);
|
|
485
497
|
}
|
|
@@ -1077,8 +1089,9 @@ var Scene = class _Scene {
|
|
|
1077
1089
|
s.margin = "0";
|
|
1078
1090
|
s.padding = "0";
|
|
1079
1091
|
s.color = "transparent";
|
|
1092
|
+
s.forcedColorAdjust = "none";
|
|
1093
|
+
s.setProperty("-webkit-text-fill-color", "transparent");
|
|
1080
1094
|
s.whiteSpace = "pre-wrap";
|
|
1081
|
-
s.overflow = "hidden";
|
|
1082
1095
|
s.zIndex = "0";
|
|
1083
1096
|
el.addEventListener(
|
|
1084
1097
|
"wheel",
|
|
@@ -1106,24 +1119,26 @@ var Scene = class _Scene {
|
|
|
1106
1119
|
const lineFont = line.font ?? projection.font ?? "";
|
|
1107
1120
|
const lineHeight2 = line.lineHeight ?? projection.lineHeight ?? 16;
|
|
1108
1121
|
lineElement.style.position = "absolute";
|
|
1122
|
+
lineElement.dir = "auto";
|
|
1109
1123
|
lineElement.style.left = `${line.x}px`;
|
|
1110
1124
|
lineElement.style.top = `${line.y + line.baseline - cssLineBoxBaseline(lineFont, lineHeight2)}px`;
|
|
1111
1125
|
lineElement.style.whiteSpace = "pre";
|
|
1112
1126
|
if (lineFont) lineElement.style.font = lineFont;
|
|
1113
1127
|
lineElement.style.lineHeight = `${lineHeight2}px`;
|
|
1128
|
+
const separator = line.separatorAfter ?? (index < lines.length - 1 ? "\n" : "");
|
|
1114
1129
|
if (line.runs && line.runs.length > 0) {
|
|
1115
|
-
for (
|
|
1130
|
+
for (let runIndex = 0; runIndex < line.runs.length; runIndex++) {
|
|
1131
|
+
const run = line.runs[runIndex];
|
|
1116
1132
|
const runElement = document.createElement("span");
|
|
1117
|
-
runElement.textContent = run.text;
|
|
1133
|
+
runElement.textContent = run.text + (runIndex === line.runs.length - 1 ? separator : "");
|
|
1118
1134
|
if (run.font) runElement.style.font = run.font;
|
|
1119
1135
|
runElement.style.lineHeight = `${lineHeight2}px`;
|
|
1120
1136
|
lineElement.appendChild(runElement);
|
|
1121
1137
|
}
|
|
1122
1138
|
} else {
|
|
1123
|
-
lineElement.textContent = line.text;
|
|
1139
|
+
lineElement.textContent = line.text + separator;
|
|
1124
1140
|
}
|
|
1125
1141
|
el.appendChild(lineElement);
|
|
1126
|
-
if (index < lines.length - 1) el.appendChild(document.createTextNode("\n"));
|
|
1127
1142
|
}
|
|
1128
1143
|
el.dataset.vectoProjectionLines = signature;
|
|
1129
1144
|
}
|
package/dist/tree/Entity.d.ts
CHANGED
|
@@ -68,6 +68,13 @@ export interface ContentProjectionRun {
|
|
|
68
68
|
export interface ContentProjectionLine {
|
|
69
69
|
/** Text for browser find-in-page and native selection. */
|
|
70
70
|
text: string;
|
|
71
|
+
/**
|
|
72
|
+
* Logical source content between this visual line and the next one. Use a
|
|
73
|
+
* space for a consumed soft-wrap separator, `"\n"` for a hard break, or an
|
|
74
|
+
* empty string for a space-less wrap. Omit to retain the legacy newline
|
|
75
|
+
* fallback between non-final lines.
|
|
76
|
+
*/
|
|
77
|
+
separatorAfter?: string;
|
|
71
78
|
/** Local origin of the visual line inside the entity. */
|
|
72
79
|
x: number;
|
|
73
80
|
y: number;
|
|
@@ -81,7 +88,7 @@ export interface ContentProjectionLine {
|
|
|
81
88
|
runs?: ContentProjectionRun[];
|
|
82
89
|
}
|
|
83
90
|
export interface ContentProjection {
|
|
84
|
-
/** The
|
|
91
|
+
/** The logical source text exposed to find, selection, copy, and assistive technology. */
|
|
85
92
|
text: string;
|
|
86
93
|
/** CSS font shorthand matching the drawn glyphs, e.g. `'24px sans-serif'`. */
|
|
87
94
|
font?: string;
|