-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into sanitize-MessageChannel-input
- Loading branch information
Showing
37 changed files
with
1,221 additions
and
1,570 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
**/*.html | ||
**/*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"bracketSameLine": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,53 @@ | ||
button, select, label { | ||
font-weight: 400; | ||
line-height: 1.5; | ||
font-size: 1rem; | ||
font-family: sans-serif; | ||
} | ||
|
||
button, select { | ||
padding: 6px 12px; | ||
text-align: center; | ||
background-color: transparent; | ||
border-radius: .25rem; | ||
} | ||
|
||
button { | ||
color: #0d6efd; | ||
border: 1px solid transparent; | ||
border-color: #0d6efd; | ||
cursor: pointer; | ||
outline: 0; | ||
display: inline-block; | ||
transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out; | ||
margin-bottom: 20px; | ||
} | ||
|
||
button:hover { | ||
color: #fff; | ||
background-color: #0d6efd; | ||
border-color: #0d6efd; | ||
} | ||
|
||
button:disabled { | ||
color: #999; | ||
border-color: #999; | ||
background: white; | ||
cursor: not-allowed; | ||
} | ||
|
||
label { | ||
padding-right: 24px; | ||
} | ||
|
||
.select-container p { | ||
color: red; | ||
margin-bottom: 36px; | ||
} | ||
button, | ||
select, | ||
label { | ||
font-weight: 400; | ||
line-height: 1.5; | ||
font-size: 1rem; | ||
font-family: sans-serif; | ||
} | ||
|
||
button, | ||
select { | ||
padding: 6px 12px; | ||
text-align: center; | ||
background-color: transparent; | ||
border-radius: 0.25rem; | ||
} | ||
|
||
button { | ||
color: #0d6efd; | ||
border: 1px solid transparent; | ||
border-color: #0d6efd; | ||
cursor: pointer; | ||
outline: 0; | ||
display: inline-block; | ||
transition: | ||
color 0.15s ease-in-out, | ||
background-color 0.15s ease-in-out, | ||
border-color 0.15s ease-in-out, | ||
box-shadow 0.15s ease-in-out; | ||
margin-bottom: 20px; | ||
} | ||
|
||
button:hover { | ||
color: #fff; | ||
background-color: #0d6efd; | ||
border-color: #0d6efd; | ||
} | ||
|
||
button:disabled { | ||
color: #999; | ||
border-color: #999; | ||
background: white; | ||
cursor: not-allowed; | ||
} | ||
|
||
label { | ||
padding-right: 24px; | ||
} | ||
|
||
.select-container p { | ||
color: red; | ||
margin-bottom: 36px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
.fancy { | ||
background-image: paint(headerHighlight); | ||
} | ||
|
||
background-image: paint(headerHighlight); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
#contents { | ||
width: 600px; | ||
font: 14px "Open Sans", sans-serif; | ||
width: 600px; | ||
font: | ||
14px "Open Sans", | ||
sans-serif; | ||
} | ||
|
||
#credits { | ||
padding: 0 0 10px 0; | ||
font: italic 10px "Open Sans", sans-serif; | ||
padding: 0 0 10px 0; | ||
font: | ||
italic 10px "Open Sans", | ||
sans-serif; | ||
} | ||
|
||
#in-pip-message { | ||
display: none; | ||
display: none; | ||
} | ||
|
||
@media (display-mode: picture-in-picture) and (prefers-color-scheme: light) { | ||
body { | ||
background: antiquewhite; | ||
} | ||
} | ||
|
||
@media (display-mode: picture-in-picture) and (prefers-color-scheme: dark) { | ||
body { | ||
background: #333; | ||
} | ||
|
||
a { | ||
color: antiquewhite; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// The EditContext object only knows about a plain text string and about | ||
// character offsets. However, our editor view renders the text by using | ||
// DOM nodes. So we sometimes need to convert between the two. | ||
// This function converts from a DOM selection object to character offsets. | ||
export function fromSelectionToOffsets(selection, editorEl) { | ||
const treeWalker = document.createTreeWalker(editorEl, NodeFilter.SHOW_TEXT); | ||
|
||
let anchorNodeFound = false; | ||
let extentNodeFound = false; | ||
let anchorOffset = 0; | ||
let extentOffset = 0; | ||
|
||
while (treeWalker.nextNode()) { | ||
const node = treeWalker.currentNode; | ||
if (node === selection.anchorNode) { | ||
anchorNodeFound = true; | ||
anchorOffset += selection.anchorOffset; | ||
} | ||
|
||
if (node === selection.extentNode) { | ||
extentNodeFound = true; | ||
extentOffset += selection.extentOffset; | ||
} | ||
|
||
if (!anchorNodeFound) { | ||
anchorOffset += node.textContent.length; | ||
} | ||
if (!extentNodeFound) { | ||
extentOffset += node.textContent.length; | ||
} | ||
} | ||
|
||
if (!anchorNodeFound || !extentNodeFound) { | ||
return null; | ||
} | ||
|
||
return { start: anchorOffset, end: extentOffset }; | ||
} | ||
|
||
// The EditContext object only knows about a plain text string and about | ||
// character offsets. However, our editor view renders the text by using | ||
// DOM nodes. So we sometimes need to convert between the two. | ||
// This function converts character offsets to a DOM selection object. | ||
export function fromOffsetsToSelection(start, end, editorEl) { | ||
const treeWalker = document.createTreeWalker(editorEl, NodeFilter.SHOW_TEXT); | ||
|
||
let offset = 0; | ||
let anchorNode = null; | ||
let anchorOffset = 0; | ||
let extentNode = null; | ||
let extentOffset = 0; | ||
|
||
while (treeWalker.nextNode()) { | ||
const node = treeWalker.currentNode; | ||
|
||
if (!anchorNode && offset + node.textContent.length >= start) { | ||
anchorNode = node; | ||
anchorOffset = start - offset; | ||
} | ||
|
||
if (!extentNode && offset + node.textContent.length >= end) { | ||
extentNode = node; | ||
extentOffset = end - offset; | ||
} | ||
|
||
if (anchorNode && extentNode) { | ||
break; | ||
} | ||
|
||
offset += node.textContent.length; | ||
} | ||
|
||
return { anchorNode, anchorOffset, extentNode, extentOffset }; | ||
} | ||
|
||
// The EditContext object only knows about character offsets. But out editor | ||
// view renders HTML tokens as DOM nodes. This function finds DOM node tokens | ||
// that are in the provided EditContext offset range. | ||
export function fromOffsetsToRenderedTokenNodes(renderedTokens, start, end) { | ||
const tokenNodes = []; | ||
|
||
for (let offset = start; offset < end; offset++) { | ||
const token = renderedTokens.find( | ||
(token) => token.pos <= offset && token.pos + token.value.length > offset | ||
); | ||
if (token) { | ||
tokenNodes.push({ | ||
node: token.node, | ||
nodeOffset: token.pos, | ||
charOffset: offset, | ||
}); | ||
} | ||
} | ||
|
||
return tokenNodes; | ||
} |
Oops, something went wrong.