-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: add runkit embeds #30241
Closed
Closed
doc: add runkit embeds #30241
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,44 @@ | ||
.hljs-attribute, | ||
.hljs-tag, | ||
.hljs-name, | ||
.hljs-class .hljs-title, | ||
.hljs-selector-id, | ||
.hljs-type, | ||
.hljs-params, | ||
.hljs-function { | ||
color: hsla(288, 8.108%, 37%, 1); | ||
} | ||
|
||
.hljs-literal { | ||
color: hsla(39, 81.176%, 57.5%, 1); | ||
} | ||
|
||
.hljs-comment, | ||
.hljs-quote { | ||
color: #978998; | ||
} | ||
|
||
.hljs-variable, | ||
.hljs-template-variable { | ||
color: #8e85e5; | ||
} | ||
|
||
.hljs-link, | ||
.hljs-keyword, | ||
.hljs-built_in, | ||
.hljs-builtin-name { | ||
color: #4a91e2; | ||
} | ||
|
||
.hljs-number { | ||
color: #33b277; | ||
} | ||
|
||
.hljs-string { | ||
color: #dd6546; | ||
} | ||
|
||
.hljs-regexp, | ||
.hljs-symbol { | ||
color: #cc4928; | ||
} |
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,47 @@ | ||
'use strict'; | ||
|
||
(function() { | ||
// https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/replaceWith | ||
function ReplaceWithPolyfill() { | ||
'use-strict'; // For safari, and IE > 10 | ||
var parent = this.parentNode, i = arguments.length, currentNode; | ||
if (!parent) return; | ||
if (!i) // if there are no arguments | ||
parent.removeChild(this); | ||
while (i--) { // i-- decrements i and returns the value of i before the decrement | ||
currentNode = arguments[i]; | ||
if (typeof currentNode !== 'object'){ | ||
currentNode = this.ownerDocument.createTextNode(currentNode); | ||
} else if (currentNode.parentNode){ | ||
currentNode.parentNode.removeChild(currentNode); | ||
} | ||
// the value of "i" below is after the decrement | ||
if (!i) // if currentNode is the first argument (currentNode === arguments[0]) | ||
parent.replaceChild(currentNode, this); | ||
else // if currentNode isn't the first | ||
parent.insertBefore(currentNode, this.previousSibling); | ||
} | ||
} | ||
if (!Element.prototype.replaceWith) | ||
Element.prototype.replaceWith = ReplaceWithPolyfill; | ||
if (!CharacterData.prototype.replaceWith) | ||
CharacterData.prototype.replaceWith = ReplaceWithPolyfill; | ||
if (!DocumentType.prototype.replaceWith) | ||
DocumentType.prototype.replaceWith = ReplaceWithPolyfill; | ||
}()); | ||
|
||
(function() { | ||
var runnables = document.querySelectorAll('.runkit'); | ||
runnables.forEach(function(runnable) { | ||
var source = RunKit.sourceFromElement(runnable); | ||
var wrapper = document.createElement('div'); | ||
wrapper.class = 'runkit-wrapper'; | ||
wrapper.style = 'top: 0; left: -9999px; margin: 1rem;'; | ||
RunKit.createNotebook({ | ||
element: wrapper, | ||
minHeight: '0px', | ||
source: source, | ||
}); | ||
runnable.parentElement.replaceWith(wrapper); | ||
}); | ||
}()); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the way #22831 marked runkit after the "```js" fence rather than inside it like it is here. This comment is visible when rendered as markdown (and maybe in the json version of the docs too?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it wouldn't highlight correctly in any editors i tried with that approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we maybe land this as is for now and try to improve the solution later on?
It seems like it would even be an improvement having the comment in markdown compared to now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this comment line is being added into only one of the js examples, is it the intention that it later be added to every single one? That seems overly intrusive.