@wordpress/block-editor 12.19.2 → 12.19.4

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.
Files changed (148) hide show
  1. package/build/components/block-edit/context.js +2 -1
  2. package/build/components/block-edit/context.js.map +1 -1
  3. package/build/components/block-edit/index.js +8 -3
  4. package/build/components/block-edit/index.js.map +1 -1
  5. package/build/components/block-inspector/index.js +5 -4
  6. package/build/components/block-inspector/index.js.map +1 -1
  7. package/build/components/block-preview/index.js +4 -0
  8. package/build/components/block-preview/index.js.map +1 -1
  9. package/build/components/block-tools/insertion-point.js +4 -1
  10. package/build/components/block-tools/insertion-point.js.map +1 -1
  11. package/build/components/global-styles/advanced-panel.js +5 -10
  12. package/build/components/global-styles/advanced-panel.js.map +1 -1
  13. package/build/components/global-styles/border-panel.js +21 -8
  14. package/build/components/global-styles/border-panel.js.map +1 -1
  15. package/build/components/global-styles/index.js +6 -0
  16. package/build/components/global-styles/index.js.map +1 -1
  17. package/build/components/global-styles/shadow-panel-components.js +80 -23
  18. package/build/components/global-styles/shadow-panel-components.js.map +1 -1
  19. package/build/components/inserter/media-tab/media-preview.js +1 -1
  20. package/build/components/inserter/media-tab/media-preview.js.map +1 -1
  21. package/build/components/inspector-controls-tabs/styles-tab.js +1 -1
  22. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  23. package/build/components/link-control/link-preview.js +4 -1
  24. package/build/components/link-control/link-preview.js.map +1 -1
  25. package/build/components/rich-text/index.js +52 -28
  26. package/build/components/rich-text/index.js.map +1 -1
  27. package/build/components/rich-text/use-enter.js +3 -0
  28. package/build/components/rich-text/use-enter.js.map +1 -1
  29. package/build/components/rich-text/use-paste-handler.js +25 -26
  30. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  31. package/build/hooks/background.js +4 -2
  32. package/build/hooks/background.js.map +1 -1
  33. package/build/hooks/block-hooks.js +8 -6
  34. package/build/hooks/block-hooks.js.map +1 -1
  35. package/build/hooks/border.js +6 -4
  36. package/build/hooks/border.js.map +1 -1
  37. package/build/hooks/use-bindings-attributes.js +2 -4
  38. package/build/hooks/use-bindings-attributes.js.map +1 -1
  39. package/build/private-apis.js +5 -1
  40. package/build/private-apis.js.map +1 -1
  41. package/build/store/index.js +0 -2
  42. package/build/store/index.js.map +1 -1
  43. package/build/store/private-actions.js +0 -10
  44. package/build/store/private-actions.js.map +1 -1
  45. package/build/store/private-keys.js +8 -0
  46. package/build/store/private-keys.js.map +1 -0
  47. package/build/store/private-selectors.js +6 -17
  48. package/build/store/private-selectors.js.map +1 -1
  49. package/build/store/reducer.js +1 -24
  50. package/build/store/reducer.js.map +1 -1
  51. package/build/store/selectors.js +7 -12
  52. package/build/store/selectors.js.map +1 -1
  53. package/build/store/utils.js +7 -2
  54. package/build/store/utils.js.map +1 -1
  55. package/build-module/components/block-edit/context.js +1 -0
  56. package/build-module/components/block-edit/context.js.map +1 -1
  57. package/build-module/components/block-edit/index.js +9 -4
  58. package/build-module/components/block-edit/index.js.map +1 -1
  59. package/build-module/components/block-inspector/index.js +6 -5
  60. package/build-module/components/block-inspector/index.js.map +1 -1
  61. package/build-module/components/block-preview/index.js +4 -0
  62. package/build-module/components/block-preview/index.js.map +1 -1
  63. package/build-module/components/block-tools/insertion-point.js +4 -1
  64. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  65. package/build-module/components/global-styles/advanced-panel.js +6 -11
  66. package/build-module/components/global-styles/advanced-panel.js.map +1 -1
  67. package/build-module/components/global-styles/border-panel.js +22 -10
  68. package/build-module/components/global-styles/border-panel.js.map +1 -1
  69. package/build-module/components/global-styles/index.js +1 -1
  70. package/build-module/components/global-styles/index.js.map +1 -1
  71. package/build-module/components/global-styles/shadow-panel-components.js +82 -24
  72. package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
  73. package/build-module/components/inserter/media-tab/media-preview.js +1 -1
  74. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
  75. package/build-module/components/inspector-controls-tabs/styles-tab.js +2 -2
  76. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  77. package/build-module/components/link-control/link-preview.js +5 -2
  78. package/build-module/components/link-control/link-preview.js.map +1 -1
  79. package/build-module/components/rich-text/index.js +52 -29
  80. package/build-module/components/rich-text/index.js.map +1 -1
  81. package/build-module/components/rich-text/use-enter.js +3 -0
  82. package/build-module/components/rich-text/use-enter.js.map +1 -1
  83. package/build-module/components/rich-text/use-paste-handler.js +25 -26
  84. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  85. package/build-module/hooks/background.js +4 -2
  86. package/build-module/hooks/background.js.map +1 -1
  87. package/build-module/hooks/block-hooks.js +8 -6
  88. package/build-module/hooks/block-hooks.js.map +1 -1
  89. package/build-module/hooks/border.js +7 -5
  90. package/build-module/hooks/border.js.map +1 -1
  91. package/build-module/hooks/use-bindings-attributes.js +3 -5
  92. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  93. package/build-module/private-apis.js +5 -1
  94. package/build-module/private-apis.js.map +1 -1
  95. package/build-module/store/index.js +0 -2
  96. package/build-module/store/index.js.map +1 -1
  97. package/build-module/store/private-actions.js +0 -9
  98. package/build-module/store/private-actions.js.map +1 -1
  99. package/build-module/store/private-keys.js +2 -0
  100. package/build-module/store/private-keys.js.map +1 -0
  101. package/build-module/store/private-selectors.js +5 -12
  102. package/build-module/store/private-selectors.js.map +1 -1
  103. package/build-module/store/reducer.js +1 -24
  104. package/build-module/store/reducer.js.map +1 -1
  105. package/build-module/store/selectors.js +8 -13
  106. package/build-module/store/selectors.js.map +1 -1
  107. package/build-module/store/utils.js +6 -2
  108. package/build-module/store/utils.js.map +1 -1
  109. package/build-style/style-rtl.css +47 -24
  110. package/build-style/style.css +47 -24
  111. package/package.json +7 -7
  112. package/src/components/block-edit/context.js +1 -0
  113. package/src/components/block-edit/index.js +5 -1
  114. package/src/components/block-inspector/index.js +7 -5
  115. package/src/components/block-preview/index.js +6 -1
  116. package/src/components/block-toolbar/style.scss +11 -6
  117. package/src/components/block-tools/insertion-point.js +6 -1
  118. package/src/components/global-styles/advanced-panel.js +6 -12
  119. package/src/components/global-styles/border-panel.js +33 -22
  120. package/src/components/global-styles/index.js +5 -1
  121. package/src/components/global-styles/shadow-panel-components.js +92 -23
  122. package/src/components/global-styles/style.scss +33 -20
  123. package/src/components/inserter/media-tab/media-preview.js +6 -1
  124. package/src/components/inspector-controls-tabs/styles-tab.js +2 -2
  125. package/src/components/link-control/link-preview.js +9 -2
  126. package/src/components/link-control/style.scss +9 -0
  127. package/src/components/rich-text/index.js +74 -44
  128. package/src/components/rich-text/use-enter.js +4 -0
  129. package/src/components/rich-text/use-paste-handler.js +26 -25
  130. package/src/components/url-popover/style.scss +1 -0
  131. package/src/hooks/background.js +5 -2
  132. package/src/hooks/block-hooks.js +10 -5
  133. package/src/hooks/block-hooks.scss +6 -0
  134. package/src/hooks/border.js +16 -4
  135. package/src/hooks/use-bindings-attributes.js +5 -7
  136. package/src/private-apis.js +4 -0
  137. package/src/store/index.js +0 -2
  138. package/src/store/private-actions.js +0 -10
  139. package/src/store/private-keys.js +1 -0
  140. package/src/store/private-selectors.js +4 -15
  141. package/src/store/reducer.js +0 -25
  142. package/src/store/selectors.js +7 -15
  143. package/src/store/utils.js +7 -2
  144. package/build/store/resolvers.js +0 -27
  145. package/build/store/resolvers.js.map +0 -1
  146. package/build-module/store/resolvers.js +0 -20
  147. package/build-module/store/resolvers.js.map +0 -1
  148. package/src/store/resolvers.js +0 -17
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ exports.PrivateRichText = void 0;
7
8
  Object.defineProperty(exports, "RichTextShortcut", {
8
9
  enumerable: true,
9
10
  get: function () {
@@ -34,6 +35,7 @@ var _components = require("@wordpress/components");
34
35
  var _blocks = require("@wordpress/blocks");
35
36
  var _autocomplete = require("../autocomplete");
36
37
  var _blockEdit = require("../block-edit");
38
+ var _context = require("../block-edit/context");
37
39
  var _formatToolbarContainer = _interopRequireDefault(require("./format-toolbar-container"));
38
40
  var _store = require("../../store");
39
41
  var _useUndoAutomaticChange = require("./use-undo-automatic-change");
@@ -129,15 +131,18 @@ function RichTextWrapper({
129
131
  __unstableDisableFormats: disableFormats,
130
132
  disableLineBreaks,
131
133
  __unstableAllowPrefixTransformations,
134
+ disableEditing,
132
135
  ...props
133
136
  }, forwardedRef) {
134
137
  props = removeNativeProps(props);
135
138
  const anchorRef = (0, _element.useRef)();
139
+ const context = (0, _blockEdit.useBlockEditContext)();
136
140
  const {
137
141
  clientId,
138
142
  isSelected: isBlockSelected,
139
143
  name: blockName
140
- } = (0, _blockEdit.useBlockEditContext)();
144
+ } = context;
145
+ const blockBindings = context[_context.blockBindingsKey];
141
146
  const selector = select => {
142
147
  // Avoid subscribing to the block editor store if the block is not
143
148
  // selected.
@@ -148,48 +153,51 @@ function RichTextWrapper({
148
153
  }
149
154
  const {
150
155
  getSelectionStart,
151
- getSelectionEnd,
152
- getBlockAttributes
156
+ getSelectionEnd
153
157
  } = select(_store.store);
154
158
  const selectionStart = getSelectionStart();
155
159
  const selectionEnd = getSelectionEnd();
156
- const blockBindings = getBlockAttributes(clientId)?.metadata?.bindings;
157
160
  let isSelected;
158
161
  if (originalIsSelected === undefined) {
159
162
  isSelected = selectionStart.clientId === clientId && selectionEnd.clientId === clientId && selectionStart.attributeKey === identifier;
160
163
  } else if (originalIsSelected) {
161
164
  isSelected = selectionStart.clientId === clientId;
162
165
  }
163
-
166
+ return {
167
+ selectionStart: isSelected ? selectionStart.offset : undefined,
168
+ selectionEnd: isSelected ? selectionEnd.offset : undefined,
169
+ isSelected
170
+ };
171
+ };
172
+ const {
173
+ selectionStart,
174
+ selectionEnd,
175
+ isSelected
176
+ } = (0, _data.useSelect)(selector, [clientId, identifier, originalIsSelected, isBlockSelected]);
177
+ const disableBoundBlocks = (0, _data.useSelect)(select => {
164
178
  // Disable Rich Text editing if block bindings specify that.
165
- let shouldDisableEditing = false;
179
+ let _disableBoundBlocks = false;
166
180
  if (blockBindings && blockName in _useBindingsAttributes.BLOCK_BINDINGS_ALLOWED_BLOCKS) {
167
181
  const blockTypeAttributes = (0, _blocks.getBlockType)(blockName).attributes;
168
182
  const {
169
183
  getBlockBindingsSource
170
- } = (0, _lockUnlock.unlock)(select(_store.store));
184
+ } = (0, _lockUnlock.unlock)(select(_blocks.store));
171
185
  for (const [attribute, args] of Object.entries(blockBindings)) {
172
- // If any of the attributes with source "rich-text" is part of the bindings,
173
- // has a source with `lockAttributesEditing`, disable it.
174
- if (blockTypeAttributes?.[attribute]?.source === 'rich-text' && getBlockBindingsSource(args.source)?.lockAttributesEditing) {
175
- shouldDisableEditing = true;
186
+ if (blockTypeAttributes?.[attribute]?.source !== 'rich-text') {
187
+ break;
188
+ }
189
+
190
+ // If the source is not defined, or if its value of `lockAttributesEditing` is `true`, disable it.
191
+ const blockBindingsSource = getBlockBindingsSource(args.source);
192
+ if (!blockBindingsSource || blockBindingsSource.lockAttributesEditing) {
193
+ _disableBoundBlocks = true;
176
194
  break;
177
195
  }
178
196
  }
179
197
  }
180
- return {
181
- selectionStart: isSelected ? selectionStart.offset : undefined,
182
- selectionEnd: isSelected ? selectionEnd.offset : undefined,
183
- isSelected,
184
- shouldDisableEditing
185
- };
186
- };
187
- const {
188
- selectionStart,
189
- selectionEnd,
190
- isSelected,
191
- shouldDisableEditing
192
- } = (0, _data.useSelect)(selector, [clientId, identifier, originalIsSelected, isBlockSelected]);
198
+ return _disableBoundBlocks;
199
+ }, [blockBindings, blockName]);
200
+ const shouldDisableEditing = disableEditing || disableBoundBlocks;
193
201
  const {
194
202
  getSelectionStart,
195
203
  getSelectionEnd,
@@ -385,14 +393,30 @@ function RichTextWrapper({
385
393
  "data-wp-block-attribute-key": identifier
386
394
  }));
387
395
  }
388
- const ForwardedRichTextContainer = (0, _withDeprecations.withDeprecations)((0, _element.forwardRef)(RichTextWrapper));
389
- ForwardedRichTextContainer.Content = _content.Content;
390
- ForwardedRichTextContainer.isEmpty = value => {
396
+
397
+ // This is the private API for the RichText component.
398
+ // It allows access to all props, not just the public ones.
399
+ const PrivateRichText = exports.PrivateRichText = (0, _withDeprecations.withDeprecations)((0, _element.forwardRef)(RichTextWrapper));
400
+ PrivateRichText.Content = _content.Content;
401
+ PrivateRichText.isEmpty = value => {
391
402
  return !value || value.length === 0;
392
403
  };
393
404
 
405
+ // This is the public API for the RichText component.
406
+ // We wrap the PrivateRichText component to hide some props from the public API.
394
407
  /**
395
408
  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md
396
409
  */
397
- var _default = exports.default = ForwardedRichTextContainer;
410
+ const PublicForwardedRichTextContainer = (0, _element.forwardRef)((props, ref) => {
411
+ return (0, _react.createElement)(PrivateRichText, {
412
+ ref: ref,
413
+ ...props,
414
+ disableEditing: false
415
+ });
416
+ });
417
+ PublicForwardedRichTextContainer.Content = _content.Content;
418
+ PublicForwardedRichTextContainer.isEmpty = value => {
419
+ return !value || value.length === 0;
420
+ };
421
+ var _default = exports.default = PublicForwardedRichTextContainer;
398
422
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_element","_data","_compose","_richText","_components","_blocks","_autocomplete","_blockEdit","_formatToolbarContainer","_store","_useUndoAutomaticChange","_useMarkPersistent","_usePasteHandler","_useBeforeInputRules","_useInputRules","_useDelete","_useEnter","_useFormatTypes","_useRemoveBrowserShortcuts","_useShortcuts","_useInputEvents","_useInsertReplacementText","_useFirefoxCompat","_formatEdit","_utils","_content","_withDeprecations","_lockUnlock","_useBindingsAttributes","_shortcut","_toolbarButton","_inputEvent","keyboardShortcutContext","exports","createContext","inputEventContext","removeNativeProps","props","__unstableMobileNoFocusOnMount","deleteEnter","placeholderTextColor","textAlign","selectionColor","tagsToEliminate","disableEditingMenu","fontSize","fontFamily","fontWeight","fontStyle","minWidth","maxWidth","setRef","disableSuggestions","disableAutocorrection","restProps","RichTextWrapper","children","tagName","value","adjustedValue","onChange","adjustedOnChange","isSelected","originalIsSelected","multiline","inlineToolbar","wrapperClassName","autocompleters","onReplace","placeholder","allowedFormats","withoutInteractiveFormatting","onRemove","onMerge","onSplit","__unstableOnSplitAtEnd","onSplitAtEnd","__unstableOnSplitAtDoubleLineEnd","onSplitAtDoubleLineEnd","identifier","preserveWhiteSpace","__unstablePastePlainText","pastePlainText","__unstableEmbedURLOnPaste","__unstableDisableFormats","disableFormats","disableLineBreaks","__unstableAllowPrefixTransformations","forwardedRef","anchorRef","useRef","clientId","isBlockSelected","name","blockName","useBlockEditContext","selector","select","getSelectionStart","getSelectionEnd","getBlockAttributes","blockEditorStore","selectionStart","selectionEnd","blockBindings","metadata","bindings","undefined","attributeKey","shouldDisableEditing","BLOCK_BINDINGS_ALLOWED_BLOCKS","blockTypeAttributes","getBlockType","attributes","getBlockBindingsSource","unlock","attribute","args","Object","entries","source","lockAttributesEditing","offset","useSelect","getBlockRootClientId","selectionChange","useDispatch","adjustedAllowedFormats","getAllowedFormats","hasFormats","length","onSelectionChange","useCallback","start","end","selection","unset","formatTypes","prepareHandlers","valueHandlers","changeHandlers","dependencies","useFormatTypes","addEditorOnlyFormats","reduce","accumulator","fn","text","formats","removeEditorOnlyFormats","forEach","formatType","__experimentalCreatePrepareEditableTree","removeFormat","addInvisibleFormats","getValue","ref","richTextRef","useRichText","html","__unstableFormats","__unstableText","values","changeHandler","__unstableIsSelected","__unstableDependencies","__unstableAfterParse","__unstableBeforeSerialize","__unstableAddInvisibleFormats","autocompleteProps","useBlockEditorAutocompleteProps","completers","record","useMarkPersistent","keyboardShortcuts","Set","inputEvents","onFocus","current","focus","TagName","_react","createElement","Fragment","Provider","Popover","__unstableSlotNameProvider","default","inline","editableContentElement","role","useMergeRefs","useBeforeInputRules","useInputRules","useInsertReplacementText","useRemoveBrowserShortcuts","useShortcuts","useInputEvents","useUndoAutomaticChange","usePasteHandler","useDelete","useEnter","useFirefoxCompat","contentEditable","suppressContentEditableWarning","className","classnames","tabIndex","ForwardedRichTextContainer","withDeprecations","forwardRef","Content","isEmpty","_default"],"sources":["@wordpress/block-editor/src/components/rich-text/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseCallback,\n\tforwardRef,\n\tcreateContext,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useMergeRefs } from '@wordpress/compose';\nimport {\n\t__unstableUseRichText as useRichText,\n\tremoveFormat,\n} from '@wordpress/rich-text';\nimport { Popover } from '@wordpress/components';\nimport { getBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditorAutocompleteProps } from '../autocomplete';\nimport { useBlockEditContext } from '../block-edit';\nimport FormatToolbarContainer from './format-toolbar-container';\nimport { store as blockEditorStore } from '../../store';\nimport { useUndoAutomaticChange } from './use-undo-automatic-change';\nimport { useMarkPersistent } from './use-mark-persistent';\nimport { usePasteHandler } from './use-paste-handler';\nimport { useBeforeInputRules } from './use-before-input-rules';\nimport { useInputRules } from './use-input-rules';\nimport { useDelete } from './use-delete';\nimport { useEnter } from './use-enter';\nimport { useFormatTypes } from './use-format-types';\nimport { useRemoveBrowserShortcuts } from './use-remove-browser-shortcuts';\nimport { useShortcuts } from './use-shortcuts';\nimport { useInputEvents } from './use-input-events';\nimport { useInsertReplacementText } from './use-insert-replacement-text';\nimport { useFirefoxCompat } from './use-firefox-compat';\nimport FormatEdit from './format-edit';\nimport { getAllowedFormats } from './utils';\nimport { Content } from './content';\nimport { withDeprecations } from './with-deprecations';\nimport { unlock } from '../../lock-unlock';\nimport { BLOCK_BINDINGS_ALLOWED_BLOCKS } from '../../hooks/use-bindings-attributes';\n\nexport const keyboardShortcutContext = createContext();\nexport const inputEventContext = createContext();\n\n/**\n * Removes props used for the native version of RichText so that they are not\n * passed to the DOM element and log warnings.\n *\n * @param {Object} props Props to filter.\n *\n * @return {Object} Filtered props.\n */\nfunction removeNativeProps( props ) {\n\tconst {\n\t\t__unstableMobileNoFocusOnMount,\n\t\tdeleteEnter,\n\t\tplaceholderTextColor,\n\t\ttextAlign,\n\t\tselectionColor,\n\t\ttagsToEliminate,\n\t\tdisableEditingMenu,\n\t\tfontSize,\n\t\tfontFamily,\n\t\tfontWeight,\n\t\tfontStyle,\n\t\tminWidth,\n\t\tmaxWidth,\n\t\tsetRef,\n\t\tdisableSuggestions,\n\t\tdisableAutocorrection,\n\t\t...restProps\n\t} = props;\n\treturn restProps;\n}\n\nexport function RichTextWrapper(\n\t{\n\t\tchildren,\n\t\ttagName = 'div',\n\t\tvalue: adjustedValue = '',\n\t\tonChange: adjustedOnChange,\n\t\tisSelected: originalIsSelected,\n\t\tmultiline,\n\t\tinlineToolbar,\n\t\twrapperClassName,\n\t\tautocompleters,\n\t\tonReplace,\n\t\tplaceholder,\n\t\tallowedFormats,\n\t\twithoutInteractiveFormatting,\n\t\tonRemove,\n\t\tonMerge,\n\t\tonSplit,\n\t\t__unstableOnSplitAtEnd: onSplitAtEnd,\n\t\t__unstableOnSplitAtDoubleLineEnd: onSplitAtDoubleLineEnd,\n\t\tidentifier,\n\t\tpreserveWhiteSpace,\n\t\t__unstablePastePlainText: pastePlainText,\n\t\t__unstableEmbedURLOnPaste,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tdisableLineBreaks,\n\t\t__unstableAllowPrefixTransformations,\n\t\t...props\n\t},\n\tforwardedRef\n) {\n\tprops = removeNativeProps( props );\n\n\tconst anchorRef = useRef();\n\tconst {\n\t\tclientId,\n\t\tisSelected: isBlockSelected,\n\t\tname: blockName,\n\t} = useBlockEditContext();\n\tconst selector = ( select ) => {\n\t\t// Avoid subscribing to the block editor store if the block is not\n\t\t// selected.\n\t\tif ( ! isBlockSelected ) {\n\t\t\treturn { isSelected: false };\n\t\t}\n\n\t\tconst { getSelectionStart, getSelectionEnd, getBlockAttributes } =\n\t\t\tselect( blockEditorStore );\n\t\tconst selectionStart = getSelectionStart();\n\t\tconst selectionEnd = getSelectionEnd();\n\t\tconst blockBindings =\n\t\t\tgetBlockAttributes( clientId )?.metadata?.bindings;\n\n\t\tlet isSelected;\n\n\t\tif ( originalIsSelected === undefined ) {\n\t\t\tisSelected =\n\t\t\t\tselectionStart.clientId === clientId &&\n\t\t\t\tselectionEnd.clientId === clientId &&\n\t\t\t\tselectionStart.attributeKey === identifier;\n\t\t} else if ( originalIsSelected ) {\n\t\t\tisSelected = selectionStart.clientId === clientId;\n\t\t}\n\n\t\t// Disable Rich Text editing if block bindings specify that.\n\t\tlet shouldDisableEditing = false;\n\t\tif ( blockBindings && blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS ) {\n\t\t\tconst blockTypeAttributes = getBlockType( blockName ).attributes;\n\t\t\tconst { getBlockBindingsSource } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\tfor ( const [ attribute, args ] of Object.entries(\n\t\t\t\tblockBindings\n\t\t\t) ) {\n\t\t\t\t// If any of the attributes with source \"rich-text\" is part of the bindings,\n\t\t\t\t// has a source with `lockAttributesEditing`, disable it.\n\t\t\t\tif (\n\t\t\t\t\tblockTypeAttributes?.[ attribute ]?.source ===\n\t\t\t\t\t\t'rich-text' &&\n\t\t\t\t\tgetBlockBindingsSource( args.source )?.lockAttributesEditing\n\t\t\t\t) {\n\t\t\t\t\tshouldDisableEditing = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tselectionStart: isSelected ? selectionStart.offset : undefined,\n\t\t\tselectionEnd: isSelected ? selectionEnd.offset : undefined,\n\t\t\tisSelected,\n\t\t\tshouldDisableEditing,\n\t\t};\n\t};\n\tconst { selectionStart, selectionEnd, isSelected, shouldDisableEditing } =\n\t\tuseSelect( selector, [\n\t\t\tclientId,\n\t\t\tidentifier,\n\t\t\toriginalIsSelected,\n\t\t\tisBlockSelected,\n\t\t] );\n\tconst { getSelectionStart, getSelectionEnd, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst { selectionChange } = useDispatch( blockEditorStore );\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats,\n\t\tdisableFormats,\n\t} );\n\tconst hasFormats =\n\t\t! adjustedAllowedFormats || adjustedAllowedFormats.length > 0;\n\n\tconst onSelectionChange = useCallback(\n\t\t( start, end ) => {\n\t\t\tconst selection = {};\n\t\t\tconst unset = start === undefined && end === undefined;\n\n\t\t\tif ( typeof start === 'number' || unset ) {\n\t\t\t\t// If we are only setting the start (or the end below), which\n\t\t\t\t// means a partial selection, and we're not updating a selection\n\t\t\t\t// with the same client ID, abort. This means the selected block\n\t\t\t\t// is a parent block.\n\t\t\t\tif (\n\t\t\t\t\tend === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionEnd().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.start = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: start,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( typeof end === 'number' || unset ) {\n\t\t\t\tif (\n\t\t\t\t\tstart === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionStart().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.end = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: end,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tselectionChange( selection );\n\t\t},\n\t\t[ clientId, identifier ]\n\t);\n\n\tconst {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t} = useFormatTypes( {\n\t\tclientId,\n\t\tidentifier,\n\t\twithoutInteractiveFormatting,\n\t\tallowedFormats: adjustedAllowedFormats,\n\t} );\n\n\tfunction addEditorOnlyFormats( value ) {\n\t\treturn valueHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction removeEditorOnlyFormats( value ) {\n\t\tformatTypes.forEach( ( formatType ) => {\n\t\t\t// Remove formats created by prepareEditableTree, because they are editor only.\n\t\t\tif ( formatType.__experimentalCreatePrepareEditableTree ) {\n\t\t\t\tvalue = removeFormat(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformatType.name,\n\t\t\t\t\t0,\n\t\t\t\t\tvalue.text.length\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn value.formats;\n\t}\n\n\tfunction addInvisibleFormats( value ) {\n\t\treturn prepareHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tconst {\n\t\tvalue,\n\t\tgetValue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: adjustedValue,\n\t\tonChange( html, { __unstableFormats, __unstableText } ) {\n\t\t\tadjustedOnChange( html );\n\t\t\tObject.values( changeHandlers ).forEach( ( changeHandler ) => {\n\t\t\t\tchangeHandler( __unstableFormats, __unstableText );\n\t\t\t} );\n\t\t},\n\t\tselectionStart,\n\t\tselectionEnd,\n\t\tonSelectionChange,\n\t\tplaceholder,\n\t\t__unstableIsSelected: isSelected,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tpreserveWhiteSpace,\n\t\t__unstableDependencies: [ ...dependencies, tagName ],\n\t\t__unstableAfterParse: addEditorOnlyFormats,\n\t\t__unstableBeforeSerialize: removeEditorOnlyFormats,\n\t\t__unstableAddInvisibleFormats: addInvisibleFormats,\n\t} );\n\tconst autocompleteProps = useBlockEditorAutocompleteProps( {\n\t\tonReplace,\n\t\tcompleters: autocompleters,\n\t\trecord: value,\n\t\tonChange,\n\t} );\n\n\tuseMarkPersistent( { html: adjustedValue, value } );\n\n\tconst keyboardShortcuts = useRef( new Set() );\n\tconst inputEvents = useRef( new Set() );\n\n\tfunction onFocus() {\n\t\tanchorRef.current?.focus();\n\t}\n\n\tconst TagName = tagName;\n\treturn (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<keyboardShortcutContext.Provider value={ keyboardShortcuts }>\n\t\t\t\t\t<inputEventContext.Provider value={ inputEvents }>\n\t\t\t\t\t\t<Popover.__unstableSlotNameProvider value=\"__unstable-block-tools-after\">\n\t\t\t\t\t\t\t{ children &&\n\t\t\t\t\t\t\t\tchildren( { value, onChange, onFocus } ) }\n\n\t\t\t\t\t\t\t<FormatEdit\n\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tformatTypes={ formatTypes }\n\t\t\t\t\t\t\t\tforwardedRef={ anchorRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Popover.__unstableSlotNameProvider>\n\t\t\t\t\t</inputEventContext.Provider>\n\t\t\t\t</keyboardShortcutContext.Provider>\n\t\t\t) }\n\t\t\t{ isSelected && hasFormats && (\n\t\t\t\t<FormatToolbarContainer\n\t\t\t\t\tinline={ inlineToolbar }\n\t\t\t\t\teditableContentElement={ anchorRef.current }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<TagName\n\t\t\t\t// Overridable props.\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline={ ! disableLineBreaks }\n\t\t\t\taria-label={ placeholder }\n\t\t\t\taria-readonly={ shouldDisableEditing }\n\t\t\t\t{ ...props }\n\t\t\t\t{ ...autocompleteProps }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t// Rich text ref must be first because its focus listener\n\t\t\t\t\t// must be set up before any other ref calls .focus() on\n\t\t\t\t\t// mount.\n\t\t\t\t\trichTextRef,\n\t\t\t\t\tforwardedRef,\n\t\t\t\t\tautocompleteProps.ref,\n\t\t\t\t\tprops.ref,\n\t\t\t\t\tuseBeforeInputRules( { value, onChange } ),\n\t\t\t\t\tuseInputRules( {\n\t\t\t\t\t\tgetValue,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tselectionChange,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseInsertReplacementText(),\n\t\t\t\t\tuseRemoveBrowserShortcuts(),\n\t\t\t\t\tuseShortcuts( keyboardShortcuts ),\n\t\t\t\t\tuseInputEvents( inputEvents ),\n\t\t\t\t\tuseUndoAutomaticChange(),\n\t\t\t\t\tusePasteHandler( {\n\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\tdisableFormats,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\ttagName,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\t\t\tpastePlainText,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseDelete( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonMerge,\n\t\t\t\t\t\tonRemove,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseEnter( {\n\t\t\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tdisableLineBreaks,\n\t\t\t\t\t\tonSplitAtEnd,\n\t\t\t\t\t\tonSplitAtDoubleLineEnd,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseFirefoxCompat(),\n\t\t\t\t\tanchorRef,\n\t\t\t\t] ) }\n\t\t\t\tcontentEditable={ ! shouldDisableEditing }\n\t\t\t\tsuppressContentEditableWarning={ true }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-rich-text__editable',\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'rich-text'\n\t\t\t\t) }\n\t\t\t\t// Setting tabIndex to 0 is unnecessary, the element is already\n\t\t\t\t// focusable because it's contentEditable. This also fixes a\n\t\t\t\t// Safari bug where it's not possible to Shift+Click multi\n\t\t\t\t// select blocks when Shift Clicking into an element with\n\t\t\t\t// tabIndex because Safari will focus the element. However,\n\t\t\t\t// Safari will correctly ignore nested contentEditable elements.\n\t\t\t\ttabIndex={\n\t\t\t\t\tprops.tabIndex === 0 && ! shouldDisableEditing\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: props.tabIndex\n\t\t\t\t}\n\t\t\t\tdata-wp-block-attribute-key={ identifier }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nconst ForwardedRichTextContainer = withDeprecations(\n\tforwardRef( RichTextWrapper )\n);\n\nForwardedRichTextContainer.Content = Content;\nForwardedRichTextContainer.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md\n */\nexport default ForwardedRichTextContainer;\nexport { RichTextShortcut } from './shortcut';\nexport { RichTextToolbarButton } from './toolbar-button';\nexport { __unstableRichTextInputEvent } from './input-event';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAMA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAIA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAKA,IAAAO,aAAA,GAAAP,OAAA;A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C5CH,0BAA0B,CAACI,OAAO,GAAK1J,KAAK,IAAM;EACjD,OAAO,CAAEA,KAAK,IAAIA,KAAK,CAACwE,MAAM,KAAK,CAAC;AACrC,CAAC;;AAED;AACA;AACA;AAFA,IAAAmF,QAAA,GAAApL,OAAA,CAAA0J,OAAA,GAGeqB,0BAA0B"}
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_element","_data","_compose","_richText","_components","_blocks","_autocomplete","_blockEdit","_context","_formatToolbarContainer","_store","_useUndoAutomaticChange","_useMarkPersistent","_usePasteHandler","_useBeforeInputRules","_useInputRules","_useDelete","_useEnter","_useFormatTypes","_useRemoveBrowserShortcuts","_useShortcuts","_useInputEvents","_useInsertReplacementText","_useFirefoxCompat","_formatEdit","_utils","_content","_withDeprecations","_lockUnlock","_useBindingsAttributes","_shortcut","_toolbarButton","_inputEvent","keyboardShortcutContext","exports","createContext","inputEventContext","removeNativeProps","props","__unstableMobileNoFocusOnMount","deleteEnter","placeholderTextColor","textAlign","selectionColor","tagsToEliminate","disableEditingMenu","fontSize","fontFamily","fontWeight","fontStyle","minWidth","maxWidth","setRef","disableSuggestions","disableAutocorrection","restProps","RichTextWrapper","children","tagName","value","adjustedValue","onChange","adjustedOnChange","isSelected","originalIsSelected","multiline","inlineToolbar","wrapperClassName","autocompleters","onReplace","placeholder","allowedFormats","withoutInteractiveFormatting","onRemove","onMerge","onSplit","__unstableOnSplitAtEnd","onSplitAtEnd","__unstableOnSplitAtDoubleLineEnd","onSplitAtDoubleLineEnd","identifier","preserveWhiteSpace","__unstablePastePlainText","pastePlainText","__unstableEmbedURLOnPaste","__unstableDisableFormats","disableFormats","disableLineBreaks","__unstableAllowPrefixTransformations","disableEditing","forwardedRef","anchorRef","useRef","context","useBlockEditContext","clientId","isBlockSelected","name","blockName","blockBindings","blockBindingsKey","selector","select","getSelectionStart","getSelectionEnd","blockEditorStore","selectionStart","selectionEnd","undefined","attributeKey","offset","useSelect","disableBoundBlocks","_disableBoundBlocks","BLOCK_BINDINGS_ALLOWED_BLOCKS","blockTypeAttributes","getBlockType","attributes","getBlockBindingsSource","unlock","blocksStore","attribute","args","Object","entries","source","blockBindingsSource","lockAttributesEditing","shouldDisableEditing","getBlockRootClientId","selectionChange","useDispatch","adjustedAllowedFormats","getAllowedFormats","hasFormats","length","onSelectionChange","useCallback","start","end","selection","unset","formatTypes","prepareHandlers","valueHandlers","changeHandlers","dependencies","useFormatTypes","addEditorOnlyFormats","reduce","accumulator","fn","text","formats","removeEditorOnlyFormats","forEach","formatType","__experimentalCreatePrepareEditableTree","removeFormat","addInvisibleFormats","getValue","ref","richTextRef","useRichText","html","__unstableFormats","__unstableText","values","changeHandler","__unstableIsSelected","__unstableDependencies","__unstableAfterParse","__unstableBeforeSerialize","__unstableAddInvisibleFormats","autocompleteProps","useBlockEditorAutocompleteProps","completers","record","useMarkPersistent","keyboardShortcuts","Set","inputEvents","onFocus","current","focus","TagName","_react","createElement","Fragment","Provider","Popover","__unstableSlotNameProvider","default","inline","editableContentElement","role","useMergeRefs","useBeforeInputRules","useInputRules","useInsertReplacementText","useRemoveBrowserShortcuts","useShortcuts","useInputEvents","useUndoAutomaticChange","usePasteHandler","useDelete","useEnter","useFirefoxCompat","contentEditable","suppressContentEditableWarning","className","classnames","tabIndex","PrivateRichText","withDeprecations","forwardRef","Content","isEmpty","PublicForwardedRichTextContainer","_default"],"sources":["@wordpress/block-editor/src/components/rich-text/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseCallback,\n\tforwardRef,\n\tcreateContext,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useMergeRefs } from '@wordpress/compose';\nimport {\n\t__unstableUseRichText as useRichText,\n\tremoveFormat,\n} from '@wordpress/rich-text';\nimport { Popover } from '@wordpress/components';\nimport { getBlockType, store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditorAutocompleteProps } from '../autocomplete';\nimport { useBlockEditContext } from '../block-edit';\nimport { blockBindingsKey } from '../block-edit/context';\nimport FormatToolbarContainer from './format-toolbar-container';\nimport { store as blockEditorStore } from '../../store';\nimport { useUndoAutomaticChange } from './use-undo-automatic-change';\nimport { useMarkPersistent } from './use-mark-persistent';\nimport { usePasteHandler } from './use-paste-handler';\nimport { useBeforeInputRules } from './use-before-input-rules';\nimport { useInputRules } from './use-input-rules';\nimport { useDelete } from './use-delete';\nimport { useEnter } from './use-enter';\nimport { useFormatTypes } from './use-format-types';\nimport { useRemoveBrowserShortcuts } from './use-remove-browser-shortcuts';\nimport { useShortcuts } from './use-shortcuts';\nimport { useInputEvents } from './use-input-events';\nimport { useInsertReplacementText } from './use-insert-replacement-text';\nimport { useFirefoxCompat } from './use-firefox-compat';\nimport FormatEdit from './format-edit';\nimport { getAllowedFormats } from './utils';\nimport { Content } from './content';\nimport { withDeprecations } from './with-deprecations';\nimport { unlock } from '../../lock-unlock';\nimport { BLOCK_BINDINGS_ALLOWED_BLOCKS } from '../../hooks/use-bindings-attributes';\n\nexport const keyboardShortcutContext = createContext();\nexport const inputEventContext = createContext();\n\n/**\n * Removes props used for the native version of RichText so that they are not\n * passed to the DOM element and log warnings.\n *\n * @param {Object} props Props to filter.\n *\n * @return {Object} Filtered props.\n */\nfunction removeNativeProps( props ) {\n\tconst {\n\t\t__unstableMobileNoFocusOnMount,\n\t\tdeleteEnter,\n\t\tplaceholderTextColor,\n\t\ttextAlign,\n\t\tselectionColor,\n\t\ttagsToEliminate,\n\t\tdisableEditingMenu,\n\t\tfontSize,\n\t\tfontFamily,\n\t\tfontWeight,\n\t\tfontStyle,\n\t\tminWidth,\n\t\tmaxWidth,\n\t\tsetRef,\n\t\tdisableSuggestions,\n\t\tdisableAutocorrection,\n\t\t...restProps\n\t} = props;\n\treturn restProps;\n}\n\nexport function RichTextWrapper(\n\t{\n\t\tchildren,\n\t\ttagName = 'div',\n\t\tvalue: adjustedValue = '',\n\t\tonChange: adjustedOnChange,\n\t\tisSelected: originalIsSelected,\n\t\tmultiline,\n\t\tinlineToolbar,\n\t\twrapperClassName,\n\t\tautocompleters,\n\t\tonReplace,\n\t\tplaceholder,\n\t\tallowedFormats,\n\t\twithoutInteractiveFormatting,\n\t\tonRemove,\n\t\tonMerge,\n\t\tonSplit,\n\t\t__unstableOnSplitAtEnd: onSplitAtEnd,\n\t\t__unstableOnSplitAtDoubleLineEnd: onSplitAtDoubleLineEnd,\n\t\tidentifier,\n\t\tpreserveWhiteSpace,\n\t\t__unstablePastePlainText: pastePlainText,\n\t\t__unstableEmbedURLOnPaste,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tdisableLineBreaks,\n\t\t__unstableAllowPrefixTransformations,\n\t\tdisableEditing,\n\t\t...props\n\t},\n\tforwardedRef\n) {\n\tprops = removeNativeProps( props );\n\n\tconst anchorRef = useRef();\n\tconst context = useBlockEditContext();\n\tconst { clientId, isSelected: isBlockSelected, name: blockName } = context;\n\tconst blockBindings = context[ blockBindingsKey ];\n\tconst selector = ( select ) => {\n\t\t// Avoid subscribing to the block editor store if the block is not\n\t\t// selected.\n\t\tif ( ! isBlockSelected ) {\n\t\t\treturn { isSelected: false };\n\t\t}\n\n\t\tconst { getSelectionStart, getSelectionEnd } =\n\t\t\tselect( blockEditorStore );\n\t\tconst selectionStart = getSelectionStart();\n\t\tconst selectionEnd = getSelectionEnd();\n\n\t\tlet isSelected;\n\n\t\tif ( originalIsSelected === undefined ) {\n\t\t\tisSelected =\n\t\t\t\tselectionStart.clientId === clientId &&\n\t\t\t\tselectionEnd.clientId === clientId &&\n\t\t\t\tselectionStart.attributeKey === identifier;\n\t\t} else if ( originalIsSelected ) {\n\t\t\tisSelected = selectionStart.clientId === clientId;\n\t\t}\n\n\t\treturn {\n\t\t\tselectionStart: isSelected ? selectionStart.offset : undefined,\n\t\t\tselectionEnd: isSelected ? selectionEnd.offset : undefined,\n\t\t\tisSelected,\n\t\t};\n\t};\n\tconst { selectionStart, selectionEnd, isSelected } = useSelect( selector, [\n\t\tclientId,\n\t\tidentifier,\n\t\toriginalIsSelected,\n\t\tisBlockSelected,\n\t] );\n\n\tconst disableBoundBlocks = useSelect(\n\t\t( select ) => {\n\t\t\t// Disable Rich Text editing if block bindings specify that.\n\t\t\tlet _disableBoundBlocks = false;\n\t\t\tif ( blockBindings && blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS ) {\n\t\t\t\tconst blockTypeAttributes =\n\t\t\t\t\tgetBlockType( blockName ).attributes;\n\t\t\t\tconst { getBlockBindingsSource } = unlock(\n\t\t\t\t\tselect( blocksStore )\n\t\t\t\t);\n\t\t\t\tfor ( const [ attribute, args ] of Object.entries(\n\t\t\t\t\tblockBindings\n\t\t\t\t) ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tblockTypeAttributes?.[ attribute ]?.source !==\n\t\t\t\t\t\t'rich-text'\n\t\t\t\t\t) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\t// If the source is not defined, or if its value of `lockAttributesEditing` is `true`, disable it.\n\t\t\t\t\tconst blockBindingsSource = getBlockBindingsSource(\n\t\t\t\t\t\targs.source\n\t\t\t\t\t);\n\t\t\t\t\tif (\n\t\t\t\t\t\t! blockBindingsSource ||\n\t\t\t\t\t\tblockBindingsSource.lockAttributesEditing\n\t\t\t\t\t) {\n\t\t\t\t\t\t_disableBoundBlocks = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn _disableBoundBlocks;\n\t\t},\n\t\t[ blockBindings, blockName ]\n\t);\n\n\tconst shouldDisableEditing = disableEditing || disableBoundBlocks;\n\n\tconst { getSelectionStart, getSelectionEnd, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst { selectionChange } = useDispatch( blockEditorStore );\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats,\n\t\tdisableFormats,\n\t} );\n\tconst hasFormats =\n\t\t! adjustedAllowedFormats || adjustedAllowedFormats.length > 0;\n\n\tconst onSelectionChange = useCallback(\n\t\t( start, end ) => {\n\t\t\tconst selection = {};\n\t\t\tconst unset = start === undefined && end === undefined;\n\n\t\t\tif ( typeof start === 'number' || unset ) {\n\t\t\t\t// If we are only setting the start (or the end below), which\n\t\t\t\t// means a partial selection, and we're not updating a selection\n\t\t\t\t// with the same client ID, abort. This means the selected block\n\t\t\t\t// is a parent block.\n\t\t\t\tif (\n\t\t\t\t\tend === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionEnd().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.start = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: start,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( typeof end === 'number' || unset ) {\n\t\t\t\tif (\n\t\t\t\t\tstart === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionStart().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.end = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: end,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tselectionChange( selection );\n\t\t},\n\t\t[ clientId, identifier ]\n\t);\n\n\tconst {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t} = useFormatTypes( {\n\t\tclientId,\n\t\tidentifier,\n\t\twithoutInteractiveFormatting,\n\t\tallowedFormats: adjustedAllowedFormats,\n\t} );\n\n\tfunction addEditorOnlyFormats( value ) {\n\t\treturn valueHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction removeEditorOnlyFormats( value ) {\n\t\tformatTypes.forEach( ( formatType ) => {\n\t\t\t// Remove formats created by prepareEditableTree, because they are editor only.\n\t\t\tif ( formatType.__experimentalCreatePrepareEditableTree ) {\n\t\t\t\tvalue = removeFormat(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformatType.name,\n\t\t\t\t\t0,\n\t\t\t\t\tvalue.text.length\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn value.formats;\n\t}\n\n\tfunction addInvisibleFormats( value ) {\n\t\treturn prepareHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tconst {\n\t\tvalue,\n\t\tgetValue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: adjustedValue,\n\t\tonChange( html, { __unstableFormats, __unstableText } ) {\n\t\t\tadjustedOnChange( html );\n\t\t\tObject.values( changeHandlers ).forEach( ( changeHandler ) => {\n\t\t\t\tchangeHandler( __unstableFormats, __unstableText );\n\t\t\t} );\n\t\t},\n\t\tselectionStart,\n\t\tselectionEnd,\n\t\tonSelectionChange,\n\t\tplaceholder,\n\t\t__unstableIsSelected: isSelected,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tpreserveWhiteSpace,\n\t\t__unstableDependencies: [ ...dependencies, tagName ],\n\t\t__unstableAfterParse: addEditorOnlyFormats,\n\t\t__unstableBeforeSerialize: removeEditorOnlyFormats,\n\t\t__unstableAddInvisibleFormats: addInvisibleFormats,\n\t} );\n\tconst autocompleteProps = useBlockEditorAutocompleteProps( {\n\t\tonReplace,\n\t\tcompleters: autocompleters,\n\t\trecord: value,\n\t\tonChange,\n\t} );\n\n\tuseMarkPersistent( { html: adjustedValue, value } );\n\n\tconst keyboardShortcuts = useRef( new Set() );\n\tconst inputEvents = useRef( new Set() );\n\n\tfunction onFocus() {\n\t\tanchorRef.current?.focus();\n\t}\n\n\tconst TagName = tagName;\n\treturn (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<keyboardShortcutContext.Provider value={ keyboardShortcuts }>\n\t\t\t\t\t<inputEventContext.Provider value={ inputEvents }>\n\t\t\t\t\t\t<Popover.__unstableSlotNameProvider value=\"__unstable-block-tools-after\">\n\t\t\t\t\t\t\t{ children &&\n\t\t\t\t\t\t\t\tchildren( { value, onChange, onFocus } ) }\n\n\t\t\t\t\t\t\t<FormatEdit\n\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tformatTypes={ formatTypes }\n\t\t\t\t\t\t\t\tforwardedRef={ anchorRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Popover.__unstableSlotNameProvider>\n\t\t\t\t\t</inputEventContext.Provider>\n\t\t\t\t</keyboardShortcutContext.Provider>\n\t\t\t) }\n\t\t\t{ isSelected && hasFormats && (\n\t\t\t\t<FormatToolbarContainer\n\t\t\t\t\tinline={ inlineToolbar }\n\t\t\t\t\teditableContentElement={ anchorRef.current }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<TagName\n\t\t\t\t// Overridable props.\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline={ ! disableLineBreaks }\n\t\t\t\taria-label={ placeholder }\n\t\t\t\taria-readonly={ shouldDisableEditing }\n\t\t\t\t{ ...props }\n\t\t\t\t{ ...autocompleteProps }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t// Rich text ref must be first because its focus listener\n\t\t\t\t\t// must be set up before any other ref calls .focus() on\n\t\t\t\t\t// mount.\n\t\t\t\t\trichTextRef,\n\t\t\t\t\tforwardedRef,\n\t\t\t\t\tautocompleteProps.ref,\n\t\t\t\t\tprops.ref,\n\t\t\t\t\tuseBeforeInputRules( { value, onChange } ),\n\t\t\t\t\tuseInputRules( {\n\t\t\t\t\t\tgetValue,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tselectionChange,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseInsertReplacementText(),\n\t\t\t\t\tuseRemoveBrowserShortcuts(),\n\t\t\t\t\tuseShortcuts( keyboardShortcuts ),\n\t\t\t\t\tuseInputEvents( inputEvents ),\n\t\t\t\t\tuseUndoAutomaticChange(),\n\t\t\t\t\tusePasteHandler( {\n\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\tdisableFormats,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\ttagName,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\t\t\tpastePlainText,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseDelete( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonMerge,\n\t\t\t\t\t\tonRemove,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseEnter( {\n\t\t\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tdisableLineBreaks,\n\t\t\t\t\t\tonSplitAtEnd,\n\t\t\t\t\t\tonSplitAtDoubleLineEnd,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseFirefoxCompat(),\n\t\t\t\t\tanchorRef,\n\t\t\t\t] ) }\n\t\t\t\tcontentEditable={ ! shouldDisableEditing }\n\t\t\t\tsuppressContentEditableWarning={ true }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-rich-text__editable',\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'rich-text'\n\t\t\t\t) }\n\t\t\t\t// Setting tabIndex to 0 is unnecessary, the element is already\n\t\t\t\t// focusable because it's contentEditable. This also fixes a\n\t\t\t\t// Safari bug where it's not possible to Shift+Click multi\n\t\t\t\t// select blocks when Shift Clicking into an element with\n\t\t\t\t// tabIndex because Safari will focus the element. However,\n\t\t\t\t// Safari will correctly ignore nested contentEditable elements.\n\t\t\t\ttabIndex={\n\t\t\t\t\tprops.tabIndex === 0 && ! shouldDisableEditing\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: props.tabIndex\n\t\t\t\t}\n\t\t\t\tdata-wp-block-attribute-key={ identifier }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\n// This is the private API for the RichText component.\n// It allows access to all props, not just the public ones.\nexport const PrivateRichText = withDeprecations(\n\tforwardRef( RichTextWrapper )\n);\n\nPrivateRichText.Content = Content;\nPrivateRichText.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\n// This is the public API for the RichText component.\n// We wrap the PrivateRichText component to hide some props from the public API.\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md\n */\nconst PublicForwardedRichTextContainer = forwardRef( ( props, ref ) => {\n\treturn (\n\t\t<PrivateRichText ref={ ref } { ...props } disableEditing={ false } />\n\t);\n} );\n\nPublicForwardedRichTextContainer.Content = Content;\nPublicForwardedRichTextContainer.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\nexport default PublicForwardedRichTextContainer;\nexport { RichTextShortcut } from './shortcut';\nexport { RichTextToolbarButton } from './toolbar-button';\nexport { __unstableRichTextInputEvent } from './input-event';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAMA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAI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AK,CAAC4K,SAAS,EACf,WACD;IACA;IACA;IACA;IACA;IACA;IACA;IAAA;IACAE,QAAQ,EACP9K,KAAK,CAAC8K,QAAQ,KAAK,CAAC,IAAI,CAAEpF,oBAAoB,GAC3C,IAAI,GACJ1F,KAAK,CAAC8K,QACT;IACD,+BAA8BpI;EAAY,CAC1C,CACA,CAAC;AAEL;;AAEA;AACA;AACO,MAAMqI,eAAe,GAAAnL,OAAA,CAAAmL,eAAA,GAAG,IAAAC,kCAAgB,EAC9C,IAAAC,mBAAU,EAAE/J,eAAgB,CAC7B,CAAC;AAED6J,eAAe,CAACG,OAAO,GAAGA,gBAAO;AACjCH,eAAe,CAACI,OAAO,GAAK9J,KAAK,IAAM;EACtC,OAAO,CAAEA,KAAK,IAAIA,KAAK,CAAC4E,MAAM,KAAK,CAAC;AACrC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMmF,gCAAgC,GAAG,IAAAH,mBAAU,EAAE,CAAEjL,KAAK,EAAE2H,GAAG,KAAM;EACtE,OACC,IAAAyB,MAAA,CAAAC,aAAA,EAAC0B,eAAe;IAACpD,GAAG,EAAGA,GAAK;IAAA,GAAM3H,KAAK;IAAGmD,cAAc,EAAG;EAAO,CAAE,CAAC;AAEvE,CAAE,CAAC;AAEHiI,gCAAgC,CAACF,OAAO,GAAGA,gBAAO;AAClDE,gCAAgC,CAACD,OAAO,GAAK9J,KAAK,IAAM;EACvD,OAAO,CAAEA,KAAK,IAAIA,KAAK,CAAC4E,MAAM,KAAK,CAAC;AACrC,CAAC;AAAC,IAAAoF,QAAA,GAAAzL,OAAA,CAAA8J,OAAA,GAEa0B,gCAAgC"}
@@ -29,6 +29,9 @@ function useEnter(props) {
29
29
  propsRef.current = props;
30
30
  return (0, _compose.useRefEffect)(element => {
31
31
  function onKeyDown(event) {
32
+ if (event.target.contentEditable !== 'true') {
33
+ return;
34
+ }
32
35
  if (event.defaultPrevented) {
33
36
  return;
34
37
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_compose","_keycodes","_richText","_blocks","_data","_store","_splitValue","useEnter","props","registry","useRegistry","__unstableMarkAutomaticChange","useDispatch","blockEditorStore","propsRef","useRef","current","useRefEffect","element","onKeyDown","event","defaultPrevented","keyCode","ENTER","removeEditorOnlyFormats","value","onReplace","onSplit","onChange","disableLineBreaks","onSplitAtEnd","onSplitAtDoubleLineEnd","preventDefault","_value","formats","canSplit","transforms","getBlockTransforms","filter","type","transformation","findTransform","item","regExp","test","text","transform","content","start","end","shiftKey","insert","splitValue","length","slice","batch","remove","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/rich-text/use-enter.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER } from '@wordpress/keycodes';\nimport { insert, remove } from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\nimport { useDispatch, useRegistry } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { splitValue } from './split-value';\n\nexport function useEnter( props ) {\n\tconst registry = useRegistry();\n\tconst { __unstableMarkAutomaticChange } = useDispatch( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode !== ENTER ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\tvalue,\n\t\t\t\tonReplace,\n\t\t\t\tonSplit,\n\t\t\t\tonChange,\n\t\t\t\tdisableLineBreaks,\n\t\t\t\tonSplitAtEnd,\n\t\t\t\tonSplitAtDoubleLineEnd,\n\t\t\t} = propsRef.current;\n\n\t\t\tevent.preventDefault();\n\n\t\t\tconst _value = { ...value };\n\t\t\t_value.formats = removeEditorOnlyFormats( value );\n\t\t\tconst canSplit = onReplace && onSplit;\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t\t( { type } ) => type === 'enter'\n\t\t\t\t);\n\t\t\t\tconst transformation = findTransform( transforms, ( item ) => {\n\t\t\t\t\treturn item.regExp.test( _value.text );\n\t\t\t\t} );\n\n\t\t\t\tif ( transformation ) {\n\t\t\t\t\tonReplace( [\n\t\t\t\t\t\ttransformation.transform( {\n\t\t\t\t\t\t\tcontent: _value.text,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t] );\n\t\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst { text, start, end } = _value;\n\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tif ( ! disableLineBreaks ) {\n\t\t\t\t\tonChange( insert( _value, '\\n' ) );\n\t\t\t\t}\n\t\t\t} else if ( canSplit ) {\n\t\t\t\tsplitValue( {\n\t\t\t\t\tvalue: _value,\n\t\t\t\t\tonReplace,\n\t\t\t\t\tonSplit,\n\t\t\t\t} );\n\t\t\t} else if ( onSplitAtEnd && start === end && end === text.length ) {\n\t\t\t\tonSplitAtEnd();\n\t\t\t} else if (\n\t\t\t\t// For some blocks it's desirable to split at the end of the\n\t\t\t\t// block when there are two line breaks at the end of the\n\t\t\t\t// block, so triple Enter exits the block.\n\t\t\t\tonSplitAtDoubleLineEnd &&\n\t\t\t\tstart === end &&\n\t\t\t\tend === text.length &&\n\t\t\t\ttext.slice( -2 ) === '\\n\\n'\n\t\t\t) {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t_value.start = _value.end - 2;\n\t\t\t\t\tonChange( remove( _value ) );\n\t\t\t\t\tonSplitAtDoubleLineEnd();\n\t\t\t\t} );\n\t\t\t} else if ( ! disableLineBreaks ) {\n\t\t\t\tonChange( insert( _value, '\\n' ) );\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAdA;AACA;AACA;;AAQA;AACA;AACA;;AAIO,SAASQ,QAAQA,CAAEC,KAAK,EAAG;EACjC,MAAMC,QAAQ,GAAG,IAAAC,iBAAW,EAAC,CAAC;EAC9B,MAAM;IAAEC;EAA8B,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAiB,CAAC;EACzE,MAAMC,QAAQ,GAAG,IAAAC,eAAM,EAAEP,KAAM,CAAC;EAChCM,QAAQ,CAACE,OAAO,GAAGR,KAAK;EACxB,OAAO,IAAAS,qBAAY,EAAIC,OAAO,IAAM;IACnC,SAASC,SAASA,CAAEC,KAAK,EAAG;MAC3B,IAAKA,KAAK,CAACC,gBAAgB,EAAG;QAC7B;MACD;MAEA,IAAKD,KAAK,CAACE,OAAO,KAAKC,eAAK,EAAG;QAC9B;MACD;MAEA,MAAM;QACLC,uBAAuB;QACvBC,KAAK;QACLC,SAAS;QACTC,OAAO;QACPC,QAAQ;QACRC,iBAAiB;QACjBC,YAAY;QACZC;MACD,CAAC,GAAGjB,QAAQ,CAACE,OAAO;MAEpBI,KAAK,CAACY,cAAc,CAAC,CAAC;MAEtB,MAAMC,MAAM,GAAG;QAAE,GAAGR;MAAM,CAAC;MAC3BQ,MAAM,CAACC,OAAO,GAAGV,uBAAuB,CAAEC,KAAM,CAAC;MACjD,MAAMU,QAAQ,GAAGT,SAAS,IAAIC,OAAO;MAErC,IAA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K,GAAGf,MAAM,CAACgB,GAAG,GAAG,CAAC;UAC7BrB,QAAQ,CAAE,IAAA4B,gBAAM,EAAEvB,MAAO,CAAE,CAAC;UAC5BF,sBAAsB,CAAC,CAAC;QACzB,CAAE,CAAC;MACJ,CAAC,MAAM,IAAK,CAAEF,iBAAiB,EAAG;QACjCD,QAAQ,CAAE,IAAAuB,gBAAM,EAAElB,MAAM,EAAE,IAAK,CAAE,CAAC;MACnC;IACD;IAEAf,OAAO,CAACuC,gBAAgB,CAAE,SAAS,EAAEtC,SAAU,CAAC;IAChD,OAAO,MAAM;MACZD,OAAO,CAACwC,mBAAmB,CAAE,SAAS,EAAEvC,SAAU,CAAC;IACpD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR"}
1
+ {"version":3,"names":["_element","require","_compose","_keycodes","_richText","_blocks","_data","_store","_splitValue","useEnter","props","registry","useRegistry","__unstableMarkAutomaticChange","useDispatch","blockEditorStore","propsRef","useRef","current","useRefEffect","element","onKeyDown","event","target","contentEditable","defaultPrevented","keyCode","ENTER","removeEditorOnlyFormats","value","onReplace","onSplit","onChange","disableLineBreaks","onSplitAtEnd","onSplitAtDoubleLineEnd","preventDefault","_value","formats","canSplit","transforms","getBlockTransforms","filter","type","transformation","findTransform","item","regExp","test","text","transform","content","start","end","shiftKey","insert","splitValue","length","slice","batch","remove","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/rich-text/use-enter.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER } from '@wordpress/keycodes';\nimport { insert, remove } from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\nimport { useDispatch, useRegistry } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { splitValue } from './split-value';\n\nexport function useEnter( props ) {\n\tconst registry = useRegistry();\n\tconst { __unstableMarkAutomaticChange } = useDispatch( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.target.contentEditable !== 'true' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode !== ENTER ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\tvalue,\n\t\t\t\tonReplace,\n\t\t\t\tonSplit,\n\t\t\t\tonChange,\n\t\t\t\tdisableLineBreaks,\n\t\t\t\tonSplitAtEnd,\n\t\t\t\tonSplitAtDoubleLineEnd,\n\t\t\t} = propsRef.current;\n\n\t\t\tevent.preventDefault();\n\n\t\t\tconst _value = { ...value };\n\t\t\t_value.formats = removeEditorOnlyFormats( value );\n\t\t\tconst canSplit = onReplace && onSplit;\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t\t( { type } ) => type === 'enter'\n\t\t\t\t);\n\t\t\t\tconst transformation = findTransform( transforms, ( item ) => {\n\t\t\t\t\treturn item.regExp.test( _value.text );\n\t\t\t\t} );\n\n\t\t\t\tif ( transformation ) {\n\t\t\t\t\tonReplace( [\n\t\t\t\t\t\ttransformation.transform( {\n\t\t\t\t\t\t\tcontent: _value.text,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t] );\n\t\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst { text, start, end } = _value;\n\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tif ( ! disableLineBreaks ) {\n\t\t\t\t\tonChange( insert( _value, '\\n' ) );\n\t\t\t\t}\n\t\t\t} else if ( canSplit ) {\n\t\t\t\tsplitValue( {\n\t\t\t\t\tvalue: _value,\n\t\t\t\t\tonReplace,\n\t\t\t\t\tonSplit,\n\t\t\t\t} );\n\t\t\t} else if ( onSplitAtEnd && start === end && end === text.length ) {\n\t\t\t\tonSplitAtEnd();\n\t\t\t} else if (\n\t\t\t\t// For some blocks it's desirable to split at the end of the\n\t\t\t\t// block when there are two line breaks at the end of the\n\t\t\t\t// block, so triple Enter exits the block.\n\t\t\t\tonSplitAtDoubleLineEnd &&\n\t\t\t\tstart === end &&\n\t\t\t\tend === text.length &&\n\t\t\t\ttext.slice( -2 ) === '\\n\\n'\n\t\t\t) {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t_value.start = _value.end - 2;\n\t\t\t\t\tonChange( remove( _value ) );\n\t\t\t\t\tonSplitAtDoubleLineEnd();\n\t\t\t\t} );\n\t\t\t} else if ( ! disableLineBreaks ) {\n\t\t\t\tonChange( insert( _value, '\\n' ) );\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAdA;AACA;AACA;;AAQA;AACA;AACA;;AAIO,SAASQ,QAAQA,CAAEC,KAAK,EAAG;EACjC,MAAMC,QAAQ,GAAG,IAAAC,iBAAW,EAAC,CAAC;EAC9B,MAAM;IAAEC;EAA8B,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAiB,CAAC;EACzE,MAAMC,QAAQ,GAAG,IAAAC,eAAM,EAAEP,KAAM,CAAC;EAChCM,QAAQ,CAACE,OAAO,GAAGR,KAAK;EAC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EAAG;QACrB,IAAK,CAAErB,iBAAiB,EAAG;UAC1BD,QAAQ,CAAE,IAAAuB,gBAAM,EAAElB,MAAM,EAAE,IAAK,CAAE,CAAC;QACnC;MACD,CAAC,MAAM,IAAKE,QAAQ,EAAG;QACtB,IAAAiB,sBAAU,EAAE;UACX3B,KAAK,EAAEQ,MAAM;UACbP,SAAS;UACTC;QACD,CAAE,CAAC;MACJ,CAAC,MAAM,IAAKG,YAAY,IAAIkB,KAAK,KAAKC,GAAG,IAAIA,GAAG,KAAKJ,IAAI,CAACQ,MAAM,EAAG;QAClEvB,YAAY,CAAC,CAAC;MACf,CAAC,MAAM;MACN;MACA;MACA;MACAC,sBAAsB,IACtBiB,KAAK,KAAKC,GAAG,IACbA,GAAG,KAAKJ,IAAI,CAACQ,MAAM,IACnBR,IAAI,CAACS,KAAK,CAAE,CAAC,CAAE,CAAC,KAAK,MAAM,EAC1B;QACD/C,QAAQ,CAACgD,KAAK,CAAE,MAAM;UACrBtB,MAAM,CAACe,KAAK,GAAGf,MAAM,CAACgB,GAAG,GAAG,CAAC;UAC7BrB,QAAQ,CAAE,IAAA4B,gBAAM,EAAEvB,MAAO,CAAE,CAAC;UAC5BF,sBAAsB,CAAC,CAAC;QACzB,CAAE,CAAC;MACJ,CAAC,MAAM,IAAK,CAAEF,iBAAiB,EAAG;QACjCD,QAAQ,CAAE,IAAAuB,gBAAM,EAAElB,MAAM,EAAE,IAAK,CAAE,CAAC;MACnC;IACD;IAEAjB,OAAO,CAACyC,gBAAgB,CAAE,SAAS,EAAExC,SAAU,CAAC;IAChD,OAAO,MAAM;MACZD,OAAO,CAAC0C,mBAAmB,CAAE,SAAS,EAAEzC,SAAU,CAAC;IACpD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR"}
@@ -57,16 +57,35 @@ function usePasteHandler(props) {
57
57
  return;
58
58
  }
59
59
  const isInternal = event.clipboardData.getData('rich-text') === 'true';
60
+ function pasteInline(content) {
61
+ const transformed = formatTypes.reduce((accumulator, {
62
+ __unstablePasteRule
63
+ }) => {
64
+ // Only allow one transform.
65
+ if (__unstablePasteRule && accumulator === value) {
66
+ accumulator = __unstablePasteRule(value, {
67
+ html,
68
+ plainText
69
+ });
70
+ }
71
+ return accumulator;
72
+ }, value);
73
+ if (transformed !== value) {
74
+ onChange(transformed);
75
+ } else {
76
+ const valueToInsert = (0, _richText.create)({
77
+ html: content
78
+ });
79
+ (0, _utils.addActiveFormats)(valueToInsert, value.activeFormats);
80
+ onChange((0, _richText.insert)(value, valueToInsert));
81
+ }
82
+ }
60
83
 
61
84
  // If the data comes from a rich text instance, we can directly use it
62
85
  // without filtering the data. The filters are only meant for externally
63
86
  // pasted content and remove inline styles.
64
87
  if (isInternal) {
65
- const pastedValue = (0, _richText.create)({
66
- html
67
- });
68
- (0, _utils.addActiveFormats)(pastedValue, value.activeFormats);
69
- onChange((0, _richText.insert)(value, pastedValue));
88
+ pasteInline(html);
70
89
  return;
71
90
  }
72
91
  if (pastePlainText) {
@@ -116,27 +135,7 @@ function usePasteHandler(props) {
116
135
  tagName
117
136
  });
118
137
  if (typeof content === 'string') {
119
- const transformed = formatTypes.reduce((accumlator, {
120
- __unstablePasteRule
121
- }) => {
122
- // Only allow one transform.
123
- if (__unstablePasteRule && accumlator === value) {
124
- accumlator = __unstablePasteRule(value, {
125
- html,
126
- plainText
127
- });
128
- }
129
- return accumlator;
130
- }, value);
131
- if (transformed !== value) {
132
- onChange(transformed);
133
- } else {
134
- const valueToInsert = (0, _richText.create)({
135
- html: content
136
- });
137
- (0, _utils.addActiveFormats)(valueToInsert, value.activeFormats);
138
- onChange((0, _richText.insert)(value, valueToInsert));
139
- }
138
+ pasteInline(content);
140
139
  } else if (content.length > 0) {
141
140
  if (onReplace && (0, _richText.isEmpty)(value)) {
142
141
  onReplace(content, content.length - 1, -1);
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_compose","_blocks","_richText","_url","_utils","_splitValue","_pasting","usePasteHandler","props","propsRef","useRef","current","useRefEffect","element","_onPaste","event","isSelected","disableFormats","onChange","value","formatTypes","tagName","onReplace","onSplit","__unstableEmbedURLOnPaste","pastePlainText","plainText","html","files","getPasteEventData","preventDefault","window","console","log","insert","isInternal","clipboardData","getData","pastedValue","create","addActiveFormats","activeFormats","text","length","fromTransforms","getBlockTransforms","blocks","reduce","accumulator","file","transformation","findTransform","transform","type","isMatch","push","flat","isEmpty","splitValue","pastedBlocks","mode","trimmedPlainText","trim","isURL","test","content","pasteHandler","HTML","transformed","accumlator","__unstablePasteRule","valueToInsert","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/rich-text/use-paste-handler.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport {\n\tpasteHandler,\n\tfindTransform,\n\tgetBlockTransforms,\n} from '@wordpress/blocks';\nimport { isEmpty, insert, create } from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { addActiveFormats } from './utils';\nimport { splitValue } from './split-value';\nimport { getPasteEventData } from '../../utils/pasting';\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\nexport function usePasteHandler( props ) {\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction _onPaste( event ) {\n\t\t\tconst {\n\t\t\t\tisSelected,\n\t\t\t\tdisableFormats,\n\t\t\t\tonChange,\n\t\t\t\tvalue,\n\t\t\t\tformatTypes,\n\t\t\t\ttagName,\n\t\t\t\tonReplace,\n\t\t\t\tonSplit,\n\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\tpastePlainText,\n\t\t\t} = propsRef.current;\n\n\t\t\tif ( ! isSelected ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { plainText, html, files } = getPasteEventData( event );\n\n\t\t\tevent.preventDefault();\n\n\t\t\t// Allows us to ask for this information when we get a report.\n\t\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\t\tif ( disableFormats ) {\n\t\t\t\tonChange( insert( value, plainText ) );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isInternal =\n\t\t\t\tevent.clipboardData.getData( 'rich-text' ) === 'true';\n\n\t\t\t// If the data comes from a rich text instance, we can directly use it\n\t\t\t// without filtering the data. The filters are only meant for externally\n\t\t\t// pasted content and remove inline styles.\n\t\t\tif ( isInternal ) {\n\t\t\t\tconst pastedValue = create( { html } );\n\t\t\t\taddActiveFormats( pastedValue, value.activeFormats );\n\t\t\t\tonChange( insert( value, pastedValue ) );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( pastePlainText ) {\n\t\t\t\tonChange( insert( value, create( { text: plainText } ) ) );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( files?.length ) {\n\t\t\t\t// Allows us to ask for this information when we get a report.\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\twindow.console.log( 'Received items:\\n\\n', files );\n\n\t\t\t\tconst fromTransforms = getBlockTransforms( 'from' );\n\t\t\t\tconst blocks = files\n\t\t\t\t\t.reduce( ( accumulator, file ) => {\n\t\t\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\t\t\tfromTransforms,\n\t\t\t\t\t\t\t( transform ) =>\n\t\t\t\t\t\t\t\ttransform.type === 'files' &&\n\t\t\t\t\t\t\t\ttransform.isMatch( [ file ] )\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( transformation ) {\n\t\t\t\t\t\t\taccumulator.push(\n\t\t\t\t\t\t\t\ttransformation.transform( [ file ] )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn accumulator;\n\t\t\t\t\t}, [] )\n\t\t\t\t\t.flat();\n\t\t\t\tif ( ! blocks.length ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tonReplace( blocks );\n\t\t\t\t} else {\n\t\t\t\t\tsplitValue( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpastedBlocks: blocks,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet mode = onReplace && onSplit ? 'AUTO' : 'INLINE';\n\n\t\t\tconst trimmedPlainText = plainText.trim();\n\n\t\t\tif (\n\t\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisURL( trimmedPlainText ) &&\n\t\t\t\t// For the link pasting feature, allow only http(s) protocols.\n\t\t\t\t/^https?:/.test( trimmedPlainText )\n\t\t\t) {\n\t\t\t\tmode = 'BLOCKS';\n\t\t\t}\n\n\t\t\tconst content = pasteHandler( {\n\t\t\t\tHTML: html,\n\t\t\t\tplainText,\n\t\t\t\tmode,\n\t\t\t\ttagName,\n\t\t\t} );\n\n\t\t\tif ( typeof content === 'string' ) {\n\t\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t\t( accumlator, { __unstablePasteRule } ) => {\n\t\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\t\tif ( __unstablePasteRule && accumlator === value ) {\n\t\t\t\t\t\t\taccumlator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn accumlator;\n\t\t\t\t\t},\n\t\t\t\t\tvalue\n\t\t\t\t);\n\n\t\t\t\tif ( transformed !== value ) {\n\t\t\t\t\tonChange( transformed );\n\t\t\t\t} else {\n\t\t\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t\t}\n\t\t\t} else if ( content.length > 0 ) {\n\t\t\t\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tonReplace( content, content.length - 1, -1 );\n\t\t\t\t} else {\n\t\t\t\t\tsplitValue( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpastedBlocks: content,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'paste', _onPaste );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'paste', _onPaste );\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAKA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAlBA;AACA;AACA;;AAWA;AACA;AACA;;AAKA;;AAEO,SAASQ,eAAeA,CAAEC,KAAK,EAAG;EACxC,MAAMC,QAAQ,GAAG,IAAAC,eAAM,EAAEF,KAAM,CAAC;EAChCC,QAAQ,CAACE,OAAO,GAAGH,KAAK;EACxB,OAAO,IAAAI,qBAAY,EAAIC,OAAO,IAAM;IACnC,SAASC,QAAQA,CAAEC,KAAK,EAAG;MAC1B,MAAM;QACLC,UAAU;QACVC,cAAc;QACdC,QAAQ;QACRC,KAAK;QACLC,WAAW;QACXC,OAAO;QACPC,SAAS;QACTC,OAAO;QACPC,yBAAyB;QACzBC;MACD,CAAC,GAAGhB,QAAQ,CAACE,OAAO;MAEpB,IAAK,CAAEK,UAAU,EAAG;QACnB;MACD;MAEA,MAAM;QAAEU,SAAS;QAAEC,IAAI;QAAEC;MAAM,CAAC,GAAG,IAAAC,0BAAiB,EAAEd,KAAM,CAAC;MAE7D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D;YACD,CAAE,CAAC;UACJ;UAEA,OAAO2C,UAAU;QAClB,CAAC,EACDlD,KACD,CAAC;QAED,IAAKiD,WAAW,KAAKjD,KAAK,EAAG;UAC5BD,QAAQ,CAAEkD,WAAY,CAAC;QACxB,CAAC,MAAM;UACN,MAAMG,aAAa,GAAG,IAAAhC,gBAAM,EAAE;YAAEZ,IAAI,EAAEsC;UAAQ,CAAE,CAAC;UACjD,IAAAzB,uBAAgB,EAAE+B,aAAa,EAAEpD,KAAK,CAACsB,aAAc,CAAC;UACtDvB,QAAQ,CAAE,IAAAgB,gBAAM,EAAEf,KAAK,EAAEoD,aAAc,CAAE,CAAC;QAC3C;MACD,CAAC,MAAM,IAAKN,OAAO,CAACtB,MAAM,GAAG,CAAC,EAAG;QAChC,IAAKrB,SAAS,IAAI,IAAAmC,iBAAO,EAAEtC,KAAM,CAAC,EAAG;UACpCG,SAAS,CAAE2C,OAAO,EAAEA,OAAO,CAACtB,MAAM,GAAG,CAAC,EAAE,CAAC,CAAE,CAAC;QAC7C,CAAC,MAAM;UACN,IAAAe,sBAAU,EAAE;YACXvC,KAAK;YACLwC,YAAY,EAAEM,OAAO;YACrB3C,SAAS;YACTC;UACD,CAAE,CAAC;QACJ;MACD;IACD;IAEAV,OAAO,CAAC2D,gBAAgB,CAAE,OAAO,EAAE1D,QAAS,CAAC;IAC7C,OAAO,MAAM;MACZD,OAAO,CAAC4D,mBAAmB,CAAE,OAAO,EAAE3D,QAAS,CAAC;IACjD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR"}
1
+ {"version":3,"names":["_element","require","_compose","_blocks","_richText","_url","_utils","_splitValue","_pasting","usePasteHandler","props","propsRef","useRef","current","useRefEffect","element","_onPaste","event","isSelected","disableFormats","onChange","value","formatTypes","tagName","onReplace","onSplit","__unstableEmbedURLOnPaste","pastePlainText","plainText","html","files","getPasteEventData","preventDefault","window","console","log","insert","isInternal","clipboardData","getData","pasteInline","content","transformed","reduce","accumulator","__unstablePasteRule","valueToInsert","create","addActiveFormats","activeFormats","text","length","fromTransforms","getBlockTransforms","blocks","file","transformation","findTransform","transform","type","isMatch","push","flat","isEmpty","splitValue","pastedBlocks","mode","trimmedPlainText","trim","isURL","test","pasteHandler","HTML","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/rich-text/use-paste-handler.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport {\n\tpasteHandler,\n\tfindTransform,\n\tgetBlockTransforms,\n} from '@wordpress/blocks';\nimport { isEmpty, insert, create } from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { addActiveFormats } from './utils';\nimport { splitValue } from './split-value';\nimport { getPasteEventData } from '../../utils/pasting';\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\nexport function usePasteHandler( props ) {\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction _onPaste( event ) {\n\t\t\tconst {\n\t\t\t\tisSelected,\n\t\t\t\tdisableFormats,\n\t\t\t\tonChange,\n\t\t\t\tvalue,\n\t\t\t\tformatTypes,\n\t\t\t\ttagName,\n\t\t\t\tonReplace,\n\t\t\t\tonSplit,\n\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\tpastePlainText,\n\t\t\t} = propsRef.current;\n\n\t\t\tif ( ! isSelected ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { plainText, html, files } = getPasteEventData( event );\n\n\t\t\tevent.preventDefault();\n\n\t\t\t// Allows us to ask for this information when we get a report.\n\t\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\t\tif ( disableFormats ) {\n\t\t\t\tonChange( insert( value, plainText ) );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isInternal =\n\t\t\t\tevent.clipboardData.getData( 'rich-text' ) === 'true';\n\n\t\t\tfunction pasteInline( content ) {\n\t\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t\t( accumulator, { __unstablePasteRule } ) => {\n\t\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\t\tif ( __unstablePasteRule && accumulator === value ) {\n\t\t\t\t\t\t\taccumulator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn accumulator;\n\t\t\t\t\t},\n\t\t\t\t\tvalue\n\t\t\t\t);\n\t\t\t\tif ( transformed !== value ) {\n\t\t\t\t\tonChange( transformed );\n\t\t\t\t} else {\n\t\t\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If the data comes from a rich text instance, we can directly use it\n\t\t\t// without filtering the data. The filters are only meant for externally\n\t\t\t// pasted content and remove inline styles.\n\t\t\tif ( isInternal ) {\n\t\t\t\tpasteInline( html );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( pastePlainText ) {\n\t\t\t\tonChange( insert( value, create( { text: plainText } ) ) );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( files?.length ) {\n\t\t\t\t// Allows us to ask for this information when we get a report.\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\twindow.console.log( 'Received items:\\n\\n', files );\n\n\t\t\t\tconst fromTransforms = getBlockTransforms( 'from' );\n\t\t\t\tconst blocks = files\n\t\t\t\t\t.reduce( ( accumulator, file ) => {\n\t\t\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\t\t\tfromTransforms,\n\t\t\t\t\t\t\t( transform ) =>\n\t\t\t\t\t\t\t\ttransform.type === 'files' &&\n\t\t\t\t\t\t\t\ttransform.isMatch( [ file ] )\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( transformation ) {\n\t\t\t\t\t\t\taccumulator.push(\n\t\t\t\t\t\t\t\ttransformation.transform( [ file ] )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn accumulator;\n\t\t\t\t\t}, [] )\n\t\t\t\t\t.flat();\n\t\t\t\tif ( ! blocks.length ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tonReplace( blocks );\n\t\t\t\t} else {\n\t\t\t\t\tsplitValue( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpastedBlocks: blocks,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet mode = onReplace && onSplit ? 'AUTO' : 'INLINE';\n\n\t\t\tconst trimmedPlainText = plainText.trim();\n\n\t\t\tif (\n\t\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisURL( trimmedPlainText ) &&\n\t\t\t\t// For the link pasting feature, allow only http(s) protocols.\n\t\t\t\t/^https?:/.test( trimmedPlainText )\n\t\t\t) {\n\t\t\t\tmode = 'BLOCKS';\n\t\t\t}\n\n\t\t\tconst content = pasteHandler( {\n\t\t\t\tHTML: html,\n\t\t\t\tplainText,\n\t\t\t\tmode,\n\t\t\t\ttagName,\n\t\t\t} );\n\n\t\t\tif ( typeof content === 'string' ) {\n\t\t\t\tpasteInline( content );\n\t\t\t} else if ( content.length > 0 ) {\n\t\t\t\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tonReplace( content, content.length - 1, -1 );\n\t\t\t\t} else {\n\t\t\t\t\tsplitValue( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tpastedBlocks: content,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'paste', _onPaste );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'paste', _onPaste );\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAKA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAlBA;AACA;AACA;;AAWA;AACA;AACA;;AAKA;;AAEO,SAASQ,eAAeA,CAAEC,KAAK,EAAG;EACxC,MAAMC,QAAQ,GAAG,IAAAC,eAAM,EAAEF,KAAM,CAAC;EAChCC,QAAQ,CAACE,OAAO,GAAGH,KAAK;EACxB,OAAO,IAAAI,qBAAY,EAAIC,OAAO,IAAM;IACnC,SAASC,QAAQA,CAAEC,KAAK,EAAG;MAC1B,MAAM;QACLC,UAAU;QACVC,cAAc;QACdC,QAAQ;QACRC,KAAK;QACLC,WAAW;QACXC,OAAO;QACPC,SAAS;QACTC,OAAO;QACPC,yBAAyB;QACzBC;MACD,CAAC,GAAGhB,QAAQ,CAACE,OAAO;MAEpB,IAAK,CAAEK,UAAU,EAAG;QACnB;MACD;MAEA,MAAM;QAAEU,SAAS;QAAEC,IAAI;QAAEC;MAAM,CAAC,GAAG,IAAAC,0BAAiB,EAAEd,KAAM,CAAC;MAE7DA,KAAK,CAACe,cAAc,CAAC,CAAC;;MAEtB;MACAC,MAAM,CAACC,OAAO,CAACC,GAAG,CAAE,oBAAoB,EAAEN,IAAK,CAAC;MAChDI,MAAM,CAACC,OAAO,CAACC,GAAG,CAAE,0BAA0B,EAAEP,SAAU,CAAC;MAE3D,IAAKT,cAAc,EAAG;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D,CAAE,CAAC;MAEH,IAAK,OAAOkB,OAAO,KAAK,QAAQ,EAAG;QAClCD,WAAW,CAAEC,OAAQ,CAAC;MACvB,CAAC,MAAM,IAAKA,OAAO,CAACU,MAAM,GAAG,CAAC,EAAG;QAChC,IAAK3B,SAAS,IAAI,IAAAuC,iBAAO,EAAE1C,KAAM,CAAC,EAAG;UACpCG,SAAS,CAAEiB,OAAO,EAAEA,OAAO,CAACU,MAAM,GAAG,CAAC,EAAE,CAAC,CAAE,CAAC;QAC7C,CAAC,MAAM;UACN,IAAAa,sBAAU,EAAE;YACX3C,KAAK;YACL4C,YAAY,EAAExB,OAAO;YACrBjB,SAAS;YACTC;UACD,CAAE,CAAC;QACJ;MACD;IACD;IAEAV,OAAO,CAAC0D,gBAAgB,CAAE,OAAO,EAAEzD,QAAS,CAAC;IAC7C,OAAO,MAAM;MACZD,OAAO,CAAC2D,mBAAmB,CAAE,OAAO,EAAE1D,QAAS,CAAC;IACjD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR"}
@@ -314,10 +314,12 @@ function backgroundSizeHelpText(value) {
314
314
  return (0, _i18n.__)('Specify a fixed width.');
315
315
  }
316
316
  const coordsToBackgroundPosition = value => {
317
- if (!value || isNaN(value.x) || isNaN(value.y)) {
317
+ if (!value || isNaN(value.x) && isNaN(value.y)) {
318
318
  return undefined;
319
319
  }
320
- return `${value.x * 100}% ${value.y * 100}%`;
320
+ const x = isNaN(value.x) ? 0.5 : value.x;
321
+ const y = isNaN(value.y) ? 0.5 : value.y;
322
+ return `${x * 100}% ${y * 100}%`;
321
323
  };
322
324
  exports.coordsToBackgroundPosition = coordsToBackgroundPosition;
323
325
  const backgroundPositionToCoords = value => {