-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: include a custom display rendering content as text
- Loading branch information
Showing
6 changed files
with
68 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,18 +6,34 @@ | |
"keywords": [ | ||
"directus", | ||
"directus-extension", | ||
"directus-custom-bundle", | ||
"directus-custom-interface", | ||
"directus-custom-display", | ||
"tiptap" | ||
], | ||
"homepage": "https://github.com/gbicou/directus-extension-tiptap", | ||
"author": "Benjamin VIELLARD <[email protected]>", | ||
"license": "MIT", | ||
"repository": "github:gbicou/directus-extension-tiptap", | ||
"directus:extension": { | ||
"type": "interface", | ||
"path": "dist/index.js", | ||
"source": "src/index.ts", | ||
"host": "^9.23.4" | ||
"host": "^9.23.4", | ||
"type": "bundle", | ||
"path": { | ||
"app": "dist/app.js", | ||
"api": "dist/api.js" | ||
}, | ||
"entries": [ | ||
{ | ||
"type": "interface", | ||
"name": "directus-extension-tiptap-interface", | ||
"source": "src/interface.ts" | ||
}, | ||
{ | ||
"type": "display", | ||
"name": "directus-extension-tiptap-display", | ||
"source": "src/display.ts" | ||
} | ||
] | ||
}, | ||
"files": [ | ||
"dist" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineDisplay } from "@directus/extensions-sdk"; | ||
import TiptapDisplay from "./tiptap-display.vue"; | ||
|
||
export default defineDisplay({ | ||
id: "tiptap", | ||
name: "TipTap", | ||
icon: "text_fields", | ||
description: "Tip Tap content", | ||
component: TiptapDisplay, | ||
options: null, | ||
types: ["json", "text"], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<template> | ||
<div>{{ text }}</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed } from "vue"; | ||
import type { TypeType, ValueType } from "./types"; | ||
import { generateText } from "@tiptap/core"; | ||
import StarterKit from "@tiptap/starter-kit"; | ||
import Underline from "@tiptap/extension-underline"; | ||
const props = withDefaults( | ||
defineProps<{ | ||
value: ValueType | null; | ||
type: TypeType; | ||
}>(), | ||
{ value: null } | ||
); | ||
const text = computed(() => { | ||
if (props.type === "json") { | ||
return generateText(props.value, [StarterKit, Underline]); | ||
} | ||
return props.value; | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import type { HTMLContent, JSONContent } from "@tiptap/vue-3"; | ||
|
||
export type TypeType = "json" | "text"; | ||
export type ValueType = JSONContent | HTMLContent; |