@scalar/use-codemirror 0.11.10 → 0.11.12

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,23 @@
1
1
  # @scalar/use-codemirror
2
2
 
3
+ ## 0.11.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [b856652]
8
+ - @scalar/components@0.12.46
9
+
10
+ ## 0.11.11
11
+
12
+ ### Patch Changes
13
+
14
+ - b8fdc19: feat: foldable code blocks
15
+ - b8fdc19: feat: adds useDropdown hook
16
+ - Updated dependencies [a08aa37]
17
+ - Updated dependencies [ee22a82]
18
+ - Updated dependencies [6fd83dc]
19
+ - @scalar/components@0.12.45
20
+
3
21
  ## 0.11.10
4
22
 
5
23
  ### 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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as B, closeBrackets as I, closeBracketsKeymap as O } from "@codemirror/autocomplete";
2
- import { indentWithTab as K, insertNewline as L } from "@codemirror/commands";
3
- import { css as R } from "@codemirror/lang-css";
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
4
  import { html as V } from "@codemirror/lang-html";
5
- import { json as A } from "@codemirror/lang-json";
6
- import { xml as z } from "@codemirror/lang-xml";
7
- import { yaml as J } from "@codemirror/lang-yaml";
8
- import { syntaxHighlighting as P, defaultHighlightStyle as U, indentOnInput as W, bracketMatching as y } from "@codemirror/language";
9
- import { linter as q } from "@codemirror/lint";
10
- import { StateEffect as D } from "@codemirror/state";
11
- import { EditorView as h, highlightSpecialChars as G, keymap as u, placeholder as Q, lineNumbers as X } from "@codemirror/view";
12
- import { ref as Y, watch as m, onBeforeUnmount as Z, toValue as t, computed as _ } from "vue";
13
- import { customTheme as $ } from "../themes/index.js";
14
- import { variables as F } from "./variables.js";
15
- const d = (e) => "provider" in e && !!t(e.provider), ee = {
5
+ import { json as z } from "@codemirror/lang-json";
6
+ import { xml as A } from "@codemirror/lang-xml";
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
+ import { linter as W } from "@codemirror/lint";
10
+ import { StateEffect as q } from "@codemirror/state";
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
- }, ge = (e) => {
22
- const i = Y(null);
23
- m(
22
+ }, ke = (e) => {
23
+ const r = _(null);
24
+ g(
24
25
  e.codeMirrorRef,
25
26
  () => {
26
27
  var o;
27
- (o = i.value) == null || o.destroy(), s();
28
+ (o = r.value) == null || o.destroy(), c();
28
29
  },
29
30
  { immediate: !0 }
30
- ), Z(() => {
31
+ ), F(() => {
31
32
  var o;
32
- return (o = i.value) == null ? void 0 : o.destroy();
33
+ return (o = r.value) == null ? void 0 : o.destroy();
33
34
  });
34
- function s() {
35
+ function c() {
35
36
  if (e.codeMirrorRef.value) {
36
- const o = d(e) ? t(e.provider) : null, a = E({
37
- ...l.value,
37
+ const o = u(e) ? t(e.provider) : null, h = x({
38
+ ...f.value,
38
39
  provider: o
39
40
  });
40
- i.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 l = _(() => ({
47
+ const f = $(() => ({
47
48
  onChange: e.onChange,
48
49
  onBlur: e.onBlur,
49
50
  onFocus: e.onFocus,
@@ -60,86 +61,87 @@ const d = (e) => "provider" in e && !!t(e.provider), ee = {
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 = i.value) == null || o.destroy(), s());
68
+ u(e) && ((o = r.value) == null || o.destroy(), c());
68
69
  }
69
- ), m(
70
- l,
70
+ ), g(
71
+ f,
71
72
  () => {
72
- if (i.value) {
73
- const o = d(e) ? t(e.provider) : null, a = E({
74
- ...l.value,
73
+ if (r.value) {
74
+ const o = u(e) ? t(e.provider) : null, h = x({
75
+ ...f.value,
75
76
  provider: o
76
77
  });
77
- i.value.dispatch({
78
- effects: D.reconfigure.of(a)
78
+ r.value.dispatch({
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
- i.value && i.value.state.doc.toString() !== o && i.value.dispatch({
86
+ const l = (o = "") => {
87
+ r.value && r.value.state.doc.toString() !== o && r.value.dispatch({
87
88
  changes: {
88
89
  from: 0,
89
- to: i.value.state.doc.length,
90
+ to: r.value.state.doc.length,
90
91
  insert: o
91
92
  },
92
93
  selection: {
93
94
  anchor: Math.min(
94
- i.value.state.selection.main.anchor,
95
+ r.value.state.selection.main.anchor,
95
96
  o.length
96
97
  )
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
- codeMirror: i
111
+ codeMirror: r
111
112
  };
112
- }, x = {
113
+ }, k = {
113
114
  html: V,
114
- json: A,
115
- yaml: J,
116
- css: R,
117
- xml: z
115
+ json: z,
116
+ yaml: D,
117
+ css: K,
118
+ xml: A
118
119
  };
119
- function E({
120
+ function x({
120
121
  onChange: e,
121
- onBlur: i,
122
- onFocus: s,
123
- provider: l,
124
- language: n,
122
+ onBlur: r,
123
+ onFocus: c,
124
+ provider: f,
125
+ language: l,
125
126
  classes: o = [],
126
- readOnly: a = !1,
127
- lineNumbers: k = !1,
127
+ readOnly: h = !1,
128
+ lineNumbers: E = !1,
128
129
  withVariables: C = !1,
129
130
  disableEnter: M = !1,
130
131
  disableCloseBrackets: S = !1,
131
132
  disableTabIndent: T = !1,
132
- withoutTheme: N = !1,
133
- lint: w = !1,
133
+ withoutTheme: w = !1,
134
+ lint: N = !1,
134
135
  additionalExtensions: H = [],
135
- placeholder: g
136
+ placeholder: p
136
137
  }) {
137
- const r = [
138
- G(),
139
- P(U, { 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 E({
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
- i == null || i(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
- s == null || s(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(" ") }),
179
+ a.editorAttributes.of({ class: o.join(" ") }),
173
180
  ...H
174
181
  ];
175
- if (l && r.push(l), N || r.push($), a ? r.push(h.editable.of(!1)) : (r.push(
176
- W(),
182
+ if (f && n.push(f), w || n.push(oe), h ? n.push(a.editable.of(!1)) : (n.push(
183
+ J(),
177
184
  y(),
178
- j(),
179
- u.of([...B, ee]),
185
+ I(),
186
+ d.of([...O, ne]),
180
187
  y()
181
- ), S || r.push(I(), u.of([...O])), T ? r.push(
182
- u.of([
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,26 +195,39 @@ function E({
188
195
  // Prevent default Shift+Tab behavior
189
196
  }
190
197
  ])
191
- ) : r.push(u.of([K]))), g && r.push(Q(g)), n && x[n] && r.push(x[n]()), w && n === "json") {
192
- const f = q((c) => {
193
- const p = [], b = c.state.doc.toString();
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"
207
+ });
208
+ return te(m, i), i;
209
+ }
210
+ })
211
+ ), N && l === "json") {
212
+ const s = W((i) => {
213
+ const m = [], b = i.state.doc.toString();
194
214
  if (b.trim())
195
215
  try {
196
216
  JSON.parse(b);
197
217
  } catch (v) {
198
- v instanceof Error && p.push({
218
+ v instanceof Error && m.push({
199
219
  from: 0,
200
- to: c.state.doc.length,
220
+ to: i.state.doc.length,
201
221
  severity: "error",
202
222
  message: v.message
203
223
  });
204
224
  }
205
- return p;
225
+ return m;
206
226
  });
207
- r.push(f);
227
+ n.push(s);
208
228
  }
209
- return k && r.push(X()), C && r.push(F()), M ? r.push(
210
- u.of([
229
+ return C && n.push(re()), M ? n.push(
230
+ d.of([
211
231
  {
212
232
  key: "Enter",
213
233
  run: () => !0
@@ -222,15 +242,15 @@ function E({
222
242
  run: () => !0
223
243
  }
224
244
  ])
225
- ) : r.push(
226
- u.of([
245
+ ) : n.push(
246
+ d.of([
227
247
  {
228
248
  key: "Enter",
229
- run: L
249
+ run: R
230
250
  }
231
251
  ])
232
- ), r;
252
+ ), n;
233
253
  }
234
254
  export {
235
- ge as useCodeMirror
255
+ ke as useCodeMirror
236
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.10",
19
+ "version": "0.11.12",
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.46"
56
57
  },
57
58
  "devDependencies": {
58
59
  "@vitejs/plugin-vue": "^5.0.4",