daisy-tiptap-test 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +441 -0
- package/dist/components/AddLinkButton.vue.d.ts +30 -0
- package/dist/components/AddLinkButton.vue.js +1 -0
- package/dist/components/BubbleMenu.vue.d.ts +25 -0
- package/dist/components/BubbleMenu.vue.js +1 -0
- package/dist/components/ColorDropdown.vue.d.ts +34 -0
- package/dist/components/ColorDropdown.vue.js +1 -0
- package/dist/components/DaisyTiptap.vue.d.ts +584 -0
- package/dist/components/DaisyTiptap.vue.js +1 -0
- package/dist/components/EditImageButton.vue.d.ts +24 -0
- package/dist/components/EditImageButton.vue.js +1 -0
- package/dist/components/EditLinkDialog.vue.d.ts +33 -0
- package/dist/components/EditLinkDialog.vue.js +1 -0
- package/dist/components/EmojiDropdown.vue.d.ts +33 -0
- package/dist/components/EmojiDropdown.vue.js +1 -0
- package/dist/components/FloatingMenu.vue.d.ts +24 -0
- package/dist/components/FloatingMenu.vue.js +1 -0
- package/dist/components/FontFamilyDropdown.vue.d.ts +30 -0
- package/dist/components/FontFamilyDropdown.vue.js +1 -0
- package/dist/components/FontSizeDropdown.vue.d.ts +30 -0
- package/dist/components/FontSizeDropdown.vue.js +1 -0
- package/dist/components/HeadingDropdown.vue.d.ts +32 -0
- package/dist/components/HeadingDropdown.vue.js +1 -0
- package/dist/components/Icon.vue.d.ts +12 -0
- package/dist/components/Icon.vue.js +1 -0
- package/dist/components/ImageBubbleMenu.vue.d.ts +23 -0
- package/dist/components/ImageBubbleMenu.vue.js +1 -0
- package/dist/components/ImageView.vue.d.ts +53 -0
- package/dist/components/ImageView.vue.js +1 -0
- package/dist/components/InsertImageButton.vue.d.ts +13 -0
- package/dist/components/InsertImageButton.vue.js +1 -0
- package/dist/components/LinkBubbleMenu.vue.d.ts +30 -0
- package/dist/components/LinkBubbleMenu.vue.js +1 -0
- package/dist/components/MentionView.vue.d.ts +34 -0
- package/dist/components/MentionView.vue.js +1 -0
- package/dist/components/MenuBar.vue.d.ts +24 -0
- package/dist/components/MenuBar.vue.js +1 -0
- package/dist/components/TableBubbleMenu.vue.d.ts +23 -0
- package/dist/components/TableBubbleMenu.vue.js +1 -0
- package/dist/components/TableDropdown.vue.d.ts +30 -0
- package/dist/components/TableDropdown.vue.js +1 -0
- package/dist/components/TaskItemView.vue.d.ts +20 -0
- package/dist/components/TaskItemView.vue.js +1 -0
- package/dist/components/UniversalToggleButton.vue.d.ts +39 -0
- package/dist/components/UniversalToggleButton.vue.js +1 -0
- package/dist/components/index.d.ts +51 -0
- package/dist/components/index.js +1 -0
- package/dist/extensions/blockquote.d.ts +25 -0
- package/dist/extensions/blockquote.js +1 -0
- package/dist/extensions/bold.d.ts +28 -0
- package/dist/extensions/bold.js +1 -0
- package/dist/extensions/bullet-list.d.ts +20 -0
- package/dist/extensions/bullet-list.js +1 -0
- package/dist/extensions/character-count.d.ts +28 -0
- package/dist/extensions/character-count.js +1 -0
- package/dist/extensions/code-block-lowlight.d.ts +8 -0
- package/dist/extensions/code-block-lowlight.js +1 -0
- package/dist/extensions/code-block.d.ts +43 -0
- package/dist/extensions/code-block.js +4 -0
- package/dist/extensions/code.d.ts +26 -0
- package/dist/extensions/code.js +1 -0
- package/dist/extensions/color.d.ts +21 -0
- package/dist/extensions/color.js +1 -0
- package/dist/extensions/document.d.ts +10 -0
- package/dist/extensions/document.js +1 -0
- package/dist/extensions/dropcursor.d.ts +7 -0
- package/dist/extensions/dropcursor.js +1 -0
- package/dist/extensions/emoji.d.ts +17 -0
- package/dist/extensions/emoji.js +1 -0
- package/dist/extensions/focus.d.ts +6 -0
- package/dist/extensions/focus.js +1 -0
- package/dist/extensions/font-family.d.ts +23 -0
- package/dist/extensions/font-family.js +1 -0
- package/dist/extensions/font-size.d.ts +20 -0
- package/dist/extensions/font-size.js +1 -0
- package/dist/extensions/gapcursor.d.ts +15 -0
- package/dist/extensions/gapcursor.js +1 -0
- package/dist/extensions/hard-break.d.ts +17 -0
- package/dist/extensions/hard-break.js +2 -0
- package/dist/extensions/heading.d.ts +26 -0
- package/dist/extensions/heading.js +1 -0
- package/dist/extensions/highlight.d.ts +32 -0
- package/dist/extensions/highlight.js +1 -0
- package/dist/extensions/history.d.ts +21 -0
- package/dist/extensions/history.js +1 -0
- package/dist/extensions/horizontal-rule.d.ts +16 -0
- package/dist/extensions/horizontal-rule.js +1 -0
- package/dist/extensions/image.d.ts +25 -0
- package/dist/extensions/image.js +1 -0
- package/dist/extensions/indent.d.ts +21 -0
- package/dist/extensions/indent.js +1 -0
- package/dist/extensions/index.d.ts +104 -0
- package/dist/extensions/index.js +1 -0
- package/dist/extensions/italic.d.ts +28 -0
- package/dist/extensions/italic.js +1 -0
- package/dist/extensions/link.d.ts +63 -0
- package/dist/extensions/link.js +1 -0
- package/dist/extensions/list-item.d.ts +7 -0
- package/dist/extensions/list-item.js +1 -0
- package/dist/extensions/mention.d.ts +14 -0
- package/dist/extensions/mention.js +1 -0
- package/dist/extensions/ordered-list.d.ts +20 -0
- package/dist/extensions/ordered-list.js +1 -0
- package/dist/extensions/paragraph.d.ts +15 -0
- package/dist/extensions/paragraph.js +1 -0
- package/dist/extensions/placeholder.d.ts +16 -0
- package/dist/extensions/placeholder.js +1 -0
- package/dist/extensions/strike.d.ts +26 -0
- package/dist/extensions/strike.js +1 -0
- package/dist/extensions/subscript.d.ts +24 -0
- package/dist/extensions/subscript.js +1 -0
- package/dist/extensions/superscript.d.ts +24 -0
- package/dist/extensions/superscript.js +1 -0
- package/dist/extensions/table-cell.d.ts +5 -0
- package/dist/extensions/table-cell.js +1 -0
- package/dist/extensions/table-header.d.ts +5 -0
- package/dist/extensions/table-header.js +1 -0
- package/dist/extensions/table-row.d.ts +5 -0
- package/dist/extensions/table-row.js +1 -0
- package/dist/extensions/table.d.ts +56 -0
- package/dist/extensions/table.js +1 -0
- package/dist/extensions/tableView.d.ts +17 -0
- package/dist/extensions/tableView.js +1 -0
- package/dist/extensions/task-item.d.ts +10 -0
- package/dist/extensions/task-item.js +1 -0
- package/dist/extensions/task-list.d.ts +17 -0
- package/dist/extensions/task-list.js +1 -0
- package/dist/extensions/text-align.d.ts +22 -0
- package/dist/extensions/text-align.js +1 -0
- package/dist/extensions/text-style.d.ts +16 -0
- package/dist/extensions/text-style.js +1 -0
- package/dist/extensions/text.d.ts +2 -0
- package/dist/extensions/text.js +1 -0
- package/dist/extensions/typography.d.ts +48 -0
- package/dist/extensions/typography.js +1 -0
- package/dist/extensions/underline.d.ts +24 -0
- package/dist/extensions/underline.js +1 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useCharacterCount.d.ts +5 -0
- package/dist/hooks/useCharacterCount.js +1 -0
- package/dist/hooks/useCodeView.d.ts +6 -0
- package/dist/hooks/useCodeView.js +1 -0
- package/dist/hooks/useEditorStyle.d.ts +7 -0
- package/dist/hooks/useEditorStyle.js +1 -0
- package/dist/i18n/index.d.ts +4 -0
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/locales/en/index.d.ts +237 -0
- package/dist/i18n/locales/en/index.js +1 -0
- package/dist/i18n/locales/index.d.ts +3 -0
- package/dist/i18n/locales/index.js +1 -0
- package/dist/i18n/locales/zh/index.d.ts +237 -0
- package/dist/i18n/locales/zh/index.js +1 -0
- package/dist/i18n/locales/zh-tw/index.d.ts +237 -0
- package/dist/i18n/locales/zh-tw/index.js +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -0
- package/dist/plugin/autolink.d.ts +10 -0
- package/dist/plugin/autolink.js +1 -0
- package/dist/plugin/clickHandler.d.ts +7 -0
- package/dist/plugin/clickHandler.js +1 -0
- package/dist/plugin/emojis.d.ts +1 -0
- package/dist/plugin/emojis.js +1 -0
- package/dist/plugin/icons.d.ts +5 -0
- package/dist/plugin/icons.js +1 -0
- package/dist/plugin/index.d.ts +7 -0
- package/dist/plugin/index.js +1 -0
- package/dist/plugin/lowlight.d.ts +6 -0
- package/dist/plugin/lowlight.js +1 -0
- package/dist/plugin/pasteHandler.d.ts +9 -0
- package/dist/plugin/pasteHandler.js +1 -0
- package/dist/plugin/suggestion.d.ts +2 -0
- package/dist/plugin/suggestion.js +1 -0
- package/dist/utils/color.d.ts +2 -0
- package/dist/utils/color.js +1 -0
- package/dist/utils/constants.d.ts +24 -0
- package/dist/utils/constants.js +1 -0
- package/dist/utils/createCell.d.ts +2 -0
- package/dist/utils/createCell.js +1 -0
- package/dist/utils/createTable.d.ts +2 -0
- package/dist/utils/createTable.js +1 -0
- package/dist/utils/deleteTableWhenAllCellsSelected.d.ts +2 -0
- package/dist/utils/deleteTableWhenAllCellsSelected.js +1 -0
- package/dist/utils/fontFamily.d.ts +3 -0
- package/dist/utils/fontFamily.js +1 -0
- package/dist/utils/fontSize.d.ts +2 -0
- package/dist/utils/fontSize.js +1 -0
- package/dist/utils/getTableNodeTypes.d.ts +4 -0
- package/dist/utils/getTableNodeTypes.js +1 -0
- package/dist/utils/image.d.ts +14 -0
- package/dist/utils/image.js +1 -0
- package/dist/utils/indent.d.ts +12 -0
- package/dist/utils/indent.js +1 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/isCellSelection.d.ts +2 -0
- package/dist/utils/isCellSelection.js +1 -0
- package/dist/utils/shared.d.ts +20 -0
- package/dist/utils/shared.js +1 -0
- package/package.json +18 -0
- package/style.css +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as a}from"./Icon.vue.js";import{default as f}from"./UniversalToggleButton.vue.js";import{default as l}from"./AddLinkButton.vue.js";import{default as m}from"./InsertImageButton.vue.js";import{default as n}from"./EditImageButton.vue.js";import{default as x}from"./EditLinkDialog.vue.js";import{default as b}from"./BubbleMenu.vue.js";import{default as w}from"./FloatingMenu.vue.js";import{default as D}from"./ImageBubbleMenu.vue.js";import{default as M}from"./LinkBubbleMenu.vue.js";import{default as F}from"./TableBubbleMenu.vue.js";import{default as E}from"./ColorDropdown.vue.js";import{default as V}from"./EmojiDropdown.vue.js";import{default as j}from"./FontFamilyDropdown.vue.js";import{default as y}from"./FontSizeDropdown.vue.js";import{default as A}from"./HeadingDropdown.vue.js";import{default as H}from"./TableDropdown.vue.js";import{default as U}from"./MentionView.vue.js";import{default as q}from"./ImageView.vue.js";import{default as J}from"./TaskItemView.vue.js";import{default as N}from"./MenuBar.vue.js";import{default as P}from"./DaisyTiptap.vue.js";/* empty css */export{l as AddLinkButton,b as BubbleMenu,E as ColorDropdown,n as EditImageButton,x as EditLinkDialog,V as EmojiDropdown,w as FloatingMenu,j as FontFamilyDropdown,y as FontSizeDropdown,A as HeadingDropdown,a as Icon,D as ImageBubbleMenu,q as ImageView,m as InsertImageButton,M as LinkBubbleMenu,U as MentionView,N as MenuBar,F as TableBubbleMenu,H as TableDropdown,J as TaskItemView,f as UniversalToggleButton,P as default};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
export interface BlockquoteOptions {
|
|
3
|
+
HTMLAttributes: Record<string, any>;
|
|
4
|
+
bubble?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare module '@tiptap/core' {
|
|
7
|
+
interface Commands<ReturnType> {
|
|
8
|
+
blockQuote: {
|
|
9
|
+
/**
|
|
10
|
+
* Set a blockquote node
|
|
11
|
+
*/
|
|
12
|
+
setBlockquote: () => ReturnType;
|
|
13
|
+
/**
|
|
14
|
+
* Toggle a blockquote node
|
|
15
|
+
*/
|
|
16
|
+
toggleBlockquote: () => ReturnType;
|
|
17
|
+
/**
|
|
18
|
+
* Unset a blockquote node
|
|
19
|
+
*/
|
|
20
|
+
unsetBlockquote: () => ReturnType;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export declare const inputRegex: RegExp;
|
|
25
|
+
export declare const Blockquote: Node<BlockquoteOptions, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Node as e,mergeAttributes as r,wrappingInputRule as n}from"@tiptap/core";import{UniversalToggleButton as u}from"../components";const s=/^\s*>\s$/,c=e.create({name:"blockquote",addOptions(){return{HTMLAttributes:{},btn({editor:t,i18n:o}){return{component:u,componentProps:{toggle:()=>{t.commands.toggleBlockquote(),t.chain().focus().run()},isActive:t.isActive("blockquote"),icon:"block-quote",tooltip:o("editor.extensions.Blockquote.tooltip")}}}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",r(this.options.HTMLAttributes,t,{class:"border-l-primary shadow-xl pr-4 rounded-r-lg"}),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[n({find:s,type:this.type})]}});export{c as Blockquote,s as inputRegex};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Mark } from '@tiptap/core';
|
|
2
|
+
export interface BoldOptions {
|
|
3
|
+
HTMLAttributes: Record<string, any>;
|
|
4
|
+
bubble?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare module '@tiptap/core' {
|
|
7
|
+
interface Commands<ReturnType> {
|
|
8
|
+
bold: {
|
|
9
|
+
/**
|
|
10
|
+
* Set a bold mark
|
|
11
|
+
*/
|
|
12
|
+
setBold: () => ReturnType;
|
|
13
|
+
/**
|
|
14
|
+
* Toggle a bold mark
|
|
15
|
+
*/
|
|
16
|
+
toggleBold: () => ReturnType;
|
|
17
|
+
/**
|
|
18
|
+
* Unset a bold mark
|
|
19
|
+
*/
|
|
20
|
+
unsetBold: () => ReturnType;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export declare const starInputRegex: RegExp;
|
|
25
|
+
export declare const starPasteRegex: RegExp;
|
|
26
|
+
export declare const underscoreInputRegex: RegExp;
|
|
27
|
+
export declare const underscorePasteRegex: RegExp;
|
|
28
|
+
export declare const Bold: Mark<BoldOptions, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Mark as n,mergeAttributes as r,markInputRule as e,markPasteRule as o}from"@tiptap/core";import{UniversalToggleButton as d}from"../components";const i=/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))$/,a=/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))/g,l=/(?:^|\s)((?:__)((?:[^__]+))(?:__))$/,u=/(?:^|\s)((?:__)((?:[^__]+))(?:__))/g,m=n.create({name:"bold",addOptions(){return{HTMLAttributes:{},btn({editor:t,i18n:s}){return{component:d,componentProps:{toggle:()=>{t.commands.toggleBold(),t.chain().focus().run()},isActive:t.isActive("bold"),isDisabled:t.isActive("code"),icon:"bold",tooltip:s("editor.extensions.Bold.tooltip")}}}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",r(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[e({find:i,type:this.type}),e({find:l,type:this.type})]},addPasteRules(){return[o({find:a,type:this.type}),o({find:u,type:this.type})]}});export{m as Bold,i as starInputRegex,a as starPasteRegex,l as underscoreInputRegex,u as underscorePasteRegex};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
export interface BulletListOptions {
|
|
3
|
+
itemTypeName: string;
|
|
4
|
+
HTMLAttributes: Record<string, any>;
|
|
5
|
+
keepMarks: boolean;
|
|
6
|
+
keepAttributes: boolean;
|
|
7
|
+
bubble?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare module '@tiptap/core' {
|
|
10
|
+
interface Commands<ReturnType> {
|
|
11
|
+
bulletList: {
|
|
12
|
+
/**
|
|
13
|
+
* Toggle a bullet list
|
|
14
|
+
*/
|
|
15
|
+
toggleBulletList: () => ReturnType;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export declare const inputRegex: RegExp;
|
|
20
|
+
export declare const BulletList: Node<BulletListOptions, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Node as r,mergeAttributes as n,wrappingInputRule as i}from"@tiptap/core";import{ListItem as p,TextStyle as s}from".";import{UniversalToggleButton as u}from"../components";const o=/^\s*([-+*])\s$/,d=r.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1,btn({editor:t,i18n:e}){return{component:u,componentProps:{toggle:()=>{t.commands.toggleBulletList(),t.chain().focus().run()},isActive:t.isActive("bulletList"),icon:"bullet-list",tooltip:e("editor.extensions.BulletList.tooltip")}}}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",n(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(p.name,this.editor.getAttributes(s.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=i({find:o,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=i({find:o,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(s.name),editor:this.editor})),[t]}});export{d as BulletList,o as inputRegex};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
import { Node as ProseMirrorNode } from '@tiptap/pm/model';
|
|
3
|
+
export interface CharacterCountOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The maximum number of characters that should be allowed. Defaults to `0`.
|
|
6
|
+
*/
|
|
7
|
+
limit: number | null | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* The mode by which the size is calculated. Defaults to 'textSize'.
|
|
10
|
+
*/
|
|
11
|
+
mode: 'textSize' | 'nodeSize';
|
|
12
|
+
}
|
|
13
|
+
export interface CharacterCountStorage {
|
|
14
|
+
/**
|
|
15
|
+
* Get the number of characters for the current document.
|
|
16
|
+
*/
|
|
17
|
+
characters: (options?: {
|
|
18
|
+
node?: ProseMirrorNode;
|
|
19
|
+
mode?: 'textSize' | 'nodeSize';
|
|
20
|
+
}) => number;
|
|
21
|
+
/**
|
|
22
|
+
* Get the number of words for the current document.
|
|
23
|
+
*/
|
|
24
|
+
words: (options?: {
|
|
25
|
+
node?: ProseMirrorNode;
|
|
26
|
+
}) => number;
|
|
27
|
+
}
|
|
28
|
+
export declare const CharacterCount: Extension<CharacterCountOptions, CharacterCountStorage>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Extension as i}from"@tiptap/core";import{Plugin as u,PluginKey as h}from"@tiptap/pm/state";const x=i.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize"}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{const r=(e==null?void 0:e.node)||this.editor.state.doc;return((e==null?void 0:e.mode)||this.options.mode)==="textSize"?r.textBetween(0,r.content.size,void 0," ").length:r.nodeSize},this.storage.words=e=>{const r=(e==null?void 0:e.node)||this.editor.state.doc;return r.textBetween(0,r.content.size," "," ").split(" ").filter(o=>o!=="").length}},addProseMirrorPlugins(){return[new u({key:new h("characterCount"),filterTransaction:(e,r)=>{const t=this.options.limit;if(!e.docChanged||t===0||t===null||t===void 0)return!0;const n=this.storage.characters({node:r.doc}),o=this.storage.characters({node:e.doc});if(o<=t||n>t&&o>t&&o<=n)return!0;if(n>t&&o>t&&o>n||!e.getMeta("paste"))return!1;const s=e.selection.$head.pos,d=o-t,c=s-d,a=s;return e.deleteRange(c,a),!(this.storage.characters({node:e.doc})>t)}})]}});export{x as CharacterCount};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CodeBlockOptions } from './code-block';
|
|
2
|
+
export interface CodeBlockLowlightOptions extends CodeBlockOptions {
|
|
3
|
+
lowlight?: any;
|
|
4
|
+
theme?: string;
|
|
5
|
+
defaultLanguage?: string | null | undefined;
|
|
6
|
+
bubble?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const CodeBlockLowlight: import("@tiptap/core").Node<CodeBlockLowlightOptions, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mergeAttributes as n}from"@tiptap/core";import{createLowlight as r,all as i}from"lowlight";import{CB as s}from".";import{LowlightPlugin as l}from"../plugin";import{UniversalToggleButton as a}from"../components";const g=r(i),u=s.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),lowlight:g,theme:"",defaultLanguage:"plaintext",btn({editor:o,i18n:e}){return{component:a,componentProps:{toggle:()=>{o.commands.toggleCodeBlock(),o.chain().focus().run()},isActive:o.isActive("codeBlock"),icon:"code-block",tooltip:e("editor.extensions.CodeBlock.tooltip")}}}}},renderHTML({node:t,HTMLAttributes:o}){return["pre",n(this.options.HTMLAttributes,o,{class:`not-prose rounded-lg overflow-hidden theme-${this.options.theme}`}),["code",{style:"padding: 1rem",class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language+" hljs":"hljs"},0]]},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],l({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.insertContent(" ")}}});export{u as CodeBlockLowlight};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
export interface CodeBlockOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Adds a prefix to language classes that are applied to code tags.
|
|
5
|
+
* Defaults to `'language-'`.
|
|
6
|
+
*/
|
|
7
|
+
languageClassPrefix: string;
|
|
8
|
+
/**
|
|
9
|
+
* Define whether the node should be exited on triple enter.
|
|
10
|
+
* Defaults to `true`.
|
|
11
|
+
*/
|
|
12
|
+
exitOnTripleEnter: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Define whether the node should be exited on arrow down if there is no node after it.
|
|
15
|
+
* Defaults to `true`.
|
|
16
|
+
*/
|
|
17
|
+
exitOnArrowDown: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Custom HTML attributes that should be added to the rendered HTML tag.
|
|
20
|
+
*/
|
|
21
|
+
HTMLAttributes: Record<string, any>;
|
|
22
|
+
}
|
|
23
|
+
declare module '@tiptap/core' {
|
|
24
|
+
interface Commands<ReturnType> {
|
|
25
|
+
codeBlock: {
|
|
26
|
+
/**
|
|
27
|
+
* Set a code block
|
|
28
|
+
*/
|
|
29
|
+
setCodeBlock: (attributes?: {
|
|
30
|
+
language: string;
|
|
31
|
+
}) => ReturnType;
|
|
32
|
+
/**
|
|
33
|
+
* Toggle a code block
|
|
34
|
+
*/
|
|
35
|
+
toggleCodeBlock: (attributes?: {
|
|
36
|
+
language: string;
|
|
37
|
+
}) => ReturnType;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export declare const backtickInputRegex: RegExp;
|
|
42
|
+
export declare const tildeInputRegex: RegExp;
|
|
43
|
+
export declare const CodeBlock: Node<CodeBlockOptions, any>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{Node as c,mergeAttributes as u,textblockTypeInputRule as l}from"@tiptap/core";import{Plugin as d,PluginKey as p,TextSelection as f}from"@tiptap/pm/state";const g=/^```([a-z]+)?[\s\n]$/,m=/^~~~([a-z]+)?[\s\n]$/,A=c.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:null,parseHTML:e=>{var o;const{languageClassPrefix:t}=this.options,r=[...((o=e.firstElementChild)==null?void 0:o.classList)||[]].filter(n=>n.startsWith(t)).map(n=>n.replace(t,""))[0];return r||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:e,HTMLAttributes:t}){return["pre",u(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:t}=this.editor.state.selection,a=t.pos===1;return!e||t.parent.type.name!==this.name?!1:a||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:t}=e,{selection:a}=t,{$from:s,empty:r}=a;if(!r||s.parent.type!==this.type)return!1;const o=s.parentOffset===s.parent.nodeSize-2,n=s.parent.textContent.endsWith(`
|
|
2
|
+
|
|
3
|
+
`);return!o||!n?!1:e.chain().command(({tr:i})=>(i.delete(s.pos-2,s.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:t}=e,{selection:a,doc:s}=t,{$from:r,empty:o}=a;if(!o||r.parent.type!==this.type||!(r.parentOffset===r.parent.nodeSize-2))return!1;const i=r.after();return i===void 0||s.nodeAt(i)?!1:e.commands.exitCode()}}},addInputRules(){return[l({find:g,type:this.type,getAttributes:e=>({language:e[1]})}),l({find:m,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new d({key:new p("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;const a=t.clipboardData.getData("text/plain"),s=t.clipboardData.getData("vscode-editor-data"),r=s?JSON.parse(s):void 0,o=r==null?void 0:r.mode;if(!a||!o)return!1;const{tr:n}=e.state;return n.replaceSelectionWith(this.type.create({language:o})),n.setSelection(f.near(n.doc.resolve(Math.max(0,n.selection.from-2)))),n.insertText(a.replace(/\r\n?/g,`
|
|
4
|
+
`)),n.setMeta("paste",!0),e.dispatch(n),!0}}})]}});export{A as CodeBlock,g as backtickInputRegex,m as tildeInputRegex};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Mark } from '@tiptap/core';
|
|
2
|
+
export interface CodeOptions {
|
|
3
|
+
HTMLAttributes: Record<string, any>;
|
|
4
|
+
bubble?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare module '@tiptap/core' {
|
|
7
|
+
interface Commands<ReturnType> {
|
|
8
|
+
code: {
|
|
9
|
+
/**
|
|
10
|
+
* Set a code mark
|
|
11
|
+
*/
|
|
12
|
+
setCode: () => ReturnType;
|
|
13
|
+
/**
|
|
14
|
+
* Toggle inline code
|
|
15
|
+
*/
|
|
16
|
+
toggleCode: () => ReturnType;
|
|
17
|
+
/**
|
|
18
|
+
* Unset a code mark
|
|
19
|
+
*/
|
|
20
|
+
unsetCode: () => ReturnType;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export declare const inputRegex: RegExp;
|
|
25
|
+
export declare const pasteRegex: RegExp;
|
|
26
|
+
export declare const Code: Mark<CodeOptions, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Mark as o,mergeAttributes as r,markInputRule as n,markPasteRule as s}from"@tiptap/core";import{UniversalToggleButton as d}from"../components";const a=/(?:^|\s)((?:`)((?:[^`]+))(?:`))$/,u=/(?:^|\s)((?:`)((?:[^`]+))(?:`))/g,p=o.create({name:"code",addOptions(){return{HTMLAttributes:{},btn({editor:e,i18n:t}){return{component:d,componentProps:{toggle:()=>{e.commands.toggleCode(),e.chain().focus().run()},isActive:e.isActive("code"),icon:"code",tooltip:t("editor.extensions.Code.tooltip")}}}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:e}){return["code",r(this.options.HTMLAttributes,e,{class:"not-prose badge badge-accent"}),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[n({find:a,type:this.type})]},addPasteRules(){return[s({find:u,type:this.type})]}});export{p as Code,a as inputRegex,u as pasteRegex};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
export interface ColorOptions {
|
|
3
|
+
types: string[];
|
|
4
|
+
colors: string[];
|
|
5
|
+
bubble?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare module '@tiptap/core' {
|
|
8
|
+
interface Commands<ReturnType> {
|
|
9
|
+
color: {
|
|
10
|
+
/**
|
|
11
|
+
* Set the text color
|
|
12
|
+
*/
|
|
13
|
+
setColor: (color: string) => ReturnType;
|
|
14
|
+
/**
|
|
15
|
+
* Unset the text color
|
|
16
|
+
*/
|
|
17
|
+
unsetColor: () => ReturnType;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export declare const Color: Extension<ColorOptions, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Extension as r}from"@tiptap/core";import{COLOR_SET as e}from"../utils";import{ColorDropdown as l}from"../components";const p=r.create({name:"color",addOptions(){return{types:["textStyle"],colors:e,btn({editor:o}){return{component:l,componentProps:{editor:o,icon:"color",type:"textStyle",tooltip:"TextColor",toggle:t=>{t&&t!==null?o.commands.setColor(t):o.commands.unsetColor(),o.chain().focus().run()}}}}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:o=>{var t;return(t=o.style.color)==null?void 0:t.replace(/['"]+/g,"")},renderHTML:o=>o.color?{style:`color: ${o.color}`}:{}}}}]},addCommands(){return{setColor:o=>({chain:t})=>t().setMark("textStyle",{color:o}).run(),unsetColor:()=>({chain:o})=>o().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}});export{p as Color};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Node as t}from"@tiptap/core";const r=t.create({name:"doc",topNode:!0,content:"block+",addCommands(){var o;return{...(o=this.parent)==null?void 0:o.call(this),alert:e=>{console.log(e)}}}});export{r as Document,r as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Extension as r}from"@tiptap/core";import{dropCursor as o}from"@tiptap/pm/dropcursor";const i=r.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[o(this.options)]}});export{i as Dropcursor};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
export interface MentionOptions {
|
|
3
|
+
HTMLAttributes: Record<string, any>;
|
|
4
|
+
emojis: string[];
|
|
5
|
+
bubble?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare module '@tiptap/core' {
|
|
8
|
+
interface Commands<ReturnType> {
|
|
9
|
+
emoji: {
|
|
10
|
+
/**
|
|
11
|
+
* Add an image
|
|
12
|
+
*/
|
|
13
|
+
setEmoji: (emoji: string) => ReturnType;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export declare const Emoji: Node<MentionOptions, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Node as n,mergeAttributes as r}from"@tiptap/core";import{EmojiDropdown as i}from"../components";import{emojis as m}from"../plugin";const u=n.create({name:"emoji",addOptions(){return{HTMLAttributes:{},emojis:m,btn({editor:o,i18n:t}){return{component:i,componentProps:{editor:o,toggle:({emoji:e})=>{o.commands.setEmoji(e),o.chain().focus().run()},icon:"emoji",tooltip:t("editor.extensions.Emoji.tooltip")}}}}},group:"inline",inline:!0,addCommands(){return{setEmoji:o=>({chain:t})=>t().focus().insertContent(o).run()}},parseHTML(){return[{tag:`span[data-emoji="${this.name}"]`}]},renderHTML({HTMLAttributes:o}){return["span",r({"data-emoji":this.name},o),0]}});export{u as Emoji};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Extension as l}from"@tiptap/core";import{Plugin as m,PluginKey as p}from"@tiptap/pm/state";import{DecorationSet as a,Decoration as h}from"@tiptap/pm/view";const g=l.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new m({key:new p("focus"),props:{decorations:({doc:s,selection:c})=>{const{isEditable:u,isFocused:d}=this.editor,{anchor:r}=c,n=[];if(!u||!d)return a.create(s,[]);let i=0;this.options.mode==="deepest"&&s.descendants((t,e)=>{if(t.isText)return;if(!(r>=e&&r<=e+t.nodeSize-1))return!1;i+=1});let o=0;return s.descendants((t,e)=>{if(t.isText||!(r>=e&&r<=e+t.nodeSize-1))return!1;if(o+=1,this.options.mode==="deepest"&&i-o>0||this.options.mode==="shallowest"&&o>1)return this.options.mode==="deepest";n.push(h.node(e,e+t.nodeSize,{class:this.options.className}))}),a.create(s,n)}}})]}});export{g as Focus};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
export interface FontFamilyOptions {
|
|
3
|
+
fontFamilys: {
|
|
4
|
+
[key: string]: string;
|
|
5
|
+
};
|
|
6
|
+
types?: string[];
|
|
7
|
+
bubble?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare module '@tiptap/core' {
|
|
10
|
+
interface Commands<ReturnType> {
|
|
11
|
+
fontFamily: {
|
|
12
|
+
/**
|
|
13
|
+
* Set the font family
|
|
14
|
+
*/
|
|
15
|
+
setFontFamily: (fontFamily: string) => ReturnType;
|
|
16
|
+
/**
|
|
17
|
+
* Unset the font family
|
|
18
|
+
*/
|
|
19
|
+
unsetFontFamily: () => ReturnType;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export declare const FontFamily: Extension<FontFamilyOptions, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Extension as n}from"@tiptap/core";import{DEFAULT_FONT_FAMILY_MAP as r}from"../utils";import{FontFamilyDropdown as o}from"../components";const i=n.create({name:"fontFamily",addOptions(){return{fontFamilys:r,types:["textStyle"],btn({editor:t}){return{component:o,componentProps:{editor:t,isDisabled:t.isActive("code")}}}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>{var e;return(e=t.style.fontFamily)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}});export{i as FontFamily};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
export interface FontSizeOptions {
|
|
3
|
+
types: string[];
|
|
4
|
+
bubble?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare module '@tiptap/core' {
|
|
7
|
+
interface Commands<ReturnType> {
|
|
8
|
+
fontSize: {
|
|
9
|
+
/**
|
|
10
|
+
* Set the font size
|
|
11
|
+
*/
|
|
12
|
+
setFontSize: (fontSize: string) => ReturnType;
|
|
13
|
+
/**
|
|
14
|
+
* Unset the font size
|
|
15
|
+
*/
|
|
16
|
+
unsetFontSize: () => ReturnType;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export declare const FontSize: Extension<FontSizeOptions, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Extension as n}from"@tiptap/core";import{DEFAULT_FONT_SIZES as o,convertToPX as r}from"../utils";import{FontSizeDropdown as i}from"../components";const u=n.create({name:"fontSize",addOptions(){return{types:["textStyle"],fontSizes:o,btn({editor:t}){return{component:i,componentProps:{editor:t,isDisabled:t.isActive("code")}}}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>r(t.style.fontSize)||"",renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}px`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}});export{u as FontSize};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Extension, ParentConfig } from '@tiptap/core';
|
|
2
|
+
declare module '@tiptap/core' {
|
|
3
|
+
interface NodeConfig<Options, Storage> {
|
|
4
|
+
/**
|
|
5
|
+
* Allow gap cursor
|
|
6
|
+
*/
|
|
7
|
+
allowGapCursor?: boolean | null | ((this: {
|
|
8
|
+
name: string;
|
|
9
|
+
options: Options;
|
|
10
|
+
storage: Storage;
|
|
11
|
+
parent: ParentConfig<NodeConfig<Options>>['allowGapCursor'];
|
|
12
|
+
}) => boolean | null);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export declare const Gapcursor: Extension<any, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Extension as a,callOrReturn as t,getExtensionField as e}from"@tiptap/core";import{gapCursor as n}from"@tiptap/pm/gapcursor";const p=a.create({name:"gapCursor",addProseMirrorPlugins(){return[n()]},extendNodeSchema(r){const o={name:r.name,options:r.options,storage:r.storage};return{allowGapCursor:t(e(r,"allowGapCursor",o))??null}}});export{p as Gapcursor};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
export interface HardBreakOptions {
|
|
3
|
+
keepMarks: boolean;
|
|
4
|
+
HTMLAttributes: Record<string, any>;
|
|
5
|
+
bubble?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare module '@tiptap/core' {
|
|
8
|
+
interface Commands<ReturnType> {
|
|
9
|
+
hardBreak: {
|
|
10
|
+
/**
|
|
11
|
+
* Add a hard break
|
|
12
|
+
*/
|
|
13
|
+
setHardBreak: () => ReturnType;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export declare const HardBreak: Node<HardBreakOptions, any>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Node as l,mergeAttributes as k}from"@tiptap/core";import{UniversalToggleButton as f}from"../components";const h=l.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{},btn({editor:e,i18n:r}){return{component:f,componentProps:{toggle:()=>{e.commands.setHardBreak(),e.chain().focus().run()},isActive:!1,icon:"hard-break",tooltip:r("editor.extensions.HardBreak.tooltip")}}}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",k(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
2
|
+
`},addCommands(){return{setHardBreak:()=>({commands:e,chain:r,state:s,editor:o})=>e.first([()=>e.exitCode(),()=>e.command(()=>{const{selection:t,storedMarks:a}=s;if(t.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:d}=o.extensionManager,n=a||t.$to.parentOffset&&t.$from.marks();return r().insertContent({type:this.name}).command(({tr:u,dispatch:m})=>{if(m&&n&&i){const p=n.filter(c=>d.includes(c.type.name));u.ensureMarks(p)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});export{h as HardBreak};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
export type Level = 1 | 2 | 3 | 4 | 5 | 6;
|
|
3
|
+
export interface HeadingOptions {
|
|
4
|
+
levels: Level[];
|
|
5
|
+
HTMLAttributes: Record<string, any>;
|
|
6
|
+
bubble?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare module '@tiptap/core' {
|
|
9
|
+
interface Commands<ReturnType> {
|
|
10
|
+
heading: {
|
|
11
|
+
/**
|
|
12
|
+
* Set a heading node
|
|
13
|
+
*/
|
|
14
|
+
setHeading: (attributes: {
|
|
15
|
+
level: Level;
|
|
16
|
+
}) => ReturnType;
|
|
17
|
+
/**
|
|
18
|
+
* Toggle a heading node
|
|
19
|
+
*/
|
|
20
|
+
toggleHeading: (attributes: {
|
|
21
|
+
level: Level;
|
|
22
|
+
}) => ReturnType;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export declare const Heading: Node<HeadingOptions, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Node as s,mergeAttributes as n,textblockTypeInputRule as r}from"@tiptap/core";import{HeadingDropdown as o}from"../components";const p=s.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{},btn({editor:e,extension:t}){return{component:o,componentProps:{levels:t.options.levels,editor:e}}}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,n(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>r({find:new RegExp(`^(#{1,${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});export{p as Heading};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Mark } from '@tiptap/core';
|
|
2
|
+
export interface HighlightOptions {
|
|
3
|
+
multicolor: boolean;
|
|
4
|
+
HTMLAttributes: Record<string, any>;
|
|
5
|
+
colors: string[];
|
|
6
|
+
bubble?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare module '@tiptap/core' {
|
|
9
|
+
interface Commands<ReturnType> {
|
|
10
|
+
highlight: {
|
|
11
|
+
/**
|
|
12
|
+
* Set a highlight mark
|
|
13
|
+
*/
|
|
14
|
+
setHighlight: (attributes?: {
|
|
15
|
+
color: string;
|
|
16
|
+
}) => ReturnType;
|
|
17
|
+
/**
|
|
18
|
+
* Toggle a highlight mark
|
|
19
|
+
*/
|
|
20
|
+
toggleHighlight: (attributes?: {
|
|
21
|
+
color: string;
|
|
22
|
+
}) => ReturnType;
|
|
23
|
+
/**
|
|
24
|
+
* Unset a highlight mark
|
|
25
|
+
*/
|
|
26
|
+
unsetHighlight: () => ReturnType;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export declare const inputRegex: RegExp;
|
|
31
|
+
export declare const pasteRegex: RegExp;
|
|
32
|
+
export declare const Highlight: Mark<HighlightOptions, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Mark as e,mergeAttributes as o,markInputRule as n,markPasteRule as i}from"@tiptap/core";import{COLOR_SET as s}from"../utils";import{ColorDropdown as l}from"../components";const u=/(?:^|\s)((?:==)((?:[^~=]+))(?:==))$/,a=/(?:^|\s)((?:==)((?:[^~=]+))(?:==))/g,c=e.create({name:"highlight",addOptions(){return{multicolor:!0,colors:s,HTMLAttributes:{},btn({editor:t}){return{component:l,componentProps:{editor:t,icon:"background-color",type:"highlight",tooltip:"TextHighlight",toggle:r=>{r&&r!==null?t.commands.setHighlight({color:r}):t.commands.unsetHighlight(),t.chain().focus().run()}}}}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",o(this.options.HTMLAttributes,t),0]},addCommands(){return{setHighlight:t=>({commands:r})=>r.setMark(this.name,t),toggleHighlight:t=>({commands:r})=>r.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[n({find:u,type:this.type})]},addPasteRules(){return[i({find:a,type:this.type})]}});export{c as Highlight,u as inputRegex,a as pasteRegex};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
export interface HistoryOptions {
|
|
3
|
+
depth: number;
|
|
4
|
+
newGroupDelay: number;
|
|
5
|
+
bubble?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare module '@tiptap/core' {
|
|
8
|
+
interface Commands<ReturnType> {
|
|
9
|
+
history: {
|
|
10
|
+
/**
|
|
11
|
+
* Undo recent changes
|
|
12
|
+
*/
|
|
13
|
+
undo: () => ReturnType;
|
|
14
|
+
/**
|
|
15
|
+
* Reapply reverted changes
|
|
16
|
+
*/
|
|
17
|
+
redo: () => ReturnType;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export declare const History: Extension<HistoryOptions, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Extension as d}from"@tiptap/core";import{undo as r,redo as e,history as s}from"@tiptap/pm/history";import{UniversalToggleButton as n}from"../components";const c=d.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500,btn({editor:o,i18n:t}){return[{component:n,componentProps:{toggle:()=>{o.commands.undo(),o.chain().focus().run()},isActive:!1,isDisabled:!o.can().undo(),icon:"undo",tooltip:t("editor.extensions.History.tooltip.undo")}},{component:n,componentProps:{toggle:()=>{o.commands.redo(),o.chain().focus().run()},isActive:!1,isDisabled:!o.can().redo(),icon:"redo",tooltip:t("editor.extensions.History.tooltip.redo")}}]}}},addCommands(){return{undo:()=>({state:o,dispatch:t})=>r(o,t),redo:()=>({state:o,dispatch:t})=>e(o,t)}},addProseMirrorPlugins(){return[s(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-Z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-Y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Shift-Mod-Z":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});export{c as History};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
export interface HorizontalRuleOptions {
|
|
3
|
+
HTMLAttributes: Record<string, any>;
|
|
4
|
+
bubble?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare module '@tiptap/core' {
|
|
7
|
+
interface Commands<ReturnType> {
|
|
8
|
+
horizontalRule: {
|
|
9
|
+
/**
|
|
10
|
+
* Add a horizontal rule
|
|
11
|
+
*/
|
|
12
|
+
setHorizontalRule: () => ReturnType;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export declare const HorizontalRule: Node<HorizontalRuleOptions, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Node as p,mergeAttributes as d,nodeInputRule as f}from"@tiptap/core";import{TextSelection as s,NodeSelection as m}from"@tiptap/pm/state";import{UniversalToggleButton as h}from"../components";const H=p.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},btn({editor:o,i18n:n}){return{component:h,componentProps:{toggle:()=>{o.commands.setHorizontalRule(),o.chain().focus().run()},isActive:!1,icon:"horizontal-rule",tooltip:n("editor.extensions.HorizontalRule.tooltip")}}}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:o}){return["hr",d(this.options.HTMLAttributes,o)]},addCommands(){return{setHorizontalRule:()=>({chain:o,state:n})=>{const{$to:i}=n.selection,r=o();return i.parentOffset===0?r.insertContentAt(Math.max(i.pos-2,0),{type:this.name}):r.insertContent({type:this.name}),r.command(({tr:e,dispatch:u})=>{var c;if(u){const{$to:t}=e.selection,l=t.end();if(t.nodeAfter)t.nodeAfter.isTextblock?e.setSelection(s.create(e.doc,t.pos+1)):t.nodeAfter.isBlock?e.setSelection(m.create(e.doc,t.pos)):e.setSelection(s.create(e.doc,t.pos));else{const a=(c=t.parent.type.contentMatch.defaultType)==null?void 0:c.create();a&&(e.insert(l,a),e.setSelection(s.create(e.doc,l+1)))}e.scrollIntoView()}return!0}).run()}}},addInputRules(){return[f({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});export{H as HorizontalRule};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
export interface ImageOptions {
|
|
3
|
+
inline: boolean;
|
|
4
|
+
allowBase64: boolean;
|
|
5
|
+
HTMLAttributes: Record<string, any>;
|
|
6
|
+
uploadRequest?: Function | undefined;
|
|
7
|
+
urlPattern?: RegExp;
|
|
8
|
+
bubble?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare module '@tiptap/core' {
|
|
11
|
+
interface Commands<ReturnType> {
|
|
12
|
+
image: {
|
|
13
|
+
/**
|
|
14
|
+
* Add an image
|
|
15
|
+
*/
|
|
16
|
+
setImage: (options: {
|
|
17
|
+
src: string;
|
|
18
|
+
alt?: string;
|
|
19
|
+
title?: string;
|
|
20
|
+
}) => ReturnType;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export declare const inputRegex: RegExp;
|
|
25
|
+
export declare const Image: Node<ImageOptions, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Node as l,mergeAttributes as s,nodeInputRule as u}from"@tiptap/core";import{VueNodeViewRenderer as a}from"@tiptap/vue-3";import{DEFAULT_IMAGE_URL_REGEX as d,DEFAULT_IMAGE_DISPLAY as o,ImageDisplay as i}from"../utils";import{InsertImageButton as p,ImageView as g}from"../components";const m=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,T=l.create({name:"image",addOptions(){return{allowBase64:!1,HTMLAttributes:{},inline:!0,urlPattern:d,btn({editor:t}){return{component:p,componentProps:{editor:t}}}}},inline(){return!0},group(){return"inline"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null,parseHTML:t=>{const r=t.style.width||t.getAttribute("width")||null;return r==null?null:parseInt(r,10)},renderHTML:t=>({width:t.width})},display:{default:o,parseHTML:t=>{const{cssFloat:r,display:n}=t.style;let e=t.getAttribute("data-display")||t.getAttribute("display");return e?e=/(inline|block|left|right)/.test(e)?e:i.INLINE:r==="left"&&!n?e=i.FLOAT_LEFT:r==="right"&&!n?e=i.FLOAT_RIGHT:!r&&n==="block"?e=i.BREAK_TEXT:e=i.INLINE,e},renderHTML:t=>({"data-display":t.display})}}},parseHTML(){return[{tag:"img[src]"}]},renderHTML({HTMLAttributes:t}){return["img",s(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:r})=>r.insertContent({type:this.name,attrs:t})}},addInputRules(){return[u({find:m,type:this.type,getAttributes:t=>{const[,,r,n,e]=t;return{src:n,alt:r,title:e}}})]},addNodeView(){return a(g)}});export{T as Image,m as inputRegex};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
export interface IndentOptions {
|
|
3
|
+
types: string[];
|
|
4
|
+
minIndent: number;
|
|
5
|
+
maxIndent: number;
|
|
6
|
+
}
|
|
7
|
+
declare module '@tiptap/core' {
|
|
8
|
+
interface Commands<ReturnType> {
|
|
9
|
+
indent: {
|
|
10
|
+
/**
|
|
11
|
+
* Set the indent attribute
|
|
12
|
+
*/
|
|
13
|
+
indent: () => ReturnType;
|
|
14
|
+
/**
|
|
15
|
+
* Set the outdent attribute
|
|
16
|
+
*/
|
|
17
|
+
outdent: () => ReturnType;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export declare const Indent: Extension<IndentOptions, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Extension as m}from"@tiptap/core";import{IndentProps as e,checkIndent as d,createIndentCommand as a}from"../utils";import{UniversalToggleButton as r}from"../components";const u=m.create({name:"indent",addOptions(){return{types:["paragraph","heading","blockquote"],minIndent:e.min,maxIndent:e.max,btn({editor:n,i18n:t}){var i,s;return[{component:r,componentProps:{toggle:()=>{n.commands.indent()},icon:"indent",isActive:!1,isDisabled:d(n)===((i=n.extensionManager.extensions.find(o=>o.name==="indent"))==null?void 0:i.options.maxIndent),tooltip:t("editor.extensions.Indent.buttons.indent.tooltip")}},{component:r,componentProps:{toggle:()=>{n.commands.outdent()},icon:"outdent",isActive:!1,isDisabled:d(n)===((s=n.extensionManager.extensions.find(o=>o.name==="indent"))==null?void 0:s.options.minIndent),tooltip:t("editor.extensions.Indent.buttons.outdent.tooltip")}}]}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:n=>{const t=n.getAttribute("data-indent");return(t?parseInt(t,10):0)||0},renderHTML:n=>n.indent?{"data-indent":n.indent,style:`margin-left: ${n.indent*30}px`}:{}}}}]},addCommands(){return{indent:()=>a({delta:e.more,types:this.options.types}),outdent:()=>a({delta:e.less,types:this.options.types})}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.indent(),"Shift-Tab":()=>this.editor.commands.outdent()}}});export{u as Indent};
|