refactor: fix auto import confliction

This commit is contained in:
Anthony Fu 2023-01-16 12:40:47 +01:00
parent 00379e23aa
commit 8bb6ee7639
6 changed files with 18 additions and 18 deletions

View file

@ -460,7 +460,7 @@ function transformMentionLink(node: Node): string | Node | (string | Node)[] | n
if (matchUser) {
const [, server, username] = matchUser
const handle = `${username}@${server.replace(/(.+\.)(.+\..+)/, '$2')}`
// convert to TipTap mention node
// convert to Tiptap mention node
return h('span', { 'data-type': 'mention', 'data-id': handle }, handle)
}
}

View file

@ -12,10 +12,10 @@ import History from '@tiptap/extension-history'
import { Plugin } from 'prosemirror-state'
import type { Ref } from 'vue'
import { HashtagSuggestion, MentionSuggestion } from './tiptap/suggestion'
import { CodeBlockShiki } from './tiptap/shiki'
import { CustomEmoji } from './tiptap/custom-emoji'
import { Emoji } from './tiptap/emoji'
import { TiptapEmojiSuggestion, TiptapHashtagSuggestion, TiptapMentionSuggestion } from './tiptap/suggestion'
import { TiptapPluginCodeBlockShiki } from './tiptap/shiki'
import { TiptapPluginCustomEmoji } from './tiptap/custom-emoji'
import { TiptapPluginEmoji } from './tiptap/emoji'
export interface UseTiptapOptions {
content: Ref<string>
@ -43,30 +43,30 @@ export function useTiptap(options: UseTiptapOptions) {
Italic,
Code,
Text,
Emoji,
CustomEmoji.configure({
TiptapPluginEmoji,
TiptapPluginCustomEmoji.configure({
inline: true,
HTMLAttributes: {
class: 'custom-emoji',
},
}),
Mention.configure({
suggestion: MentionSuggestion,
suggestion: TiptapMentionSuggestion,
}),
Mention
.extend({ name: 'hashtag' })
.configure({
suggestion: HashtagSuggestion,
suggestion: TiptapHashtagSuggestion,
}),
Mention
.extend({ name: 'emoji' })
.configure({
suggestion: EmojiSuggestion,
suggestion: TiptapEmojiSuggestion,
}),
Placeholder.configure({
placeholder: () => placeholder.value!,
}),
CodeBlockShiki,
TiptapPluginCodeBlockShiki,
History.configure({
depth: 10,
}),

View file

@ -25,9 +25,9 @@ declare module '@tiptap/core' {
}
}
export const inputRegex = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/
const inputRegex = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/
export const CustomEmoji = Node.create<EmojiOptions>({
export const TiptapPluginCustomEmoji = Node.create<EmojiOptions>({
name: 'custom-emoji',
addOptions() {

View file

@ -35,7 +35,7 @@ const createEmojiRule = <NR extends typeof nodeInputRule | typeof nodePasteRule>
]
}
export const Emoji = Node.create({
export const TiptapPluginEmoji = Node.create({
name: 'em-emoji',
inline: () => true,

View file

@ -12,7 +12,7 @@ export interface CodeBlockShikiOptions extends CodeBlockOptions {
defaultLanguage: string | null | undefined
}
export const CodeBlockShiki = CodeBlock.extend<CodeBlockShikiOptions>({
export const TiptapPluginCodeBlockShiki = CodeBlock.extend<CodeBlockShikiOptions>({
addOptions() {
return {
...this.parent?.(),

View file

@ -16,7 +16,7 @@ export { Emoji }
export type CustomEmoji = (mastodon.v1.CustomEmoji & { custom: true })
export const isCustomEmoji = (emoji: CustomEmoji | Emoji): emoji is CustomEmoji => !!(emoji as CustomEmoji).custom
export const MentionSuggestion: Partial<SuggestionOptions> = {
export const TiptapMentionSuggestion: Partial<SuggestionOptions> = {
pluginKey: new PluginKey('mention'),
char: '@',
async items({ query }) {
@ -29,7 +29,7 @@ export const MentionSuggestion: Partial<SuggestionOptions> = {
render: createSuggestionRenderer(TiptapMentionList),
}
export const HashtagSuggestion: Partial<SuggestionOptions> = {
export const TiptapHashtagSuggestion: Partial<SuggestionOptions> = {
pluginKey: new PluginKey('hashtag'),
char: '#',
async items({ query }) {
@ -48,7 +48,7 @@ export const HashtagSuggestion: Partial<SuggestionOptions> = {
render: createSuggestionRenderer(TiptapHashtagList),
}
export const EmojiSuggestion: Partial<SuggestionOptions> = {
export const TiptapEmojiSuggestion: Partial<SuggestionOptions> = {
pluginKey: new PluginKey('emoji'),
char: ':',
async items({ query }): Promise<(CustomEmoji | Emoji)[]> {