refactor: fix auto import confliction

zio/stable
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) { if (matchUser) {
const [, server, username] = matchUser const [, server, username] = matchUser
const handle = `${username}@${server.replace(/(.+\.)(.+\..+)/, '$2')}` 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) 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 { Plugin } from 'prosemirror-state'
import type { Ref } from 'vue' import type { Ref } from 'vue'
import { HashtagSuggestion, MentionSuggestion } from './tiptap/suggestion' import { TiptapEmojiSuggestion, TiptapHashtagSuggestion, TiptapMentionSuggestion } from './tiptap/suggestion'
import { CodeBlockShiki } from './tiptap/shiki' import { TiptapPluginCodeBlockShiki } from './tiptap/shiki'
import { CustomEmoji } from './tiptap/custom-emoji' import { TiptapPluginCustomEmoji } from './tiptap/custom-emoji'
import { Emoji } from './tiptap/emoji' import { TiptapPluginEmoji } from './tiptap/emoji'
export interface UseTiptapOptions { export interface UseTiptapOptions {
content: Ref<string> content: Ref<string>
@ -43,30 +43,30 @@ export function useTiptap(options: UseTiptapOptions) {
Italic, Italic,
Code, Code,
Text, Text,
Emoji, TiptapPluginEmoji,
CustomEmoji.configure({ TiptapPluginCustomEmoji.configure({
inline: true, inline: true,
HTMLAttributes: { HTMLAttributes: {
class: 'custom-emoji', class: 'custom-emoji',
}, },
}), }),
Mention.configure({ Mention.configure({
suggestion: MentionSuggestion, suggestion: TiptapMentionSuggestion,
}), }),
Mention Mention
.extend({ name: 'hashtag' }) .extend({ name: 'hashtag' })
.configure({ .configure({
suggestion: HashtagSuggestion, suggestion: TiptapHashtagSuggestion,
}), }),
Mention Mention
.extend({ name: 'emoji' }) .extend({ name: 'emoji' })
.configure({ .configure({
suggestion: EmojiSuggestion, suggestion: TiptapEmojiSuggestion,
}), }),
Placeholder.configure({ Placeholder.configure({
placeholder: () => placeholder.value!, placeholder: () => placeholder.value!,
}), }),
CodeBlockShiki, TiptapPluginCodeBlockShiki,
History.configure({ History.configure({
depth: 10, 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', name: 'custom-emoji',
addOptions() { 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', name: 'em-emoji',
inline: () => true, inline: () => true,

View File

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

View File

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