@vectojs/core 1.6.2 → 1.7.0

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 CHANGED
@@ -1077,6 +1077,8 @@ var Scene = (_class2 = class _Scene {
1077
1077
  s.margin = "0";
1078
1078
  s.padding = "0";
1079
1079
  s.color = "transparent";
1080
+ s.forcedColorAdjust = "none";
1081
+ s.setProperty("-webkit-text-fill-color", "transparent");
1080
1082
  s.whiteSpace = "pre-wrap";
1081
1083
  s.overflow = "hidden";
1082
1084
  s.zIndex = "0";
@@ -1106,24 +1108,26 @@ var Scene = (_class2 = class _Scene {
1106
1108
  const lineFont = _nullishCoalesce(_nullishCoalesce(line.font, () => ( projection.font)), () => ( ""));
1107
1109
  const lineHeight2 = _nullishCoalesce(_nullishCoalesce(line.lineHeight, () => ( projection.lineHeight)), () => ( 16));
1108
1110
  lineElement.style.position = "absolute";
1111
+ lineElement.dir = "auto";
1109
1112
  lineElement.style.left = `${line.x}px`;
1110
1113
  lineElement.style.top = `${line.y + line.baseline - _chunkDFNK6OV6js.cssLineBoxBaseline.call(void 0, lineFont, lineHeight2)}px`;
1111
1114
  lineElement.style.whiteSpace = "pre";
1112
1115
  if (lineFont) lineElement.style.font = lineFont;
1113
1116
  lineElement.style.lineHeight = `${lineHeight2}px`;
1117
+ const separator = _nullishCoalesce(line.separatorAfter, () => ( (index < lines.length - 1 ? "\n" : "")));
1114
1118
  if (line.runs && line.runs.length > 0) {
1115
- for (const run of line.runs) {
1119
+ for (let runIndex = 0; runIndex < line.runs.length; runIndex++) {
1120
+ const run = line.runs[runIndex];
1116
1121
  const runElement = document.createElement("span");
1117
- runElement.textContent = run.text;
1122
+ runElement.textContent = run.text + (runIndex === line.runs.length - 1 ? separator : "");
1118
1123
  if (run.font) runElement.style.font = run.font;
1119
1124
  runElement.style.lineHeight = `${lineHeight2}px`;
1120
1125
  lineElement.appendChild(runElement);
1121
1126
  }
1122
1127
  } else {
1123
- lineElement.textContent = line.text;
1128
+ lineElement.textContent = line.text + separator;
1124
1129
  }
1125
1130
  el.appendChild(lineElement);
1126
- if (index < lines.length - 1) el.appendChild(document.createTextNode("\n"));
1127
1131
  }
1128
1132
  el.dataset.vectoProjectionLines = signature;
1129
1133
  }
package/dist/index.mjs CHANGED
@@ -1077,6 +1077,8 @@ var Scene = class _Scene {
1077
1077
  s.margin = "0";
1078
1078
  s.padding = "0";
1079
1079
  s.color = "transparent";
1080
+ s.forcedColorAdjust = "none";
1081
+ s.setProperty("-webkit-text-fill-color", "transparent");
1080
1082
  s.whiteSpace = "pre-wrap";
1081
1083
  s.overflow = "hidden";
1082
1084
  s.zIndex = "0";
@@ -1106,24 +1108,26 @@ var Scene = class _Scene {
1106
1108
  const lineFont = line.font ?? projection.font ?? "";
1107
1109
  const lineHeight2 = line.lineHeight ?? projection.lineHeight ?? 16;
1108
1110
  lineElement.style.position = "absolute";
1111
+ lineElement.dir = "auto";
1109
1112
  lineElement.style.left = `${line.x}px`;
1110
1113
  lineElement.style.top = `${line.y + line.baseline - cssLineBoxBaseline(lineFont, lineHeight2)}px`;
1111
1114
  lineElement.style.whiteSpace = "pre";
1112
1115
  if (lineFont) lineElement.style.font = lineFont;
1113
1116
  lineElement.style.lineHeight = `${lineHeight2}px`;
1117
+ const separator = line.separatorAfter ?? (index < lines.length - 1 ? "\n" : "");
1114
1118
  if (line.runs && line.runs.length > 0) {
1115
- for (const run of line.runs) {
1119
+ for (let runIndex = 0; runIndex < line.runs.length; runIndex++) {
1120
+ const run = line.runs[runIndex];
1116
1121
  const runElement = document.createElement("span");
1117
- runElement.textContent = run.text;
1122
+ runElement.textContent = run.text + (runIndex === line.runs.length - 1 ? separator : "");
1118
1123
  if (run.font) runElement.style.font = run.font;
1119
1124
  runElement.style.lineHeight = `${lineHeight2}px`;
1120
1125
  lineElement.appendChild(runElement);
1121
1126
  }
1122
1127
  } else {
1123
- lineElement.textContent = line.text;
1128
+ lineElement.textContent = line.text + separator;
1124
1129
  }
1125
1130
  el.appendChild(lineElement);
1126
- if (index < lines.length - 1) el.appendChild(document.createTextNode("\n"));
1127
1131
  }
1128
1132
  el.dataset.vectoProjectionLines = signature;
1129
1133
  }
@@ -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 plain text content as rendered (line breaks as `\n`). */
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectojs/core",
3
- "version": "1.6.2",
3
+ "version": "1.7.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },