diff --git a/src/plugins/linkHelpers.js b/src/plugins/linkHelpers.js index ef20c997bfa..3ab9c1cfe60 100644 --- a/src/plugins/linkHelpers.js +++ b/src/plugins/linkHelpers.js @@ -20,6 +20,12 @@ * */ +/** + * + * @param {object} state the prosemirror state + * @param {object} state.selection - the current selection + * @param {object} state.doc - the current doc + */ export function linkNodeFromSelection({ selection, doc }) { // support for CellSelections const { ranges } = selection @@ -45,6 +51,10 @@ export function linkNodeFromSelection({ selection, doc }) { return isLinkNode(node) ? node : null } +/** + * Determine wether the given node is a link node + * @param {object} node - node to check + */ function isLinkNode(node) { const linkMark = node?.marks.find(m => m.type.name === 'link') if (!linkMark) { diff --git a/src/plugins/links.js b/src/plugins/links.js index 053bc3114d1..fc8ffb6259d 100644 --- a/src/plugins/links.js +++ b/src/plugins/links.js @@ -59,6 +59,10 @@ export const hideLinkBubble = (state, dispatch) => { } export const linkBubbleKey = new PluginKey('linkBubble') +/** + * Prosemirror link bubble plugin + * @param {object} options - options for the link bubble plugin view + */ export function linkBubble(options) { const linkBubblePlugin = new Plugin({ key: linkBubbleKey, @@ -135,6 +139,14 @@ export function linkBubble(options) { } export const linkClickingKey = new PluginKey('textHandleClickLink') + +/** + * Prosemirror plugin for special handling for clicks on links + * + * - Open link in new tab on middle click rather than pasting. + * - Only open link on ctrl/cmd + left click. + * We use the link bubble otherwise. + */ export function linkClicking() { return new Plugin({ key: linkClickingKey,