@scalar/use-codemirror 0.9.0 → 0.10.0

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,21 @@
1
1
  # @scalar/use-codemirror
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0e64a36: refactor: rename all --theme-_ variables to --scalar-_
8
+
9
+ ### Patch Changes
10
+
11
+ - 22f2858: chore: ran syncpack to update packages
12
+
13
+ ## 0.9.1
14
+
15
+ ### Patch Changes
16
+
17
+ - 6889ad9: feat: tab and shift+tab codemirror, and escape codeblock hotkeys
18
+
3
19
  ## 0.9.0
4
20
 
5
21
  ### Minor Changes
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Scalar
3
+ Copyright (c) 2023-present Scalar
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1 +1 @@
1
- {"version":3,"file":"useCodeMirror.d.ts","sourceRoot":"","sources":["../../src/hooks/useCodeMirror.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EACL,UAAU,EAKX,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,CAA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Ac,GAAG;IAChB,qEAAqE;IACrE,OAAO,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAC7C,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAC9B,CAAC,GACF,CAAC,cAAc,GAAG;IAChB,QAAQ,EAAE,gBAAgB,CAAC,SAAS,GAAG,IAAI,CAAC,CAAA;IAC5C,OAAO,CAAC,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAC9C,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/B,CAAC,CAAA;AAsBN,sCAAsC;AACtC,eAAO,MAAM,aAAa,WAChB,uBAAuB;qCAEE,MAAM,KAAK,IAAI;gBACpC,IAAI,UAAU,GAAG,IAAI,CAAC;CA+HnC,CAAA"}
package/dist/index.js CHANGED
@@ -18793,6 +18793,49 @@ const completionKeymap = [
18793
18793
  { key: "Enter", run: acceptCompletion }
18794
18794
  ];
18795
18795
  const completionKeymapExt = /* @__PURE__ */ Prec.highest(/* @__PURE__ */ keymap.computeN([completionConfig], (state) => state.facet(completionConfig).defaultKeymap ? [completionKeymap] : []));
18796
+ function changeBySelectedLine(state, f) {
18797
+ let atLine = -1;
18798
+ return state.changeByRange((range) => {
18799
+ let changes = [];
18800
+ for (let pos = range.from; pos <= range.to; ) {
18801
+ let line = state.doc.lineAt(pos);
18802
+ if (line.number > atLine && (range.empty || range.to > line.from)) {
18803
+ f(line, changes, range);
18804
+ atLine = line.number;
18805
+ }
18806
+ pos = line.to + 1;
18807
+ }
18808
+ let changeSet = state.changes(changes);
18809
+ return {
18810
+ changes,
18811
+ range: EditorSelection.range(changeSet.mapPos(range.anchor, 1), changeSet.mapPos(range.head, 1))
18812
+ };
18813
+ });
18814
+ }
18815
+ const indentMore = ({ state, dispatch }) => {
18816
+ if (state.readOnly)
18817
+ return false;
18818
+ dispatch(state.update(changeBySelectedLine(state, (line, changes) => {
18819
+ changes.push({ from: line.from, insert: state.facet(indentUnit) });
18820
+ }), { userEvent: "input.indent" }));
18821
+ return true;
18822
+ };
18823
+ const indentLess = ({ state, dispatch }) => {
18824
+ if (state.readOnly)
18825
+ return false;
18826
+ dispatch(state.update(changeBySelectedLine(state, (line, changes) => {
18827
+ let space2 = /^\s*/.exec(line.text)[0];
18828
+ if (!space2)
18829
+ return;
18830
+ let col = countColumn(space2, state.tabSize), keep = 0;
18831
+ let insert2 = indentString(state, Math.max(0, col - getIndentUnit(state)));
18832
+ while (keep < space2.length && keep < insert2.length && space2.charCodeAt(keep) == insert2.charCodeAt(keep))
18833
+ keep++;
18834
+ changes.push({ from: line.from + keep, to: line.from + space2.length, insert: insert2.slice(keep) });
18835
+ }), { userEvent: "delete.dedent" }));
18836
+ return true;
18837
+ };
18838
+ const indentWithTab = { key: "Tab", run: indentMore, shift: indentLess };
18796
18839
  class Stack {
18797
18840
  /**
18798
18841
  @internal
@@ -23598,87 +23641,87 @@ var createTheme = (_ref) => {
23598
23641
  const customTheme = createTheme({
23599
23642
  theme: "light",
23600
23643
  settings: {
23601
- background: "var(--theme-background-2, var(--default-theme-background-2))",
23602
- foreground: "var(--theme-color-1, var(--default-theme-color-1))",
23603
- caret: "var(--theme-color-1, var(--default-theme-color-1))",
23644
+ background: "var(--scalar-background-2)",
23645
+ foreground: "var(--scalar-color-1)",
23646
+ caret: "var(--scalar-color-1)",
23604
23647
  // Selection likely needs a hardcoded color due to it not accepting variables
23605
23648
  selection: "rgba(151, 183, 205, 0.2)",
23606
23649
  selectionMatch: "#e3dcce",
23607
- gutterBackground: "var(--theme-background-2, var(--default-theme-background-2))",
23608
- gutterForeground: "var(--theme-color-3, var(--default-theme-color-3))",
23650
+ gutterBackground: "var(--scalar-background-2)",
23651
+ gutterForeground: "var(--scalar-color-3)",
23609
23652
  gutterBorder: "transparent",
23610
- lineHighlight: "var(--theme-background-3, var(--default-theme-background-3))",
23611
- fontFamily: "var(--theme-font-code, var(--default-theme-font-code))"
23653
+ lineHighlight: "var(--scalar-background-3)",
23654
+ fontFamily: "var(--scalar-font-code)"
23612
23655
  },
23613
23656
  styles: [
23614
23657
  {
23615
23658
  tag: [tags$1.standard(tags$1.tagName), tags$1.tagName],
23616
- color: "var(--theme-color-purple, var(--default-theme-color-purple))"
23659
+ color: "var(--scalar-color-purple)"
23617
23660
  },
23618
23661
  {
23619
23662
  tag: [tags$1.comment],
23620
- color: "var(--theme-color-3, var(--default-theme-color-3))"
23663
+ color: "var(--scalar-color-3)"
23621
23664
  },
23622
23665
  {
23623
23666
  tag: [tags$1.className],
23624
- color: "var(--theme-color-orange, var(--default-theme-color-orange))"
23667
+ color: "var(--scalar-color-orange)"
23625
23668
  },
23626
23669
  {
23627
23670
  tag: [tags$1.variableName, tags$1.propertyName, tags$1.attributeName],
23628
- color: "var(--theme-color-1, var(--default-theme-color-1))"
23671
+ color: "var(--scalar-color-1)"
23629
23672
  },
23630
23673
  {
23631
23674
  tag: [tags$1.operator],
23632
- color: "var(--theme-color-2, var(--default-theme-color-2))"
23675
+ color: "var(--scalar-color-2)"
23633
23676
  },
23634
23677
  {
23635
23678
  tag: [tags$1.keyword, tags$1.typeName, tags$1.typeOperator],
23636
- color: "var(--theme-color-green, var(--default-theme-color-green))"
23679
+ color: "var(--scalar-color-green)"
23637
23680
  },
23638
23681
  {
23639
23682
  tag: [tags$1.string],
23640
- color: "var(--theme-color-blue, var(--default-theme-color-blue))"
23683
+ color: "var(--scalar-color-blue)"
23641
23684
  },
23642
23685
  {
23643
23686
  tag: [tags$1.bracket, tags$1.regexp, tags$1.meta],
23644
- color: "var(--theme-color-3, var(--default-theme-color-3))"
23687
+ color: "var(--scalar-color-3)"
23645
23688
  },
23646
23689
  {
23647
23690
  tag: [tags$1.number],
23648
- color: "var(--theme-color-blue, var(--default-theme-color-blue))"
23691
+ color: "var(--scalar-color-blue)"
23649
23692
  },
23650
23693
  {
23651
23694
  tag: [tags$1.name, tags$1.quote],
23652
- color: "var(--theme-color-3, var(--default-theme-color-3))"
23695
+ color: "var(--scalar-color-3)"
23653
23696
  },
23654
23697
  {
23655
23698
  tag: [tags$1.heading],
23656
- color: "var(--theme-color-3, var(--default-theme-color-3))",
23699
+ color: "var(--scalar-color-3)",
23657
23700
  fontWeight: "bold"
23658
23701
  },
23659
23702
  {
23660
23703
  tag: [tags$1.emphasis],
23661
- color: "var(--theme-color-3, var(--default-theme-color-3))",
23704
+ color: "var(--scalar-color-3)",
23662
23705
  fontStyle: "italic"
23663
23706
  },
23664
23707
  {
23665
23708
  tag: [tags$1.deleted],
23666
- color: "var(--theme-color-3, var(--default-theme-color-3))",
23709
+ color: "var(--scalar-color-3)",
23667
23710
  backgroundColor: "transparent"
23668
23711
  },
23669
23712
  {
23670
23713
  tag: [tags$1.atom, tags$1.bool, tags$1.special(tags$1.variableName)],
23671
- color: "var(--theme-color-3, var(--default-theme-color-3))"
23714
+ color: "var(--scalar-color-3)"
23672
23715
  },
23673
23716
  {
23674
23717
  tag: [tags$1.url, tags$1.escape, tags$1.regexp, tags$1.link],
23675
- color: "var(--theme-color-1, var(--default-theme-color-1))"
23718
+ color: "var(--scalar-color-1)"
23676
23719
  },
23677
23720
  { tag: tags$1.link, textDecoration: "underline" },
23678
23721
  { tag: tags$1.strikethrough, textDecoration: "line-through" },
23679
23722
  {
23680
23723
  tag: tags$1.invalid,
23681
- color: "var(--theme-color-3, var(--default-theme-color-3))"
23724
+ color: "var(--scalar-color-3)"
23682
23725
  }
23683
23726
  ]
23684
23727
  });
@@ -23894,6 +23937,7 @@ function getCodeMirrorExtensions({
23894
23937
  keymap.of([
23895
23938
  ...completionKeymap,
23896
23939
  ...closeBracketsKeymap,
23940
+ indentWithTab,
23897
23941
  selectAllKeyBinding
23898
23942
  ])
23899
23943
  );
@@ -23976,7 +24020,7 @@ const _export_sfc = (sfc, props) => {
23976
24020
  }
23977
24021
  return target;
23978
24022
  };
23979
- const CodeMirror = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-88edf4c8"]]);
24023
+ const CodeMirror = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-74ed365a"]]);
23980
24024
  export {
23981
24025
  CodeMirror,
23982
24026
  colorPicker,
package/dist/style.css CHANGED
@@ -1,15 +1,15 @@
1
1
 
2
- .codemirror-container[data-v-88edf4c8] {
2
+ .codemirror-container[data-v-74ed365a] {
3
3
  width: 100%;
4
4
  height: 100%;
5
5
  padding-top: 4px;
6
6
  min-height: 76px;
7
- background: var(--theme-background-2, var(--default-theme-background-2));
8
- color: var(--theme-color-1, var(--default-theme-color-1));
7
+ background: var(--scalar-background-2);
8
+ color: var(--scalar-color-1);
9
9
  display: flex;
10
10
  align-items: stretch;
11
11
  }
12
- .copy-to-clipboard-button[data-v-88edf4c8] {
12
+ .copy-to-clipboard-button[data-v-74ed365a] {
13
13
  background: red;
14
14
  }
15
15
 
@@ -17,7 +17,7 @@
17
17
  flex-grow: 1;
18
18
  max-width: 100%;
19
19
  cursor: text;
20
- font-size: var(--theme-small, var(--default-theme-small));
20
+ font-size: var(--scalar-small);
21
21
  /* Don't scale wide text on mobile because we let it scroll */
22
22
  -webkit-text-size-adjust: 100%;
23
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/themes/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,uCAwFtB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/themes/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,uCAsFtB,CAAA"}
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "vue",
12
12
  "vue3"
13
13
  ],
14
- "version": "0.9.0",
14
+ "version": "0.10.0",
15
15
  "engines": {
16
16
  "node": ">=18"
17
17
  },
@@ -32,6 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@codemirror/autocomplete": "^6.12.0",
35
+ "@codemirror/commands": "^6.3.3",
35
36
  "@codemirror/lang-css": "^6.2.1",
36
37
  "@codemirror/lang-html": "^6.4.8",
37
38
  "@codemirror/lang-json": "^6.0.0",
@@ -49,11 +50,11 @@
49
50
  },
50
51
  "devDependencies": {
51
52
  "@vitejs/plugin-vue": "^5.0.4",
52
- "@vitest/coverage-v8": "^1.2.2",
53
+ "@vitest/coverage-v8": "^1.5.0",
53
54
  "tsc-alias": "^1.8.8",
54
- "vite": "^5.1.1",
55
- "vitest": "^1.2.2",
56
- "vue": "^3.3.0",
55
+ "vite": "^5.2.9",
56
+ "vitest": "^1.5.0",
57
+ "vue": "^3.4.21",
57
58
  "vue-tsc": "^1.8.19"
58
59
  },
59
60
  "peerDependencies": {