Skip to content

Commit

Permalink
fix:lb=last handling updated to include quote[p] as breakpoints; decr…
Browse files Browse the repository at this point in the history
…eased spacing; #113
  • Loading branch information
linxOD committed Nov 14, 2024
1 parent 6a53291 commit da9203b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
2 changes: 1 addition & 1 deletion py/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def wrap_or_not(el, s, ancestor=False) -> ET.Element:
if el.tag not in EXCLUDE_TAGS:
next_el = el.getnext()
if el.tag == "{http://www.tei-c.org/ns/1.0}quote" or el.tag == "{http://www.tei-c.org/ns/1.0}seg":
breakpoint_els = el.xpath("./tei:p|./tei:lg|./tei:note",
breakpoint_els = el.xpath("./tei:p|./tei:lg|./tei:note|./tei:quote[tei:p]",
namespaces=NSMAP)
# quote and seg are inline or block elements but
# (Breakpoints: p, lg, note)
Expand Down
6 changes: 3 additions & 3 deletions scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -753,9 +753,9 @@ wpn-detail-view:has(span[data-bs-toggle="popover"]:hover) details:not([open]) .s
// letter-spacing: 0.4pt;
}

// #textcontent-pb .spacing {
// letter-spacing: 1pt;
// }
#textcontent-pb .spacing {
letter-spacing: 1.5pt;
}

#infocontent-pb {
font-size: 1em;
Expand Down
34 changes: 28 additions & 6 deletions wpn-utils/wpn-typo-connections.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import { find } from "instantsearch.js/es/lib/utils";
// Description: This script is used to connect elements in
// left and right margin with their anchor in the text.

const connectElements = (query: string, container: boolean) => {

const elements = document.querySelectorAll<HTMLElement>(query);
// console.log([...elements]);

[...elements].map((el) => {

let targetId = el.id;

if (container) {
targetId = el.id.replace("container-", "");
} else {
targetId = "container-" + el.id;
}

if (targetId.length > 0) {

const color = targetId.includes("metam") ? "bg-danger-subtle" : targetId.includes("-add-") ? "bg-warning-subtle" : "bg-secondary-subtle";
Expand All @@ -23,7 +28,10 @@ const connectElements = (query: string, container: boolean) => {
const spanToElement = checkForConnections(childS, "spanto");
const targetElement = checkForConnections(childT, "target");

el.onmouseover = () => {
el.onmouseover = (e) => {

e.preventDefault();

// console.log(`Connecting ${el.id} to ${targetId}`);
target?.classList.add(...["border", border, "border-2", "border-dotted"]);
el.classList.add(color);
Expand All @@ -38,48 +46,62 @@ const connectElements = (query: string, container: boolean) => {
|| childS && childS.classList.contains("doubleLineLeft")
|| childS && childS.classList.contains("doubleLineRight")
) {

spanToElement
.map(span => {
createCanvas(el);
drawLine(el, span);
span?.classList.add(...["border", border, "border-2", "border-dotted"])
});

} else {

spanToElement
.map(span => span?.classList.add(...["border", border, "border-2", "border-dotted"]));
}

}

};
el.onmouseout = () => {

el.onmouseout = (e) => {

e.preventDefault();

target?.classList.remove(...["border", border, "border-2", "border-dotted"]);
el.classList.remove(color);

targetElement.map(target => target?.classList.remove(...["border", border, "border-2", "border-dotted"]));

if (childS && childS.classList.contains("lineLeft")
|| childS && childS.classList.contains("lineRight")
|| childS && childS.classList.contains("doubleLineLeft")
|| childS && childS.classList.contains("doubleLineRight")
) {

spanToElement
.map(span => {
removeCanvas(el);
span?.classList.remove(...["border", border, "border-2", "border-dotted"])
});

} else {

spanToElement
.map(span => span?.classList.remove(...["border", border, "border-2", "border-dotted"]));

}
targetElement.map(target => target?.classList.remove(...["border", border, "border-2", "border-dotted"]));

};
}
});
};

const findChild = (element: HTMLElement, type: string) => {

const child = element.classList.contains(type) && element.tagName === "DIV" ? element.childNodes[0].childNodes[0] as HTMLElement
: element.classList.contains(type) && element.tagName !== "DIV" ? element.childNodes[0] as HTMLElement
: false;

return child;
}

Expand Down

0 comments on commit da9203b

Please sign in to comment.