@tiptap/extension-mention
Advanced tools
Comparing version 3.0.0-next.3 to 3.0.0-next.4
@@ -108,3 +108,7 @@ // src/mention.ts | ||
const mergedOptions = { ...this.options }; | ||
mergedOptions.HTMLAttributes = mergeAttributes({ "data-type": this.name }, this.options.HTMLAttributes, HTMLAttributes); | ||
mergedOptions.HTMLAttributes = mergeAttributes( | ||
{ "data-type": this.name }, | ||
this.options.HTMLAttributes, | ||
HTMLAttributes | ||
); | ||
const html = this.options.renderHTML({ | ||
@@ -115,7 +119,3 @@ options: mergedOptions, | ||
if (typeof html === "string") { | ||
return [ | ||
"span", | ||
mergeAttributes({ "data-type": this.name }, this.options.HTMLAttributes, HTMLAttributes), | ||
html | ||
]; | ||
return ["span", mergeAttributes({ "data-type": this.name }, this.options.HTMLAttributes, HTMLAttributes), html]; | ||
} | ||
@@ -172,8 +172,8 @@ return html; | ||
// src/index.ts | ||
var src_default = Mention; | ||
var index_default = Mention; | ||
export { | ||
Mention, | ||
MentionPluginKey, | ||
src_default as default | ||
index_default as default | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@tiptap/extension-mention", | ||
"description": "mention extension for tiptap", | ||
"version": "3.0.0-next.3", | ||
"version": "3.0.0-next.4", | ||
"homepage": "https://tiptap.dev", | ||
@@ -18,3 +18,6 @@ "keywords": [ | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"types": { | ||
"import": "./dist/index.d.ts", | ||
"require": "./dist/index.d.cts" | ||
}, | ||
"import": "./dist/index.js", | ||
@@ -32,5 +35,5 @@ "require": "./dist/index.cjs" | ||
"devDependencies": { | ||
"@tiptap/core": "^3.0.0-next.3", | ||
"@tiptap/pm": "^3.0.0-next.3", | ||
"@tiptap/suggestion": "^3.0.0-next.3" | ||
"@tiptap/core": "^3.0.0-next.4", | ||
"@tiptap/pm": "^3.0.0-next.4", | ||
"@tiptap/suggestion": "^3.0.0-next.4" | ||
}, | ||
@@ -48,4 +51,5 @@ "peerDependencies": { | ||
"scripts": { | ||
"build": "tsup" | ||
"build": "tsup", | ||
"lint": "prettier ./src/ --check && eslint --cache --quiet --no-error-on-unmatched-pattern ./src/" | ||
} | ||
} | ||
} |
# @tiptap/extension-mention | ||
[![Version](https://img.shields.io/npm/v/@tiptap/extension-mention.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-mention) | ||
@@ -8,8 +9,11 @@ [![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-mention.svg)](https://npmcharts.com/compare/tiptap?minimal=true) | ||
## Introduction | ||
Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*. | ||
Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as _New York Times_, _The Guardian_ or _Atlassian_. | ||
## Official Documentation | ||
Documentation can be found on the [Tiptap website](https://tiptap.dev). | ||
## License | ||
Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md). |
@@ -12,3 +12,3 @@ import { mergeAttributes, Node } from '@tiptap/core' | ||
*/ | ||
id: string | null; | ||
id: string | null | ||
/** | ||
@@ -18,3 +18,3 @@ * The label to be rendered by the editor as the displayed text for this mentioned | ||
*/ | ||
label?: string | null; | ||
label?: string | null | ||
} | ||
@@ -202,3 +202,7 @@ | ||
mergedOptions.HTMLAttributes = mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes) | ||
mergedOptions.HTMLAttributes = mergeAttributes( | ||
{ 'data-type': this.name }, | ||
this.options.HTMLAttributes, | ||
HTMLAttributes, | ||
) | ||
const html = this.options.renderHTML({ | ||
@@ -210,7 +214,3 @@ options: mergedOptions, | ||
if (typeof html === 'string') { | ||
return [ | ||
'span', | ||
mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes), | ||
html, | ||
] | ||
return ['span', mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes), html] | ||
} | ||
@@ -236,26 +236,27 @@ return html | ||
return { | ||
Backspace: () => this.editor.commands.command(({ tr, state }) => { | ||
let isMention = false | ||
const { selection } = state | ||
const { empty, anchor } = selection | ||
Backspace: () => | ||
this.editor.commands.command(({ tr, state }) => { | ||
let isMention = false | ||
const { selection } = state | ||
const { empty, anchor } = selection | ||
if (!empty) { | ||
return false | ||
} | ||
state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => { | ||
if (node.type.name === this.name) { | ||
isMention = true | ||
tr.insertText( | ||
this.options.deleteTriggerWithBackspace ? '' : this.options.suggestion.char || '', | ||
pos, | ||
pos + node.nodeSize, | ||
) | ||
if (!empty) { | ||
return false | ||
} | ||
}) | ||
return isMention | ||
}), | ||
state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => { | ||
if (node.type.name === this.name) { | ||
isMention = true | ||
tr.insertText( | ||
this.options.deleteTriggerWithBackspace ? '' : this.options.suggestion.char || '', | ||
pos, | ||
pos + node.nodeSize, | ||
) | ||
return false | ||
} | ||
}) | ||
return isMention | ||
}), | ||
} | ||
@@ -262,0 +263,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
50840
11
698
19