@wordpress/editor 11.0.1 → 12.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +1 -1
- package/build/components/autosave-monitor/index.js +5 -0
- package/build/components/autosave-monitor/index.js.map +1 -1
- package/build/components/character-count/index.js +1 -1
- package/build/components/character-count/index.js.map +1 -1
- package/build/components/editor-help/add-blocks.native.js +6 -5
- package/build/components/editor-help/add-blocks.native.js.map +1 -1
- package/build/components/editor-help/customize-blocks.native.js +7 -6
- package/build/components/editor-help/customize-blocks.native.js.map +1 -1
- package/build/components/editor-help/help-detail-navigation-screen.native.js +29 -15
- package/build/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
- package/build/components/editor-help/help-get-support-button.native.js +46 -0
- package/build/components/editor-help/help-get-support-button.native.js.map +1 -0
- package/build/components/editor-help/help-topic-row.native.js +3 -2
- package/build/components/editor-help/help-topic-row.native.js.map +1 -1
- package/build/components/editor-help/index.native.js +87 -26
- package/build/components/editor-help/index.native.js.map +1 -1
- package/build/components/editor-help/intro-to-blocks.native.js +19 -9
- package/build/components/editor-help/intro-to-blocks.native.js.map +1 -1
- package/build/components/editor-help/move-blocks.native.js +6 -5
- package/build/components/editor-help/move-blocks.native.js.map +1 -1
- package/build/components/editor-help/remove-blocks.native.js +6 -5
- package/build/components/editor-help/remove-blocks.native.js.map +1 -1
- package/build/components/editor-help/view-sections.native.js +23 -5
- package/build/components/editor-help/view-sections.native.js.map +1 -1
- package/build/components/entities-saved-states/entity-type-list.js +22 -13
- package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build/components/entities-saved-states/index.js +23 -4
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/save-shortcut.js +12 -14
- package/build/components/global-keyboard-shortcuts/save-shortcut.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -4
- package/build/components/global-keyboard-shortcuts/visual-editor-shortcuts.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/local-autosave-monitor/index.js +1 -2
- package/build/components/local-autosave-monitor/index.js.map +1 -1
- package/build/components/post-format/index.js +3 -1
- package/build/components/post-format/index.js.map +1 -1
- package/build/components/post-locked-modal/index.js +1 -1
- package/build/components/post-locked-modal/index.js.map +1 -1
- package/build/components/post-saved-state/index.js +37 -46
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js +154 -211
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-title/index.js +53 -25
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/provider/index.native.js +18 -7
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +32 -5
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/word-count/index.js +1 -1
- package/build/components/word-count/index.js.map +1 -1
- package/build/store/actions.js +13 -38
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +7 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/selectors.js +4 -93
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils/notice-builder.js +15 -18
- package/build/store/utils/notice-builder.js.map +1 -1
- package/build/{store/utils → utils}/get-template-part-icon.js +1 -1
- package/build/utils/get-template-part-icon.js.map +1 -0
- package/build/utils/index.js +8 -0
- package/build/utils/index.js.map +1 -1
- package/build-module/components/autosave-monitor/index.js +5 -0
- package/build-module/components/autosave-monitor/index.js.map +1 -1
- package/build-module/components/character-count/index.js +1 -1
- package/build-module/components/character-count/index.js.map +1 -1
- package/build-module/components/editor-help/add-blocks.native.js +7 -6
- package/build-module/components/editor-help/add-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/customize-blocks.native.js +8 -7
- package/build-module/components/editor-help/customize-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/help-detail-navigation-screen.native.js +31 -18
- package/build-module/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
- package/build-module/components/editor-help/help-get-support-button.native.js +34 -0
- package/build-module/components/editor-help/help-get-support-button.native.js.map +1 -0
- package/build-module/components/editor-help/help-topic-row.native.js +3 -2
- package/build-module/components/editor-help/help-topic-row.native.js.map +1 -1
- package/build-module/components/editor-help/index.native.js +81 -28
- package/build-module/components/editor-help/index.native.js.map +1 -1
- package/build-module/components/editor-help/intro-to-blocks.native.js +19 -10
- package/build-module/components/editor-help/intro-to-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/move-blocks.native.js +7 -6
- package/build-module/components/editor-help/move-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/remove-blocks.native.js +7 -6
- package/build-module/components/editor-help/remove-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/view-sections.native.js +22 -5
- package/build-module/components/editor-help/view-sections.native.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-type-list.js +24 -13
- package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +23 -4
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/save-shortcut.js +12 -14
- package/build-module/components/global-keyboard-shortcuts/save-shortcut.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -4
- package/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/local-autosave-monitor/index.js +1 -2
- package/build-module/components/local-autosave-monitor/index.js.map +1 -1
- package/build-module/components/post-format/index.js +4 -2
- package/build-module/components/post-format/index.js.map +1 -1
- package/build-module/components/post-locked-modal/index.js +1 -1
- package/build-module/components/post-locked-modal/index.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +38 -46
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js +156 -214
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/post-title/index.js +53 -22
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +18 -7
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +31 -5
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/word-count/index.js +1 -1
- package/build-module/components/word-count/index.js.map +1 -1
- package/build-module/store/actions.js +13 -36
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +7 -2
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/selectors.js +3 -85
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils/notice-builder.js +15 -18
- package/build-module/store/utils/notice-builder.js.map +1 -1
- package/build-module/{store/utils → utils}/get-template-part-icon.js +2 -2
- package/build-module/utils/get-template-part-icon.js.map +1 -0
- package/build-module/utils/index.js +1 -0
- package/build-module/utils/index.js.map +1 -1
- package/build-style/style-rtl.css +9 -60
- package/build-style/style.css +9 -60
- package/package.json +28 -28
- package/src/components/autosave-monitor/index.js +5 -0
- package/src/components/autosave-monitor/test/index.js +10 -4
- package/src/components/character-count/index.js +3 -2
- package/src/components/editor-help/add-blocks.native.js +17 -12
- package/src/components/editor-help/customize-blocks.native.js +16 -13
- package/src/components/editor-help/help-detail-navigation-screen.native.js +45 -15
- package/src/components/editor-help/help-get-support-button.native.js +38 -0
- package/src/components/editor-help/help-topic-row.native.js +2 -2
- package/src/components/editor-help/images/add-dark.png +0 -0
- package/src/components/editor-help/images/add-dark@2x.png +0 -0
- package/src/components/editor-help/images/add-dark@3x.png +0 -0
- package/src/components/editor-help/images/add-light.png +0 -0
- package/src/components/editor-help/images/add-light@2x.png +0 -0
- package/src/components/editor-help/images/add-light@3x.png +0 -0
- package/src/components/editor-help/images/block-layout-collage.png +0 -0
- package/src/components/editor-help/images/block-layout-collage@2x.png +0 -0
- package/src/components/editor-help/images/block-layout-collage@3x.png +0 -0
- package/src/components/editor-help/images/build-layouts-dark.png +0 -0
- package/src/components/editor-help/images/build-layouts-dark@2x.png +0 -0
- package/src/components/editor-help/images/build-layouts-dark@3x.png +0 -0
- package/src/components/editor-help/images/build-layouts-light.png +0 -0
- package/src/components/editor-help/images/build-layouts-light@2x.png +0 -0
- package/src/components/editor-help/images/build-layouts-light@3x.png +0 -0
- package/src/components/editor-help/images/edit-media-dark.png +0 -0
- package/src/components/editor-help/images/edit-media-dark@2x.png +0 -0
- package/src/components/editor-help/images/edit-media-dark@3x.png +0 -0
- package/src/components/editor-help/images/edit-media-light.png +0 -0
- package/src/components/editor-help/images/edit-media-light@2x.png +0 -0
- package/src/components/editor-help/images/edit-media-light@3x.png +0 -0
- package/src/components/editor-help/images/embed-media-dark.png +0 -0
- package/src/components/editor-help/images/embed-media-dark@2x.png +0 -0
- package/src/components/editor-help/images/embed-media-dark@3x.png +0 -0
- package/src/components/editor-help/images/embed-media-light.png +0 -0
- package/src/components/editor-help/images/embed-media-light@2x.png +0 -0
- package/src/components/editor-help/images/embed-media-light@3x.png +0 -0
- package/src/components/editor-help/images/move-dark.png +0 -0
- package/src/components/editor-help/images/move-dark@2x.png +0 -0
- package/src/components/editor-help/images/move-dark@3x.png +0 -0
- package/src/components/editor-help/images/move-light.png +0 -0
- package/src/components/editor-help/images/move-light@2x.png +0 -0
- package/src/components/editor-help/images/move-light@3x.png +0 -0
- package/src/components/editor-help/images/options-dark.png +0 -0
- package/src/components/editor-help/images/options-dark@2x.png +0 -0
- package/src/components/editor-help/images/options-dark@3x.png +0 -0
- package/src/components/editor-help/images/options-light.png +0 -0
- package/src/components/editor-help/images/options-light@2x.png +0 -0
- package/src/components/editor-help/images/options-light@3x.png +0 -0
- package/src/components/editor-help/images/rich-text-dark.png +0 -0
- package/src/components/editor-help/images/rich-text-dark@2x.png +0 -0
- package/src/components/editor-help/images/rich-text-dark@3x.png +0 -0
- package/src/components/editor-help/images/rich-text-light.png +0 -0
- package/src/components/editor-help/images/rich-text-light@2x.png +0 -0
- package/src/components/editor-help/images/rich-text-light@3x.png +0 -0
- package/src/components/editor-help/images/settings-dark.png +0 -0
- package/src/components/editor-help/images/settings-dark@2x.png +0 -0
- package/src/components/editor-help/images/settings-dark@3x.png +0 -0
- package/src/components/editor-help/images/settings-light.png +0 -0
- package/src/components/editor-help/images/settings-light@2x.png +0 -0
- package/src/components/editor-help/images/settings-light@3x.png +0 -0
- package/src/components/editor-help/index.native.js +147 -43
- package/src/components/editor-help/intro-to-blocks.native.js +63 -43
- package/src/components/editor-help/move-blocks.native.js +12 -7
- package/src/components/editor-help/remove-blocks.native.js +11 -8
- package/src/components/editor-help/style.android.scss +6 -0
- package/src/components/editor-help/style.ios.scss +6 -0
- package/src/components/editor-help/style.scss +49 -32
- package/src/components/editor-help/test/index.native.js +80 -0
- package/src/components/editor-help/view-sections.native.js +47 -4
- package/src/components/entities-saved-states/entity-type-list.js +29 -10
- package/src/components/entities-saved-states/index.js +38 -8
- package/src/components/global-keyboard-shortcuts/save-shortcut.js +34 -42
- package/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +8 -16
- package/src/components/index.js +1 -0
- package/src/components/local-autosave-monitor/index.js +1 -3
- package/src/components/post-format/index.js +6 -2
- package/src/components/post-format/style.scss +1 -0
- package/src/components/post-locked-modal/index.js +1 -1
- package/src/components/post-saved-state/index.js +41 -55
- package/src/components/post-saved-state/style.scss +10 -1
- package/src/components/post-saved-state/test/__snapshots__/index.js.snap +20 -0
- package/src/components/post-saved-state/test/index.js +2 -2
- package/src/components/post-taxonomies/flat-term-selector.js +220 -254
- package/src/components/post-title/index.js +47 -30
- package/src/components/post-title/style.scss +1 -70
- package/src/components/provider/index.native.js +17 -5
- package/src/components/provider/use-block-editor-settings.js +25 -2
- package/src/components/word-count/index.js +3 -2
- package/src/store/actions.js +13 -41
- package/src/store/defaults.js +7 -2
- package/src/store/selectors.js +2 -112
- package/src/store/test/actions.js +4 -2
- package/src/store/utils/notice-builder.js +17 -19
- package/src/store/utils/test/notice-builder.js +1 -1
- package/src/{store/utils → utils}/get-template-part-icon.js +2 -2
- package/src/utils/index.js +1 -0
- package/build/store/utils/get-template-part-icon.js.map +0 -1
- package/build-module/store/utils/get-template-part-icon.js.map +0 -1
- package/src/components/editor-help/images/add-blocks.png +0 -0
- package/src/components/editor-help/images/customize-blocks.png +0 -0
- package/src/components/editor-help/images/cut-copy-duplicate-blocks.png +0 -0
- package/src/components/editor-help/images/edit-or-replace-media.png +0 -0
- package/src/components/editor-help/images/intro-blocks-1.png +0 -0
- package/src/components/editor-help/images/intro-blocks-2.png +0 -0
- package/src/components/editor-help/images/intro-blocks-3.png +0 -0
- package/src/components/editor-help/images/intro-blocks-4.png +0 -0
- package/src/components/editor-help/images/move-blocks.png +0 -0
- package/src/components/editor-help/images/remove-blocks.png +0 -0
- package/src/components/editor-help/images/what-is-a-block.png +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-title/index.js"],"names":["REGEXP_NEWLINES","PostTitle","instanceId","ref","isSelected","setIsSelected","editPost","editorStore","insertDefaultBlock","clearSelectedBlock","insertBlocks","blockEditorStore","isCleanNewPost","title","placeholder","isFocusMode","hasFixedToolbar","select","getEditedPostAttribute","_isCleanNewPost","getSettings","titlePlaceholder","focusMode","_hasFixedToolbar","current","ownerDocument","activeElement","body","focus","onEnterPress","undefined","onInsertBlockAfter","blocks","onUpdate","newTitle","onSelect","onUnselect","onChange","event","target","value","replace","onKeyDown","keyCode","ENTER","preventDefault","onPaste","clipboardData","plainText","html","getData","error1","error2","window","console","log","content","HTML","length","firstBlock","name","attributes","slice","className","decodedPlaceholder"],"mappings":";;;;;;;;;AAUA;;AAPA;;AACA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAvBA;AACA;AACA;;AAIA;AACA;AACA;;AAWA;AACA;AACA;;AAIA;AACA;AACA;AACA,MAAMA,eAAe,GAAG,UAAxB;;AAEe,SAASC,SAA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;AAAlC,KACC;AAAK,IAAA,SAAS,EAAGiD;AAAjB,KACC,4BAAC,0BAAD;AACC,IAAA,EAAE,EAAC,OADJ;AAEC,IAAA,OAAO,EAAI,cAAc7D,UAAY;AAFtC,KAIG8D,kBAAkB,IAAI,cAAI,WAAJ,CAJzB,CADD,EAOC,4BAAC,8BAAD;AACC,IAAA,GAAG,EAAG7D,GADP;AAEC,IAAA,EAAE,EAAI,cAAcD,UAAY,EAFjC;AAGC,IAAA,SAAS,EAAC,0BAHX;AAIC,IAAA,KAAK,EAAGW,KAJT;AAKC,IAAA,QAAQ,EAAGwB,QALZ;AAMC,IAAA,WAAW,EAAG2B,kBAAkB,IAAI,cAAI,WAAJ,CANrC;AAOC,IAAA,OAAO,EAAG7B,QAPX;AAQC,IAAA,MAAM,EAAGC,UARV;AASC,IAAA,SAAS,EAAGM,SATb;AAUC,IAAA,UAAU,EAAGN,UAVd;AAWC,IAAA,OAAO,EAAGU;AAXX,IAPD,CADD,CADD;AAyBA","sourcesContent":["/**\n * External dependencies\n */\nimport TextareaAutosize from 'react-autosize-textarea';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { ENTER } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { VisuallyHidden } from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { pasteHandler } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport { store as editorStore } from '../../store';\n\n/**\n * Constants\n */\nconst REGEXP_NEWLINES = /[\\r\\n]+/g;\n\nexport default function PostTitle() {\n\tconst instanceId = useInstanceId( PostTitle );\n\tconst ref = useRef();\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\tconst { editPost } = useDispatch( editorStore );\n\tconst {\n\t\tinsertDefaultBlock,\n\t\tclearSelectedBlock,\n\t\tinsertBlocks,\n\t} = useDispatch( blockEditorStore );\n\tconst {\n\t\tisCleanNewPost,\n\t\ttitle,\n\t\tplaceholder,\n\t\tisFocusMode,\n\t\thasFixedToolbar,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetEditedPostAttribute,\n\t\t\tisCleanNewPost: _isCleanNewPost,\n\t\t} = select( editorStore );\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst {\n\t\t\ttitlePlaceholder,\n\t\t\tfocusMode,\n\t\t\thasFixedToolbar: _hasFixedToolbar,\n\t\t} = getSettings();\n\n\t\treturn {\n\t\t\tisCleanNewPost: _isCleanNewPost(),\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\tplaceholder: titlePlaceholder,\n\t\t\tisFocusMode: focusMode,\n\t\t\thasFixedToolbar: _hasFixedToolbar,\n\t\t};\n\t} );\n\n\tuseEffect( () => {\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { activeElement, body } = ownerDocument;\n\n\t\t// Only autofocus the title when the post is entirely empty. This should\n\t\t// only happen for a new post, which means we focus the title on new\n\t\t// post so the author can start typing right away, without needing to\n\t\t// click anything.\n\t\tif ( isCleanNewPost && ( ! activeElement || body === activeElement ) ) {\n\t\t\tref.current.focus();\n\t\t}\n\t}, [ isCleanNewPost ] );\n\n\tfunction onEnterPress() {\n\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t}\n\n\tfunction onInsertBlockAfter( blocks ) {\n\t\tinsertBlocks( blocks, 0 );\n\t}\n\n\tfunction onUpdate( newTitle ) {\n\t\teditPost( { title: newTitle } );\n\t}\n\n\tfunction onSelect() {\n\t\tsetIsSelected( true );\n\t\tclearSelectedBlock();\n\t}\n\n\tfunction onUnselect() {\n\t\tsetIsSelected( false );\n\t}\n\n\tfunction onChange( event ) {\n\t\tonUpdate( event.target.value.replace( REGEXP_NEWLINES, ' ' ) );\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.keyCode === ENTER ) {\n\t\t\tevent.preventDefault();\n\t\t\tonEnterPress();\n\t\t}\n\t}\n\n\tfunction onPaste( event ) {\n\t\tconst clipboardData = event.clipboardData;\n\n\t\tlet plainText = '';\n\t\tlet html = '';\n\n\t\t// IE11 only supports `Text` as an argument for `getData` and will\n\t\t// otherwise throw an invalid argument error, so we try the standard\n\t\t// arguments first, then fallback to `Text` if they fail.\n\t\ttry {\n\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t} catch ( error1 ) {\n\t\t\ttry {\n\t\t\t\thtml = clipboardData.getData( 'Text' );\n\t\t\t} catch ( error2 ) {\n\t\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t\t// behaviour.\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t} );\n\n\t\tif ( typeof content !== 'string' && content.length ) {\n\t\t\tevent.preventDefault();\n\n\t\t\tconst [ firstBlock ] = content;\n\n\t\t\tif (\n\t\t\t\t! title &&\n\t\t\t\t( firstBlock.name === 'core/heading' ||\n\t\t\t\t\tfirstBlock.name === 'core/paragraph' )\n\t\t\t) {\n\t\t\t\tonUpdate( firstBlock.attributes.content );\n\t\t\t\tonInsertBlockAfter( content.slice( 1 ) );\n\t\t\t} else {\n\t\t\t\tonInsertBlockAfter( content );\n\t\t\t}\n\t\t}\n\t}\n\n\t// The wp-block className is important for editor styles.\n\t// This same block is used in both the visual and the code editor.\n\tconst className = classnames(\n\t\t'wp-block editor-post-title editor-post-title__block',\n\t\t{\n\t\t\t'is-selected': isSelected,\n\t\t\t'is-focus-mode': isFocusMode,\n\t\t\t'has-fixed-toolbar': hasFixedToolbar,\n\t\t}\n\t);\n\tconst decodedPlaceholder = decodeEntities( placeholder );\n\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"title\">\n\t\t\t<div className={ className }>\n\t\t\t\t<VisuallyHidden\n\t\t\t\t\tas=\"label\"\n\t\t\t\t\thtmlFor={ `post-title-${ instanceId }` }\n\t\t\t\t>\n\t\t\t\t\t{ decodedPlaceholder || __( 'Add title' ) }\n\t\t\t\t</VisuallyHidden>\n\t\t\t\t<TextareaAutosize\n\t\t\t\t\tref={ ref }\n\t\t\t\t\tid={ `post-title-${ instanceId }` }\n\t\t\t\t\tclassName=\"editor-post-title__input\"\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tplaceholder={ decodedPlaceholder || __( 'Add title' ) }\n\t\t\t\t\tonFocus={ onSelect }\n\t\t\t\t\tonBlur={ onUnselect }\n\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t\tonKeyPress={ onUnselect }\n\t\t\t\t\tonPaste={ onPaste }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</PostTypeSupportCheck>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-title/index.js"],"names":["REGEXP_NEWLINES","PostTitle","ref","isSelected","setIsSelected","editPost","editorStore","insertDefaultBlock","clearSelectedBlock","insertBlocks","blockEditorStore","isCleanNewPost","title","placeholder","isFocusMode","hasFixedToolbar","select","getEditedPostAttribute","_isCleanNewPost","getSettings","titlePlaceholder","focusMode","_hasFixedToolbar","current","ownerDocument","activeElement","body","focus","onEnterPress","undefined","onInsertBlockAfter","blocks","onUpdate","newTitle","selection","setSelection","onSelect","onUnselect","onChange","value","replace","onKeyDown","event","keyCode","ENTER","preventDefault","onPaste","clipboardData","plainText","html","getData","error1","error2","window","console","log","content","HTML","length","firstBlock","name","attributes","slice","className","decodedPlaceholder","richTextRef","selectionStart","start","selectionEnd","end","onSelectionChange","newStart","newEnd","sel","__unstableDisableFormats","preserveWhiteSpace"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAtBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;AAIA;AACA;AACA;AACA,MAAMA,eAAe,GAAG,UAAxB;;AAEe,SAASC,SAAT,GAAqB;AACnC,QAAMC,GAAG,GAAG,sBAAZ;AACA,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgC,uBAAU,KAAV,CAAtC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAe,uBAAaC,YAAb,CAArB;AACA,QAAM;AACLC,IAAAA,kBADK;AAELC,IAAAA,kBAFK;AAGLC,IAAAA;AAHK,MAIF,uBAAaC,kBAAb,CAJJ;AAKA,QAAM;AACLC,IAAAA,cADK;AAELC,IAAAA,KAFK;AAGLC,IAAAA,WAHK;AAILC,IAAAA,WAJK;AAKLC,IAAAA;AALK,MAMF,qBAAaC,MAAF,IAAc;AAC5B,UAAM;AACLC,MAAAA,sBADK;AAELN,MAAAA,cAAc,EAAEO;AAFX,QAGFF,MAAM,CAAEV,YAAF,CAHV;AAIA,UAAM;AAAEa,MAAAA;AAAF,QAAkBH,MAAM,CAAEN,kBAAF,CAA9B;AACA,UAAM;AACLU,MAAAA,gBADK;AAELC,MAAAA,SAFK;AAGLN,MAAAA,eAAe,EAAEO;AAHZ,QAIFH,WAAW,EAJf;AAMA,WAAO;AACNR,MAAAA,cAAc,EAAEO,eAAe,EADzB;AAENN,MAAAA,KAAK,EAAEK,sBAAsB,CAAE,OAAF,CAFvB;AAGNJ,MAAAA,WAAW,EAAEO,gBAHP;AAINN,MAAAA,WAAW,EAAEO,SAJP;AAKNN,MAAAA,eAAe,EAAEO;AALX,KAAP;AAOA,GAnBG,EAmBD,EAnBC,CANJ;AA2BA,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EAAG6D,SAHb;AAIC,kBAAaC,kBAJd;AAKC,IAAA,IAAI,EAAC,SALN;AAMC,sBAAe,MANhB;AAOC,IAAA,OAAO,EAAG5B,QAPX;AAQC,IAAA,MAAM,EAAGC,UARV;AASC,IAAA,SAAS,EAAGI,SATb;AAUC,IAAA,UAAU,EAAGJ,UAVd;AAWC,IAAA,OAAO,EAAGS;AAXX,IADD,CADD;AAiBA;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { ENTER } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { pasteHandler } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { __unstableUseRichText as useRichText } from '@wordpress/rich-text';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport { store as editorStore } from '../../store';\n\n/**\n * Constants\n */\nconst REGEXP_NEWLINES = /[\\r\\n]+/g;\n\nexport default function PostTitle() {\n\tconst ref = useRef();\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\tconst { editPost } = useDispatch( editorStore );\n\tconst {\n\t\tinsertDefaultBlock,\n\t\tclearSelectedBlock,\n\t\tinsertBlocks,\n\t} = useDispatch( blockEditorStore );\n\tconst {\n\t\tisCleanNewPost,\n\t\ttitle,\n\t\tplaceholder,\n\t\tisFocusMode,\n\t\thasFixedToolbar,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetEditedPostAttribute,\n\t\t\tisCleanNewPost: _isCleanNewPost,\n\t\t} = select( editorStore );\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst {\n\t\t\ttitlePlaceholder,\n\t\t\tfocusMode,\n\t\t\thasFixedToolbar: _hasFixedToolbar,\n\t\t} = getSettings();\n\n\t\treturn {\n\t\t\tisCleanNewPost: _isCleanNewPost(),\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\tplaceholder: titlePlaceholder,\n\t\t\tisFocusMode: focusMode,\n\t\t\thasFixedToolbar: _hasFixedToolbar,\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { activeElement, body } = ownerDocument;\n\n\t\t// Only autofocus the title when the post is entirely empty. This should\n\t\t// only happen for a new post, which means we focus the title on new\n\t\t// post so the author can start typing right away, without needing to\n\t\t// click anything.\n\t\tif ( isCleanNewPost && ( ! activeElement || body === activeElement ) ) {\n\t\t\tref.current.focus();\n\t\t}\n\t}, [ isCleanNewPost ] );\n\n\tfunction onEnterPress() {\n\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t}\n\n\tfunction onInsertBlockAfter( blocks ) {\n\t\tinsertBlocks( blocks, 0 );\n\t}\n\n\tfunction onUpdate( newTitle ) {\n\t\teditPost( { title: newTitle } );\n\t}\n\n\tconst [ selection, setSelection ] = useState( {} );\n\n\tfunction onSelect() {\n\t\tsetIsSelected( true );\n\t\tclearSelectedBlock();\n\t}\n\n\tfunction onUnselect() {\n\t\tsetIsSelected( false );\n\t\tsetSelection( {} );\n\t}\n\n\tfunction onChange( value ) {\n\t\tonUpdate( value.replace( REGEXP_NEWLINES, ' ' ) );\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.keyCode === ENTER ) {\n\t\t\tevent.preventDefault();\n\t\t\tonEnterPress();\n\t\t}\n\t}\n\n\tfunction onPaste( event ) {\n\t\tconst clipboardData = event.clipboardData;\n\n\t\tlet plainText = '';\n\t\tlet html = '';\n\n\t\t// IE11 only supports `Text` as an argument for `getData` and will\n\t\t// otherwise throw an invalid argument error, so we try the standard\n\t\t// arguments first, then fallback to `Text` if they fail.\n\t\ttry {\n\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t} catch ( error1 ) {\n\t\t\ttry {\n\t\t\t\thtml = clipboardData.getData( 'Text' );\n\t\t\t} catch ( error2 ) {\n\t\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t\t// behaviour.\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t} );\n\n\t\tif ( typeof content !== 'string' && content.length ) {\n\t\t\tevent.preventDefault();\n\n\t\t\tconst [ firstBlock ] = content;\n\n\t\t\tif (\n\t\t\t\t! title &&\n\t\t\t\t( firstBlock.name === 'core/heading' ||\n\t\t\t\t\tfirstBlock.name === 'core/paragraph' )\n\t\t\t) {\n\t\t\t\tonUpdate( firstBlock.attributes.content );\n\t\t\t\tonInsertBlockAfter( content.slice( 1 ) );\n\t\t\t} else {\n\t\t\t\tonInsertBlockAfter( content );\n\t\t\t}\n\t\t}\n\t}\n\n\t// The wp-block className is important for editor styles.\n\t// This same block is used in both the visual and the code editor.\n\tconst className = classnames(\n\t\t'wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text',\n\t\t{\n\t\t\t'is-selected': isSelected,\n\t\t\t'is-focus-mode': isFocusMode,\n\t\t\t'has-fixed-toolbar': hasFixedToolbar,\n\t\t}\n\t);\n\tconst decodedPlaceholder =\n\t\tdecodeEntities( placeholder ) || __( 'Add title' );\n\tconst { ref: richTextRef } = useRichText( {\n\t\tvalue: title,\n\t\tonChange,\n\t\tplaceholder: decodedPlaceholder,\n\t\tselectionStart: selection.start,\n\t\tselectionEnd: selection.end,\n\t\tonSelectionChange( newStart, newEnd ) {\n\t\t\tsetSelection( ( sel ) => {\n\t\t\t\tconst { start, end } = sel;\n\t\t\t\tif ( start === newStart && end === newEnd ) {\n\t\t\t\t\treturn sel;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstart: newStart,\n\t\t\t\t\tend: newEnd,\n\t\t\t\t};\n\t\t\t} );\n\t\t},\n\t\t__unstableDisableFormats: true,\n\t\tpreserveWhiteSpace: true,\n\t} );\n\n\t/* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"title\">\n\t\t\t<h1\n\t\t\t\tref={ useMergeRefs( [ richTextRef, ref ] ) }\n\t\t\t\tcontentEditable\n\t\t\t\tclassName={ className }\n\t\t\t\taria-label={ decodedPlaceholder }\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline=\"true\"\n\t\t\t\tonFocus={ onSelect }\n\t\t\t\tonBlur={ onUnselect }\n\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\tonKeyPress={ onUnselect }\n\t\t\t\tonPaste={ onPaste }\n\t\t\t/>\n\t\t</PostTypeSupportCheck>\n\t);\n\t/* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n}\n"]}
|
|
@@ -65,7 +65,8 @@ const postTypeEntities = [{
|
|
|
65
65
|
},
|
|
66
66
|
mergedEdits: {
|
|
67
67
|
meta: true
|
|
68
|
-
}
|
|
68
|
+
},
|
|
69
|
+
rawAttributes: ['title', 'excerpt', 'content']
|
|
69
70
|
}));
|
|
70
71
|
|
|
71
72
|
class NativeEditorProvider extends _element.Component {
|
|
@@ -88,10 +89,16 @@ class NativeEditorProvider extends _element.Component {
|
|
|
88
89
|
componentDidMount() {
|
|
89
90
|
const {
|
|
90
91
|
capabilities,
|
|
91
|
-
|
|
92
|
+
locale,
|
|
93
|
+
updateSettings,
|
|
94
|
+
galleryWithImageBlocks
|
|
92
95
|
} = this.props;
|
|
93
96
|
updateSettings({ ...capabilities,
|
|
94
|
-
...
|
|
97
|
+
...{
|
|
98
|
+
__unstableGalleryWithImageBlocks: galleryWithImageBlocks
|
|
99
|
+
},
|
|
100
|
+
...this.getThemeColors(this.props),
|
|
101
|
+
locale
|
|
95
102
|
});
|
|
96
103
|
this.subscriptionParentGetHtml = (0, _reactNativeBridge.subscribeParentGetHtml)(() => {
|
|
97
104
|
this.serializeToNativeAction();
|
|
@@ -119,8 +126,11 @@ class NativeEditorProvider extends _element.Component {
|
|
|
119
126
|
this.props.insertBlock(newBlock, insertionIndex);
|
|
120
127
|
});
|
|
121
128
|
this.subscriptionParentUpdateEditorSettings = (0, _reactNativeBridge.subscribeUpdateEditorSettings)(editorSettings => {
|
|
122
|
-
|
|
123
|
-
|
|
129
|
+
updateSettings({ ...{
|
|
130
|
+
__unstableGalleryWithImageBlocks: editorSettings.galleryWithImageBlocks
|
|
131
|
+
},
|
|
132
|
+
...this.getThemeColors(editorSettings)
|
|
133
|
+
});
|
|
124
134
|
});
|
|
125
135
|
this.subscriptionParentUpdateCapabilities = (0, _reactNativeBridge.subscribeUpdateCapabilities)(payload => {
|
|
126
136
|
this.updateCapabilitiesAction(payload);
|
|
@@ -129,8 +139,6 @@ class NativeEditorProvider extends _element.Component {
|
|
|
129
139
|
this.props.createSuccessNotice(payload.message);
|
|
130
140
|
});
|
|
131
141
|
this.subscriptionParentShowEditorHelp = (0, _reactNativeBridge.subscribeShowEditorHelp)(() => {
|
|
132
|
-
// Temporary: feature hidden from production. This is just here for testing
|
|
133
|
-
// purposes and will be replaced with actual logic in a later PR.
|
|
134
142
|
this.setState({
|
|
135
143
|
isHelpVisible: true
|
|
136
144
|
});
|
|
@@ -295,6 +303,9 @@ class NativeEditorProvider extends _element.Component {
|
|
|
295
303
|
isVisible: this.state.isHelpVisible,
|
|
296
304
|
onClose: () => this.setState({
|
|
297
305
|
isHelpVisible: false
|
|
306
|
+
}),
|
|
307
|
+
close: () => this.setState({
|
|
308
|
+
isHelpVisible: false
|
|
298
309
|
})
|
|
299
310
|
}));
|
|
300
311
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/provider/index.native.js"],"names":["postTypeEntities","name","baseURL","map","postTypeEntity","kind","transientEdits","blocks","selection","mergedEdits","meta","NativeEditorProvider","Component","constructor","arguments","post","props","addEntities","receiveEntityRecords","type","getEditorSettings","settings","capabilities","maxSize","state","isHelpVisible","componentDidMount","updateSettings","getThemeColors","subscriptionParentGetHtml","serializeToNativeAction","subscriptionParentToggleHTMLMode","toggleMode","subscriptionParentSetTitle","payload","editTitle","title","subscriptionParentUpdateHtml","updateHtmlAction","html","subscriptionParentReplaceBlock","replaceBlockAction","clientId","subscriptionParentMediaAppend","blockName","mediaType","newBlock","id","mediaId","mediaUrl","indexAfterSelected","selectedBlockIndex","insertionIndex","blockCount","insertBlock","subscriptionParentUpdateEditorSettings","editorSettings","themeColors","subscriptionParentUpdateCapabilities","updateCapabilitiesAction","subscriptionParentShowNotice","createSuccessNotice","message","subscriptionParentShowEditorHelp","setState","storedImpressions","impressions","NEW_BLOCK_TYPES","storedImpressionKeys","Object","keys","storedImpressionsCurrent","every","newKey","includes","componentWillUnmount","remove","colors","gradients","rawStyles","rawFeatures","componentDidUpdate","prevProps","isReady","isUnsupportedBlock","unsupportedBlockNames","filter","block","attributes","originalName","RNReactNativeGutenbergBridge","editorDidMount","mode","hasChanges","raw","content","contentInfo","characterCount","wordCount","paragraphCount","provideToNative_Html","parsed","resetEditorBlocksWithoutUndoLevel","blockClientId","replaceBlock","switchMode","clearSelectedBlock","render","children","select","__unstableIsEditorReady","isEditorReady","getEditorBlocks","getEditedPostAttribute","getEditedPostContent","getEditorMode","getBlockIndex","getSelectedBlockClientId","getGlobalBlockCount","getSettings","getBlockEditorSettings","blockEditorStore","selectedBlockClientId","dispatch","editPost","resetEditorBlocks","switchEditorMode","__unstableShouldCreateUndoLevel"],"mappings":";;;;;;;;;;;AAsBA;;;;AAnBA;;AAK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;AAJK,MAKFmB,QAAQ,CAAEF,kBAAF,CALZ;AAMA,QAAM;AAAEK,IAAAA;AAAF,MAAuBH,QAAQ,CAAE,gBAAF,CAArC;AACA,QAAM;AAAE1G,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAAwCyG,QAAQ,CAAE,MAAF,CAAtD;AACA,QAAM;AAAE9D,IAAAA;AAAF,MAA0B8D,QAAQ,CAAE,cAAF,CAAxC;AAEA,SAAO;AACNhG,IAAAA,cADM;AAENV,IAAAA,WAFM;AAGNyF,IAAAA,kBAHM;AAINpD,IAAAA,WAJM;AAKNO,IAAAA,mBALM;;AAMN1B,IAAAA,SAAS,CAAEC,KAAF,EAAU;AAClBwF,MAAAA,QAAQ,CAAE;AAAExF,QAAAA;AAAF,OAAF,CAAR;AACA,KARK;;AASNlB,IAAAA,oBATM;;AAUNoF,IAAAA,iCAAiC,CAAE/F,MAAF,EAAW;AAC3CsH,MAAAA,iBAAiB,CAAEtH,MAAF,EAAU;AAC1BwH,QAAAA,+BAA+B,EAAE;AADP,OAAV,CAAjB;AAGA,KAdK;;AAeNtB,IAAAA,UAAU,CAAEb,IAAF,EAAS;AAClBkC,MAAAA,gBAAgB,CAAElC,IAAF,CAAhB;AACA,KAjBK;;AAkBNY,IAAAA;AAlBM,GAAP;AAoBA,CAhCD,CA9BuB,CAAT,EA+DV7F,oBA/DU,C","sourcesContent":["/**\n * External dependencies\n */\nimport memize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport RNReactNativeGutenbergBridge, {\n\trequestBlockTypeImpressions,\n\tsetBlockTypeImpressions,\n\tsubscribeParentGetHtml,\n\tsubscribeParentToggleHTMLMode,\n\tsubscribeUpdateHtml,\n\tsubscribeSetTitle,\n\tsubscribeMediaAppend,\n\tsubscribeReplaceBlock,\n\tsubscribeUpdateEditorSettings,\n\tsubscribeUpdateCapabilities,\n\tsubscribeShowNotice,\n\tsubscribeShowEditorHelp,\n} from '@wordpress/react-native-bridge';\nimport { Component } from '@wordpress/element';\nimport { count as wordCount } from '@wordpress/wordcount';\nimport {\n\tparse,\n\tserialize,\n\tgetUnregisteredTypeHandlerName,\n\tcreateBlock,\n} from '@wordpress/blocks';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { applyFilters } from '@wordpress/hooks';\nimport {\n\tvalidateThemeColors,\n\tvalidateThemeGradients,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { getGlobalStyles } from '@wordpress/components';\nimport { NEW_BLOCK_TYPES } from '@wordpress/block-library';\n\nconst postTypeEntities = [\n\t{ name: 'post', baseURL: '/wp/v2/posts' },\n\t{ name: 'page', baseURL: '/wp/v2/pages' },\n\t{ name: 'attachment', baseURL: '/wp/v2/media' },\n\t{ name: 'wp_block', baseURL: '/wp/v2/blocks' },\n].map( ( postTypeEntity ) => ( {\n\tkind: 'postType',\n\t...postTypeEntity,\n\ttransientEdits: {\n\t\tblocks: true,\n\t\tselection: true,\n\t},\n\tmergedEdits: {\n\t\tmeta: true,\n\t},\n} ) );\nimport { EditorHelpTopics } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport EditorProvider from './index.js';\n\nclass NativeEditorProvider extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\t// Keep a local reference to `post` to detect changes\n\t\tthis.post = this.props.post;\n\t\tthis.props.addEntities( postTypeEntities );\n\t\tthis.props.receiveEntityRecords(\n\t\t\t'postType',\n\t\t\tthis.post.type,\n\t\t\tthis.post\n\t\t);\n\t\tthis.getEditorSettings = memize(\n\t\t\t( settings, capabilities ) => ( {\n\t\t\t\t...settings,\n\t\t\t\tcapabilities,\n\t\t\t} ),\n\t\t\t{\n\t\t\t\tmaxSize: 1,\n\t\t\t}\n\t\t);\n\t\tthis.state = {\n\t\t\tisHelpVisible: false,\n\t\t};\n\t}\n\n\tcomponentDidMount() {\n\t\tconst { capabilities, updateSettings } = this.props;\n\n\t\tupdateSettings( {\n\t\t\t...capabilities,\n\t\t\t...this.getThemeColors( this.props ),\n\t\t} );\n\n\t\tthis.subscriptionParentGetHtml = subscribeParentGetHtml( () => {\n\t\t\tthis.serializeToNativeAction();\n\t\t} );\n\n\t\tthis.subscriptionParentToggleHTMLMode = subscribeParentToggleHTMLMode(\n\t\t\t() => {\n\t\t\t\tthis.toggleMode();\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentSetTitle = subscribeSetTitle( ( payload ) => {\n\t\t\tthis.props.editTitle( payload.title );\n\t\t} );\n\n\t\tthis.subscriptionParentUpdateHtml = subscribeUpdateHtml(\n\t\t\t( payload ) => {\n\t\t\t\tthis.updateHtmlAction( payload.html );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentReplaceBlock = subscribeReplaceBlock(\n\t\t\t( payload ) => {\n\t\t\t\tthis.replaceBlockAction( payload.html, payload.clientId );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentMediaAppend = subscribeMediaAppend(\n\t\t\t( payload ) => {\n\t\t\t\tconst blockName = 'core/' + payload.mediaType;\n\t\t\t\tconst newBlock = createBlock( blockName, {\n\t\t\t\t\tid: payload.mediaId,\n\t\t\t\t\t[ payload.mediaType === 'image'\n\t\t\t\t\t\t? 'url'\n\t\t\t\t\t\t: 'src' ]: payload.mediaUrl,\n\t\t\t\t} );\n\n\t\t\t\tconst indexAfterSelected = this.props.selectedBlockIndex + 1;\n\t\t\t\tconst insertionIndex =\n\t\t\t\t\tindexAfterSelected || this.props.blockCount;\n\n\t\t\t\tthis.props.insertBlock( newBlock, insertionIndex );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentUpdateEditorSettings = subscribeUpdateEditorSettings(\n\t\t\t( editorSettings ) => {\n\t\t\t\tconst themeColors = this.getThemeColors( editorSettings );\n\t\t\t\tupdateSettings( themeColors );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentUpdateCapabilities = subscribeUpdateCapabilities(\n\t\t\t( payload ) => {\n\t\t\t\tthis.updateCapabilitiesAction( payload );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentShowNotice = subscribeShowNotice(\n\t\t\t( payload ) => {\n\t\t\t\tthis.props.createSuccessNotice( payload.message );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentShowEditorHelp = subscribeShowEditorHelp( () => {\n\t\t\t// Temporary: feature hidden from production. This is just here for testing\n\t\t\t// purposes and will be replaced with actual logic in a later PR.\n\t\t\tthis.setState( { isHelpVisible: true } );\n\t\t} );\n\n\t\t// Request current block impressions from native app\n\t\trequestBlockTypeImpressions( ( storedImpressions ) => {\n\t\t\tconst impressions = { ...NEW_BLOCK_TYPES, ...storedImpressions };\n\n\t\t\t// Persist impressions to JavaScript store\n\t\t\tupdateSettings( { impressions } );\n\n\t\t\t// Persist impressions to native store if they do not include latest\n\t\t\t// `NEW_BLOCK_TYPES` configuration\n\t\t\tconst storedImpressionKeys = Object.keys( storedImpressions );\n\t\t\tconst storedImpressionsCurrent = Object.keys(\n\t\t\t\tNEW_BLOCK_TYPES\n\t\t\t).every( ( newKey ) => storedImpressionKeys.includes( newKey ) );\n\t\t\tif ( ! storedImpressionsCurrent ) {\n\t\t\t\tsetBlockTypeImpressions( impressions );\n\t\t\t}\n\t\t} );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( this.subscriptionParentGetHtml ) {\n\t\t\tthis.subscriptionParentGetHtml.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentToggleHTMLMode ) {\n\t\t\tthis.subscriptionParentToggleHTMLMode.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentSetTitle ) {\n\t\t\tthis.subscriptionParentSetTitle.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentUpdateHtml ) {\n\t\t\tthis.subscriptionParentUpdateHtml.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentReplaceBlock ) {\n\t\t\tthis.subscriptionParentReplaceBlock.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentMediaAppend ) {\n\t\t\tthis.subscriptionParentMediaAppend.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentUpdateEditorSettings ) {\n\t\t\tthis.subscriptionParentUpdateEditorSettings.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentUpdateCapabilities ) {\n\t\t\tthis.subscriptionParentUpdateCapabilities.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentShowNotice ) {\n\t\t\tthis.subscriptionParentShowNotice.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentShowEditorHelp ) {\n\t\t\tthis.subscriptionParentShowEditorHelp.remove();\n\t\t}\n\t}\n\n\tgetThemeColors( { colors, gradients, rawStyles, rawFeatures } ) {\n\t\treturn {\n\t\t\t...( rawStyles && rawFeatures\n\t\t\t\t? getGlobalStyles( rawStyles, rawFeatures )\n\t\t\t\t: {\n\t\t\t\t\t\tcolors: validateThemeColors( colors ),\n\t\t\t\t\t\tgradients: validateThemeGradients( gradients ),\n\t\t\t\t } ),\n\t\t};\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tif ( ! prevProps.isReady && this.props.isReady ) {\n\t\t\tconst blocks = this.props.blocks;\n\t\t\tconst isUnsupportedBlock = ( { name } ) =>\n\t\t\t\tname === getUnregisteredTypeHandlerName();\n\t\t\tconst unsupportedBlockNames = blocks\n\t\t\t\t.filter( isUnsupportedBlock )\n\t\t\t\t.map( ( block ) => block.attributes.originalName );\n\t\t\tRNReactNativeGutenbergBridge.editorDidMount(\n\t\t\t\tunsupportedBlockNames\n\t\t\t);\n\t\t}\n\t}\n\n\tserializeToNativeAction() {\n\t\tconst title = this.props.title;\n\t\tlet html;\n\n\t\tif ( this.props.mode === 'text' ) {\n\t\t\t// The HTMLTextInput component does not update the store when user is doing changes\n\t\t\t// Let's request the HTML from the component's state directly\n\t\t\thtml = applyFilters( 'native.persist-html' );\n\t\t} else {\n\t\t\thtml = serialize( this.props.blocks );\n\t\t}\n\n\t\tconst hasChanges =\n\t\t\ttitle !== this.post.title.raw || html !== this.post.content.raw;\n\n\t\t// Variable to store the content structure metrics.\n\t\tconst contentInfo = {};\n\t\tcontentInfo.characterCount = wordCount(\n\t\t\thtml,\n\t\t\t'characters_including_spaces'\n\t\t);\n\t\tcontentInfo.wordCount = wordCount( html, 'words' );\n\t\tcontentInfo.paragraphCount = this.props.paragraphCount;\n\t\tcontentInfo.blockCount = this.props.blockCount;\n\t\tRNReactNativeGutenbergBridge.provideToNative_Html(\n\t\t\thtml,\n\t\t\ttitle,\n\t\t\thasChanges,\n\t\t\tcontentInfo\n\t\t);\n\n\t\tif ( hasChanges ) {\n\t\t\tthis.post.title.raw = title;\n\t\t\tthis.post.content.raw = html;\n\t\t}\n\t}\n\n\tupdateHtmlAction( html ) {\n\t\tconst parsed = parse( html );\n\t\tthis.props.resetEditorBlocksWithoutUndoLevel( parsed );\n\t}\n\n\treplaceBlockAction( html, blockClientId ) {\n\t\tconst parsed = parse( html );\n\t\tthis.props.replaceBlock( blockClientId, parsed );\n\t}\n\n\ttoggleMode() {\n\t\tconst { mode, switchMode } = this.props;\n\t\t// refresh html content first\n\t\tthis.serializeToNativeAction();\n\t\t// make sure to blur the selected block and dismiss the keyboard\n\t\tthis.props.clearSelectedBlock();\n\t\tswitchMode( mode === 'visual' ? 'text' : 'visual' );\n\t}\n\n\tupdateCapabilitiesAction( capabilities ) {\n\t\tthis.props.updateSettings( capabilities );\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tchildren,\n\t\t\tpost, // eslint-disable-line no-unused-vars\n\t\t\tcapabilities,\n\t\t\tsettings,\n\t\t\t...props\n\t\t} = this.props;\n\t\tconst editorSettings = this.getEditorSettings( settings, capabilities );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<EditorProvider\n\t\t\t\t\tpost={ this.post }\n\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t{ ...props }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</EditorProvider>\n\t\t\t\t<EditorHelpTopics\n\t\t\t\t\tisVisible={ this.state.isHelpVisible }\n\t\t\t\t\tonClose={ () => this.setState( { isHelpVisible: false } ) }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\t__unstableIsEditorReady: isEditorReady,\n\t\t\tgetEditorBlocks,\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetEditedPostContent,\n\t\t} = select( 'core/editor' );\n\t\tconst { getEditorMode } = select( 'core/edit-post' );\n\n\t\tconst {\n\t\t\tgetBlockIndex,\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetGlobalBlockCount,\n\t\t\tgetSettings: getBlockEditorSettings,\n\t\t} = select( blockEditorStore );\n\n\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\treturn {\n\t\t\tmode: getEditorMode(),\n\t\t\tisReady: isEditorReady(),\n\t\t\tblocks: getEditorBlocks(),\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\tgetEditedPostContent,\n\t\t\tgetBlockEditorSettings,\n\t\t\tselectedBlockIndex: getBlockIndex( selectedBlockClientId ),\n\t\t\tblockCount: getGlobalBlockCount(),\n\t\t\tparagraphCount: getGlobalBlockCount( 'core/paragraph' ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { editPost, resetEditorBlocks } = dispatch( 'core/editor' );\n\t\tconst {\n\t\t\tupdateSettings,\n\t\t\tclearSelectedBlock,\n\t\t\tinsertBlock,\n\t\t\treplaceBlock,\n\t\t} = dispatch( blockEditorStore );\n\t\tconst { switchEditorMode } = dispatch( 'core/edit-post' );\n\t\tconst { addEntities, receiveEntityRecords } = dispatch( 'core' );\n\t\tconst { createSuccessNotice } = dispatch( 'core/notices' );\n\n\t\treturn {\n\t\t\tupdateSettings,\n\t\t\taddEntities,\n\t\t\tclearSelectedBlock,\n\t\t\tinsertBlock,\n\t\t\tcreateSuccessNotice,\n\t\t\teditTitle( title ) {\n\t\t\t\teditPost( { title } );\n\t\t\t},\n\t\t\treceiveEntityRecords,\n\t\t\tresetEditorBlocksWithoutUndoLevel( blocks ) {\n\t\t\t\tresetEditorBlocks( blocks, {\n\t\t\t\t\t__unstableShouldCreateUndoLevel: false,\n\t\t\t\t} );\n\t\t\t},\n\t\t\tswitchMode( mode ) {\n\t\t\t\tswitchEditorMode( mode );\n\t\t\t},\n\t\t\treplaceBlock,\n\t\t};\n\t} ),\n] )( NativeEditorProvider );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/provider/index.native.js"],"names":["postTypeEntities","name","baseURL","map","postTypeEntity","kind","transientEdits","blocks","selection","mergedEdits","meta","rawAttributes","NativeEditorProvider","Component","constructor","arguments","post","props","addEntities","receiveEntityRecords","type","getEditorSettings","settings","capabilities","maxSize","state","isHelpVisible","componentDidMount","locale","updateSettings","galleryWithImageBlocks","__unstableGalleryWithImageBlocks","getThemeColors","subscriptionParentGetHtml","serializeToNativeAction","subscriptionParentToggleHTMLMode","toggleMode","subscriptionParentSetTitle","payload","editTitle","title","subscriptionParentUpdateHtml","updateHtmlAction","html","subscriptionParentReplaceBlock","replaceBlockAction","clientId","subscriptionParentMediaAppend","blockName","mediaType","newBlock","id","mediaId","mediaUrl","indexAfterSelected","selectedBlockIndex","insertionIndex","blockCount","insertBlock","subscriptionParentUpdateEditorSettings","editorSettings","subscriptionParentUpdateCapabilities","updateCapabilitiesAction","subscriptionParentShowNotice","createSuccessNotice","message","subscriptionParentShowEditorHelp","setState","storedImpressions","impressions","NEW_BLOCK_TYPES","storedImpressionKeys","Object","keys","storedImpressionsCurrent","every","newKey","includes","componentWillUnmount","remove","colors","gradients","rawStyles","rawFeatures","componentDidUpdate","prevProps","isReady","isUnsupportedBlock","unsupportedBlockNames","filter","block","attributes","originalName","RNReactNativeGutenbergBridge","editorDidMount","mode","hasChanges","raw","content","contentInfo","characterCount","wordCount","paragraphCount","provideToNative_Html","parsed","resetEditorBlocksWithoutUndoLevel","blockClientId","replaceBlock","switchMode","clearSelectedBlock","render","children","select","__unstableIsEditorReady","isEditorReady","getEditorBlocks","getEditedPostAttribute","getEditedPostContent","getEditorMode","getBlockIndex","getSelectedBlockClientId","getGlobalBlockCount","getSettings","getBlockEditorSettings","blockEditorStore","selectedBlockClientId","dispatch","editPost","resetEditorBlocks","switchEditorMode","__unstableShouldCreateUndoLevel"],"mappings":";;;;;;;;;;;AAsBA;;;;AAnBA;;AAKA;;AAeA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAmBA;;AAKA;;AA/DA;AACA;AACA;;AAGA;AACA;AACA;AAkCA,MAAMA,gBAAgB,GAAG,CACxB;AAAEC,EAAAA,IAAI,EAAE,MAAR;AAAgBC,EAAAA,OAAO,EAAE;AAAzB,CADwB,EAExB;AAAED,EAAAA,IAAI,EAAE,MAAR;AAAgBC,EAAAA,OAAO,EAAE;AAAzB,CAFwB,EAGxB;AAAED,EAAAA,IAAI,EAAE,YAAR;AAAsBC,EAAAA,OAAO,EAAE;AAA/B,CAHwB,EAIxB;AAAED,EAAAA,IAAI,EAAE,UAAR;AAAoBC,EAAAA,OAAO,EAAE;AAA7B,CAJwB,EAKvBC,GALuB,CAKhBC,cAAF,KAAwB;AAC9BC,EAAAA,IAAI,EAAE,UADwB;AAE9B,KAAGD,cAF2B;AAG9BE,EAAAA,cAAc,EAAE;AACfC,IAAAA,MAAM,EAAE,IADO;AAEfC,IAAAA,SAAS,EAAE;AAFI,GAHc;AAO9BC,EAAAA,WAAW,EAAE;AACZC,IAAAA,IAAI,EAAE;AADM,GAPiB;AAU9BC,EAAAA,aAAa,EAAE,CAAE,OAAF,EAAW,SAAX,EAAsB,SAAtB;AAVe,CAAxB,CALkB,CAAzB;;AAwBA,MAAMC,oBAAN,SAAmCC,kBAAnC,CAA6C;AAC5CC,EAAAA,WAAW,GAAG;AACb,UAAO,GAAGC,SAAV,EADa,CAGb;;AACA,SAAKC,IAAL,GAAY,KAAKC,KAAL,CAAWD,IAAvB;AACA,SAAKC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;AAGA,KAdK;;AAeNtB,IAAAA,UAAU,CAAEb,IAAF,EAAS;AAClBkC,MAAAA,gBAAgB,CAAElC,IAAF,CAAhB;AACA,KAjBK;;AAkBNY,IAAAA;AAlBM,GAAP;AAoBA,CAhCD,CA9BuB,CAAT,EA+DV/F,oBA/DU,C","sourcesContent":["/**\n * External dependencies\n */\nimport memize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport RNReactNativeGutenbergBridge, {\n\trequestBlockTypeImpressions,\n\tsetBlockTypeImpressions,\n\tsubscribeParentGetHtml,\n\tsubscribeParentToggleHTMLMode,\n\tsubscribeUpdateHtml,\n\tsubscribeSetTitle,\n\tsubscribeMediaAppend,\n\tsubscribeReplaceBlock,\n\tsubscribeUpdateEditorSettings,\n\tsubscribeUpdateCapabilities,\n\tsubscribeShowNotice,\n\tsubscribeShowEditorHelp,\n} from '@wordpress/react-native-bridge';\nimport { Component } from '@wordpress/element';\nimport { count as wordCount } from '@wordpress/wordcount';\nimport {\n\tparse,\n\tserialize,\n\tgetUnregisteredTypeHandlerName,\n\tcreateBlock,\n} from '@wordpress/blocks';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { applyFilters } from '@wordpress/hooks';\nimport {\n\tvalidateThemeColors,\n\tvalidateThemeGradients,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { getGlobalStyles } from '@wordpress/components';\nimport { NEW_BLOCK_TYPES } from '@wordpress/block-library';\n\nconst postTypeEntities = [\n\t{ name: 'post', baseURL: '/wp/v2/posts' },\n\t{ name: 'page', baseURL: '/wp/v2/pages' },\n\t{ name: 'attachment', baseURL: '/wp/v2/media' },\n\t{ name: 'wp_block', baseURL: '/wp/v2/blocks' },\n].map( ( postTypeEntity ) => ( {\n\tkind: 'postType',\n\t...postTypeEntity,\n\ttransientEdits: {\n\t\tblocks: true,\n\t\tselection: true,\n\t},\n\tmergedEdits: {\n\t\tmeta: true,\n\t},\n\trawAttributes: [ 'title', 'excerpt', 'content' ],\n} ) );\nimport { EditorHelpTopics } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport EditorProvider from './index.js';\n\nclass NativeEditorProvider extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\t// Keep a local reference to `post` to detect changes\n\t\tthis.post = this.props.post;\n\t\tthis.props.addEntities( postTypeEntities );\n\t\tthis.props.receiveEntityRecords(\n\t\t\t'postType',\n\t\t\tthis.post.type,\n\t\t\tthis.post\n\t\t);\n\t\tthis.getEditorSettings = memize(\n\t\t\t( settings, capabilities ) => ( {\n\t\t\t\t...settings,\n\t\t\t\tcapabilities,\n\t\t\t} ),\n\t\t\t{\n\t\t\t\tmaxSize: 1,\n\t\t\t}\n\t\t);\n\t\tthis.state = {\n\t\t\tisHelpVisible: false,\n\t\t};\n\t}\n\n\tcomponentDidMount() {\n\t\tconst {\n\t\t\tcapabilities,\n\t\t\tlocale,\n\t\t\tupdateSettings,\n\t\t\tgalleryWithImageBlocks,\n\t\t} = this.props;\n\n\t\tupdateSettings( {\n\t\t\t...capabilities,\n\t\t\t...{ __unstableGalleryWithImageBlocks: galleryWithImageBlocks },\n\t\t\t...this.getThemeColors( this.props ),\n\t\t\tlocale,\n\t\t} );\n\n\t\tthis.subscriptionParentGetHtml = subscribeParentGetHtml( () => {\n\t\t\tthis.serializeToNativeAction();\n\t\t} );\n\n\t\tthis.subscriptionParentToggleHTMLMode = subscribeParentToggleHTMLMode(\n\t\t\t() => {\n\t\t\t\tthis.toggleMode();\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentSetTitle = subscribeSetTitle( ( payload ) => {\n\t\t\tthis.props.editTitle( payload.title );\n\t\t} );\n\n\t\tthis.subscriptionParentUpdateHtml = subscribeUpdateHtml(\n\t\t\t( payload ) => {\n\t\t\t\tthis.updateHtmlAction( payload.html );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentReplaceBlock = subscribeReplaceBlock(\n\t\t\t( payload ) => {\n\t\t\t\tthis.replaceBlockAction( payload.html, payload.clientId );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentMediaAppend = subscribeMediaAppend(\n\t\t\t( payload ) => {\n\t\t\t\tconst blockName = 'core/' + payload.mediaType;\n\t\t\t\tconst newBlock = createBlock( blockName, {\n\t\t\t\t\tid: payload.mediaId,\n\t\t\t\t\t[ payload.mediaType === 'image'\n\t\t\t\t\t\t? 'url'\n\t\t\t\t\t\t: 'src' ]: payload.mediaUrl,\n\t\t\t\t} );\n\n\t\t\t\tconst indexAfterSelected = this.props.selectedBlockIndex + 1;\n\t\t\t\tconst insertionIndex =\n\t\t\t\t\tindexAfterSelected || this.props.blockCount;\n\n\t\t\t\tthis.props.insertBlock( newBlock, insertionIndex );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentUpdateEditorSettings = subscribeUpdateEditorSettings(\n\t\t\t( editorSettings ) => {\n\t\t\t\tupdateSettings( {\n\t\t\t\t\t...{\n\t\t\t\t\t\t__unstableGalleryWithImageBlocks:\n\t\t\t\t\t\t\teditorSettings.galleryWithImageBlocks,\n\t\t\t\t\t},\n\t\t\t\t\t...this.getThemeColors( editorSettings ),\n\t\t\t\t} );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentUpdateCapabilities = subscribeUpdateCapabilities(\n\t\t\t( payload ) => {\n\t\t\t\tthis.updateCapabilitiesAction( payload );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentShowNotice = subscribeShowNotice(\n\t\t\t( payload ) => {\n\t\t\t\tthis.props.createSuccessNotice( payload.message );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentShowEditorHelp = subscribeShowEditorHelp( () => {\n\t\t\tthis.setState( { isHelpVisible: true } );\n\t\t} );\n\n\t\t// Request current block impressions from native app\n\t\trequestBlockTypeImpressions( ( storedImpressions ) => {\n\t\t\tconst impressions = { ...NEW_BLOCK_TYPES, ...storedImpressions };\n\n\t\t\t// Persist impressions to JavaScript store\n\t\t\tupdateSettings( { impressions } );\n\n\t\t\t// Persist impressions to native store if they do not include latest\n\t\t\t// `NEW_BLOCK_TYPES` configuration\n\t\t\tconst storedImpressionKeys = Object.keys( storedImpressions );\n\t\t\tconst storedImpressionsCurrent = Object.keys(\n\t\t\t\tNEW_BLOCK_TYPES\n\t\t\t).every( ( newKey ) => storedImpressionKeys.includes( newKey ) );\n\t\t\tif ( ! storedImpressionsCurrent ) {\n\t\t\t\tsetBlockTypeImpressions( impressions );\n\t\t\t}\n\t\t} );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( this.subscriptionParentGetHtml ) {\n\t\t\tthis.subscriptionParentGetHtml.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentToggleHTMLMode ) {\n\t\t\tthis.subscriptionParentToggleHTMLMode.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentSetTitle ) {\n\t\t\tthis.subscriptionParentSetTitle.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentUpdateHtml ) {\n\t\t\tthis.subscriptionParentUpdateHtml.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentReplaceBlock ) {\n\t\t\tthis.subscriptionParentReplaceBlock.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentMediaAppend ) {\n\t\t\tthis.subscriptionParentMediaAppend.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentUpdateEditorSettings ) {\n\t\t\tthis.subscriptionParentUpdateEditorSettings.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentUpdateCapabilities ) {\n\t\t\tthis.subscriptionParentUpdateCapabilities.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentShowNotice ) {\n\t\t\tthis.subscriptionParentShowNotice.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentShowEditorHelp ) {\n\t\t\tthis.subscriptionParentShowEditorHelp.remove();\n\t\t}\n\t}\n\n\tgetThemeColors( { colors, gradients, rawStyles, rawFeatures } ) {\n\t\treturn {\n\t\t\t...( rawStyles && rawFeatures\n\t\t\t\t? getGlobalStyles( rawStyles, rawFeatures )\n\t\t\t\t: {\n\t\t\t\t\t\tcolors: validateThemeColors( colors ),\n\t\t\t\t\t\tgradients: validateThemeGradients( gradients ),\n\t\t\t\t } ),\n\t\t};\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tif ( ! prevProps.isReady && this.props.isReady ) {\n\t\t\tconst blocks = this.props.blocks;\n\t\t\tconst isUnsupportedBlock = ( { name } ) =>\n\t\t\t\tname === getUnregisteredTypeHandlerName();\n\t\t\tconst unsupportedBlockNames = blocks\n\t\t\t\t.filter( isUnsupportedBlock )\n\t\t\t\t.map( ( block ) => block.attributes.originalName );\n\t\t\tRNReactNativeGutenbergBridge.editorDidMount(\n\t\t\t\tunsupportedBlockNames\n\t\t\t);\n\t\t}\n\t}\n\n\tserializeToNativeAction() {\n\t\tconst title = this.props.title;\n\t\tlet html;\n\n\t\tif ( this.props.mode === 'text' ) {\n\t\t\t// The HTMLTextInput component does not update the store when user is doing changes\n\t\t\t// Let's request the HTML from the component's state directly\n\t\t\thtml = applyFilters( 'native.persist-html' );\n\t\t} else {\n\t\t\thtml = serialize( this.props.blocks );\n\t\t}\n\n\t\tconst hasChanges =\n\t\t\ttitle !== this.post.title.raw || html !== this.post.content.raw;\n\n\t\t// Variable to store the content structure metrics.\n\t\tconst contentInfo = {};\n\t\tcontentInfo.characterCount = wordCount(\n\t\t\thtml,\n\t\t\t'characters_including_spaces'\n\t\t);\n\t\tcontentInfo.wordCount = wordCount( html, 'words' );\n\t\tcontentInfo.paragraphCount = this.props.paragraphCount;\n\t\tcontentInfo.blockCount = this.props.blockCount;\n\t\tRNReactNativeGutenbergBridge.provideToNative_Html(\n\t\t\thtml,\n\t\t\ttitle,\n\t\t\thasChanges,\n\t\t\tcontentInfo\n\t\t);\n\n\t\tif ( hasChanges ) {\n\t\t\tthis.post.title.raw = title;\n\t\t\tthis.post.content.raw = html;\n\t\t}\n\t}\n\n\tupdateHtmlAction( html ) {\n\t\tconst parsed = parse( html );\n\t\tthis.props.resetEditorBlocksWithoutUndoLevel( parsed );\n\t}\n\n\treplaceBlockAction( html, blockClientId ) {\n\t\tconst parsed = parse( html );\n\t\tthis.props.replaceBlock( blockClientId, parsed );\n\t}\n\n\ttoggleMode() {\n\t\tconst { mode, switchMode } = this.props;\n\t\t// refresh html content first\n\t\tthis.serializeToNativeAction();\n\t\t// make sure to blur the selected block and dismiss the keyboard\n\t\tthis.props.clearSelectedBlock();\n\t\tswitchMode( mode === 'visual' ? 'text' : 'visual' );\n\t}\n\n\tupdateCapabilitiesAction( capabilities ) {\n\t\tthis.props.updateSettings( capabilities );\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tchildren,\n\t\t\tpost, // eslint-disable-line no-unused-vars\n\t\t\tcapabilities,\n\t\t\tsettings,\n\t\t\t...props\n\t\t} = this.props;\n\t\tconst editorSettings = this.getEditorSettings( settings, capabilities );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<EditorProvider\n\t\t\t\t\tpost={ this.post }\n\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t{ ...props }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</EditorProvider>\n\t\t\t\t<EditorHelpTopics\n\t\t\t\t\tisVisible={ this.state.isHelpVisible }\n\t\t\t\t\tonClose={ () => this.setState( { isHelpVisible: false } ) }\n\t\t\t\t\tclose={ () => this.setState( { isHelpVisible: false } ) }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\t__unstableIsEditorReady: isEditorReady,\n\t\t\tgetEditorBlocks,\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetEditedPostContent,\n\t\t} = select( 'core/editor' );\n\t\tconst { getEditorMode } = select( 'core/edit-post' );\n\n\t\tconst {\n\t\t\tgetBlockIndex,\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetGlobalBlockCount,\n\t\t\tgetSettings: getBlockEditorSettings,\n\t\t} = select( blockEditorStore );\n\n\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\treturn {\n\t\t\tmode: getEditorMode(),\n\t\t\tisReady: isEditorReady(),\n\t\t\tblocks: getEditorBlocks(),\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\tgetEditedPostContent,\n\t\t\tgetBlockEditorSettings,\n\t\t\tselectedBlockIndex: getBlockIndex( selectedBlockClientId ),\n\t\t\tblockCount: getGlobalBlockCount(),\n\t\t\tparagraphCount: getGlobalBlockCount( 'core/paragraph' ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { editPost, resetEditorBlocks } = dispatch( 'core/editor' );\n\t\tconst {\n\t\t\tupdateSettings,\n\t\t\tclearSelectedBlock,\n\t\t\tinsertBlock,\n\t\t\treplaceBlock,\n\t\t} = dispatch( blockEditorStore );\n\t\tconst { switchEditorMode } = dispatch( 'core/edit-post' );\n\t\tconst { addEntities, receiveEntityRecords } = dispatch( 'core' );\n\t\tconst { createSuccessNotice } = dispatch( 'core/notices' );\n\n\t\treturn {\n\t\t\tupdateSettings,\n\t\t\taddEntities,\n\t\t\tclearSelectedBlock,\n\t\t\tinsertBlock,\n\t\t\tcreateSuccessNotice,\n\t\t\teditTitle( title ) {\n\t\t\t\teditPost( { title } );\n\t\t\t},\n\t\t\treceiveEntityRecords,\n\t\t\tresetEditorBlocksWithoutUndoLevel( blocks ) {\n\t\t\t\tresetEditorBlocks( blocks, {\n\t\t\t\t\t__unstableShouldCreateUndoLevel: false,\n\t\t\t\t} );\n\t\t\t},\n\t\t\tswitchMode( mode ) {\n\t\t\t\tswitchEditorMode( mode );\n\t\t\t},\n\t\t\treplaceBlock,\n\t\t};\n\t} ),\n] )( NativeEditorProvider );\n"]}
|
|
@@ -13,6 +13,8 @@ var _data = require("@wordpress/data");
|
|
|
13
13
|
|
|
14
14
|
var _coreData = require("@wordpress/core-data");
|
|
15
15
|
|
|
16
|
+
var _i18n = require("@wordpress/i18n");
|
|
17
|
+
|
|
16
18
|
var _utils = require("../../utils");
|
|
17
19
|
|
|
18
20
|
var _store = require("../../store");
|
|
@@ -41,7 +43,8 @@ function useBlockEditorSettings(settings, hasTemplate) {
|
|
|
41
43
|
const {
|
|
42
44
|
reusableBlocks,
|
|
43
45
|
hasUploadPermissions,
|
|
44
|
-
canUseUnfilteredHTML
|
|
46
|
+
canUseUnfilteredHTML,
|
|
47
|
+
userCanCreatePages
|
|
45
48
|
} = (0, _data.useSelect)(select => {
|
|
46
49
|
const {
|
|
47
50
|
canUserUseUnfilteredHTML
|
|
@@ -62,21 +65,45 @@ function useBlockEditorSettings(settings, hasTemplate) {
|
|
|
62
65
|
// Reusable blocks are fetched in the native version of this hook.
|
|
63
66
|
hasUploadPermissions: (0, _lodash.defaultTo)(canUser('create', 'media'), true),
|
|
64
67
|
hasResolvedLocalSiteData: hasFinishedResolvingSiteData,
|
|
65
|
-
baseUrl: (siteData === null || siteData === void 0 ? void 0 : siteData.url) || ''
|
|
68
|
+
baseUrl: (siteData === null || siteData === void 0 ? void 0 : siteData.url) || '',
|
|
69
|
+
userCanCreatePages: canUser('create', 'pages')
|
|
66
70
|
};
|
|
67
71
|
}, []);
|
|
68
72
|
const {
|
|
69
73
|
undo
|
|
70
74
|
} = (0, _data.useDispatch)(_store.store);
|
|
71
|
-
|
|
75
|
+
const {
|
|
76
|
+
saveEntityRecord
|
|
77
|
+
} = (0, _data.useDispatch)(_coreData.store);
|
|
78
|
+
/**
|
|
79
|
+
* Creates a Post entity.
|
|
80
|
+
* This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.
|
|
81
|
+
*
|
|
82
|
+
* @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.
|
|
83
|
+
* @return {Object} the post type object that was created.
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
const createPageEntity = options => {
|
|
87
|
+
if (!userCanCreatePages) {
|
|
88
|
+
return Promise.reject({
|
|
89
|
+
message: (0, _i18n.__)('You do not have permission to create Pages.')
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return saveEntityRecord('postType', 'page', options);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return (0, _element.useMemo)(() => ({ ...(0, _lodash.pick)(settings, ['__experimentalBlockDirectory', '__experimentalBlockPatternCategories', '__experimentalBlockPatterns', '__experimentalFeatures', '__experimentalPreferredStyleVariations', '__experimentalSetIsInserterOpened', '__unstableGalleryWithImageBlocks', 'alignWide', 'allowedBlockTypes', 'bodyPlaceholder', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomGradients', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'focusMode', 'fontSizes', 'gradients', 'hasFixedToolbar', 'hasReducedUI', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isRTL', 'keepCaretInsideBlock', 'maxWidth', 'onUpdateDefaultBlockStyles', 'styles', 'template', 'templateLock', 'titlePlaceholder', 'supportsLayout', 'widgetTypesToHideFromLegacyWidgetBlock']),
|
|
72
97
|
mediaUpload: hasUploadPermissions ? _utils.mediaUpload : undefined,
|
|
73
98
|
__experimentalReusableBlocks: reusableBlocks,
|
|
74
99
|
__experimentalFetchLinkSuggestions: (search, searchOptions) => (0, _coreData.__experimentalFetchLinkSuggestions)(search, searchOptions, settings),
|
|
75
100
|
__experimentalFetchRichUrlData: _coreData.__experimentalFetchUrlData,
|
|
76
101
|
__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,
|
|
77
102
|
__experimentalUndo: undo,
|
|
78
|
-
outlineMode: hasTemplate
|
|
79
|
-
|
|
103
|
+
outlineMode: hasTemplate,
|
|
104
|
+
__experimentalCreatePageEntity: createPageEntity,
|
|
105
|
+
__experimentalUserCanCreatePages: userCanCreatePages
|
|
106
|
+
}), [settings, hasUploadPermissions, reusableBlocks, canUseUnfilteredHTML, undo, hasTemplate, userCanCreatePages]);
|
|
80
107
|
}
|
|
81
108
|
|
|
82
109
|
var _default = useBlockEditorSettings;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/provider/use-block-editor-settings.js"],"names":["useBlockEditorSettings","settings","hasTemplate","reusableBlocks","hasUploadPermissions","canUseUnfilteredHTML","select","canUserUseUnfilteredHTML","editorStore","isWeb","Platform","OS","canUser","getUnstableBase","hasFinishedResolution","coreStore","siteData","hasFinishedResolvingSiteData","getEntityRecords","per_page","hasResolvedLocalSiteData","baseUrl","url","undo","mediaUpload","undefined","__experimentalReusableBlocks","__experimentalFetchLinkSuggestions","search","searchOptions","__experimentalFetchRichUrlData","fetchUrlData","__experimentalCanUserUseUnfilteredHTML","__experimentalUndo","outlineMode"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/provider/use-block-editor-settings.js"],"names":["useBlockEditorSettings","settings","hasTemplate","reusableBlocks","hasUploadPermissions","canUseUnfilteredHTML","userCanCreatePages","select","canUserUseUnfilteredHTML","editorStore","isWeb","Platform","OS","canUser","getUnstableBase","hasFinishedResolution","coreStore","siteData","hasFinishedResolvingSiteData","getEntityRecords","per_page","hasResolvedLocalSiteData","baseUrl","url","undo","saveEntityRecord","createPageEntity","options","Promise","reject","message","mediaUpload","undefined","__experimentalReusableBlocks","__experimentalFetchLinkSuggestions","search","searchOptions","__experimentalFetchRichUrlData","fetchUrlData","__experimentalCanUserUseUnfilteredHTML","__experimentalUndo","outlineMode","__experimentalCreatePageEntity","__experimentalUserCanCreatePages"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,sBAAT,CAAiCC,QAAjC,EAA2CC,WAA3C,EAAyD;AACxD,QAAM;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iB,IAAAA,WAAW,EAAEvC,WA/CN;AAgDPwC,IAAAA,8BAA8B,EAAEhB,gBAhDzB;AAiDPiB,IAAAA,gCAAgC,EAAErC;AAjD3B,GAAR,CADM,EAoDN,CACCL,QADD,EAECG,oBAFD,EAGCD,cAHD,EAICE,oBAJD,EAKCmB,IALD,EAMCtB,WAND,EAOCI,kBAPD,CApDM,CAAP;AA8DA;;eAEcN,sB","sourcesContent":["/**\n * External dependencies\n */\nimport { pick, defaultTo } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Platform, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as coreStore,\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { mediaUpload } from '../../utils';\nimport { store as editorStore } from '../../store';\n\n/**\n * React hook used to compute the block editor settings to use for the post editor.\n *\n * @param {Object} settings EditorProvider settings prop.\n * @param {boolean} hasTemplate Whether template mode is enabled.\n *\n * @return {Object} Block Editor Settings.\n */\nfunction useBlockEditorSettings( settings, hasTemplate ) {\n\tconst {\n\t\treusableBlocks,\n\t\thasUploadPermissions,\n\t\tcanUseUnfilteredHTML,\n\t\tuserCanCreatePages,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUserUseUnfilteredHTML } = select( editorStore );\n\t\tconst isWeb = Platform.OS === 'web';\n\t\tconst { canUser, getUnstableBase, hasFinishedResolution } = select(\n\t\t\tcoreStore\n\t\t);\n\n\t\tconst siteData = getUnstableBase();\n\n\t\tconst hasFinishedResolvingSiteData = hasFinishedResolution(\n\t\t\t'getUnstableBase'\n\t\t);\n\n\t\treturn {\n\t\t\tcanUseUnfilteredHTML: canUserUseUnfilteredHTML(),\n\t\t\treusableBlocks: isWeb\n\t\t\t\t? select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_block',\n\t\t\t\t\t\t{ per_page: -1 }\n\t\t\t\t )\n\t\t\t\t: [], // Reusable blocks are fetched in the native version of this hook.\n\t\t\thasUploadPermissions: defaultTo(\n\t\t\t\tcanUser( 'create', 'media' ),\n\t\t\t\ttrue\n\t\t\t),\n\t\t\thasResolvedLocalSiteData: hasFinishedResolvingSiteData,\n\t\t\tbaseUrl: siteData?.url || '',\n\t\t\tuserCanCreatePages: canUser( 'create', 'pages' ),\n\t\t};\n\t}, [] );\n\n\tconst { undo } = useDispatch( editorStore );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\t/**\n\t * Creates a Post entity.\n\t * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.\n\t *\n\t * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.\n\t * @return {Object} the post type object that was created.\n\t */\n\tconst createPageEntity = ( options ) => {\n\t\tif ( ! userCanCreatePages ) {\n\t\t\treturn Promise.reject( {\n\t\t\t\tmessage: __( 'You do not have permission to create Pages.' ),\n\t\t\t} );\n\t\t}\n\t\treturn saveEntityRecord( 'postType', 'page', options );\n\t};\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\t...pick( settings, [\n\t\t\t\t'__experimentalBlockDirectory',\n\t\t\t\t'__experimentalBlockPatternCategories',\n\t\t\t\t'__experimentalBlockPatterns',\n\t\t\t\t'__experimentalFeatures',\n\t\t\t\t'__experimentalPreferredStyleVariations',\n\t\t\t\t'__experimentalSetIsInserterOpened',\n\t\t\t\t'__unstableGalleryWithImageBlocks',\n\t\t\t\t'alignWide',\n\t\t\t\t'allowedBlockTypes',\n\t\t\t\t'bodyPlaceholder',\n\t\t\t\t'codeEditingEnabled',\n\t\t\t\t'colors',\n\t\t\t\t'disableCustomColors',\n\t\t\t\t'disableCustomFontSizes',\n\t\t\t\t'disableCustomGradients',\n\t\t\t\t'enableCustomLineHeight',\n\t\t\t\t'enableCustomSpacing',\n\t\t\t\t'enableCustomUnits',\n\t\t\t\t'focusMode',\n\t\t\t\t'fontSizes',\n\t\t\t\t'gradients',\n\t\t\t\t'hasFixedToolbar',\n\t\t\t\t'hasReducedUI',\n\t\t\t\t'imageDefaultSize',\n\t\t\t\t'imageDimensions',\n\t\t\t\t'imageEditing',\n\t\t\t\t'imageSizes',\n\t\t\t\t'isRTL',\n\t\t\t\t'keepCaretInsideBlock',\n\t\t\t\t'maxWidth',\n\t\t\t\t'onUpdateDefaultBlockStyles',\n\t\t\t\t'styles',\n\t\t\t\t'template',\n\t\t\t\t'templateLock',\n\t\t\t\t'titlePlaceholder',\n\t\t\t\t'supportsLayout',\n\t\t\t\t'widgetTypesToHideFromLegacyWidgetBlock',\n\t\t\t] ),\n\t\t\tmediaUpload: hasUploadPermissions ? mediaUpload : undefined,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\t__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>\n\t\t\t\tfetchLinkSuggestions( search, searchOptions, settings ),\n\t\t\t__experimentalFetchRichUrlData: fetchUrlData,\n\t\t\t__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,\n\t\t\t__experimentalUndo: undo,\n\t\t\toutlineMode: hasTemplate,\n\t\t\t__experimentalCreatePageEntity: createPageEntity,\n\t\t\t__experimentalUserCanCreatePages: userCanCreatePages,\n\t\t} ),\n\t\t[\n\t\t\tsettings,\n\t\t\thasUploadPermissions,\n\t\t\treusableBlocks,\n\t\t\tcanUseUnfilteredHTML,\n\t\t\tundo,\n\t\t\thasTemplate,\n\t\t\tuserCanCreatePages,\n\t\t]\n\t);\n}\n\nexport default useBlockEditorSettings;\n"]}
|
|
@@ -23,7 +23,7 @@ var _store = require("../../store");
|
|
|
23
23
|
* Internal dependencies
|
|
24
24
|
*/
|
|
25
25
|
function WordCount() {
|
|
26
|
-
const content = (0, _data.useSelect)(select => select(_store.store).getEditedPostAttribute('content'));
|
|
26
|
+
const content = (0, _data.useSelect)(select => select(_store.store).getEditedPostAttribute('content'), []);
|
|
27
27
|
/*
|
|
28
28
|
* translators: If your word count is based on single characters (e.g. East Asian characters),
|
|
29
29
|
* enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/word-count/index.js"],"names":["WordCount","content","select","editorStore","getEditedPostAttribute","wordCountType"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGe,SAASA,SAAT,GAAqB;AACnC,QAAMC,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/word-count/index.js"],"names":["WordCount","content","select","editorStore","getEditedPostAttribute","wordCountType"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGe,SAASA,SAAT,GAAqB;AACnC,QAAMC,OAAO,GAAG,qBACbC,MAAF,IAAcA,MAAM,CAAEC,YAAF,CAAN,CAAsBC,sBAAtB,CAA8C,SAA9C,CADC,EAEf,EAFe,CAAhB;AAKA;AACD;AACA;AACA;AACA;;AACC,QAAMC,aAAa,GAAG,cAAI,OAAJ,EAAa,oCAAb,CAAtB;AAEA,SACC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACG,sBAAWJ,OAAX,EAAoBI,aAApB,CADH,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { _x } from '@wordpress/i18n';\nimport { count as wordCount } from '@wordpress/wordcount';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function WordCount() {\n\tconst content = useSelect(\n\t\t( select ) => select( editorStore ).getEditedPostAttribute( 'content' ),\n\t\t[]\n\t);\n\n\t/*\n\t * translators: If your word count is based on single characters (e.g. East Asian characters),\n\t * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.\n\t * Do not translate into your own language.\n\t */\n\tconst wordCountType = _x( 'words', 'Word count type. Do not translate!' );\n\n\treturn (\n\t\t<span className=\"word-count\">\n\t\t\t{ wordCount( content, wordCountType ) }\n\t\t</span>\n\t);\n}\n"]}
|
package/build/store/actions.js
CHANGED
|
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.setupEditor = setupEditor;
|
|
9
9
|
exports.__experimentalTearDownEditor = __experimentalTearDownEditor;
|
|
10
10
|
exports.resetPost = resetPost;
|
|
11
|
-
exports.resetAutosave = resetAutosave;
|
|
12
11
|
exports.__experimentalRequestPostUpdateStart = __experimentalRequestPostUpdateStart;
|
|
13
12
|
exports.__experimentalRequestPostUpdateFinish = __experimentalRequestPostUpdateFinish;
|
|
14
13
|
exports.updatePost = updatePost;
|
|
@@ -136,30 +135,6 @@ function resetPost(post) {
|
|
|
136
135
|
post
|
|
137
136
|
};
|
|
138
137
|
}
|
|
139
|
-
/**
|
|
140
|
-
* Returns an action object used in signalling that the latest autosave of the
|
|
141
|
-
* post has been received, by initialization or autosave.
|
|
142
|
-
*
|
|
143
|
-
* @deprecated since 5.6. Callers should use the `receiveAutosaves( postId, autosave )`
|
|
144
|
-
* selector from the '@wordpress/core-data' package.
|
|
145
|
-
*
|
|
146
|
-
* @param {Object} newAutosave Autosave post object.
|
|
147
|
-
*
|
|
148
|
-
* @return {Object} Action object.
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
function* resetAutosave(newAutosave) {
|
|
153
|
-
(0, _deprecated.default)('resetAutosave action (`core/editor` store)', {
|
|
154
|
-
since: '5.3',
|
|
155
|
-
alternative: 'receiveAutosaves action (`core` store)'
|
|
156
|
-
});
|
|
157
|
-
const postId = yield _data.controls.select(_constants.STORE_NAME, 'getCurrentPostId');
|
|
158
|
-
yield _data.controls.dispatch(_coreData.store.name, 'receiveAutosaves', postId, newAutosave);
|
|
159
|
-
return {
|
|
160
|
-
type: '__INERT__'
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
138
|
/**
|
|
164
139
|
* Action for dispatching that a post update request has started.
|
|
165
140
|
*
|
|
@@ -240,7 +215,7 @@ function* editPost(edits, options) {
|
|
|
240
215
|
id,
|
|
241
216
|
type
|
|
242
217
|
} = yield _data.controls.select(_constants.STORE_NAME, 'getCurrentPost');
|
|
243
|
-
yield _data.controls.dispatch(_coreData.store
|
|
218
|
+
yield _data.controls.dispatch(_coreData.store, 'editEntityRecord', 'postType', type, id, edits, options);
|
|
244
219
|
}
|
|
245
220
|
/**
|
|
246
221
|
* Action generator for saving the current post in the editor.
|
|
@@ -268,12 +243,12 @@ function* savePost(options = {}) {
|
|
|
268
243
|
const previousRecord = yield _data.controls.select(_constants.STORE_NAME, 'getCurrentPost');
|
|
269
244
|
edits = {
|
|
270
245
|
id: previousRecord.id,
|
|
271
|
-
...(yield _data.controls.select(_coreData.store
|
|
246
|
+
...(yield _data.controls.select(_coreData.store, 'getEntityRecordNonTransientEdits', 'postType', previousRecord.type, previousRecord.id)),
|
|
272
247
|
...edits
|
|
273
248
|
};
|
|
274
|
-
yield _data.controls.dispatch(_coreData.store
|
|
249
|
+
yield _data.controls.dispatch(_coreData.store, 'saveEntityRecord', 'postType', previousRecord.type, edits, options);
|
|
275
250
|
yield __experimentalRequestPostUpdateFinish(options);
|
|
276
|
-
const error = yield _data.controls.select(_coreData.store
|
|
251
|
+
const error = yield _data.controls.select(_coreData.store, 'getLastEntitySaveError', 'postType', previousRecord.type, previousRecord.id);
|
|
277
252
|
|
|
278
253
|
if (error) {
|
|
279
254
|
const args = (0, _noticeBuilder.getNotificationArgumentsForSaveFail)({
|
|
@@ -290,7 +265,7 @@ function* savePost(options = {}) {
|
|
|
290
265
|
const args = (0, _noticeBuilder.getNotificationArgumentsForSaveSuccess)({
|
|
291
266
|
previousPost: previousRecord,
|
|
292
267
|
post: updatedRecord,
|
|
293
|
-
postType: yield _data.controls.resolveSelect(_coreData.store
|
|
268
|
+
postType: yield _data.controls.resolveSelect(_coreData.store, 'getPostType', updatedRecord.type),
|
|
294
269
|
options
|
|
295
270
|
});
|
|
296
271
|
|
|
@@ -301,7 +276,7 @@ function* savePost(options = {}) {
|
|
|
301
276
|
|
|
302
277
|
|
|
303
278
|
if (!options.isAutosave) {
|
|
304
|
-
yield _data.controls.dispatch(_blockEditor.store
|
|
279
|
+
yield _data.controls.dispatch(_blockEditor.store, '__unstableMarkLastChangeAsPersistent');
|
|
305
280
|
}
|
|
306
281
|
}
|
|
307
282
|
}
|
|
@@ -313,7 +288,7 @@ function* savePost(options = {}) {
|
|
|
313
288
|
function* refreshPost() {
|
|
314
289
|
const post = yield _data.controls.select(_constants.STORE_NAME, 'getCurrentPost');
|
|
315
290
|
const postTypeSlug = yield _data.controls.select(_constants.STORE_NAME, 'getCurrentPostType');
|
|
316
|
-
const postType = yield _data.controls.resolveSelect(_coreData.store
|
|
291
|
+
const postType = yield _data.controls.resolveSelect(_coreData.store, 'getPostType', postTypeSlug);
|
|
317
292
|
const newPost = yield (0, _dataControls.apiFetch)({
|
|
318
293
|
// Timestamp arg allows caller to bypass browser caching, which is
|
|
319
294
|
// expected for this specific function.
|
|
@@ -328,7 +303,7 @@ function* refreshPost() {
|
|
|
328
303
|
|
|
329
304
|
function* trashPost() {
|
|
330
305
|
const postTypeSlug = yield _data.controls.select(_constants.STORE_NAME, 'getCurrentPostType');
|
|
331
|
-
const postType = yield _data.controls.resolveSelect(_coreData.store
|
|
306
|
+
const postType = yield _data.controls.resolveSelect(_coreData.store, 'getPostType', postTypeSlug);
|
|
332
307
|
yield _data.controls.dispatch(_notices.store, 'removeNotice', _constants.TRASH_POST_NOTICE_ID);
|
|
333
308
|
|
|
334
309
|
try {
|
|
@@ -388,7 +363,7 @@ function* autosave({
|
|
|
388
363
|
|
|
389
364
|
|
|
390
365
|
function* redo() {
|
|
391
|
-
yield _data.controls.dispatch(_coreData.store
|
|
366
|
+
yield _data.controls.dispatch(_coreData.store, 'redo');
|
|
392
367
|
}
|
|
393
368
|
/**
|
|
394
369
|
* Returns an action object used in signalling that undo history should pop.
|
|
@@ -398,7 +373,7 @@ function* redo() {
|
|
|
398
373
|
|
|
399
374
|
|
|
400
375
|
function* undo() {
|
|
401
|
-
yield _data.controls.dispatch(_coreData.store
|
|
376
|
+
yield _data.controls.dispatch(_coreData.store, 'undo');
|
|
402
377
|
}
|
|
403
378
|
/**
|
|
404
379
|
* Returns an action object used in signalling that undo history record should
|
|
@@ -593,10 +568,10 @@ function* resetEditorBlocks(blocks, options = {}) {
|
|
|
593
568
|
id,
|
|
594
569
|
type
|
|
595
570
|
} = yield _data.controls.select(_constants.STORE_NAME, 'getCurrentPost');
|
|
596
|
-
const noChange = (yield _data.controls.select(_coreData.store
|
|
571
|
+
const noChange = (yield _data.controls.select(_coreData.store, 'getEditedEntityRecord', 'postType', type, id)).blocks === edits.blocks;
|
|
597
572
|
|
|
598
573
|
if (noChange) {
|
|
599
|
-
return yield _data.controls.dispatch(_coreData.store
|
|
574
|
+
return yield _data.controls.dispatch(_coreData.store, '__unstableCreateUndoLevel', 'postType', type, id);
|
|
600
575
|
} // We create a new function here on every persistent edit
|
|
601
576
|
// to make sure the edit makes the post dirty and creates
|
|
602
577
|
// a new undo level.
|
|
@@ -634,7 +609,7 @@ const getBlockEditorAction = name => function* (...args) {
|
|
|
634
609
|
since: '5.3',
|
|
635
610
|
alternative: "`wp.data.dispatch( 'core/block-editor' )." + name + '`'
|
|
636
611
|
});
|
|
637
|
-
yield _data.controls.dispatch(_blockEditor.store
|
|
612
|
+
yield _data.controls.dispatch(_blockEditor.store, name, ...args);
|
|
638
613
|
};
|
|
639
614
|
/**
|
|
640
615
|
* @see resetBlocks in core/block-editor store.
|