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 by passing 'at' to Transforms.setNodes api call for location of node @kHAPPY2004
kHAPPY2004 marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -200,6 +200,7 @@ export const autoformatBlock = (editor, type, at, { preFormat, format }) => {
Transforms.setNodes(
editor,
{ type },
{ at },
{ match: (n) => Editor.isBlock(editor, n) },
);
} else {
Expand Down