Skip to content

Commit

Permalink
fix(todo_item): fix TodoItem checkbox unexpected render in preview …
Browse files Browse the repository at this point in the history
…modal (#73)

close #73
  • Loading branch information
Leecason committed Jun 7, 2020
1 parent 19cd3cc commit c4a8860
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 25 deletions.
2 changes: 2 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function getConfig ({
vue: 'Vue',
// TODO: tiptap
'element-ui/lib/button': 'ELEMENT.Button',
'element-ui/lib/checkbox': 'ELEMENT.Checkbox',
'element-ui/lib/tooltip': 'ELEMENT.Tooltip',
'element-ui/lib/dialog': 'ELEMENT.Dialog',
'element-ui/lib/popover': 'ELEMENT.Popover',
Expand All @@ -61,6 +62,7 @@ function getConfig ({
'prosemirror-model',
'prosemirror-tables',
'element-ui/lib/button',
'element-ui/lib/checkbox',
'element-ui/lib/tooltip',
'element-ui/lib/dialog',
'element-ui/lib/popover',
Expand Down
18 changes: 4 additions & 14 deletions src/components/ExtensionViews/TodoItemView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
class="todo-item"
data-drag-handle
>
<span
contenteditable="false"
class="todo-checkbox"
@click.stop="toggle"
>
<v-icon :name="done ? 'check-square' : 'regular/square'" />
<span contenteditable="false">
<el-checkbox v-model="done" />
</span>

<div
Expand All @@ -26,16 +22,14 @@

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { Checkbox } from 'element-ui';
import { Node as ProsemirrorNode } from 'prosemirror-model';
import { EditorView } from 'prosemirror-view';
import Icon from 'vue-awesome/components/Icon.vue';
import 'vue-awesome/icons/check-square';
import 'vue-awesome/icons/regular/square';
import { transformLineHeightToCSS } from '@/utils/line_height';
@Component({
components: {
'v-icon': Icon,
[Checkbox.name]: Checkbox,
},
})
export default class TodoItemView extends Vue {
Expand Down Expand Up @@ -72,9 +66,5 @@ export default class TodoItemView extends Vue {
lineHeight: transformLineHeightToCSS(this.node.attrs.lineHeight),
};
}
toggle () {
this.done = !this.done;
}
};
</script>
12 changes: 10 additions & 2 deletions src/extensions/todo_item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,16 @@ function toDOM (node: ProsemirrorNode): DOMOutputSpec {

return [
'li',
attrs,
['span', { class: 'todo-checkbox', contenteditable: 'false' }],
{ ...attrs, class: `todo-item ${done ? 'todo-item--done' : ''}` },
// el-checkbox dom
['span', {
contenteditable: 'false'
}, ['span', {
class: `el-checkbox ${done ? 'is-checked' : ''}`,
style: 'pointer-events: none;',
}, ['span', { class: `el-checkbox__input ${done ? 'is-checked' : ''}` }, [
'span', { class: 'el-checkbox__inner' }
]]]],
['div', { class: 'todo-content' }, 0],
];
}
Expand Down
9 changes: 0 additions & 9 deletions src/styles/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,6 @@
text-align: space-between !important;
}

.todo-checkbox {
color: $border-color;
cursor: pointer;
display: inline-block;
font-size: 18px;
line-height: inherit;
margin-top: 2px;
}

.todo-content {
padding-left: 10px;

Expand Down

0 comments on commit c4a8860

Please sign in to comment.