diff --git a/package.json b/package.json index f5e6cf4..5f28519 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@matters/matters-editor", - "version": "0.3.0-alpha.3", + "version": "0.3.0-alpha.4", "description": "Editor for matters.news", "author": "https://github.com/thematters", "homepage": "https://github.com/thematters/matters-editor", diff --git a/src/editors/extensions/figcaptionKit.ts b/src/editors/extensions/figcaptionKit.ts index d26ad93..22f0ce8 100644 --- a/src/editors/extensions/figcaptionKit.ts +++ b/src/editors/extensions/figcaptionKit.ts @@ -7,8 +7,6 @@ import { Decoration, DecorationSet } from '@tiptap/pm/view' * FigcaptionKit extension works with FigureAudio, * FigureEmbed and FigureImage extensions to: * - limit figcaption length - * - handle enter key event to insert a new paragraph - * - handle backspace key event to remove the figcaption if it's empty * - handle click event to select the figcaption * - customize the empty node class and placeholder * @@ -48,52 +46,6 @@ export const makeFigcaptionEventHandlerPlugin = ({ // @see {@url https://discuss.prosemirror.net/t/prevent-nodeview-selection-on-click/3193} return true }, - handleKeyDown(view, event) { - const isBackSpace = event.key.toLowerCase() === 'backspace' - const isEnter = event.key.toLowerCase() === 'enter' - - if (!isBackSpace && !isEnter) { - return - } - - const anchorParent = view.state.selection.$anchor.parent - const isFigureExtensions = supportedFigureExtensions.includes( - anchorParent.type.name, - ) - const isEmptyFigcaption = anchorParent.content.size <= 0 - - if (!isFigureExtensions) { - return - } - - // backSpace to remove if the figcaption is empty - if (isBackSpace && isEmptyFigcaption) { - // FIXME: setTimeOut to avoid repetitive deletion - setTimeout(() => { - editor.commands.deleteNode(pluginName) - }) - return - } - - // insert a new paragraph - if (isEnter) { - const { $from, $to } = editor.state.selection - const isTextAfter = $to.nodeAfter?.type?.name === 'text' - - // skip if figcaption text is selected - // or has text after current selection - if ($from !== $to || isTextAfter) { - return - } - - // FIXME: setTimeOut to avoid repetitive paragraph insertion - setTimeout(() => { - editor.commands.insertContentAt($to.pos + 1, { - type: 'paragraph', - }) - }) - } - }, }, }) }