From 4adb5d996c8ca25076e5aea8d8018287010721ad Mon Sep 17 00:00:00 2001 From: Roman Makovyak Date: Tue, 7 May 2019 14:21:14 +0200 Subject: [PATCH 1/3] Forward icon to redo/undo toolbar buttons --- lib/components/ToolbarDefaults.js | 6 +++ .../ToolbarDefaults.test.js.snap | 42 ++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/lib/components/ToolbarDefaults.js b/lib/components/ToolbarDefaults.js index 206e8850..ab61ec2a 100644 --- a/lib/components/ToolbarDefaults.js +++ b/lib/components/ToolbarDefaults.js @@ -185,6 +185,9 @@ class ToolbarDefaults extends PureComponent { onClick={onUndoRedo} label={getButtonLabel(UNDO_TYPE, showUndoControl)} title={getButtonTitle(UNDO_TYPE, showUndoControl)} + icon={ + typeof showUndoControl !== "boolean" ? showUndoControl.icon : null + } /> ) : null} @@ -194,6 +197,9 @@ class ToolbarDefaults extends PureComponent { onClick={onUndoRedo} label={getButtonLabel(REDO_TYPE, showRedoControl)} title={getButtonTitle(REDO_TYPE, showRedoControl)} + icon={ + typeof showRedoControl !== "boolean" ? showRedoControl.icon : null + } /> ) : null} , diff --git a/lib/components/__snapshots__/ToolbarDefaults.test.js.snap b/lib/components/__snapshots__/ToolbarDefaults.test.js.snap index 1f205527..ff0cc4ea 100644 --- a/lib/components/__snapshots__/ToolbarDefaults.test.js.snap +++ b/lib/components/__snapshots__/ToolbarDefaults.test.js.snap @@ -768,7 +768,7 @@ exports[`ToolbarDefaults #showRedoControl control overrides 1`] = ` > + + + + + @@ -910,7 +929,7 @@ exports[`ToolbarDefaults #showUndoControl control overrides 1`] = ` > + + + + + From 66155106d5f491f2f983f92b8bec2a586b08c7f5 Mon Sep 17 00:00:00 2001 From: Thibaud Colas Date: Thu, 1 Aug 2019 23:18:45 +0100 Subject: [PATCH 2/3] Add examples of icon overrides for undo/redo controls --- examples/constants/ui.js | 4 ++++ examples/docs.story.js | 8 ++++++++ examples/examples.story.js | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/examples/constants/ui.js b/examples/constants/ui.js index 1cfeadee..7b33d4d5 100644 --- a/examples/constants/ui.js +++ b/examples/constants/ui.js @@ -19,6 +19,10 @@ export const EMBED_ICON = ; export const BR_ICON = "M.436 633.471l296.897-296.898v241.823h616.586V94.117h109.517v593.796H297.333v242.456z"; +export const UNDO_ICON = + "M496.485 78c-137.092 0-261.213 55.575-351.046 145.439L.031 78v372.364h372.364L233.224 311.193c67.398-67.398 160.488-109.072 263.292-109.072 205.638 0 372.364 166.726 372.364 372.364 0 111.212-48.78 211.037-126.077 279.273l82.107 93.09C927.992 855.868 993 722.778 993 574.485 993 300.27 770.73 78 496.517 78h-.031z"; +export const REDO_ICON = + "M0 576c0 152.928 67.04 290.176 173.344 384l84.672-96C178.304 793.632 128 690.688 128 576c0-212.064 171.936-384 384-384 106.048 0 202.048 42.976 271.52 112.48L640 448h384V64L874.016 213.984C781.376 121.312 653.376 64 512 64 229.216 64 0 293.216 0 576z"; export const INLINE_CONTROL = { BOLD: { type: INLINE_STYLE.BOLD, icon: "#icon-bold" }, diff --git a/examples/docs.story.js b/examples/docs.story.js index b5ce8ddd..c467ce7d 100644 --- a/examples/docs.story.js +++ b/examples/docs.story.js @@ -13,6 +13,8 @@ import { ENTITY_CONTROL, REDACTED_STYLE, BR_ICON, + UNDO_ICON, + REDO_ICON, } from "./constants/ui"; import EditorWrapper from "./components/EditorWrapper"; @@ -318,6 +320,12 @@ storiesOf("Docs", module) REDACTED_STYLE, ]} entityTypes={[ENTITY_CONTROL.EMBED]} + showUndoControl={{ + icon: UNDO_ICON, + }} + showRedoControl={{ + icon: REDO_ICON, + }} /> )) .add("i18n", () => { diff --git a/examples/examples.story.js b/examples/examples.story.js index 5bcce735..d7e0d54c 100644 --- a/examples/examples.story.js +++ b/examples/examples.story.js @@ -7,6 +7,8 @@ import { BLOCK_CONTROL, ENTITY_CONTROL, BR_ICON, + UNDO_ICON, + REDO_ICON, TINY_TEXT_BLOCK, REDACTED_STYLE, } from "./constants/ui"; @@ -106,9 +108,11 @@ storiesOf("Examples", module) }} showUndoControl={{ description: "Undo last change", + icon: UNDO_ICON, }} showRedoControl={{ description: "Redo last change", + icon: REDO_ICON, }} maxListNesting={6} blockTypes={Object.values(BLOCK_CONTROL)} From cd0a6c61a140accfb08871f07cff9bfd5ccf6349 Mon Sep 17 00:00:00 2001 From: Thibaud Colas Date: Thu, 1 Aug 2019 23:28:27 +0100 Subject: [PATCH 3/3] Add release notes for #195 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41a24f86..a31f4ddc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ > Documentation: [draftail.org/docs/next/getting-started](https://www.draftail.org/docs/next/getting-started) +### Fixed + +- Fix undo/redo button icons not being customisable ([#195](https://github.com/springload/draftail/issues/195), [#196](https://github.com/springload/draftail/pull/196)). + ## [[v1.2.1]](https://github.com/springload/draftail/releases/tag/v1.2.1) > Documentation: [draftail.org/docs/getting-started](https://www.draftail.org/docs/getting-started)