From 426cc084316e866c8ba2f320afdbadba649c46e9 Mon Sep 17 00:00:00 2001 From: kHAPPY2004 Date: Tue, 5 Dec 2023 23:54:13 +0530 Subject: [PATCH 1/5] issue-5452 markdown shourtcut --- packages/generator-volto/news/5452.bugfix | 1 + packages/volto-slate/src/constants.js | 3 +++ .../volto-slate/src/editor/plugins/Markdown/constants.js | 8 ++++---- .../volto-slate/src/editor/plugins/Markdown/extensions.js | 6 +----- 4 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 packages/generator-volto/news/5452.bugfix diff --git a/packages/generator-volto/news/5452.bugfix b/packages/generator-volto/news/5452.bugfix new file mode 100644 index 0000000000..c6133b314e --- /dev/null +++ b/packages/generator-volto/news/5452.bugfix @@ -0,0 +1 @@ +Fixed markup shortcut for heading and blockquote @kHAPPY2004 \ No newline at end of file diff --git a/packages/volto-slate/src/constants.js b/packages/volto-slate/src/constants.js index 9774580cf6..0108272441 100644 --- a/packages/volto-slate/src/constants.js +++ b/packages/volto-slate/src/constants.js @@ -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; diff --git a/packages/volto-slate/src/editor/plugins/Markdown/constants.js b/packages/volto-slate/src/editor/plugins/Markdown/constants.js index ad0bb47991..9614c15426 100644 --- a/packages/volto-slate/src/editor/plugins/Markdown/constants.js +++ b/packages/volto-slate/src/editor/plugins/Markdown/constants.js @@ -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. @@ -22,11 +22,11 @@ export const localToggleList = (editor, format) => { */ export const autoformatRules = [ { - type: 'h2', + type: H2, markup: '#', }, { - type: 'h3', + type: H3, markup: '##', }, { @@ -44,7 +44,7 @@ export const autoformatRules = [ }, }, { - type: 'blockquote', + type: BLOCKQUOTE, markup: ['>'], // preFormat, }, diff --git a/packages/volto-slate/src/editor/plugins/Markdown/extensions.js b/packages/volto-slate/src/editor/plugins/Markdown/extensions.js index e067a8ab13..b0de36f728 100644 --- a/packages/volto-slate/src/editor/plugins/Markdown/extensions.js +++ b/packages/volto-slate/src/editor/plugins/Markdown/extensions.js @@ -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); } From 7d87e01861e204aa1fa80f5732b464cd904ffab4 Mon Sep 17 00:00:00 2001 From: kHAPPY2004 Date: Wed, 6 Dec 2023 01:44:03 +0530 Subject: [PATCH 2/5] changelog --- packages/{generator-volto => volto-slate}/news/5452.bugfix | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/{generator-volto => volto-slate}/news/5452.bugfix (100%) diff --git a/packages/generator-volto/news/5452.bugfix b/packages/volto-slate/news/5452.bugfix similarity index 100% rename from packages/generator-volto/news/5452.bugfix rename to packages/volto-slate/news/5452.bugfix From 6fa7bc4083bf9bd23742769fa5472d47cf5a2958 Mon Sep 17 00:00:00 2001 From: kHAPPY2004 Date: Thu, 7 Dec 2023 00:10:19 +0530 Subject: [PATCH 3/5] improved changelog and fixed bug --- packages/volto-slate/news/5452.bugfix | 2 +- .../volto-slate/src/editor/plugins/Markdown/extensions.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/volto-slate/news/5452.bugfix b/packages/volto-slate/news/5452.bugfix index c6133b314e..6d436bbd62 100644 --- a/packages/volto-slate/news/5452.bugfix +++ b/packages/volto-slate/news/5452.bugfix @@ -1 +1 @@ -Fixed markup shortcut for heading and blockquote @kHAPPY2004 \ No newline at end of file +Fixed markup shortcut for heading and blockquote by passing 'at' to Transforms.setNodes api call for location of node @kHAPPY2004 \ No newline at end of file diff --git a/packages/volto-slate/src/editor/plugins/Markdown/extensions.js b/packages/volto-slate/src/editor/plugins/Markdown/extensions.js index b0de36f728..726895e134 100644 --- a/packages/volto-slate/src/editor/plugins/Markdown/extensions.js +++ b/packages/volto-slate/src/editor/plugins/Markdown/extensions.js @@ -197,7 +197,12 @@ export const autoformatBlock = (editor, type, at, { preFormat, format }) => { } if (!format) { - Transforms.setNodes(editor, { type }); + Transforms.setNodes( + editor, + { type }, + { at }, + { match: (n) => Editor.isBlock(editor, n) }, + ); } else { format(editor); } From 3e2cb77d08306782ea5e375034d47806ae4d4093 Mon Sep 17 00:00:00 2001 From: kHAPPY2004 Date: Thu, 7 Dec 2023 11:53:40 +0530 Subject: [PATCH 4/5] imporved changelog --- packages/volto-slate/news/5452.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/volto-slate/news/5452.bugfix b/packages/volto-slate/news/5452.bugfix index 6d436bbd62..7ba4c91476 100644 --- a/packages/volto-slate/news/5452.bugfix +++ b/packages/volto-slate/news/5452.bugfix @@ -1 +1 @@ -Fixed markup shortcut for heading and blockquote by passing 'at' to Transforms.setNodes api call for location of node @kHAPPY2004 \ No newline at end of file +In the Slate text block, the markup shortcuts for heading and blockquote work again. @kHAPPY2004 \ No newline at end of file From a7d59da58524c0423ca9e1c72891c7c190546b00 Mon Sep 17 00:00:00 2001 From: HAPPY_KAMBOJ <95476677+kHAPPY2004@users.noreply.github.com> Date: Thu, 7 Dec 2023 11:54:43 +0530 Subject: [PATCH 5/5] Update packages/volto-slate/news/5452.bugfix Co-authored-by: Steve Piercy --- packages/volto-slate/news/5452.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/volto-slate/news/5452.bugfix b/packages/volto-slate/news/5452.bugfix index 6d436bbd62..7ba4c91476 100644 --- a/packages/volto-slate/news/5452.bugfix +++ b/packages/volto-slate/news/5452.bugfix @@ -1 +1 @@ -Fixed markup shortcut for heading and blockquote by passing 'at' to Transforms.setNodes api call for location of node @kHAPPY2004 \ No newline at end of file +In the Slate text block, the markup shortcuts for heading and blockquote work again. @kHAPPY2004 \ No newline at end of file