@readme/syntax-highlighter 15.0.2 → 16.0.0
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/index.js +2 -47606
- package/dist/index.js.LICENSE.txt +66 -0
- package/dist/index.node.js +1 -394
- package/package.json +7 -4
- package/.babelrc +0 -13
- package/LICENSES +0 -23
- package/knip.ts +0 -22
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -7
- package/public/index.js +0 -170
- package/public/index.legacy.js +0 -169
- package/src/codeEditor/cm.options.ts +0 -11
- package/src/codeEditor/index.tsx +0 -55
- package/src/codeEditor/style.scss +0 -6
- package/src/codeMirror/index.jsx +0 -260
- package/src/codeMirror/style.scss +0 -104
- package/src/index.js +0 -68
- package/src/index.node.ts +0 -5
- package/src/utils/canonical.ts +0 -65
- package/src/utils/cm-mode-imports.js +0 -33
- package/src/utils/index.ts +0 -5
- package/src/utils/modes/solidity.js +0 -605
- package/src/utils/modes.ts +0 -104
- package/src/utils/uppercase.ts +0 -111
- package/tsconfig.json +0 -13
- package/webpack.config.dev.js +0 -45
- package/webpack.config.js +0 -80
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
$gutterWidth: 43px; // enough for 3 chars
|
|
2
|
-
|
|
3
|
-
// dark theme
|
|
4
|
-
$darkBackground: #242e34;
|
|
5
|
-
$darkColor: #fff;
|
|
6
|
-
$darkHightlight: rgba(#000, 0.25);
|
|
7
|
-
|
|
8
|
-
// light theme
|
|
9
|
-
$lightBackground: #fff;
|
|
10
|
-
$lightColor: #000;
|
|
11
|
-
$lightHighlight: rgba($lightColor, 0.1);
|
|
12
|
-
|
|
13
|
-
.CodeEditor {
|
|
14
|
-
|
|
15
|
-
&.cm-s-material-palenight {
|
|
16
|
-
|
|
17
|
-
&:not(.CodeEditor-Input_highlight) {
|
|
18
|
-
.cm-linerow.cm-overlay,
|
|
19
|
-
.cm-linerow.cm-overlay > span,
|
|
20
|
-
.cm-linerow.cm-overlay > p {
|
|
21
|
-
color: rgba($darkColor, 0.5);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.cm-highlight {
|
|
26
|
-
background: $darkHightlight;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.CodeMirror {
|
|
30
|
-
background: $darkBackground;
|
|
31
|
-
color: $darkColor;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
&.cm-s-neo {
|
|
36
|
-
|
|
37
|
-
&:not(.CodeEditor-Input_highlight) {
|
|
38
|
-
.cm-linerow.cm-overlay,
|
|
39
|
-
.cm-linerow.cm-overlay > span,
|
|
40
|
-
.cm-linerow.cm-overlay > p {
|
|
41
|
-
color: rgba($lightColor, 0.5);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.cm-highlight {
|
|
46
|
-
background: $lightHighlight;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.CodeMirror {
|
|
50
|
-
background: $lightBackground;
|
|
51
|
-
color: $lightColor;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.cm-linerow.cm-overlay,
|
|
56
|
-
.cm-linerow.cm-overlay .cm-lineNumber {
|
|
57
|
-
opacity: 0.75;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Custom scrollbar styles
|
|
62
|
-
// see: https://codemirror.net/5/demo/simplescrollbars.html
|
|
63
|
-
.CodeMirror {
|
|
64
|
-
&-scrollbar-filler {
|
|
65
|
-
display: none !important;
|
|
66
|
-
}
|
|
67
|
-
&-overlayscroll {
|
|
68
|
-
&-horizontal div,
|
|
69
|
-
&-vertical div {
|
|
70
|
-
background: rgba(#cacaca, 0.5) !important;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.cm-linerow {
|
|
76
|
-
position: relative;
|
|
77
|
-
text-indent: $gutterWidth + 4px;
|
|
78
|
-
transition: background 0.5s cubic-bezier(0.16, 1, 0.3, 1), color 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1);
|
|
79
|
-
|
|
80
|
-
> span,
|
|
81
|
-
> p {
|
|
82
|
-
transition: color 0.5s cubic-bezier(0.16, 1, 0.3, 1);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.cm-lineNumber {
|
|
87
|
-
color: #676e95;
|
|
88
|
-
display: inline-block;
|
|
89
|
-
left: 0;
|
|
90
|
-
margin: 0;
|
|
91
|
-
min-width: $gutterWidth;
|
|
92
|
-
padding: 0 6px 0 10px;
|
|
93
|
-
position: absolute;
|
|
94
|
-
right: auto;
|
|
95
|
-
text-align: right;
|
|
96
|
-
text-indent: 0;
|
|
97
|
-
top: 0;
|
|
98
|
-
transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1);
|
|
99
|
-
|
|
100
|
-
-webkit-user-select: none; /* Safari */
|
|
101
|
-
-moz-user-select: none; /* Firefox */
|
|
102
|
-
-ms-user-select: none; /* IE10+/Edge */
|
|
103
|
-
user-select: none; /* Standard */
|
|
104
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import codeEditor from './codeEditor/index.tsx';
|
|
4
|
-
import codemirror, { VariablesContext as cmVariableContext } from './codeMirror';
|
|
5
|
-
import canonical from './utils/canonical.ts';
|
|
6
|
-
import { modes } from './utils/modes.ts';
|
|
7
|
-
import uppercase from './utils/uppercase.ts';
|
|
8
|
-
|
|
9
|
-
const SyntaxHighlighter = (
|
|
10
|
-
code,
|
|
11
|
-
lang,
|
|
12
|
-
opts = {
|
|
13
|
-
// If `customTheme` is present, it will override the `dark` option.
|
|
14
|
-
className: '',
|
|
15
|
-
customTheme: false,
|
|
16
|
-
dark: false,
|
|
17
|
-
editable: false,
|
|
18
|
-
inline: false,
|
|
19
|
-
tokenizeVariables: false,
|
|
20
|
-
},
|
|
21
|
-
props = {},
|
|
22
|
-
) => {
|
|
23
|
-
const { mdx, ...editorProps } = props;
|
|
24
|
-
let theme = opts.dark ? 'material-palenight' : 'neo';
|
|
25
|
-
if (opts.customTheme) {
|
|
26
|
-
theme = opts.customTheme;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (opts.foldGutter) {
|
|
30
|
-
// `foldGutter` does not work with runmode and has to be done with the codeEditor component
|
|
31
|
-
// NOTE: To disable editing, to still allow folding, `readOnly` must be `true`.
|
|
32
|
-
// oxlint-disable-next-line no-param-reassign
|
|
33
|
-
opts.editable = true;
|
|
34
|
-
// Default CSS classes
|
|
35
|
-
// oxlint-disable-next-line no-param-reassign
|
|
36
|
-
opts.gutters = ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (opts.editable) {
|
|
40
|
-
return React.createElement(codeEditor, {
|
|
41
|
-
...editorProps,
|
|
42
|
-
code,
|
|
43
|
-
lang,
|
|
44
|
-
theme,
|
|
45
|
-
options: opts,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const classes = [`cm-s-${theme}`];
|
|
50
|
-
if (opts.className) {
|
|
51
|
-
classes.push(opts.className);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (opts.highlightMode) {
|
|
55
|
-
classes.push('CodeEditor');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const wrapper = opts.inline ? 'span' : 'div';
|
|
59
|
-
|
|
60
|
-
return React.createElement(
|
|
61
|
-
wrapper,
|
|
62
|
-
{ className: classes.join(' '), 'data-testid': 'SyntaxHighlighter' },
|
|
63
|
-
codemirror(typeof code === 'string' ? code : '', lang, opts, { mdx }),
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export default SyntaxHighlighter;
|
|
68
|
-
export { uppercase, canonical, modes, cmVariableContext };
|
package/src/index.node.ts
DELETED
package/src/utils/canonical.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
const modeAliases = {
|
|
2
|
-
aspx: 'asp',
|
|
3
|
-
bash: 'shell',
|
|
4
|
-
'c++': 'cplusplus',
|
|
5
|
-
'c#': 'csharp',
|
|
6
|
-
clj: 'clojure',
|
|
7
|
-
cljc: 'clojure',
|
|
8
|
-
cljx: 'clojure',
|
|
9
|
-
coffeescript: 'javascript',
|
|
10
|
-
cpp: 'cplusplus',
|
|
11
|
-
cql: 'sql',
|
|
12
|
-
cs: 'csharp',
|
|
13
|
-
docker: 'dockerfile',
|
|
14
|
-
ecmascript: 'javascript',
|
|
15
|
-
erl: 'erlang',
|
|
16
|
-
gql: 'graphql',
|
|
17
|
-
gradle: 'groovy',
|
|
18
|
-
handlebars: 'html',
|
|
19
|
-
hbs: 'html',
|
|
20
|
-
jl: 'julia',
|
|
21
|
-
jruby: 'ruby',
|
|
22
|
-
js: 'javascript',
|
|
23
|
-
kt: 'kotlin',
|
|
24
|
-
less: 'css',
|
|
25
|
-
macruby: 'ruby',
|
|
26
|
-
md: 'markdown',
|
|
27
|
-
ml: 'ocaml',
|
|
28
|
-
mssql: 'sql',
|
|
29
|
-
mysql: 'sql',
|
|
30
|
-
node: 'javascript',
|
|
31
|
-
'obj-c': 'objectivec',
|
|
32
|
-
'obj-c++': 'objectivecplusplus',
|
|
33
|
-
'objc++': 'objectivecplusplus',
|
|
34
|
-
objc: 'objectivec',
|
|
35
|
-
objcpp: 'objectivecplusplus',
|
|
36
|
-
objectivecpp: 'objectivecplusplus',
|
|
37
|
-
pgsql: 'sql',
|
|
38
|
-
pl: 'perl',
|
|
39
|
-
plsql: 'sql',
|
|
40
|
-
postgres: 'sql',
|
|
41
|
-
postgresql: 'sql',
|
|
42
|
-
ps1: 'powershell',
|
|
43
|
-
py: 'python',
|
|
44
|
-
rake: 'ruby',
|
|
45
|
-
rb: 'ruby',
|
|
46
|
-
rbx: 'ruby',
|
|
47
|
-
rs: 'rust',
|
|
48
|
-
sass: 'css',
|
|
49
|
-
scss: 'css',
|
|
50
|
-
sh: 'shell',
|
|
51
|
-
solidity: 'sol',
|
|
52
|
-
sqlite: 'sql',
|
|
53
|
-
styl: 'css',
|
|
54
|
-
stylus: 'css',
|
|
55
|
-
xhtml: 'html',
|
|
56
|
-
yml: 'yaml',
|
|
57
|
-
zsh: 'shell',
|
|
58
|
-
} as const;
|
|
59
|
-
|
|
60
|
-
const canonical = (language: keyof typeof modeAliases) => {
|
|
61
|
-
if (language in modeAliases) return modeAliases[language];
|
|
62
|
-
return language;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export default canonical;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// oxlint-disable typescript/no-require-imports
|
|
2
|
-
// Codemirror-specfic mode-integrations, used for styling syntax
|
|
3
|
-
require('codemirror/mode/clike/clike');
|
|
4
|
-
require('codemirror/mode/clojure/clojure');
|
|
5
|
-
require('codemirror/mode/d/d');
|
|
6
|
-
require('codemirror/mode/dart/dart');
|
|
7
|
-
require('codemirror/mode/diff/diff');
|
|
8
|
-
require('codemirror/mode/dockerfile/dockerfile');
|
|
9
|
-
require('codemirror/mode/erlang/erlang');
|
|
10
|
-
require('codemirror/mode/go/go');
|
|
11
|
-
require('codemirror/mode/gfm/gfm');
|
|
12
|
-
require('codemirror/mode/groovy/groovy');
|
|
13
|
-
require('codemirror/mode/htmlmixed/htmlmixed');
|
|
14
|
-
require('codemirror/mode/http/http');
|
|
15
|
-
require('codemirror/mode/javascript/javascript');
|
|
16
|
-
require('codemirror/mode/jsx/jsx');
|
|
17
|
-
require('codemirror/mode/julia/julia');
|
|
18
|
-
require('codemirror/mode/lua/lua');
|
|
19
|
-
require('codemirror/mode/mllike/mllike');
|
|
20
|
-
require('codemirror/mode/perl/perl');
|
|
21
|
-
require('codemirror/mode/php/php');
|
|
22
|
-
require('codemirror/mode/powershell/powershell');
|
|
23
|
-
require('codemirror/mode/python/python');
|
|
24
|
-
require('codemirror/mode/r/r');
|
|
25
|
-
require('codemirror/mode/ruby/ruby');
|
|
26
|
-
require('codemirror/mode/rust/rust');
|
|
27
|
-
require('codemirror/mode/shell/shell');
|
|
28
|
-
require('codemirror/mode/sql/sql');
|
|
29
|
-
require('codemirror/mode/swift/swift');
|
|
30
|
-
require('codemirror/mode/toml/toml');
|
|
31
|
-
require('codemirror/mode/yaml/yaml');
|
|
32
|
-
require('codemirror-graphql/mode');
|
|
33
|
-
require('./modes/solidity');
|