@scalar/use-codemirror 0.7.19 → 0.7.20

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,11 @@
1
1
  # @scalar/use-codemirror
2
2
 
3
+ ## 0.7.20
4
+
5
+ ### Patch Changes
6
+
7
+ - 3d712d74: chore: remove light/dark mode features from useCodeMirror
8
+
3
9
  ## 0.7.19
4
10
 
5
11
  ### Patch Changes
@@ -10,10 +10,8 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
10
10
  lineNumbers?: boolean | undefined;
11
11
  withoutTheme?: boolean | undefined;
12
12
  disableEnter?: boolean | undefined;
13
- forceDarkMode?: boolean | undefined;
14
13
  }>, {
15
14
  disableEnter: boolean;
16
- forceDarkMode: boolean;
17
15
  }>, {
18
16
  setCodeMirrorContent: (content?: string | undefined) => void;
19
17
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
@@ -28,14 +26,11 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
28
26
  lineNumbers?: boolean | undefined;
29
27
  withoutTheme?: boolean | undefined;
30
28
  disableEnter?: boolean | undefined;
31
- forceDarkMode?: boolean | undefined;
32
29
  }>, {
33
30
  disableEnter: boolean;
34
- forceDarkMode: boolean;
35
31
  }>>> & {
36
32
  onChange?: ((value: string) => any) | undefined;
37
33
  }, {
38
- forceDarkMode: boolean;
39
34
  disableEnter: boolean;
40
35
  }, {}>;
41
36
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"CodeMirror.vue.d.ts","sourceRoot":"","sources":["../../../src/components/CodeMirror/CodeMirror.vue.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAUlD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;;;;;;;;;;;;;;;;;;;;;;;;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wBAkBG;AAGH,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACjE,KAAK,6BAA6B,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CAAE,CAAC;AAC9M,KAAK,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI;KAE1B,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QACxE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;KACb,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACT,CAAC;AACN,KAAK,cAAc,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -10,14 +10,6 @@ type UseCodeMirrorParameters = {
10
10
  * Prefill the content. Will be ignored when a provider is given.
11
11
  */
12
12
  content?: string;
13
- /**
14
- * Force the dark mode.
15
- */
16
- forceDarkMode?: boolean;
17
- /**
18
- * Force the light mode.
19
- */
20
- forceLightMode?: boolean;
21
13
  /**
22
14
  * Whether to load a theme.
23
15
  */
@@ -1 +1 @@
1
- {"version":3,"file":"useCodeMirror.d.ts","sourceRoot":"","sources":["../../src/hooks/useCodeMirror.ts"],"names":[],"mappings":"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AAG,IAAI,CAAC;qCACD,MAAM,KAAK,IAAI;2CACT,SAAS,EAAE,KAAK,IAAI;uCACxB,SAAS,EAAE,KAAK,IAAI;CA+HxD,CAAA"}
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import { javascript } from "@codemirror/lang-javascript";
11
11
  import { json } from "@codemirror/lang-json";
12
12
  import { python } from "@codemirror/lang-python";
13
13
  import { StreamLanguage } from "@codemirror/language";
14
- import { keymap, MatchDecorator, Decoration, ViewPlugin, EditorView as EditorView$1, lineNumbers } from "@codemirror/view";
14
+ import { MatchDecorator, Decoration, ViewPlugin, EditorView as EditorView$1, lineNumbers, keymap } from "@codemirror/view";
15
15
  import { StateEffect } from "@codemirror/state";
16
16
  import { EditorView } from "codemirror";
17
17
  import { tags } from "@lezer/highlight";
@@ -3856,7 +3856,7 @@ const yaml = {
3856
3856
  commentTokens: { line: "#" }
3857
3857
  }
3858
3858
  };
3859
- const lightTheme = createTheme({
3859
+ const customTheme = createTheme({
3860
3860
  theme: "light",
3861
3861
  settings: {
3862
3862
  background: "var(--theme-background-2, var(--default-theme-background-2))",
@@ -3942,95 +3942,8 @@ const lightTheme = createTheme({
3942
3942
  }
3943
3943
  ]
3944
3944
  });
3945
- const darkTheme = createTheme({
3946
- theme: "dark",
3947
- settings: {
3948
- background: "var(--theme-background-2, var(--default-theme-background-2))",
3949
- foreground: "var(--theme-color-1, var(--default-theme-color-1))",
3950
- caret: "var(--theme-color-1, var(--default-theme-color-1))",
3951
- selection: "var(--theme-background-3, var(--default-theme-background-3))",
3952
- selectionMatch: "#e3dcce",
3953
- gutterBackground: "var(--theme-background-2, var(--default-theme-background-2))",
3954
- gutterForeground: "var(--theme-color-3, var(--default-theme-color-3))",
3955
- gutterBorder: "transparent",
3956
- lineHighlight: "var(--theme-background-3, var(--default-theme-background-3))",
3957
- fontFamily: "var(--theme-font-code, var(--default-theme-font-code))"
3958
- },
3959
- styles: [
3960
- {
3961
- tag: [tags.standard(tags.tagName), tags.tagName],
3962
- color: "var(--theme-color-purple, var(--default-theme-color-purple))"
3963
- },
3964
- {
3965
- tag: [tags.comment],
3966
- color: "var(--theme-color-3, var(--default-theme-color-3))"
3967
- },
3968
- {
3969
- tag: [tags.className],
3970
- color: "var(--theme-color-orange, var(--default-theme-color-orange))"
3971
- },
3972
- {
3973
- tag: [tags.variableName, tags.propertyName, tags.attributeName],
3974
- color: "var(--theme-color-1, var(--default-theme-color-1))"
3975
- },
3976
- {
3977
- tag: [tags.operator],
3978
- color: "var(--theme-color-2, var(--default-theme-color-2))"
3979
- },
3980
- {
3981
- tag: [tags.keyword, tags.typeName, tags.typeOperator],
3982
- color: "var(--theme-color-green, var(--default-theme-color-green))"
3983
- },
3984
- {
3985
- tag: [tags.string],
3986
- color: "var(--theme-color-blue, var(--default-theme-color-blue))"
3987
- },
3988
- {
3989
- tag: [tags.bracket, tags.regexp, tags.meta],
3990
- color: "var(--theme-color-3, var(--default-theme-color-3))"
3991
- },
3992
- {
3993
- tag: [tags.number],
3994
- color: "var(--theme-color-blue, var(--default-theme-color-blue))"
3995
- },
3996
- {
3997
- tag: [tags.name, tags.quote],
3998
- color: "var(--theme-color-3, var(--default-theme-color-3))"
3999
- },
4000
- {
4001
- tag: [tags.heading],
4002
- color: "var(--theme-color-3, var(--default-theme-color-3))",
4003
- fontWeight: "bold"
4004
- },
4005
- {
4006
- tag: [tags.emphasis],
4007
- color: "var(--theme-color-3, var(--default-theme-color-3))",
4008
- fontStyle: "italic"
4009
- },
4010
- {
4011
- tag: [tags.deleted],
4012
- color: "var(--theme-color-3, var(--default-theme-color-3))",
4013
- backgroundColor: "transparent"
4014
- },
4015
- {
4016
- tag: [tags.atom, tags.bool, tags.special(tags.variableName)],
4017
- color: "var(--theme-color-3, var(--default-theme-color-3))"
4018
- },
4019
- {
4020
- tag: [tags.url, tags.escape, tags.regexp, tags.link],
4021
- color: "var(--theme-color-1, var(--default-theme-color-1))"
4022
- },
4023
- { tag: tags.link, textDecoration: "underline" },
4024
- { tag: tags.strikethrough, textDecoration: "line-through" },
4025
- {
4026
- tag: tags.invalid,
4027
- color: "var(--theme-color-3, var(--default-theme-color-3))"
4028
- }
4029
- ]
4030
- });
4031
- const isDark = ref(false);
4032
3945
  const useCodeMirror = (parameters) => {
4033
- const { extensions, content, forceDarkMode, forceLightMode, withoutTheme } = parameters;
3946
+ const { extensions, content, withoutTheme } = parameters;
4034
3947
  const value = ref(content ?? "");
4035
3948
  const codeMirrorRef = ref(null);
4036
3949
  const codeMirror = ref(null);
@@ -4050,55 +3963,20 @@ const useCodeMirror = (parameters) => {
4050
3963
  codeMirror.value = new EditorView(configuration);
4051
3964
  }
4052
3965
  };
4053
- const getCurrentTheme = () => {
4054
- if (withoutTheme) {
4055
- return null;
4056
- }
4057
- if (forceDarkMode) {
4058
- return darkTheme;
4059
- }
4060
- if (forceLightMode) {
4061
- return lightTheme;
4062
- }
4063
- if (isDark.value) {
4064
- return darkTheme;
4065
- }
4066
- return lightTheme;
4067
- };
4068
3966
  const addDefaultExtensions = (newExtensions = []) => {
4069
- const selectAllKeyBinding = {
4070
- key: "Mod-a",
4071
- run: (view) => {
4072
- view.dispatch({
4073
- selection: { anchor: 0, head: view.state.doc.length },
4074
- scrollIntoView: false
4075
- });
4076
- return true;
4077
- }
4078
- };
4079
3967
  const defaultExtensions = [
4080
- EditorView.theme(
4081
- {
4082
- ".cm-line": {
4083
- lineHeight: "20px"
4084
- },
4085
- ".cm-gutterElement": {
4086
- lineHeight: "20px"
4087
- }
3968
+ withoutTheme ? null : customTheme,
3969
+ EditorView.theme({
3970
+ ".cm-line": {
3971
+ lineHeight: "20px"
4088
3972
  },
4089
- { dark: forceDarkMode ? false : isDark.value }
4090
- ),
4091
- keymap.of([selectAllKeyBinding]),
4092
- getCurrentTheme()
3973
+ ".cm-gutterElement": {
3974
+ lineHeight: "20px"
3975
+ }
3976
+ })
4093
3977
  ].filter((extension) => extension !== null);
4094
3978
  return [...defaultExtensions, newExtensions];
4095
3979
  };
4096
- watch(isDark, () => {
4097
- const { extensions: configuredExtensions } = parameters;
4098
- if (!forceDarkMode) {
4099
- reconfigureCodeMirror(configuredExtensions);
4100
- }
4101
- });
4102
3980
  const destroyCodeMirror = () => {
4103
3981
  var _a;
4104
3982
  (_a = codeMirror.value) == null ? void 0 : _a.destroy();
@@ -4210,8 +4088,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
4210
4088
  withVariables: { type: Boolean },
4211
4089
  lineNumbers: { type: Boolean },
4212
4090
  withoutTheme: { type: Boolean },
4213
- disableEnter: { type: Boolean, default: false },
4214
- forceDarkMode: { type: Boolean, default: false }
4091
+ disableEnter: { type: Boolean, default: false }
4215
4092
  },
4216
4093
  emits: ["change"],
4217
4094
  setup(__props, { expose: __expose, emit }) {
@@ -4307,8 +4184,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
4307
4184
  } = useCodeMirror({
4308
4185
  content: props.content ?? "",
4309
4186
  extensions: getCodeMirrorExtensions(),
4310
- withoutTheme: props.withoutTheme,
4311
- forceDarkMode: props.forceDarkMode
4187
+ withoutTheme: props.withoutTheme
4312
4188
  });
4313
4189
  watch(
4314
4190
  () => props.content,
@@ -4325,7 +4201,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
4325
4201
  watch(
4326
4202
  [
4327
4203
  () => props.disableEnter,
4328
- () => props.forceDarkMode,
4329
4204
  () => props.languages,
4330
4205
  () => props.lineNumbers,
4331
4206
  () => props.readOnly,
@@ -1,3 +1,2 @@
1
- export declare const lightTheme: import("@codemirror/state").Extension;
2
- export declare const darkTheme: import("@codemirror/state").Extension;
1
+ export declare const customTheme: import("@codemirror/state").Extension;
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/themes/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,uCAuFrB,CAAA;AAEF,eAAO,MAAM,SAAS,uCAuFpB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/themes/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,uCAuFtB,CAAA"}
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "vue",
12
12
  "vue3"
13
13
  ],
14
- "version": "0.7.19",
14
+ "version": "0.7.20",
15
15
  "engines": {
16
16
  "node": ">=18"
17
17
  },
@@ -34,7 +34,7 @@
34
34
  "@vitejs/plugin-vue": "^4.4.0",
35
35
  "@vitest/coverage-v8": "^0.34.4",
36
36
  "tsc-alias": "^1.8.8",
37
- "vite": "^4.4.12",
37
+ "vite": "^4.5.2",
38
38
  "vitest": "^0.34.4",
39
39
  "vue": "^3.3.0",
40
40
  "vue-tsc": "^1.8.19"