@kerebron/extension-codejar 0.4.19 → 0.4.21

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.
@@ -33,3 +33,103 @@
33
33
  color: gray;
34
34
  font-style: italic;
35
35
  }
36
+
37
+ /* Common captures */
38
+ .ts-property {
39
+ color: #905;
40
+ } /* Property names (e.g., in objects/CSS) */
41
+ .ts-function,
42
+ .ts-function_call {
43
+ color: #07a;
44
+ } /* Functions */
45
+ .ts-keyword {
46
+ color: #d73;
47
+ font-weight: bold;
48
+ } /* Keywords like if, return */
49
+ .ts-string {
50
+ color: #690;
51
+ } /* Strings */
52
+ .ts-number {
53
+ color: #099;
54
+ } /* Numbers */
55
+ .ts-comment {
56
+ color: #998;
57
+ font-style: italic;
58
+ } /* Comments */
59
+ .ts-perator {
60
+ color: #9a6;
61
+ } /* Operators like + - = */
62
+ .ts-type {
63
+ color: #458;
64
+ font-weight: bold;
65
+ } /* Types */
66
+ .ts-variable {
67
+ color: #333;
68
+ } /* Variables */
69
+ .ts-constant,
70
+ .ts-constant_builtin {
71
+ color: #0086b3;
72
+ } /* Constants */
73
+ .ts-punctuation,
74
+ .ts-punctuation_bracket {
75
+ color: #999;
76
+ } /* Brackets, commas */
77
+ .ts-namespace {
78
+ color: #000;
79
+ font-weight: bold;
80
+ }
81
+
82
+ /* More specific ones */
83
+ .ts-function_builtin {
84
+ color: #d73;
85
+ }
86
+ .ts-keyword_operator {
87
+ color: #d73;
88
+ }
89
+ .ts-string_special {
90
+ color: #d44;
91
+ } /* e.g., regex */
92
+ .ts-tag {
93
+ color: #008080;
94
+ } /* HTML/XML tags */
95
+ .ts-attribute {
96
+ color: #e90;
97
+ } /* Attributes */
98
+
99
+ @media (prefers-color-scheme: dark) {
100
+ /* Dark mode adjustments */
101
+ .ts-property {
102
+ color: #9cdcfe;
103
+ }
104
+ .ts-function {
105
+ color: #dcdcaa;
106
+ }
107
+ .ts-keyword {
108
+ color: #c586c0;
109
+ }
110
+ .ts-string {
111
+ color: #ce9178;
112
+ }
113
+ .ts-number {
114
+ color: #b5cea8;
115
+ }
116
+ .ts-comment {
117
+ color: #6a9955;
118
+ }
119
+ .ts-operator {
120
+ color: #d4d4d4;
121
+ }
122
+ .ts-type {
123
+ color: #4ec9b0;
124
+ }
125
+ .ts-constant {
126
+ color: #4fc1ff;
127
+ }
128
+ }
129
+
130
+ .ts-diff_plus {
131
+ color: green;
132
+ }
133
+ .ts-diff_minus {
134
+ color: red;
135
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"CodeJar.d.ts","sourceRoot":"","sources":["../src/CodeJar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAG3C,KAAK,OAAO,GAAG;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,OAAO,OAAO,CAAC,aAAa,CAAC;IACrC,SAAS,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,QAAQ,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACnB,CAAC;AAqEF,qBAAa,OAAQ,SAAQ,WAAW;IAUpC,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,SAAS;IAV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;IAgF5B,OAAO,CAAC,GAAG,EAAE,QAAQ;IAiFrB,aAAa;IA0Bb,OAAO;CAKR"}
package/esm/CodeJar.js CHANGED
@@ -102,15 +102,15 @@ export class CodeJar extends EventTarget {
102
102
  const firefoxVersion = matchFirefoxVersion
103
103
  ? parseInt(matchFirefoxVersion[1])
104
104
  : 0;
105
+ let isLegacy = false; // true if plaintext-only is not supported
106
+ if (editor.contentEditable !== 'plaintext-only' || firefoxVersion >= 136) {
107
+ isLegacy = true;
108
+ }
109
+ if (isLegacy)
110
+ editor.setAttribute('contenteditable', 'true');
105
111
  if (!opt.readOnly) {
106
112
  editor.setAttribute('contenteditable', 'plaintext-only');
107
113
  editor.setAttribute('spellcheck', this.options.spellcheck ? 'true' : 'false');
108
- let isLegacy = false; // true if plaintext-only is not supported
109
- if (editor.contentEditable !== 'plaintext-only' || firefoxVersion >= 136) {
110
- isLegacy = true;
111
- }
112
- if (isLegacy)
113
- editor.setAttribute('contenteditable', 'true');
114
114
  }
115
115
  const debounceHighlight = debounce(() => {
116
116
  const pos = this.save();
@@ -4,6 +4,7 @@ export declare class TreeSitterHighlighter {
4
4
  parser: Parser | undefined;
5
5
  hightligtScm: string | undefined;
6
6
  cdnUrl?: string | undefined;
7
+ lang?: string;
7
8
  init(lang: string): Promise<boolean>;
8
9
  highlight(code: string, decorator: Decorator): string;
9
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TreeSitterHighlighter.d.ts","sourceRoot":"","sources":["../src/TreeSitterHighlighter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAQlE,OAAO,EAAoB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE7D,qBAAa,qBAAqB;IAChC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,MAAM,CAAC,qBAAiC;IAElC,IAAI,CAAC,IAAI,EAAE,MAAM;IA0BvB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS;CAmC7C"}
1
+ {"version":3,"file":"TreeSitterHighlighter.d.ts","sourceRoot":"","sources":["../src/TreeSitterHighlighter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAQlE,OAAO,EAAoB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE7D,qBAAa,qBAAqB;IAChC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,MAAM,CAAC,qBAAiC;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;IAER,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAgC1C,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS;CAoC7C"}
@@ -4,7 +4,14 @@ export class TreeSitterHighlighter {
4
4
  parser;
5
5
  hightligtScm;
6
6
  cdnUrl = 'http://localhost:8000/wasm/';
7
+ lang;
7
8
  async init(lang) {
9
+ this.lang = lang;
10
+ if (!lang) {
11
+ this.parser = undefined;
12
+ this.hightligtScm = undefined;
13
+ return true;
14
+ }
8
15
  const treeSitterConfig = getLangTreeSitter(lang, this.cdnUrl);
9
16
  const wasmUrl = treeSitterConfig.files[0]; // TODO add support for split parsers like markdown
10
17
  const highlightUrl = treeSitterConfig.queries['highlights.scm'];
@@ -27,7 +34,8 @@ export class TreeSitterHighlighter {
27
34
  return true;
28
35
  }
29
36
  highlight(code, decorator) {
30
- if (!this.parser || !this.hightligtScm) {
37
+ if (!this.lang || !this.parser || !this.hightligtScm) {
38
+ decorator.decorationGroups['highlight'] = [];
31
39
  return decorator.highlight(code);
32
40
  }
33
41
  const tree = this.parser.parse(code);
@@ -45,7 +53,7 @@ export class TreeSitterHighlighter {
45
53
  decorations.push({
46
54
  startIndex,
47
55
  endIndex,
48
- className: 'ts-' + name,
56
+ className: 'ts-' + name.replaceAll('.', '_'),
49
57
  });
50
58
  }
51
59
  decorator.decorationGroups['highlight'] = decorations;
@@ -1 +1 @@
1
- {"version":3,"file":"codeJarBlockNodeView.d.ts","sourceRoot":"","sources":["../src/codeJarBlockNodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,UAAU,EAEV,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,UAAU,EAAiB,MAAM,kBAAkB,CAAC;AAc7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAmUrD,eAAO,MAAM,oBAAoB,EAAE,CACjC,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,UAAU,KACf,CACH,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,MAAM,GAAG,SAAS,EAChC,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,gBAAgB,EAAE,gBAAgB,KAC/B,QAgBJ,CAAC"}
1
+ {"version":3,"file":"codeJarBlockNodeView.d.ts","sourceRoot":"","sources":["../src/codeJarBlockNodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,UAAU,EAEV,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,UAAU,EAAiB,MAAM,kBAAkB,CAAC;AAc7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAkUrD,eAAO,MAAM,oBAAoB,EAAE,CACjC,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,UAAU,KACf,CACH,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,MAAM,GAAG,SAAS,EAChC,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,gBAAgB,EAAE,gBAAgB,KAC/B,QAgBJ,CAAC"}
@@ -91,7 +91,7 @@ class CodeJarBlockNodeView {
91
91
  const file = client.workspace.getFile(this.uri);
92
92
  if (file) {
93
93
  const { mapper } = file;
94
- console.log({
94
+ console.debug({
95
95
  diagnostics: detail.params.diagnostics,
96
96
  mapper,
97
97
  });
@@ -137,8 +137,8 @@ class CodeJarBlockNodeView {
137
137
  return select;
138
138
  }
139
139
  async setLang(lang) {
140
- await this.highlighter.init(this.node.attrs.lang);
141
- this.languageDropDown.value = this.node.attrs.lang || '';
140
+ this.languageDropDown.value = lang || '';
141
+ await this.highlighter.init(lang);
142
142
  this.highlight(this.element);
143
143
  this.lang = lang;
144
144
  const client = this.extensionLsp?.getClient(this.lang);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kerebron/extension-codejar",
3
- "version": "0.4.19",
3
+ "version": "0.4.21",
4
4
  "license": "MIT",
5
5
  "module": "./esm/mod.js",
6
6
  "exports": {
@@ -13,12 +13,12 @@
13
13
  },
14
14
  "scripts": {},
15
15
  "dependencies": {
16
- "@kerebron/editor": "0.4.19",
17
- "@kerebron/extension-basic-editor": "0.4.19",
18
- "@kerebron/extension-lsp": "0.4.19",
19
- "@kerebron/extension-markdown": "0.4.19",
20
- "@kerebron/tree-sitter": "0.4.19",
21
- "@kerebron/wasm": "0.4.19",
16
+ "@kerebron/editor": "0.4.21",
17
+ "@kerebron/extension-basic-editor": "0.4.21",
18
+ "@kerebron/extension-lsp": "0.4.21",
19
+ "@kerebron/extension-markdown": "0.4.21",
20
+ "@kerebron/tree-sitter": "0.4.21",
21
+ "@kerebron/wasm": "0.4.21",
22
22
  "prosemirror-model": "1.25.3",
23
23
  "prosemirror-state": "1.4.3",
24
24
  "prosemirror-view": "1.40.0",