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

issue-5452 markdown shortcut #5495

Merged
merged 11 commits into from
Jun 18, 2024
1 change: 1 addition & 0 deletions packages/volto-slate/news/5452.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed markup shortcut for heading and blockquote @kHAPPY2004
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly was broken, and how was it fixed? Please include some details, such as what was the original broken behavior and what is the new fixed behavior. These change log entries appear in documentation upon release, so they should be helpful to a developer looking to fix a broken behavior that they observed.

3 changes: 3 additions & 0 deletions packages/volto-slate/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export const P = 'p';
export const LI = 'li';
export const UL = 'ul';
export const OL = 'ol';
export const H2 = 'h2';
export const H3 = 'h3';
export const BLOCKQUOTE = 'blockquote';

// dom parsing node information
export const TEXT_NODE = 3;
Expand Down
8 changes: 4 additions & 4 deletions packages/volto-slate/src/editor/plugins/Markdown/constants.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { toggleList } from './utils';
import { isBlockActive } from '@plone/volto-slate/utils';
import { UL, OL, LI } from '@plone/volto-slate/constants';
import { UL, OL, LI, H2, H3, BLOCKQUOTE } from '@plone/volto-slate/constants';

/**
* Uses the old toggleList function to toggle lists on or off or from a type to another.
Expand All @@ -22,11 +22,11 @@ export const localToggleList = (editor, format) => {
*/
export const autoformatRules = [
{
type: 'h2',
type: H2,
markup: '#',
},
{
type: 'h3',
type: H3,
markup: '##',
},
{
Expand All @@ -44,7 +44,7 @@ export const autoformatRules = [
},
},
{
type: 'blockquote',
type: BLOCKQUOTE,
markup: ['>'],
// preFormat,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,7 @@ export const autoformatBlock = (editor, type, at, { preFormat, format }) => {
}

if (!format) {
Transforms.setNodes(
editor,
{ type },
{ match: (n) => Editor.isBlock(editor, n) },
);
Transforms.setNodes(editor, { type });
} else {
format(editor);
}
Expand Down
Loading