Commit 43165cf6 authored by Julie Blanc's avatar Julie Blanc

set different var value on var propertie

parent 09511420
......@@ -116,6 +116,8 @@ class StringSets extends Handler {
// let cssVar = previousPageLastString;
// Get the last found string for the current identifier
let cssVar = ( name in this.pageLastString ) ? this.pageLastString[name] : "";
let varFirst, varLast, varStart, varFirstExcept;
selected.forEach((sel) => {
// push each content into the array to define in the variable the first and the last element of the page.
......@@ -125,29 +127,33 @@ class StringSets extends Handler {
// Index by identifier
this.pageLastString[name] = selected[selected.length - 1].textContent;
varFirst = "var first";
varLast = "var last";
varStart = "var start";
varFirstExcept = "varFirstExcept"
if (this.type === "first") {
cssVar = selected[0].textContent;
}
// if (this.type === "first") {
// cssVar = selected[0].textContent;
// }
else if (this.type === "last") {
cssVar = selected[selected.length - 1].textContent;
}
// else if (this.type === "last") {
// cssVar = selected[selected.length - 1].textContent;
// }
else if (this.type === "start") {
// else if (this.type === "start") {
if (sel.parentElement.firstChild === sel) {
cssVar = sel.textContent;
}
}
else if (this.type === "first-except") {
cssVar = "";
}
else {
cssVar = selected[0].textContent;
}
// if (sel.parentElement.firstChild === sel) {
// cssVar = sel.textContent;
// }
// }
// else if (this.type === "first-except") {
// cssVar = "";
// }
// else {
// cssVar = selected[0].textContent;
// }
});
fragment.setAttribute("data-string", `string-type-${this.type}-${name}`);
......@@ -155,6 +161,12 @@ class StringSets extends Handler {
// fragment.style.setProperty(`--pagedjs-string-${name}`, `"${cssVar.replace(/\\([\s\S])|(["|'])/g, "\\$1$2")}"`);
fragment.style.setProperty(`--pagedjs-string-${name}`, `"${cleanPseudoContent(cssVar)}`);
fragment.style.setProperty(`--pagedjs-string-first-${name}`, `"${cleanPseudoContent(varFirst)}`);
fragment.style.setProperty(`--pagedjs-string-last-${name}`, `"${cleanPseudoContent(varLast)}`);
fragment.style.setProperty(`--pagedjs-string-start-${name}`, `"${cleanPseudoContent(varStart)}`);
fragment.style.setProperty(`--pagedjs-string-first-except-${name}`, `"${cleanPseudoContent(varFirstExcept)}`);
// if there is no new string on the page
if (!fragment.hasAttribute("data-string")) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment