Skip to content

Commit

Permalink
feat: skip untargeted node
Browse files Browse the repository at this point in the history
  • Loading branch information
robertu7 committed May 4, 2023
1 parent 99415f7 commit 9915362
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 35 deletions.
44 changes: 22 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@matters/matters-editor",
"version": "0.2.0-alpha.34",
"version": "0.2.0-alpha.35",
"description": "Editor for matters.news",
"author": "https://github.com/thematters",
"homepage": "https://github.com/thematters/matters-editor",
Expand Down
10 changes: 6 additions & 4 deletions src/editors/extensions/figureAudio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,13 @@ export const FigureAudio = Node.create({
// @ts-ignore
const editor = view.dom.editor as Editor

if (!isFigure) {
return
}

// backSpace to remove if the figcaption is empty
if (event.key === 'BackSpace') {
if (isEmptyFigcaption && isFigure) {
editor.commands.deleteNode(pluginName)
}
if (event.key === 'BackSpace' && isEmptyFigcaption) {
editor.commands.deleteNode(pluginName)
}

// enter to insert a new paragraph
Expand Down
10 changes: 6 additions & 4 deletions src/editors/extensions/figureEmbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,13 @@ export const FigureEmbed = Node.create({
// @ts-ignore
const editor = view.dom.editor as Editor

if (!isFigure) {
return
}

// backSpace to remove if the figcaption is empty
if (event.key === 'BackSpace') {
if (isEmptyFigcaption && isFigure) {
editor.commands.deleteNode(pluginName)
}
if (event.key === 'BackSpace' && isEmptyFigcaption) {
editor.commands.deleteNode(pluginName)
}

// enter to insert a new paragraph
Expand Down
10 changes: 6 additions & 4 deletions src/editors/extensions/figureImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ export const FigureImage = Node.create({
// @ts-ignore
const editor = view.dom.editor as Editor

if (!isFigure) {
return
}

// backSpace to remove if the figcaption is empty
if (event.key === 'BackSpace') {
if (isEmptyFigcaption && isFigure) {
editor.commands.deleteNode(pluginName)
}
if (event.key === 'BackSpace' && isEmptyFigcaption) {
editor.commands.deleteNode(pluginName)
}

// enter to insert a new paragraph
Expand Down

0 comments on commit 9915362

Please sign in to comment.