@kerebron/extension-codejar 0.4.7 → 0.4.9
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/esm/CodeJar.js +11 -54
- package/esm/Decorator.js +1 -8
- package/esm/ExtensionCodeJar.js +4 -18
- package/esm/NodeCodeJar.js +2 -6
- package/esm/TreeSitterHighlighter.js +3 -20
- package/esm/codeJarBlockNodeView.js +23 -108
- package/package.json +10 -7
package/esm/CodeJar.js
CHANGED
|
@@ -63,62 +63,19 @@ function findPadding(text) {
|
|
|
63
63
|
return [text.substring(i, j) || '', i, j];
|
|
64
64
|
}
|
|
65
65
|
export class CodeJar extends EventTarget {
|
|
66
|
+
editor;
|
|
67
|
+
highlight;
|
|
68
|
+
options;
|
|
69
|
+
listeners = [];
|
|
70
|
+
history = [];
|
|
71
|
+
at = -1;
|
|
72
|
+
onUpdateCbk = () => void 0;
|
|
73
|
+
focus = false;
|
|
74
|
+
prev; // code content prior keydown event
|
|
66
75
|
constructor(editor, highlight, opt = {}) {
|
|
67
76
|
super();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
configurable: true,
|
|
71
|
-
writable: true,
|
|
72
|
-
value: editor
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(this, "highlight", {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
configurable: true,
|
|
77
|
-
writable: true,
|
|
78
|
-
value: highlight
|
|
79
|
-
});
|
|
80
|
-
Object.defineProperty(this, "options", {
|
|
81
|
-
enumerable: true,
|
|
82
|
-
configurable: true,
|
|
83
|
-
writable: true,
|
|
84
|
-
value: void 0
|
|
85
|
-
});
|
|
86
|
-
Object.defineProperty(this, "listeners", {
|
|
87
|
-
enumerable: true,
|
|
88
|
-
configurable: true,
|
|
89
|
-
writable: true,
|
|
90
|
-
value: []
|
|
91
|
-
});
|
|
92
|
-
Object.defineProperty(this, "history", {
|
|
93
|
-
enumerable: true,
|
|
94
|
-
configurable: true,
|
|
95
|
-
writable: true,
|
|
96
|
-
value: []
|
|
97
|
-
});
|
|
98
|
-
Object.defineProperty(this, "at", {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
configurable: true,
|
|
101
|
-
writable: true,
|
|
102
|
-
value: -1
|
|
103
|
-
});
|
|
104
|
-
Object.defineProperty(this, "onUpdateCbk", {
|
|
105
|
-
enumerable: true,
|
|
106
|
-
configurable: true,
|
|
107
|
-
writable: true,
|
|
108
|
-
value: () => void 0
|
|
109
|
-
});
|
|
110
|
-
Object.defineProperty(this, "focus", {
|
|
111
|
-
enumerable: true,
|
|
112
|
-
configurable: true,
|
|
113
|
-
writable: true,
|
|
114
|
-
value: false
|
|
115
|
-
});
|
|
116
|
-
Object.defineProperty(this, "prev", {
|
|
117
|
-
enumerable: true,
|
|
118
|
-
configurable: true,
|
|
119
|
-
writable: true,
|
|
120
|
-
value: void 0
|
|
121
|
-
}); // code content prior keydown event
|
|
77
|
+
this.editor = editor;
|
|
78
|
+
this.highlight = highlight;
|
|
122
79
|
this.options = {
|
|
123
80
|
tab: '\t',
|
|
124
81
|
indentOn: /[({\[]$/,
|
package/esm/Decorator.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
export class Decorator {
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(this, "decorationGroups", {
|
|
4
|
-
enumerable: true,
|
|
5
|
-
configurable: true,
|
|
6
|
-
writable: true,
|
|
7
|
-
value: {}
|
|
8
|
-
});
|
|
9
|
-
}
|
|
2
|
+
decorationGroups = {};
|
|
10
3
|
highlight(code) {
|
|
11
4
|
const decorations = [];
|
|
12
5
|
for (const groupName in this.decorationGroups) {
|
package/esm/ExtensionCodeJar.js
CHANGED
|
@@ -3,26 +3,12 @@ import { createNodeFromObject } from '@kerebron/editor/utilities';
|
|
|
3
3
|
import { NodeCodeJar } from './NodeCodeJar.js';
|
|
4
4
|
export * from './NodeCodeJar.js';
|
|
5
5
|
export class ExtensionCodeJar extends Extension {
|
|
6
|
+
config;
|
|
7
|
+
name = 'code-jar';
|
|
8
|
+
requires;
|
|
6
9
|
constructor(config = {}) {
|
|
7
10
|
super(config);
|
|
8
|
-
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: config
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(this, "name", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: 'code-jar'
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(this, "requires", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value: void 0
|
|
25
|
-
});
|
|
11
|
+
this.config = config;
|
|
26
12
|
this.requires = [
|
|
27
13
|
new NodeCodeJar({
|
|
28
14
|
languageWhitelist: config.languageWhitelist,
|
package/esm/NodeCodeJar.js
CHANGED
|
@@ -19,14 +19,10 @@ function arrowHandler(dir) {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
export class NodeCodeJar extends NodeCodeBlock {
|
|
22
|
+
config;
|
|
22
23
|
constructor(config) {
|
|
23
24
|
super(config);
|
|
24
|
-
|
|
25
|
-
enumerable: true,
|
|
26
|
-
configurable: true,
|
|
27
|
-
writable: true,
|
|
28
|
-
value: config
|
|
29
|
-
});
|
|
25
|
+
this.config = config;
|
|
30
26
|
}
|
|
31
27
|
getCommandFactories(editor, type) {
|
|
32
28
|
return {
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
import { createParser } from '@kerebron/tree-sitter';
|
|
2
2
|
import { fetchTextResource, fetchWasm, getLangTreeSitter, } from '@kerebron/wasm';
|
|
3
3
|
export class TreeSitterHighlighter {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
configurable: true,
|
|
8
|
-
writable: true,
|
|
9
|
-
value: void 0
|
|
10
|
-
});
|
|
11
|
-
Object.defineProperty(this, "hightligtScm", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
configurable: true,
|
|
14
|
-
writable: true,
|
|
15
|
-
value: void 0
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(this, "cdnUrl", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
configurable: true,
|
|
20
|
-
writable: true,
|
|
21
|
-
value: 'http://localhost:8000/wasm/'
|
|
22
|
-
});
|
|
23
|
-
}
|
|
4
|
+
parser;
|
|
5
|
+
hightligtScm;
|
|
6
|
+
cdnUrl = 'http://localhost:8000/wasm/';
|
|
24
7
|
async init(lang) {
|
|
25
8
|
const treeSitterConfig = getLangTreeSitter(lang, this.cdnUrl);
|
|
26
9
|
const wasmUrl = treeSitterConfig.files[0]; // TODO add support for split parsers like markdown
|
|
@@ -6,115 +6,30 @@ import { TreeSitterHighlighter } from './TreeSitterHighlighter.js';
|
|
|
6
6
|
import { Decorator } from './Decorator.js';
|
|
7
7
|
import { initLineNumbers, lineNumberOptions, refreshNumbers, } from './codeJarLineNumbers.js';
|
|
8
8
|
class CodeJarBlockNodeView {
|
|
9
|
+
node;
|
|
10
|
+
view;
|
|
11
|
+
getPos;
|
|
12
|
+
config;
|
|
13
|
+
editor;
|
|
14
|
+
dom;
|
|
15
|
+
codeJar;
|
|
16
|
+
updating;
|
|
17
|
+
element;
|
|
18
|
+
highlighter;
|
|
19
|
+
decorator;
|
|
20
|
+
languageDropDown;
|
|
21
|
+
lineNumbers;
|
|
22
|
+
source;
|
|
23
|
+
extensionLsp;
|
|
24
|
+
lang = 'plaintext';
|
|
25
|
+
uri = 'file:///' + Math.random() + '.ts';
|
|
26
|
+
diagListener;
|
|
9
27
|
constructor(node, view, getPos, config, editor) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
Object.defineProperty(this, "view", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
configurable: true,
|
|
19
|
-
writable: true,
|
|
20
|
-
value: view
|
|
21
|
-
});
|
|
22
|
-
Object.defineProperty(this, "getPos", {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
configurable: true,
|
|
25
|
-
writable: true,
|
|
26
|
-
value: getPos
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(this, "config", {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
configurable: true,
|
|
31
|
-
writable: true,
|
|
32
|
-
value: config
|
|
33
|
-
});
|
|
34
|
-
Object.defineProperty(this, "editor", {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
configurable: true,
|
|
37
|
-
writable: true,
|
|
38
|
-
value: editor
|
|
39
|
-
});
|
|
40
|
-
Object.defineProperty(this, "dom", {
|
|
41
|
-
enumerable: true,
|
|
42
|
-
configurable: true,
|
|
43
|
-
writable: true,
|
|
44
|
-
value: void 0
|
|
45
|
-
});
|
|
46
|
-
Object.defineProperty(this, "codeJar", {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
configurable: true,
|
|
49
|
-
writable: true,
|
|
50
|
-
value: void 0
|
|
51
|
-
});
|
|
52
|
-
Object.defineProperty(this, "updating", {
|
|
53
|
-
enumerable: true,
|
|
54
|
-
configurable: true,
|
|
55
|
-
writable: true,
|
|
56
|
-
value: void 0
|
|
57
|
-
});
|
|
58
|
-
Object.defineProperty(this, "element", {
|
|
59
|
-
enumerable: true,
|
|
60
|
-
configurable: true,
|
|
61
|
-
writable: true,
|
|
62
|
-
value: void 0
|
|
63
|
-
});
|
|
64
|
-
Object.defineProperty(this, "highlighter", {
|
|
65
|
-
enumerable: true,
|
|
66
|
-
configurable: true,
|
|
67
|
-
writable: true,
|
|
68
|
-
value: void 0
|
|
69
|
-
});
|
|
70
|
-
Object.defineProperty(this, "decorator", {
|
|
71
|
-
enumerable: true,
|
|
72
|
-
configurable: true,
|
|
73
|
-
writable: true,
|
|
74
|
-
value: void 0
|
|
75
|
-
});
|
|
76
|
-
Object.defineProperty(this, "languageDropDown", {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
configurable: true,
|
|
79
|
-
writable: true,
|
|
80
|
-
value: void 0
|
|
81
|
-
});
|
|
82
|
-
Object.defineProperty(this, "lineNumbers", {
|
|
83
|
-
enumerable: true,
|
|
84
|
-
configurable: true,
|
|
85
|
-
writable: true,
|
|
86
|
-
value: void 0
|
|
87
|
-
});
|
|
88
|
-
Object.defineProperty(this, "source", {
|
|
89
|
-
enumerable: true,
|
|
90
|
-
configurable: true,
|
|
91
|
-
writable: true,
|
|
92
|
-
value: void 0
|
|
93
|
-
});
|
|
94
|
-
Object.defineProperty(this, "extensionLsp", {
|
|
95
|
-
enumerable: true,
|
|
96
|
-
configurable: true,
|
|
97
|
-
writable: true,
|
|
98
|
-
value: void 0
|
|
99
|
-
});
|
|
100
|
-
Object.defineProperty(this, "lang", {
|
|
101
|
-
enumerable: true,
|
|
102
|
-
configurable: true,
|
|
103
|
-
writable: true,
|
|
104
|
-
value: 'plaintext'
|
|
105
|
-
});
|
|
106
|
-
Object.defineProperty(this, "uri", {
|
|
107
|
-
enumerable: true,
|
|
108
|
-
configurable: true,
|
|
109
|
-
writable: true,
|
|
110
|
-
value: 'file:///' + Math.random() + '.ts'
|
|
111
|
-
});
|
|
112
|
-
Object.defineProperty(this, "diagListener", {
|
|
113
|
-
enumerable: true,
|
|
114
|
-
configurable: true,
|
|
115
|
-
writable: true,
|
|
116
|
-
value: void 0
|
|
117
|
-
});
|
|
28
|
+
this.node = node;
|
|
29
|
+
this.view = view;
|
|
30
|
+
this.getPos = getPos;
|
|
31
|
+
this.config = config;
|
|
32
|
+
this.editor = editor;
|
|
118
33
|
this.updating = false;
|
|
119
34
|
const dom = document.createElement('div');
|
|
120
35
|
this.dom = dom;
|
package/package.json
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kerebron/extension-codejar",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"module": "./esm/mod.js",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"import": "./esm/mod.js"
|
|
9
|
+
},
|
|
10
|
+
"./assets/*.css": {
|
|
11
|
+
"import": "./assets/*.css"
|
|
9
12
|
}
|
|
10
13
|
},
|
|
11
14
|
"scripts": {},
|
|
12
15
|
"dependencies": {
|
|
13
|
-
"@kerebron/editor": "0.4.
|
|
14
|
-
"@kerebron/extension-basic-editor": "0.4.
|
|
15
|
-
"@kerebron/extension-lsp": "0.4.
|
|
16
|
-
"@kerebron/extension-markdown": "0.4.
|
|
17
|
-
"@kerebron/tree-sitter": "0.4.
|
|
18
|
-
"@kerebron/wasm": "0.4.
|
|
16
|
+
"@kerebron/editor": "0.4.9",
|
|
17
|
+
"@kerebron/extension-basic-editor": "0.4.9",
|
|
18
|
+
"@kerebron/extension-lsp": "0.4.9",
|
|
19
|
+
"@kerebron/extension-markdown": "0.4.9",
|
|
20
|
+
"@kerebron/tree-sitter": "0.4.9",
|
|
21
|
+
"@kerebron/wasm": "0.4.9",
|
|
19
22
|
"prosemirror-model": "1.25.3",
|
|
20
23
|
"prosemirror-state": "1.4.3",
|
|
21
24
|
"prosemirror-view": "1.40.0",
|