tiptap 中文文档

Tiptap Dropcursor 拖动光标扩展

Tiptap Dropcursor 扩展,当你在编辑器里面拖拽一个对象比如图片时,它显示一个光标要拖拽到的位置。

Install 安装

npm install @tiptap/extension-dropcursor

Settings 配置

color 光栅Dropcursor的颜色。

Dropcursor.configure({
  color: '#ff0000',
})

width 光栅Dropcursor的宽度

Dropcursor.configure({
  width: 2,
})

class 自定义样式

Dropcursor.configure({
  class: 'my-custom-class',
})

源代码

dropcursor 源代码

在线例子

vue 在线例子

Dropcursor 例子

  • Vue 例子

  • React 例子

  • React CSS

<template>
  <editor-content :editor="editor" />
</template>
<script>
import Document from '@tiptap/extension-document'
import Dropcursor from '@tiptap/extension-dropcursor'
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,
        Dropcursor,
      ],
      content: `
        <p>拖动下面的图片试试看</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 Dropcursor from '@tiptap/extension-dropcursor'
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, Dropcursor],
    content: `
        <p>拖动图片试试看</p>
        <img src="https://www.itxst.com/img/logov31.png" />
      `,
  })

  return <EditorContent editor={editor} />
}
/* Basic editor styles */
.ProseMirror {
  > * + * {
    margin-top: 0.75em;
  }

  img {
    height: auto;
    max-width: 100%;
  }
}
Catalog
快速入门 Guide 向导 API 列表 tiptap 方法 tiptap 属性 titap 配置 commands 命令 nodes 节点 marks 标记 extensions 扩展 Color 颜色扩展 Bubble Menu 气泡菜单 CharacterCount 文字统计 Collaboration 实时协作 CollaborationCursor 协作光标 Dropcursor 拖动光标 Floating Menu 浮动菜单 Focus 焦点扩展 FontFamily 字体 Gapcursor 空光标 History 历史记录 Placeholder 占位符 StarterKit 核心扩展 TextAlign 对齐方式 Typography 特殊符号