diff --git a/apps/www/src/config/customizer-items.ts b/apps/www/src/config/customizer-items.ts index 03554dfe9d..8b4d5499fa 100644 --- a/apps/www/src/config/customizer-items.ts +++ b/apps/www/src/config/customizer-items.ts @@ -959,20 +959,10 @@ export const customizerItems: Record = { }, [KEY_DELETE]: { id: KEY_DELETE, - npmPackage: '@udecode/plate-select', + npmPackage: '@udecode/plate-delete', pluginFactory: 'createDeletePlugin', - pluginOptions: [ - `options: {`, - ` query: {`, - ` allow: [`, - ` // ELEMENT_IMAGE, ELEMENT_HR`, - ` ],`, - ` },`, - `},`, - ], - label: 'Forward Delete Plugin', + label: 'Delete', badges: [customizerBadges.handler], - route: customizerPlugins.media.route, }, [KEY_SINGLE_LINE]: { id: KEY_SINGLE_LINE, diff --git a/apps/www/src/config/descriptions.ts b/apps/www/src/config/descriptions.ts index c469d429bd..9b4d4d766b 100644 --- a/apps/www/src/config/descriptions.ts +++ b/apps/www/src/config/descriptions.ts @@ -94,7 +94,7 @@ export const descriptions: Record = { [KEY_RESET_NODE]: 'Reset the block type using rules.', [KEY_SELECT_ON_BACKSPACE]: 'Select the preceding block instead of deleting when pressing backspace.', - [KEY_DELETE]: 'Enable forward delete plugin', + [KEY_DELETE]: 'Remove the current block if empty when pressing delete foward', [KEY_SINGLE_LINE]: 'Restrict the editor to a single block.', [KEY_SOFT_BREAK]: 'Insert line breaks within a block of text without starting a new block.', diff --git a/apps/www/src/registry/default/example/playground-demo.tsx b/apps/www/src/registry/default/example/playground-demo.tsx index dc4a55c784..b9ae56dda1 100644 --- a/apps/www/src/registry/default/example/playground-demo.tsx +++ b/apps/www/src/registry/default/example/playground-demo.tsx @@ -220,7 +220,7 @@ export const usePlaygroundPlugins = ({ enabled: !!enabled.selectOnBackspace, }), createDeletePlugin({ - enabled: !!enabled.selectOnBackspace, + enabled: !!enabled.createDeletePlugin, }), createSingleLinePlugin({ enabled: id === 'singleline' || !!enabled.singleLine, diff --git a/packages/select/src/createDeletePlugin.ts b/packages/select/src/createDeletePlugin.ts index 60b9c5117e..ba166d1334 100644 --- a/packages/select/src/createDeletePlugin.ts +++ b/packages/select/src/createDeletePlugin.ts @@ -1,4 +1,4 @@ -import { createPluginFactory, QueryNodeOptions } from '@udecode/plate-common'; +import { createPluginFactory, ELEMENT_DEFAULT, QueryNodeOptions } from '@udecode/plate-common'; import { withDelete } from './withDelete'; @@ -14,4 +14,9 @@ export const KEY_DELETE = 'delete'; export const createDeletePlugin = createPluginFactory({ key: KEY_DELETE, withOverrides: withDelete, + options: { + query: { + allow: [ELEMENT_DEFAULT], + }, + }, }); diff --git a/packages/select/src/withDelete.ts b/packages/select/src/withDelete.ts index bee76837de..fe37cd1c71 100644 --- a/packages/select/src/withDelete.ts +++ b/packages/select/src/withDelete.ts @@ -22,7 +22,7 @@ export const withDelete = < { options: { query } }: WithPlatePlugin ) => { const { deleteForward } = editor; - editor.deleteForward = (unit: 'character' | 'word' | 'line' | 'block') => { + editor.deleteForward = (unit) => { if (!editor.selection) return; const isValidNode = queryNode(getAboveNode(editor), query); if ( diff --git a/templates/plate-playground-template/src/lib/plate/plate-plugins.ts b/templates/plate-playground-template/src/lib/plate/plate-plugins.ts index bc2461b92b..bb25b4920f 100644 --- a/templates/plate-playground-template/src/lib/plate/plate-plugins.ts +++ b/templates/plate-playground-template/src/lib/plate/plate-plugins.ts @@ -38,7 +38,6 @@ import { createComboboxPlugin } from '@udecode/plate-combobox'; import { createCommentsPlugin, MARK_COMMENT } from '@udecode/plate-comments'; import { createPlugins, - ELEMENT_DEFAULT, isBlockAboveEmpty, isSelectionAtBlockStart, PlateElement, @@ -324,13 +323,6 @@ export const plugins = createPlugins( }, }), - createDeletePlugin({ - options: { - query: { - allow: [ELEMENT_DEFAULT], - }, - }, - }), createSoftBreakPlugin({ options: { rules: [