feat: add JavaScript cheatsheet.
This commit is contained in:
parent
789aa12440
commit
9fe3fcdc0d
13
README.md
13
README.md
@ -5,9 +5,16 @@ Quick Reference
|
||||
|
||||
如果您发现此处的备忘单不合适,您可以通过提交 PR 来修复它或提供更好的备忘单,只针对【中文】用户。
|
||||
|
||||
以下是开源天使提供的一些备忘单和快速参考。:)
|
||||
以下是开源天使提供的一些备忘单和快速参考 :)。
|
||||
|
||||
## 编程
|
||||
|
||||
[JavaScript](./docs/javascript.md)
|
||||
|
||||
## 工具包
|
||||
|
||||
[VSCode](./docs/vscode.md)
|
||||
|
||||
## License
|
||||
|
||||
MIT © Randy8080
|
||||
|
||||
MIT © [Kenny Wong](https://github.com/jaywcjlove)
|
||||
|
1423
docs/javascript.md
Normal file
1423
docs/javascript.md
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,8 @@
|
||||
import markdown from '@wcj/markdown-to-html';
|
||||
import rehypeDocument from 'rehype-document';
|
||||
import rehypeFormat from 'rehype-format';
|
||||
import { rehypeUrls } from './nodes/rehypeUrls.mjs';
|
||||
import { htmlTagAddAttri } from './nodes/htmlTagAddAttri.mjs';
|
||||
|
||||
/** 标记 Number */
|
||||
function panelAddNumber(arr = [], result = []) {
|
||||
@ -58,9 +60,10 @@ export function getTocsTree(arr = [], result = []) {
|
||||
const headerCls = ['warp-header', `h${level}warp`];
|
||||
|
||||
if (level === 1) warpCls.push('max-container');
|
||||
|
||||
const warpStyle = toc.properties['data-warp-style'];
|
||||
const bodyStyle = toc.properties['data-body-style'];
|
||||
delete toc.properties['data-warp-style']
|
||||
delete toc.properties['data-body-style']
|
||||
|
||||
const panle = {
|
||||
type: 'element',
|
||||
@ -91,7 +94,7 @@ export function getTocsTree(arr = [], result = []) {
|
||||
panle.children = panle.children.concat({
|
||||
type: 'element',
|
||||
tagName: 'div',
|
||||
properties: { class: `h${level}warp-body` },
|
||||
properties: { class: `h${level}warp-body`, style: bodyStyle },
|
||||
children: [...resultChilds]
|
||||
});
|
||||
}
|
||||
@ -119,6 +122,8 @@ export function create(str = '', options = {}) {
|
||||
}],
|
||||
],
|
||||
rewrite: (node, index, parent) => {
|
||||
htmlTagAddAttri(node);
|
||||
rehypeUrls(node);
|
||||
if (node.type === 'element' && node.tagName === 'body') {
|
||||
node.children = getTocsTree([ ...node.children ]);
|
||||
}
|
||||
|
5
scripts/nodes/htmlTagAddAttri.mjs
Normal file
5
scripts/nodes/htmlTagAddAttri.mjs
Normal file
@ -0,0 +1,5 @@
|
||||
export function htmlTagAddAttri(node) {
|
||||
if (node && node.tagName === 'html') {
|
||||
node.properties['data-color-mode'] = 'dark';
|
||||
}
|
||||
}
|
6
scripts/nodes/rehypeUrls.mjs
Normal file
6
scripts/nodes/rehypeUrls.mjs
Normal file
@ -0,0 +1,6 @@
|
||||
export function rehypeUrls(node) {
|
||||
if (node.type === 'element' && node.properties.href && /.md/.test(node.properties.href)) {
|
||||
let href = node.properties.href;
|
||||
node.properties.href = href.replace(/([^\.\/\\]+)\.(md|markdown)/gi, '$1.html');
|
||||
}
|
||||
}
|
@ -22,6 +22,22 @@ blockquote, dl, dd, h1, h2, h3, h4, h5, h6, hr, figure, p, pre {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.max-container a, .max-container a:visited {
|
||||
color: rgb(2 132 199/1);
|
||||
text-decoration: none;
|
||||
background-image: linear-gradient(transparent,transparent 6px,#34495e 6px,#34495e);
|
||||
background-position: bottom;
|
||||
background-size: 100% 6px;
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
|
||||
.max-container a:hover, .max-container a:visited:hover{
|
||||
text-decoration-line: underline;
|
||||
text-decoration-color: #10b981;
|
||||
text-decoration-thickness: 2px;
|
||||
text-underline-offset: 4px;
|
||||
}
|
||||
|
||||
.max-container {
|
||||
max-width: 1320px;
|
||||
margin-left: auto;
|
||||
@ -35,14 +51,23 @@ blockquote, dl, dd, h1, h2, h3, h4, h5, h6, hr, figure, p, pre {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.warp-header.h1warp h1 {
|
||||
.warp-header.h1warp .warp-body {
|
||||
color: rgb(71 85 105/1);
|
||||
}
|
||||
|
||||
.warp-header.h1warp > h1 {
|
||||
font-size: 3rem;
|
||||
line-height: 1;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.h1warp-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3rem;
|
||||
}
|
||||
|
||||
.warp-header.h2warp h2 {
|
||||
.warp-header.h2warp > h2 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
margin-bottom: 24px;
|
||||
@ -62,14 +87,14 @@ blockquote, dl, dd, h1, h2, h3, h4, h5, h6, hr, figure, p, pre {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.warp-header.h3warp h3 {
|
||||
.warp-header.h3warp > h3 {
|
||||
color: rgb(226 232 240/1);
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
top: 0px;
|
||||
z-index: 10;
|
||||
border-bottom-left-radius: 0.5rem;
|
||||
background-color: rgb(16 185 129/1);
|
||||
background-color: #228e6c;
|
||||
padding-left: 0.75rem;
|
||||
padding-right: 0.75rem;
|
||||
padding-top: 0.25rem;
|
||||
@ -79,7 +104,33 @@ blockquote, dl, dd, h1, h2, h3, h4, h5, h6, hr, figure, p, pre {
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
.warp-header.h3warp .warp-body {
|
||||
.warp-header.h3warp > .warp-body p, .warp-header.h4warp > .warp-body p {
|
||||
margin: 0px;
|
||||
width: 100%;
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
padding-top: 0.75rem;
|
||||
padding-bottom: 0.75rem;
|
||||
color: rgb(148 163 184/1);
|
||||
background-color: rgb(15 23 42/0.3);
|
||||
}
|
||||
|
||||
.warp-header.h3warp > .warp-body p:first-child:before {
|
||||
background-color: rgb(15 23 42/0.3);
|
||||
color: rgb(30 41 59/0);
|
||||
content: '-';
|
||||
line-height: 1.75rem;
|
||||
top: -4px;
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.warp-header.h3warp > .warp-body p:last-child {
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
.warp-header.h3warp > .warp-body {
|
||||
z-index: 0;
|
||||
display: flex;
|
||||
height: 100%;
|
||||
@ -87,6 +138,55 @@ blockquote, dl, dd, h1, h2, h3, h4, h5, h6, hr, figure, p, pre {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.h4warp > h4 {
|
||||
border-color: rgb(51 65 85/0.5);
|
||||
background-color: rgb(51 65 85/0.3);
|
||||
color: rgb(203 213 225/1);
|
||||
|
||||
margin: 0px;
|
||||
border-top-width: 1px;
|
||||
/* border-color: rgb(226 232 240/1);
|
||||
background-color: rgb(241 245 249/1); */
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
padding-top: 0.25rem;
|
||||
padding-bottom: 0.25rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
ol, ul, menu {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.h3warp > .warp-body ul, .h3warp > .warp-body ol, .h3warp > .warp-body dl {
|
||||
margin-top: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
display: grid;
|
||||
list-style-position: outside;
|
||||
grid-template-columns: repeat(1,minmax(0,1fr));
|
||||
}
|
||||
|
||||
.h3warp > .warp-body ul li, .h3warp > .warp-body ol li, .h3warp > .warp-body dl li {
|
||||
padding: 9px;
|
||||
padding-left: 26px;
|
||||
position: relative;
|
||||
border-bottom: solid 1px rgb(51 65 85/0.5);
|
||||
}
|
||||
|
||||
.h3warp>.warp-body ul:not(.style-none)>li::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
width: 4px;
|
||||
height: 4px;
|
||||
background: #556677;
|
||||
border-radius: 50%;
|
||||
left: 14px;
|
||||
top: 18px;
|
||||
}
|
||||
|
||||
.h2warp-body {
|
||||
display: grid;
|
||||
gap: 1.75rem;
|
||||
@ -96,8 +196,8 @@ blockquote, dl, dd, h1, h2, h3, h4, h5, h6, hr, figure, p, pre {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.h2warp-body .warp {
|
||||
background-color: rgb(30 41 59/1);
|
||||
.h2warp-body > .warp {
|
||||
background-color: #1e293b;
|
||||
color: rgb(203 213 225/1);
|
||||
position: relative;
|
||||
display: flex;
|
||||
@ -147,6 +247,196 @@ table tr th:last-child, table tr td:last-child {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
table thead th {
|
||||
white-space: nowrap;
|
||||
font-weight: normal;
|
||||
color: rgb(16 185 129/1);
|
||||
}
|
||||
|
||||
.table-thead-hide thead {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
tt, code {
|
||||
font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;
|
||||
font-size: 1em;
|
||||
}
|
||||
pre:only-child {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
pre {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;
|
||||
word-wrap: normal;
|
||||
line-height: 1.5;
|
||||
overflow: hidden;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.code-highlight {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
[data-color-mode*='light'], [data-color-mode*='light'] body {
|
||||
--color-prettylights-syntax-comment: #6e7781;
|
||||
--color-prettylights-syntax-constant: #0550ae;
|
||||
--color-prettylights-syntax-entity: #8250df;
|
||||
--color-prettylights-syntax-storage-modifier-import: #24292f;
|
||||
--color-prettylights-syntax-entity-tag: #116329;
|
||||
--color-prettylights-syntax-keyword: #cf222e;
|
||||
--color-prettylights-syntax-string: #0a3069;
|
||||
--color-prettylights-syntax-variable: #953800;
|
||||
--color-prettylights-syntax-brackethighlighter-unmatched: #82071e;
|
||||
--color-prettylights-syntax-invalid-illegal-text: #f6f8fa;
|
||||
--color-prettylights-syntax-invalid-illegal-bg: #82071e;
|
||||
--color-prettylights-syntax-carriage-return-text: #f6f8fa;
|
||||
--color-prettylights-syntax-carriage-return-bg: #cf222e;
|
||||
--color-prettylights-syntax-string-regexp: #116329;
|
||||
--color-prettylights-syntax-markup-list: #3b2300;
|
||||
--color-prettylights-syntax-markup-heading: #0550ae;
|
||||
--color-prettylights-syntax-markup-italic: #24292f;
|
||||
--color-prettylights-syntax-markup-bold: #24292f;
|
||||
--color-prettylights-syntax-markup-deleted-text: #82071e;
|
||||
--color-prettylights-syntax-markup-deleted-bg: #FFEBE9;
|
||||
--color-prettylights-syntax-markup-inserted-text: #116329;
|
||||
--color-prettylights-syntax-markup-inserted-bg: #dafbe1;
|
||||
--color-prettylights-syntax-markup-changed-text: #953800;
|
||||
--color-prettylights-syntax-markup-changed-bg: #ffd8b5;
|
||||
--color-prettylights-syntax-markup-ignored-text: #eaeef2;
|
||||
--color-prettylights-syntax-markup-ignored-bg: #0550ae;
|
||||
--color-prettylights-syntax-meta-diff-range: #8250df;
|
||||
--color-prettylights-syntax-brackethighlighter-angle: #57606a;
|
||||
--color-prettylights-syntax-sublimelinter-gutter-mark: #8c959f;
|
||||
--color-prettylights-syntax-constant-other-reference-link: #0a3069;
|
||||
--color-fg-default: #24292f;
|
||||
--color-fg-muted: #57606a;
|
||||
--color-fg-subtle: #6e7781;
|
||||
--color-canvas-default: #ffffff;
|
||||
--color-canvas-subtle: #f6f8fa;
|
||||
--color-border-default: #d0d7de;
|
||||
--color-border-muted: hsla(210,18%,87%,1);
|
||||
--color-neutral-muted: rgba(175,184,193,0.2);
|
||||
--color-accent-fg: #0969da;
|
||||
--color-accent-emphasis: #0969da;
|
||||
--color-attention-subtle: #fff8c5;
|
||||
--color-danger-fg: #cf222e;
|
||||
}
|
||||
|
||||
[data-color-mode*='dark'], [data-color-mode*='dark'] body {
|
||||
--color-prettylights-syntax-comment: #8b949e;
|
||||
--color-prettylights-syntax-constant: #79c0ff;
|
||||
--color-prettylights-syntax-entity: #d2a8ff;
|
||||
--color-prettylights-syntax-storage-modifier-import: #c9d1d9;
|
||||
--color-prettylights-syntax-entity-tag: #7ee787;
|
||||
--color-prettylights-syntax-keyword: #ff7b72;
|
||||
--color-prettylights-syntax-string: #a5d6ff;
|
||||
--color-prettylights-syntax-variable: #ffa657;
|
||||
--color-prettylights-syntax-brackethighlighter-unmatched: #f85149;
|
||||
--color-prettylights-syntax-invalid-illegal-text: #f0f6fc;
|
||||
--color-prettylights-syntax-invalid-illegal-bg: #8e1519;
|
||||
--color-prettylights-syntax-carriage-return-text: #f0f6fc;
|
||||
--color-prettylights-syntax-carriage-return-bg: #b62324;
|
||||
--color-prettylights-syntax-string-regexp: #7ee787;
|
||||
--color-prettylights-syntax-markup-list: #f2cc60;
|
||||
--color-prettylights-syntax-markup-heading: #1f6feb;
|
||||
--color-prettylights-syntax-markup-italic: #c9d1d9;
|
||||
--color-prettylights-syntax-markup-bold: #c9d1d9;
|
||||
--color-prettylights-syntax-markup-deleted-text: #ffdcd7;
|
||||
--color-prettylights-syntax-markup-deleted-bg: #67060c;
|
||||
--color-prettylights-syntax-markup-inserted-text: #aff5b4;
|
||||
--color-prettylights-syntax-markup-inserted-bg: #033a16;
|
||||
--color-prettylights-syntax-markup-changed-text: #ffdfb6;
|
||||
--color-prettylights-syntax-markup-changed-bg: #5a1e02;
|
||||
--color-prettylights-syntax-markup-ignored-text: #c9d1d9;
|
||||
--color-prettylights-syntax-markup-ignored-bg: #1158c7;
|
||||
--color-prettylights-syntax-meta-diff-range: #d2a8ff;
|
||||
--color-prettylights-syntax-brackethighlighter-angle: #8b949e;
|
||||
--color-prettylights-syntax-sublimelinter-gutter-mark: #484f58;
|
||||
--color-prettylights-syntax-constant-other-reference-link: #a5d6ff;
|
||||
--color-fg-default: #c9d1d9;
|
||||
--color-fg-muted: #8b949e;
|
||||
--color-fg-subtle: #484f58;
|
||||
--color-canvas-default: #0d1117;
|
||||
--color-canvas-subtle: #161b22;
|
||||
--color-border-default: #30363d;
|
||||
--color-border-muted: #21262d;
|
||||
--color-neutral-muted: rgba(110,118,129,0.4);
|
||||
--color-accent-fg: #58a6ff;
|
||||
--color-accent-emphasis: #1f6feb;
|
||||
--color-attention-subtle: rgba(187,128,9,0.15);
|
||||
--color-danger-fg: #f85149;
|
||||
}
|
||||
|
||||
/* 代码高亮 Start */
|
||||
.token.comment, .token.prolog, .token.doctype, .token.cdata {
|
||||
color: var(--color-prettylights-syntax-comment);
|
||||
}
|
||||
.token.namespace { opacity: 0.7; }
|
||||
.token.tag, .token.selector, .token.constant, .token.symbol, .token.deleted {
|
||||
color: var(--color-prettylights-syntax-entity-tag);
|
||||
}
|
||||
.token.maybe-class-name {
|
||||
color: var(--color-prettylights-syntax-variable);
|
||||
}
|
||||
.token.property-access, .token.operator, .token.boolean, .token.number, .token.selector .token.class, .token.attr-name, .token.string, .token.char, .token.builtin {
|
||||
color: var(--color-prettylights-syntax-constant);
|
||||
}
|
||||
.token.deleted {
|
||||
color: var(--color-prettylights-syntax-markup-deleted-text);
|
||||
}
|
||||
.token.property {
|
||||
color: var(--color-prettylights-syntax-constant);
|
||||
}
|
||||
.token.punctuation {
|
||||
color: var(--color-prettylights-syntax-markup-bold);
|
||||
}
|
||||
.token.function {
|
||||
color: var(--color-prettylights-syntax-entity);
|
||||
}
|
||||
.code-line .token.deleted {
|
||||
background-color: var(--color-prettylights-syntax-markup-deleted-bg);
|
||||
}
|
||||
.token.inserted {
|
||||
color: var(--color-prettylights-syntax-markup-inserted-text);
|
||||
}
|
||||
.code-line .token.inserted {
|
||||
background-color: var(--color-prettylights-syntax-markup-inserted-bg);
|
||||
}
|
||||
|
||||
.token.variable {
|
||||
color: var(--color-prettylights-syntax-constant);
|
||||
}
|
||||
.token.entity, .token.url, .language-css .token.string, .style .token.string {
|
||||
color: var(--color-prettylights-syntax-string);
|
||||
}
|
||||
.token.color, .token.atrule, .token.attr-value, .token.function, .token.class-name {
|
||||
color: var(--color-prettylights-syntax-string);
|
||||
}
|
||||
.token.rule, .token.regex, .token.important, .token.keyword {
|
||||
color: var(--color-prettylights-syntax-keyword);
|
||||
}
|
||||
.token.coord {
|
||||
color: var(--color-prettylights-syntax-meta-diff-range);
|
||||
}
|
||||
|
||||
.token.number {
|
||||
color: var(--color-accent-emphasis);
|
||||
}
|
||||
.token.string {
|
||||
color: var(--color-prettylights-syntax-string);
|
||||
}
|
||||
.token.boolean {
|
||||
color: var(--color-prettylights-syntax-markup-heading);
|
||||
}
|
||||
.token.property-access {
|
||||
color: var(--color-prettylights-syntax-variable);
|
||||
}
|
||||
|
||||
.token.important, .token.bold { font-weight: bold; }
|
||||
.token.italic { font-style: italic; }
|
||||
.token.entity { cursor: help; }
|
||||
|
||||
/* 代码高亮 End */
|
Loading…
x
Reference in New Issue
Block a user