@ditojs/admin 2.34.5 → 2.36.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/dist/dito-admin.es.js +2212 -2134
- package/dist/dito-admin.umd.js +5 -5
- package/dist/style.css +1 -1
- package/package.json +32 -35
- package/src/DitoContext.js +44 -14
- package/src/components/DitoButtons.vue +5 -0
- package/src/components/DitoContainer.vue +5 -3
- package/src/components/DitoCreateButton.vue +3 -1
- package/src/components/DitoEditButtons.vue +5 -0
- package/src/components/DitoPane.vue +8 -0
- package/src/components/DitoPanel.vue +7 -1
- package/src/components/DitoPanels.vue +10 -0
- package/src/components/DitoSchema.vue +9 -29
- package/src/components/DitoTableCell.vue +3 -0
- package/src/mixins/ContextMixin.js +68 -0
- package/src/mixins/TypeMixin.js +3 -86
- package/src/mixins/ValueMixin.js +32 -0
- package/src/types/DitoTypeCode.vue +82 -25
- package/src/types/DitoTypeComputed.vue +3 -3
- package/src/types/DitoTypeList.vue +1 -0
- package/src/types/DitoTypeMarkup.vue +0 -12
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import DitoContext from '../DitoContext.js'
|
|
2
|
+
import { computeValue } from '../utils/schema.js'
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
computed: {
|
|
6
|
+
value: {
|
|
7
|
+
get() {
|
|
8
|
+
const value = computeValue(
|
|
9
|
+
this.schema,
|
|
10
|
+
this.data,
|
|
11
|
+
this.name,
|
|
12
|
+
this.dataPath,
|
|
13
|
+
{ component: this }
|
|
14
|
+
)
|
|
15
|
+
const { format } = this.schema
|
|
16
|
+
return format
|
|
17
|
+
? format(new DitoContext(this, { value }))
|
|
18
|
+
: value
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
set(value) {
|
|
22
|
+
const { parse } = this.schema
|
|
23
|
+
if (parse) {
|
|
24
|
+
value = parse(new DitoContext(this, { value }))
|
|
25
|
+
}
|
|
26
|
+
this.parsedValue = value
|
|
27
|
+
// eslint-disable-next-line vue/no-mutating-props
|
|
28
|
+
this.data[this.name] = value
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,34 +1,63 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
.dito-code(
|
|
3
3
|
:id="dataPath"
|
|
4
|
-
ref="code"
|
|
5
4
|
:style="style"
|
|
6
5
|
)
|
|
6
|
+
.dito-code__editor(ref="editor")
|
|
7
|
+
.dito-resize(
|
|
8
|
+
v-if="resizable"
|
|
9
|
+
@mousedown.stop.prevent="onDragResize"
|
|
10
|
+
)
|
|
7
11
|
</template>
|
|
8
12
|
|
|
9
13
|
<script>
|
|
10
14
|
import DitoTypeComponent from '../DitoTypeComponent.js'
|
|
11
15
|
import DomMixin from '../mixins/DomMixin.js'
|
|
16
|
+
import { getSchemaAccessor } from '../utils/accessor.js'
|
|
12
17
|
import CodeFlask from 'codeflask'
|
|
13
18
|
|
|
14
19
|
// @vue/component
|
|
15
20
|
export default DitoTypeComponent.register('code', {
|
|
16
21
|
mixins: [DomMixin],
|
|
17
22
|
|
|
23
|
+
data() {
|
|
24
|
+
return {
|
|
25
|
+
height: null
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
|
|
18
29
|
computed: {
|
|
19
|
-
lines(
|
|
20
|
-
|
|
21
|
-
|
|
30
|
+
lines: getSchemaAccessor('lines', {
|
|
31
|
+
type: Number,
|
|
32
|
+
default: 3
|
|
33
|
+
}),
|
|
34
|
+
|
|
35
|
+
language: getSchemaAccessor('language', {
|
|
36
|
+
type: String,
|
|
37
|
+
default: 'javascript'
|
|
38
|
+
}),
|
|
39
|
+
|
|
40
|
+
indentSize: getSchemaAccessor('indentSize', {
|
|
41
|
+
type: Number,
|
|
42
|
+
default: 2
|
|
43
|
+
}),
|
|
44
|
+
|
|
45
|
+
resizable: getSchemaAccessor('resizable', {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: false
|
|
48
|
+
}),
|
|
22
49
|
|
|
23
50
|
style() {
|
|
24
|
-
return
|
|
51
|
+
return {
|
|
52
|
+
height: this.height || `calc(${this.lines}em * var(--line-height))`
|
|
53
|
+
}
|
|
25
54
|
}
|
|
26
55
|
},
|
|
27
56
|
|
|
28
57
|
mounted() {
|
|
29
|
-
const flask = new CodeFlask(this.$refs.
|
|
30
|
-
language: this.
|
|
31
|
-
|
|
58
|
+
const flask = new CodeFlask(this.$refs.editor, {
|
|
59
|
+
language: this.language,
|
|
60
|
+
indentSize: this.indentSize,
|
|
32
61
|
lineNumbers: false
|
|
33
62
|
})
|
|
34
63
|
|
|
@@ -50,7 +79,7 @@ export default DitoTypeComponent.register('code', {
|
|
|
50
79
|
onChange()
|
|
51
80
|
}
|
|
52
81
|
|
|
53
|
-
this.domOn(this.$refs.
|
|
82
|
+
this.domOn(this.$refs.editor.querySelector('textarea'), {
|
|
54
83
|
focus: onFocus,
|
|
55
84
|
blur: onBlur
|
|
56
85
|
})
|
|
@@ -87,6 +116,10 @@ export default DitoTypeComponent.register('code', {
|
|
|
87
116
|
}
|
|
88
117
|
})
|
|
89
118
|
|
|
119
|
+
this.$watch('language', language => {
|
|
120
|
+
flask.updateLanguage(language)
|
|
121
|
+
})
|
|
122
|
+
|
|
90
123
|
setCode(this.value || '')
|
|
91
124
|
},
|
|
92
125
|
|
|
@@ -96,7 +129,30 @@ export default DitoTypeComponent.register('code', {
|
|
|
96
129
|
},
|
|
97
130
|
|
|
98
131
|
blurElement() {
|
|
99
|
-
this.$el.querySelector('textarea')?.
|
|
132
|
+
this.$el.querySelector('textarea')?.blur()
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
onDragResize(event) {
|
|
136
|
+
const getPoint = ({ clientX: x, clientY: y }) => ({ x, y })
|
|
137
|
+
|
|
138
|
+
let prevY = getPoint(event).y
|
|
139
|
+
let height = parseFloat(getComputedStyle(this.$el).height)
|
|
140
|
+
|
|
141
|
+
const mousemove = event => {
|
|
142
|
+
const { y } = getPoint(event)
|
|
143
|
+
height += y - prevY
|
|
144
|
+
prevY = y
|
|
145
|
+
this.height = `${Math.max(height, 0)}px`
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const handlers = this.domOn(document, {
|
|
149
|
+
mousemove,
|
|
150
|
+
|
|
151
|
+
mouseup(event) {
|
|
152
|
+
mousemove(event)
|
|
153
|
+
handlers.remove()
|
|
154
|
+
}
|
|
155
|
+
})
|
|
100
156
|
}
|
|
101
157
|
}
|
|
102
158
|
})
|
|
@@ -112,6 +168,7 @@ export default DitoTypeComponent.register('code', {
|
|
|
112
168
|
// For proper sizing of content along with :style="style" setting above,
|
|
113
169
|
// for proper line-height calculation.
|
|
114
170
|
padding: $input-padding;
|
|
171
|
+
min-height: calc(1em * var(--line-height) + 2 * $input-padding-ver);
|
|
115
172
|
|
|
116
173
|
.codeflask {
|
|
117
174
|
background: none;
|
|
@@ -119,24 +176,24 @@ export default DitoTypeComponent.register('code', {
|
|
|
119
176
|
// the desired height with :style="style".
|
|
120
177
|
top: 0;
|
|
121
178
|
left: 0;
|
|
122
|
-
}
|
|
123
179
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
180
|
+
&__textarea,
|
|
181
|
+
&__pre {
|
|
182
|
+
// Use same padding as .dito-code
|
|
183
|
+
padding: $input-padding;
|
|
184
|
+
}
|
|
129
185
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
186
|
+
&__textarea,
|
|
187
|
+
&__code,
|
|
188
|
+
&__lines {
|
|
189
|
+
font-family: $font-family-mono;
|
|
190
|
+
font-size: var(--font-size);
|
|
191
|
+
line-height: var(--line-height);
|
|
192
|
+
}
|
|
137
193
|
|
|
138
|
-
|
|
139
|
-
|
|
194
|
+
&__lines {
|
|
195
|
+
padding: $input-padding;
|
|
196
|
+
}
|
|
140
197
|
}
|
|
141
198
|
}
|
|
142
199
|
</style>
|
|
@@ -14,7 +14,7 @@ input.dito-text.dito-input(
|
|
|
14
14
|
|
|
15
15
|
<script>
|
|
16
16
|
import DitoTypeComponent from '../DitoTypeComponent.js'
|
|
17
|
-
import
|
|
17
|
+
import ValueMixin from '../mixins/ValueMixin.js'
|
|
18
18
|
import DataMixin from '../mixins/DataMixin.js'
|
|
19
19
|
|
|
20
20
|
export default DitoTypeComponent.register(
|
|
@@ -37,11 +37,11 @@ export default DitoTypeComponent.register(
|
|
|
37
37
|
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
|
38
38
|
this.data[this.name] = value
|
|
39
39
|
}
|
|
40
|
-
return
|
|
40
|
+
return ValueMixin.computed.value.get.call(this)
|
|
41
41
|
},
|
|
42
42
|
|
|
43
43
|
set(value) {
|
|
44
|
-
|
|
44
|
+
ValueMixin.computed.value.set.call(this, value)
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -526,18 +526,6 @@ const LinkWithTitle = Link.extend({
|
|
|
526
526
|
|
|
527
527
|
position: relative;
|
|
528
528
|
|
|
529
|
-
.dito-resize {
|
|
530
|
-
@extend %icon-resize;
|
|
531
|
-
|
|
532
|
-
position: absolute;
|
|
533
|
-
top: unset;
|
|
534
|
-
left: unset;
|
|
535
|
-
right: 0;
|
|
536
|
-
bottom: 0;
|
|
537
|
-
width: 1em;
|
|
538
|
-
height: 1em;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
529
|
.ProseMirror {
|
|
542
530
|
height: 100%;
|
|
543
531
|
outline: none;
|