@scalar/use-codemirror 0.11.6 → 0.11.7
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/CHANGELOG.md +6 -0
- package/dist/hooks/useCodeMirror.js +82 -75
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -8
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { autocompletion as
|
|
2
|
-
import { indentWithTab as O } from "@codemirror/commands";
|
|
3
|
-
import { css as
|
|
4
|
-
import { html as
|
|
5
|
-
import { json as
|
|
6
|
-
import { yaml as
|
|
7
|
-
import { syntaxHighlighting as
|
|
8
|
-
import { linter as
|
|
9
|
-
import { StateEffect as
|
|
10
|
-
import { EditorView as
|
|
11
|
-
import { ref as
|
|
12
|
-
import { customTheme as
|
|
13
|
-
import { variables as
|
|
14
|
-
const
|
|
1
|
+
import { autocompletion as H, completionKeymap as j, closeBrackets as B, closeBracketsKeymap as I } from "@codemirror/autocomplete";
|
|
2
|
+
import { indentWithTab as O, insertNewline as K } from "@codemirror/commands";
|
|
3
|
+
import { css as L } from "@codemirror/lang-css";
|
|
4
|
+
import { html as R } from "@codemirror/lang-html";
|
|
5
|
+
import { json as V } from "@codemirror/lang-json";
|
|
6
|
+
import { yaml as A } from "@codemirror/lang-yaml";
|
|
7
|
+
import { syntaxHighlighting as z, defaultHighlightStyle as J, indentOnInput as P, bracketMatching as v } from "@codemirror/language";
|
|
8
|
+
import { linter as U } from "@codemirror/lint";
|
|
9
|
+
import { StateEffect as W } from "@codemirror/state";
|
|
10
|
+
import { EditorView as h, highlightSpecialChars as q, keymap as u, placeholder as D, lineNumbers as G } from "@codemirror/view";
|
|
11
|
+
import { ref as Q, watch as m, onBeforeUnmount as X, toValue as t, computed as Y } from "vue";
|
|
12
|
+
import { customTheme as Z } from "../themes/index.js";
|
|
13
|
+
import { variables as _ } from "./variables.js";
|
|
14
|
+
const d = (e) => "provider" in e && !!t(e.provider), $ = {
|
|
15
15
|
key: "Mod-a",
|
|
16
16
|
run: (e) => (e.dispatch({
|
|
17
17
|
selection: { anchor: 0, head: e.state.doc.length },
|
|
18
18
|
scrollIntoView: !1
|
|
19
19
|
}), !0)
|
|
20
|
-
},
|
|
21
|
-
const i =
|
|
20
|
+
}, he = (e) => {
|
|
21
|
+
const i = Q(null);
|
|
22
22
|
m(
|
|
23
23
|
e.codeMirrorRef,
|
|
24
24
|
() => {
|
|
25
25
|
var o;
|
|
26
|
-
(o = i.value) == null || o.destroy(),
|
|
26
|
+
(o = i.value) == null || o.destroy(), s();
|
|
27
27
|
},
|
|
28
28
|
{ immediate: !0 }
|
|
29
|
-
),
|
|
29
|
+
), X(() => {
|
|
30
30
|
var o;
|
|
31
31
|
return (o = i.value) == null ? void 0 : o.destroy();
|
|
32
32
|
});
|
|
33
|
-
function
|
|
33
|
+
function s() {
|
|
34
34
|
if (e.codeMirrorRef.value) {
|
|
35
|
-
const o =
|
|
36
|
-
...
|
|
35
|
+
const o = d(e) ? t(e.provider) : null, a = E({
|
|
36
|
+
...l.value,
|
|
37
37
|
provider: o
|
|
38
38
|
});
|
|
39
|
-
i.value = new
|
|
39
|
+
i.value = new h({
|
|
40
40
|
parent: e.codeMirrorRef.value,
|
|
41
|
-
extensions:
|
|
42
|
-
}),
|
|
41
|
+
extensions: a
|
|
42
|
+
}), d(e) || n(t(e.content));
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
const
|
|
45
|
+
const l = Y(() => ({
|
|
46
46
|
onChange: e.onChange,
|
|
47
47
|
onBlur: e.onBlur,
|
|
48
48
|
onFocus: e.onFocus,
|
|
@@ -60,21 +60,21 @@ const u = (e) => "provider" in e && !!t(e.provider), _ = {
|
|
|
60
60
|
placeholder: t(e.placeholder)
|
|
61
61
|
}));
|
|
62
62
|
m(
|
|
63
|
-
() =>
|
|
63
|
+
() => d(e) ? t(e.provider) : null,
|
|
64
64
|
() => {
|
|
65
65
|
var o;
|
|
66
|
-
|
|
66
|
+
d(e) && ((o = i.value) == null || o.destroy(), s());
|
|
67
67
|
}
|
|
68
68
|
), m(
|
|
69
|
-
|
|
69
|
+
l,
|
|
70
70
|
() => {
|
|
71
71
|
if (i.value) {
|
|
72
|
-
const o =
|
|
73
|
-
...
|
|
72
|
+
const o = d(e) ? t(e.provider) : null, a = E({
|
|
73
|
+
...l.value,
|
|
74
74
|
provider: o
|
|
75
75
|
});
|
|
76
76
|
i.value.dispatch({
|
|
77
|
-
effects:
|
|
77
|
+
effects: W.reconfigure.of(a)
|
|
78
78
|
});
|
|
79
79
|
} else
|
|
80
80
|
return;
|
|
@@ -99,7 +99,7 @@ const u = (e) => "provider" in e && !!t(e.provider), _ = {
|
|
|
99
99
|
return m(
|
|
100
100
|
() => t(e.content),
|
|
101
101
|
() => {
|
|
102
|
-
|
|
102
|
+
d(e) || n(t(e.content));
|
|
103
103
|
},
|
|
104
104
|
{ immediate: !0 }
|
|
105
105
|
), {
|
|
@@ -109,33 +109,33 @@ const u = (e) => "provider" in e && !!t(e.provider), _ = {
|
|
|
109
109
|
codeMirror: i
|
|
110
110
|
};
|
|
111
111
|
}, y = {
|
|
112
|
-
html:
|
|
113
|
-
json:
|
|
114
|
-
yaml:
|
|
115
|
-
css:
|
|
112
|
+
html: R,
|
|
113
|
+
json: V,
|
|
114
|
+
yaml: A,
|
|
115
|
+
css: L
|
|
116
116
|
};
|
|
117
|
-
function
|
|
117
|
+
function E({
|
|
118
118
|
onChange: e,
|
|
119
119
|
onBlur: i,
|
|
120
|
-
onFocus:
|
|
121
|
-
provider:
|
|
120
|
+
onFocus: s,
|
|
121
|
+
provider: l,
|
|
122
122
|
language: n,
|
|
123
123
|
classes: o = [],
|
|
124
|
-
readOnly:
|
|
125
|
-
lineNumbers:
|
|
126
|
-
withVariables:
|
|
124
|
+
readOnly: a = !1,
|
|
125
|
+
lineNumbers: k = !1,
|
|
126
|
+
withVariables: x = !1,
|
|
127
127
|
disableEnter: C = !1,
|
|
128
128
|
disableCloseBrackets: M = !1,
|
|
129
129
|
disableTabIndent: S = !1,
|
|
130
130
|
withoutTheme: T = !1,
|
|
131
|
-
lint:
|
|
132
|
-
additionalExtensions:
|
|
131
|
+
lint: N = !1,
|
|
132
|
+
additionalExtensions: w = [],
|
|
133
133
|
placeholder: g
|
|
134
134
|
}) {
|
|
135
135
|
const r = [
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
q(),
|
|
137
|
+
z(J, { fallback: !0 }),
|
|
138
|
+
h.theme({
|
|
139
139
|
".cm-line": {
|
|
140
140
|
lineHeight: "20px"
|
|
141
141
|
},
|
|
@@ -155,29 +155,29 @@ function x({
|
|
|
155
155
|
}
|
|
156
156
|
}),
|
|
157
157
|
// Listen to updates
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
h.updateListener.of((f) => {
|
|
159
|
+
f.docChanged && (e == null || e(f.state.doc.toString()));
|
|
160
160
|
}),
|
|
161
|
-
|
|
162
|
-
blur: (
|
|
163
|
-
i == null || i(
|
|
161
|
+
h.domEventHandlers({
|
|
162
|
+
blur: (f, c) => {
|
|
163
|
+
i == null || i(c.state.doc.toString());
|
|
164
164
|
},
|
|
165
|
-
focus: (
|
|
166
|
-
|
|
165
|
+
focus: (f, c) => {
|
|
166
|
+
s == null || s(c.state.doc.toString());
|
|
167
167
|
}
|
|
168
168
|
}),
|
|
169
169
|
// Add Classes
|
|
170
|
-
|
|
171
|
-
...
|
|
170
|
+
h.editorAttributes.of({ class: o.join(" ") }),
|
|
171
|
+
...w
|
|
172
172
|
];
|
|
173
|
-
if (
|
|
174
|
-
|
|
173
|
+
if (l && r.push(l), T || r.push(Z), a ? r.push(h.editable.of(!1)) : (r.push(
|
|
174
|
+
P(),
|
|
175
175
|
v(),
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
H(),
|
|
177
|
+
u.of([...j, $]),
|
|
178
178
|
v()
|
|
179
|
-
), M || r.push(B(),
|
|
180
|
-
|
|
179
|
+
), M || r.push(B(), u.of([...I])), S ? r.push(
|
|
180
|
+
u.of([
|
|
181
181
|
{
|
|
182
182
|
key: "Tab",
|
|
183
183
|
run: () => !1,
|
|
@@ -186,25 +186,25 @@ function x({
|
|
|
186
186
|
// Prevent default Shift+Tab behavior
|
|
187
187
|
}
|
|
188
188
|
])
|
|
189
|
-
) : r.push(
|
|
190
|
-
const
|
|
191
|
-
const
|
|
189
|
+
) : r.push(u.of([O]))), g && r.push(D(g)), n && y[n] && r.push(y[n]()), N && n === "json") {
|
|
190
|
+
const f = U((c) => {
|
|
191
|
+
const p = [];
|
|
192
192
|
try {
|
|
193
|
-
JSON.parse(
|
|
194
|
-
} catch (
|
|
195
|
-
|
|
193
|
+
JSON.parse(c.state.doc.toString());
|
|
194
|
+
} catch (b) {
|
|
195
|
+
b instanceof Error && p.push({
|
|
196
196
|
from: 0,
|
|
197
|
-
to:
|
|
197
|
+
to: c.state.doc.length,
|
|
198
198
|
severity: "error",
|
|
199
|
-
message:
|
|
199
|
+
message: b.message
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
|
-
return
|
|
202
|
+
return p;
|
|
203
203
|
});
|
|
204
|
-
r.push(
|
|
204
|
+
r.push(f);
|
|
205
205
|
}
|
|
206
|
-
return
|
|
207
|
-
|
|
206
|
+
return k && r.push(G()), x && r.push(_()), C ? r.push(
|
|
207
|
+
u.of([
|
|
208
208
|
{
|
|
209
209
|
key: "Enter",
|
|
210
210
|
run: () => !0
|
|
@@ -219,8 +219,15 @@ function x({
|
|
|
219
219
|
run: () => !0
|
|
220
220
|
}
|
|
221
221
|
])
|
|
222
|
+
) : r.push(
|
|
223
|
+
u.of([
|
|
224
|
+
{
|
|
225
|
+
key: "Enter",
|
|
226
|
+
run: K
|
|
227
|
+
}
|
|
228
|
+
])
|
|
222
229
|
), r;
|
|
223
230
|
}
|
|
224
231
|
export {
|
|
225
|
-
|
|
232
|
+
he as useCodeMirror
|
|
226
233
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { type Extension } from '@codemirror/state';
|
|
1
|
+
export { type Extension, RangeSetBuilder, StateEffect } from '@codemirror/state';
|
|
2
2
|
export { yCollab } from 'y-codemirror.next';
|
|
3
3
|
export { colorPicker } from '@replit/codemirror-css-color-picker';
|
|
4
|
+
export { Decoration, type DecorationSet, EditorView, ViewPlugin, type ViewUpdate, WidgetType, } from '@codemirror/view';
|
|
4
5
|
export { CodeMirror } from './components/CodeMirror';
|
|
5
6
|
export * from './hooks';
|
|
6
7
|
export * from './types';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAA;AAEjE,OAAO,EACL,UAAU,EACV,KAAK,aAAa,EAClB,UAAU,EACV,UAAU,EACV,KAAK,UAAU,EACf,UAAU,GACX,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { RangeSetBuilder as e, StateEffect as t } from "@codemirror/state";
|
|
2
|
+
import { yCollab as f } from "y-codemirror.next";
|
|
3
|
+
import { colorPicker as a } from "@replit/codemirror-css-color-picker";
|
|
4
|
+
import { Decoration as l, EditorView as m, ViewPlugin as x, WidgetType as c } from "@codemirror/view";
|
|
5
|
+
import { default as g } from "./components/CodeMirror/CodeMirror.vue.js";
|
|
6
|
+
import { useCodeMirror as C } from "./hooks/useCodeMirror.js";
|
|
5
7
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
e as
|
|
8
|
+
g as CodeMirror,
|
|
9
|
+
l as Decoration,
|
|
10
|
+
m as EditorView,
|
|
11
|
+
e as RangeSetBuilder,
|
|
12
|
+
t as StateEffect,
|
|
13
|
+
x as ViewPlugin,
|
|
14
|
+
c as WidgetType,
|
|
15
|
+
a as colorPicker,
|
|
16
|
+
C as useCodeMirror,
|
|
17
|
+
f as yCollab
|
|
10
18
|
};
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"vue",
|
|
17
17
|
"vue3"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.11.
|
|
19
|
+
"version": "0.11.7",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@replit/codemirror-css-color-picker": "^6.1.0",
|
|
52
52
|
"@uiw/codemirror-themes": "^4.21.21",
|
|
53
53
|
"codemirror": "^6.0.0",
|
|
54
|
-
"vue": "^3.4.
|
|
54
|
+
"vue": "^3.4.29"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@vitejs/plugin-vue": "^5.0.4",
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
"tsc-alias": "^1.8.8",
|
|
60
60
|
"vite": "^5.2.10",
|
|
61
61
|
"vitest": "^1.6.0",
|
|
62
|
-
"vue": "^3.4.
|
|
62
|
+
"vue": "^3.4.29",
|
|
63
63
|
"vue-tsc": "^2.0.13",
|
|
64
64
|
"y-codemirror.next": "^0.3.2",
|
|
65
65
|
"yjs": "^13.6.0",
|
|
66
|
-
"@scalar/build-tooling": "0.1.
|
|
66
|
+
"@scalar/build-tooling": "0.1.10"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"build": "vite build && pnpm types:build && tsc-alias -p tsconfig.build.json",
|