From 239365705c6d58a2106be40307a7a6c426986ceb Mon Sep 17 00:00:00 2001 From: Thibaud Colas Date: Thu, 18 Jan 2018 18:31:15 +0200 Subject: [PATCH] Finish making Draftail toolbar translatable --- client/src/components/Draftail/index.js | 11 ++++++++--- client/tests/stubs.js | 4 ++++ wagtail/admin/templates/wagtailadmin/admin_base.html | 4 ++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/client/src/components/Draftail/index.js b/client/src/components/Draftail/index.js index fbed11f67..a89ace08c 100644 --- a/client/src/components/Draftail/index.js +++ b/client/src/components/Draftail/index.js @@ -58,6 +58,10 @@ export const initEditor = (fieldName, options = {}) => { ); } + const enableHorizontalRule = options && options.enableHorizontalRule ? { + description: STRINGS.HORIZONTAL_LINE, + } : false; + const fieldValue = JSON.parse(field.value); // TODO Remove default null when finishing https://github.com/springload/wagtaildraftail/issues/32. const rawContentState = @@ -69,9 +73,9 @@ export const initEditor = (fieldName, options = {}) => { onSave={serialiseInputValue} placeholder={STRINGS.WRITE_HERE} spellCheck={true} - enableLineBreak={true} - showUndoControl={true} - showRedoControl={true} + enableLineBreak={{ description: STRINGS.LINE_BREAK }} + showUndoControl={{ description: STRINGS.UNDO }} + showRedoControl={{ description: STRINGS.REDO }} // If increasing above 4, we will need to add styles for the extra nesting levels. maxListNesting={4} // Draft.js + IE 11 presents some issues with pasting rich text. Disable rich paste there. @@ -80,6 +84,7 @@ export const initEditor = (fieldName, options = {}) => { blockTypes={blockTypes} inlineStyles={inlineStyles} entityTypes={entityTypes} + enableHorizontalRule={enableHorizontalRule} /> ); diff --git a/client/tests/stubs.js b/client/tests/stubs.js index 773541c6c..b59441030 100644 --- a/client/tests/stubs.js +++ b/client/tests/stubs.js @@ -31,6 +31,10 @@ global.wagtailConfig = { CLOSE_EXPLORER: 'Close explorer', ALT_TEXT: 'Alt text', WRITE_HERE: 'Write here…', + HORIZONTAL_LINE: 'Horizontal line', + LINE_BREAK: 'Line break', + UNDO: 'Undo', + REDO: 'Redo', }, }; diff --git a/wagtail/admin/templates/wagtailadmin/admin_base.html b/wagtail/admin/templates/wagtailadmin/admin_base.html index 21a02a21d..88929f6a1 100644 --- a/wagtail/admin/templates/wagtailadmin/admin_base.html +++ b/wagtail/admin/templates/wagtailadmin/admin_base.html @@ -40,6 +40,10 @@ CLOSE_EXPLORER: "{% trans 'Close explorer' %}", ALT_TEXT: "{% trans 'Alt text' %}", WRITE_HERE: "{% trans 'Write here…' %}", + HORIZONTAL_LINE: "{% trans 'Horizontal line' %}", + LINE_BREAK: "{% trans 'Line break' %}", + UNDO: "{% trans 'Undo' %}", + REDO: "{% trans 'Redo' %}", }; wagtailConfig.ADMIN_URLS = {