Skip to content

Commit

Permalink
feat: placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
gbicou committed Apr 6, 2023
1 parent 11ebd6f commit a410b11
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@tiptap/core": "^2.0.2",
"@tiptap/extension-placeholder": "^2.0.2",
"@tiptap/extension-underline": "^2.0.2",
"@tiptap/pm": "^2.0.2",
"@tiptap/starter-kit": "^2.0.2",
Expand Down
13 changes: 13 additions & 0 deletions pnpm-lock.yaml

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

15 changes: 14 additions & 1 deletion src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ export default defineInterface({
component: TiptapEditor,
types: ["json", "text"],
group: "standard",
options: null,
recommendedDisplays: ["tiptap"],
options: [
{
field: "placeholder",
name: "$t:placeholder",
type: "string",
meta: {
width: "full",
interface: "system-input-translated-string",
options: {
placeholder: "$t:enter_a_placeholder",
},
},
},
],
});
18 changes: 17 additions & 1 deletion src/tiptap-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,21 @@
strong {
font-weight: 700;
}
.ProseMirror p.is-editor-empty:first-child::before {
color: var(--foreground-subdued);
content: attr(data-placeholder);
float: left;
height: 0;
pointer-events: none;
}
}
}
</style>

<script setup lang="ts">
import { Editor, EditorContent, BubbleMenu } from "@tiptap/vue-3";
import { Placeholder } from "@tiptap/extension-placeholder";
import { onBeforeUnmount, watch } from "vue";
import { useI18n } from "vue-i18n";
import { translateShortcut } from "./utils/translate-shortcut";
Expand Down Expand Up @@ -344,14 +353,21 @@ const props = withDefaults(
value: ValueType | null;
type: TypeType;
disabled: boolean;
placeholder: string | null;
}>(),
{ value: null, disabled: false }
{ value: null, disabled: false, placeholder: null }
);
const emit = defineEmits<{
(e: "input", value: ValueType): void;
}>();
extensions.push(
Placeholder.configure({
placeholder: props.placeholder,
})
);
const editor = new Editor({
editable: !props.disabled,
content: props.value,
Expand Down

0 comments on commit a410b11

Please sign in to comment.