Skip to content

Commit 0c7d327

Browse files
feat: implement strikethrough functionality to markdown editor (#7625)
Co-authored-by: Martin Jagodic <jagodicmartin1@gmail.com>
1 parent 7576d1c commit 0c7d327

File tree

7 files changed

+18
-1
lines changed

7 files changed

+18
-1
lines changed

cypress/support/commands.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ Cypress.Commands.add('insertEditorComponent', title => {
271271
['clickUnorderedListButton', 'Bulleted List'],
272272
['clickCodeButton', 'Code'],
273273
['clickItalicButton', 'Italic'],
274+
['clickStrikethroughButton', 'Strikethrough'],
274275
['clickQuoteButton', 'Quote'],
275276
['clickLinkButton', 'Link'],
276277
].forEach(([commandName, toolbarButtonName]) => {

packages/decap-cms-locales/src/en/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ const en = {
157157
markdown: {
158158
bold: 'Bold',
159159
italic: 'Italic',
160+
strikethrough: 'Strikethrough',
160161
code: 'Code',
161162
link: 'Link',
162163
linkPrompt: 'Enter the URL of the link',

packages/decap-cms-ui-default/src/Icon/images/_index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import iconRefresh from './refresh.svg';
4242
import iconScroll from './scroll.svg';
4343
import iconSearch from './search.svg';
4444
import iconSettings from './settings.svg';
45+
import iconStrikethrough from './strikethrough.svg';
4546
import iconUser from './user.svg';
4647
import iconWorkflow from './workflow.svg';
4748
import iconWrite from './write.svg';
@@ -94,6 +95,7 @@ const images = {
9495
scroll: iconScroll,
9596
search: iconSearch,
9697
settings: iconSettings,
98+
strikethrough: iconStrikethrough,
9799
user: iconUser,
98100
workflow: iconWorkflow,
99101
write: iconWrite,
Lines changed: 1 addition & 0 deletions
Loading

packages/decap-cms-widget-markdown/src/MarkdownControl/Toolbar.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@ export default class Toolbar extends React.Component {
160160
disabled={disabled}
161161
/>
162162
)}
163+
{isVisible('strikethrough') && (
164+
<ToolbarButton
165+
type="strikethrough"
166+
label={t('editor.editorWidgets.markdown.strikethrough')}
167+
icon="strikethrough"
168+
onClick={this.handleMarkClick}
169+
isActive={hasMark('delete')}
170+
disabled={disabled}
171+
/>
172+
)}
163173
{isVisible('code') && (
164174
<ToolbarButton
165175
type="code"

packages/decap-cms-widget-markdown/src/MarkdownControl/VisualEditor.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ function Editor(props) {
141141

142142
function handleMarkClick(format) {
143143
ReactEditor.focus(editor);
144-
toggleMark(editor, format);
144+
const markFormat = format === 'strikethrough' ? 'delete' : format;
145+
toggleMark(editor, markFormat);
145146
}
146147

147148
function handleBlockClick(format) {

packages/decap-cms-widget-markdown/src/schema.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default {
88
enum: [
99
'bold',
1010
'italic',
11+
'strikethrough',
1112
'code',
1213
'link',
1314
'heading-one',

0 commit comments

Comments
 (0)