@braccato/core 1.6.3 → 1.6.4
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/inject.js +11 -2
- package/package.json +1 -1
package/dist/inject.js
CHANGED
|
@@ -298,6 +298,15 @@ function createHighlightRun(doc, text) {
|
|
|
298
298
|
run.setAttribute("aria-hidden", "true");
|
|
299
299
|
return run;
|
|
300
300
|
}
|
|
301
|
+
// A background gap must carry the background size too, or it renders full-size and the gap looks oversized.
|
|
302
|
+
function createSpaceNode(doc, text, isBackground) {
|
|
303
|
+
if (!isBackground)
|
|
304
|
+
return doc.createTextNode(text);
|
|
305
|
+
const span = doc.createElement("span");
|
|
306
|
+
span.classList.add(BACKGROUND_LYRIC_CLASS);
|
|
307
|
+
span.textContent = text;
|
|
308
|
+
return span;
|
|
309
|
+
}
|
|
301
310
|
export function createLyricsLine(doc, parts, line, lyricElement, options = { splitBackgroundLine: true }) {
|
|
302
311
|
const lineText = parts.map(part => part.words).join("");
|
|
303
312
|
const mainText = options.splitBackgroundLine
|
|
@@ -336,8 +345,8 @@ export function createLyricsLine(doc, parts, line, lyricElement, options = { spl
|
|
|
336
345
|
const highlightRun = shouldUseBackgroundLine ? backgroundHighlightRun : mainHighlightRun;
|
|
337
346
|
const pendingSpace = shouldUseBackgroundLine ? pendingBackgroundSpace : pendingForegroundSpace;
|
|
338
347
|
if (target.childNodes.length > 0 && pendingSpace.length > 0) {
|
|
339
|
-
target.appendChild(doc
|
|
340
|
-
highlightRun.appendChild(doc
|
|
348
|
+
target.appendChild(createSpaceNode(doc, pendingSpace, shouldUseBackgroundLine));
|
|
349
|
+
highlightRun.appendChild(createSpaceNode(doc, pendingSpace, shouldUseBackgroundLine));
|
|
341
350
|
}
|
|
342
351
|
const { lyricGroup, highlightGroup } = createWordGroup(doc, item, line);
|
|
343
352
|
target.appendChild(lyricGroup);
|