Skip to content

Commit

Permalink
feat(editor): update content
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Sep 21, 2021
1 parent f0193de commit 53e4eed
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
"vue/no-mutating-props": 0,
"vue/valid-v-on": 0,
"vue/valid-v-for": 0,
"vue/require-default-prop": 0,
"@typescript-eslint/no-empty-function": 0,
"no-undef": 0
},
Expand Down
1 change: 1 addition & 0 deletions src/components/editor/EditorBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
:key="page.id"
:type="page.type"
:position="page.id"
:raw="page.raw"
>
{{ page.raw }}
</TextShow>
Expand Down
21 changes: 18 additions & 3 deletions src/components/editor/text/TextShow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
class="flex w-full hover:shadow-winset dark:hover:shadow-binset"
@mouseenter="hover = true"
@mouseleave="hover = false"
@click.prevent="edit = true"
>
<TextShowPopover v-if="hover" :position="position" />
<TextShowPopover v-if="hover && !edit" :position="position" />
<p
class="w-full break-all"
:class="[
Expand Down Expand Up @@ -65,21 +66,35 @@
: '',
]"
>
<slot />
<slot v-if="!edit" />
<input
v-else
id="editInput"
class="w-full bg-transparent"
@keypress.enter="edit = false"
/>
</p>
</section>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { ref, watch, nextTick } from 'vue'
import { useStore } from 'vuex'
const props = defineProps({
type: String,
position: Number,
raw: String,
})
const store = useStore()
const hover = ref(false)
const edit = ref(false)
watch(edit, async (_edit) => {
await nextTick
if (_edit)
(document.querySelector('#editInput') as HTMLInputElement).focus()
})
</script>

0 comments on commit 53e4eed

Please sign in to comment.