add basic text style mark
This commit is contained in:
47
docs/src/demos/Marks/TextStyle/index.vue
Normal file
47
docs/src/demos/Marks/TextStyle/index.vue
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<template>
|
||||||
|
<div v-if="editor">
|
||||||
|
<editor-content :editor="editor" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { Editor } from '@tiptap/core'
|
||||||
|
import { EditorContent } from '@tiptap/vue'
|
||||||
|
import Document from '@tiptap/extension-document'
|
||||||
|
import Paragraph from '@tiptap/extension-paragraph'
|
||||||
|
import Text from '@tiptap/extension-text'
|
||||||
|
import Heading from '@tiptap/extension-heading'
|
||||||
|
import TextStyle from '@tiptap/extension-text-style'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
EditorContent,
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
editor: null,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
this.editor = new Editor({
|
||||||
|
extensions: [
|
||||||
|
Document(),
|
||||||
|
Paragraph(),
|
||||||
|
Text(),
|
||||||
|
Heading(),
|
||||||
|
TextStyle(),
|
||||||
|
],
|
||||||
|
content: `
|
||||||
|
<h2>Hello</h2>
|
||||||
|
<p>This is text.</p>
|
||||||
|
`,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
beforeDestroy() {
|
||||||
|
this.editor.destroy()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
16
docs/src/docPages/api/marks/text-style.md
Normal file
16
docs/src/docPages/api/marks/text-style.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Text Style
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
```bash
|
||||||
|
# With npm
|
||||||
|
npm install @tiptap/extension-text-style
|
||||||
|
|
||||||
|
# Or: With Yarn
|
||||||
|
yarn add @tiptap/extension-text-style
|
||||||
|
```
|
||||||
|
|
||||||
|
## Source code
|
||||||
|
[packages/extension-text-style/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-text-style/)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
<demo name="Marks/TextStyle" />
|
||||||
@@ -114,6 +114,9 @@
|
|||||||
link: /api/marks/link
|
link: /api/marks/link
|
||||||
- title: Strike
|
- title: Strike
|
||||||
link: /api/marks/strike
|
link: /api/marks/strike
|
||||||
|
- title: Text Style
|
||||||
|
link: /api/marks/text-style
|
||||||
|
draft: true
|
||||||
- title: Underline
|
- title: Underline
|
||||||
link: /api/marks/underline
|
link: /api/marks/underline
|
||||||
- title: Extensions
|
- title: Extensions
|
||||||
|
|||||||
25
packages/extension-text-style/index.ts
Normal file
25
packages/extension-text-style/index.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { createMark } from '@tiptap/core'
|
||||||
|
|
||||||
|
const TextStyle = createMark({
|
||||||
|
name: 'textStyle',
|
||||||
|
|
||||||
|
parseHTML() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
tag: 'span',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
renderHTML({ attributes }) {
|
||||||
|
return ['span', attributes, 0]
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
export default TextStyle
|
||||||
|
|
||||||
|
declare module '@tiptap/core/src/Editor' {
|
||||||
|
interface AllExtensions {
|
||||||
|
TextStyle: typeof TextStyle,
|
||||||
|
}
|
||||||
|
}
|
||||||
17
packages/extension-text-style/package.json
Normal file
17
packages/extension-text-style/package.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "@tiptap/extension-text-style",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"source": "index.ts",
|
||||||
|
"main": "dist/tiptap-extension-text-style.js",
|
||||||
|
"umd:main": "dist/tiptap-extension-text-style.umd.js",
|
||||||
|
"module": "dist/tiptap-extension-text-style.mjs",
|
||||||
|
"unpkg": "dist/tiptap-extension-text-style.js",
|
||||||
|
"jsdelivr": "dist/tiptap-extension-text-style.js",
|
||||||
|
"files": [
|
||||||
|
"src",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"peerDependencies": {
|
||||||
|
"@tiptap/core": "2.x"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user