Skip to content

Commit

Permalink
added placeholder and spacing to editor
Browse files Browse the repository at this point in the history
  • Loading branch information
msalbrain committed Nov 24, 2023
1 parent 464fc11 commit d02dbf1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
18 changes: 15 additions & 3 deletions web/admin/src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<script setup>
import { onBeforeUnmount, onMounted, ref, watch } from "vue";
import { EditorContent, Editor } from "@tiptap/vue-3";
import Placeholder from '@tiptap/extension-placeholder'
import StarterKit from "@tiptap/starter-kit";
const emits = defineEmits(["update:modelValue"]);
Expand All @@ -58,12 +59,14 @@ const props = defineProps({
type: String,
required: true,
default: "",
},
}, placeholder: String
});
onMounted(() => {
editor.value = new Editor({
extensions: [StarterKit],
extensions: [StarterKit, Placeholder.configure({
placeholder: props.placeholder,
})],
content: props.modelValue,
onUpdate: () => {
emits("update:modelValue", editor.value.getHTML());
Expand All @@ -88,8 +91,17 @@ watch(
</script>

<style lang="scss">
.tiptap p.is-editor-empty:first-child::before {
color: #adb5bd;
content: attr(data-placeholder);
float: left;
height: 0;
pointer-events: none;
}
.ProseMirror:focus {
outline: none;
outline:none;
}
button,
Expand Down
10 changes: 7 additions & 3 deletions web/admin/src/components/product/Add.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@
</div>

<hr />

<span>Description</span>
<Editor v-model:model-value="product.description" />
<br />
<br />

<b style="font-weight: 550;">Description</b>
<Editor v-model:model-value="product.description" placeholder="type description here"/>

<br />
<br />
</dl>
</div>

Expand Down
2 changes: 1 addition & 1 deletion web/admin/src/components/product/Update.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<hr />

<span>Description</span>
<Editor v-model:model-value="product.description"/>
<Editor v-model:model-value="product.description" placeholder="type description here"/>

</dl>
</div>
Expand Down

0 comments on commit d02dbf1

Please sign in to comment.