Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
archie9211 committed Oct 10, 2023
1 parent 2fdf847 commit db1c9bd
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 24 deletions.
14 changes: 2 additions & 12 deletions apps/www/src/config/customizer-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,20 +959,10 @@ export const customizerItems: Record<string, SettingPlugin> = {
},
[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,
Expand Down
2 changes: 1 addition & 1 deletion apps/www/src/config/descriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const descriptions: Record<string, string> = {
[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.',
Expand Down
2 changes: 1 addition & 1 deletion apps/www/src/registry/default/example/playground-demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export const usePlaygroundPlugins = ({
enabled: !!enabled.selectOnBackspace,
}),
createDeletePlugin({
enabled: !!enabled.selectOnBackspace,
enabled: !!enabled.createDeletePlugin,
}),
createSingleLinePlugin({
enabled: id === 'singleline' || !!enabled.singleLine,
Expand Down
7 changes: 6 additions & 1 deletion packages/select/src/createDeletePlugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createPluginFactory, QueryNodeOptions } from '@udecode/plate-common';
import { createPluginFactory, ELEMENT_DEFAULT, QueryNodeOptions } from '@udecode/plate-common';

import { withDelete } from './withDelete';

Expand All @@ -14,4 +14,9 @@ export const KEY_DELETE = 'delete';
export const createDeletePlugin = createPluginFactory<DeletePlugin>({
key: KEY_DELETE,
withOverrides: withDelete,
options: {
query: {
allow: [ELEMENT_DEFAULT],
},
},
});
2 changes: 1 addition & 1 deletion packages/select/src/withDelete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const withDelete = <
{ options: { query } }: WithPlatePlugin<DeletePlugin, V, E>
) => {
const { deleteForward } = editor;
editor.deleteForward = (unit: 'character' | 'word' | 'line' | 'block') => {
editor.deleteForward = (unit) => {
if (!editor.selection) return;
const isValidNode = queryNode(getAboveNode(editor), query);
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -324,13 +323,6 @@ export const plugins = createPlugins(
},
}),

createDeletePlugin({
options: {
query: {
allow: [ELEMENT_DEFAULT],
},
},
}),
createSoftBreakPlugin({
options: {
rules: [
Expand Down

0 comments on commit db1c9bd

Please sign in to comment.