@wordpress/block-editor 8.1.0 → 8.1.1
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 +6 -0
- package/README.md +7 -5
- package/build/components/block-inspector/index.js +7 -0
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-preview/auto.js +3 -1
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/colors-gradients/tools-panel-color-dropdown.js +89 -0
- package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +1 -0
- package/build/components/contrast-checker/index.js +75 -64
- package/build/components/contrast-checker/index.js.map +1 -1
- package/build/components/index.js +9 -9
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +9 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/search-items.js +3 -1
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +3 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/line-height-control/index.native.js +3 -2
- package/build/components/line-height-control/index.native.js.map +1 -1
- package/build/components/link-control/link-preview.js +5 -2
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/list-view/block-contents.js +3 -1
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block-select-button.js +4 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +2 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/media-placeholder/index.js +1 -11
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.native.js +13 -0
- package/build/components/media-replace-flow/index.native.js.map +1 -0
- package/build/components/rich-text/index.js +2 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +2 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +14 -5
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/rich-text/utils.js +2 -1
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/hooks/border-color.js +1 -1
- package/build/hooks/border-color.js.map +1 -1
- package/build/hooks/color-panel.js +23 -17
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +176 -10
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/font-size.js +14 -0
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/typography.native.js +2 -4
- package/build/hooks/typography.native.js.map +1 -1
- package/build/hooks/utils.js +55 -0
- package/build/hooks/utils.js.map +1 -1
- package/build-module/components/block-inspector/index.js +7 -0
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +3 -1
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +75 -0
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +1 -0
- package/build-module/components/contrast-checker/index.js +75 -65
- package/build-module/components/contrast-checker/index.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/search-items.js +3 -1
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/line-height-control/index.native.js +3 -2
- package/build-module/components/line-height-control/index.native.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +5 -2
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +3 -1
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +4 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +2 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +1 -10
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.native.js +4 -0
- package/build-module/components/media-replace-flow/index.native.js.map +1 -0
- package/build-module/components/rich-text/index.js +2 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +2 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +14 -5
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/rich-text/utils.js +2 -1
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/hooks/border-color.js +1 -1
- package/build-module/hooks/border-color.js.map +1 -1
- package/build-module/hooks/color-panel.js +22 -15
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +174 -11
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/font-size.js +12 -1
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/typography.native.js +2 -4
- package/build-module/hooks/typography.native.js.map +1 -1
- package/build-module/hooks/utils.js +52 -1
- package/build-module/hooks/utils.js.map +1 -1
- package/build-style/style-rtl.css +71 -9
- package/build-style/style.css +71 -9
- package/package.json +26 -30
- package/src/components/block-inspector/index.js +9 -0
- package/src/components/block-preview/auto.js +3 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +0 -1
- package/src/components/colors-gradients/tools-panel-color-dropdown.js +85 -0
- package/src/components/contrast-checker/index.js +102 -87
- package/src/components/contrast-checker/test/index.js +176 -7
- package/src/components/index.js +1 -1
- package/src/components/index.native.js +1 -0
- package/src/components/inserter/search-items.js +3 -1
- package/src/components/inspector-controls/block-support-tools-panel.js +2 -0
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/line-height-control/index.native.js +2 -1
- package/src/components/link-control/link-preview.js +2 -1
- package/src/components/link-control/style.scss +3 -9
- package/src/components/list-view/block-contents.js +2 -0
- package/src/components/list-view/block-select-button.js +2 -0
- package/src/components/list-view/block.js +1 -0
- package/src/components/media-placeholder/index.js +1 -10
- package/src/components/media-replace-flow/index.native.js +3 -0
- package/src/components/rich-text/index.js +1 -0
- package/src/components/rich-text/index.native.js +1 -0
- package/src/components/rich-text/use-paste-handler.js +16 -3
- package/src/components/rich-text/utils.js +1 -0
- package/src/hooks/border-color.js +1 -1
- package/src/hooks/color-panel.js +24 -21
- package/src/hooks/color.js +177 -8
- package/src/hooks/color.scss +85 -0
- package/src/hooks/font-size.js +29 -1
- package/src/hooks/typography.native.js +1 -3
- package/src/hooks/utils.js +69 -1
- package/src/style.scss +1 -0
- package/build/components/preserve-scroll-in-reorder/index.js +0 -22
- package/build/components/preserve-scroll-in-reorder/index.js.map +0 -1
- package/build-module/components/preserve-scroll-in-reorder/index.js +0 -12
- package/build-module/components/preserve-scroll-in-reorder/index.js.map +0 -1
- package/src/components/preserve-scroll-in-reorder/index.js +0 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/index.native.js"],"names":["classnames","omit","RawHTML","Platform","useRef","useCallback","forwardRef","useDispatch","useSelect","pasteHandler","children","childrenSource","getBlockTransforms","findTransform","isUnmodifiedDefaultBlock","useInstanceId","useMergeRefs","__experimentalRichText","RichText","__unstableCreateElement","isEmpty","__unstableIsEmptyLine","isEmptyLine","insert","__unstableInsertLineSeparator","insertLineSeparator","create","replace","split","__UNSTABLE_LINE_SEPARATOR","LINE_SEPARATOR","toHTMLString","slice","deprecated","isURL","Autocomplete","useBlockEditContext","RemoveBrowserShortcuts","filePasteHandler","FormatToolbarContainer","useNativeProps","store","blockEditorStore","addActiveFormats","getMultilineTag","getAllowedFormats","isShortcode","createLinkInParagraph","EmbedHandlerPicker","wrapperClasses","classes","RichTextWrapper","forwardedRef","tagName","value","originalValue","onChange","originalOnChange","isSelected","originalIsSelected","multiline","inlineToolbar","wrapperClassName","autocompleters","onReplace","placeholder","allowedFormats","formattingControls","withoutInteractiveFormatting","onRemove","onMerge","onSplit","__unstableOnSplitAtEnd","onSplitAtEnd","__unstableOnSplitMiddle","onSplitMiddle","identifier","preserveWhiteSpace","__unstablePastePlainText","pastePlainText","__unstableEmbedURLOnPaste","__unstableDisableFormats","disableFormats","disableLineBreaks","unstableOnFocus","__unstableAllowPrefixTransformations","__unstableMultilineRootTag","__unstableMobileNoFocusOnMount","deleteEnter","placeholderTextColor","textAlign","selectionColor","tagsToEliminate","rootTagsToEliminate","disableEditingMenu","fontSize","fontFamily","fontWeight","fontStyle","minWidth","maxWidth","onBlur","setRef","props","instanceId","fallbackRef","clientId","blockIsSelected","nativeProps","embedHandlerPickerRef","selector","select","isCaretWithinFormattedText","getSelectionStart","getSelectionEnd","getSettings","didAutomaticChange","getBlock","isMultiSelecting","hasMultiSelection","selectionStart","selectionEnd","__experimentalUndo","undo","undefined","attributeKey","extraProps","OS","block","shouldBlurOnUnmount","offset","disabled","__unstableMarkLastChangeAsPersistent","enterFormattedText","exitFormattedText","selectionChange","__unstableMarkAutomaticChange","multilineTag","adjustedAllowedFormats","hasFormats","length","adjustedValue","adjustedOnChange","Array","isArray","toHTML","newValue","fromDOM","document","childNodes","onSelectionChange","start","end","onDelete","isReverse","splitValue","record","pastedBlocks","blocks","before","after","hasPastedBlocks","lastPastedBlockIndex","isAfterOriginal","push","indexToSelect","initialPosition","onEnter","shiftKey","canSplit","transforms","filter","type","transformation","item","regExp","test","text","transform","content","canSplitAtEnd","onPaste","html","plainText","isInternal","files","activeFormats","pastedValue","multilineWrapperTags","HTML","mode","window","console","log","isPastedURL","trim","presentEmbedHandlerPicker","current","presentPicker","createEmbed","createLink","valueToInsert","canPasteEmbed","name","inputRule","valueToFormat","characterBefore","trimmedTextBefore","prefixTransforms","prefix","mergedRef","id","style","nestedIsSelected","onFocus","editableProps","editableTagName","TagName","listBoxId","activeId","onKeyDown","className","event","since","alternative","ForwardedRichTextContainer","Content","Tag","MultilineTag","defaultProps","format","RichTextShortcut","RichTextToolbarButton","__unstableRichTextInputEvent"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SACCC,OADD,EAECC,QAFD,EAGCC,MAHD,EAICC,WAJD,EAKCC,UALD,QAMO,oBANP;AAOA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SACCC,YADD,EAECC,QAAQ,IAAIC,cAFb,EAGCC,kBAHD,EAICC,aAJD,EAKCC,wBALD,QAMO,mBANP;AAOA,SAASC,aAAT,EAAwBC,YAAxB,QAA4C,oBAA5C;AACA,SACCC,sBAAsB,IAAIC,QAD3B,EAECC,uBAFD,EAGCC,OAHD,EAICC,qBAAqB,IAAIC,WAJ1B,EAKCC,MALD,EAMCC,6BAA6B,IAAIC,mBANlC,EAOCC,MAPD,EAQCC,OARD,EASCC,KATD,EAUCC,yBAAyB,IAAIC,cAV9B,EAWCC,YAXD,EAYCC,KAZD,QAaO,sBAbP;AAcA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,KAAT,QAAsB,gBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,SAASC,mBAAT,QAAoC,eAApC;AACA,SAASC,sBAAT,QAAuC,4BAAvC;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AACA,OAAOC,sBAAP,MAAmC,4BAAnC;AACA,SAASC,cAAT,QAA+B,oBAA/B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SACCC,gBADD,EAECC,eAFD,EAGCC,iBAHD,EAICC,WAJD,EAKCC,qBALD,QAMO,SANP;AAOA,OAAOC,kBAAP,MAA+B,wBAA/B;AAEA,MAAMC,cAAc,GAAG,wBAAvB;AACA,MAAMC,OAAO,GAAG,kCAAhB;;AAEA,SAASC,eAAT,OAiDCC,YAjDD,EAkDE;AAAA,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;AAC9B9K,IAAAA,KAAK,GAAI,IAAI8K,YAAc,MAAMA,YAAc,GAA/C;AACA;;AAED,QAAMjD,OAAO,GAAG,cAAC,OAAD,QAAW7H,KAAX,CAAhB;;AAEA,MAAK6K,GAAL,EAAW;AACV,WAAO,cAAC,GAAD,EAAUlO,IAAI,CAAEsG,KAAF,EAAS,CAAE,QAAF,CAAT,CAAd,EAA0C4E,OAA1C,CAAP;AACA;;AAED,SAAOA,OAAP;AACA,CAxBD;;AA0BA8C,0BAA0B,CAAC7M,OAA3B,GAAuCkC,KAAF,IAAa;AACjD,SAAO,CAAEA,KAAF,IAAWA,KAAK,CAACsF,MAAN,KAAiB,CAAnC;AACA,CAFD;;AAIAqF,0BAA0B,CAACC,OAA3B,CAAmCG,YAAnC,GAAkD;AACjDC,EAAAA,MAAM,EAAE,QADyC;AAEjDhL,EAAAA,KAAK,EAAE;AAF0C,CAAlD;AAKA;AACA;AACA;;AACA,eAAe2K,0BAAf;AACA,SAASM,gBAAT,QAAiC,YAAjC;AACA,SAASC,qBAAT,QAAsC,kBAAtC;AACA,SAASC,4BAAT,QAA6C,eAA7C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { omit } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tRawHTML,\n\tPlatform,\n\tuseRef,\n\tuseCallback,\n\tforwardRef,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tpasteHandler,\n\tchildren as childrenSource,\n\tgetBlockTransforms,\n\tfindTransform,\n\tisUnmodifiedDefaultBlock,\n} from '@wordpress/blocks';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport {\n\t__experimentalRichText as RichText,\n\t__unstableCreateElement,\n\tisEmpty,\n\t__unstableIsEmptyLine as isEmptyLine,\n\tinsert,\n\t__unstableInsertLineSeparator as insertLineSeparator,\n\tcreate,\n\treplace,\n\tsplit,\n\t__UNSTABLE_LINE_SEPARATOR as LINE_SEPARATOR,\n\ttoHTMLString,\n\tslice,\n} from '@wordpress/rich-text';\nimport deprecated from '@wordpress/deprecated';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport Autocomplete from '../autocomplete';\nimport { useBlockEditContext } from '../block-edit';\nimport { RemoveBrowserShortcuts } from './remove-browser-shortcuts';\nimport { filePasteHandler } from './file-paste-handler';\nimport FormatToolbarContainer from './format-toolbar-container';\nimport { useNativeProps } from './use-native-props';\nimport { store as blockEditorStore } from '../../store';\nimport {\n\taddActiveFormats,\n\tgetMultilineTag,\n\tgetAllowedFormats,\n\tisShortcode,\n\tcreateLinkInParagraph,\n} from './utils';\nimport EmbedHandlerPicker from './embed-handler-picker';\n\nconst wrapperClasses = 'block-editor-rich-text';\nconst classes = 'block-editor-rich-text__editable';\n\nfunction RichTextWrapper(\n\t{\n\t\tchildren,\n\t\ttagName,\n\t\tvalue: originalValue,\n\t\tonChange: originalOnChange,\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\tformattingControls,\n\t\twithoutInteractiveFormatting,\n\t\tonRemove,\n\t\tonMerge,\n\t\tonSplit,\n\t\t__unstableOnSplitAtEnd: onSplitAtEnd,\n\t\t__unstableOnSplitMiddle: onSplitMiddle,\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\tunstableOnFocus,\n\t\t__unstableAllowPrefixTransformations,\n\t\t__unstableMultilineRootTag,\n\t\t// Native props.\n\t\t__unstableMobileNoFocusOnMount,\n\t\tdeleteEnter,\n\t\tplaceholderTextColor,\n\t\ttextAlign,\n\t\tselectionColor,\n\t\ttagsToEliminate,\n\t\trootTagsToEliminate,\n\t\tdisableEditingMenu,\n\t\tfontSize,\n\t\tfontFamily,\n\t\tfontWeight,\n\t\tfontStyle,\n\t\tminWidth,\n\t\tmaxWidth,\n\t\tonBlur,\n\t\tsetRef,\n\t\t...props\n\t},\n\tforwardedRef\n) {\n\tconst instanceId = useInstanceId( RichTextWrapper );\n\n\tidentifier = identifier || instanceId;\n\n\tconst fallbackRef = useRef();\n\tconst { clientId, isSelected: blockIsSelected } = useBlockEditContext();\n\tconst nativeProps = useNativeProps();\n\tconst embedHandlerPickerRef = useRef();\n\tconst selector = ( select ) => {\n\t\tconst {\n\t\t\tisCaretWithinFormattedText,\n\t\t\tgetSelectionStart,\n\t\t\tgetSelectionEnd,\n\t\t\tgetSettings,\n\t\t\tdidAutomaticChange,\n\t\t\tgetBlock,\n\t\t\tisMultiSelecting,\n\t\t\thasMultiSelection,\n\t\t} = select( blockEditorStore );\n\n\t\tconst selectionStart = getSelectionStart();\n\t\tconst selectionEnd = getSelectionEnd();\n\t\tconst { __experimentalUndo: undo } = getSettings();\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\tselectionStart.attributeKey === identifier;\n\t\t} else if ( originalIsSelected ) {\n\t\t\tisSelected = selectionStart.clientId === clientId;\n\t\t}\n\n\t\tlet extraProps = {};\n\t\tif ( Platform.OS === 'native' ) {\n\t\t\t// If the block of this RichText is unmodified then it's a candidate for replacing when adding a new block.\n\t\t\t// In order to fix https://github.com/wordpress-mobile/gutenberg-mobile/issues/1126, let's blur on unmount in that case.\n\t\t\t// This apparently assumes functionality the BlockHlder actually\n\t\t\tconst block = clientId && getBlock( clientId );\n\t\t\tconst shouldBlurOnUnmount =\n\t\t\t\tblock && isSelected && isUnmodifiedDefaultBlock( block );\n\t\t\textraProps = {\n\t\t\t\tshouldBlurOnUnmount,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tisCaretWithinFormattedText: isCaretWithinFormattedText(),\n\t\t\tselectionStart: isSelected ? selectionStart.offset : undefined,\n\t\t\tselectionEnd: isSelected ? selectionEnd.offset : undefined,\n\t\t\tisSelected,\n\t\t\tdidAutomaticChange: didAutomaticChange(),\n\t\t\tdisabled: isMultiSelecting() || hasMultiSelection(),\n\t\t\tundo,\n\t\t\t...extraProps,\n\t\t};\n\t};\n\t// This selector must run on every render so the right selection state is\n\t// retreived from the store on merge.\n\t// To do: fix this somehow.\n\tconst {\n\t\tisCaretWithinFormattedText,\n\t\tselectionStart,\n\t\tselectionEnd,\n\t\tisSelected,\n\t\tdidAutomaticChange,\n\t\tdisabled,\n\t\tundo,\n\t\tshouldBlurOnUnmount,\n\t} = useSelect( selector );\n\tconst {\n\t\t__unstableMarkLastChangeAsPersistent,\n\t\tenterFormattedText,\n\t\texitFormattedText,\n\t\tselectionChange,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\tconst multilineTag = getMultilineTag( multiline );\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats,\n\t\tformattingControls,\n\t\tdisableFormats,\n\t} );\n\tconst hasFormats =\n\t\t! adjustedAllowedFormats || adjustedAllowedFormats.length > 0;\n\tlet adjustedValue = originalValue;\n\tlet adjustedOnChange = originalOnChange;\n\n\t// Handle deprecated format.\n\tif ( Array.isArray( originalValue ) ) {\n\t\tadjustedValue = childrenSource.toHTML( originalValue );\n\t\tadjustedOnChange = ( newValue ) =>\n\t\t\toriginalOnChange(\n\t\t\t\tchildrenSource.fromDOM(\n\t\t\t\t\t__unstableCreateElement( document, newValue ).childNodes\n\t\t\t\t)\n\t\t\t);\n\t}\n\n\tconst onSelectionChange = useCallback(\n\t\t( start, end ) => {\n\t\t\tselectionChange( clientId, identifier, start, end );\n\t\t},\n\t\t[ clientId, identifier ]\n\t);\n\n\tconst onDelete = useCallback(\n\t\t( { value, isReverse } ) => {\n\t\t\tif ( onMerge ) {\n\t\t\t\tonMerge( ! isReverse );\n\t\t\t}\n\n\t\t\t// Only handle remove on Backspace. This serves dual-purpose of being\n\t\t\t// an intentional user interaction distinguishing between Backspace and\n\t\t\t// Delete to remove the empty field, but also to avoid merge & remove\n\t\t\t// causing destruction of two fields (merge, then removed merged).\n\t\t\tif ( onRemove && isEmpty( value ) && isReverse ) {\n\t\t\t\tonRemove( ! isReverse );\n\t\t\t}\n\t\t},\n\t\t[ onMerge, onRemove ]\n\t);\n\n\t/**\n\t * Signals to the RichText owner that the block can be replaced with two\n\t * blocks as a result of splitting the block by pressing enter, or with\n\t * blocks as a result of splitting the block by pasting block content in the\n\t * instance.\n\t *\n\t * @param {Object} record The rich text value to split.\n\t * @param {Array} pastedBlocks The pasted blocks to insert, if any.\n\t */\n\tconst splitValue = useCallback(\n\t\t( record, pastedBlocks = [] ) => {\n\t\t\tif ( ! onReplace || ! onSplit ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst blocks = [];\n\t\t\tconst [ before, after ] = split( record );\n\t\t\tconst hasPastedBlocks = pastedBlocks.length > 0;\n\t\t\tlet lastPastedBlockIndex = -1;\n\n\t\t\t// Consider the after value to be the original it is not empty and\n\t\t\t// the before value *is* empty.\n\t\t\tconst isAfterOriginal = isEmpty( before ) && ! isEmpty( after );\n\n\t\t\t// Create a block with the content before the caret if there's no pasted\n\t\t\t// blocks, or if there are pasted blocks and the value is not empty.\n\t\t\t// We do not want a leading empty block on paste, but we do if split\n\t\t\t// with e.g. the enter key.\n\t\t\tif ( ! hasPastedBlocks || ! isEmpty( before ) ) {\n\t\t\t\tblocks.push(\n\t\t\t\t\tonSplit(\n\t\t\t\t\t\ttoHTMLString( {\n\t\t\t\t\t\t\tvalue: before,\n\t\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t\t! isAfterOriginal\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tlastPastedBlockIndex += 1;\n\t\t\t}\n\n\t\t\tif ( hasPastedBlocks ) {\n\t\t\t\tblocks.push( ...pastedBlocks );\n\t\t\t\tlastPastedBlockIndex += pastedBlocks.length;\n\t\t\t} else if ( onSplitMiddle ) {\n\t\t\t\tblocks.push( onSplitMiddle() );\n\t\t\t}\n\n\t\t\t// If there's pasted blocks, append a block with non empty content\n\t\t\t/// after the caret. Otherwise, do append an empty block if there\n\t\t\t// is no `onSplitMiddle` prop, but if there is and the content is\n\t\t\t// empty, the middle block is enough to set focus in.\n\t\t\tif (\n\t\t\t\thasPastedBlocks\n\t\t\t\t\t? ! isEmpty( after )\n\t\t\t\t\t: ! onSplitMiddle || ! isEmpty( after )\n\t\t\t) {\n\t\t\t\tblocks.push(\n\t\t\t\t\tonSplit(\n\t\t\t\t\t\ttoHTMLString( {\n\t\t\t\t\t\t\tvalue: after,\n\t\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t\tisAfterOriginal\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// If there are pasted blocks, set the selection to the last one.\n\t\t\t// Otherwise, set the selection to the second block.\n\t\t\tconst indexToSelect = hasPastedBlocks ? lastPastedBlockIndex : 1;\n\n\t\t\t// If there are pasted blocks, move the caret to the end of the selected block\n\t\t\t// Otherwise, retain the default value.\n\t\t\tconst initialPosition = hasPastedBlocks ? -1 : 0;\n\n\t\t\tonReplace( blocks, indexToSelect, initialPosition );\n\t\t},\n\t\t[ onReplace, onSplit, multilineTag, onSplitMiddle ]\n\t);\n\n\tconst onEnter = useCallback(\n\t\t( { value, onChange, shiftKey } ) => {\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( { content: value.text } ),\n\t\t\t\t\t] );\n\t\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( multiline ) {\n\t\t\t\tif ( shiftKey ) {\n\t\t\t\t\tif ( ! disableLineBreaks ) {\n\t\t\t\t\t\tonChange( insert( value, '\\n' ) );\n\t\t\t\t\t}\n\t\t\t\t} else if ( canSplit && isEmptyLine( value ) ) {\n\t\t\t\t\tsplitValue( value );\n\t\t\t\t} else {\n\t\t\t\t\tonChange( insertLineSeparator( value ) );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst { text, start, end } = value;\n\t\t\t\tconst canSplitAtEnd =\n\t\t\t\t\tonSplitAtEnd && start === end && end === text.length;\n\n\t\t\t\tif ( shiftKey || ( ! canSplit && ! canSplitAtEnd ) ) {\n\t\t\t\t\tif ( ! disableLineBreaks ) {\n\t\t\t\t\t\tonChange( insert( value, '\\n' ) );\n\t\t\t\t\t}\n\t\t\t\t} else if ( ! canSplit && canSplitAtEnd ) {\n\t\t\t\t\tonSplitAtEnd();\n\t\t\t\t} else if ( canSplit ) {\n\t\t\t\t\tsplitValue( value );\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tonReplace,\n\t\t\tonSplit,\n\t\t\t__unstableMarkAutomaticChange,\n\t\t\tmultiline,\n\t\t\tsplitValue,\n\t\t\tonSplitAtEnd,\n\t\t]\n\t);\n\n\tconst onPaste = useCallback(\n\t\t( {\n\t\t\tvalue,\n\t\t\tonChange,\n\t\t\thtml,\n\t\t\tplainText,\n\t\t\tisInternal,\n\t\t\tfiles,\n\t\t\tactiveFormats,\n\t\t} ) => {\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( {\n\t\t\t\t\thtml,\n\t\t\t\t\tmultilineTag,\n\t\t\t\t\tmultilineWrapperTags:\n\t\t\t\t\t\tmultilineTag === 'li' ? [ 'ul', 'ol' ] : undefined,\n\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t} );\n\t\t\t\taddActiveFormats( pastedValue, 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\t// Only process file if no HTML is present.\n\t\t\t// Note: a pasted file may have the URL as plain text.\n\t\t\tif ( files && files.length && ! html ) {\n\t\t\t\tconst content = pasteHandler( {\n\t\t\t\t\tHTML: filePasteHandler( files ),\n\t\t\t\t\tmode: 'BLOCKS',\n\t\t\t\t\ttagName,\n\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t} );\n\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\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tonReplace( content );\n\t\t\t\t} else {\n\t\t\t\t\tsplitValue( value, content );\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\t// Force the blocks mode when the user is pasting\n\t\t\t// on a new line & the content resembles a shortcode.\n\t\t\t// Otherwise it's going to be detected as inline\n\t\t\t// and the shortcode won't be replaced.\n\t\t\tif (\n\t\t\t\tmode === 'AUTO' &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisShortcode( plainText )\n\t\t\t) {\n\t\t\t\tmode = 'BLOCKS';\n\t\t\t}\n\n\t\t\tconst isPastedURL = isURL( plainText.trim() );\n\t\t\tconst presentEmbedHandlerPicker = () =>\n\t\t\t\tembedHandlerPickerRef.current?.presentPicker( {\n\t\t\t\t\tcreateEmbed: () =>\n\t\t\t\t\t\tonReplace( content, content.length - 1, -1 ),\n\t\t\t\t\tcreateLink: () =>\n\t\t\t\t\t\tcreateLinkInParagraph( plainText.trim(), onReplace ),\n\t\t\t\t} );\n\n\t\t\tif (\n\t\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisPastedURL\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\tpreserveWhiteSpace,\n\t\t\t} );\n\n\t\t\tif ( typeof content === 'string' ) {\n\t\t\t\tlet valueToInsert = create( { html: content } );\n\n\t\t\t\taddActiveFormats( valueToInsert, activeFormats );\n\n\t\t\t\t// If the content should be multiline, we should process text\n\t\t\t\t// separated by a line break as separate lines.\n\t\t\t\tif ( multilineTag ) {\n\t\t\t\t\tvalueToInsert = replace(\n\t\t\t\t\t\tvalueToInsert,\n\t\t\t\t\t\t/\\n+/g,\n\t\t\t\t\t\tLINE_SEPARATOR\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t} else if ( content.length > 0 ) {\n\t\t\t\t// When an URL is pasted in an empty paragraph then the EmbedHandlerPicker should showcase options allowing the transformation of that URL\n\t\t\t\t// into either an Embed block or a link within the target paragraph. If the paragraph is non-empty, the URL is pasted as text.\n\t\t\t\tconst canPasteEmbed =\n\t\t\t\t\tisPastedURL &&\n\t\t\t\t\tcontent.length === 1 &&\n\t\t\t\t\tcontent[ 0 ].name === 'core/embed';\n\t\t\t\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tif ( canPasteEmbed ) {\n\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\tinsert( value, create( { text: plainText } ) )\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( __unstableEmbedURLOnPaste ) {\n\t\t\t\t\t\t\tpresentEmbedHandlerPicker();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tonReplace( content, content.length - 1, -1 );\n\t\t\t\t} else {\n\t\t\t\t\tif ( canPasteEmbed ) {\n\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\tinsert( value, create( { text: plainText } ) )\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tsplitValue( value, content );\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\ttagName,\n\t\t\tonReplace,\n\t\t\tonSplit,\n\t\t\tsplitValue,\n\t\t\t__unstableEmbedURLOnPaste,\n\t\t\tmultilineTag,\n\t\t\tpreserveWhiteSpace,\n\t\t\tpastePlainText,\n\t\t]\n\t);\n\n\tconst inputRule = useCallback(\n\t\t( value, valueToFormat ) => {\n\t\t\tif ( ! onReplace ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { start, text } = value;\n\t\t\tconst characterBefore = text.slice( start - 1, start );\n\n\t\t\t// The character right before the caret must be a plain space.\n\t\t\tif ( characterBefore !== ' ' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst trimmedTextBefore = text.slice( 0, start ).trim();\n\t\t\tconst prefixTransforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t( { type } ) => type === 'prefix'\n\t\t\t);\n\t\t\tconst transformation = findTransform(\n\t\t\t\tprefixTransforms,\n\t\t\t\t( { prefix } ) => {\n\t\t\t\t\treturn trimmedTextBefore === prefix;\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( ! transformation ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst content = valueToFormat( slice( value, start, text.length ) );\n\t\t\tconst block = transformation.transform( content );\n\n\t\t\tonReplace( [ block ] );\n\t\t\t__unstableMarkAutomaticChange();\n\t\t},\n\t\t[ onReplace, __unstableMarkAutomaticChange ]\n\t);\n\n\tconst mergedRef = useMergeRefs( [ forwardedRef, fallbackRef ] );\n\n\tconst content = (\n\t\t<RichText\n\t\t\tclientId={ clientId }\n\t\t\tidentifier={ identifier }\n\t\t\tref={ mergedRef }\n\t\t\tvalue={ adjustedValue }\n\t\t\tonChange={ adjustedOnChange }\n\t\t\tselectionStart={ selectionStart }\n\t\t\tselectionEnd={ selectionEnd }\n\t\t\tonSelectionChange={ onSelectionChange }\n\t\t\ttagName={ tagName }\n\t\t\tplaceholder={ placeholder }\n\t\t\tallowedFormats={ adjustedAllowedFormats }\n\t\t\twithoutInteractiveFormatting={ withoutInteractiveFormatting }\n\t\t\tonEnter={ onEnter }\n\t\t\tonDelete={ onDelete }\n\t\t\tonPaste={ onPaste }\n\t\t\t__unstableIsSelected={ isSelected }\n\t\t\t__unstableInputRule={ inputRule }\n\t\t\t__unstableMultilineTag={ multilineTag }\n\t\t\t__unstableIsCaretWithinFormattedText={ isCaretWithinFormattedText }\n\t\t\t__unstableOnEnterFormattedText={ enterFormattedText }\n\t\t\t__unstableOnExitFormattedText={ exitFormattedText }\n\t\t\t__unstableOnCreateUndoLevel={ __unstableMarkLastChangeAsPersistent }\n\t\t\t__unstableMarkAutomaticChange={ __unstableMarkAutomaticChange }\n\t\t\t__unstableDidAutomaticChange={ didAutomaticChange }\n\t\t\t__unstableUndo={ undo }\n\t\t\t__unstableDisableFormats={ disableFormats }\n\t\t\tpreserveWhiteSpace={ preserveWhiteSpace }\n\t\t\tdisabled={ disabled }\n\t\t\tunstableOnFocus={ unstableOnFocus }\n\t\t\t__unstableAllowPrefixTransformations={\n\t\t\t\t__unstableAllowPrefixTransformations\n\t\t\t}\n\t\t\t__unstableMultilineRootTag={ __unstableMultilineRootTag }\n\t\t\t// Native props.\n\t\t\t{ ...nativeProps }\n\t\t\tblockIsSelected={\n\t\t\t\toriginalIsSelected !== undefined\n\t\t\t\t\t? originalIsSelected\n\t\t\t\t\t: blockIsSelected\n\t\t\t}\n\t\t\tshouldBlurOnUnmount={ shouldBlurOnUnmount }\n\t\t\t__unstableMobileNoFocusOnMount={ __unstableMobileNoFocusOnMount }\n\t\t\tdeleteEnter={ deleteEnter }\n\t\t\tplaceholderTextColor={ placeholderTextColor }\n\t\t\ttextAlign={ textAlign }\n\t\t\tselectionColor={ selectionColor }\n\t\t\ttagsToEliminate={ tagsToEliminate }\n\t\t\trootTagsToEliminate={ rootTagsToEliminate }\n\t\t\tdisableEditingMenu={ disableEditingMenu }\n\t\t\tfontSize={ fontSize }\n\t\t\tfontFamily={ fontFamily }\n\t\t\tfontWeight={ fontWeight }\n\t\t\tfontStyle={ fontStyle }\n\t\t\tminWidth={ minWidth }\n\t\t\tmaxWidth={ maxWidth }\n\t\t\tonBlur={ onBlur }\n\t\t\tsetRef={ setRef }\n\t\t\t// Props to be set on the editable container are destructured on the\n\t\t\t// element itself for web (see below), but passed through rich text\n\t\t\t// for native.\n\t\t\tid={ props.id }\n\t\t\tstyle={ props.style }\n\t\t>\n\t\t\t{ ( {\n\t\t\t\tisSelected: nestedIsSelected,\n\t\t\t\tvalue,\n\t\t\t\tonChange,\n\t\t\t\tonFocus,\n\t\t\t\teditableProps,\n\t\t\t\teditableTagName: TagName,\n\t\t\t} ) => (\n\t\t\t\t<>\n\t\t\t\t\t{ children && children( { value, onChange, onFocus } ) }\n\t\t\t\t\t{ nestedIsSelected && hasFormats && (\n\t\t\t\t\t\t<FormatToolbarContainer\n\t\t\t\t\t\t\tinline={ inlineToolbar }\n\t\t\t\t\t\t\tanchorRef={ fallbackRef.current }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ nestedIsSelected && <RemoveBrowserShortcuts /> }\n\t\t\t\t\t<Autocomplete\n\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\tcompleters={ autocompleters }\n\t\t\t\t\t\trecord={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tisSelected={ nestedIsSelected }\n\t\t\t\t\t\tcontentRef={ fallbackRef }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( { listBoxId, activeId, onKeyDown } ) => (\n\t\t\t\t\t\t\t<TagName\n\t\t\t\t\t\t\t\t{ ...editableProps }\n\t\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\tprops.style\n\t\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t\t...props.style,\n\t\t\t\t\t\t\t\t\t\t\t\t...editableProps.style,\n\t\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t\t: editableProps.style\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\tclasses,\n\t\t\t\t\t\t\t\t\tprops.className,\n\t\t\t\t\t\t\t\t\teditableProps.className\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\taria-autocomplete={\n\t\t\t\t\t\t\t\t\tlistBoxId ? 'list' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\taria-owns={ listBoxId }\n\t\t\t\t\t\t\t\taria-activedescendant={ activeId }\n\t\t\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\t\t\tonKeyDown( event );\n\t\t\t\t\t\t\t\t\teditableProps.onKeyDown( event );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Autocomplete>\n\t\t\t\t\t<EmbedHandlerPicker ref={ embedHandlerPickerRef } />\n\t\t\t\t</>\n\t\t\t) }\n\t\t</RichText>\n\t);\n\n\tif ( ! wrapperClassName ) {\n\t\treturn content;\n\t}\n\n\tdeprecated( 'wp.blockEditor.RichText wrapperClassName prop', {\n\t\tsince: '5.4',\n\t\talternative: 'className prop or create your own wrapper div',\n\t} );\n\n\treturn (\n\t\t<div className={ classnames( wrapperClasses, wrapperClassName ) }>\n\t\t\t{ content }\n\t\t</div>\n\t);\n}\n\nconst ForwardedRichTextContainer = forwardRef( RichTextWrapper );\n\nForwardedRichTextContainer.Content = ( {\n\tvalue,\n\ttagName: Tag,\n\tmultiline,\n\t...props\n} ) => {\n\t// Handle deprecated `children` and `node` sources.\n\tif ( Array.isArray( value ) ) {\n\t\tvalue = childrenSource.toHTML( value );\n\t}\n\n\tconst MultilineTag = getMultilineTag( multiline );\n\n\tif ( ! value && MultilineTag ) {\n\t\tvalue = `<${ MultilineTag }></${ MultilineTag }>`;\n\t}\n\n\tconst content = <RawHTML>{ value }</RawHTML>;\n\n\tif ( Tag ) {\n\t\treturn <Tag { ...omit( props, [ 'format' ] ) }>{ content }</Tag>;\n\t}\n\n\treturn content;\n};\n\nForwardedRichTextContainer.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\nForwardedRichTextContainer.Content.defaultProps = {\n\tformat: 'string',\n\tvalue: '',\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"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/index.native.js"],"names":["classnames","omit","RawHTML","Platform","useRef","useCallback","forwardRef","useDispatch","useSelect","pasteHandler","children","childrenSource","getBlockTransforms","findTransform","isUnmodifiedDefaultBlock","useInstanceId","useMergeRefs","__experimentalRichText","RichText","__unstableCreateElement","isEmpty","__unstableIsEmptyLine","isEmptyLine","insert","__unstableInsertLineSeparator","insertLineSeparator","create","replace","split","__UNSTABLE_LINE_SEPARATOR","LINE_SEPARATOR","toHTMLString","slice","deprecated","isURL","Autocomplete","useBlockEditContext","RemoveBrowserShortcuts","filePasteHandler","FormatToolbarContainer","useNativeProps","store","blockEditorStore","addActiveFormats","getMultilineTag","getAllowedFormats","isShortcode","createLinkInParagraph","EmbedHandlerPicker","wrapperClasses","classes","RichTextWrapper","forwardedRef","tagName","value","originalValue","onChange","originalOnChange","isSelected","originalIsSelected","multiline","inlineToolbar","wrapperClassName","autocompleters","onReplace","placeholder","allowedFormats","formattingControls","withoutInteractiveFormatting","onRemove","onMerge","onSplit","__unstableOnSplitAtEnd","onSplitAtEnd","__unstableOnSplitMiddle","onSplitMiddle","identifier","preserveWhiteSpace","__unstablePastePlainText","pastePlainText","__unstableEmbedURLOnPaste","__unstableDisableFormats","disableFormats","disableLineBreaks","unstableOnFocus","__unstableAllowPrefixTransformations","__unstableMultilineRootTag","__unstableMobileNoFocusOnMount","deleteEnter","placeholderTextColor","textAlign","selectionColor","tagsToEliminate","rootTagsToEliminate","disableEditingMenu","fontSize","fontFamily","fontWeight","fontStyle","minWidth","maxWidth","onBlur","setRef","props","instanceId","fallbackRef","clientId","blockIsSelected","nativeProps","embedHandlerPickerRef","selector","select","isCaretWithinFormattedText","getSelectionStart","getSelectionEnd","getSettings","didAutomaticChange","getBlock","isMultiSelecting","hasMultiSelection","selectionStart","selectionEnd","__experimentalUndo","undo","undefined","attributeKey","extraProps","OS","block","shouldBlurOnUnmount","offset","disabled","__unstableMarkLastChangeAsPersistent","enterFormattedText","exitFormattedText","selectionChange","__unstableMarkAutomaticChange","multilineTag","adjustedAllowedFormats","hasFormats","length","adjustedValue","adjustedOnChange","Array","isArray","toHTML","newValue","fromDOM","document","childNodes","onSelectionChange","start","end","onDelete","isReverse","splitValue","record","pastedBlocks","blocks","before","after","hasPastedBlocks","lastPastedBlockIndex","isAfterOriginal","push","indexToSelect","initialPosition","onEnter","shiftKey","canSplit","transforms","filter","type","transformation","item","regExp","test","text","transform","content","canSplitAtEnd","onPaste","html","plainText","isInternal","files","activeFormats","pastedValue","multilineWrapperTags","HTML","mode","window","console","log","isPastedURL","trim","presentEmbedHandlerPicker","current","presentPicker","createEmbed","createLink","valueToInsert","canPasteEmbed","name","inputRule","valueToFormat","characterBefore","trimmedTextBefore","prefixTransforms","prefix","mergedRef","id","style","nestedIsSelected","onFocus","editableProps","editableTagName","TagName","listBoxId","activeId","onKeyDown","className","event","since","alternative","version","ForwardedRichTextContainer","Content","Tag","MultilineTag","defaultProps","format","RichTextShortcut","RichTextToolbarButton","__unstableRichTextInputEvent"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SACCC,OADD,EAECC,QAFD,EAGCC,MAHD,EAICC,WAJD,EAKCC,UALD,QAMO,oBANP;AAOA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SACCC,YADD,EAECC,QAAQ,IAAIC,cAFb,EAGCC,kBAHD,EAICC,aAJD,EAKCC,wBALD,QAMO,mBANP;AAOA,SAASC,aAAT,EAAwBC,YAAxB,QAA4C,oBAA5C;AACA,SACCC,sBAAsB,IAAIC,QAD3B,EAECC,uBAFD,EAGCC,OAHD,EAICC,qBAAqB,IAAIC,WAJ1B,EAKCC,MALD,EAMCC,6BAA6B,IAAIC,mBANlC,EAOCC,MAPD,EAQCC,OARD,EASCC,KATD,EAUCC,yBAAyB,IAAIC,cAV9B,EAWCC,YAXD,EAYCC,KAZD,QAaO,sBAbP;AAcA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,KAAT,QAAsB,gBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,SAASC,mBAAT,QAAoC,eAApC;AACA,SAASC,sBAAT,QAAuC,4BAAvC;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AACA,OAAOC,sBAAP,MAAmC,4BAAnC;AACA,SAASC,cAAT,QAA+B,oBAA/B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SACCC,gBADD,EAECC,eAFD,EAGCC,iBAHD,EAICC,WAJD,EAKCC,qBALD,QAMO,SANP;AAOA,OAAOC,kBAAP,MAA+B,wBAA/B;AAEA,MAAMC,c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AAf,CAAuB3F,KAAvB,CAAR;AACA;;AAED,QAAM+K,YAAY,GAAGzL,eAAe,CAAEgB,SAAF,CAApC;;AAEA,MAAK,CAAEN,KAAF,IAAW+K,YAAhB,EAA+B;AAC9B/K,IAAAA,KAAK,GAAI,IAAI+K,YAAc,MAAMA,YAAc,GAA/C;AACA;;AAED,QAAMlD,OAAO,GAAG,cAAC,OAAD,QAAW7H,KAAX,CAAhB;;AAEA,MAAK8K,GAAL,EAAW;AACV,WAAO,cAAC,GAAD,EAAUnO,IAAI,CAAEsG,KAAF,EAAS,CAAE,QAAF,CAAT,CAAd,EAA0C4E,OAA1C,CAAP;AACA;;AAED,SAAOA,OAAP;AACA,CAxBD;;AA0BA+C,0BAA0B,CAAC9M,OAA3B,GAAuCkC,KAAF,IAAa;AACjD,SAAO,CAAEA,KAAF,IAAWA,KAAK,CAACsF,MAAN,KAAiB,CAAnC;AACA,CAFD;;AAIAsF,0BAA0B,CAACC,OAA3B,CAAmCG,YAAnC,GAAkD;AACjDC,EAAAA,MAAM,EAAE,QADyC;AAEjDjL,EAAAA,KAAK,EAAE;AAF0C,CAAlD;AAKA;AACA;AACA;;AACA,eAAe4K,0BAAf;AACA,SAASM,gBAAT,QAAiC,YAAjC;AACA,SAASC,qBAAT,QAAsC,kBAAtC;AACA,SAASC,4BAAT,QAA6C,eAA7C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { omit } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tRawHTML,\n\tPlatform,\n\tuseRef,\n\tuseCallback,\n\tforwardRef,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tpasteHandler,\n\tchildren as childrenSource,\n\tgetBlockTransforms,\n\tfindTransform,\n\tisUnmodifiedDefaultBlock,\n} from '@wordpress/blocks';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport {\n\t__experimentalRichText as RichText,\n\t__unstableCreateElement,\n\tisEmpty,\n\t__unstableIsEmptyLine as isEmptyLine,\n\tinsert,\n\t__unstableInsertLineSeparator as insertLineSeparator,\n\tcreate,\n\treplace,\n\tsplit,\n\t__UNSTABLE_LINE_SEPARATOR as LINE_SEPARATOR,\n\ttoHTMLString,\n\tslice,\n} from '@wordpress/rich-text';\nimport deprecated from '@wordpress/deprecated';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport Autocomplete from '../autocomplete';\nimport { useBlockEditContext } from '../block-edit';\nimport { RemoveBrowserShortcuts } from './remove-browser-shortcuts';\nimport { filePasteHandler } from './file-paste-handler';\nimport FormatToolbarContainer from './format-toolbar-container';\nimport { useNativeProps } from './use-native-props';\nimport { store as blockEditorStore } from '../../store';\nimport {\n\taddActiveFormats,\n\tgetMultilineTag,\n\tgetAllowedFormats,\n\tisShortcode,\n\tcreateLinkInParagraph,\n} from './utils';\nimport EmbedHandlerPicker from './embed-handler-picker';\n\nconst wrapperClasses = 'block-editor-rich-text';\nconst classes = 'block-editor-rich-text__editable';\n\nfunction RichTextWrapper(\n\t{\n\t\tchildren,\n\t\ttagName,\n\t\tvalue: originalValue,\n\t\tonChange: originalOnChange,\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\tformattingControls,\n\t\twithoutInteractiveFormatting,\n\t\tonRemove,\n\t\tonMerge,\n\t\tonSplit,\n\t\t__unstableOnSplitAtEnd: onSplitAtEnd,\n\t\t__unstableOnSplitMiddle: onSplitMiddle,\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\tunstableOnFocus,\n\t\t__unstableAllowPrefixTransformations,\n\t\t__unstableMultilineRootTag,\n\t\t// Native props.\n\t\t__unstableMobileNoFocusOnMount,\n\t\tdeleteEnter,\n\t\tplaceholderTextColor,\n\t\ttextAlign,\n\t\tselectionColor,\n\t\ttagsToEliminate,\n\t\trootTagsToEliminate,\n\t\tdisableEditingMenu,\n\t\tfontSize,\n\t\tfontFamily,\n\t\tfontWeight,\n\t\tfontStyle,\n\t\tminWidth,\n\t\tmaxWidth,\n\t\tonBlur,\n\t\tsetRef,\n\t\t...props\n\t},\n\tforwardedRef\n) {\n\tconst instanceId = useInstanceId( RichTextWrapper );\n\n\tidentifier = identifier || instanceId;\n\n\tconst fallbackRef = useRef();\n\tconst { clientId, isSelected: blockIsSelected } = useBlockEditContext();\n\tconst nativeProps = useNativeProps();\n\tconst embedHandlerPickerRef = useRef();\n\tconst selector = ( select ) => {\n\t\tconst {\n\t\t\tisCaretWithinFormattedText,\n\t\t\tgetSelectionStart,\n\t\t\tgetSelectionEnd,\n\t\t\tgetSettings,\n\t\t\tdidAutomaticChange,\n\t\t\tgetBlock,\n\t\t\tisMultiSelecting,\n\t\t\thasMultiSelection,\n\t\t} = select( blockEditorStore );\n\n\t\tconst selectionStart = getSelectionStart();\n\t\tconst selectionEnd = getSelectionEnd();\n\t\tconst { __experimentalUndo: undo } = getSettings();\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\tselectionStart.attributeKey === identifier;\n\t\t} else if ( originalIsSelected ) {\n\t\t\tisSelected = selectionStart.clientId === clientId;\n\t\t}\n\n\t\tlet extraProps = {};\n\t\tif ( Platform.OS === 'native' ) {\n\t\t\t// If the block of this RichText is unmodified then it's a candidate for replacing when adding a new block.\n\t\t\t// In order to fix https://github.com/wordpress-mobile/gutenberg-mobile/issues/1126, let's blur on unmount in that case.\n\t\t\t// This apparently assumes functionality the BlockHlder actually\n\t\t\tconst block = clientId && getBlock( clientId );\n\t\t\tconst shouldBlurOnUnmount =\n\t\t\t\tblock && isSelected && isUnmodifiedDefaultBlock( block );\n\t\t\textraProps = {\n\t\t\t\tshouldBlurOnUnmount,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tisCaretWithinFormattedText: isCaretWithinFormattedText(),\n\t\t\tselectionStart: isSelected ? selectionStart.offset : undefined,\n\t\t\tselectionEnd: isSelected ? selectionEnd.offset : undefined,\n\t\t\tisSelected,\n\t\t\tdidAutomaticChange: didAutomaticChange(),\n\t\t\tdisabled: isMultiSelecting() || hasMultiSelection(),\n\t\t\tundo,\n\t\t\t...extraProps,\n\t\t};\n\t};\n\t// This selector must run on every render so the right selection state is\n\t// retreived from the store on merge.\n\t// To do: fix this somehow.\n\tconst {\n\t\tisCaretWithinFormattedText,\n\t\tselectionStart,\n\t\tselectionEnd,\n\t\tisSelected,\n\t\tdidAutomaticChange,\n\t\tdisabled,\n\t\tundo,\n\t\tshouldBlurOnUnmount,\n\t} = useSelect( selector );\n\tconst {\n\t\t__unstableMarkLastChangeAsPersistent,\n\t\tenterFormattedText,\n\t\texitFormattedText,\n\t\tselectionChange,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\tconst multilineTag = getMultilineTag( multiline );\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats,\n\t\tformattingControls,\n\t\tdisableFormats,\n\t} );\n\tconst hasFormats =\n\t\t! adjustedAllowedFormats || adjustedAllowedFormats.length > 0;\n\tlet adjustedValue = originalValue;\n\tlet adjustedOnChange = originalOnChange;\n\n\t// Handle deprecated format.\n\tif ( Array.isArray( originalValue ) ) {\n\t\tadjustedValue = childrenSource.toHTML( originalValue );\n\t\tadjustedOnChange = ( newValue ) =>\n\t\t\toriginalOnChange(\n\t\t\t\tchildrenSource.fromDOM(\n\t\t\t\t\t__unstableCreateElement( document, newValue ).childNodes\n\t\t\t\t)\n\t\t\t);\n\t}\n\n\tconst onSelectionChange = useCallback(\n\t\t( start, end ) => {\n\t\t\tselectionChange( clientId, identifier, start, end );\n\t\t},\n\t\t[ clientId, identifier ]\n\t);\n\n\tconst onDelete = useCallback(\n\t\t( { value, isReverse } ) => {\n\t\t\tif ( onMerge ) {\n\t\t\t\tonMerge( ! isReverse );\n\t\t\t}\n\n\t\t\t// Only handle remove on Backspace. This serves dual-purpose of being\n\t\t\t// an intentional user interaction distinguishing between Backspace and\n\t\t\t// Delete to remove the empty field, but also to avoid merge & remove\n\t\t\t// causing destruction of two fields (merge, then removed merged).\n\t\t\tif ( onRemove && isEmpty( value ) && isReverse ) {\n\t\t\t\tonRemove( ! isReverse );\n\t\t\t}\n\t\t},\n\t\t[ onMerge, onRemove ]\n\t);\n\n\t/**\n\t * Signals to the RichText owner that the block can be replaced with two\n\t * blocks as a result of splitting the block by pressing enter, or with\n\t * blocks as a result of splitting the block by pasting block content in the\n\t * instance.\n\t *\n\t * @param {Object} record The rich text value to split.\n\t * @param {Array} pastedBlocks The pasted blocks to insert, if any.\n\t */\n\tconst splitValue = useCallback(\n\t\t( record, pastedBlocks = [] ) => {\n\t\t\tif ( ! onReplace || ! onSplit ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst blocks = [];\n\t\t\tconst [ before, after ] = split( record );\n\t\t\tconst hasPastedBlocks = pastedBlocks.length > 0;\n\t\t\tlet lastPastedBlockIndex = -1;\n\n\t\t\t// Consider the after value to be the original it is not empty and\n\t\t\t// the before value *is* empty.\n\t\t\tconst isAfterOriginal = isEmpty( before ) && ! isEmpty( after );\n\n\t\t\t// Create a block with the content before the caret if there's no pasted\n\t\t\t// blocks, or if there are pasted blocks and the value is not empty.\n\t\t\t// We do not want a leading empty block on paste, but we do if split\n\t\t\t// with e.g. the enter key.\n\t\t\tif ( ! hasPastedBlocks || ! isEmpty( before ) ) {\n\t\t\t\tblocks.push(\n\t\t\t\t\tonSplit(\n\t\t\t\t\t\ttoHTMLString( {\n\t\t\t\t\t\t\tvalue: before,\n\t\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t\t! isAfterOriginal\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tlastPastedBlockIndex += 1;\n\t\t\t}\n\n\t\t\tif ( hasPastedBlocks ) {\n\t\t\t\tblocks.push( ...pastedBlocks );\n\t\t\t\tlastPastedBlockIndex += pastedBlocks.length;\n\t\t\t} else if ( onSplitMiddle ) {\n\t\t\t\tblocks.push( onSplitMiddle() );\n\t\t\t}\n\n\t\t\t// If there's pasted blocks, append a block with non empty content\n\t\t\t/// after the caret. Otherwise, do append an empty block if there\n\t\t\t// is no `onSplitMiddle` prop, but if there is and the content is\n\t\t\t// empty, the middle block is enough to set focus in.\n\t\t\tif (\n\t\t\t\thasPastedBlocks\n\t\t\t\t\t? ! isEmpty( after )\n\t\t\t\t\t: ! onSplitMiddle || ! isEmpty( after )\n\t\t\t) {\n\t\t\t\tblocks.push(\n\t\t\t\t\tonSplit(\n\t\t\t\t\t\ttoHTMLString( {\n\t\t\t\t\t\t\tvalue: after,\n\t\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t\tisAfterOriginal\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// If there are pasted blocks, set the selection to the last one.\n\t\t\t// Otherwise, set the selection to the second block.\n\t\t\tconst indexToSelect = hasPastedBlocks ? lastPastedBlockIndex : 1;\n\n\t\t\t// If there are pasted blocks, move the caret to the end of the selected block\n\t\t\t// Otherwise, retain the default value.\n\t\t\tconst initialPosition = hasPastedBlocks ? -1 : 0;\n\n\t\t\tonReplace( blocks, indexToSelect, initialPosition );\n\t\t},\n\t\t[ onReplace, onSplit, multilineTag, onSplitMiddle ]\n\t);\n\n\tconst onEnter = useCallback(\n\t\t( { value, onChange, shiftKey } ) => {\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( { content: value.text } ),\n\t\t\t\t\t] );\n\t\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( multiline ) {\n\t\t\t\tif ( shiftKey ) {\n\t\t\t\t\tif ( ! disableLineBreaks ) {\n\t\t\t\t\t\tonChange( insert( value, '\\n' ) );\n\t\t\t\t\t}\n\t\t\t\t} else if ( canSplit && isEmptyLine( value ) ) {\n\t\t\t\t\tsplitValue( value );\n\t\t\t\t} else {\n\t\t\t\t\tonChange( insertLineSeparator( value ) );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst { text, start, end } = value;\n\t\t\t\tconst canSplitAtEnd =\n\t\t\t\t\tonSplitAtEnd && start === end && end === text.length;\n\n\t\t\t\tif ( shiftKey || ( ! canSplit && ! canSplitAtEnd ) ) {\n\t\t\t\t\tif ( ! disableLineBreaks ) {\n\t\t\t\t\t\tonChange( insert( value, '\\n' ) );\n\t\t\t\t\t}\n\t\t\t\t} else if ( ! canSplit && canSplitAtEnd ) {\n\t\t\t\t\tonSplitAtEnd();\n\t\t\t\t} else if ( canSplit ) {\n\t\t\t\t\tsplitValue( value );\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tonReplace,\n\t\t\tonSplit,\n\t\t\t__unstableMarkAutomaticChange,\n\t\t\tmultiline,\n\t\t\tsplitValue,\n\t\t\tonSplitAtEnd,\n\t\t]\n\t);\n\n\tconst onPaste = useCallback(\n\t\t( {\n\t\t\tvalue,\n\t\t\tonChange,\n\t\t\thtml,\n\t\t\tplainText,\n\t\t\tisInternal,\n\t\t\tfiles,\n\t\t\tactiveFormats,\n\t\t} ) => {\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( {\n\t\t\t\t\thtml,\n\t\t\t\t\tmultilineTag,\n\t\t\t\t\tmultilineWrapperTags:\n\t\t\t\t\t\tmultilineTag === 'li' ? [ 'ul', 'ol' ] : undefined,\n\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t} );\n\t\t\t\taddActiveFormats( pastedValue, 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\t// Only process file if no HTML is present.\n\t\t\t// Note: a pasted file may have the URL as plain text.\n\t\t\tif ( files && files.length && ! html ) {\n\t\t\t\tconst content = pasteHandler( {\n\t\t\t\t\tHTML: filePasteHandler( files ),\n\t\t\t\t\tmode: 'BLOCKS',\n\t\t\t\t\ttagName,\n\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t} );\n\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\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tonReplace( content );\n\t\t\t\t} else {\n\t\t\t\t\tsplitValue( value, content );\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\t// Force the blocks mode when the user is pasting\n\t\t\t// on a new line & the content resembles a shortcode.\n\t\t\t// Otherwise it's going to be detected as inline\n\t\t\t// and the shortcode won't be replaced.\n\t\t\tif (\n\t\t\t\tmode === 'AUTO' &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisShortcode( plainText )\n\t\t\t) {\n\t\t\t\tmode = 'BLOCKS';\n\t\t\t}\n\n\t\t\tconst isPastedURL = isURL( plainText.trim() );\n\t\t\tconst presentEmbedHandlerPicker = () =>\n\t\t\t\tembedHandlerPickerRef.current?.presentPicker( {\n\t\t\t\t\tcreateEmbed: () =>\n\t\t\t\t\t\tonReplace( content, content.length - 1, -1 ),\n\t\t\t\t\tcreateLink: () =>\n\t\t\t\t\t\tcreateLinkInParagraph( plainText.trim(), onReplace ),\n\t\t\t\t} );\n\n\t\t\tif (\n\t\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisPastedURL\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\tpreserveWhiteSpace,\n\t\t\t} );\n\n\t\t\tif ( typeof content === 'string' ) {\n\t\t\t\tlet valueToInsert = create( { html: content } );\n\n\t\t\t\taddActiveFormats( valueToInsert, activeFormats );\n\n\t\t\t\t// If the content should be multiline, we should process text\n\t\t\t\t// separated by a line break as separate lines.\n\t\t\t\tif ( multilineTag ) {\n\t\t\t\t\tvalueToInsert = replace(\n\t\t\t\t\t\tvalueToInsert,\n\t\t\t\t\t\t/\\n+/g,\n\t\t\t\t\t\tLINE_SEPARATOR\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t} else if ( content.length > 0 ) {\n\t\t\t\t// When an URL is pasted in an empty paragraph then the EmbedHandlerPicker should showcase options allowing the transformation of that URL\n\t\t\t\t// into either an Embed block or a link within the target paragraph. If the paragraph is non-empty, the URL is pasted as text.\n\t\t\t\tconst canPasteEmbed =\n\t\t\t\t\tisPastedURL &&\n\t\t\t\t\tcontent.length === 1 &&\n\t\t\t\t\tcontent[ 0 ].name === 'core/embed';\n\t\t\t\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tif ( canPasteEmbed ) {\n\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\tinsert( value, create( { text: plainText } ) )\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( __unstableEmbedURLOnPaste ) {\n\t\t\t\t\t\t\tpresentEmbedHandlerPicker();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tonReplace( content, content.length - 1, -1 );\n\t\t\t\t} else {\n\t\t\t\t\tif ( canPasteEmbed ) {\n\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\tinsert( value, create( { text: plainText } ) )\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tsplitValue( value, content );\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\ttagName,\n\t\t\tonReplace,\n\t\t\tonSplit,\n\t\t\tsplitValue,\n\t\t\t__unstableEmbedURLOnPaste,\n\t\t\tmultilineTag,\n\t\t\tpreserveWhiteSpace,\n\t\t\tpastePlainText,\n\t\t]\n\t);\n\n\tconst inputRule = useCallback(\n\t\t( value, valueToFormat ) => {\n\t\t\tif ( ! onReplace ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { start, text } = value;\n\t\t\tconst characterBefore = text.slice( start - 1, start );\n\n\t\t\t// The character right before the caret must be a plain space.\n\t\t\tif ( characterBefore !== ' ' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst trimmedTextBefore = text.slice( 0, start ).trim();\n\t\t\tconst prefixTransforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t( { type } ) => type === 'prefix'\n\t\t\t);\n\t\t\tconst transformation = findTransform(\n\t\t\t\tprefixTransforms,\n\t\t\t\t( { prefix } ) => {\n\t\t\t\t\treturn trimmedTextBefore === prefix;\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( ! transformation ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst content = valueToFormat( slice( value, start, text.length ) );\n\t\t\tconst block = transformation.transform( content );\n\n\t\t\tonReplace( [ block ] );\n\t\t\t__unstableMarkAutomaticChange();\n\t\t},\n\t\t[ onReplace, __unstableMarkAutomaticChange ]\n\t);\n\n\tconst mergedRef = useMergeRefs( [ forwardedRef, fallbackRef ] );\n\n\tconst content = (\n\t\t<RichText\n\t\t\tclientId={ clientId }\n\t\t\tidentifier={ identifier }\n\t\t\tref={ mergedRef }\n\t\t\tvalue={ adjustedValue }\n\t\t\tonChange={ adjustedOnChange }\n\t\t\tselectionStart={ selectionStart }\n\t\t\tselectionEnd={ selectionEnd }\n\t\t\tonSelectionChange={ onSelectionChange }\n\t\t\ttagName={ tagName }\n\t\t\tplaceholder={ placeholder }\n\t\t\tallowedFormats={ adjustedAllowedFormats }\n\t\t\twithoutInteractiveFormatting={ withoutInteractiveFormatting }\n\t\t\tonEnter={ onEnter }\n\t\t\tonDelete={ onDelete }\n\t\t\tonPaste={ onPaste }\n\t\t\t__unstableIsSelected={ isSelected }\n\t\t\t__unstableInputRule={ inputRule }\n\t\t\t__unstableMultilineTag={ multilineTag }\n\t\t\t__unstableIsCaretWithinFormattedText={ isCaretWithinFormattedText }\n\t\t\t__unstableOnEnterFormattedText={ enterFormattedText }\n\t\t\t__unstableOnExitFormattedText={ exitFormattedText }\n\t\t\t__unstableOnCreateUndoLevel={ __unstableMarkLastChangeAsPersistent }\n\t\t\t__unstableMarkAutomaticChange={ __unstableMarkAutomaticChange }\n\t\t\t__unstableDidAutomaticChange={ didAutomaticChange }\n\t\t\t__unstableUndo={ undo }\n\t\t\t__unstableDisableFormats={ disableFormats }\n\t\t\tpreserveWhiteSpace={ preserveWhiteSpace }\n\t\t\tdisabled={ disabled }\n\t\t\tunstableOnFocus={ unstableOnFocus }\n\t\t\t__unstableAllowPrefixTransformations={\n\t\t\t\t__unstableAllowPrefixTransformations\n\t\t\t}\n\t\t\t__unstableMultilineRootTag={ __unstableMultilineRootTag }\n\t\t\t// Native props.\n\t\t\t{ ...nativeProps }\n\t\t\tblockIsSelected={\n\t\t\t\toriginalIsSelected !== undefined\n\t\t\t\t\t? originalIsSelected\n\t\t\t\t\t: blockIsSelected\n\t\t\t}\n\t\t\tshouldBlurOnUnmount={ shouldBlurOnUnmount }\n\t\t\t__unstableMobileNoFocusOnMount={ __unstableMobileNoFocusOnMount }\n\t\t\tdeleteEnter={ deleteEnter }\n\t\t\tplaceholderTextColor={ placeholderTextColor }\n\t\t\ttextAlign={ textAlign }\n\t\t\tselectionColor={ selectionColor }\n\t\t\ttagsToEliminate={ tagsToEliminate }\n\t\t\trootTagsToEliminate={ rootTagsToEliminate }\n\t\t\tdisableEditingMenu={ disableEditingMenu }\n\t\t\tfontSize={ fontSize }\n\t\t\tfontFamily={ fontFamily }\n\t\t\tfontWeight={ fontWeight }\n\t\t\tfontStyle={ fontStyle }\n\t\t\tminWidth={ minWidth }\n\t\t\tmaxWidth={ maxWidth }\n\t\t\tonBlur={ onBlur }\n\t\t\tsetRef={ setRef }\n\t\t\t// Props to be set on the editable container are destructured on the\n\t\t\t// element itself for web (see below), but passed through rich text\n\t\t\t// for native.\n\t\t\tid={ props.id }\n\t\t\tstyle={ props.style }\n\t\t>\n\t\t\t{ ( {\n\t\t\t\tisSelected: nestedIsSelected,\n\t\t\t\tvalue,\n\t\t\t\tonChange,\n\t\t\t\tonFocus,\n\t\t\t\teditableProps,\n\t\t\t\teditableTagName: TagName,\n\t\t\t} ) => (\n\t\t\t\t<>\n\t\t\t\t\t{ children && children( { value, onChange, onFocus } ) }\n\t\t\t\t\t{ nestedIsSelected && hasFormats && (\n\t\t\t\t\t\t<FormatToolbarContainer\n\t\t\t\t\t\t\tinline={ inlineToolbar }\n\t\t\t\t\t\t\tanchorRef={ fallbackRef.current }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ nestedIsSelected && <RemoveBrowserShortcuts /> }\n\t\t\t\t\t<Autocomplete\n\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\tcompleters={ autocompleters }\n\t\t\t\t\t\trecord={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tisSelected={ nestedIsSelected }\n\t\t\t\t\t\tcontentRef={ fallbackRef }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( { listBoxId, activeId, onKeyDown } ) => (\n\t\t\t\t\t\t\t<TagName\n\t\t\t\t\t\t\t\t{ ...editableProps }\n\t\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\tprops.style\n\t\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t\t...props.style,\n\t\t\t\t\t\t\t\t\t\t\t\t...editableProps.style,\n\t\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t\t: editableProps.style\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\tclasses,\n\t\t\t\t\t\t\t\t\tprops.className,\n\t\t\t\t\t\t\t\t\teditableProps.className\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\taria-autocomplete={\n\t\t\t\t\t\t\t\t\tlistBoxId ? 'list' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\taria-owns={ listBoxId }\n\t\t\t\t\t\t\t\taria-activedescendant={ activeId }\n\t\t\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\t\t\tonKeyDown( event );\n\t\t\t\t\t\t\t\t\teditableProps.onKeyDown( event );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Autocomplete>\n\t\t\t\t\t<EmbedHandlerPicker ref={ embedHandlerPickerRef } />\n\t\t\t\t</>\n\t\t\t) }\n\t\t</RichText>\n\t);\n\n\tif ( ! wrapperClassName ) {\n\t\treturn content;\n\t}\n\n\tdeprecated( 'wp.blockEditor.RichText wrapperClassName prop', {\n\t\tsince: '5.4',\n\t\talternative: 'className prop or create your own wrapper div',\n\t\tversion: '6.2',\n\t} );\n\n\treturn (\n\t\t<div className={ classnames( wrapperClasses, wrapperClassName ) }>\n\t\t\t{ content }\n\t\t</div>\n\t);\n}\n\nconst ForwardedRichTextContainer = forwardRef( RichTextWrapper );\n\nForwardedRichTextContainer.Content = ( {\n\tvalue,\n\ttagName: Tag,\n\tmultiline,\n\t...props\n} ) => {\n\t// Handle deprecated `children` and `node` sources.\n\tif ( Array.isArray( value ) ) {\n\t\tvalue = childrenSource.toHTML( value );\n\t}\n\n\tconst MultilineTag = getMultilineTag( multiline );\n\n\tif ( ! value && MultilineTag ) {\n\t\tvalue = `<${ MultilineTag }></${ MultilineTag }>`;\n\t}\n\n\tconst content = <RawHTML>{ value }</RawHTML>;\n\n\tif ( Tag ) {\n\t\treturn <Tag { ...omit( props, [ 'format' ] ) }>{ content }</Tag>;\n\t}\n\n\treturn content;\n};\n\nForwardedRichTextContainer.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\nForwardedRichTextContainer.Content.defaultProps = {\n\tformat: 'string',\n\tvalue: '',\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"]}
|
|
@@ -39,6 +39,8 @@ export function usePasteHandler(props) {
|
|
|
39
39
|
propsRef.current = props;
|
|
40
40
|
return useRefEffect(element => {
|
|
41
41
|
function _onPaste(event) {
|
|
42
|
+
var _html;
|
|
43
|
+
|
|
42
44
|
const {
|
|
43
45
|
isSelected,
|
|
44
46
|
disableFormats,
|
|
@@ -141,11 +143,18 @@ export function usePasteHandler(props) {
|
|
|
141
143
|
text: plainText
|
|
142
144
|
})));
|
|
143
145
|
return;
|
|
144
|
-
} //
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
} // Process any attached files, unless we detect Microsoft Office as
|
|
147
|
+
// the source.
|
|
148
|
+
//
|
|
149
|
+
// When content is copied from Microsoft Office, an image of the
|
|
150
|
+
// content is rendered and attached to the clipboard along with the
|
|
151
|
+
// plain-text and HTML content. This artifact is a distraction from
|
|
152
|
+
// the relevant clipboard data, so we ignore it.
|
|
153
|
+
//
|
|
154
|
+
// Props https://github.com/pubpub/pubpub/commit/2f933277a15a263a1ab4bbd36b96d3a106544aec
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
if (files && files.length && !((_html = html) !== null && _html !== void 0 && _html.includes('xmlns:o="urn:schemas-microsoft-com:office:office'))) {
|
|
149
158
|
const content = pasteHandler({
|
|
150
159
|
HTML: filePasteHandler(files),
|
|
151
160
|
mode: 'BLOCKS',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-paste-handler.js"],"names":["useRef","useRefEffect","getFilesFromDataTransfer","pasteHandler","isEmpty","insert","create","replace","__UNSTABLE_LINE_SEPARATOR","LINE_SEPARATOR","isURL","filePasteHandler","addActiveFormats","isShortcode","splitValue","adjustLines","value","isMultiline","RegExp","usePasteHandler","props","propsRef","current","element","_onPaste","event","isSelected","disableFormats","onChange","formatTypes","tagName","onReplace","onSplit","onSplitMiddle","__unstableEmbedURLOnPaste","multilineTag","preserveWhiteSpace","pastePlainText","preventDefault","clipboardData","plainText","html","getData","error1","error2","removeWindowsFragments","removeCharsetMetaTag","window","console","log","transformed","reduce","accumlator","__unstablePasteRule","files","isInternal","pastedMultilineTag","undefined","pastedValue","multilineWrapperTags","activeFormats","text","length","content","HTML","mode","pastedBlocks","trim","valueToInsert","addEventListener","removeEventListener","startReg","endReg","metaTag","startsWith","slice"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,oBAAvB;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,wBAAT,QAAyC,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BAAT,CAA+BL,IAA/B,EAAsC;AACrC,QAAMgC,OAAO,GAAI,wBAAjB;;AAEA,MAAKhC,IAAI,CAACiC,UAAL,CAAiBD,OAAjB,CAAL,EAAkC;AACjC,WAAOhC,IAAI,CAACkC,KAAL,CAAYF,OAAO,CAACX,MAApB,CAAP;AACA;;AAED,SAAOrB,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\nimport { pasteHandler } from '@wordpress/blocks';\nimport {\n\tisEmpty,\n\tinsert,\n\tcreate,\n\treplace,\n\t__UNSTABLE_LINE_SEPARATOR as LINE_SEPARATOR,\n} from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { filePasteHandler } from './file-paste-handler';\nimport { addActiveFormats, isShortcode } from './utils';\nimport { splitValue } from './split-value';\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\n/**\n * Replaces line separators with line breaks if not multiline.\n * Replaces line breaks with line separators if multiline.\n *\n * @param {RichTextValue} value Value to adjust.\n * @param {boolean} isMultiline Whether to adjust to multiline or not.\n *\n * @return {RichTextValue} Adjusted value.\n */\nfunction adjustLines( value, isMultiline ) {\n\tif ( isMultiline ) {\n\t\treturn replace( value, /\\n+/g, LINE_SEPARATOR );\n\t}\n\n\treturn replace( value, new RegExp( LINE_SEPARATOR, 'g' ), '\\n' );\n}\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\tonSplitMiddle,\n\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\tmultilineTag,\n\t\t\t\tpreserveWhiteSpace,\n\t\t\t\tpastePlainText,\n\t\t\t} = propsRef.current;\n\n\t\t\tif ( ! isSelected ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { clipboardData } = event;\n\n\t\t\tlet plainText = '';\n\t\t\tlet html = '';\n\n\t\t\t// IE11 only supports `Text` as an argument for `getData` and will\n\t\t\t// otherwise throw an invalid argument error, so we try the standard\n\t\t\t// arguments first, then fallback to `Text` if they fail.\n\t\t\ttry {\n\t\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t\t} catch ( error1 ) {\n\t\t\t\ttry {\n\t\t\t\t\thtml = clipboardData.getData( 'Text' );\n\t\t\t\t} catch ( error2 ) {\n\t\t\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t\t\t// behaviour.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remove Windows-specific metadata appended within copied HTML text.\n\t\t\thtml = removeWindowsFragments( html );\n\n\t\t\t// Strip meta tag.\n\t\t\thtml = removeCharsetMetaTag( html );\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 transformed = formatTypes.reduce(\n\t\t\t\t( accumlator, { __unstablePasteRule } ) => {\n\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\tif ( __unstablePasteRule && accumlator === value ) {\n\t\t\t\t\t\taccumlator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumlator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\n\t\t\tif ( transformed !== value ) {\n\t\t\t\tonChange( transformed );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst files = [ ...getFilesFromDataTransfer( clipboardData ) ];\n\t\t\tconst isInternal = 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 pastedMultilineTag =\n\t\t\t\t\tclipboardData.getData( 'rich-text-multi-line-tag' ) ||\n\t\t\t\t\tundefined;\n\t\t\t\tlet pastedValue = create( {\n\t\t\t\t\thtml,\n\t\t\t\t\tmultilineTag: pastedMultilineTag,\n\t\t\t\t\tmultilineWrapperTags:\n\t\t\t\t\t\tpastedMultilineTag === 'li'\n\t\t\t\t\t\t\t? [ 'ul', 'ol' ]\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t} );\n\t\t\t\tpastedValue = adjustLines( pastedValue, !! multilineTag );\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\t// Only process file if no HTML is present.\n\t\t\t// Note: a pasted file may have the URL as plain text.\n\t\t\tif ( files && files.length && ! html ) {\n\t\t\t\tconst content = pasteHandler( {\n\t\t\t\t\tHTML: filePasteHandler( files ),\n\t\t\t\t\tmode: 'BLOCKS',\n\t\t\t\t\ttagName,\n\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t} );\n\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\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tonReplace( content );\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\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\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\t// Force the blocks mode when the user is pasting\n\t\t\t// on a new line & the content resembles a shortcode.\n\t\t\t// Otherwise it's going to be detected as inline\n\t\t\t// and the shortcode won't be replaced.\n\t\t\tif (\n\t\t\t\tmode === 'AUTO' &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisShortcode( plainText )\n\t\t\t) {\n\t\t\t\tmode = 'BLOCKS';\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisURL( plainText.trim() )\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\tpreserveWhiteSpace,\n\t\t\t} );\n\n\t\t\tif ( typeof content === 'string' ) {\n\t\t\t\tlet valueToInsert = create( { html: content } );\n\n\t\t\t\t// If the content should be multiline, we should process text\n\t\t\t\t// separated by a line break as separate lines.\n\t\t\t\tvalueToInsert = adjustLines( valueToInsert, !! multilineTag );\n\n\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\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\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\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\n/**\n * Normalizes a given string of HTML to remove the Windows specific \"Fragment\" comments\n * and any preceeding and trailing whitespace.\n *\n * @param {string} html the html to be normalized\n * @return {string} the normalized html\n */\nfunction removeWindowsFragments( html ) {\n\tconst startReg = /.*<!--StartFragment-->/s;\n\tconst endReg = /<!--EndFragment-->.*/s;\n\n\treturn html.replace( startReg, '' ).replace( endReg, '' );\n}\n\n/**\n * Removes the charset meta tag inserted by Chromium.\n * See:\n * - https://github.com/WordPress/gutenberg/issues/33585\n * - https://bugs.chromium.org/p/chromium/issues/detail?id=1264616#c4\n *\n * @param {string} html the html to be stripped of the meta tag.\n * @return {string} the cleaned html\n */\nfunction removeCharsetMetaTag( html ) {\n\tconst metaTag = `<meta charset='utf-8'>`;\n\n\tif ( html.startsWith( metaTag ) ) {\n\t\treturn html.slice( metaTag.length );\n\t}\n\n\treturn html;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-paste-handler.js"],"names":["useRef","useRefEffect","getFilesFromDataTransfer","pasteHandler","isEmpty","insert","create","replace","__UNSTABLE_LINE_SEPARATOR","LINE_SEPARATOR","isURL","filePasteHandler","addActiveFormats","isShortcode","splitValue","adjustLines","value","isMultiline","RegExp","usePasteHandler","props","propsRef","current","element","_onPaste","event","isSelected","disableFormats","onChange","formatTypes","tagName","onReplace","onSplit","onSplitMiddle","__unstableEmbedURLOnPaste","multilineTag","preserveWhiteSpace","pastePlainText","preventDefault","clipboardData","plainText","html","getData","error1","error2","removeWindowsFragments","removeCharsetMetaTag","window","console","log","transformed","reduce","accumlator","__unstablePasteRule","files","isInternal","pastedMultilineTag","undefined","pastedValue","multilineWrapperTags","activeFormats","text","length","includes","content","HTML","mode","pastedBlocks","trim","valueToInsert","addEventListener","removeEventListener","startReg","endReg","metaTag","startsWith","slice"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,oBAAvB;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,wBAAT,QAAyC,gBAAzC;AACA,SAASC,YAAT,QAA6B,mBAA7B;AACA,SACCC,OADD,EAECC,MAFD,EAGCC,MAHD,EAICC,OAJD,EAKCC,yBAAyB,IAAIC,cAL9B,QAMO,sBANP;AAOA,SAASC,KAAT,QAAsB,gBAAtB;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AACA,SAASC,gBAAT,EAA2BC,WAA3B,QAA8C,SAA9C;AACA,SAASC,UAAT,QAA2B,eAA3B;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,CAAsBC,KAAtB,EAA6BC,WAA7B,EAA2C;AAC1C,MAAKA,WAAL,EAAmB;AAClB,WAAOV,OAAO,CAAES,KAAF,EAAS,MAAT,EAAiBP,cAAjB,CAAd;AACA;;AAED,SAAOF,OAAO,CAAES,KAAF,EAAS,IAAIE,MAAJ,CAAYT,cAAZ,EAA4B,GAA5B,CAAT,EAA4C,IAA5C,CAAd;AACA;;AAED,OAAO,SAASU,eAAT,CAA0BC,KAA1B,EAAkC;AACxC,QAAMC,QAAQ,GAAGrB,MAAM,CAAEoB,KAAF,CAAvB;AACAC,EAAAA,QAAQ,CAACC,OAAT,GAAmBF,KAAnB;AACA,SAAOnB,YAAY,CAAIsB,OAAF,IAAe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0B,OAA1B,EAAmC9C,QAAnC;AACA,WAAO,MAAM;AACZD,MAAAA,OAAO,CAACgD,mBAAR,CAA6B,OAA7B,EAAsC/C,QAAtC;AACA,KAFD;AAGA,GAtNkB,EAsNhB,EAtNgB,CAAnB;AAuNA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASqB,sBAAT,CAAiCJ,IAAjC,EAAwC;AACvC,QAAM+B,QAAQ,GAAG,yBAAjB;AACA,QAAMC,MAAM,GAAG,uBAAf;AAEA,SAAOhC,IAAI,CAAClC,OAAL,CAAciE,QAAd,EAAwB,EAAxB,EAA6BjE,OAA7B,CAAsCkE,MAAtC,EAA8C,EAA9C,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAAS3B,oBAAT,CAA+BL,IAA/B,EAAsC;AACrC,QAAMiC,OAAO,GAAI,wBAAjB;;AAEA,MAAKjC,IAAI,CAACkC,UAAL,CAAiBD,OAAjB,CAAL,EAAkC;AACjC,WAAOjC,IAAI,CAACmC,KAAL,CAAYF,OAAO,CAACZ,MAApB,CAAP;AACA;;AAED,SAAOrB,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\nimport { pasteHandler } from '@wordpress/blocks';\nimport {\n\tisEmpty,\n\tinsert,\n\tcreate,\n\treplace,\n\t__UNSTABLE_LINE_SEPARATOR as LINE_SEPARATOR,\n} from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { filePasteHandler } from './file-paste-handler';\nimport { addActiveFormats, isShortcode } from './utils';\nimport { splitValue } from './split-value';\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\n/**\n * Replaces line separators with line breaks if not multiline.\n * Replaces line breaks with line separators if multiline.\n *\n * @param {RichTextValue} value Value to adjust.\n * @param {boolean} isMultiline Whether to adjust to multiline or not.\n *\n * @return {RichTextValue} Adjusted value.\n */\nfunction adjustLines( value, isMultiline ) {\n\tif ( isMultiline ) {\n\t\treturn replace( value, /\\n+/g, LINE_SEPARATOR );\n\t}\n\n\treturn replace( value, new RegExp( LINE_SEPARATOR, 'g' ), '\\n' );\n}\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\tonSplitMiddle,\n\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\tmultilineTag,\n\t\t\t\tpreserveWhiteSpace,\n\t\t\t\tpastePlainText,\n\t\t\t} = propsRef.current;\n\n\t\t\tif ( ! isSelected ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { clipboardData } = event;\n\n\t\t\tlet plainText = '';\n\t\t\tlet html = '';\n\n\t\t\t// IE11 only supports `Text` as an argument for `getData` and will\n\t\t\t// otherwise throw an invalid argument error, so we try the standard\n\t\t\t// arguments first, then fallback to `Text` if they fail.\n\t\t\ttry {\n\t\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t\t} catch ( error1 ) {\n\t\t\t\ttry {\n\t\t\t\t\thtml = clipboardData.getData( 'Text' );\n\t\t\t\t} catch ( error2 ) {\n\t\t\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t\t\t// behaviour.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remove Windows-specific metadata appended within copied HTML text.\n\t\t\thtml = removeWindowsFragments( html );\n\n\t\t\t// Strip meta tag.\n\t\t\thtml = removeCharsetMetaTag( html );\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 transformed = formatTypes.reduce(\n\t\t\t\t( accumlator, { __unstablePasteRule } ) => {\n\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\tif ( __unstablePasteRule && accumlator === value ) {\n\t\t\t\t\t\taccumlator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumlator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\n\t\t\tif ( transformed !== value ) {\n\t\t\t\tonChange( transformed );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst files = [ ...getFilesFromDataTransfer( clipboardData ) ];\n\t\t\tconst isInternal = 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 pastedMultilineTag =\n\t\t\t\t\tclipboardData.getData( 'rich-text-multi-line-tag' ) ||\n\t\t\t\t\tundefined;\n\t\t\t\tlet pastedValue = create( {\n\t\t\t\t\thtml,\n\t\t\t\t\tmultilineTag: pastedMultilineTag,\n\t\t\t\t\tmultilineWrapperTags:\n\t\t\t\t\t\tpastedMultilineTag === 'li'\n\t\t\t\t\t\t\t? [ 'ul', 'ol' ]\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t} );\n\t\t\t\tpastedValue = adjustLines( pastedValue, !! multilineTag );\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\t// Process any attached files, unless we detect Microsoft Office as\n\t\t\t// the source.\n\t\t\t//\n\t\t\t// When content is copied from Microsoft Office, an image of the\n\t\t\t// content is rendered and attached to the clipboard along with the\n\t\t\t// plain-text and HTML content. This artifact is a distraction from\n\t\t\t// the relevant clipboard data, so we ignore it.\n\t\t\t//\n\t\t\t// Props https://github.com/pubpub/pubpub/commit/2f933277a15a263a1ab4bbd36b96d3a106544aec\n\t\t\tif (\n\t\t\t\tfiles &&\n\t\t\t\tfiles.length &&\n\t\t\t\t! html?.includes(\n\t\t\t\t\t'xmlns:o=\"urn:schemas-microsoft-com:office:office'\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tconst content = pasteHandler( {\n\t\t\t\t\tHTML: filePasteHandler( files ),\n\t\t\t\t\tmode: 'BLOCKS',\n\t\t\t\t\ttagName,\n\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t} );\n\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\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\t\tonReplace( content );\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\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\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\t// Force the blocks mode when the user is pasting\n\t\t\t// on a new line & the content resembles a shortcode.\n\t\t\t// Otherwise it's going to be detected as inline\n\t\t\t// and the shortcode won't be replaced.\n\t\t\tif (\n\t\t\t\tmode === 'AUTO' &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisShortcode( plainText )\n\t\t\t) {\n\t\t\t\tmode = 'BLOCKS';\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\t\tisEmpty( value ) &&\n\t\t\t\tisURL( plainText.trim() )\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\tpreserveWhiteSpace,\n\t\t\t} );\n\n\t\t\tif ( typeof content === 'string' ) {\n\t\t\t\tlet valueToInsert = create( { html: content } );\n\n\t\t\t\t// If the content should be multiline, we should process text\n\t\t\t\t// separated by a line break as separate lines.\n\t\t\t\tvalueToInsert = adjustLines( valueToInsert, !! multilineTag );\n\n\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\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\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\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\n/**\n * Normalizes a given string of HTML to remove the Windows specific \"Fragment\" comments\n * and any preceeding and trailing whitespace.\n *\n * @param {string} html the html to be normalized\n * @return {string} the normalized html\n */\nfunction removeWindowsFragments( html ) {\n\tconst startReg = /.*<!--StartFragment-->/s;\n\tconst endReg = /<!--EndFragment-->.*/s;\n\n\treturn html.replace( startReg, '' ).replace( endReg, '' );\n}\n\n/**\n * Removes the charset meta tag inserted by Chromium.\n * See:\n * - https://github.com/WordPress/gutenberg/issues/33585\n * - https://bugs.chromium.org/p/chromium/issues/detail?id=1264616#c4\n *\n * @param {string} html the html to be stripped of the meta tag.\n * @return {string} the cleaned html\n */\nfunction removeCharsetMetaTag( html ) {\n\tconst metaTag = `<meta charset='utf-8'>`;\n\n\tif ( html.startsWith( metaTag ) ) {\n\t\treturn html.slice( metaTag.length );\n\t}\n\n\treturn html;\n}\n"]}
|
|
@@ -52,7 +52,8 @@ export function getAllowedFormats(_ref) {
|
|
|
52
52
|
|
|
53
53
|
deprecated('wp.blockEditor.RichText formattingControls prop', {
|
|
54
54
|
since: '5.4',
|
|
55
|
-
alternative: 'allowedFormats'
|
|
55
|
+
alternative: 'allowedFormats',
|
|
56
|
+
version: '6.2'
|
|
56
57
|
});
|
|
57
58
|
return formattingControls.map(name => `core/${name}`);
|
|
58
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/utils.js"],"names":["regexp","deprecated","renderToString","createBlock","addActiveFormats","value","activeFormats","length","index","formats","getMultilineTag","multiline","getAllowedFormats","allowedFormats","formattingControls","disableFormats","EMPTY_ARRAY","since","alternative","map","name","isShortcode","text","test","createLinkInParagraph","url","onReplace","link","content"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,sBAAvB;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,cAAT,QAA+B,oBAA/B;AACA,SAASC,WAAT,QAA4B,mBAA5B;AAEA,OAAO,SAASC,gBAAT,CAA2BC,KAA3B,EAAkCC,aAAlC,EAAkD;AACxD,MAAKA,aAAL,aAAKA,aAAL,eAAKA,aAAa,CAAEC,MAApB,EAA6B;AAC5B,QAAIC,KAAK,GAAGH,KAAK,CAACI,OAAN,CAAcF,MAA1B;;AAEA,WAAQC,KAAK,EAAb,EAAkB;AACjBH,MAAAA,KAAK,CAACI,OAAN,CAAeD,KAAf,IAAyB,CACxB,GAAGF,aADqB,EAExB,IAAKD,KAAK,CAACI,OAAN,CAAeD,KAAf,KAA0B,EAA/B,CAFwB,CAAzB;AAIA;AACD;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,eAAT,CAA0BC,SAA1B,EAAsC;AAC5C,MAAKA,SAAS,KAAK,IAAd,IAAsBA,SAAS,KAAK,GAApC,IAA2CA,SAAS,KAAK,IAA9D,EAAqE;AACpE;AACA;;AAED,SAAOA,SAAS,KAAK,IAAd,GAAqB,GAArB,GAA2BA,SAAlC;AACA;AAED,OAAO,SAASC,iBAAT,OAIH;AAAA,MAJ+B;AAClCC,IAAAA,cADkC;AAElCC,IAAAA,kBAFkC;AAGlCC,IAAAA;AAHkC,GAI/B;;AACH,MAAKA,cAAL,EAAsB;AACrB,WAAOH,iBAAiB,CAACI,WAAzB;AACA;;AAED,MAAK,CAAEH,cAAF,IAAoB,CAAEC,kBAA3B,EAAgD;AAC/C;AACA;;AAED,MAAKD,cAAL,EAAsB;AACrB,WAAOA,cAAP;AACA;;AAEDZ,EAAAA,UAAU,CAAE,iDAAF,EAAqD;AAC9DgB,IAAAA,KAAK,EAAE,KADuD;AAE9DC,IAAAA,WAAW,EAAE;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/utils.js"],"names":["regexp","deprecated","renderToString","createBlock","addActiveFormats","value","activeFormats","length","index","formats","getMultilineTag","multiline","getAllowedFormats","allowedFormats","formattingControls","disableFormats","EMPTY_ARRAY","since","alternative","version","map","name","isShortcode","text","test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D;AAG9DC,IAAAA,OAAO,EAAE;AAHqD,GAArD,CAAV;AAMA,SAAOL,kBAAkB,CAACM,GAAnB,CAA0BC,IAAF,IAAa,QAAQA,IAAM,EAAnD,CAAP;AACA;AAEDT,iBAAiB,CAACI,WAAlB,GAAgC,EAAhC;AAEA,OAAO,MAAMM,WAAW,GAAKC,IAAF,IAAYvB,MAAM,CAAE,IAAF,CAAN,CAAewB,IAAf,CAAqBD,IAArB,CAAhC;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,qBAAT,CAAgCC,GAAhC,EAAqCC,SAArC,EAAiD;AACvD,QAAMC,IAAI,GAAG;AAAG,IAAA,IAAI,EAAGF;AAAV,KAAkBA,GAAlB,CAAb;AACAC,EAAAA,SAAS,CACRxB,WAAW,CAAE,gBAAF,EAAoB;AAAE0B,IAAAA,OAAO,EAAE3B,cAAc,CAAE0B,IAAF;AAAzB,GAApB,CADH,CAAT;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { regexp } from '@wordpress/shortcode';\nimport deprecated from '@wordpress/deprecated';\nimport { renderToString } from '@wordpress/element';\nimport { createBlock } from '@wordpress/blocks';\n\nexport function addActiveFormats( value, activeFormats ) {\n\tif ( activeFormats?.length ) {\n\t\tlet index = value.formats.length;\n\n\t\twhile ( index-- ) {\n\t\t\tvalue.formats[ index ] = [\n\t\t\t\t...activeFormats,\n\t\t\t\t...( value.formats[ index ] || [] ),\n\t\t\t];\n\t\t}\n\t}\n}\n\n/**\n * Get the multiline tag based on the multiline prop.\n *\n * @param {?(string|boolean)} multiline The multiline prop.\n *\n * @return {?string} The multiline tag.\n */\nexport function getMultilineTag( multiline ) {\n\tif ( multiline !== true && multiline !== 'p' && multiline !== 'li' ) {\n\t\treturn;\n\t}\n\n\treturn multiline === true ? 'p' : multiline;\n}\n\nexport function getAllowedFormats( {\n\tallowedFormats,\n\tformattingControls,\n\tdisableFormats,\n} ) {\n\tif ( disableFormats ) {\n\t\treturn getAllowedFormats.EMPTY_ARRAY;\n\t}\n\n\tif ( ! allowedFormats && ! formattingControls ) {\n\t\treturn;\n\t}\n\n\tif ( allowedFormats ) {\n\t\treturn allowedFormats;\n\t}\n\n\tdeprecated( 'wp.blockEditor.RichText formattingControls prop', {\n\t\tsince: '5.4',\n\t\talternative: 'allowedFormats',\n\t\tversion: '6.2',\n\t} );\n\n\treturn formattingControls.map( ( name ) => `core/${ name }` );\n}\n\ngetAllowedFormats.EMPTY_ARRAY = [];\n\nexport const isShortcode = ( text ) => regexp( '.*' ).test( text );\n\n/**\n * Creates a link from pasted URL.\n * Creates a paragraph block containing a link to the URL, and calls `onReplace`.\n *\n * @param {string} url The URL that could not be embedded.\n * @param {Function} onReplace Function to call with the created fallback block.\n */\nexport function createLinkInParagraph( url, onReplace ) {\n\tconst link = <a href={ url }>{ url }</a>;\n\tonReplace(\n\t\tcreateBlock( 'core/paragraph', { content: renderToString( link ) } )\n\t);\n}\n"]}
|
|
@@ -59,7 +59,7 @@ export function BorderColorEdit(props) {
|
|
|
59
59
|
return (_getColorObjectByAttr = getColorObjectByAttributeValues(availableColors, borderColor, customBorderColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color;
|
|
60
60
|
}); // Detect changes in the color attributes and update the colorValue to keep the
|
|
61
61
|
// UI in sync. This is necessary for situations when border controls interact with
|
|
62
|
-
//
|
|
62
|
+
// each other: eg, setting the border width to zero causes the color and style
|
|
63
63
|
// selections to be cleared.
|
|
64
64
|
|
|
65
65
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/border-color.js"],"names":["classnames","addFilter","__","createHigherOrderComponent","useEffect","useState","ColorGradientSettingsDropdown","useMultipleOriginColorsAndGradients","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","useSetting","hasBorderSupport","removeBorderAttribute","shouldSkipSerialization","cleanEmptyObject","EMPTY_ARRAY","BorderColorEdit","props","attributes","borderColor","style","setAttributes","colorGradientSettings","availableColors","colors","reduce","origin","concat","color","customBorderColor","border","colorValue","setColorValue","onChangeColor","value","colorObject","newStyle","slug","undefined","newNamedColor","settings","label","onColorChange","clearable","hasBorderColorValue","resetBorderColor","addAttributes","type","addSaveProps","blockType","borderColorClass","newClassName","className","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","name","extraStyles","wrapperProps"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,oBAApC;AAEA;AACA;AACA;;AACA,OAAOC,6BAAP,MAA0C,yCAA1C;AACA,OAAOC,mCAAP,MAAgD,yEAAhD;AACA,SACCC,iBADD,EAECC,0BAFD,EAGCC,+BAHD,QAIO,sBAJP;AAKA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SACCC,gBADD,EAECC,qBAFD,EAGCC,uBAHD,QAIO,UAJP;AAKA,SAASC,gBAAT,QAAiC,SAAjC,C,CAEA;AACA;;AACA,MAAMC,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,eAAT,CAA0BC,KAA1B,EAAkC;AACxC,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,WAAF;AAAeC,MAAAA;AAAf,KADP;AAELC,IAAAA;AAFK,MAGFJ,KAHJ;AAIA,QAAMK,qBAAqB,GAAGhB,mCAAmC,EAAjE;AACA,QAAMiB,eAAe,GAAGD,qBAAqB,CAACE,MAAtB,CAA6BC,MAA7B,CACvB,CAAED,MAAF,EAAUE,MAAV,KAAsBF,MAAM,CAACG,MAAP,CAAeD,MAAM,CAACF,MAAtB,CADC,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AAEN,iCAAG1C,KAAK,CAAC2C,YAAT,wDAAG,oBAAoBxC,KAAvB;AAFM;AAFO,GAAf;AAQA,SAAO,cAAC,cAAD,eAAqBH,KAArB;AAA6B,IAAA,YAAY,EAAG2C;AAA5C,KAAP;AACA,CA7BoE,CAA/D;AAgCP5D,SAAS,CACR,0BADQ,EAER,2BAFQ,EAGR8C,aAHQ,CAAT;AAMA9C,SAAS,CACR,kCADQ,EAER,0BAFQ,EAGRgD,YAHQ,CAAT;AAMAhD,SAAS,CACR,0BADQ,EAER,0BAFQ,EAGRqD,YAHQ,CAAT;AAMArD,SAAS,CACR,uBADQ,EAER,8CAFQ,EAGRwD,4BAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ColorGradientSettingsDropdown from '../components/colors-gradients/dropdown';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport useSetting from '../components/use-setting';\nimport {\n\thasBorderSupport,\n\tremoveBorderAttribute,\n\tshouldSkipSerialization,\n} from './border';\nimport { cleanEmptyObject } from './utils';\n\n// Defining empty array here instead of inline avoids unnecessary re-renders of\n// color control.\nconst EMPTY_ARRAY = [];\n\n/**\n * Inspector control panel containing the border color related configuration.\n *\n * There is deliberate overlap between the colors and borders block supports\n * relating to border color. It can be argued the border color controls could\n * be included within either, or both, the colors and borders panels in the\n * inspector controls. If they share the same block attributes it should not\n * matter.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border color edit element.\n */\nexport function BorderColorEdit( props ) {\n\tconst {\n\t\tattributes: { borderColor, style },\n\t\tsetAttributes,\n\t} = props;\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\tconst availableColors = colorGradientSettings.colors.reduce(\n\t\t( colors, origin ) => colors.concat( origin.colors ),\n\t\t[]\n\t);\n\tconst { color: customBorderColor } = style?.border || {};\n\tconst [ colorValue, setColorValue ] = useState(\n\t\t() =>\n\t\t\tgetColorObjectByAttributeValues(\n\t\t\t\tavailableColors,\n\t\t\t\tborderColor,\n\t\t\t\tcustomBorderColor\n\t\t\t)?.color\n\t);\n\n\t// Detect changes in the color attributes and update the colorValue to keep the\n\t// UI in sync. This is necessary for situations when border controls interact with\n\t// eachother: eg, setting the border width to zero causes the color and style\n\t// selections to be cleared.\n\tuseEffect( () => {\n\t\tsetColorValue(\n\t\t\tgetColorObjectByAttributeValues(\n\t\t\t\tavailableColors,\n\t\t\t\tborderColor,\n\t\t\t\tcustomBorderColor\n\t\t\t)?.color\n\t\t);\n\t}, [ borderColor, customBorderColor, availableColors ] );\n\n\tconst onChangeColor = ( value ) => {\n\t\tsetColorValue( value );\n\n\t\tconst colorObject = getColorObjectByColorValue(\n\t\t\tavailableColors,\n\t\t\tvalue\n\t\t);\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tcolor: colorObject?.slug ? undefined : value,\n\t\t\t},\n\t\t};\n\n\t\t// If empty slug, ensure undefined to remove attribute.\n\t\tconst newNamedColor = colorObject?.slug ? colorObject.slug : undefined;\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\tborderColor: newNamedColor,\n\t\t} );\n\t};\n\n\tconst settings = [\n\t\t{\n\t\t\tlabel: __( 'Color' ),\n\t\t\tonColorChange: onChangeColor,\n\t\t\tcolorValue,\n\t\t\tclearable: false,\n\t\t},\n\t];\n\treturn (\n\t\t<ColorGradientSettingsDropdown\n\t\t\tsettings={ settings }\n\t\t\tdisableCustomColors\n\t\t\tdisableCustomGradients\n\t\t\t__experimentalHasMultipleOrigins\n\t\t\t__experimentalIsRenderedInSidebar\n\t\t\tenableAlpha\n\t\t\t{ ...colorGradientSettings }\n\t\t/>\n\t);\n}\n\n/**\n * Checks if there is a current value in the border color block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a border color value set.\n */\nexport function hasBorderColorValue( props ) {\n\tconst {\n\t\tattributes: { borderColor, style },\n\t} = props;\n\n\treturn !! borderColor || !! style?.border?.color;\n}\n\n/**\n * Resets the border color block support attributes. This can be used when\n * disabling the border color support controls for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetBorderColor( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tborderColor: undefined,\n\t\tstyle: removeBorderAttribute( style, 'color' ),\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockType, 'color' ) ||\n\t\tshouldSkipSerialization( blockType )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\tconst newClassName = classnames( props.className, {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters the registered block settings to apply border color styles and\n * classnames to the block edit wrapper.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif (\n\t\t! hasBorderSupport( settings, 'color' ) ||\n\t\tshouldSkipSerialization( settings )\n\t) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBorderColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { borderColor } = attributes;\n\t\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\n\t\tif (\n\t\t\t! hasBorderSupport( name, 'color' ) ||\n\t\t\tshouldSkipSerialization( name )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst extraStyles = {\n\t\t\tborderColor: borderColor\n\t\t\t\t? getColorObjectByAttributeValues( colors, borderColor )?.color\n\t\t\t\t: undefined,\n\t\t};\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...extraStyles,\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/border/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/border/with-border-color-palette-styles',\n\twithBorderColorPaletteStyles\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/border-color.js"],"names":["classnames","addFilter","__","createHigherOrderComponent","useEffect","useState","ColorGradientSettingsDropdown","useMultipleOriginColorsAndGradients","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","useSetting","hasBorderSupport","removeBorderAttribute","shouldSkipSerialization","cleanEmptyObject","EMPTY_ARRAY","BorderColorEdit","props","attributes","borderColor","style","setAttributes","colorGradientSettings","availableColors","colors","reduce","origin","concat","color","customBorderColor","border","colorValue","setColorValue","onChangeColor","value","colorObject","newStyle","slug","undefined","newNamedColor","settings","label","onColorChange","clearable","hasBorderColorValue","resetBorderColor","addAttributes","type","addSaveProps","blockType","borderColorClass","newClassName","className","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","name","extraStyles","wrapperProps"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,oBAApC;AAEA;AACA;AACA;;AACA,OAAOC,6BAAP,MAA0C,y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BAA0B,CACnEuD,cAAF,IAAwBxC,KAAF,IAAa;AAAA;;AAClC,QAAM;AAAEyC,IAAAA,IAAF;AAAQxC,IAAAA;AAAR,MAAuBD,KAA7B;AACA,QAAM;AAAEE,IAAAA;AAAF,MAAkBD,UAAxB;AACA,QAAMM,MAAM,GAAGd,UAAU,CAAE,eAAF,CAAV,IAAiCK,WAAhD;;AAEA,MACC,CAAEJ,gBAAgB,CAAE+C,IAAF,EAAQ,OAAR,CAAlB,IACA7C,uBAAuB,CAAE6C,IAAF,CAFxB,EAGE;AACD,WAAO,cAAC,cAAD,EAAqBzC,KAArB,CAAP;AACA;;AAED,QAAM0C,WAAW,GAAG;AACnBxC,IAAAA,WAAW,EAAEA,WAAW,6BACrBV,+BAA+B,CAAEe,MAAF,EAAUL,WAAV,CADV,2DACrB,uBAAwDS,KADnC,GAErBU;AAHgB,GAApB;AAMA,MAAIsB,YAAY,GAAG3C,KAAK,CAAC2C,YAAzB;AACAA,EAAAA,YAAY,GAAG,EACd,GAAG3C,KAAK,CAAC2C,YADK;AAEdxC,IAAAA,KAAK,EAAE,EACN,GAAGuC,WADG;AAEN,iCAAG1C,KAAK,CAAC2C,YAAT,wDAAG,oBAAoBxC,KAAvB;AAFM;AAFO,GAAf;AAQA,SAAO,cAAC,cAAD,eAAqBH,KAArB;AAA6B,IAAA,YAAY,EAAG2C;AAA5C,KAAP;AACA,CA7BoE,CAA/D;AAgCP5D,SAAS,CACR,0BADQ,EAER,2BAFQ,EAGR8C,aAHQ,CAAT;AAMA9C,SAAS,CACR,kCADQ,EAER,0BAFQ,EAGRgD,YAHQ,CAAT;AAMAhD,SAAS,CACR,0BADQ,EAER,0BAFQ,EAGRqD,YAHQ,CAAT;AAMArD,SAAS,CACR,uBADQ,EAER,8CAFQ,EAGRwD,4BAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ColorGradientSettingsDropdown from '../components/colors-gradients/dropdown';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport useSetting from '../components/use-setting';\nimport {\n\thasBorderSupport,\n\tremoveBorderAttribute,\n\tshouldSkipSerialization,\n} from './border';\nimport { cleanEmptyObject } from './utils';\n\n// Defining empty array here instead of inline avoids unnecessary re-renders of\n// color control.\nconst EMPTY_ARRAY = [];\n\n/**\n * Inspector control panel containing the border color related configuration.\n *\n * There is deliberate overlap between the colors and borders block supports\n * relating to border color. It can be argued the border color controls could\n * be included within either, or both, the colors and borders panels in the\n * inspector controls. If they share the same block attributes it should not\n * matter.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border color edit element.\n */\nexport function BorderColorEdit( props ) {\n\tconst {\n\t\tattributes: { borderColor, style },\n\t\tsetAttributes,\n\t} = props;\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\tconst availableColors = colorGradientSettings.colors.reduce(\n\t\t( colors, origin ) => colors.concat( origin.colors ),\n\t\t[]\n\t);\n\tconst { color: customBorderColor } = style?.border || {};\n\tconst [ colorValue, setColorValue ] = useState(\n\t\t() =>\n\t\t\tgetColorObjectByAttributeValues(\n\t\t\t\tavailableColors,\n\t\t\t\tborderColor,\n\t\t\t\tcustomBorderColor\n\t\t\t)?.color\n\t);\n\n\t// Detect changes in the color attributes and update the colorValue to keep the\n\t// UI in sync. This is necessary for situations when border controls interact with\n\t// each other: eg, setting the border width to zero causes the color and style\n\t// selections to be cleared.\n\tuseEffect( () => {\n\t\tsetColorValue(\n\t\t\tgetColorObjectByAttributeValues(\n\t\t\t\tavailableColors,\n\t\t\t\tborderColor,\n\t\t\t\tcustomBorderColor\n\t\t\t)?.color\n\t\t);\n\t}, [ borderColor, customBorderColor, availableColors ] );\n\n\tconst onChangeColor = ( value ) => {\n\t\tsetColorValue( value );\n\n\t\tconst colorObject = getColorObjectByColorValue(\n\t\t\tavailableColors,\n\t\t\tvalue\n\t\t);\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tcolor: colorObject?.slug ? undefined : value,\n\t\t\t},\n\t\t};\n\n\t\t// If empty slug, ensure undefined to remove attribute.\n\t\tconst newNamedColor = colorObject?.slug ? colorObject.slug : undefined;\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\tborderColor: newNamedColor,\n\t\t} );\n\t};\n\n\tconst settings = [\n\t\t{\n\t\t\tlabel: __( 'Color' ),\n\t\t\tonColorChange: onChangeColor,\n\t\t\tcolorValue,\n\t\t\tclearable: false,\n\t\t},\n\t];\n\treturn (\n\t\t<ColorGradientSettingsDropdown\n\t\t\tsettings={ settings }\n\t\t\tdisableCustomColors\n\t\t\tdisableCustomGradients\n\t\t\t__experimentalHasMultipleOrigins\n\t\t\t__experimentalIsRenderedInSidebar\n\t\t\tenableAlpha\n\t\t\t{ ...colorGradientSettings }\n\t\t/>\n\t);\n}\n\n/**\n * Checks if there is a current value in the border color block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a border color value set.\n */\nexport function hasBorderColorValue( props ) {\n\tconst {\n\t\tattributes: { borderColor, style },\n\t} = props;\n\n\treturn !! borderColor || !! style?.border?.color;\n}\n\n/**\n * Resets the border color block support attributes. This can be used when\n * disabling the border color support controls for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetBorderColor( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tborderColor: undefined,\n\t\tstyle: removeBorderAttribute( style, 'color' ),\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockType, 'color' ) ||\n\t\tshouldSkipSerialization( blockType )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\tconst newClassName = classnames( props.className, {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters the registered block settings to apply border color styles and\n * classnames to the block edit wrapper.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif (\n\t\t! hasBorderSupport( settings, 'color' ) ||\n\t\tshouldSkipSerialization( settings )\n\t) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBorderColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { borderColor } = attributes;\n\t\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\n\t\tif (\n\t\t\t! hasBorderSupport( name, 'color' ) ||\n\t\t\tshouldSkipSerialization( name )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst extraStyles = {\n\t\t\tborderColor: borderColor\n\t\t\t\t? getColorObjectByAttributeValues( colors, borderColor )?.color\n\t\t\t\t: undefined,\n\t\t};\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...extraStyles,\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/border/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/border/with-border-color-palette-styles',\n\twithBorderColorPaletteStyles\n);\n"]}
|
|
@@ -4,13 +4,12 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
6
|
import { useState, useEffect } from '@wordpress/element';
|
|
7
|
-
import { __ } from '@wordpress/i18n';
|
|
8
7
|
/**
|
|
9
8
|
* Internal dependencies
|
|
10
9
|
*/
|
|
11
10
|
|
|
12
|
-
import PanelColorGradientSettings from '../components/colors-gradients/panel-color-gradient-settings';
|
|
13
11
|
import ContrastChecker from '../components/contrast-checker';
|
|
12
|
+
import ToolsPanelColorDropdown from '../components/colors-gradients/tools-panel-color-dropdown';
|
|
14
13
|
import InspectorControls from '../components/inspector-controls';
|
|
15
14
|
import { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';
|
|
16
15
|
|
|
@@ -23,13 +22,15 @@ export default function ColorPanel(_ref) {
|
|
|
23
22
|
enableAlpha = false,
|
|
24
23
|
settings,
|
|
25
24
|
clientId,
|
|
26
|
-
enableContrastChecking = true
|
|
27
|
-
showTitle = true
|
|
25
|
+
enableContrastChecking = true
|
|
28
26
|
} = _ref;
|
|
29
27
|
const [detectedBackgroundColor, setDetectedBackgroundColor] = useState();
|
|
30
28
|
const [detectedColor, setDetectedColor] = useState();
|
|
29
|
+
const [detectedLinkColor, setDetectedLinkColor] = useState();
|
|
31
30
|
const ref = useBlockRef(clientId);
|
|
32
31
|
useEffect(() => {
|
|
32
|
+
var _ref$current;
|
|
33
|
+
|
|
33
34
|
if (!enableContrastChecking) {
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
@@ -39,6 +40,12 @@ export default function ColorPanel(_ref) {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
setDetectedColor(getComputedStyle(ref.current).color);
|
|
43
|
+
const firstLinkElement = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector('a');
|
|
44
|
+
|
|
45
|
+
if (firstLinkElement && !!firstLinkElement.innerText) {
|
|
46
|
+
setDetectedLinkColor(getComputedStyle(firstLinkElement).color);
|
|
47
|
+
}
|
|
48
|
+
|
|
42
49
|
let backgroundColorNode = ref.current;
|
|
43
50
|
let backgroundColor = getComputedStyle(backgroundColorNode).backgroundColor;
|
|
44
51
|
|
|
@@ -49,18 +56,18 @@ export default function ColorPanel(_ref) {
|
|
|
49
56
|
|
|
50
57
|
setDetectedBackgroundColor(backgroundColor);
|
|
51
58
|
});
|
|
52
|
-
return createElement(InspectorControls,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}, enableContrastChecking && createElement(ContrastChecker, {
|
|
59
|
+
return createElement(InspectorControls, {
|
|
60
|
+
__experimentalGroup: "color"
|
|
61
|
+
}, settings.map((setting, index) => createElement(ToolsPanelColorDropdown, {
|
|
62
|
+
key: index,
|
|
63
|
+
settings: setting,
|
|
64
|
+
panelId: clientId,
|
|
65
|
+
enableAlpha: enableAlpha
|
|
66
|
+
})), enableContrastChecking && createElement(ContrastChecker, {
|
|
61
67
|
backgroundColor: detectedBackgroundColor,
|
|
62
68
|
textColor: detectedColor,
|
|
63
|
-
enableAlphaChecker: enableAlpha
|
|
64
|
-
|
|
69
|
+
enableAlphaChecker: enableAlpha,
|
|
70
|
+
linkColor: detectedLinkColor
|
|
71
|
+
}));
|
|
65
72
|
}
|
|
66
73
|
//# sourceMappingURL=color-panel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/color-panel.js"],"names":["useState","useEffect","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/color-panel.js"],"names":["useState","useEffect","ContrastChecker","ToolsPanelColorDropdown","InspectorControls","__unstableUseBlockRef","useBlockRef","getComputedStyle","node","ownerDocument","defaultView","ColorPanel","enableAlpha","settings","clientId","enableContrastChecking","detectedBackgroundColor","setDetectedBackgroundColor","detectedColor","setDetectedColor","detectedLinkColor","setDetectedLinkColor","ref","current","color","firstLinkElement","querySelector","innerText","backgroundColorNode","backgroundColor","parentNode","nodeType","ELEMENT_NODE","map","setting","index"],"mappings":";;AAA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,CAAqCD,KAAvC,CAApB;AACA;;AAED,QAAII,mBAAmB,GAAGN,GAAG,CAACC,OAA9B;AACA,QAAIM,eAAe,GAAGtB,gBAAgB,CAAEqB,mBAAF,CAAhB,CACpBC,eADF;;AAEA,WACCA,eAAe,KAAK,kBAApB,IACAD,mBAAmB,CAACE,UADpB,IAEAF,mBAAmB,CAACE,UAApB,CAA+BC,QAA/B,KACCH,mBAAmB,CAACE,UAApB,CAA+BE,YAJjC,EAKE;AACDJ,MAAAA,mBAAmB,GAAGA,mBAAmB,CAACE,UAA1C;AACAD,MAAAA,eAAe,GAAGtB,gBAAgB,CAAEqB,mBAAF,CAAhB,CAChBC,eADF;AAEA;;AAEDZ,IAAAA,0BAA0B,CAAEY,eAAF,CAA1B;AACA,GA9BQ,CAAT;AAgCA,SACC,cAAC,iBAAD;AAAmB,IAAA,mBAAmB,EAAC;AAAvC,KACGhB,QAAQ,CAACoB,GAAT,CAAc,CAAEC,OAAF,EAAWC,KAAX,KACf,cAAC,uBAAD;AACC,IAAA,GAAG,EAAGA,KADP;AAEC,IAAA,QAAQ,EAAGD,OAFZ;AAGC,IAAA,OAAO,EAAGpB,QAHX;AAIC,IAAA,WAAW,EAAGF;AAJf,IADC,CADH,EASGG,sBAAsB,IACvB,cAAC,eAAD;AACC,IAAA,eAAe,EAAGC,uBADnB;AAEC,IAAA,SAAS,EAAGE,aAFb;AAGC,IAAA,kBAAkB,EAAGN,WAHtB;AAIC,IAAA,SAAS,EAAGQ;AAJb,IAVF,CADD;AAoBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ContrastChecker from '../components/contrast-checker';\nimport ToolsPanelColorDropdown from '../components/colors-gradients/tools-panel-color-dropdown';\nimport InspectorControls from '../components/inspector-controls';\nimport { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';\n\nfunction getComputedStyle( node ) {\n\treturn node.ownerDocument.defaultView.getComputedStyle( node );\n}\n\nexport default function ColorPanel( {\n\tenableAlpha = false,\n\tsettings,\n\tclientId,\n\tenableContrastChecking = true,\n} ) {\n\tconst [ detectedBackgroundColor, setDetectedBackgroundColor ] = useState();\n\tconst [ detectedColor, setDetectedColor ] = useState();\n\tconst [ detectedLinkColor, setDetectedLinkColor ] = useState();\n\tconst ref = useBlockRef( clientId );\n\n\tuseEffect( () => {\n\t\tif ( ! enableContrastChecking ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\t\tsetDetectedColor( getComputedStyle( ref.current ).color );\n\n\t\tconst firstLinkElement = ref.current?.querySelector( 'a' );\n\t\tif ( firstLinkElement && !! firstLinkElement.innerText ) {\n\t\t\tsetDetectedLinkColor( getComputedStyle( firstLinkElement ).color );\n\t\t}\n\n\t\tlet backgroundColorNode = ref.current;\n\t\tlet backgroundColor = getComputedStyle( backgroundColorNode )\n\t\t\t.backgroundColor;\n\t\twhile (\n\t\t\tbackgroundColor === 'rgba(0, 0, 0, 0)' &&\n\t\t\tbackgroundColorNode.parentNode &&\n\t\t\tbackgroundColorNode.parentNode.nodeType ===\n\t\t\t\tbackgroundColorNode.parentNode.ELEMENT_NODE\n\t\t) {\n\t\t\tbackgroundColorNode = backgroundColorNode.parentNode;\n\t\t\tbackgroundColor = getComputedStyle( backgroundColorNode )\n\t\t\t\t.backgroundColor;\n\t\t}\n\n\t\tsetDetectedBackgroundColor( backgroundColor );\n\t} );\n\n\treturn (\n\t\t<InspectorControls __experimentalGroup=\"color\">\n\t\t\t{ settings.map( ( setting, index ) => (\n\t\t\t\t<ToolsPanelColorDropdown\n\t\t\t\t\tkey={ index }\n\t\t\t\t\tsettings={ setting }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ enableContrastChecking && (\n\t\t\t\t<ContrastChecker\n\t\t\t\t\tbackgroundColor={ detectedBackgroundColor }\n\t\t\t\t\ttextColor={ detectedColor }\n\t\t\t\t\tenableAlphaChecker={ enableAlpha }\n\t\t\t\t\tlinkColor={ detectedLinkColor }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n"]}
|