@scalar/use-codemirror 0.11.9 → 0.11.11

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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # @scalar/use-codemirror
2
2
 
3
+ ## 0.11.11
4
+
5
+ ### Patch Changes
6
+
7
+ - b8fdc19: feat: foldable code blocks
8
+ - b8fdc19: feat: adds useDropdown hook
9
+ - Updated dependencies [a08aa37]
10
+ - Updated dependencies [ee22a82]
11
+ - Updated dependencies [6fd83dc]
12
+ - @scalar/components@0.12.45
13
+
14
+ ## 0.11.10
15
+
16
+ ### Patch Changes
17
+
18
+ - 4e5de89: fix: lint only if content is given
19
+
3
20
  ## 0.11.9
4
21
 
5
22
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"useCodeMirror.d.ts","sourceRoot":"","sources":["../../src/hooks/useCodeMirror.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EACL,UAAU,EAMX,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,GAAG,EAMT,MAAM,KAAK,CAAA;AAGZ,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAGlD,KAAK,cAAc,GAAG;IACpB,yCAAyC;IACzC,aAAa,EAAE,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IACzC,mDAAmD;IACnD,UAAU,CAAC,EAAE,gBAAgB,CAAC,SAAS,EAAE,CAAC,CAAA;IAC1C,8BAA8B;IAC9B,YAAY,CAAC,EAAE,gBAAgB,CAAC,OAAO,GAAG,SAAS,CAAC,CAAA;IACpD,mDAAmD;IACnD,QAAQ,EAAE,gBAAgB,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAA;IAC1D,2CAA2C;IAC3C,OAAO,CAAC,EAAE,gBAAgB,CAAC,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eBracketsKeymap 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";
1
+ import { autocompletion as I, completionKeymap as O, closeBrackets as j, closeBracketsKeymap as B } from "@codemirror/autocomplete";
2
+ import { indentWithTab as L, insertNewline as R } from "@codemirror/commands";
3
+ import { css as K } from "@codemirror/lang-css";
4
+ import { html as V } from "@codemirror/lang-html";
5
+ import { json as z } from "@codemirror/lang-json";
6
6
  import { xml as A } from "@codemirror/lang-xml";
7
- import { yaml as z } from "@codemirror/lang-yaml";
8
- import { syntaxHighlighting as J, defaultHighlightStyle as P, indentOnInput as U, bracketMatching as v } from "@codemirror/language";
7
+ import { yaml as D } from "@codemirror/lang-yaml";
8
+ import { syntaxHighlighting as P, defaultHighlightStyle as G, indentOnInput as J, bracketMatching as y, foldGutter as U } from "@codemirror/language";
9
9
  import { linter as W } from "@codemirror/lint";
10
10
  import { StateEffect as q } from "@codemirror/state";
11
- import { EditorView as h, highlightSpecialChars as D, keymap as u, placeholder as G, lineNumbers as Q } from "@codemirror/view";
12
- import { ref as X, watch as m, onBeforeUnmount as Y, toValue as t, computed as Z } from "vue";
13
- import { customTheme as _ } from "../themes/index.js";
14
- import { variables as $ } from "./variables.js";
15
- const d = (e) => "provider" in e && !!t(e.provider), F = {
11
+ import { EditorView as a, highlightSpecialChars as Q, keymap as d, placeholder as X, lineNumbers as Y } from "@codemirror/view";
12
+ import { ScalarIcon as Z } from "@scalar/components";
13
+ import { ref as _, watch as g, onBeforeUnmount as F, toValue as t, computed as $, h as ee, render as te } from "vue";
14
+ import { customTheme as oe } from "../themes/index.js";
15
+ import { variables as re } from "./variables.js";
16
+ const u = (e) => "provider" in e && !!t(e.provider), ne = {
16
17
  key: "Mod-a",
17
18
  run: (e) => (e.dispatch({
18
19
  selection: { anchor: 0, head: e.state.doc.length },
19
20
  scrollIntoView: !1
20
21
  }), !0)
21
- }, me = (e) => {
22
- const r = X(null);
23
- m(
22
+ }, ke = (e) => {
23
+ const r = _(null);
24
+ g(
24
25
  e.codeMirrorRef,
25
26
  () => {
26
27
  var o;
27
- (o = r.value) == null || o.destroy(), l();
28
+ (o = r.value) == null || o.destroy(), c();
28
29
  },
29
30
  { immediate: !0 }
30
- ), Y(() => {
31
+ ), F(() => {
31
32
  var o;
32
33
  return (o = r.value) == null ? void 0 : o.destroy();
33
34
  });
34
- function l() {
35
+ function c() {
35
36
  if (e.codeMirrorRef.value) {
36
- const o = d(e) ? t(e.provider) : null, a = x({
37
- ...s.value,
37
+ const o = u(e) ? t(e.provider) : null, h = x({
38
+ ...f.value,
38
39
  provider: o
39
40
  });
40
- r.value = new h({
41
+ r.value = new a({
41
42
  parent: e.codeMirrorRef.value,
42
- extensions: a
43
- }), d(e) || n(t(e.content));
43
+ extensions: h
44
+ }), u(e) || l(t(e.content));
44
45
  }
45
46
  }
46
- const s = Z(() => ({
47
+ const f = $(() => ({
47
48
  onChange: e.onChange,
48
49
  onBlur: e.onBlur,
49
50
  onFocus: e.onFocus,
@@ -60,29 +61,29 @@ const d = (e) => "provider" in e && !!t(e.provider), F = {
60
61
  additionalExtensions: t(e.extensions),
61
62
  placeholder: t(e.placeholder)
62
63
  }));
63
- m(
64
- () => d(e) ? t(e.provider) : null,
64
+ g(
65
+ () => u(e) ? t(e.provider) : null,
65
66
  () => {
66
67
  var o;
67
- d(e) && ((o = r.value) == null || o.destroy(), l());
68
+ u(e) && ((o = r.value) == null || o.destroy(), c());
68
69
  }
69
- ), m(
70
- s,
70
+ ), g(
71
+ f,
71
72
  () => {
72
73
  if (r.value) {
73
- const o = d(e) ? t(e.provider) : null, a = x({
74
- ...s.value,
74
+ const o = u(e) ? t(e.provider) : null, h = x({
75
+ ...f.value,
75
76
  provider: o
76
77
  });
77
78
  r.value.dispatch({
78
- effects: q.reconfigure.of(a)
79
+ effects: q.reconfigure.of(h)
79
80
  });
80
81
  } else
81
82
  return;
82
83
  },
83
84
  { immediate: !0 }
84
85
  );
85
- const n = (o = "") => {
86
+ const l = (o = "") => {
86
87
  r.value && r.value.state.doc.toString() !== o && r.value.dispatch({
87
88
  changes: {
88
89
  from: 0,
@@ -97,49 +98,50 @@ const d = (e) => "provider" in e && !!t(e.provider), F = {
97
98
  }
98
99
  });
99
100
  };
100
- return m(
101
+ return g(
101
102
  () => t(e.content),
102
103
  () => {
103
- d(e) || n(t(e.content));
104
+ u(e) || l(t(e.content));
104
105
  },
105
106
  { immediate: !0 }
106
107
  ), {
107
108
  /** Replaces the current content with the given value. */
108
- setCodeMirrorContent: n,
109
+ setCodeMirrorContent: l,
109
110
  /** Codemirror instance */
110
111
  codeMirror: r
111
112
  };
112
- }, y = {
113
- html: R,
114
- json: V,
115
- yaml: z,
116
- css: L,
113
+ }, k = {
114
+ html: V,
115
+ json: z,
116
+ yaml: D,
117
+ css: K,
117
118
  xml: A
118
119
  };
119
120
  function x({
120
121
  onChange: e,
121
122
  onBlur: r,
122
- onFocus: l,
123
- provider: s,
124
- language: n,
123
+ onFocus: c,
124
+ provider: f,
125
+ language: l,
125
126
  classes: o = [],
126
- readOnly: a = !1,
127
+ readOnly: h = !1,
127
128
  lineNumbers: E = !1,
128
- withVariables: k = !1,
129
- disableEnter: C = !1,
130
- disableCloseBrackets: M = !1,
131
- disableTabIndent: S = !1,
132
- withoutTheme: T = !1,
129
+ withVariables: C = !1,
130
+ disableEnter: M = !1,
131
+ disableCloseBrackets: S = !1,
132
+ disableTabIndent: T = !1,
133
+ withoutTheme: w = !1,
133
134
  lint: N = !1,
134
- additionalExtensions: w = [],
135
- placeholder: g
135
+ additionalExtensions: H = [],
136
+ placeholder: p
136
137
  }) {
137
- const i = [
138
- D(),
139
- J(P, { fallback: !0 }),
140
- h.theme({
138
+ const n = [
139
+ Q(),
140
+ P(G, { fallback: !0 }),
141
+ a.theme({
141
142
  ".cm-line": {
142
- lineHeight: "20px"
143
+ lineHeight: "20px",
144
+ padding: "0 2px 0 4px"
143
145
  },
144
146
  ".cm-gutterElement": {
145
147
  lineHeight: "20px"
@@ -154,32 +156,37 @@ function x({
154
156
  ".cm-diagnostic-error": {
155
157
  borderLeft: "0",
156
158
  color: "#dc1b19"
159
+ },
160
+ ".cm-foldPlaceholder": {
161
+ background: "var(--scalar-background-1)",
162
+ border: "none",
163
+ fontFamily: "var(--scalar-font)"
157
164
  }
158
165
  }),
159
166
  // Listen to updates
160
- h.updateListener.of((f) => {
161
- f.docChanged && (e == null || e(f.state.doc.toString()));
167
+ a.updateListener.of((s) => {
168
+ s.docChanged && (e == null || e(s.state.doc.toString()));
162
169
  }),
163
- h.domEventHandlers({
164
- blur: (f, c) => {
165
- r == null || r(c.state.doc.toString());
170
+ a.domEventHandlers({
171
+ blur: (s, i) => {
172
+ r == null || r(i.state.doc.toString());
166
173
  },
167
- focus: (f, c) => {
168
- l == null || l(c.state.doc.toString());
174
+ focus: (s, i) => {
175
+ c == null || c(i.state.doc.toString());
169
176
  }
170
177
  }),
171
178
  // Add Classes
172
- h.editorAttributes.of({ class: o.join(" ") }),
173
- ...w
179
+ a.editorAttributes.of({ class: o.join(" ") }),
180
+ ...H
174
181
  ];
175
- if (s && i.push(s), T || i.push(_), a ? i.push(h.editable.of(!1)) : (i.push(
176
- U(),
177
- v(),
178
- H(),
179
- u.of([...j, F]),
180
- v()
181
- ), M || i.push(B(), u.of([...I])), S ? i.push(
182
- u.of([
182
+ if (f && n.push(f), w || n.push(oe), h ? n.push(a.editable.of(!1)) : (n.push(
183
+ J(),
184
+ y(),
185
+ I(),
186
+ d.of([...O, ne]),
187
+ y()
188
+ ), S || n.push(j(), d.of([...B])), T ? n.push(
189
+ d.of([
183
190
  {
184
191
  key: "Tab",
185
192
  run: () => !1,
@@ -188,25 +195,39 @@ function x({
188
195
  // Prevent default Shift+Tab behavior
189
196
  }
190
197
  ])
191
- ) : i.push(u.of([O]))), g && i.push(G(g)), n && y[n] && i.push(y[n]()), N && n === "json") {
192
- const f = W((c) => {
193
- const p = [];
194
- try {
195
- JSON.parse(c.state.doc.toString());
196
- } catch (b) {
197
- b instanceof Error && p.push({
198
- from: 0,
199
- to: c.state.doc.length,
200
- severity: "error",
201
- message: b.message
198
+ ) : n.push(d.of([L]))), p && n.push(X(p)), E && n.push(Y()), l && k[l] && n.push(
199
+ k[l](),
200
+ U({
201
+ markerDOM: (s) => {
202
+ const i = document.createElement("div");
203
+ i.classList.add("cm-foldMarker");
204
+ const m = ee(Z, {
205
+ icon: s ? "ChevronDown" : "ChevronRight",
206
+ size: "xs"
202
207
  });
208
+ return te(m, i), i;
203
209
  }
204
- return p;
210
+ })
211
+ ), N && l === "json") {
212
+ const s = W((i) => {
213
+ const m = [], b = i.state.doc.toString();
214
+ if (b.trim())
215
+ try {
216
+ JSON.parse(b);
217
+ } catch (v) {
218
+ v instanceof Error && m.push({
219
+ from: 0,
220
+ to: i.state.doc.length,
221
+ severity: "error",
222
+ message: v.message
223
+ });
224
+ }
225
+ return m;
205
226
  });
206
- i.push(f);
227
+ n.push(s);
207
228
  }
208
- return E && i.push(Q()), k && i.push($()), C ? i.push(
209
- u.of([
229
+ return C && n.push(re()), M ? n.push(
230
+ d.of([
210
231
  {
211
232
  key: "Enter",
212
233
  run: () => !0
@@ -221,15 +242,15 @@ function x({
221
242
  run: () => !0
222
243
  }
223
244
  ])
224
- ) : i.push(
225
- u.of([
245
+ ) : n.push(
246
+ d.of([
226
247
  {
227
248
  key: "Enter",
228
- run: K
249
+ run: R
229
250
  }
230
251
  ])
231
- ), i;
252
+ ), n;
232
253
  }
233
254
  export {
234
- me as useCodeMirror
255
+ ke as useCodeMirror
235
256
  };
@@ -0,0 +1,17 @@
1
+ import type { EditorView } from '@codemirror/view';
2
+ import { type Ref } from 'vue';
3
+ /** Custom hook to manage a dropdown in a CodeMirror editor */
4
+ export declare function useDropdown(params: {
5
+ codeMirror: Ref<EditorView | null>;
6
+ onSelect?: (item: string) => void;
7
+ query: Ref<string>;
8
+ showDropdown: Ref<boolean>;
9
+ dropdownPosition: Ref<{
10
+ left: number;
11
+ top: number;
12
+ }>;
13
+ }): {
14
+ handleDropdownSelect: (item: string) => void;
15
+ updateDropdownVisibility: () => void;
16
+ };
17
+ //# sourceMappingURL=useDropdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDropdown.d.ts","sourceRoot":"","sources":["../../src/hooks/useDropdown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,KAAK,GAAG,EAAS,MAAM,KAAK,CAAA;AAErC,8DAA8D;AAC9D,wBAAgB,WAAW,CAAC,MAAM,EAAE;IAClC,UAAU,EAAE,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,CAAA;IAClC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAClB,YAAY,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAC1B,gBAAgB,EAAE,GAAG,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACrD;iCA2BqC,MAAM;;EAqC3C"}
@@ -0,0 +1,42 @@
1
+ import { watch as v } from "vue";
2
+ function x(h) {
3
+ const { codeMirror: e, query: n, showDropdown: r, dropdownPosition: u } = h;
4
+ function c() {
5
+ var t;
6
+ return ((t = e.value) == null ? void 0 : t.state.selection.main.head) || 0;
7
+ }
8
+ function i(t) {
9
+ var o;
10
+ return (o = e.value) == null ? void 0 : o.coordsAtPos(t);
11
+ }
12
+ function d() {
13
+ const t = c(), o = i(t - n.value.length - 2);
14
+ o && (u.value = {
15
+ left: o.left,
16
+ top: Math.max(o.bottom)
17
+ });
18
+ }
19
+ v(n, d);
20
+ function m(t) {
21
+ var p;
22
+ const o = `{{${t}}}`, s = c(), l = Math.max(0, s - n.value.length - 2), a = s;
23
+ (p = e.value) == null || p.dispatch({
24
+ changes: { from: l, to: a, insert: o }
25
+ }), r.value = !1;
26
+ }
27
+ function f() {
28
+ var a;
29
+ const t = c(), o = ((a = e.value) == null ? void 0 : a.state.doc.sliceString(0, t)) || "", s = o.lastIndexOf("{{"), l = o.lastIndexOf("}}");
30
+ s > l ? (n.value = o.slice(s + 2), r.value = !0, u.value = i(t) || { left: 0, top: 0 }, n.value === "" && d()) : r.value = !1;
31
+ }
32
+ return v(() => {
33
+ var t;
34
+ return (t = e.value) == null ? void 0 : t.state.doc.toString();
35
+ }, f), {
36
+ handleDropdownSelect: m,
37
+ updateDropdownVisibility: f
38
+ };
39
+ }
40
+ export {
41
+ x as useDropdown
42
+ };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export { yCollab } from 'y-codemirror.next';
3
3
  export { colorPicker } from '@replit/codemirror-css-color-picker';
4
4
  export { Decoration, type DecorationSet, EditorView, ViewPlugin, type ViewUpdate, WidgetType, } from '@codemirror/view';
5
5
  export { CodeMirror } from './components/CodeMirror';
6
+ export { useDropdown } from './hooks/useDropdown.js';
6
7
  export * from './hooks';
7
8
  export * from './types';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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"}
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,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
package/dist/index.js CHANGED
@@ -1,18 +1,20 @@
1
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";
2
+ import { yCollab as i } from "y-codemirror.next";
3
+ import { colorPicker as d } from "@replit/codemirror-css-color-picker";
4
+ import { Decoration as x, EditorView as a, ViewPlugin as l, WidgetType as u } from "@codemirror/view";
5
+ import { useDropdown as n } from "./hooks/useDropdown.js";
6
+ import { default as s } from "./components/CodeMirror/CodeMirror.vue.js";
6
7
  import { useCodeMirror as C } from "./hooks/useCodeMirror.js";
7
8
  export {
8
- g as CodeMirror,
9
- l as Decoration,
10
- m as EditorView,
9
+ s as CodeMirror,
10
+ x as Decoration,
11
+ a as EditorView,
11
12
  e as RangeSetBuilder,
12
13
  t as StateEffect,
13
- x as ViewPlugin,
14
- c as WidgetType,
15
- a as colorPicker,
14
+ l as ViewPlugin,
15
+ u as WidgetType,
16
+ d as colorPicker,
16
17
  C as useCodeMirror,
17
- f as yCollab
18
+ n as useDropdown,
19
+ i as yCollab
18
20
  };
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "vue",
17
17
  "vue3"
18
18
  ],
19
- "version": "0.11.9",
19
+ "version": "0.11.11",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -52,7 +52,8 @@
52
52
  "@replit/codemirror-css-color-picker": "^6.1.0",
53
53
  "@uiw/codemirror-themes": "^4.21.21",
54
54
  "codemirror": "^6.0.0",
55
- "vue": "^3.4.29"
55
+ "vue": "^3.4.29",
56
+ "@scalar/components": "0.12.45"
56
57
  },
57
58
  "devDependencies": {
58
59
  "@vitejs/plugin-vue": "^5.0.4",