Tiptap Gapcursor 空光标扩展,当你选择类似图片之类的节点后面又没有节点时,该插件会插入一个空光标。
npm install @tiptap/extension-gapcursor
Vue 例子
React 例子
<template>
<editor-content :editor="editor" />
</template>
<script>
import Document from '@tiptap/extension-document'
import Gapcursor from '@tiptap/extension-gapcursor'
import Image from '@tiptap/extension-image'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
import { Editor, EditorContent } from '@tiptap/vue-3'
export default {
components: {
EditorContent,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
extensions: [
Document,
Paragraph,
Text,
Image,
Gapcursor,
],
content: `
<p>试着用方向键移动光标到图像后面!您应该在图像下方看到一个水平闪烁的光标。这是gap光标。</p>
<img src="https://www.itxst.com/img/logov31.png" />
`,
})
},
beforeUnmount() {
this.editor.destroy()
},
}
</script>
<style>
/* Basic editor styles */
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
img {
max-width: 100%;
height: auto;
}
}
</style>
import './styles.scss'
import Document from '@tiptap/extension-document'
import Gapcursor from '@tiptap/extension-gapcursor'
import Image from '@tiptap/extension-image'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
import { EditorContent, useEditor } from '@tiptap/react'
import React from 'react'
export default () => {
const editor = useEditor({
extensions: [Document, Paragraph, Text, Image, Gapcursor],
content: `
<p>试着用方向键移动光标到图像后面!您应该在图像下方看到一个水平闪烁的光标。这是gap光标。</p>
<img src="https://www.itxst.com/img/logov31.png" />
`,
})
return <EditorContent editor={editor} />
}