Move editor stuff to its own module
This commit is contained in:
@@ -16,7 +16,7 @@ export interface LinkAttributes {
|
||||
|
||||
declare module "@tiptap/core" {
|
||||
interface Commands<ReturnType> {
|
||||
link: {
|
||||
inlineLink: {
|
||||
insertLink: (options: {url: string}) => ReturnType
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ declare module "@tiptap/core" {
|
||||
|
||||
export const LinkExtension = Node.create({
|
||||
atom: true,
|
||||
name: "link",
|
||||
name: "inlineLink",
|
||||
group: "inline",
|
||||
inline: true,
|
||||
selectable: true,
|
||||
@@ -74,6 +74,7 @@ export const LinkExtension = Node.create({
|
||||
const matches = []
|
||||
|
||||
for (const match of text.matchAll(LINK_REGEX)) {
|
||||
console.log(text, match)
|
||||
try {
|
||||
matches.push(createPasteRuleMatch(match, {url: match[0]}))
|
||||
} catch (e) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import type {Node as ProsemirrorNode} from "@tiptap/pm/model"
|
||||
import type {MarkdownSerializerState} from "prosemirror-markdown"
|
||||
import {createPasteRuleMatch} from "@lib/tiptap/util"
|
||||
|
||||
export const TOPIC_REGEX = /(#[^\s]+)/g
|
||||
export const TOPIC_REGEX = /(?:^|\s)(#[^\s]+)/g
|
||||
|
||||
export interface TopicAttributes {
|
||||
name: string
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import type {JSONContent, PasteRuleMatch} from "@tiptap/core"
|
||||
|
||||
export const asInline = (extend: Record<string, any>) => ({
|
||||
inline: true,
|
||||
group: "inline",
|
||||
...extend,
|
||||
})
|
||||
|
||||
export const createPasteRuleMatch = <T extends Record<string, unknown>>(
|
||||
match: RegExpMatchArray,
|
||||
data: T,
|
||||
|
||||
Reference in New Issue
Block a user