Skip to content

Commit

Permalink
fix(alignment): alignment in table, fixed #2
Browse files Browse the repository at this point in the history
  • Loading branch information
mekery committed Apr 18, 2020
1 parent c51622c commit 13c9cf3
Show file tree
Hide file tree
Showing 11 changed files with 200 additions and 136 deletions.
10 changes: 5 additions & 5 deletions src/components/buttons/OAlignDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<q-list>
<q-item v-for="(item, index) in alignments" :key="index"
:class="{ 'is-active': isActive(item.value) }"
@click.native="item.command()" clickable v-close-popup>
@click.native="item.command({ textAlign: item.value })" clickable v-close-popup>
<q-item-section side>
<q-icon :name="`format_align_${item.value}`" />
</q-item-section>
Expand Down Expand Up @@ -43,10 +43,10 @@ export default {
computed: {
alignments () {
return [
{ label: this.$o.lang.editor.left, value: 'left', command: this.commands.align_left },
{ label: this.$o.lang.editor.center, value: 'center', command: this.commands.align_center },
{ label: this.$o.lang.editor.right, value: 'right', command: this.commands.align_right },
{ label: this.$o.lang.editor.justify, value: 'justify', command: this.commands.align_justify },
{ label: this.$o.lang.editor.left, value: 'left', command: this.commands.alignment },
{ label: this.$o.lang.editor.center, value: 'center', command: this.commands.alignment },
{ label: this.$o.lang.editor.right, value: 'right', command: this.commands.alignment },
{ label: this.$o.lang.editor.justify, value: 'justify', command: this.commands.alignment },
]
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/buttons/OAlignGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:icon="`format_align_${item.value}`"
:tooltip="item.label"
:class="{ 'is-active': isActive(item.value) }"
@click.native="item.command" />
@click.native="item.command({ textAlign: item.value })" />
</section>
</template>

Expand Down Expand Up @@ -36,9 +36,9 @@ export default {
computed: {
alignments () {
return [
{ label: this.$o.lang.editor.left, value: 'left', command: this.commands.align_left },
{ label: this.$o.lang.editor.center, value: 'center', command: this.commands.align_center },
{ label: this.$o.lang.editor.right, value: 'right', command: this.commands.align_right },
{ label: this.$o.lang.editor.left, value: 'left', command: this.commands.alignment },
{ label: this.$o.lang.editor.center, value: 'center', command: this.commands.alignment },
{ label: this.$o.lang.editor.right, value: 'right', command: this.commands.alignment },
]
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/components/menubars/OEditorMenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
:is="getName(item)"
:editor="editor"
v-bind="editorContext"
v-else>
</component>
v-else-if="typeof item === 'string'" />
<component :key="index"
:is="item"
:editor="editor"
v-bind="editorContext"
v-else />
<o-table-group v-bind="editorContext" :key="`table-${index}`" v-if="item==='table'" />
</template>
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/components/menubars/OEditorMenuBubble.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<editor-menu-bubble :editor="editor" v-slot="editorContext">
<section class="tiptap-menububble"
:class="{ 'is-active': editorContext.menu.isActive && selectedCellSize === 0 }"
:style="`left: ${editorContext.menu.left}px; bottom: ${editorContext.menu.bottom}px;`">
:style="`left: ${editorContext.menu.left}px; bottom: ${editorContext.menu.bottom + 8}px;`">
<template v-for="(item, index) of bubbleToolbar">
<q-separator vertical inset :key="index" v-if="item==='separator'" />
<component :key="index"
Expand Down
4 changes: 2 additions & 2 deletions src/components/views/OTodoItemView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
>
<div
contenteditable="false"
class="row items-center todo-checkbox"
class="row col-12 items-center todo-checkbox"
@click.stop="toggle"
>
<q-icon :name="done ? 'check_box' : 'check_box_outline_blank'" />
Expand All @@ -18,7 +18,7 @@
<div
ref="content"
:contenteditable="view.editable.toString()"
class="todo-content"
class="full-width todo-content"
/>
</li>
</template>
Expand Down
61 changes: 3 additions & 58 deletions src/data/article.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 8 additions & 20 deletions src/extentions/Alignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { Extension } from 'tiptap'
import { setAlignment } from 'src/utils/alignment'

export default class Alignment extends Extension {
constructor (options = {}) {
super(options)

this._alignment = options.alignment || 'left'
}

get name () {
return 'alignment'
}
Expand All @@ -17,25 +23,7 @@ export default class Alignment extends Extension {
}
}

commands () {
return this.options.alignments.reduce((commands, alignment) => {
return {
...commands,
[`align_${alignment}`]: () => (state, dispatch) => {
const { selection } = state
const tr = setAlignment(
state.tr.setSelection(selection),
alignment === 'left' ? null : alignment,
)

if (tr.docChanged) {
dispatch && dispatch(tr)
return true
} else {
return false
}
},
}
}, {})
commands ({ type }) {
return attrs => setAlignment(type, attrs)
}
}
12 changes: 10 additions & 2 deletions src/pages/examples/all.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<q-page class="page-quasar-tiptap-all">
<quasar-tiptap v-bind="options" scrollable>
<quasar-tiptap v-bind="options" @update="onUpdate" scrollable>
<template slot="toolbar-left">
<q-separator vertical inset />
<o-menubar-btn icon="mdi-overscan"
Expand Down Expand Up @@ -89,13 +89,21 @@ export default {
'redo',
]
},
isSlideShow: false
isSlideShow: false,
json: '',
html: ''
}
},
components: {
OMenubarBtn,
},
methods: {
onUpdate ({ state, getJSON, getHTML }) {
this.json = getJSON()
this.html = getHTML()
console.log('html', this.html)
// console.log('json', JSON.stringify(this.json))
},
onSlideShow () {}
},
mounted () {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/examples/basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default {
this.json = getJSON()
this.html = getHTML()
console.log('html', this.html)
console.log('json', JSON.stringify(this.json))
// console.log('json', JSON.stringify(this.json))
}
},
mounted () {
Expand Down
Loading

0 comments on commit 13c9cf3

Please sign in to comment.