@tiptap/extension-link
Advanced tools
Comparing version 1.0.0-alpha.2 to 2.0.0-alpha.1
@@ -6,2 +6,10 @@ # Change Log | ||
# [2.0.0-alpha.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-link@1.0.0-alpha.2...@tiptap/extension-link@2.0.0-alpha.1) (2020-11-18) | ||
**Note:** Version bump only for package @tiptap/extension-link | ||
# [1.0.0-alpha.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-link@1.0.0-alpha.1...@tiptap/extension-link@1.0.0-alpha.2) (2020-11-16) | ||
@@ -8,0 +16,0 @@ |
@@ -11,8 +11,19 @@ import { Command, Mark } from '@tiptap/core'; | ||
/** | ||
* Toggle or update a link mark | ||
* Set a link mark | ||
*/ | ||
link: (options?: { | ||
setLink: (attributes?: { | ||
href?: string; | ||
target?: string; | ||
}) => Command; | ||
/** | ||
* Toggle a link mark | ||
*/ | ||
toggleLink: (attributes?: { | ||
href?: string; | ||
target?: string; | ||
}) => Command; | ||
/** | ||
* Unset a link mark | ||
*/ | ||
unsetLink: () => Command; | ||
}>; | ||
@@ -19,0 +30,0 @@ export default Link; |
@@ -40,10 +40,19 @@ 'use strict'; | ||
/** | ||
* Toggle or update a link mark | ||
* Set a link mark | ||
*/ | ||
link: (options = {}) => ({ commands }) => { | ||
if (!options.href) { | ||
return commands.removeMark('link'); | ||
} | ||
return commands.updateMarkAttributes('link', options); | ||
setLink: (attributes = {}) => ({ commands }) => { | ||
return commands.setMark('link', attributes); | ||
}, | ||
/** | ||
* Toggle a link mark | ||
*/ | ||
toggleLink: (attributes = {}) => ({ commands }) => { | ||
return commands.toggleMark('link', attributes); | ||
}, | ||
/** | ||
* Unset a link mark | ||
*/ | ||
unsetLink: () => ({ commands }) => { | ||
return commands.unsetMark('link'); | ||
}, | ||
}; | ||
@@ -65,3 +74,3 @@ }, | ||
handleClick: (view, pos, event) => { | ||
const attrs = this.editor.getMarkAttrs('link'); | ||
const attrs = this.editor.getMarkAttributes('link'); | ||
if (attrs.href && event.target instanceof HTMLAnchorElement) { | ||
@@ -68,0 +77,0 @@ window.open(attrs.href, attrs.target); |
@@ -36,10 +36,19 @@ import { Mark, markPasteRule } from '@tiptap/core'; | ||
/** | ||
* Toggle or update a link mark | ||
* Set a link mark | ||
*/ | ||
link: (options = {}) => ({ commands }) => { | ||
if (!options.href) { | ||
return commands.removeMark('link'); | ||
} | ||
return commands.updateMarkAttributes('link', options); | ||
setLink: (attributes = {}) => ({ commands }) => { | ||
return commands.setMark('link', attributes); | ||
}, | ||
/** | ||
* Toggle a link mark | ||
*/ | ||
toggleLink: (attributes = {}) => ({ commands }) => { | ||
return commands.toggleMark('link', attributes); | ||
}, | ||
/** | ||
* Unset a link mark | ||
*/ | ||
unsetLink: () => ({ commands }) => { | ||
return commands.unsetMark('link'); | ||
}, | ||
}; | ||
@@ -61,3 +70,3 @@ }, | ||
handleClick: (view, pos, event) => { | ||
const attrs = this.editor.getMarkAttrs('link'); | ||
const attrs = this.editor.getMarkAttributes('link'); | ||
if (attrs.href && event.target instanceof HTMLAnchorElement) { | ||
@@ -64,0 +73,0 @@ window.open(attrs.href, attrs.target); |
@@ -39,10 +39,19 @@ (function (global, factory) { | ||
/** | ||
* Toggle or update a link mark | ||
* Set a link mark | ||
*/ | ||
link: (options = {}) => ({ commands }) => { | ||
if (!options.href) { | ||
return commands.removeMark('link'); | ||
} | ||
return commands.updateMarkAttributes('link', options); | ||
setLink: (attributes = {}) => ({ commands }) => { | ||
return commands.setMark('link', attributes); | ||
}, | ||
/** | ||
* Toggle a link mark | ||
*/ | ||
toggleLink: (attributes = {}) => ({ commands }) => { | ||
return commands.toggleMark('link', attributes); | ||
}, | ||
/** | ||
* Unset a link mark | ||
*/ | ||
unsetLink: () => ({ commands }) => { | ||
return commands.unsetMark('link'); | ||
}, | ||
}; | ||
@@ -64,3 +73,3 @@ }, | ||
handleClick: (view, pos, event) => { | ||
const attrs = this.editor.getMarkAttrs('link'); | ||
const attrs = this.editor.getMarkAttributes('link'); | ||
if (attrs.href && event.target instanceof HTMLAnchorElement) { | ||
@@ -67,0 +76,0 @@ window.open(attrs.href, attrs.target); |
{ | ||
"name": "@tiptap/extension-link", | ||
"version": "1.0.0-alpha.2", | ||
"version": "2.0.0-alpha.1", | ||
"homepage": "https://tiptap.dev", | ||
@@ -24,3 +24,3 @@ "keywords": [ | ||
"peerDependencies": { | ||
"@tiptap/core": "2.0.0-alpha.3" | ||
"@tiptap/core": "^2.0.0-alpha.0" | ||
}, | ||
@@ -30,3 +30,3 @@ "dependencies": { | ||
}, | ||
"gitHead": "a8a578edb78db7763e2eda83960c25b02e8488c5" | ||
"gitHead": "276118e48eef313fb435088dee3dc58b91363109" | ||
} |
@@ -8,3 +8,3 @@ # @tiptap/extension-link | ||
## 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*. | ||
@@ -11,0 +11,0 @@ ## Offical Documentation |
@@ -50,11 +50,19 @@ import { Command, Mark, markPasteRule } from '@tiptap/core' | ||
/** | ||
* Toggle or update a link mark | ||
* Set a link mark | ||
*/ | ||
link: (options: { href?: string, target?: string } = {}): Command => ({ commands }) => { | ||
if (!options.href) { | ||
return commands.removeMark('link') | ||
} | ||
return commands.updateMarkAttributes('link', options) | ||
setLink: (attributes: { href?: string, target?: string } = {}): Command => ({ commands }) => { | ||
return commands.setMark('link', attributes) | ||
}, | ||
/** | ||
* Toggle a link mark | ||
*/ | ||
toggleLink: (attributes: { href?: string, target?: string } = {}): Command => ({ commands }) => { | ||
return commands.toggleMark('link', attributes) | ||
}, | ||
/** | ||
* Unset a link mark | ||
*/ | ||
unsetLink: (): Command => ({ commands }) => { | ||
return commands.unsetMark('link') | ||
}, | ||
} | ||
@@ -79,3 +87,3 @@ }, | ||
handleClick: (view, pos, event) => { | ||
const attrs = this.editor.getMarkAttrs('link') | ||
const attrs = this.editor.getMarkAttributes('link') | ||
@@ -82,0 +90,0 @@ if (attrs.href && event.target instanceof HTMLAnchorElement) { |
Sorry, the diff of this file is too big to display
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
460754
702