mirror of https://github.com/fantasticit/think.git
tiptap: update node input rule
parent
db53cc576c
commit
1541a6acb0
|
@ -72,7 +72,7 @@ export const Callout = Node.create({
|
|||
addInputRules() {
|
||||
return [
|
||||
wrappingInputRule({
|
||||
find: /^:::callout $/,
|
||||
find: /^\$callout $/,
|
||||
type: this.type,
|
||||
getAttributes: (match) => {
|
||||
return { type: match[1] };
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { mergeAttributes, Node } from '@tiptap/core';
|
||||
import { mergeAttributes, Node, nodeInputRule } from '@tiptap/core';
|
||||
import { ReactNodeViewRenderer } from '@tiptap/react';
|
||||
import { CountdownWrapper } from 'tiptap/core/wrappers/countdown';
|
||||
import { getDatasetAttribute } from 'tiptap/prose-utils';
|
||||
|
@ -77,6 +77,18 @@ export const Countdown = Node.create({
|
|||
};
|
||||
},
|
||||
|
||||
addInputRules() {
|
||||
return [
|
||||
nodeInputRule({
|
||||
find: /^\$countdown $/,
|
||||
type: this.type,
|
||||
getAttributes: () => {
|
||||
return { width: '100%' };
|
||||
},
|
||||
}),
|
||||
];
|
||||
},
|
||||
|
||||
addNodeView() {
|
||||
return ReactNodeViewRenderer(CountdownWrapper);
|
||||
},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core';
|
||||
import { mergeAttributes, Node } from '@tiptap/core';
|
||||
import { ReactNodeViewRenderer } from '@tiptap/react';
|
||||
import { DocumentChildrenWrapper } from 'tiptap/core/wrappers/document-children';
|
||||
import { getDatasetAttribute } from 'tiptap/prose-utils';
|
||||
|
@ -11,8 +11,6 @@ declare module '@tiptap/core' {
|
|||
}
|
||||
}
|
||||
|
||||
export const DocumentChildrenInputRegex = /^documentChildren\$$/;
|
||||
|
||||
export const DocumentChildren = Node.create({
|
||||
name: 'documentChildren',
|
||||
group: 'block',
|
||||
|
@ -64,15 +62,6 @@ export const DocumentChildren = Node.create({
|
|||
};
|
||||
},
|
||||
|
||||
addInputRules() {
|
||||
return [
|
||||
wrappingInputRule({
|
||||
find: DocumentChildrenInputRegex,
|
||||
type: this.type,
|
||||
}),
|
||||
];
|
||||
},
|
||||
|
||||
addNodeView() {
|
||||
return ReactNodeViewRenderer(DocumentChildrenWrapper);
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { IUser } from '@think/domains';
|
||||
import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core';
|
||||
import { mergeAttributes, Node } from '@tiptap/core';
|
||||
import { ReactNodeViewRenderer } from '@tiptap/react';
|
||||
import { DocumentReferenceWrapper } from 'tiptap/core/wrappers/document-reference';
|
||||
import { getDatasetAttribute } from 'tiptap/prose-utils';
|
||||
|
@ -17,8 +17,6 @@ declare module '@tiptap/core' {
|
|||
}
|
||||
}
|
||||
|
||||
export const DocumentReferenceInputRegex = /^documentReference\$$/;
|
||||
|
||||
export const DocumentReference = Node.create({
|
||||
name: 'documentReference',
|
||||
group: 'block',
|
||||
|
@ -80,15 +78,6 @@ export const DocumentReference = Node.create({
|
|||
};
|
||||
},
|
||||
|
||||
addInputRules() {
|
||||
return [
|
||||
wrappingInputRule({
|
||||
find: DocumentReferenceInputRegex,
|
||||
type: this.type,
|
||||
}),
|
||||
];
|
||||
},
|
||||
|
||||
addNodeView() {
|
||||
return ReactNodeViewRenderer(DocumentReferenceWrapper);
|
||||
},
|
||||
|
|
|
@ -106,8 +106,8 @@ export const Flow = Node.create({
|
|||
nodeInputRule({
|
||||
find: /^\$flow $/,
|
||||
type: this.type,
|
||||
getAttributes: (match) => {
|
||||
return { type: match[1] };
|
||||
getAttributes: () => {
|
||||
return { width: '100%' };
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { IUser } from '@think/domains';
|
||||
import { mergeAttributes, Node } from '@tiptap/core';
|
||||
import { mergeAttributes, Node, nodeInputRule } from '@tiptap/core';
|
||||
import { ReactNodeViewRenderer } from '@tiptap/react';
|
||||
import { IframeWrapper } from 'tiptap/core/wrappers/iframe';
|
||||
import { getDatasetAttribute } from 'tiptap/prose-utils';
|
||||
|
@ -97,6 +97,18 @@ export const Iframe = Node.create({
|
|||
};
|
||||
},
|
||||
|
||||
addInputRules() {
|
||||
return [
|
||||
nodeInputRule({
|
||||
find: /^\$iframe $/,
|
||||
type: this.type,
|
||||
getAttributes: () => {
|
||||
return { width: '100%' };
|
||||
},
|
||||
}),
|
||||
];
|
||||
},
|
||||
|
||||
addNodeView() {
|
||||
return ReactNodeViewRenderer(IframeWrapper);
|
||||
},
|
||||
|
|
|
@ -17,8 +17,6 @@ declare module '@tiptap/core' {
|
|||
}
|
||||
}
|
||||
|
||||
export const KatexInputRegex = /^\$\$(.+)?\$\$$/;
|
||||
|
||||
export const Katex = Node.create({
|
||||
name: 'katex',
|
||||
group: 'block',
|
||||
|
@ -74,11 +72,8 @@ export const Katex = Node.create({
|
|||
addInputRules() {
|
||||
return [
|
||||
nodeInputRule({
|
||||
find: KatexInputRegex,
|
||||
find: /^\$katex $/,
|
||||
type: this.type,
|
||||
getAttributes: (match) => {
|
||||
return { text: match[1] };
|
||||
},
|
||||
}),
|
||||
];
|
||||
},
|
||||
|
|
|
@ -95,6 +95,7 @@ export const Mind = Node.create({
|
|||
|
||||
const { selection } = editor.state;
|
||||
const pos = selection.$head;
|
||||
|
||||
return chain()
|
||||
.insertContentAt(pos.after(), [
|
||||
{
|
||||
|
@ -116,8 +117,8 @@ export const Mind = Node.create({
|
|||
nodeInputRule({
|
||||
find: /^\$mind $/,
|
||||
type: this.type,
|
||||
getAttributes: (match) => {
|
||||
return { type: match[1] };
|
||||
getAttributes: () => {
|
||||
return { width: '100%' };
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue