-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 整理core-editor 文件夹,为后续将编辑器做成独立模块作准备
- Loading branch information
Showing
96 changed files
with
756 additions
and
646 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
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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<template> | ||
<a-layout-header class="layout-header"> | ||
<LogoOfHeader /> | ||
<div style="float:right;"> | ||
<Links /> | ||
<slot name="action-menu"></slot> | ||
<LangSelect /> | ||
</div> | ||
</a-layout-header> | ||
</template> | ||
<script> | ||
import LogoOfHeader from './logo.js' | ||
import LangSelect from './LangSelect' | ||
import Links from './links' | ||
export default { | ||
name: 'Header', | ||
components: { | ||
LogoOfHeader, | ||
LangSelect, | ||
Links | ||
} | ||
} | ||
</script> | ||
<style lang="scss" scoped> | ||
.layout-header { | ||
padding: 0 10px; | ||
.logo { | ||
width: 120px; | ||
height: 31px; | ||
margin: 16px 28px 16px 0; | ||
float: left; | ||
line-height: 31px; | ||
text-align: center; | ||
color: white; | ||
font-size: 16px; | ||
} | ||
.lang-select-activator, | ||
.user-avatar-activator { | ||
// float: right; | ||
background: transparent; | ||
margin: 0 28px 16px 0; | ||
cursor: pointer; | ||
.anticon { | ||
color: white; | ||
} | ||
} | ||
} | ||
</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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.card-cover-wrapper { | ||
position: relative; | ||
height: 300px; | ||
border: 1px dashed #eee; | ||
color: #aaa; | ||
padding: 4px; | ||
} |
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { mapState, mapActions } from 'vuex' | ||
|
||
import RenderEditCanvas from './edit' | ||
import RenderPreviewCanvas from './preview' | ||
|
||
export default { | ||
name: 'EditorCanvas', | ||
data: () => ({ | ||
isPreviewMode: false, | ||
scaleRate: 1 | ||
}), | ||
computed: { | ||
...mapState('editor', { | ||
editingPage: state => state.editingPage, | ||
editingElement: state => state.editingElement, | ||
elements: state => state.editingPage.elements, | ||
pages: state => state.work.pages, | ||
work: state => state.work | ||
}), | ||
...mapState('loading', [ | ||
'saveWork_loading', | ||
'previewWork_loading', | ||
'setWorkAsTemplate_loading', | ||
'uploadWorkCover_loading' | ||
]) | ||
}, | ||
methods: { | ||
...mapActions('editor', [ | ||
'elementManager', | ||
'pageManager', | ||
'saveWork', | ||
'createWork', | ||
'fetchWork', | ||
'updateWork', | ||
'setWorkAsTemplate', | ||
'setEditingElement', | ||
'setEditingPage' | ||
]), | ||
handleToggleMode (isPreviewMode) { | ||
this.isPreviewMode = isPreviewMode | ||
if (isPreviewMode) { | ||
// 当切换到预览模式的时候,清空当前编辑元素 | ||
this.setEditingElement() // 相当于 setEditingElement(null) | ||
} | ||
} | ||
}, | ||
render (h) { | ||
return ( | ||
<a-layout id="canvas-outer-wrapper"> | ||
<a-radio-group | ||
class="mode-toggle-wrapper" | ||
size="small" | ||
value={this.isPreviewMode} | ||
onInput={this.handleToggleMode} | ||
> | ||
{/* 编辑模式、预览模式 */} | ||
<a-radio-button label={false} value={false}>{this.$t('editor.centerPanel.mode.edit')}</a-radio-button> | ||
<a-radio-button label={true} value={true}>{this.$t('editor.centerPanel.mode.preview')}</a-radio-button> | ||
</a-radio-group> | ||
<a-layout-content style={{ transform: `scale(${this.scaleRate})`, 'transform-origin': 'center top' }}> | ||
<div class='canvas-wrapper' style={{ | ||
height: `${this.work.height}px` | ||
}}> | ||
{ this.isPreviewMode | ||
? <RenderPreviewCanvas elements={this.elements}/> | ||
: <RenderEditCanvas | ||
class="edit-mode" | ||
elements={this.elements} | ||
/> | ||
} | ||
</div> | ||
</a-layout-content> | ||
</a-layout> | ||
) | ||
} | ||
} |
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
51 changes: 51 additions & 0 deletions
51
front-end/h5/src/components/core/editor/fixed-tools/index.js
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import hotkeys from 'hotkeys-js' | ||
import fixedTools from './options' | ||
|
||
export default { | ||
render () { | ||
return ( | ||
<a-layout-sider | ||
width="40" | ||
theme='light' | ||
style={{ background: '#fff', border: '1px solid #eee' }} | ||
> | ||
<a-button-group style={{ display: 'flex', flexDirection: 'column' }}> | ||
{ | ||
fixedTools.map(tool => ( | ||
<a-tooltip | ||
effect="dark" | ||
placement="left" | ||
title={this.$t(tool.i18nTooltip, { hotkey: tool.hotkeyTooltip })}> | ||
<a-button | ||
block | ||
class="transparent-bg" | ||
type="link" | ||
size="small" | ||
style={{ height: '40px', color: '#000' }} | ||
disabled={!!tool.disabled} | ||
onClick={() => tool.action && tool.action.call(this)} | ||
> | ||
{ | ||
tool.icon | ||
? <i class={['shortcut-icon', 'fa', `fa-${tool.icon}`]} aria-hidden='true' /> | ||
: (tool.text || this.$t(tool.i18nTooltip)) | ||
} | ||
</a-button> | ||
{ tool.icon === 'minus' && <div style={{ fontSize: '12px', textAlign: 'center' }}>{this.scaleRate * 100}%</div>} | ||
</a-tooltip> | ||
)) | ||
} | ||
</a-button-group> | ||
</a-layout-sider> | ||
) | ||
}, | ||
mounted () { | ||
fixedTools.map(tool => { | ||
tool.hotkey && hotkeys(tool.hotkey, { splitKey: '&' }, (event, handler) => { | ||
event.preventDefault() | ||
event.stopPropagation() | ||
tool.action && tool.action.call(this) | ||
}) | ||
}) | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
front-end/h5/src/components/core/editor/fixed-tools/options.js
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import undoRedoHistory from '../../../../store/plugins/undo-redo/History' | ||
|
||
const fixedTools = [ | ||
{ | ||
i18nTooltip: 'editor.fixedTool.undo', | ||
icon: 'mail-reply', | ||
action: () => undoRedoHistory.undo(), | ||
hotkey: 'ctrl&z,⌘&z', | ||
hotkeyTooltip: '(ctrl+z)' | ||
}, | ||
{ | ||
i18nTooltip: 'editor.fixedTool.redo', | ||
icon: 'mail-forward', | ||
action: () => undoRedoHistory.redo(), | ||
hotkey: 'ctrl&y,⌘&u', | ||
hotkeyTooltip: '(ctrl+y)' | ||
}, | ||
{ | ||
i18nTooltip: 'editor.fixedTool.preview', | ||
icon: 'eye', | ||
action: function () { this.previewDialogVisible = true } | ||
}, | ||
{ | ||
i18nTooltip: 'editor.fixedTool.copyCurrentPage', | ||
icon: 'copy', | ||
action: function () { this.pageManager({ type: 'copy' }) }, | ||
hotkey: 'ctrl&c,⌘&c' | ||
}, | ||
{ | ||
i18nTooltip: 'editor.fixedTool.copyCurrentElement', | ||
icon: 'copy', | ||
action: function () { this.elementManager({ type: 'copy' }) } | ||
}, | ||
{ | ||
i18nTooltip: 'editor.fixedTool.importPSD', | ||
text: 'Ps', | ||
icon: '', // 优先级: icon > text > i18nTooltip | ||
action: '', | ||
disabled: true | ||
}, | ||
{ | ||
i18nTooltip: 'editor.fixedTool.zoomOut', | ||
icon: 'plus', | ||
action: function () { this.scaleRate += 0.25 }, | ||
hotkey: 'ctrl&=,⌘&=', | ||
hotkeyTooltip: '(ctrl +)' | ||
}, | ||
{ | ||
i18nTooltip: 'editor.fixedTool.zoomIn', | ||
icon: 'minus', | ||
action: function () { this.scaleRate -= 0.25 }, | ||
hotkey: 'ctrl&-,⌘&-', | ||
hotkeyTooltip: '(ctrl -)' | ||
}, | ||
{ | ||
i18nTooltip: 'editor.fixedTool.issues', | ||
icon: 'question', | ||
action: function () { window.open('https://github.com/ly525/luban-h5/issues/110') } | ||
} | ||
] | ||
|
||
export default fixedTools |
Oops, something went wrong.