-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* dnd: add drag event in dnd polyfill * feat: make viewport be resizable * feat: allow to resize from any corner of resizable element * refactor: rewrite render function with template of renderer * fix: avoid throwing assertion error when canceling node selection * feat: add a toolbar to show and edit viewport size * test: add test for matchSelectedNodeWithStyles * test: add test of Resizable component * test: add Toolbar test * test: add more test for Toolbar
- Loading branch information
Showing
13 changed files
with
816 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ export default Vue.extend({ | |
body { | ||
padding: 0; | ||
margin: 0; | ||
background-color: #ddd; | ||
} | ||
</style> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,59 @@ | ||
<template> | ||
<div class="renderer" @click="$emit('select')"> | ||
<Viewport :width="width" :height="height" @resize="$emit('resize', arguments[0])"> | ||
<VueComponent | ||
:uri="document.uri" | ||
:template="document.template" | ||
:props="document.props" | ||
:data="document.data" | ||
:child-components="document.childComponents" | ||
:styles="document.styleCode" | ||
@select="$emit('select', arguments[0])" | ||
@dragover="$emit('dragover', arguments[0])" | ||
@add="$emit('add')" | ||
/> | ||
</Viewport> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue, { VNode } from 'vue' | ||
import Vue from 'vue' | ||
import Viewport from './Viewport.vue' | ||
import VueComponent from './VueComponent.vue' | ||
import { ScopedDocument } from '../store/modules/project' | ||
export default Vue.extend({ | ||
name: 'Renderer', | ||
functional: true, | ||
components: { | ||
Viewport, | ||
VueComponent | ||
}, | ||
props: { | ||
document: { | ||
type: Object as () => ScopedDocument, | ||
required: true | ||
}, | ||
width: { | ||
type: Number, | ||
required: true | ||
}, | ||
height: { | ||
type: Number, | ||
required: true | ||
} | ||
}, | ||
// @ts-ignore | ||
render(h, { props, listeners }): VNode { | ||
const { document: d } = props | ||
return h( | ||
'div', | ||
{ | ||
class: 'renderer', | ||
on: { | ||
click: () => { | ||
if (listeners.select) { | ||
listeners.select() | ||
} | ||
} | ||
} | ||
}, | ||
[ | ||
h(Viewport, [ | ||
h(VueComponent, { | ||
props: { | ||
uri: d.uri, | ||
template: d.template, | ||
props: d.props, | ||
data: d.data, | ||
childComponents: d.childComponents, | ||
styles: d.styleCode | ||
}, | ||
on: listeners | ||
}) | ||
]) | ||
] | ||
) | ||
} | ||
}) | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.renderer { | ||
all: initial; | ||
overflow: auto; | ||
display: block; | ||
position: relative; | ||
box-sizing: border-box; | ||
height: 100%; | ||
width: 100%; | ||
background-color: #ddd; | ||
} | ||
</style> |
Oops, something went wrong.