@codady/coax 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/coax.cjs.js +829 -140
- package/dist/coax.cjs.min.js +3 -3
- package/dist/coax.esm.js +823 -140
- package/dist/coax.esm.min.js +3 -3
- package/dist/coax.umd.js +849 -138
- package/dist/coax.umd.min.js +3 -3
- package/examples/.htaccess +0 -0
- package/examples/append-highlight.html +82 -0
- package/examples/color-selector.html +412 -0
- package/examples/css-highlight.html +2 -18
- package/examples/deepseek-highlight.html +91 -0
- package/examples/js-highlight.html +2 -17
- package/examples/md-highlight.html +60 -0
- package/examples/nginx.htaccess +0 -0
- package/examples/plain-highlight.html +47 -0
- package/examples/replace-highlight.html +69 -0
- package/examples/stream-highlight.html +64 -0
- package/examples/theme-highlight.html +69 -0
- package/package.json +19 -3
- package/rollup.config.js +3 -3
- package/src/Coax.js +50 -184
- package/src/Coax.ts +56 -207
- package/src/components/CoaxElem.js +457 -0
- package/src/components/CoaxElem.ts +488 -0
- package/src/modules.js +12 -0
- package/src/modules.ts +23 -0
- package/src/rules/css.js +11 -0
- package/src/rules/css.ts +11 -0
- package/src/rules/html.js +13 -0
- package/src/rules/html.ts +13 -0
- package/src/rules/javascript.js +10 -0
- package/src/rules/javascript.ts +10 -0
- package/src/rules/markdown.js +29 -0
- package/src/rules/markdown.ts +41 -0
- package/src/rules/ruleCss - /345/211/257/346/234/254.js" +10 -0
- package/src/rules/ruleHTML - /345/211/257/346/234/254.js" +12 -0
- package/src/rules/ruleJs - /345/211/257/346/234/254.js" +10 -0
- package/src/rules/ruleTs - /345/211/257/346/234/254.js" +12 -0
- package/src/rules/typescript.js +12 -0
- package/src/rules/typescript.ts +12 -0
- package/src/tools/copy.js +26 -0
- package/src/tools/copy.ts +29 -0
- package/tsconfig.json +2 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const markdown = [
|
|
2
|
+
// 注释: 这是 Markdown 中的行内注释
|
|
3
|
+
{ token: 'comment', pattern: /<!--[\s\S]*?-->/, light: '#6a737d', dark: '#8b949e' },
|
|
4
|
+
|
|
5
|
+
// 标题: 通过 `#` 来定义标题
|
|
6
|
+
{ token: 'heading', pattern: /(^|\n)(#{1,6})\s*(.+)/, light: '#e36209', dark: '#ffa657' },
|
|
7
|
+
|
|
8
|
+
// 粗体: **text** 或 __text__
|
|
9
|
+
{ token: 'bold', pattern: /\*\*([^*]+)\*\*|__([^_]+)__/g, light: '#d73a49', dark: '#ff7b72' },
|
|
10
|
+
|
|
11
|
+
// 斜体: *text* 或 _text_
|
|
12
|
+
{ token: 'italic', pattern: /\*([^*]+)\*|_([^_]+)_/g, light: '#032f62', dark: '#a5d6ff' },
|
|
13
|
+
|
|
14
|
+
// 链接: [text](url)
|
|
15
|
+
{ token: 'link', pattern: /\[([^\]]+)\]\(([^)]+)\)/g, light: '#0288d1', dark: '#80c0ff' },
|
|
16
|
+
|
|
17
|
+
// 行内代码: `code`
|
|
18
|
+
{ token: 'inline-code', pattern: /`([^`]+)`/g, light: '#032f62', dark: '#98c379' },
|
|
19
|
+
|
|
20
|
+
// 代码块: ```code```
|
|
21
|
+
{ token: 'code-block', pattern: /```([^\n]+)\n([\s\S]*?)```/g, light: '#24292e', dark: '#c9d1d9' },
|
|
22
|
+
|
|
23
|
+
// 列表项: - item 或 * item
|
|
24
|
+
{ token: 'list-item', pattern: /(^|\n)([-*])\s+(.+)/g, light: '#5c6e7c', dark: '#8b949e' },
|
|
25
|
+
|
|
26
|
+
// 引用: > text
|
|
27
|
+
{ token: 'quote', pattern: /(^|\n)>[ \t]*(.+)/g, light: '#6f42c1', dark: '#d2a8ff' },
|
|
28
|
+
|
|
29
|
+
// 图片: 
|
|
30
|
+
{ token: 'image', pattern: /!\[([^\]]+)\]\(([^)]+)\)/g, light: '#d73a49', dark: '#ff7b72' },
|
|
31
|
+
|
|
32
|
+
// 分割线: ---
|
|
33
|
+
{ token: 'hr', pattern: /^(---|___|\*\*\*)\s*$/gm, light: '#24292e', dark: '#c9d1d9' },
|
|
34
|
+
|
|
35
|
+
// 强调和删除: ~~text~~
|
|
36
|
+
{ token: 'strikethrough', pattern: /~~([^~]+)~~/g, light: '#e36209', dark: '#ffa657' },
|
|
37
|
+
|
|
38
|
+
// 表格: | header1 | header2 |
|
|
39
|
+
{ token: 'table', pattern: /\|([^\|]+)\|([^\|]+)\|/g, light: '#5c6e7c', dark: '#8b949e' }
|
|
40
|
+
]
|
|
41
|
+
export default markdown;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const ruleCss = [
|
|
2
|
+
{ token: 'comment', pattern: /\/\*[\s\S]*?\*\//, light: '#6a737d', dark: '#8b949e' },
|
|
3
|
+
{ token: 'value', pattern: /(?:'|")(?:\\.|[^\\'"\b])*?(?:'|")/, light: '#032f62', dark: '#a5d6ff' },
|
|
4
|
+
{ token: 'func', pattern: /[a-z-]+\(?=/, light: '#e36209', dark: '#ffa657' },
|
|
5
|
+
{ token: 'property', pattern: /[a-z-]+(?=\s*:)/, light: '#005cc5', dark: '#79c0ff' },
|
|
6
|
+
{ token: 'selector', pattern: /[.#a-z0-9, \n\t>:+()_-]+(?=\s*\{)/i, light: '#22863a', dark: '#7ee787' },
|
|
7
|
+
{ token: 'unit', pattern: /(?<=\d)(px|em|rem|%|vh|vw|ms|s|deg)/, light: '#d73a49', dark: '#ff7b72' },
|
|
8
|
+
{ token: 'number', pattern: /\b\d+(\.\d+)?\b/, light: '#005cc5', dark: '#79c0ff' },
|
|
9
|
+
{ token: 'punct', pattern: /[{}();:]/, light: '#24292e', dark: '#c9d1d9' }
|
|
10
|
+
];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const ruleHTML = [
|
|
2
|
+
{ token: 'comment', pattern: /<!--[\s\S]*?-->/, light: '#999999', dark: '#6e7681' },
|
|
3
|
+
{ token: 'doctype', pattern: /<!DOCTYPE[\s\S]*?>/i, light: '#6a737d', dark: '#8b949e' },
|
|
4
|
+
// 匹配标签名: <div, </div
|
|
5
|
+
{ token: 'tag', pattern: /<\/?[a-zA-Z0-9]+/, light: '#22863a', dark: '#7ee787' },
|
|
6
|
+
// 匹配属性名: class=
|
|
7
|
+
{ token: 'attr', pattern: /[a-zA-Z-]+(?=\s*=\s*)/, light: '#6f42c1', dark: '#d2a8ff' },
|
|
8
|
+
// 匹配属性值: "value"
|
|
9
|
+
{ token: 'string', pattern: /(['"])(?:\\.|[^\\])*?\1/, light: '#032f62', dark: '#a5d6ff' },
|
|
10
|
+
// 匹配标签闭合: >, />
|
|
11
|
+
{ token: 'bracket', pattern: /\/?>/, light: '#24292e', dark: '#c9d1d9' }
|
|
12
|
+
];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const ruleJs = [
|
|
2
|
+
{ token: 'comment', pattern: /\/\/[^\n]*|\/\*[\s\S]*?\*\//, light: '#6a737d', dark: '#8b949e' },
|
|
3
|
+
{ token: 'string', pattern: /(?:'|"|`)(?:\\.|[^\\'"\b])*?(?:'|"|`)/, light: '#032f62', dark: '#98c379' },
|
|
4
|
+
{ token: 'keyword', pattern: /\b(async|await|break|case|catch|class|const|continue|default|delete|do|else|export|extends|finally|for|function|if|import|in|instanceof|new|return|super|switch|this|throw|try|typeof|var|while|with|yield|let|static)\b/, light: '#d73a49', dark: '#ff7b72' },
|
|
5
|
+
{ token: 'builtin', pattern: /\b(console|window|document|Math|JSON|true|false|null|undefined|Object|Array|Promise|Number|String|Boolean)\b/, light: '#e36209', dark: '#ffa657' },
|
|
6
|
+
{ token: 'number', pattern: /\b(0x[\da-fA-F]+|0b[01]+|\d+(\.\d+)?)\b/, light: '#005cc5', dark: '#79c0ff' },
|
|
7
|
+
{ token: 'func', pattern: /\b[a-zA-Z_]\w*(?=\s*\()/, light: '#6f42c1', dark: '#d2a8ff' },
|
|
8
|
+
{ token: 'op', pattern: /[+\-*/%=<>!&|^~]+/, light: '#069598', dark: '#56b6c2' }
|
|
9
|
+
];
|
|
10
|
+
export default ruleJs;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const ruleTs = [
|
|
2
|
+
{ token: 'comment', pattern: /\/\/[^\n]*|\/\*[\s\S]*?\*\//, light: '#6a737d', dark: '#8b949e' },
|
|
3
|
+
{ token: 'string', pattern: /(?:'|"|`)(?:\\.|[^\\'"\b])*?(?:'|"|`)/, light: '#032f62', dark: '#98c379' },
|
|
4
|
+
{ token: 'decorator', pattern: /@[a-zA-Z_]\w*/, light: '#953800', dark: '#ffa657' },
|
|
5
|
+
{ token: 'keyword', pattern: /\b(abstract|as|async|await|break|case|catch|class|const|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|is|keyof|let|module|namespace|new|package|private|protected|public|readonly|return|set|static|super|switch|this|throw|try|type|typeof|var|while|with|yield)\b/, light: '#d73a49', dark: '#ff7b72' },
|
|
6
|
+
{ token: 'builtin', pattern: /\b(any|boolean|never|number|string|symbol|unknown|void|undefined|null|true|false|console|window|document)\b/, light: '#e36209', dark: '#ffa657' },
|
|
7
|
+
{ token: 'type', pattern: /\b[A-Z]\w*\b/, light: '#005cc5', dark: '#79c0ff' },
|
|
8
|
+
{ token: 'number', pattern: /\b(0x[\da-fA-F]+|0b[01]+|\d+(\.\d+)?)\b/, light: '#005cc5', dark: '#79c0ff' },
|
|
9
|
+
{ token: 'func', pattern: /\b[a-zA-Z_]\w*(?=\s*\()/, light: '#6f42c1', dark: '#d2a8ff' },
|
|
10
|
+
{ token: 'op', pattern: /(\?\.|![:\.]|[+\-*/%=<>!&|^~]+)/, light: '#089ba6', dark: '#79c0ff' }
|
|
11
|
+
];
|
|
12
|
+
export default ruleTs;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const typescript = [
|
|
2
|
+
{ token: 'comment', pattern: /\/\/[^\n]*|\/\*[\s\S]*?\*\//, light: '#6a737d', dark: '#8b949e' },
|
|
3
|
+
{ token: 'string', pattern: /(?:'|"|`)(?:\\.|[^\\'"\b])*?(?:'|"|`)/, light: '#032f62', dark: '#98c379' },
|
|
4
|
+
{ token: 'decorator', pattern: /@[a-zA-Z_]\w*/, light: '#953800', dark: '#ffa657' },
|
|
5
|
+
{ token: 'keyword', pattern: /\b(abstract|as|async|await|break|case|catch|class|const|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|is|keyof|let|module|namespace|new|package|private|protected|public|readonly|return|set|static|super|switch|this|throw|try|type|typeof|var|while|with|yield)\b/, light: '#d73a49', dark: '#ff7b72' },
|
|
6
|
+
{ token: 'builtin', pattern: /\b(any|boolean|never|number|string|symbol|unknown|void|undefined|null|true|false|console|window|document)\b/, light: '#e36209', dark: '#ffa657' },
|
|
7
|
+
{ token: 'type', pattern: /\b[A-Z]\w*\b/, light: '#005cc5', dark: '#79c0ff' },
|
|
8
|
+
{ token: 'number', pattern: /\b(0x[\da-fA-F]+|0b[01]+|\d+(\.\d+)?)\b/, light: '#005cc5', dark: '#79c0ff' },
|
|
9
|
+
{ token: 'func', pattern: /\b[a-zA-Z_]\w*(?=\s*\()/, light: '#6f42c1', dark: '#d2a8ff' },
|
|
10
|
+
{ token: 'op', pattern: /(\?\.|![:\.]|[+\-*/%=<>!&|^~]+)/, light: '#089ba6', dark: '#79c0ff' }
|
|
11
|
+
];
|
|
12
|
+
export default typescript;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const typescript = [
|
|
2
|
+
{ token: 'comment', pattern: /\/\/[^\n]*|\/\*[\s\S]*?\*\//, light: '#6a737d', dark: '#8b949e' },
|
|
3
|
+
{ token: 'string', pattern: /(?:'|"|`)(?:\\.|[^\\'"\b])*?(?:'|"|`)/, light: '#032f62', dark: '#98c379' },
|
|
4
|
+
{ token: 'decorator', pattern: /@[a-zA-Z_]\w*/, light: '#953800', dark: '#ffa657' },
|
|
5
|
+
{ token: 'keyword', pattern: /\b(abstract|as|async|await|break|case|catch|class|const|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|is|keyof|let|module|namespace|new|package|private|protected|public|readonly|return|set|static|super|switch|this|throw|try|type|typeof|var|while|with|yield)\b/, light: '#d73a49', dark: '#ff7b72' },
|
|
6
|
+
{ token: 'builtin', pattern: /\b(any|boolean|never|number|string|symbol|unknown|void|undefined|null|true|false|console|window|document)\b/, light: '#e36209', dark: '#ffa657' },
|
|
7
|
+
{ token: 'type', pattern: /\b[A-Z]\w*\b/, light: '#005cc5', dark: '#79c0ff' },
|
|
8
|
+
{ token: 'number', pattern: /\b(0x[\da-fA-F]+|0b[01]+|\d+(\.\d+)?)\b/, light: '#005cc5', dark: '#79c0ff' },
|
|
9
|
+
{ token: 'func', pattern: /\b[a-zA-Z_]\w*(?=\s*\()/, light: '#6f42c1', dark: '#d2a8ff' },
|
|
10
|
+
{ token: 'op', pattern: /(\?\.|![:\.]|[+\-*/%=<>!&|^~]+)/, light: '#089ba6', dark: '#79c0ff' }
|
|
11
|
+
]
|
|
12
|
+
export default typescript;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import icaxCheck from "@codady/icax/src/icaxCheck";
|
|
2
|
+
import icaxCopy from "@codady/icax/src/icaxCopy";
|
|
3
|
+
const copy = {
|
|
4
|
+
name: 'copy',
|
|
5
|
+
icon: icaxCopy(),
|
|
6
|
+
action: function (arg) {
|
|
7
|
+
arg.wrapEl.onclick = () => {
|
|
8
|
+
//this只是组件实例
|
|
9
|
+
navigator.clipboard.writeText(this.source)
|
|
10
|
+
.then(() => {
|
|
11
|
+
console.log('Text successfully copied to clipboard');
|
|
12
|
+
arg.iconEl.innerHTML = icaxCheck();
|
|
13
|
+
arg.iconEl.toggleAttribute('disabled', true);
|
|
14
|
+
setTimeout(() => {
|
|
15
|
+
//恢复
|
|
16
|
+
arg.iconEl.removeAttribute('disabled');
|
|
17
|
+
arg.iconEl.innerHTML = icaxCopy();
|
|
18
|
+
}, 2000);
|
|
19
|
+
})
|
|
20
|
+
.catch(err => {
|
|
21
|
+
console.error('Error copying text to clipboard: ', err);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export default copy;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import icaxCheck from "@codady/icax/src/icaxCheck";
|
|
2
|
+
import icaxCopy from "@codady/icax/src/icaxCopy";
|
|
3
|
+
import { toolsItem } from "@codady/utils/createTools";
|
|
4
|
+
|
|
5
|
+
const copy:toolsItem = {
|
|
6
|
+
name: 'copy',
|
|
7
|
+
icon: icaxCopy(),
|
|
8
|
+
action: function (this:any,arg: any) {
|
|
9
|
+
arg.wrapEl.onclick = () => {
|
|
10
|
+
//this只是组件实例
|
|
11
|
+
navigator.clipboard.writeText(this.source)
|
|
12
|
+
.then(() => {
|
|
13
|
+
console.log('Text successfully copied to clipboard');
|
|
14
|
+
arg.iconEl.innerHTML = icaxCheck();
|
|
15
|
+
arg.iconEl.toggleAttribute('disabled', true);
|
|
16
|
+
setTimeout(() => {
|
|
17
|
+
//恢复
|
|
18
|
+
arg.iconEl.removeAttribute('disabled');
|
|
19
|
+
arg.iconEl.innerHTML = icaxCopy();
|
|
20
|
+
}, 2000);
|
|
21
|
+
})
|
|
22
|
+
.catch(err => {
|
|
23
|
+
console.error('Error copying text to clipboard: ', err);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default copy;
|
package/tsconfig.json
CHANGED
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
23
23
|
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
24
24
|
/* Modules */
|
|
25
|
-
"module": "
|
|
25
|
+
"module": "nodenext", /* Specify what module code is generated. */
|
|
26
26
|
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
27
|
-
|
|
27
|
+
"moduleResolution": "nodenext", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
28
28
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
29
29
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
30
30
|
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|