+
@@ -55,14 +55,8 @@ DIFF_STYLE_TOGGLE = r'''
'''
MAIN_CSS = r'''
-@layer base-style {
- html, body {
- margin: 0;
- padding: 0;
- font-family: sans-serif;
- }
-
- #js-controls {
+@layer wsd-base-style {
+ #wsd-js-controls {
display: none;
background-color: #f8f8f8;
padding: 5px 20px;
@@ -76,51 +70,51 @@ MAIN_CSS = r'''
}
@media screen and (max-width: 40em) {
- #js-controls {
+ #wsd-js-controls {
position: initial;
}
- .diff {
+ .wsd-diff {
border-top: none;
}
- .file-title {
+ .wsd-file-title {
background-color: #f8f8f8;
border-bottom: solid 1px #e0e0e0;
}
}
- input[type="checkbox"] {
+ #wsd-js-controls input[type="checkbox"] {
width: 20px;
height: 20px;
}
- input, label, .control-label {
+ #wsd-js-controls input, #wsd-js-controls label, #wsd-js-controls .control-label {
vertical-align: middle;
}
- .field-group {
+ .wsd-field-group {
display: inline-block;
}
- .field {
+ .wsd-field {
white-space: nowrap;
display: inline-block;
}
- label {
+ #wsd-js-controls label {
font-weight: normal;
margin-right: .5em;
margin-left: 5px;
}
- .control-label {
+ .wsd-control-label {
margin-right: .5em;
margin-left: 5px;
padding-bottom: 3px;
}
- .file-container {
+ .wsd-file-container {
font-family: monospace;
font-size: 9pt;
background-color: #f8f8f8;
@@ -128,7 +122,7 @@ MAIN_CSS = r'''
margin: 15px;
}
- .file-title {
+ .wsd-file-title {
padding: 10px 20px;
font-size: 10pt;
font-weight: bold;
@@ -138,7 +132,7 @@ MAIN_CSS = r'''
display: flex;
}
- .filename {
+ .wsd-filename {
max-width: 30em;
text-overflow: ellipsis;
overflow: hidden;
@@ -146,58 +140,58 @@ MAIN_CSS = r'''
direction: rtl;
}
- .diff {
+ .wsd-diff {
overflow-x: auto;
display: grid;
align-items: start;
border-top: 1px solid #e0e0e0;
}
- .line {
+ .wsd-line {
padding-left: calc(4em + 5px);
text-indent: -4em;
padding-top: 2px;
}
/* Make individual syntax tokens wrap anywhere */
- .line > span {
+ .wsd-line > span {
overflow-wrap: anywhere;
white-space: pre-wrap;
}
- .line {
+ .wsd-line {
min-width: 15em;
}
- .line.left.change, .line.left.insert {
+ .wsd-line.wsd-left.wsd-change, .wsd-line.wsd-left.wsd-insert {
background-color: #fbe9eb;
}
- .line.right.change, .line.right.insert {
+ .wsd-line.wsd-right.wsd-change, .wsd-line.wsd-right.wsd-insert {
background-color: #ecfdf0;
}
- .lineno.left.change, .lineno.left.insert {
+ .wsd-lineno.wsd-left.wsd-change, .wsd-lineno.wsd-left.wsd-insert {
background-color: #f9d7dc;
color: #ae969a;
}
- .lineno.right.change, .lineno.right.insert {
+ .wsd-lineno.wsd-right.wsd-change, .wsd-lineno.wsd-right.wsd-insert {
background-color: #ddfbe6;
color: #9bb0a1;
}
- .right > .word_change {
+ .wsd-right > .wsd-word-change {
background-color: #c7f0d2;
color: #004000;
}
- .left > .word_change {
+ .wsd-left > .wsd-word-change {
background-color: #fac5cd;
color: #400000;
}
- .lineno {
+ .wsd-lineno {
word-break: keep-all;
margin: 0;
padding-left: 30px;
@@ -211,11 +205,11 @@ MAIN_CSS = r'''
align-self: stretch;
}
- .lineno.change, .lineno.insert {
+ .wsd-lineno.wsd-change, .wsd-lineno.wsd-insert {
color: #000000;
}
- .lineno::after {
+ .wsd-lineno::after {
position: absolute;
right: 0;
content: "\a↳\a↳\a↳\a↳\a↳\a↳\a↳\a↳\a↳\a↳\a↳\a↳\a↳\a↳\a↳\a↳\a↳\a↳";
@@ -224,38 +218,38 @@ MAIN_CSS = r'''
}
/* Default rules for split diff for wide screens (laptops) */
- .diff {
+ .wsd-diff {
grid-template-columns: min-content 1fr min-content 1fr;
}
- .empty {
+ .wsd-empty {
background-color: #f0f0f0;
align-self: stretch;
}
/* line continuation arrows only in non-empty lines */
- .lineno.empty::after {
+ .wsd-lineno.wsd-empty::after {
content: "";
}
}
-@layer automatic-media-rule {
+@layer wsd-automatic-media-rule {
/* Unified diff for narrow screens (phones) */
@media screen and (max-width: 70em) {
- .diff {
+ .wsd-diff {
grid-auto-flow: dense;
grid-template-columns: min-content min-content 1fr;
}
- .lineno {
+ .wsd-lineno {
padding-left: 1em;
}
- .lineno.left {
+ .wsd-lineno.wsd-left {
grid-column: 1;
}
- .lineno.left.change, .lineno.right.change {
+ .wsd-lineno.wsd-left.wsd-change, .wsd-lineno.wsd-right.wsd-change {
grid-column: 1 / span 2;
display: grid;
grid-template-columns: 1fr 1fr;
@@ -266,7 +260,7 @@ MAIN_CSS = r'''
column-gap: 10px;
}
- .lineno.right.change::before {
+ .wsd-lineno.wsd-right.wsd-change::before {
content: "";
align-self: stretch;
grid-column: 1;
@@ -274,7 +268,7 @@ MAIN_CSS = r'''
margin-right: -6px; /* move border into column gap, and 1px over to align with other borders */
}
- .lineno.left.change::before {
+ .wsd-lineno.wsd-left.wsd-change::before {
content: "";
align-self: stretch;
grid-column: 2;
@@ -282,15 +276,15 @@ MAIN_CSS = r'''
margin-left: -5px;
}
- .lineno.left.insert {
+ .wsd-lineno.wsd-left.wsd-insert {
border-right: 1px solid #e0c8c8;
}
- .lineno.right.change::after {
+ .wsd-lineno.wsd-right.wsd-change::after {
grid-column: 2;
}
- .lineno.left.insert {
+ .wsd-lineno.wsd-left.wsd-insert {
grid-column: 1 / span 2;
display: grid;
grid-template-columns: 1fr 1fr;
@@ -300,43 +294,43 @@ MAIN_CSS = r'''
padding-right: 0;
}
- .lineno.right {
+ .wsd-lineno.wsd-right {
grid-column: 2;
}
- .lineno.right.insert {
+ .wsd-lineno.wsd-right.wsd-insert {
grid-column: 2;
}
- .line.left, .line.right.empty {
+ .wsd-line.wsd-left, .wsd-line.wsd-right.wsd-empty {
display: none;
}
- .line {
+ .wsd-line {
grid-column: 3;
}
- .line.left.insert {
+ .wsd-line.wsd-left.wsd-insert {
display: block;
}
- .line.left.change {
+ .wsd-line.wsd-left.wsd-change {
display: block;
}
- .lineno.right.empty {
+ .wsd-lineno.wsd-right.wsd-empty {
display: none;
}
- .lineno.left.empty {
+ .wsd-lineno.wsd-left.wsd-empty {
background-color: #ddfbe6;
}
/* line continuation arrows only in right line number column */
- .lineno.left.insert::after {
+ .wsd-lineno.wsd-left.wsd-insert::after {
}
- .lineno.left.insert::before {
+ .wsd-lineno.wsd-left.wsd-insert::before {
content: "";
grid-column: 2;
border-left: 1px solid #e0c8c8; /* pick a darker border color inside the light red gutter */
@@ -351,13 +345,13 @@ DIFF_STYLE_SCRIPT = r'''
const findRule = ((stylesheet, name) => Array.from(stylesheet.cssRules).find(
element => (element instanceof CSSLayerBlockRule && element.name == name)).cssRules[0]);
- const automaticMediaElement = findRule(findStylesheet('main-style'), 'automatic-media-rule');
+ const automaticMediaElement = findRule(findStylesheet('wsd-main-style'), 'wsd-automatic-media-rule');
const automaticMediaRule = automaticMediaElement.media[0];
const impossibleMediaRule = "screen and (max-width: 0px)";
const tautologicalMediaRule = "screen and (min-width: 0px)";
- const toggleAuto = document.getElementById("toggle-split-auto");
- const toggleForce = document.getElementById("toggle-split-force");
+ const toggleAuto = document.getElementById("wsd-toggle-split-auto");
+ const toggleForce = document.getElementById("wsd-toggle-split-force");
toggleAuto.checked = true;
toggleForce.disabled = true;
@@ -398,7 +392,7 @@ DIFF_STYLE_SCRIPT = r'''
});
toggleForce.checked = !mediaMatch.matches;
- document.getElementById('js-controls').style = 'display: flex';
+ document.getElementById('wsd-js-controls').style = 'display: flex';
'''
HTML_TEMPLATE = r'''
@@ -410,7 +404,13 @@ HTML_TEMPLATE = r'''
-