File tree 5 files changed +30
-13
lines changed
5 files changed +30
-13
lines changed Original file line number Diff line number Diff line change
1
+ *.js linguist-detectable=false
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @hackdoor/codebox" ,
3
- "version" : " 1.0.11 " ,
3
+ "version" : " 1.0.16 " ,
4
4
"license" : " ISC" ,
5
5
"description" : " Code syntax highlighting tool for Editor.js" ,
6
6
"keywords" : [
23
23
"url" : " git+https://github.com/BomdiZane/codebox.git"
24
24
},
25
25
"scripts" : {
26
- "build" : " esbuild --bundle --outfile=\" ./dist/index.min.js\" --global-name=\" CodeBox\" --platform=\" browser\" ./src/index.ts && cp ./src/style.css ./dist/style.css" ,
26
+ "build" : " esbuild --bundle --outfile=\" ./dist/index.min.js\" --global-name=\" CodeBox\" --format= \" cjs \" -- platform=\" browser\" ./src/index.ts && cp ./src/style.css ./dist/style.css" ,
27
27
"dev" : " nodemon --watch ./src/*.ts npm run build" ,
28
28
"start" : " node test.js" ,
29
29
"prepublish" : " npm run build"
30
30
},
31
31
"devDependencies" : {
32
+ "@types/node" : " ^14.11.2" ,
32
33
"css-loader" : " ^1.0.0" ,
33
34
"esbuild" : " ^0.7.9" ,
34
35
"eslint" : " ^6.8.0" ,
39
40
" dist" ,
40
41
" src"
41
42
],
42
- "main" : " dist/index.min.js" ,
43
- "dependencies" : {
44
- "rangy" : " ^1.3.0"
45
- }
43
+ "main" : " dist/index.min.js"
46
44
}
Original file line number Diff line number Diff line change 7
7
* @author - Adombang Munang Mbomndih (Bomdi) <[email protected] > (https://bomdisoft.com)
8
8
*/
9
9
10
- import rangy from 'rangy/lib/rangy-core.js'
11
- import 'rangy/lib/rangy-textrange.js'
12
- import 'rangy/lib/rangy-selectionsaverestore.js'
13
-
14
10
import { DEFAULT_THEMES , COMMON_LANGUAGES } from './constants' ;
15
11
16
12
type CodeboxConfig = {
@@ -156,9 +152,26 @@ export default class CodeBox {
156
152
}
157
153
158
154
_highlightCodeArea ( event ) {
159
- const savedSel = rangy . saveSelection ( ) ;
160
155
hljs . highlightBlock ( this . codeArea ) ;
161
- rangy . restoreSelection ( savedSel ) ;
156
+ this . _placeCaretAtEnd ( this . codeArea )
157
+ }
158
+
159
+ _placeCaretAtEnd ( el ) {
160
+ el . focus ( ) ;
161
+ if ( typeof window . getSelection != "undefined" &&
162
+ typeof document . createRange != "undefined" ) {
163
+ let range = document . createRange ( ) ;
164
+ range . selectNodeContents ( el ) ;
165
+ range . collapse ( false ) ;
166
+ let sel = window . getSelection ( ) ;
167
+ sel . removeAllRanges ( ) ;
168
+ sel . addRange ( range ) ;
169
+ } else if ( typeof document . body . createTextRange != "undefined" ) {
170
+ let textRange = document . body . createTextRange ( ) ;
171
+ textRange . moveToElementText ( el ) ;
172
+ textRange . collapse ( false ) ;
173
+ textRange . select ( ) ;
174
+ }
162
175
}
163
176
164
177
_handleCodeAreaPaste ( event ) {
Original file line number Diff line number Diff line change 2
2
"compilerOptions" : {
3
3
"incremental" : true ,
4
4
"target" : " ESNext" ,
5
- "module" : " UMD " ,
5
+ "module" : " ESNext " ,
6
6
"allowJs" : true ,
7
7
"checkJs" : true ,
8
8
"strict" : true ,
Original file line number Diff line number Diff line change 40
40
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
41
41
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==
42
42
43
+ " @types/node@^14.11.2 " :
44
+ version "14.11.2"
45
+ resolved "https://registry.yarnpkg.com/@types/node/-/node-14.11.2.tgz#2de1ed6670439387da1c9f549a2ade2b0a799256"
46
+ integrity sha512-jiE3QIxJ8JLNcb1Ps6rDbysDhN4xa8DJJvuC9prr6w+1tIh+QAbYyNF3tyiZNLDBIuBCf4KEcV2UvQm/V60xfA==
47
+
43
48
abbrev@1 :
44
49
version "1.1.1"
45
50
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
You can’t perform that action at this time.
0 commit comments