st-comp 0.0.85 → 0.0.86

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "st-comp",
3
3
  "public": true,
4
- "version": "0.0.85",
4
+ "version": "0.0.86",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -53,6 +53,9 @@ defineExpose({
53
53
  },
54
54
  getValue: () => {
55
55
  return editorInstance.getValue();
56
+ },
57
+ setReadOnly: (readOnly = true) => {
58
+ editorInstance.updateOptions({ readOnly });
56
59
  }
57
60
  })
58
61
  </script>
@@ -1,6 +1,8 @@
1
1
  <template>
2
2
  <el-button @click="consoleFn">打印</el-button>
3
3
  <el-button @click="resetFn">重置</el-button>
4
+ <el-button @click="setReadOnly(true)">只读</el-button>
5
+ <el-button @click="setReadOnly(false)">取消只读</el-button>
4
6
  <div style="width: 800px; height: 800px; border: 1px solid #000;">
5
7
  <st-monacoEditor
6
8
  ref="monacoEditorRef"
@@ -10,7 +12,7 @@
10
12
  </div>
11
13
  </template>
12
14
 
13
- <script setup lang="ts">
15
+ <script setup>
14
16
  import { ref } from 'vue'
15
17
 
16
18
  const defaultValue = `def add(x, y):
@@ -34,7 +36,7 @@ print(multiply(5, 3))
34
36
  print(divide(5, 3))
35
37
  `
36
38
 
37
- const monacoEditorRef = ref<any>(null)
39
+ const monacoEditorRef = ref(null)
38
40
  const value = ref(defaultValue)
39
41
 
40
42
  const consoleFn = () => {
@@ -48,6 +50,10 @@ const resetFn = () => {
48
50
  const changeCode = (val) => {
49
51
  console.log('changeCode', val)
50
52
  }
53
+
54
+ const setReadOnly = (readOnly) => {
55
+ monacoEditorRef.value.setReadOnly(readOnly)
56
+ }
51
57
  </script>
52
58
 
53
59
  <style lang="scss" scoped>