@operato/board 8.0.0-beta.0 → 8.0.0-beta.1
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 +9 -0
- package/package.json +14 -14
- package/.storybook/main.js +0 -3
- package/.storybook/server.mjs +0 -8
- package/src/component/3d.ts +0 -29
- package/src/component/chart-and-gauge.ts +0 -28
- package/src/component/container.ts +0 -63
- package/src/component/data-source.ts +0 -30
- package/src/component/etc.ts +0 -88
- package/src/component/form.ts +0 -42
- package/src/component/index.ts +0 -12
- package/src/component/iot.ts +0 -52
- package/src/component/line.ts +0 -156
- package/src/component/register-default-groups.ts +0 -28
- package/src/component/shape.ts +0 -156
- package/src/component/table.ts +0 -28
- package/src/component/text-and-media.ts +0 -125
- package/src/component/warehouse.ts +0 -26
- package/src/data-storage/data-storage.ts +0 -76
- package/src/graphql/board.ts +0 -144
- package/src/graphql/data-subscription.ts +0 -30
- package/src/graphql/favorite-board.ts +0 -25
- package/src/graphql/group.ts +0 -138
- package/src/graphql/index.ts +0 -4
- package/src/graphql/play-group.ts +0 -225
- package/src/graphql/scenario.ts +0 -79
- package/src/index.ts +0 -10
- package/src/modeller/component-toolbar/component-detail.ts +0 -52
- package/src/modeller/component-toolbar/component-menu.ts +0 -196
- package/src/modeller/component-toolbar/component-toolbar.ts +0 -196
- package/src/modeller/component-toolbar/mode-icons.ts +0 -88
- package/src/modeller/edit-toolbar-style.ts +0 -232
- package/src/modeller/edit-toolbar.ts +0 -587
- package/src/modeller/property-sidebar/abstract-property.ts +0 -69
- package/src/modeller/property-sidebar/data-binding/data-binding-mapper.ts +0 -475
- package/src/modeller/property-sidebar/data-binding/data-binding-value-map.ts +0 -19
- package/src/modeller/property-sidebar/data-binding/data-binding-value-range.ts +0 -19
- package/src/modeller/property-sidebar/data-binding/data-binding.ts +0 -480
- package/src/modeller/property-sidebar/effects/effects-shared-style.ts +0 -62
- package/src/modeller/property-sidebar/effects/effects.ts +0 -69
- package/src/modeller/property-sidebar/effects/property-animation.ts +0 -146
- package/src/modeller/property-sidebar/effects/property-animations.ts +0 -93
- package/src/modeller/property-sidebar/effects/property-event-hover.ts +0 -200
- package/src/modeller/property-sidebar/effects/property-event-tap.ts +0 -251
- package/src/modeller/property-sidebar/effects/property-event.ts +0 -73
- package/src/modeller/property-sidebar/effects/property-shadow.ts +0 -114
- package/src/modeller/property-sidebar/effects/value-converter.ts +0 -23
- package/src/modeller/property-sidebar/inspector/inspector.ts +0 -404
- package/src/modeller/property-sidebar/property-shared-style.ts +0 -136
- package/src/modeller/property-sidebar/property-sidebar.ts +0 -326
- package/src/modeller/property-sidebar/shapes/box-padding-editor-styles.ts +0 -94
- package/src/modeller/property-sidebar/shapes/shapes.ts +0 -432
- package/src/modeller/property-sidebar/specifics/specific-properties-builder.ts +0 -152
- package/src/modeller/property-sidebar/specifics/specifics.ts +0 -81
- package/src/modeller/property-sidebar/styles/styles.ts +0 -577
- package/src/modeller/scene-viewer/confidential-overlay.ts +0 -18
- package/src/modeller/scene-viewer/ox-scene-handler.ts +0 -40
- package/src/modeller/scene-viewer/ox-scene-layer.ts +0 -42
- package/src/modeller/scene-viewer/ox-scene-property.ts +0 -10
- package/src/modeller/scene-viewer/ox-scene-viewer.ts +0 -263
- package/src/ox-board-component-info.ts +0 -236
- package/src/ox-board-list.ts +0 -401
- package/src/ox-board-modeller.ts +0 -408
- package/src/ox-board-player-style.ts +0 -200
- package/src/ox-board-player.ts +0 -333
- package/src/ox-board-template-list.ts +0 -267
- package/src/ox-board-template-viewer.ts +0 -198
- package/src/ox-board-viewer.ts +0 -727
- package/src/ox-editor-board-selector.ts +0 -91
- package/src/ox-property-editor-board-selector.ts +0 -23
- package/src/player/ox-board-player-carousel.ts +0 -197
- package/src/player/ox-board-player-grid.ts +0 -78
- package/src/player/ox-board-wrapper.ts +0 -152
- package/src/selector/board-creation-popup.ts +0 -151
- package/src/selector/board-thumbnail-card.ts +0 -175
- package/src/selector/ox-board-creation-card.ts +0 -98
- package/src/selector/ox-board-selector.ts +0 -382
- package/src/types.ts +0 -63
- package/stories/property-data-binding.stories.ts +0 -34
- package/tsconfig.json +0 -24
- package/web-dev-server.config.mjs +0 -30
- package/web-test-runner.config.mjs +0 -29
@@ -1,587 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
|
-
*/
|
4
|
-
|
5
|
-
import { html, LitElement, PropertyValues } from 'lit'
|
6
|
-
import { property, query, queryAll } from 'lit/decorators.js'
|
7
|
-
|
8
|
-
import { Component, Scene } from '@hatiolab/things-scene'
|
9
|
-
import { copyToClipboard, isMacOS } from '@operato/utils'
|
10
|
-
|
11
|
-
import { style } from './edit-toolbar-style'
|
12
|
-
|
13
|
-
const MACOS = isMacOS()
|
14
|
-
|
15
|
-
export class EditToolbar extends LitElement {
|
16
|
-
static styles = [style]
|
17
|
-
|
18
|
-
@property({ type: Object }) scene?: Scene
|
19
|
-
@property({ type: Array }) selected: any[] = []
|
20
|
-
@property({ type: Boolean }) hideProperty: boolean = false
|
21
|
-
|
22
|
-
private cliped?: string
|
23
|
-
|
24
|
-
@query('#redo') private redo!: HTMLElement
|
25
|
-
@query('#undo') private undo!: HTMLElement
|
26
|
-
|
27
|
-
@query('#fullscreen') private fullscreen!: HTMLElement
|
28
|
-
@query('#style-copy') private styleCopy!: HTMLElement
|
29
|
-
@query('#databind-copy') private databindCopy!: HTMLElement
|
30
|
-
@query('#cut') private cut!: HTMLElement
|
31
|
-
@query('#copy') private copy!: HTMLElement
|
32
|
-
@query('#paste') private paste!: HTMLElement
|
33
|
-
@query('#delete') private delete!: HTMLElement
|
34
|
-
|
35
|
-
@query('#forward') private forward!: HTMLElement
|
36
|
-
@query('#backward') private backward!: HTMLElement
|
37
|
-
@query('#front') private front!: HTMLElement
|
38
|
-
@query('#back') private back!: HTMLElement
|
39
|
-
|
40
|
-
@queryAll('[data-align]') private aligners!: NodeListOf<HTMLSpanElement>
|
41
|
-
@queryAll('[data-zorder]') private zorders!: NodeListOf<HTMLSpanElement>
|
42
|
-
@queryAll('[data-distribute]') private distributes!: NodeListOf<HTMLSpanElement>
|
43
|
-
|
44
|
-
firstUpdated() {
|
45
|
-
this.addEventListener('mousewheel', this.onWheelEvent.bind(this) as EventListener, false)
|
46
|
-
|
47
|
-
window.addEventListener('paste', (e: Event) => {
|
48
|
-
try {
|
49
|
-
this.cliped = (e as ClipboardEvent).clipboardData?.getData('text/plain')
|
50
|
-
} catch (e) {
|
51
|
-
console.error('model paste failed', e)
|
52
|
-
}
|
53
|
-
})
|
54
|
-
|
55
|
-
this.aligners.forEach(aligner => aligner.addEventListener('tap', this.onTapAlign.bind(this) as EventListener))
|
56
|
-
this.zorders.forEach(zorder => zorder.addEventListener('tap', this.onTapZorder.bind(this) as EventListener))
|
57
|
-
this.distributes.forEach(distribute =>
|
58
|
-
distribute.addEventListener('tap', this.onTapDistribute.bind(this) as EventListener)
|
59
|
-
)
|
60
|
-
|
61
|
-
this.undo.addEventListener('tap', this.onTapUndo.bind(this) as EventListener)
|
62
|
-
this.redo.addEventListener('tap', this.onTapRedo.bind(this) as EventListener)
|
63
|
-
this.fullscreen.addEventListener('tap', this.onTapFullscreen.bind(this) as EventListener)
|
64
|
-
this.styleCopy.addEventListener('tap', this.onStartStylePasteMode.bind(this) as EventListener)
|
65
|
-
this.databindCopy.addEventListener('tap', this.onStartDatabindPasteMode.bind(this) as EventListener)
|
66
|
-
this.cut.addEventListener('tap', this.onTapCut.bind(this) as EventListener)
|
67
|
-
this.copy.addEventListener('tap', this.onTapCopy.bind(this) as EventListener)
|
68
|
-
this.paste.addEventListener('tap', this.onTapPaste.bind(this) as EventListener)
|
69
|
-
this.delete.addEventListener('tap', this.onTapDelete.bind(this) as EventListener)
|
70
|
-
|
71
|
-
this.renderRoot
|
72
|
-
.querySelector('#font-increase')!
|
73
|
-
.addEventListener('tap', this.onTapFontIncrease.bind(this) as EventListener)
|
74
|
-
this.renderRoot
|
75
|
-
.querySelector('#font-decrease')!
|
76
|
-
.addEventListener('tap', this.onTapFontDecrease.bind(this) as EventListener)
|
77
|
-
this.renderRoot.querySelector('#group')!.addEventListener('tap', this.onTapGroup.bind(this) as EventListener)
|
78
|
-
this.renderRoot.querySelector('#ungroup')!.addEventListener('tap', this.onTapUngroup.bind(this) as EventListener)
|
79
|
-
this.renderRoot
|
80
|
-
.querySelector('#toggle-property')!
|
81
|
-
.addEventListener('tap', this.onTapToggle.bind(this) as EventListener)
|
82
|
-
this.renderRoot.querySelector('#fit-scene')!.addEventListener('tap', this.onTapFitScene.bind(this) as EventListener)
|
83
|
-
this.renderRoot.querySelector('#preview')!.addEventListener('tap', this.onTapPreview.bind(this) as EventListener)
|
84
|
-
}
|
85
|
-
|
86
|
-
updated(changes: PropertyValues<this>) {
|
87
|
-
changes.has('scene') && this.onSceneChanged(this.scene, changes.get('scene') as Scene)
|
88
|
-
changes.has('selected') && this.onSelectedChanged(this.selected, changes.get('selected') as Component[])
|
89
|
-
}
|
90
|
-
|
91
|
-
render() {
|
92
|
-
return html`
|
93
|
-
<div tools>
|
94
|
-
<span><slot></slot></span>
|
95
|
-
|
96
|
-
<span button id="undo" title="undo (${this.getShortcutString('cmd', 'z')})"> </span>
|
97
|
-
<span button id="redo" title="redo (${this.getShortcutString('cmd', 'shift', 'z')})"> </span>
|
98
|
-
|
99
|
-
<span class="vline"></span>
|
100
|
-
|
101
|
-
<span button id="style-copy" title="style copy (${this.getShortcutString('cmd', '1')})"> </span>
|
102
|
-
<span button id="databind-copy" title="databind copy (${this.getShortcutString('cmd', '2')})"> </span>
|
103
|
-
|
104
|
-
<span class="vline"></span>
|
105
|
-
|
106
|
-
<span button id="cut" title="cut (${this.getShortcutString('cmd', 'x')})"> </span>
|
107
|
-
<span button id="copy" title="copy (${this.getShortcutString('cmd', 'c')})"> </span>
|
108
|
-
<span button id="paste" title="paste (${this.getShortcutString('cmd', 'v')})"> </span>
|
109
|
-
<span
|
110
|
-
button
|
111
|
-
id="delete"
|
112
|
-
title="delete (${this.getShortcutString('backspace')}, ${this.getShortcutString('delete')})"
|
113
|
-
>
|
114
|
-
</span>
|
115
|
-
|
116
|
-
<span class="vline"></span>
|
117
|
-
|
118
|
-
<span
|
119
|
-
button
|
120
|
-
data-align="left"
|
121
|
-
id="align-left"
|
122
|
-
title="align left (${this.getShortcutString('alt', 'shift', 'l')})"
|
123
|
-
>
|
124
|
-
</span>
|
125
|
-
<span
|
126
|
-
button
|
127
|
-
data-align="center"
|
128
|
-
id="align-center"
|
129
|
-
title="align center (${this.getShortcutString('alt', 'shift', 'c')})"
|
130
|
-
>
|
131
|
-
</span>
|
132
|
-
<span
|
133
|
-
button
|
134
|
-
data-align="right"
|
135
|
-
id="align-right"
|
136
|
-
title="align right (${this.getShortcutString('alt', 'shift', 'r')})"
|
137
|
-
>
|
138
|
-
</span>
|
139
|
-
|
140
|
-
<span button data-align="top" id="align-top" title="align top (${this.getShortcutString('alt', 'shift', 't')})">
|
141
|
-
</span>
|
142
|
-
<span
|
143
|
-
button
|
144
|
-
data-align="middle"
|
145
|
-
id="align-middle"
|
146
|
-
title="align middle (${this.getShortcutString('alt', 'shift', 'm')})"
|
147
|
-
>
|
148
|
-
</span>
|
149
|
-
<span
|
150
|
-
button
|
151
|
-
data-align="bottom"
|
152
|
-
id="align-bottom"
|
153
|
-
title="align bottom (${this.getShortcutString('alt', 'shift', 'b')})"
|
154
|
-
>
|
155
|
-
</span>
|
156
|
-
|
157
|
-
<span
|
158
|
-
button
|
159
|
-
data-distribute="HORIZONTAL"
|
160
|
-
id="distribute-horizontal"
|
161
|
-
title="distribute horizontally (${this.getShortcutString('alt', 'shift', 'h')})"
|
162
|
-
>
|
163
|
-
</span>
|
164
|
-
|
165
|
-
<span
|
166
|
-
button
|
167
|
-
data-distribute="VERTICAL"
|
168
|
-
id="distribute-vertical"
|
169
|
-
title="distribute vertically (${this.getShortcutString('alt', 'shift', 'v')})"
|
170
|
-
>
|
171
|
-
</span>
|
172
|
-
|
173
|
-
<span class="vline"></span>
|
174
|
-
|
175
|
-
<span
|
176
|
-
button
|
177
|
-
id="front"
|
178
|
-
data-zorder="front"
|
179
|
-
title="bring to front (${this.getShortcutString('cmd', 'shift', 'f')})"
|
180
|
-
>
|
181
|
-
</span>
|
182
|
-
<span button id="back" data-zorder="back" title="send to back (${this.getShortcutString('cmd', 'shift', 'b')})">
|
183
|
-
</span>
|
184
|
-
<span button id="forward" data-zorder="forward" title="bring forward (${this.getShortcutString('cmd', 'f')})">
|
185
|
-
</span>
|
186
|
-
<span button id="backward" data-zorder="backward" title="send backward (${this.getShortcutString('cmd', 'b')})">
|
187
|
-
</span>
|
188
|
-
|
189
|
-
<span class="vline"></span>
|
190
|
-
|
191
|
-
<span button id="group" title="group (${this.getShortcutString('cmd', 'g')})"> </span>
|
192
|
-
<span button id="ungroup" title="ungroup (${this.getShortcutString('cmd', 'shift', 'g')})"> </span>
|
193
|
-
|
194
|
-
<span class="vline"></span>
|
195
|
-
|
196
|
-
<span button id="font-increase" title="increase font size"></span>
|
197
|
-
<span button id="font-decrease" title="decrease font size" style="scale: 0.7;"></span>
|
198
|
-
|
199
|
-
<span class="vline"></span>
|
200
|
-
<span padding></span>
|
201
|
-
|
202
|
-
<span button id="fit-scene" title="fit scene (${this.getShortcutString('cmd', 'd')})"> </span>
|
203
|
-
|
204
|
-
<span class="vline"></span>
|
205
|
-
|
206
|
-
<span button id="preview" title="preview (${this.getShortcutString('ctrl', 'p')})"> </span>
|
207
|
-
|
208
|
-
<span button id="fullscreen" title="fullscreen (${this.getShortcutString('f11')})"> </span>
|
209
|
-
|
210
|
-
<span
|
211
|
-
button
|
212
|
-
id="toggle-property"
|
213
|
-
title="toggle property panel (${this.getShortcutString('cmd', 'h')})"
|
214
|
-
toggles="true"
|
215
|
-
>
|
216
|
-
</span>
|
217
|
-
</div>
|
218
|
-
`
|
219
|
-
}
|
220
|
-
|
221
|
-
onWheelEvent(e: Event) {
|
222
|
-
var delta = Math.max(-1, Math.min(1, (e as WheelEvent).deltaY || -(e as WheelEvent).detail))
|
223
|
-
this.scrollLeft -= delta * 40
|
224
|
-
|
225
|
-
e.preventDefault()
|
226
|
-
}
|
227
|
-
|
228
|
-
getSymbol(key: string) {
|
229
|
-
var symbol
|
230
|
-
switch (key) {
|
231
|
-
case 'cmd':
|
232
|
-
case 'ctrl':
|
233
|
-
symbol = MACOS ? '⌘' : 'Ctrl'
|
234
|
-
break
|
235
|
-
case 'shift':
|
236
|
-
symbol = MACOS ? '⇧' : 'Shift'
|
237
|
-
break
|
238
|
-
case 'alt':
|
239
|
-
case 'option':
|
240
|
-
symbol = MACOS ? '⌥' : 'Alt'
|
241
|
-
break
|
242
|
-
case 'backspace':
|
243
|
-
symbol = MACOS ? '⌫' : 'BackSpace'
|
244
|
-
break
|
245
|
-
case 'delete':
|
246
|
-
symbol = MACOS ? '⌦' : 'Del'
|
247
|
-
break
|
248
|
-
default:
|
249
|
-
symbol = key.toUpperCase()
|
250
|
-
break
|
251
|
-
}
|
252
|
-
|
253
|
-
return symbol
|
254
|
-
}
|
255
|
-
|
256
|
-
private getShortcutString(...keys: string[]) {
|
257
|
-
var symbols = []
|
258
|
-
for (var i = 0; i < arguments.length; i++) {
|
259
|
-
symbols.push(this.getSymbol(arguments[i]))
|
260
|
-
}
|
261
|
-
|
262
|
-
return symbols.join(MACOS ? '' : '+')
|
263
|
-
}
|
264
|
-
|
265
|
-
onShortcut(e: KeyboardEvent) {
|
266
|
-
if (MACOS) var ctrlKey = e.metaKey
|
267
|
-
else var ctrlKey = e.ctrlKey
|
268
|
-
|
269
|
-
var altKey = e.altKey
|
270
|
-
var shiftKey = e.shiftKey
|
271
|
-
|
272
|
-
var defaultPrevent = ctrlKey || altKey
|
273
|
-
|
274
|
-
switch (e.code) {
|
275
|
-
case 'KeyZ':
|
276
|
-
if (ctrlKey && !shiftKey) this.onTapUndo()
|
277
|
-
else if (ctrlKey && shiftKey) this.onTapRedo()
|
278
|
-
break
|
279
|
-
case 'KeyY':
|
280
|
-
if (ctrlKey && !shiftKey) this.onTapRedo()
|
281
|
-
break
|
282
|
-
case 'Digit1':
|
283
|
-
if (ctrlKey) this.onStartStylePasteMode()
|
284
|
-
break
|
285
|
-
case 'Digit2':
|
286
|
-
if (ctrlKey) this.onStartDatabindPasteMode()
|
287
|
-
break
|
288
|
-
case 'KeyC':
|
289
|
-
if (ctrlKey && !shiftKey) this.onTapCopy()
|
290
|
-
else if (altKey && shiftKey) this.onTapAlign('center')
|
291
|
-
break
|
292
|
-
case 'KeyX':
|
293
|
-
if (ctrlKey && !shiftKey) this.onTapCut()
|
294
|
-
break
|
295
|
-
case 'KeyV':
|
296
|
-
if (ctrlKey && !shiftKey) {
|
297
|
-
this.onTapPaste()
|
298
|
-
defaultPrevent = false
|
299
|
-
} else if (altKey && shiftKey) this.onTapDistribute('VERTICAL')
|
300
|
-
break
|
301
|
-
case 'Delete':
|
302
|
-
case 'Backspace':
|
303
|
-
this.onTapDelete()
|
304
|
-
defaultPrevent = true
|
305
|
-
break
|
306
|
-
case 'KeyG':
|
307
|
-
if (ctrlKey && !shiftKey) this.onTapGroup()
|
308
|
-
else if (ctrlKey && shiftKey) this.onTapUngroup()
|
309
|
-
break
|
310
|
-
case 'KeyF':
|
311
|
-
if (ctrlKey && !shiftKey) this.scene?.zorder('forward')
|
312
|
-
else if (ctrlKey && shiftKey) this.scene?.zorder('front')
|
313
|
-
break
|
314
|
-
case 'KeyB':
|
315
|
-
if (ctrlKey && !shiftKey) this.scene?.zorder('backward')
|
316
|
-
else if (ctrlKey && shiftKey) this.scene?.zorder('back')
|
317
|
-
else if (altKey && shiftKey) this.onTapAlign('bottom')
|
318
|
-
break
|
319
|
-
case 'KeyH':
|
320
|
-
if (ctrlKey && !shiftKey) this.onTapToggle()
|
321
|
-
else if (altKey && shiftKey) this.onTapDistribute('HORIZONTAL')
|
322
|
-
break
|
323
|
-
case 'F11':
|
324
|
-
this.onTapFullscreen()
|
325
|
-
defaultPrevent = true
|
326
|
-
break
|
327
|
-
case 'KeyP':
|
328
|
-
if (ctrlKey) {
|
329
|
-
this.onTapPreview()
|
330
|
-
defaultPrevent = true
|
331
|
-
}
|
332
|
-
break
|
333
|
-
case 'KeyA':
|
334
|
-
if (ctrlKey) this.onTapSelectAll()
|
335
|
-
break
|
336
|
-
case 'KeyL':
|
337
|
-
if (altKey && shiftKey) this.onTapAlign('left')
|
338
|
-
break
|
339
|
-
case 'KeyR':
|
340
|
-
if (altKey && shiftKey) this.onTapAlign('right')
|
341
|
-
break
|
342
|
-
case 'KeyM':
|
343
|
-
if (altKey && shiftKey) this.onTapAlign('middle')
|
344
|
-
break
|
345
|
-
case 'KeyT':
|
346
|
-
if (altKey && shiftKey) this.onTapAlign('top')
|
347
|
-
break
|
348
|
-
case 'KeyD':
|
349
|
-
if (ctrlKey) {
|
350
|
-
this.onTapFitScene()
|
351
|
-
defaultPrevent = true
|
352
|
-
}
|
353
|
-
break
|
354
|
-
case 'KeyE':
|
355
|
-
if (ctrlKey && shiftKey) this.onTapDownloadModel()
|
356
|
-
break
|
357
|
-
case 'Digit1':
|
358
|
-
if (ctrlKey) {
|
359
|
-
console.log('MODEL', this.scene && this.scene.model)
|
360
|
-
defaultPrevent = true
|
361
|
-
}
|
362
|
-
break
|
363
|
-
case 'Digit2':
|
364
|
-
if (ctrlKey) {
|
365
|
-
console.log('SELECTED', this.scene && this.scene.selected)
|
366
|
-
defaultPrevent = true
|
367
|
-
}
|
368
|
-
break
|
369
|
-
|
370
|
-
default:
|
371
|
-
return false
|
372
|
-
}
|
373
|
-
|
374
|
-
if (defaultPrevent) e.preventDefault()
|
375
|
-
return true
|
376
|
-
}
|
377
|
-
|
378
|
-
onExecute(command: string, undoable: boolean, redoable: boolean) {
|
379
|
-
!undoable ? this.undo.setAttribute('disabled', '') : this.undo.removeAttribute('disabled')
|
380
|
-
!redoable ? this.redo.setAttribute('disabled', '') : this.redo.removeAttribute('disabled')
|
381
|
-
}
|
382
|
-
|
383
|
-
onUndo(undoable: boolean, redoable: boolean) {
|
384
|
-
!undoable ? this.undo.setAttribute('disabled', '') : this.undo.removeAttribute('disabled')
|
385
|
-
!redoable ? this.redo.setAttribute('disabled', '') : this.redo.removeAttribute('disabled')
|
386
|
-
}
|
387
|
-
|
388
|
-
onRedo(undoable: boolean, redoable: boolean) {
|
389
|
-
!undoable ? this.undo.setAttribute('disabled', '') : this.undo.removeAttribute('disabled')
|
390
|
-
!redoable ? this.redo.setAttribute('disabled', '') : this.redo.removeAttribute('disabled')
|
391
|
-
}
|
392
|
-
|
393
|
-
onSceneChanged(after?: Scene, before?: Scene) {
|
394
|
-
if (before) {
|
395
|
-
before.off('execute', this.onExecute, this)
|
396
|
-
before.off('undo', this.onUndo, this)
|
397
|
-
before.off('redo', this.onRedo, this)
|
398
|
-
}
|
399
|
-
|
400
|
-
if (after) {
|
401
|
-
after.on('execute', this.onExecute, this)
|
402
|
-
after.on('undo', this.onUndo, this)
|
403
|
-
after.on('redo', this.onRedo, this)
|
404
|
-
}
|
405
|
-
}
|
406
|
-
|
407
|
-
onSelectedChanged(after: Component[], before: Component[]) {
|
408
|
-
var alignable = after.length > 1
|
409
|
-
|
410
|
-
this.aligners.forEach(aligner =>
|
411
|
-
alignable ? aligner.removeAttribute('disabled') : aligner.setAttribute('disabled', '')
|
412
|
-
)
|
413
|
-
|
414
|
-
var movable = after.length === 1
|
415
|
-
|
416
|
-
/* forward, backward 이동은 한 컴포넌트만 가능하다. */
|
417
|
-
!movable ? this.forward.setAttribute('disabled', '') : this.forward.removeAttribute('disabled')
|
418
|
-
!movable ? this.backward.setAttribute('disabled', '') : this.backward.removeAttribute('disabled')
|
419
|
-
|
420
|
-
/* 여러 컴포넌트는 front, back 이동이 가능하다. */
|
421
|
-
!(alignable || movable) ? this.front.setAttribute('disabled', '') : this.front.removeAttribute('disabled')
|
422
|
-
!(alignable || movable) ? this.back.setAttribute('disabled', '') : this.back.removeAttribute('disabled')
|
423
|
-
}
|
424
|
-
|
425
|
-
onTapUndo() {
|
426
|
-
this.scene?.undo()
|
427
|
-
}
|
428
|
-
|
429
|
-
onTapRedo() {
|
430
|
-
this.scene?.redo()
|
431
|
-
}
|
432
|
-
|
433
|
-
onStartStylePasteMode() {
|
434
|
-
this.scene?.startStylePasteMode()
|
435
|
-
}
|
436
|
-
|
437
|
-
onStartDatabindPasteMode() {
|
438
|
-
this.scene?.startDatabindPasteMode()
|
439
|
-
}
|
440
|
-
|
441
|
-
onTapCut() {
|
442
|
-
this.scene?.cut()
|
443
|
-
}
|
444
|
-
|
445
|
-
async onTapCopy() {
|
446
|
-
var copied = this.scene?.copy()
|
447
|
-
|
448
|
-
if (!copied) return
|
449
|
-
|
450
|
-
await copyToClipboard(copied)
|
451
|
-
this.cliped = copied
|
452
|
-
}
|
453
|
-
|
454
|
-
onTapPaste() {
|
455
|
-
setTimeout(() => {
|
456
|
-
this.cliped && this.scene?.paste(this.cliped)
|
457
|
-
}, 100)
|
458
|
-
}
|
459
|
-
|
460
|
-
onTapDelete() {
|
461
|
-
this.scene?.remove()
|
462
|
-
}
|
463
|
-
|
464
|
-
onTapSelectAll() {
|
465
|
-
this.scene?.select('(child)')
|
466
|
-
}
|
467
|
-
|
468
|
-
onTapFontIncrease(e: TouchEvent) {
|
469
|
-
var selected = this.scene?.selected
|
470
|
-
if (!selected || !selected.length) {
|
471
|
-
return
|
472
|
-
}
|
473
|
-
|
474
|
-
this.scene?.undoableChange(function () {
|
475
|
-
selected!.forEach(function (component) {
|
476
|
-
var fontSize = component.get('fontSize')
|
477
|
-
|
478
|
-
if (!fontSize) fontSize = '15'
|
479
|
-
|
480
|
-
if (fontSize) {
|
481
|
-
var size = parseInt(fontSize)
|
482
|
-
component.set('fontSize', size + 1)
|
483
|
-
}
|
484
|
-
})
|
485
|
-
})
|
486
|
-
}
|
487
|
-
|
488
|
-
onTapFontDecrease(e: TouchEvent) {
|
489
|
-
var selected = this.scene?.selected
|
490
|
-
|
491
|
-
if (!selected || !selected.length) {
|
492
|
-
return
|
493
|
-
}
|
494
|
-
|
495
|
-
this.scene?.undoableChange(function () {
|
496
|
-
selected!.forEach(function (component) {
|
497
|
-
var fontSize = component.get('fontSize')
|
498
|
-
|
499
|
-
if (!fontSize) fontSize = '15'
|
500
|
-
|
501
|
-
if (fontSize) {
|
502
|
-
var size = parseInt(fontSize)
|
503
|
-
if (size > 1) component.set('fontSize', size - 1)
|
504
|
-
}
|
505
|
-
})
|
506
|
-
})
|
507
|
-
}
|
508
|
-
|
509
|
-
onTapAlign(e: TouchEvent | string) {
|
510
|
-
if (!this.scene) return
|
511
|
-
|
512
|
-
var selected = this.scene.selected
|
513
|
-
|
514
|
-
var align = typeof e === 'string' ? e : (e.target as HTMLElement).getAttribute('data-align')
|
515
|
-
if (!align) {
|
516
|
-
return
|
517
|
-
}
|
518
|
-
|
519
|
-
if (selected.length <= 1) {
|
520
|
-
this.scene.place(align)
|
521
|
-
} else {
|
522
|
-
this.scene.align(align)
|
523
|
-
}
|
524
|
-
}
|
525
|
-
|
526
|
-
onTapZorder(e: TouchEvent | string) {
|
527
|
-
if (!this.scene) return
|
528
|
-
|
529
|
-
var selected = this.scene.selected
|
530
|
-
if (selected.length < 1) return
|
531
|
-
|
532
|
-
var zorder = typeof e === 'string' ? e : (e.target as HTMLElement).getAttribute('data-zorder')
|
533
|
-
|
534
|
-
zorder && this.scene.zorder(zorder)
|
535
|
-
}
|
536
|
-
|
537
|
-
onTapGroup() {
|
538
|
-
this.scene && this.scene.group()
|
539
|
-
}
|
540
|
-
|
541
|
-
onTapUngroup() {
|
542
|
-
this.scene && this.scene.ungroup()
|
543
|
-
}
|
544
|
-
|
545
|
-
onTapFullscreen() {
|
546
|
-
this.dispatchEvent(new CustomEvent('modeller-fullscreen'))
|
547
|
-
}
|
548
|
-
|
549
|
-
onTapToggle() {
|
550
|
-
this.hideProperty = !this.hideProperty
|
551
|
-
this.dispatchEvent(
|
552
|
-
new CustomEvent('hide-property-changed', {
|
553
|
-
bubbles: true,
|
554
|
-
composed: true,
|
555
|
-
detail: { value: this.hideProperty }
|
556
|
-
})
|
557
|
-
)
|
558
|
-
}
|
559
|
-
|
560
|
-
onTapFitScene() {
|
561
|
-
if (this.scene) {
|
562
|
-
this.scene.resize()
|
563
|
-
this.scene.fit('ratio')
|
564
|
-
}
|
565
|
-
}
|
566
|
-
|
567
|
-
onTapPreview() {
|
568
|
-
this.dispatchEvent(new CustomEvent('open-preview'))
|
569
|
-
}
|
570
|
-
|
571
|
-
onTapDownloadModel() {
|
572
|
-
this.dispatchEvent(new CustomEvent('download-model'))
|
573
|
-
}
|
574
|
-
|
575
|
-
onTapDistribute(e: TouchEvent | string) {
|
576
|
-
if (!this.scene) return
|
577
|
-
|
578
|
-
var selected = this.scene.selected
|
579
|
-
if (selected.length <= 1) {
|
580
|
-
return
|
581
|
-
}
|
582
|
-
|
583
|
-
var distribute = typeof e === 'string' ? e : (e.target as HTMLElement)!.getAttribute('data-distribute')
|
584
|
-
|
585
|
-
distribute && this.scene.distribute(distribute)
|
586
|
-
}
|
587
|
-
}
|
@@ -1,69 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
|
-
*/
|
4
|
-
|
5
|
-
import { LitElement } from 'lit'
|
6
|
-
|
7
|
-
export class AbstractProperty extends LitElement {
|
8
|
-
firstUpdated() {
|
9
|
-
this.renderRoot.addEventListener('change', this._onValueChange.bind(this))
|
10
|
-
}
|
11
|
-
|
12
|
-
_onValueChange(e: Event) {
|
13
|
-
var element = e.target as HTMLElement
|
14
|
-
var key = element.getAttribute('value-key')
|
15
|
-
|
16
|
-
if (!key) {
|
17
|
-
return
|
18
|
-
}
|
19
|
-
|
20
|
-
var value = this._getValueFromEventTarget(element)
|
21
|
-
|
22
|
-
this._onAfterValueChange(key, value)
|
23
|
-
}
|
24
|
-
|
25
|
-
_getValueFromEventTarget(element: HTMLElement) {
|
26
|
-
var value
|
27
|
-
|
28
|
-
switch (element.tagName) {
|
29
|
-
case 'INPUT':
|
30
|
-
switch ((element as any).type) {
|
31
|
-
case 'checkbox':
|
32
|
-
value = (element as any).checked
|
33
|
-
break
|
34
|
-
case 'number':
|
35
|
-
value = Number((element as any).valueAsNumber)
|
36
|
-
break
|
37
|
-
case 'text':
|
38
|
-
value = String((element as any).value)
|
39
|
-
}
|
40
|
-
break
|
41
|
-
|
42
|
-
case 'PAPER-BUTTON':
|
43
|
-
value = (element as any).active
|
44
|
-
break
|
45
|
-
|
46
|
-
case 'PAPER-LISTBOX':
|
47
|
-
value = (element as any).selected
|
48
|
-
break
|
49
|
-
|
50
|
-
default:
|
51
|
-
value = (element as any).value
|
52
|
-
break
|
53
|
-
}
|
54
|
-
|
55
|
-
return value
|
56
|
-
}
|
57
|
-
|
58
|
-
_onAfterValueChange(key: string, value: any) {
|
59
|
-
this.dispatchEvent(
|
60
|
-
new CustomEvent('property-change', {
|
61
|
-
bubbles: true,
|
62
|
-
composed: true,
|
63
|
-
detail: {
|
64
|
-
[key]: value
|
65
|
-
}
|
66
|
-
})
|
67
|
-
)
|
68
|
-
}
|
69
|
-
}
|