Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete forward on empty line before code block unwraps code line #2686 #2687

Merged
merged 18 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
zbeyens marked this conversation as resolved.
Show resolved Hide resolved
[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,
zbeyens marked this conversation as resolved.
Show resolved Hide resolved
}),
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,
12joan marked this conversation as resolved.
Show resolved Hide resolved
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);
zbeyens marked this conversation as resolved.
Show resolved Hide resolved
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