From 017601d20e00967d9d60f503f48808f7639c9f29 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Wed, 24 Oct 2018 14:46:45 +0800 Subject: [PATCH 1/8] Add state to determine whether the caret is currently within formatting --- packages/editor/src/store/actions.js | 65 ++++++++++ packages/editor/src/store/reducer.js | 21 ++++ packages/editor/src/store/selectors.js | 11 ++ packages/editor/src/store/test/actions.js | 132 ++++++++++++++++++++ packages/editor/src/store/test/reducer.js | 19 +++ packages/editor/src/store/test/selectors.js | 19 +++ 6 files changed, 267 insertions(+) diff --git a/packages/editor/src/store/actions.js b/packages/editor/src/store/actions.js index b173122b4e3c9d..db1cb62fe1470f 100644 --- a/packages/editor/src/store/actions.js +++ b/packages/editor/src/store/actions.js @@ -535,6 +535,71 @@ export function stopTyping() { }; } +/** + * Returns an action object used in signalling that the caret has entered formatted text. + * + * @return {Object} Action object. + */ +export function enterFormattedText() { + return { + type: 'ENTER_FORMATTED_TEXT', + }; +} + +/** + * Returns an action object used in signalling that the user caret has left formatted text. + * + * @return {Object} Action object. + */ +export function leaveFormattedText() { + return { + type: 'LEAVE_FORMATTED_TEXT', + }; +} + +/** + * Returns an action object used to create a notice. + * + * @param {string} status The notice status. + * @param {WPElement} content The notice content. + * @param {?Object} options The notice options. Available options: + * `id` (string; default auto-generated) + * `isDismissible` (boolean; default `true`). + * + * @return {Object} Action object. + */ +export function createNotice( status, content, options = {} ) { + const { + id = uuid(), + isDismissible = true, + spokenMessage, + } = options; + return { + type: 'CREATE_NOTICE', + notice: { + id, + status, + content, + isDismissible, + spokenMessage, + }, + }; +} + +/** + * Returns an action object used to remove a notice. + * + * @param {string} id The notice id. + * + * @return {Object} Action object. + */ +export function removeNotice( id ) { + return { + type: 'REMOVE_NOTICE', + noticeId: id, + }; +} + /** * Returns an action object used to lock the editor. * diff --git a/packages/editor/src/store/reducer.js b/packages/editor/src/store/reducer.js index 0e9b477eac5d95..3b8cc81fbea160 100644 --- a/packages/editor/src/store/reducer.js +++ b/packages/editor/src/store/reducer.js @@ -584,6 +584,26 @@ export function isTyping( state = false, action ) { return state; } +/** + * Reducer returning whether the caret is within formatted text. + * + * @param {boolean} state Current state. + * @param {Object} action Dispatched action. + * + * @return {boolean} Updated state. + */ +export function isCaretWithinFormattedText( state = false, action ) { + switch ( action.type ) { + case 'ENTER_FORMATTED_TEXT': + return true; + + case 'LEAVE_FORMATTED_TEXT': + return false; + } + + return state; +} + /** * Reducer returning the block selection's state. * @@ -1093,6 +1113,7 @@ export default optimist( combineReducers( { editor, currentPost, isTyping, + isCaretWithinFormattedText, blockSelection, blocksMode, blockListSettings, diff --git a/packages/editor/src/store/selectors.js b/packages/editor/src/store/selectors.js index d82d4edef0cf10..df1ccae61d91df 100644 --- a/packages/editor/src/store/selectors.js +++ b/packages/editor/src/store/selectors.js @@ -1255,6 +1255,17 @@ export function isTyping( state ) { return state.isTyping; } +/** + * Returns true if the caret is within formatted text, or false otherwise. + * + * @param {Object} state Global application state. + * + * @return {boolean} Whether the caret is within formatted text. + */ +export function isCaretWithinFormattedText( state ) { + return state.isCaretWithinFormattedText; +} + /** * Returns the insertion point, the index at which the new inserted block would * be placed. Defaults to the last index. diff --git a/packages/editor/src/store/test/actions.js b/packages/editor/src/store/test/actions.js index b2ab5cf6c91453..1437d874235db4 100644 --- a/packages/editor/src/store/test/actions.js +++ b/packages/editor/src/store/test/actions.js @@ -5,6 +5,14 @@ import { replaceBlocks, startTyping, stopTyping, + createNotice, + createErrorNotice, + createInfoNotice, + createSuccessNotice, + createWarningNotice, + removeNotice, + enterFormattedText, + leaveFormattedText, fetchReusableBlocks, saveReusableBlock, deleteReusableBlock, @@ -344,6 +352,130 @@ describe( 'actions', () => { } ); } ); + describe( 'enterFormattedText', () => { + it( 'should return the ENTER_FORMATTED_TEXT action', () => { + expect( enterFormattedText() ).toEqual( { + type: 'ENTER_FORMATTED_TEXT', + } ); + } ); + } ); + + describe( 'leaveFormattedText', () => { + it( 'should return the LEAVE_FORMATTED_TEXT action', () => { + expect( leaveFormattedText() ).toEqual( { + type: 'LEAVE_FORMATTED_TEXT', + } ); + } ); + } ); + + describe( 'createNotice', () => { + const status = 'status'; + const content =

element

; + it( 'should return CREATE_NOTICE action when options is empty', () => { + const result = createNotice( status, content ); + expect( result ).toMatchObject( { + type: 'CREATE_NOTICE', + notice: { + status, + content, + isDismissible: true, + id: expect.any( String ), + }, + } ); + } ); + it( 'should return CREATE_NOTICE action when options is desined', () => { + const id = 'my-id'; + const options = { + id, + isDismissible: false, + }; + const result = createNotice( status, content, options ); + expect( result ).toEqual( { + type: 'CREATE_NOTICE', + notice: { + id, + status, + content, + isDismissible: false, + }, + } ); + } ); + } ); + + describe( 'createSuccessNotice', () => { + it( 'should return CREATE_NOTICE action', () => { + const content =

element

; + const result = createSuccessNotice( content ); + expect( result ).toMatchObject( { + type: 'CREATE_NOTICE', + notice: { + status: 'success', + content, + isDismissible: true, + id: expect.any( String ), + }, + } ); + } ); + } ); + + describe( 'createInfoNotice', () => { + it( 'should return CREATE_NOTICE action', () => { + const content =

element

; + const result = createInfoNotice( content ); + expect( result ).toMatchObject( { + type: 'CREATE_NOTICE', + notice: { + status: 'info', + content, + isDismissible: true, + id: expect.any( String ), + }, + } ); + } ); + } ); + + describe( 'createErrorNotice', () => { + it( 'should return CREATE_NOTICE action', () => { + const content =

element

; + const result = createErrorNotice( content ); + expect( result ).toMatchObject( { + type: 'CREATE_NOTICE', + notice: { + status: 'error', + content, + isDismissible: true, + id: expect.any( String ), + }, + } ); + } ); + } ); + + describe( 'createWarningNotice', () => { + it( 'should return CREATE_NOTICE action', () => { + const content =

element

; + const result = createWarningNotice( content ); + expect( result ).toMatchObject( { + type: 'CREATE_NOTICE', + notice: { + status: 'warning', + content, + isDismissible: true, + id: expect.any( String ), + }, + } ); + } ); + } ); + + describe( 'removeNotice', () => { + it( 'should return REMOVE_NOTICE actions', () => { + const noticeId = 'id'; + expect( removeNotice( noticeId ) ).toEqual( { + type: 'REMOVE_NOTICE', + noticeId, + } ); + } ); + } ); + describe( 'fetchReusableBlocks', () => { it( 'should return the FETCH_REUSABLE_BLOCKS action', () => { expect( fetchReusableBlocks() ).toEqual( { diff --git a/packages/editor/src/store/test/reducer.js b/packages/editor/src/store/test/reducer.js index 9ebca4c39c10c8..788d0238db2187 100644 --- a/packages/editor/src/store/test/reducer.js +++ b/packages/editor/src/store/test/reducer.js @@ -25,6 +25,7 @@ import { editor, currentPost, isTyping, + isCaretWithinFormattedText, blockSelection, preferences, saving, @@ -1315,6 +1316,24 @@ describe( 'state', () => { } ); } ); + describe( 'isCaretWithinFormattedText()', () => { + it( 'should set the flag to true', () => { + const state = isCaretWithinFormattedText( false, { + type: 'ENTER_FORMATTED_TEXT', + } ); + + expect( state ).toBe( true ); + } ); + + it( 'should set the flag to false', () => { + const state = isCaretWithinFormattedText( true, { + type: 'LEAVE_FORMATTED_TEXT', + } ); + + expect( state ).toBe( false ); + } ); + } ); + describe( 'blockSelection()', () => { it( 'should return with block clientId as selected', () => { const state = blockSelection( undefined, { diff --git a/packages/editor/src/store/test/selectors.js b/packages/editor/src/store/test/selectors.js index 108f8dcf69e01d..bd348c1357ead7 100644 --- a/packages/editor/src/store/test/selectors.js +++ b/packages/editor/src/store/test/selectors.js @@ -82,6 +82,7 @@ const { isFirstMultiSelectedBlock, getBlockMode, isTyping, + isCaretWithinFormattedText, getBlockInsertionPoint, isBlockInsertionPointVisible, isSavingPost, @@ -2719,6 +2720,24 @@ describe( 'selectors', () => { } ); } ); + describe( 'isCaretWithinFormattedText', () => { + it( 'returns true if the isCaretWithinFormattedText state is also true', () => { + const state = { + isCaretWithinFormattedText: true, + }; + + expect( isCaretWithinFormattedText( state ) ).toBe( true ); + } ); + + it( 'returns false if the isCaretWithinFormattedText state is also false', () => { + const state = { + isCaretWithinFormattedText: false, + }; + + expect( isCaretWithinFormattedText( state ) ).toBe( false ); + } ); + } ); + describe( 'isSelectionEnabled', () => { it( 'should return true if selection is enable', () => { const state = { From 0bdbc2be8d12b76f6ca2ef2e3c35ace0e2843f3c Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Wed, 24 Oct 2018 15:26:42 +0800 Subject: [PATCH 2/8] Show toolbar when the caret is positioned within formatting --- packages/editor/src/components/block-list/block.js | 5 ++++- packages/editor/src/components/rich-text/index.js | 12 +++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/editor/src/components/block-list/block.js b/packages/editor/src/components/block-list/block.js index 498c79c3da5534..d7493ee0810b60 100644 --- a/packages/editor/src/components/block-list/block.js +++ b/packages/editor/src/components/block-list/block.js @@ -372,6 +372,7 @@ export class BlockListBlock extends Component { isPartOfMultiSelection, isFirstMultiSelected, isTypingWithinBlock, + isCaretWithinFormattedText, isMultiSelecting, hoverArea, isEmptyDefaultBlock, @@ -399,7 +400,7 @@ export class BlockListBlock extends Component { // We render block movers and block settings to keep them tabbale even if hidden const shouldRenderMovers = ! isFocusMode && ( isSelected || hoverArea === 'left' ) && ! showEmptyBlockSideInserter && ! isMultiSelecting && ! isPartOfMultiSelection && ! isTypingWithinBlock; const shouldShowBreadcrumb = ! isFocusMode && isHovered && ! isEmptyDefaultBlock; - const shouldShowContextualToolbar = ! hasFixedToolbar && ! showSideInserter && ( ( isSelected && ! isTypingWithinBlock ) || isFirstMultiSelected ); + const shouldShowContextualToolbar = ! hasFixedToolbar && ! showSideInserter && ( ( isSelected && ( ! isTypingWithinBlock || isCaretWithinFormattedText ) ) || isFirstMultiSelected ); const shouldShowMobileToolbar = shouldAppearSelected; const { error, dragging } = this.state; @@ -588,6 +589,7 @@ const applyWithSelect = withSelect( ( select, { clientId, rootClientId, isLargeV isFirstMultiSelectedBlock, isMultiSelecting, isTyping, + isCaretWithinFormattedText, getBlockIndex, getEditedPostAttribute, getBlockMode, @@ -613,6 +615,7 @@ const applyWithSelect = withSelect( ( select, { clientId, rootClientId, isLargeV // We only care about this prop when the block is selected // Thus to avoid unnecessary rerenders we avoid updating the prop if the block is not selected. isTypingWithinBlock: ( isSelected || isParentOfSelectedBlock ) && isTyping(), + isCaretWithinFormattedText: isCaretWithinFormattedText(), order: getBlockIndex( clientId, rootClientId ), meta: getEditedPostAttribute( 'meta' ), mode: getBlockMode( clientId ), diff --git a/packages/editor/src/components/rich-text/index.js b/packages/editor/src/components/rich-text/index.js index 20cf3555bb8bda..fbe5b7a0e4fdef 100644 --- a/packages/editor/src/components/rich-text/index.js +++ b/packages/editor/src/components/rich-text/index.js @@ -424,7 +424,13 @@ export class RichText extends Component { return; } - const { start, end } = this.createRecord(); + const { start, end, formats } = this.createRecord(); + + if ( formats[ start ] ) { + this.props.onEnterFormattedText(); + } else { + this.props.onLeaveFormattedText(); + } if ( start !== this.state.start || end !== this.state.end ) { this.setState( { start, end } ); @@ -962,12 +968,16 @@ const RichTextContainer = compose( [ createUndoLevel, redo, undo, + enterFormattedText, + leaveFormattedText, } = dispatch( 'core/editor' ); return { onCreateUndoLevel: createUndoLevel, onRedo: redo, onUndo: undo, + onEnterFormattedText: enterFormattedText, + onLeaveFormattedText: leaveFormattedText, }; } ), withSafeTimeout, From 45c09f53f134f0bded6b4206ce6724ac01495de7 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Mon, 22 Oct 2018 18:35:48 +0800 Subject: [PATCH 3/8] Add e2e test covering modifying an existing link using the keyboard --- test/e2e/specs/links.test.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/e2e/specs/links.test.js b/test/e2e/specs/links.test.js index 23546f8c72045f..850ad3d07afc9b 100644 --- a/test/e2e/specs/links.test.js +++ b/test/e2e/specs/links.test.js @@ -388,4 +388,36 @@ describe( 'Links', () => { await page.keyboard.press( 'Escape' ); expect( await page.$( '.editor-url-popover' ) ).toBeNull(); } ); + + it( 'can be modified using the keyboard once a link has been set', async () => { + const URL = 'https://wordpress.org/gutenberg'; + + // Create a block with some text and format it as a link. + await clickBlockAppender(); + await page.keyboard.type( 'This is Gutenberg' ); + await pressWithModifier( SELECT_WORD_MODIFIER_KEYS, 'ArrowLeft' ); + await pressWithModifier( META_KEY, 'K' ); + await waitForAutoFocus(); + await page.keyboard.type( URL ); + await page.keyboard.press( 'Enter' ); + + // Deselect the link text by moving the caret to the end of the line + // and the link popover should not be displayed. + await page.keyboard.press( 'End' ); + expect( await page.$( '.editor-url-popover' ) ).toBeNull(); + + // Move the caret back into the link text and the link popover + // should be displayed. + await page.keyboard.press( 'ArrowLeft' ); + expect( await page.$( '.editor-url-popover' ) ).not.toBeNull(); + + // Press Cmd+K to edit the link and the url-input should become + // focused with the value previously inserted. + await pressWithModifier( META_KEY, 'K' ); + await waitForAutoFocus(); + const activeElementParentClasses = await page.evaluate( () => Object.values( document.activeElement.parentElement.classList ) ); + expect( activeElementParentClasses ).toContain( 'editor-url-input' ); + const activeElementValue = await page.evaluate( () => document.activeElement.value ); + expect( activeElementValue ).toBe( URL ); + } ); } ); From fd432f0f6afe2a1c47b435598e41a83e6aab64be Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Wed, 24 Oct 2018 17:36:32 +0800 Subject: [PATCH 4/8] Update docs --- docs/data/data-core-editor.md | 42 +++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/docs/data/data-core-editor.md b/docs/data/data-core-editor.md index 0fc957c749a0c4..9c8e115b7caa29 100644 --- a/docs/data/data-core-editor.md +++ b/docs/data/data-core-editor.md @@ -907,6 +907,18 @@ Returns true if the user is typing, or false otherwise. Whether user is typing. +### isCaretWithinFormattedText + +Returns true if the caret is within formatted text, or false otherwise. + +*Parameters* + + * state: Global application state. + +*Returns* + +Whether the caret is within formatted text. + ### getBlockInsertionPoint Returns the insertion point, the index at which the new inserted block would @@ -1623,6 +1635,34 @@ Returns an action object used in signalling that the user has begun to type. Returns an action object used in signalling that the user has stopped typing. +### enterFormattedText + +Returns an action object used in signalling that the caret has entered formatted text. + +### leaveFormattedText + +Returns an action object used in signalling that the user caret has left formatted text. + +### createNotice + +Returns an action object used to create a notice. + +*Parameters* + + * status: The notice status. + * content: The notice content. + * options: The notice options. Available options: + `id` (string; default auto-generated) + `isDismissible` (boolean; default `true`). + +### removeNotice + +Returns an action object used to remove a notice. + +*Parameters* + + * id: The notice id. + ### updatePostLock Returns an action object used to lock the editor. @@ -1757,5 +1797,3 @@ Returns an action object signaling that a new term is added to the edited post. * slug: Taxonomy slug. * term: Term object. - -### createNotice \ No newline at end of file From ec5bfb3a43993f14c37f1b0c55db7af153240565 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Thu, 25 Oct 2018 16:43:20 +0800 Subject: [PATCH 5/8] Change leave to exit --- docs/data/data-core-editor.md | 4 ++-- packages/editor/src/components/rich-text/index.js | 6 +++--- packages/editor/src/store/actions.js | 6 +++--- packages/editor/src/store/reducer.js | 2 +- packages/editor/src/store/test/actions.js | 10 +++++----- packages/editor/src/store/test/reducer.js | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/data/data-core-editor.md b/docs/data/data-core-editor.md index 9c8e115b7caa29..2ea8cae8336d66 100644 --- a/docs/data/data-core-editor.md +++ b/docs/data/data-core-editor.md @@ -1639,9 +1639,9 @@ Returns an action object used in signalling that the user has stopped typing. Returns an action object used in signalling that the caret has entered formatted text. -### leaveFormattedText +### exitFormattedText -Returns an action object used in signalling that the user caret has left formatted text. +Returns an action object used in signalling that the user caret has exited formatted text. ### createNotice diff --git a/packages/editor/src/components/rich-text/index.js b/packages/editor/src/components/rich-text/index.js index fbe5b7a0e4fdef..49574450ccb8c4 100644 --- a/packages/editor/src/components/rich-text/index.js +++ b/packages/editor/src/components/rich-text/index.js @@ -429,7 +429,7 @@ export class RichText extends Component { if ( formats[ start ] ) { this.props.onEnterFormattedText(); } else { - this.props.onLeaveFormattedText(); + this.props.onExitFormattedText(); } if ( start !== this.state.start || end !== this.state.end ) { @@ -969,7 +969,7 @@ const RichTextContainer = compose( [ redo, undo, enterFormattedText, - leaveFormattedText, + exitFormattedText, } = dispatch( 'core/editor' ); return { @@ -977,7 +977,7 @@ const RichTextContainer = compose( [ onRedo: redo, onUndo: undo, onEnterFormattedText: enterFormattedText, - onLeaveFormattedText: leaveFormattedText, + onExitFormattedText: exitFormattedText, }; } ), withSafeTimeout, diff --git a/packages/editor/src/store/actions.js b/packages/editor/src/store/actions.js index db1cb62fe1470f..69c94e45f769e1 100644 --- a/packages/editor/src/store/actions.js +++ b/packages/editor/src/store/actions.js @@ -547,13 +547,13 @@ export function enterFormattedText() { } /** - * Returns an action object used in signalling that the user caret has left formatted text. + * Returns an action object used in signalling that the user caret has exited formatted text. * * @return {Object} Action object. */ -export function leaveFormattedText() { +export function exitFormattedText() { return { - type: 'LEAVE_FORMATTED_TEXT', + type: 'EXIT_FORMATTED_TEXT', }; } diff --git a/packages/editor/src/store/reducer.js b/packages/editor/src/store/reducer.js index 3b8cc81fbea160..e3472344f58c11 100644 --- a/packages/editor/src/store/reducer.js +++ b/packages/editor/src/store/reducer.js @@ -597,7 +597,7 @@ export function isCaretWithinFormattedText( state = false, action ) { case 'ENTER_FORMATTED_TEXT': return true; - case 'LEAVE_FORMATTED_TEXT': + case 'EXIT_FORMATTED_TEXT': return false; } diff --git a/packages/editor/src/store/test/actions.js b/packages/editor/src/store/test/actions.js index 1437d874235db4..598fc9eb66925c 100644 --- a/packages/editor/src/store/test/actions.js +++ b/packages/editor/src/store/test/actions.js @@ -12,7 +12,7 @@ import { createWarningNotice, removeNotice, enterFormattedText, - leaveFormattedText, + exitFormattedText, fetchReusableBlocks, saveReusableBlock, deleteReusableBlock, @@ -360,10 +360,10 @@ describe( 'actions', () => { } ); } ); - describe( 'leaveFormattedText', () => { - it( 'should return the LEAVE_FORMATTED_TEXT action', () => { - expect( leaveFormattedText() ).toEqual( { - type: 'LEAVE_FORMATTED_TEXT', + describe( 'exitFormattedText', () => { + it( 'should return the EXIT_FORMATTED_TEXT action', () => { + expect( exitFormattedText() ).toEqual( { + type: 'EXIT_FORMATTED_TEXT', } ); } ); } ); diff --git a/packages/editor/src/store/test/reducer.js b/packages/editor/src/store/test/reducer.js index 788d0238db2187..c0462df96f4112 100644 --- a/packages/editor/src/store/test/reducer.js +++ b/packages/editor/src/store/test/reducer.js @@ -1327,7 +1327,7 @@ describe( 'state', () => { it( 'should set the flag to false', () => { const state = isCaretWithinFormattedText( true, { - type: 'LEAVE_FORMATTED_TEXT', + type: 'EXIT_FORMATTED_TEXT', } ); expect( state ).toBe( false ); From 861c00cf5fbe956a903c45e5e344a45039375c27 Mon Sep 17 00:00:00 2001 From: "Matthew Riley MacPherson (tofumatt)" Date: Sat, 27 Oct 2018 11:59:51 +0100 Subject: [PATCH 6/8] chore: Fix rebase issue --- packages/editor/src/store/actions.js | 43 -------- packages/editor/src/store/test/actions.js | 114 ---------------------- 2 files changed, 157 deletions(-) diff --git a/packages/editor/src/store/actions.js b/packages/editor/src/store/actions.js index 69c94e45f769e1..d074b85ae3d4e9 100644 --- a/packages/editor/src/store/actions.js +++ b/packages/editor/src/store/actions.js @@ -557,49 +557,6 @@ export function exitFormattedText() { }; } -/** - * Returns an action object used to create a notice. - * - * @param {string} status The notice status. - * @param {WPElement} content The notice content. - * @param {?Object} options The notice options. Available options: - * `id` (string; default auto-generated) - * `isDismissible` (boolean; default `true`). - * - * @return {Object} Action object. - */ -export function createNotice( status, content, options = {} ) { - const { - id = uuid(), - isDismissible = true, - spokenMessage, - } = options; - return { - type: 'CREATE_NOTICE', - notice: { - id, - status, - content, - isDismissible, - spokenMessage, - }, - }; -} - -/** - * Returns an action object used to remove a notice. - * - * @param {string} id The notice id. - * - * @return {Object} Action object. - */ -export function removeNotice( id ) { - return { - type: 'REMOVE_NOTICE', - noticeId: id, - }; -} - /** * Returns an action object used to lock the editor. * diff --git a/packages/editor/src/store/test/actions.js b/packages/editor/src/store/test/actions.js index 598fc9eb66925c..9c776f0cc47e80 100644 --- a/packages/editor/src/store/test/actions.js +++ b/packages/editor/src/store/test/actions.js @@ -5,12 +5,6 @@ import { replaceBlocks, startTyping, stopTyping, - createNotice, - createErrorNotice, - createInfoNotice, - createSuccessNotice, - createWarningNotice, - removeNotice, enterFormattedText, exitFormattedText, fetchReusableBlocks, @@ -368,114 +362,6 @@ describe( 'actions', () => { } ); } ); - describe( 'createNotice', () => { - const status = 'status'; - const content =

element

; - it( 'should return CREATE_NOTICE action when options is empty', () => { - const result = createNotice( status, content ); - expect( result ).toMatchObject( { - type: 'CREATE_NOTICE', - notice: { - status, - content, - isDismissible: true, - id: expect.any( String ), - }, - } ); - } ); - it( 'should return CREATE_NOTICE action when options is desined', () => { - const id = 'my-id'; - const options = { - id, - isDismissible: false, - }; - const result = createNotice( status, content, options ); - expect( result ).toEqual( { - type: 'CREATE_NOTICE', - notice: { - id, - status, - content, - isDismissible: false, - }, - } ); - } ); - } ); - - describe( 'createSuccessNotice', () => { - it( 'should return CREATE_NOTICE action', () => { - const content =

element

; - const result = createSuccessNotice( content ); - expect( result ).toMatchObject( { - type: 'CREATE_NOTICE', - notice: { - status: 'success', - content, - isDismissible: true, - id: expect.any( String ), - }, - } ); - } ); - } ); - - describe( 'createInfoNotice', () => { - it( 'should return CREATE_NOTICE action', () => { - const content =

element

; - const result = createInfoNotice( content ); - expect( result ).toMatchObject( { - type: 'CREATE_NOTICE', - notice: { - status: 'info', - content, - isDismissible: true, - id: expect.any( String ), - }, - } ); - } ); - } ); - - describe( 'createErrorNotice', () => { - it( 'should return CREATE_NOTICE action', () => { - const content =

element

; - const result = createErrorNotice( content ); - expect( result ).toMatchObject( { - type: 'CREATE_NOTICE', - notice: { - status: 'error', - content, - isDismissible: true, - id: expect.any( String ), - }, - } ); - } ); - } ); - - describe( 'createWarningNotice', () => { - it( 'should return CREATE_NOTICE action', () => { - const content =

element

; - const result = createWarningNotice( content ); - expect( result ).toMatchObject( { - type: 'CREATE_NOTICE', - notice: { - status: 'warning', - content, - isDismissible: true, - id: expect.any( String ), - }, - } ); - } ); - } ); - - describe( 'removeNotice', () => { - it( 'should return REMOVE_NOTICE actions', () => { - const noticeId = 'id'; - expect( removeNotice( noticeId ) ).toEqual( { - type: 'REMOVE_NOTICE', - noticeId, - } ); - } ); - } ); - describe( 'fetchReusableBlocks', () => { it( 'should return the FETCH_REUSABLE_BLOCKS action', () => { expect( fetchReusableBlocks() ).toEqual( { From 6c0a2b729e14edbf38bec26673edde96cb1ebd85 Mon Sep 17 00:00:00 2001 From: "Matthew Riley MacPherson (tofumatt)" Date: Sat, 27 Oct 2018 12:00:42 +0100 Subject: [PATCH 7/8] Fix docs rebase issue --- docs/data/data-core-editor.md | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/docs/data/data-core-editor.md b/docs/data/data-core-editor.md index 2ea8cae8336d66..f57266a4687fb7 100644 --- a/docs/data/data-core-editor.md +++ b/docs/data/data-core-editor.md @@ -1643,26 +1643,6 @@ Returns an action object used in signalling that the caret has entered formatted Returns an action object used in signalling that the user caret has exited formatted text. -### createNotice - -Returns an action object used to create a notice. - -*Parameters* - - * status: The notice status. - * content: The notice content. - * options: The notice options. Available options: - `id` (string; default auto-generated) - `isDismissible` (boolean; default `true`). - -### removeNotice - -Returns an action object used to remove a notice. - -*Parameters* - - * id: The notice id. - ### updatePostLock Returns an action object used to lock the editor. From 97dfc04b92c4a317373f041d4a14b8e6a21f5112 Mon Sep 17 00:00:00 2001 From: "Matthew Riley MacPherson (tofumatt)" Date: Sat, 27 Oct 2018 21:14:19 +0100 Subject: [PATCH 8/8] fix docs --- docs/data/data-core-editor.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/data/data-core-editor.md b/docs/data/data-core-editor.md index f57266a4687fb7..6554b8d7535bdc 100644 --- a/docs/data/data-core-editor.md +++ b/docs/data/data-core-editor.md @@ -1777,3 +1777,5 @@ Returns an action object signaling that a new term is added to the edited post. * slug: Taxonomy slug. * term: Term object. + +### createNotice \ No newline at end of file