Only attach license footer to ProseMirror's parent
This commit is contained in:
parent
acecd619e9
commit
3baddadada
1 changed files with 10 additions and 13 deletions
|
|
@ -8,25 +8,22 @@
|
||||||
return location.pathname.indexOf("/doc/") === 0;
|
return location.pathname.indexOf("/doc/") === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function findTarget() {
|
function removeAll() {
|
||||||
var pm = document.querySelector(".ProseMirror");
|
document.querySelectorAll(".cc-license-footer").forEach(function (el) {
|
||||||
if (pm && pm.parentElement) return pm.parentElement;
|
el.remove();
|
||||||
return (
|
});
|
||||||
document.querySelector("article") ||
|
|
||||||
document.querySelector("[role=main]") ||
|
|
||||||
document.querySelector("main")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
var existing = document.querySelector(".cc-license-footer");
|
|
||||||
if (!isDoc()) {
|
if (!isDoc()) {
|
||||||
if (existing) existing.remove();
|
removeAll();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (existing) return;
|
var pm = document.querySelector(".ProseMirror");
|
||||||
var target = findTarget();
|
if (!pm || !pm.parentElement) return;
|
||||||
if (!target) return;
|
var target = pm.parentElement;
|
||||||
|
if (target.querySelector(":scope > .cc-license-footer")) return;
|
||||||
|
removeAll();
|
||||||
var footer = document.createElement("footer");
|
var footer = document.createElement("footer");
|
||||||
footer.className = "cc-license-footer";
|
footer.className = "cc-license-footer";
|
||||||
var p = document.createElement("p");
|
var p = document.createElement("p");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue