@scalar/use-codemirror 0.7.10 → 0.7.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,12 @@
1
1
  # @scalar/use-codemirror
2
2
 
3
+ ## 0.7.11
4
+
5
+ ### Patch Changes
6
+
7
+ - 509db1e: refactor: move all api reference refs and watchers to hooks
8
+ - a4f1b08: fix: switching documents with collaborative editing mode enabled
9
+
3
10
  ## 0.7.10
4
11
 
5
12
  ### Patch Changes
@@ -17,6 +17,9 @@ declare const _default: import("vue").DefineComponent<{
17
17
  readOnly: {
18
18
  type: import("vue").PropType<boolean>;
19
19
  };
20
+ name: {
21
+ type: import("vue").PropType<string>;
22
+ };
20
23
  languages: {
21
24
  type: import("vue").PropType<CodeMirrorLanguage[]>;
22
25
  };
@@ -51,6 +54,9 @@ declare const _default: import("vue").DefineComponent<{
51
54
  readOnly: {
52
55
  type: import("vue").PropType<boolean>;
53
56
  };
57
+ name: {
58
+ type: import("vue").PropType<string>;
59
+ };
54
60
  languages: {
55
61
  type: import("vue").PropType<CodeMirrorLanguage[]>;
56
62
  };
@@ -1 +1 @@
1
- {"version":3,"file":"CodeMirror.vue.d.ts","sourceRoot":"","sources":["../../../src/components/CodeMirror/CodeMirror.vue.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAUlD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8OrD,wBAAkD"}
1
+ {"version":3,"file":"CodeMirror.vue.d.ts","sourceRoot":"","sources":["../../../src/components/CodeMirror/CodeMirror.vue.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAUlD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqQrD,wBAAkD"}
@@ -1 +1 @@
1
- {"version":3,"file":"useCodeMirror.d.ts","sourceRoot":"","sources":["../../src/hooks/useCodeMirror.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,mBAAmB,CAAA;AAG/D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,KAAK,GAAG,EAAc,MAAM,KAAK,CAAA;AAO1C,KAAK,uBAAuB,GAAG;IAC7B;;OAEG;IACH,UAAU,EAAE,SAAS,EAAE,CAAA;IACvB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,aAAa,eACZ,uBAAuB;WAE5B,IAAI,MAAM,CAAC;mBACH,IAAI,cAAc,GAAG,IAAI,CAAC;gBAC7B,IAAI,UAAU,GAAG,IAAI,CAAC;oCACF,MAAM,KAAK,IAAI;2CACR,SAAS,EAAE,KAAK,IAAI;uCACxB,SAAS,EAAE,KAAK,IAAI;CAqKxD,CAAA"}
1
+ {"version":3,"file":"useCodeMirror.d.ts","sourceRoot":"","sources":["../../src/hooks/useCodeMirror.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,mBAAmB,CAAA;AAM/D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,KAAK,GAAG,EAAc,MAAM,KAAK,CAAA;AAO1C,KAAK,uBAAuB,GAAG;IAC7B;;OAEG;IACH,UAAU,EAAE,SAAS,EAAE,CAAA;IACvB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,aAAa,eACZ,uBAAuB;WAE5B,IAAI,MAAM,CAAC;mBACH,IAAI,cAAc,GAAG,IAAI,CAAC;gBAC7B,IAAI,UAAU,GAAG,IAAI,CAAC;oCACF,MAAM,KAAK,IAAI;2CACR,SAAS,EAAE,KAAK,IAAI;uCACxB,SAAS,EAAE,KAAK,IAAI;CAgLxD,CAAA"}
package/dist/index.js CHANGED
@@ -4004,7 +4004,13 @@ const useCodeMirror = (parameters) => {
4004
4004
  if (!codeMirror.value) {
4005
4005
  return;
4006
4006
  }
4007
+ if (value.value === newValue) {
4008
+ return;
4009
+ }
4007
4010
  value.value = newValue;
4011
+ if (codeMirror.value.state.doc.toString() === newValue) {
4012
+ return;
4013
+ }
4008
4014
  codeMirror.value.dispatch({
4009
4015
  changes: {
4010
4016
  from: 0,
@@ -4093,6 +4099,7 @@ const variables = () => ViewPlugin.fromClass(
4093
4099
  const _sfc_main = /* @__PURE__ */ defineComponent({
4094
4100
  __name: "CodeMirror",
4095
4101
  props: {
4102
+ name: {},
4096
4103
  extensions: {},
4097
4104
  content: {},
4098
4105
  readOnly: { type: Boolean },
@@ -4200,16 +4207,35 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
4200
4207
  withoutTheme: props.withoutTheme,
4201
4208
  forceDarkMode: props.forceDarkMode
4202
4209
  });
4203
- watch(props, () => {
4204
- setCodeMirrorContent(props.content ?? "");
4205
- reconfigureCodeMirror(getCodeMirrorExtensions());
4206
- });
4207
4210
  watch(
4208
- () => props.extensions,
4211
+ () => props.content,
4212
+ () => {
4213
+ var _a;
4214
+ if ((_a = props.content) == null ? void 0 : _a.length) {
4215
+ setCodeMirrorContent(props.content);
4216
+ }
4217
+ }
4218
+ );
4219
+ watch(
4220
+ () => props.name,
4209
4221
  () => {
4210
4222
  restartCodeMirror(getCodeMirrorExtensions());
4211
4223
  }
4212
4224
  );
4225
+ watch(
4226
+ [
4227
+ () => props.disableEnter,
4228
+ () => props.forceDarkMode,
4229
+ () => props.languages,
4230
+ () => props.lineNumbers,
4231
+ () => props.readOnly,
4232
+ () => props.withoutTheme,
4233
+ () => props.withVariables
4234
+ ],
4235
+ () => {
4236
+ reconfigureCodeMirror(getCodeMirrorExtensions());
4237
+ }
4238
+ );
4213
4239
  __expose({
4214
4240
  setCodeMirrorContent
4215
4241
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scalar/use-codemirror",
3
3
  "description": "CodeMirror for Vue",
4
- "version": "0.7.10",
4
+ "version": "0.7.11",
5
5
  "author": "Scalar (https://github.com/scalar)",
6
6
  "bugs": "https://github.com/scalar/scalar/issues/new",
7
7
  "dependencies": {