@appscode/design-system 1.0.43-alpha.146 → 1.0.43-alpha.149
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
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
/>
|
|
8
8
|
<monaco-editor
|
|
9
9
|
v-if="activeTab === 'edit'"
|
|
10
|
-
ref="monacoEditor"
|
|
11
10
|
@editorDidMount="onEditorMount"
|
|
12
11
|
key="edit"
|
|
13
12
|
:class="`vh-${editorHeight} is-clipped`"
|
|
14
|
-
|
|
13
|
+
:value="editorContent"
|
|
14
|
+
@change="onChange"
|
|
15
15
|
:language="language"
|
|
16
16
|
:options="{
|
|
17
17
|
minimap: {
|
|
@@ -82,10 +82,11 @@ export default {
|
|
|
82
82
|
default: "off",
|
|
83
83
|
},
|
|
84
84
|
},
|
|
85
|
+
|
|
85
86
|
components: {
|
|
86
87
|
EditorTabs: () => import("../tabs/EditorTabs.vue"),
|
|
87
88
|
MonacoEditor: () => ({
|
|
88
|
-
component: import("vue
|
|
89
|
+
component: import("./MonacoEditor.vue"),
|
|
89
90
|
loading: Preloader,
|
|
90
91
|
delay: 200,
|
|
91
92
|
error: Banner,
|
|
@@ -136,8 +137,10 @@ export default {
|
|
|
136
137
|
},
|
|
137
138
|
|
|
138
139
|
methods: {
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
onChange(e) {
|
|
141
|
+
if (typeof e === "string") this.editorContent = e;
|
|
142
|
+
},
|
|
143
|
+
onEditorMount(editor) {
|
|
141
144
|
// add event listeners
|
|
142
145
|
editor.onDidBlurEditorText(() => {
|
|
143
146
|
this.$emit("input", this.editorContent);
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="monaco-editor-vue2" :style="style"></div>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
const monaco = require("monaco-editor");
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
name: "MonacoEditor",
|
|
10
|
+
props: {
|
|
11
|
+
diffEditor: { type: Boolean, default: false },
|
|
12
|
+
width: { type: [String, Number], default: "100%" },
|
|
13
|
+
height: { type: [String, Number], default: "100%" },
|
|
14
|
+
original: String,
|
|
15
|
+
value: String,
|
|
16
|
+
language: { type: String, default: "javascript" },
|
|
17
|
+
theme: { type: String, default: "vs" },
|
|
18
|
+
options: {
|
|
19
|
+
type: Object,
|
|
20
|
+
default() {
|
|
21
|
+
return {};
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
computed: {
|
|
26
|
+
style() {
|
|
27
|
+
const fixedWidth = this.width.toString().includes("%")
|
|
28
|
+
? this.width
|
|
29
|
+
: `${this.width}px`;
|
|
30
|
+
const fixedHeight = this.height.toString().includes("%")
|
|
31
|
+
? this.height
|
|
32
|
+
: `${this.height}px`;
|
|
33
|
+
return {
|
|
34
|
+
width: fixedWidth,
|
|
35
|
+
height: fixedHeight,
|
|
36
|
+
"text-align": "left",
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
mounted() {
|
|
41
|
+
this.initMonaco();
|
|
42
|
+
},
|
|
43
|
+
beforeDestroy() {
|
|
44
|
+
this.editor && this.editor.dispose();
|
|
45
|
+
},
|
|
46
|
+
methods: {
|
|
47
|
+
initMonaco() {
|
|
48
|
+
this.$emit("editorWillMount", this.monaco);
|
|
49
|
+
const { value, language, theme, options } = this;
|
|
50
|
+
this.editor = monaco.editor[
|
|
51
|
+
this.diffEditor ? "createDiffEditor" : "create"
|
|
52
|
+
](this.$el, {
|
|
53
|
+
value: value,
|
|
54
|
+
language: language,
|
|
55
|
+
theme: theme,
|
|
56
|
+
...options,
|
|
57
|
+
});
|
|
58
|
+
this.diffEditor && this._setModel(this.value, this.original);
|
|
59
|
+
|
|
60
|
+
// @event `change`
|
|
61
|
+
const editor = this._getEditor();
|
|
62
|
+
editor.onDidChangeModelContent((event) => {
|
|
63
|
+
const value = editor.getValue();
|
|
64
|
+
if (this.value !== value) {
|
|
65
|
+
this.$emit("change", value, event);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
this.$emit("editorDidMount", this.editor);
|
|
70
|
+
},
|
|
71
|
+
_setModel(value, original) {
|
|
72
|
+
const { language } = this;
|
|
73
|
+
const originalModel = monaco.editor.createModel(original, language);
|
|
74
|
+
const modifiedModel = monaco.editor.createModel(value, language);
|
|
75
|
+
this.editor.setModel({
|
|
76
|
+
original: originalModel,
|
|
77
|
+
modified: modifiedModel,
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
_setValue(value) {
|
|
81
|
+
let editor = this._getEditor();
|
|
82
|
+
if (editor) return editor.setValue(value);
|
|
83
|
+
},
|
|
84
|
+
_getValue() {
|
|
85
|
+
let editor = this._getEditor();
|
|
86
|
+
if (!editor) return "";
|
|
87
|
+
return editor.getValue();
|
|
88
|
+
},
|
|
89
|
+
_getEditor() {
|
|
90
|
+
if (!this.editor) return null;
|
|
91
|
+
return this.diffEditor ? this.editor.getModifiedEditor() : this.editor;
|
|
92
|
+
},
|
|
93
|
+
_setOriginal() {
|
|
94
|
+
const { original } = this.editor.getModel();
|
|
95
|
+
original.setValue(this.original);
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
watch: {
|
|
99
|
+
options: {
|
|
100
|
+
deep: true,
|
|
101
|
+
handler(options) {
|
|
102
|
+
this.editor.updateOptions(options);
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
value() {
|
|
106
|
+
this.value !== this._getValue() && this._setValue(this.value);
|
|
107
|
+
},
|
|
108
|
+
original() {
|
|
109
|
+
this._setOriginal();
|
|
110
|
+
},
|
|
111
|
+
language() {
|
|
112
|
+
if (!this.editor) return;
|
|
113
|
+
if (this.diffEditor) {
|
|
114
|
+
const { original, modified } = this.editor.getModel();
|
|
115
|
+
monaco.editor.setModelLanguage(original, this.language);
|
|
116
|
+
monaco.editor.setModelLanguage(modified, this.language);
|
|
117
|
+
} else
|
|
118
|
+
monaco.editor.setModelLanguage(this.editor.getModel(), this.language);
|
|
119
|
+
},
|
|
120
|
+
theme() {
|
|
121
|
+
monaco.editor.setTheme(this.theme);
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
</script>
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
<!-- modal body end -->
|
|
40
40
|
|
|
41
41
|
<!-- modal footer start -->
|
|
42
|
-
<div
|
|
42
|
+
<div v-if="!hideActionFooter"
|
|
43
43
|
class="ac-modal-footer action-footer is-flex is-align-items-center is-justify-content-space-between"
|
|
44
44
|
>
|
|
45
45
|
<div>
|
|
@@ -77,6 +77,10 @@ export default {
|
|
|
77
77
|
ignoreOutsideClick: {
|
|
78
78
|
type: Boolean,
|
|
79
79
|
default: false
|
|
80
|
+
},
|
|
81
|
+
hideActionFooter: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: false
|
|
80
84
|
}
|
|
81
85
|
},
|
|
82
86
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
v-if="showModal"
|
|
7
7
|
class="ac-modal is-middle-alignment"
|
|
8
8
|
:class="modifierClasses"
|
|
9
|
-
@click.self="
|
|
9
|
+
@click.self="onModalOutsideClick"
|
|
10
10
|
>
|
|
11
11
|
<div class="ac-modal-inner">
|
|
12
12
|
<!-- modal header start -->
|
|
@@ -37,7 +37,9 @@
|
|
|
37
37
|
<!-- modal body end -->
|
|
38
38
|
|
|
39
39
|
<!-- modal footer start -->
|
|
40
|
-
<div
|
|
40
|
+
<div v-if="!hideActionFooter"
|
|
41
|
+
class="ac-modal-footer action-footer is-flex is-align-items-center is-justify-content-space-between"
|
|
42
|
+
>
|
|
41
43
|
<div>
|
|
42
44
|
<slot name="modal-footer-left" />
|
|
43
45
|
</div>
|
|
@@ -58,36 +60,44 @@ export default defineComponent({
|
|
|
58
60
|
props: {
|
|
59
61
|
open: {
|
|
60
62
|
type: Boolean,
|
|
61
|
-
default: false
|
|
63
|
+
default: false
|
|
62
64
|
},
|
|
63
65
|
title: {
|
|
64
66
|
type: String,
|
|
65
|
-
default: "Modal"
|
|
67
|
+
default: "Modal"
|
|
66
68
|
},
|
|
67
69
|
modifierClasses: {
|
|
68
70
|
type: String,
|
|
69
|
-
default: ""
|
|
71
|
+
default: ""
|
|
70
72
|
},
|
|
71
73
|
isCloseOptionDisabled: {
|
|
72
74
|
type: Boolean,
|
|
73
|
-
default: false
|
|
75
|
+
default: false
|
|
76
|
+
},
|
|
77
|
+
ignoreOutsideClick: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
default: false
|
|
80
|
+
},
|
|
81
|
+
hideActionFooter: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: false
|
|
74
84
|
}
|
|
75
85
|
},
|
|
76
86
|
emits: ["closemodal"],
|
|
77
87
|
|
|
78
88
|
components: {
|
|
79
89
|
HeaderItems: defineAsyncComponent(() =>
|
|
80
|
-
import("../../v2/header/HeaderItems.vue").then(
|
|
90
|
+
import("../../v2/header/HeaderItems.vue").then(module => module.default)
|
|
81
91
|
),
|
|
82
92
|
HeaderItem: defineAsyncComponent(() =>
|
|
83
|
-
import("../../v2/header/HeaderItem.vue").then(
|
|
93
|
+
import("../../v2/header/HeaderItem.vue").then(module => module.default)
|
|
84
94
|
),
|
|
85
95
|
Buttons: defineAsyncComponent(() =>
|
|
86
|
-
import("../../v2/button/Buttons.vue").then(
|
|
96
|
+
import("../../v2/button/Buttons.vue").then(module => module.default)
|
|
87
97
|
),
|
|
88
98
|
AcButton: defineAsyncComponent(() =>
|
|
89
|
-
import("../button/Button.vue").then(
|
|
90
|
-
)
|
|
99
|
+
import("../button/Button.vue").then(module => module.default)
|
|
100
|
+
)
|
|
91
101
|
},
|
|
92
102
|
|
|
93
103
|
data() {
|
|
@@ -95,7 +105,7 @@ export default defineComponent({
|
|
|
95
105
|
showModal: false,
|
|
96
106
|
crossIcon: import.meta.globEager(
|
|
97
107
|
"/src/assets/icons/modal/close-icon.svg"
|
|
98
|
-
)["/src/assets/icons/modal/close-icon.svg"].default
|
|
108
|
+
)["/src/assets/icons/modal/close-icon.svg"].default
|
|
99
109
|
};
|
|
100
110
|
},
|
|
101
111
|
|
|
@@ -108,8 +118,8 @@ export default defineComponent({
|
|
|
108
118
|
} else {
|
|
109
119
|
this.destroyModal();
|
|
110
120
|
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
113
123
|
},
|
|
114
124
|
|
|
115
125
|
methods: {
|
|
@@ -123,13 +133,17 @@ export default defineComponent({
|
|
|
123
133
|
this.showModal = true;
|
|
124
134
|
document.addEventListener("keydown", this.onKeyDown);
|
|
125
135
|
},
|
|
136
|
+
onModalOutsideClick() {
|
|
137
|
+
if (this.ignoreOutsideClick) return;
|
|
138
|
+
this.destroyModal();
|
|
139
|
+
},
|
|
126
140
|
destroyModal() {
|
|
127
141
|
if (this.isCloseOptionDisabled) return;
|
|
128
142
|
this.showModal = false;
|
|
129
143
|
document.removeEventListener("keydown", this.onKeyDown);
|
|
130
144
|
|
|
131
145
|
this.$emit("closemodal", true);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
134
148
|
});
|
|
135
149
|
</script>
|