@wordpress/format-library 3.0.6 → 3.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/build/bold/index.js +8 -6
  2. package/build/bold/index.js.map +1 -1
  3. package/build/code/index.js +8 -6
  4. package/build/code/index.js.map +1 -1
  5. package/build/image/index.js +27 -23
  6. package/build/image/index.js.map +1 -1
  7. package/build/index.js +7 -4
  8. package/build/index.js.map +1 -1
  9. package/build/italic/index.js +8 -6
  10. package/build/italic/index.js.map +1 -1
  11. package/build/keyboard/index.js +8 -6
  12. package/build/keyboard/index.js.map +1 -1
  13. package/build/link/index.js +15 -12
  14. package/build/link/index.js.map +1 -1
  15. package/build/link/inline.js +11 -10
  16. package/build/link/inline.js.map +1 -1
  17. package/build/link/modal-screens/link-picker-screen.native.js +6 -4
  18. package/build/link/modal-screens/link-picker-screen.native.js.map +1 -1
  19. package/build/link/modal-screens/link-settings-screen.native.js +15 -12
  20. package/build/link/modal-screens/link-settings-screen.native.js.map +1 -1
  21. package/build/link/modal.native.js +5 -4
  22. package/build/link/modal.native.js.map +1 -1
  23. package/build/link/use-link-instance-key.js +4 -0
  24. package/build/link/use-link-instance-key.js.map +1 -1
  25. package/build/link/utils.js +11 -8
  26. package/build/link/utils.js.map +1 -1
  27. package/build/strikethrough/index.js +8 -6
  28. package/build/strikethrough/index.js.map +1 -1
  29. package/build/subscript/index.js +8 -6
  30. package/build/subscript/index.js.map +1 -1
  31. package/build/superscript/index.js +8 -6
  32. package/build/superscript/index.js.map +1 -1
  33. package/build/text-color/index.js +18 -13
  34. package/build/text-color/index.js.map +1 -1
  35. package/build/text-color/inline.js +22 -16
  36. package/build/text-color/inline.js.map +1 -1
  37. package/build/underline/index.js +6 -4
  38. package/build/underline/index.js.map +1 -1
  39. package/build-module/bold/index.js +8 -6
  40. package/build-module/bold/index.js.map +1 -1
  41. package/build-module/code/index.js +8 -6
  42. package/build-module/code/index.js.map +1 -1
  43. package/build-module/image/index.js +27 -23
  44. package/build-module/image/index.js.map +1 -1
  45. package/build-module/index.js +7 -4
  46. package/build-module/index.js.map +1 -1
  47. package/build-module/italic/index.js +8 -6
  48. package/build-module/italic/index.js.map +1 -1
  49. package/build-module/keyboard/index.js +8 -6
  50. package/build-module/keyboard/index.js.map +1 -1
  51. package/build-module/link/index.js +15 -12
  52. package/build-module/link/index.js.map +1 -1
  53. package/build-module/link/inline.js +11 -10
  54. package/build-module/link/inline.js.map +1 -1
  55. package/build-module/link/modal-screens/link-picker-screen.native.js +6 -4
  56. package/build-module/link/modal-screens/link-picker-screen.native.js.map +1 -1
  57. package/build-module/link/modal-screens/link-settings-screen.native.js +15 -12
  58. package/build-module/link/modal-screens/link-settings-screen.native.js.map +1 -1
  59. package/build-module/link/modal.native.js +5 -4
  60. package/build-module/link/modal.native.js.map +1 -1
  61. package/build-module/link/use-link-instance-key.js +4 -0
  62. package/build-module/link/use-link-instance-key.js.map +1 -1
  63. package/build-module/link/utils.js +10 -7
  64. package/build-module/link/utils.js.map +1 -1
  65. package/build-module/strikethrough/index.js +8 -6
  66. package/build-module/strikethrough/index.js.map +1 -1
  67. package/build-module/subscript/index.js +8 -6
  68. package/build-module/subscript/index.js.map +1 -1
  69. package/build-module/superscript/index.js +8 -6
  70. package/build-module/superscript/index.js.map +1 -1
  71. package/build-module/text-color/index.js +14 -11
  72. package/build-module/text-color/index.js.map +1 -1
  73. package/build-module/text-color/inline.js +21 -15
  74. package/build-module/text-color/inline.js.map +1 -1
  75. package/build-module/underline/index.js +6 -4
  76. package/build-module/underline/index.js.map +1 -1
  77. package/package.json +16 -16
  78. package/src/link/use-link-instance-key.js +3 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/link/modal-screens/link-settings-screen.native.js"],"names":["LinkSettingsScreen","onRemove","onClose","onChange","speak","value","isActive","activeAttributes","isVisible","text","setText","opensInNewWindow","setOpensInNewWindows","target","linkValues","setLinkValues","isActiveLink","isRemovingLink","shouldEnableBottomSheetMaxHeight","onHandleClosingBottomSheet","listProps","BottomSheetContext","navigation","route","inputValue","url","params","onLinkCellPressed","navigate","linkSettingsScreens","picker","submit","submitLink","removeLink","clearFormat","activeFormats","shouldCloseBottomSheet","linkText","format","newAttributes","toInsert","length","start","end","textLength","needsSelectionUpdate","submitValue","unsubscribe","addListener","shouldShowLinkOptions","textColor","undefined","external","styles","clearLinkButton","safeAreaBottomInset"],"mappings":";;;;;;;;;AAQA;;AALA;;AAIA;;AAEA;;AAEA;;AACA;;AAQA;;AAKA;;AACA;;AAEA;;AA5BA;AACA;AACA;;AAEA;AACA;AACA;;AAgBA;AACA;AACA;AAMA,MAAMA,kBAAkB,GAAG,CAAE;AAC5BC,EAAAA,QAD4B;AAE5BC,EAAAA,OAF4B;AAG5BC,EAAAA,QAH4B;AAI5BC,EAAAA,KAJ4B;AAK5BC,EAAAA,KAL4B;AAM5BC,EAAAA,QAN4B;AAO5BC,EAAAA,gBAP4B;AAQ5BC,EAAAA;AAR4B,CAAF,KASpB;AAAA;;AACN,QAAM,CAAEC,IAAF,EAAQC,OAAR,IAAoB,uBAAU,8BAAgB,qBAAOL,KAAP,CAAhB,CAAV,CAA1B;AACA,QAAM,CAAEM,gBAAF,EAAoBC,oBAApB,IAA6C,uBAClDL,gBAAgB,CAACM,MAAjB,KAA4B,QADsB,CAAnD;AAGA,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgC,uBAAU;AAC/CC,IAAAA,YAAY,EAAEV,QADiC;AAE/CW,IAAAA,cAAc,EAAE;AAF+B,GAAV,CAAtC;AAKA,QAAM;AACLC,IAAAA,gCADK;AAELC,IAAAA,0BAFK;AAGLC,IAAAA;AAHK,MAIF,yBAAYC,8BAAZ,CAJJ;AAMA,QAAMC,UAAU,GAAG,4BAAnB;AACA,QAAMC,KAAK,GAAG,uBAAd;AACA,QAAM;AAAEC,IAAAA,UAAU,GAAGjB,gBAAgB,CAACkB,GAAjB,IAAwB;AAAvC,MAA8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EAQG,CAAEzB,UAAF,mBAAcC,KAAK,CAACG,MAApB,kDAAc,cAAcjB,IAA5B,EAAkCA,IAAlC,CARH;AAUA,SAAO,sBAAS,MAAM;AACrB,UAAMwC,qBAAqB,GAAG,CAAC,CAAEzB,UAAjC;AAEA,WACC,qDACC,4BAAC,uBAAD,CAAa,QAAb;AACC,MAAA,KAAK,EAAGA,UADT;AAEC,MAAA,OAAO,EAAGG;AAFX,MADD,EAKC,4BAAC,uBAAD,CAAa,IAAb;AACC,MAAA,IAAI,EAAGuB,gBADR;AAEC,MAAA,KAAK,EAAG,cAAI,WAAJ,CAFT;AAGC,MAAA,KAAK,EAAGzC,IAHT;AAIC,MAAA,WAAW,EAAG,cAAI,eAAJ,CAJf;AAKC,MAAA,aAAa,EAAGC,OALjB;AAMC,MAAA,QAAQ,EAAGqB,MANZ;AAOC,MAAA,aAAa,EAAGkB,qBAAqB,GAAGE,SAAH,GAAe;AAPrD,MALD,EAcGF,qBAAqB,IACtB,qDACC,4BAAC,uBAAD,CAAa,UAAb;AACC,MAAA,IAAI,EAAGG,eADR;AAEC,MAAA,KAAK,EAAG,cAAI,iBAAJ,CAFT;AAGC,MAAA,KAAK,EAAGzC,gBAHT;AAIC,MAAA,aAAa,EAAGC,oBAJjB;AAKC,MAAA,aAAa,EAAG;AALjB,MADD,EAQC,4BAAC,uBAAD,CAAa,IAAb;AACC,MAAA,KAAK,EAAG,cAAI,aAAJ,CADT;AAEC,MAAA,UAAU,EAAGyC,eAAOC,eAFrB;AAGC,MAAA,aAAa,EAAG,MAHjB;AAIC,MAAA,OAAO,EAAGrB;AAJX,MARD,CAfF,CADD;AAkCA,GArCM,EAqCJ,CAAET,UAAF,EAAcf,IAAd,EAAoBE,gBAApB,EAAsCS,SAAS,CAACmC,mBAAhD,CArCI,CAAP;AAsCA,CAvLD;;eAyLevD,kB","sourcesContent":["/**\n * External dependencies\n */\nimport { useNavigation, useRoute } from '@react-navigation/native';\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useContext, useEffect, useMemo } from '@wordpress/element';\nimport { prependHTTP } from '@wordpress/url';\n\nimport { BottomSheet, BottomSheetContext } from '@wordpress/components';\nimport {\n\tcreate,\n\tinsert,\n\tisCollapsed,\n\tapplyFormat,\n\tgetTextContent,\n\tslice,\n} from '@wordpress/rich-text';\nimport { external, textColor } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { createLinkFormat, isValidHref } from '../utils';\nimport linkSettingsScreens from './screens';\n\nimport styles from '../modal.scss';\n\nconst LinkSettingsScreen = ( {\n\tonRemove,\n\tonClose,\n\tonChange,\n\tspeak,\n\tvalue,\n\tisActive,\n\tactiveAttributes,\n\tisVisible,\n} ) => {\n\tconst [ text, setText ] = useState( getTextContent( slice( value ) ) );\n\tconst [ opensInNewWindow, setOpensInNewWindows ] = useState(\n\t\tactiveAttributes.target === '_blank'\n\t);\n\tconst [ linkValues, setLinkValues ] = useState( {\n\t\tisActiveLink: isActive,\n\t\tisRemovingLink: false,\n\t} );\n\n\tconst {\n\t\tshouldEnableBottomSheetMaxHeight,\n\t\tonHandleClosingBottomSheet,\n\t\tlistProps,\n\t} = useContext( BottomSheetContext );\n\n\tconst navigation = useNavigation();\n\tconst route = useRoute();\n\tconst { inputValue = activeAttributes.url || '' } = route.params || {};\n\tconst onLinkCellPressed = () => {\n\t\tshouldEnableBottomSheetMaxHeight( false );\n\t\tnavigation.navigate( linkSettingsScreens.picker, { inputValue } );\n\t};\n\tuseEffect( () => {\n\t\tonHandleClosingBottomSheet( () => {\n\t\t\tsubmit( inputValue );\n\t\t} );\n\t}, [ inputValue, opensInNewWindow, text ] );\n\n\tuseEffect( () => {\n\t\tconst { isActiveLink, isRemovingLink } = linkValues;\n\t\tif ( !! inputValue && ! isActiveLink && isVisible ) {\n\t\t\tsubmitLink( false );\n\t\t} else if ( ( inputValue === '' && isActiveLink ) || isRemovingLink ) {\n\t\t\tremoveLink( false );\n\t\t}\n\t}, [\n\t\tinputValue,\n\t\tisVisible,\n\t\tlinkValues.isActiveLink,\n\t\tlinkValues.isRemovingLink,\n\t] );\n\n\tconst clearFormat = () => {\n\t\tonChange( { ...value, activeFormats: [] } );\n\t\tsetLinkValues( { isActiveLink: false, isRemovingLink: true } );\n\t};\n\n\tconst submitLink = ( shouldCloseBottomSheet = true ) => {\n\t\tconst url = prependHTTP( inputValue );\n\t\tconst linkText = text || inputValue;\n\t\tconst format = createLinkFormat( {\n\t\t\turl,\n\t\t\topensInNewWindow,\n\t\t\ttext: linkText,\n\t\t} );\n\t\tlet newAttributes;\n\t\tif ( isCollapsed( value ) && ! isActive ) {\n\t\t\t// insert link\n\t\t\tconst toInsert = applyFormat(\n\t\t\t\tcreate( { text: linkText } ),\n\t\t\t\tformat,\n\t\t\t\t0,\n\t\t\t\tlinkText.length\n\t\t\t);\n\t\t\tnewAttributes = insert( value, toInsert );\n\t\t} else if ( text !== getTextContent( slice( value ) ) ) {\n\t\t\t// edit text in selected link\n\t\t\tconst toInsert = applyFormat(\n\t\t\t\tcreate( { text } ),\n\t\t\t\tformat,\n\t\t\t\t0,\n\t\t\t\ttext.length\n\t\t\t);\n\t\t\tnewAttributes = insert( value, toInsert, value.start, value.end );\n\t\t} else {\n\t\t\t// transform selected text into link\n\t\t\tnewAttributes = applyFormat( value, format );\n\t\t}\n\t\t// move selection to end of link\n\t\tconst textLength = newAttributes.text.length;\n\t\t// check for zero width spaces\n\t\tif ( newAttributes.end > textLength ) {\n\t\t\tnewAttributes.start = textLength;\n\t\t\tnewAttributes.end = textLength;\n\t\t} else {\n\t\t\tnewAttributes.start = newAttributes.end;\n\t\t}\n\t\tnewAttributes.activeFormats = [];\n\t\tonChange( { ...newAttributes, needsSelectionUpdate: true } );\n\t\tsetLinkValues( { isActiveLink: true, isRemovingLink: false } );\n\n\t\tif ( ! isValidHref( url ) ) {\n\t\t\tspeak(\n\t\t\t\t__(\n\t\t\t\t\t'Warning: the link has been inserted but may have errors. Please test it.'\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t} else if ( isActive ) {\n\t\t\tspeak( __( 'Link edited.' ), 'assertive' );\n\t\t} else {\n\t\t\tspeak( __( 'Link inserted' ), 'assertive' );\n\t\t}\n\n\t\tif ( shouldCloseBottomSheet ) {\n\t\t\tonClose();\n\t\t}\n\t};\n\n\tconst removeLink = ( shouldCloseBottomSheet = true ) => {\n\t\tclearFormat();\n\t\tonRemove();\n\t\tif ( shouldCloseBottomSheet ) {\n\t\t\tonClose();\n\t\t}\n\t};\n\n\tconst submit = ( submitValue ) => {\n\t\tif ( submitValue === '' ) {\n\t\t\tremoveLink();\n\t\t} else {\n\t\t\tsubmitLink();\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tconst unsubscribe = navigation.addListener( 'focus', () => {\n\t\t\tconst { params = {} } = route;\n\t\t\tif ( ! text && params.text ) {\n\t\t\t\tsetText( params.text );\n\t\t\t}\n\t\t} );\n\t\treturn unsubscribe;\n\t}, [ navigation, route.params?.text, text ] );\n\n\treturn useMemo( () => {\n\t\tconst shouldShowLinkOptions = !! inputValue;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BottomSheet.LinkCell\n\t\t\t\t\tvalue={ inputValue }\n\t\t\t\t\tonPress={ onLinkCellPressed }\n\t\t\t\t/>\n\t\t\t\t<BottomSheet.Cell\n\t\t\t\t\ticon={ textColor }\n\t\t\t\t\tlabel={ __( 'Link text' ) }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tplaceholder={ __( 'Add link text' ) }\n\t\t\t\t\tonChangeValue={ setText }\n\t\t\t\t\tonSubmit={ submit }\n\t\t\t\t\tseparatorType={ shouldShowLinkOptions ? undefined : 'none' }\n\t\t\t\t/>\n\t\t\t\t{ shouldShowLinkOptions && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BottomSheet.SwitchCell\n\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\tvalue={ opensInNewWindow }\n\t\t\t\t\t\t\tonValueChange={ setOpensInNewWindows }\n\t\t\t\t\t\t\tseparatorType={ 'fullWidth' }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BottomSheet.Cell\n\t\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\t\tlabelStyle={ styles.clearLinkButton }\n\t\t\t\t\t\t\tseparatorType={ 'none' }\n\t\t\t\t\t\t\tonPress={ removeLink }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}, [ inputValue, text, opensInNewWindow, listProps.safeAreaBottomInset ] );\n};\n\nexport default LinkSettingsScreen;\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/link/modal-screens/link-settings-screen.native.js"],"names":["LinkSettingsScreen","onRemove","onClose","onChange","speak","value","isActive","activeAttributes","isVisible","text","setText","opensInNewWindow","setOpensInNewWindows","target","linkValues","setLinkValues","isActiveLink","isRemovingLink","shouldEnableBottomSheetMaxHeight","onHandleClosingBottomSheet","listProps","BottomSheetContext","navigation","route","inputValue","url","params","onLinkCellPressed","navigate","linkSettingsScreens","picker","submit","submitLink","removeLink","clearFormat","activeFormats","shouldCloseBottomSheet","linkText","format","newAttributes","toInsert","length","start","end","textLength","needsSelectionUpdate","submitValue","unsubscribe","addListener","shouldShowLinkOptions","textColor","undefined","external","styles","clearLinkButton","safeAreaBottomInset"],"mappings":";;;;;;;;;AAQA;;AALA;;AAIA;;AAEA;;AAEA;;AACA;;AAQA;;AAKA;;AACA;;AAEA;;AA5BA;AACA;AACA;;AAEA;AACA;AACA;;AAgBA;AACA;AACA;AAMA,MAAMA,kBAAkB,GAAG,QASpB;AAAA;;AAAA,MATsB;AAC5BC,IAAAA,QAD4B;AAE5BC,IAAAA,OAF4B;AAG5BC,IAAAA,QAH4B;AAI5BC,IAAAA,KAJ4B;AAK5BC,IAAAA,KAL4B;AAM5BC,IAAAA,QAN4B;AAO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EAcGF,qBAAqB,IACtB,qDACC,4BAAC,uBAAD,CAAa,UAAb;AACC,MAAA,IAAI,EAAGG,eADR;AAEC,MAAA,KAAK,EAAG,cAAI,iBAAJ,CAFT;AAGC,MAAA,KAAK,EAAGzC,gBAHT;AAIC,MAAA,aAAa,EAAGC,oBAJjB;AAKC,MAAA,aAAa,EAAG;AALjB,MADD,EAQC,4BAAC,uBAAD,CAAa,IAAb;AACC,MAAA,KAAK,EAAG,cAAI,aAAJ,CADT;AAEC,MAAA,UAAU,EAAGyC,eAAOC,eAFrB;AAGC,MAAA,aAAa,EAAG,MAHjB;AAIC,MAAA,OAAO,EAAGrB;AAJX,MARD,CAfF,CADD;AAkCA,GArCM,EAqCJ,CAAET,UAAF,EAAcf,IAAd,EAAoBE,gBAApB,EAAsCS,SAAS,CAACmC,mBAAhD,CArCI,CAAP;AAsCA,CAvLD;;eAyLevD,kB","sourcesContent":["/**\n * External dependencies\n */\nimport { useNavigation, useRoute } from '@react-navigation/native';\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useContext, useEffect, useMemo } from '@wordpress/element';\nimport { prependHTTP } from '@wordpress/url';\n\nimport { BottomSheet, BottomSheetContext } from '@wordpress/components';\nimport {\n\tcreate,\n\tinsert,\n\tisCollapsed,\n\tapplyFormat,\n\tgetTextContent,\n\tslice,\n} from '@wordpress/rich-text';\nimport { external, textColor } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { createLinkFormat, isValidHref } from '../utils';\nimport linkSettingsScreens from './screens';\n\nimport styles from '../modal.scss';\n\nconst LinkSettingsScreen = ( {\n\tonRemove,\n\tonClose,\n\tonChange,\n\tspeak,\n\tvalue,\n\tisActive,\n\tactiveAttributes,\n\tisVisible,\n} ) => {\n\tconst [ text, setText ] = useState( getTextContent( slice( value ) ) );\n\tconst [ opensInNewWindow, setOpensInNewWindows ] = useState(\n\t\tactiveAttributes.target === '_blank'\n\t);\n\tconst [ linkValues, setLinkValues ] = useState( {\n\t\tisActiveLink: isActive,\n\t\tisRemovingLink: false,\n\t} );\n\n\tconst {\n\t\tshouldEnableBottomSheetMaxHeight,\n\t\tonHandleClosingBottomSheet,\n\t\tlistProps,\n\t} = useContext( BottomSheetContext );\n\n\tconst navigation = useNavigation();\n\tconst route = useRoute();\n\tconst { inputValue = activeAttributes.url || '' } = route.params || {};\n\tconst onLinkCellPressed = () => {\n\t\tshouldEnableBottomSheetMaxHeight( false );\n\t\tnavigation.navigate( linkSettingsScreens.picker, { inputValue } );\n\t};\n\tuseEffect( () => {\n\t\tonHandleClosingBottomSheet( () => {\n\t\t\tsubmit( inputValue );\n\t\t} );\n\t}, [ inputValue, opensInNewWindow, text ] );\n\n\tuseEffect( () => {\n\t\tconst { isActiveLink, isRemovingLink } = linkValues;\n\t\tif ( !! inputValue && ! isActiveLink && isVisible ) {\n\t\t\tsubmitLink( false );\n\t\t} else if ( ( inputValue === '' && isActiveLink ) || isRemovingLink ) {\n\t\t\tremoveLink( false );\n\t\t}\n\t}, [\n\t\tinputValue,\n\t\tisVisible,\n\t\tlinkValues.isActiveLink,\n\t\tlinkValues.isRemovingLink,\n\t] );\n\n\tconst clearFormat = () => {\n\t\tonChange( { ...value, activeFormats: [] } );\n\t\tsetLinkValues( { isActiveLink: false, isRemovingLink: true } );\n\t};\n\n\tconst submitLink = ( shouldCloseBottomSheet = true ) => {\n\t\tconst url = prependHTTP( inputValue );\n\t\tconst linkText = text || inputValue;\n\t\tconst format = createLinkFormat( {\n\t\t\turl,\n\t\t\topensInNewWindow,\n\t\t\ttext: linkText,\n\t\t} );\n\t\tlet newAttributes;\n\t\tif ( isCollapsed( value ) && ! isActive ) {\n\t\t\t// insert link\n\t\t\tconst toInsert = applyFormat(\n\t\t\t\tcreate( { text: linkText } ),\n\t\t\t\tformat,\n\t\t\t\t0,\n\t\t\t\tlinkText.length\n\t\t\t);\n\t\t\tnewAttributes = insert( value, toInsert );\n\t\t} else if ( text !== getTextContent( slice( value ) ) ) {\n\t\t\t// edit text in selected link\n\t\t\tconst toInsert = applyFormat(\n\t\t\t\tcreate( { text } ),\n\t\t\t\tformat,\n\t\t\t\t0,\n\t\t\t\ttext.length\n\t\t\t);\n\t\t\tnewAttributes = insert( value, toInsert, value.start, value.end );\n\t\t} else {\n\t\t\t// transform selected text into link\n\t\t\tnewAttributes = applyFormat( value, format );\n\t\t}\n\t\t// move selection to end of link\n\t\tconst textLength = newAttributes.text.length;\n\t\t// check for zero width spaces\n\t\tif ( newAttributes.end > textLength ) {\n\t\t\tnewAttributes.start = textLength;\n\t\t\tnewAttributes.end = textLength;\n\t\t} else {\n\t\t\tnewAttributes.start = newAttributes.end;\n\t\t}\n\t\tnewAttributes.activeFormats = [];\n\t\tonChange( { ...newAttributes, needsSelectionUpdate: true } );\n\t\tsetLinkValues( { isActiveLink: true, isRemovingLink: false } );\n\n\t\tif ( ! isValidHref( url ) ) {\n\t\t\tspeak(\n\t\t\t\t__(\n\t\t\t\t\t'Warning: the link has been inserted but may have errors. Please test it.'\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t} else if ( isActive ) {\n\t\t\tspeak( __( 'Link edited.' ), 'assertive' );\n\t\t} else {\n\t\t\tspeak( __( 'Link inserted' ), 'assertive' );\n\t\t}\n\n\t\tif ( shouldCloseBottomSheet ) {\n\t\t\tonClose();\n\t\t}\n\t};\n\n\tconst removeLink = ( shouldCloseBottomSheet = true ) => {\n\t\tclearFormat();\n\t\tonRemove();\n\t\tif ( shouldCloseBottomSheet ) {\n\t\t\tonClose();\n\t\t}\n\t};\n\n\tconst submit = ( submitValue ) => {\n\t\tif ( submitValue === '' ) {\n\t\t\tremoveLink();\n\t\t} else {\n\t\t\tsubmitLink();\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tconst unsubscribe = navigation.addListener( 'focus', () => {\n\t\t\tconst { params = {} } = route;\n\t\t\tif ( ! text && params.text ) {\n\t\t\t\tsetText( params.text );\n\t\t\t}\n\t\t} );\n\t\treturn unsubscribe;\n\t}, [ navigation, route.params?.text, text ] );\n\n\treturn useMemo( () => {\n\t\tconst shouldShowLinkOptions = !! inputValue;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BottomSheet.LinkCell\n\t\t\t\t\tvalue={ inputValue }\n\t\t\t\t\tonPress={ onLinkCellPressed }\n\t\t\t\t/>\n\t\t\t\t<BottomSheet.Cell\n\t\t\t\t\ticon={ textColor }\n\t\t\t\t\tlabel={ __( 'Link text' ) }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tplaceholder={ __( 'Add link text' ) }\n\t\t\t\t\tonChangeValue={ setText }\n\t\t\t\t\tonSubmit={ submit }\n\t\t\t\t\tseparatorType={ shouldShowLinkOptions ? undefined : 'none' }\n\t\t\t\t/>\n\t\t\t\t{ shouldShowLinkOptions && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BottomSheet.SwitchCell\n\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\tvalue={ opensInNewWindow }\n\t\t\t\t\t\t\tonValueChange={ setOpensInNewWindows }\n\t\t\t\t\t\t\tseparatorType={ 'fullWidth' }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BottomSheet.Cell\n\t\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\t\tlabelStyle={ styles.clearLinkButton }\n\t\t\t\t\t\t\tseparatorType={ 'none' }\n\t\t\t\t\t\t\tonPress={ removeLink }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}, [ inputValue, text, opensInNewWindow, listProps.safeAreaBottomInset ] );\n};\n\nexport default LinkSettingsScreen;\n"]}
@@ -26,10 +26,11 @@ var _linkPickerScreen = _interopRequireDefault(require("./modal-screens/link-pic
26
26
  /**
27
27
  * Internal dependencies
28
28
  */
29
- const ModalLinkUI = ({
30
- isVisible,
31
- ...restProps
32
- }) => {
29
+ const ModalLinkUI = _ref => {
30
+ let {
31
+ isVisible,
32
+ ...restProps
33
+ } = _ref;
33
34
  return (0, _element.useMemo)(() => {
34
35
  return (0, _element.createElement)(_components.BottomSheet, {
35
36
  isVisible: isVisible,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/link/modal.native.js"],"names":["ModalLinkUI","isVisible","restProps","onClose","screens","settings","picker"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AAKA;;AACA;;AACA;;AAXA;AACA;AACA;;AAIA;AACA;AACA;AAKA,MAAMA,WAAW,GAAG,CAAE;AAAEC,EAAAA,SAAF;AAAa,KAAGC;AAAhB,CAAF,KAAmC;AACtD,SAAO,sBAAS,MAAM;AACrB,WACC,4BAAC,uBAAD;AACC,MAAA,SAAS,EAAGD,SADb;AAEC,MAAA,UAAU,MAFX;AAGC,MAAA,OAAO,EAAGC,SAAS,CAACC,OAHrB;AAIC,MAAA,aAAa;AAJd,OAMC,4BAAC,uBAAD,CAAa,mBAAb;AAAiC,MAAA,OAAO,MAAxC;AAAyC,MAAA,IAAI;AAA7C,OACC,4BAAC,uBAAD,CAAa,gBAAb;AAA8B,MAAA,IAAI,EAAGC,iBAAQC;AAA7C,OACC,4BAAC,2BAAD;AACC,MAAA,SAAS,EAAGJ;AADb,OAEMC,SAFN,EADD,CADD,EAOC,4BAAC,uBAAD,CAAa,gBAAb;AACC,MAAA,IAAI,EAAGE,iBAAQE,MADhB;AAEC,MAAA,YAAY,MAFb;AAGC,MAAA,UAAU;AAHX,OAKC,4BAAC,yBAAD,OALD,CAPD,CAND,CADD;AAwBA,GAzBM,EAyBJ,CAAEL,SAAF,CAzBI,CAAP;AA0BA,CA3BD;;eA6Be,oCAAoBD,WAApB,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { BottomSheet, withSpokenMessages } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport screens from './modal-screens/screens';\nimport LinkSettingsScreen from './modal-screens/link-settings-screen';\nimport LinkPickerScreen from './modal-screens/link-picker-screen';\n\nconst ModalLinkUI = ( { isVisible, ...restProps } ) => {\n\treturn useMemo( () => {\n\t\treturn (\n\t\t\t<BottomSheet\n\t\t\t\tisVisible={ isVisible }\n\t\t\t\thideHeader\n\t\t\t\tonClose={ restProps.onClose }\n\t\t\t\thasNavigation\n\t\t\t>\n\t\t\t\t<BottomSheet.NavigationContainer animate main>\n\t\t\t\t\t<BottomSheet.NavigationScreen name={ screens.settings }>\n\t\t\t\t\t\t<LinkSettingsScreen\n\t\t\t\t\t\t\tisVisible={ isVisible }\n\t\t\t\t\t\t\t{ ...restProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t\t<BottomSheet.NavigationScreen\n\t\t\t\t\t\tname={ screens.picker }\n\t\t\t\t\t\tisScrollable\n\t\t\t\t\t\tfullScreen\n\t\t\t\t\t>\n\t\t\t\t\t\t<LinkPickerScreen />\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t</BottomSheet.NavigationContainer>\n\t\t\t</BottomSheet>\n\t\t);\n\t}, [ isVisible ] );\n};\n\nexport default withSpokenMessages( ModalLinkUI );\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/link/modal.native.js"],"names":["ModalLinkUI","isVisible","restProps","onClose","screens","settings","picker"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AAKA;;AACA;;AACA;;AAXA;AACA;AACA;;AAIA;AACA;AACA;AAKA,MAAMA,WAAW,GAAG,QAAmC;AAAA,MAAjC;AAAEC,IAAAA,SAAF;AAAa,OAAGC;AAAhB,GAAiC;AACtD,SAAO,sBAAS,MAAM;AACrB,WACC,4BAAC,uBAAD;AACC,MAAA,SAAS,EAAGD,SADb;AAEC,MAAA,UAAU,MAFX;AAGC,MAAA,OAAO,EAAGC,SAAS,CAACC,OAHrB;AAIC,MAAA,aAAa;AAJd,OAMC,4BAAC,uBAAD,CAAa,mBAAb;AAAiC,MAAA,OAAO,MAAxC;AAAyC,MAAA,IAAI;AAA7C,OACC,4BAAC,uBAAD,CAAa,gBAAb;AAA8B,MAAA,IAAI,EAAGC,iBAAQC;AAA7C,OACC,4BAAC,2BAAD;AACC,MAAA,SAAS,EAAGJ;AADb,OAEMC,SAFN,EADD,CADD,EAOC,4BAAC,uBAAD,CAAa,gBAAb;AACC,MAAA,IAAI,EAAGE,iBAAQE,MADhB;AAEC,MAAA,YAAY,MAFb;AAGC,MAAA,UAAU;AAHX,OAKC,4BAAC,yBAAD,OALD,CAPD,CAND,CADD;AAwBA,GAzBM,EAyBJ,CAAEL,SAAF,CAzBI,CAAP;AA0BA,CA3BD;;eA6Be,oCAAoBD,WAApB,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { BottomSheet, withSpokenMessages } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport screens from './modal-screens/screens';\nimport LinkSettingsScreen from './modal-screens/link-settings-screen';\nimport LinkPickerScreen from './modal-screens/link-picker-screen';\n\nconst ModalLinkUI = ( { isVisible, ...restProps } ) => {\n\treturn useMemo( () => {\n\t\treturn (\n\t\t\t<BottomSheet\n\t\t\t\tisVisible={ isVisible }\n\t\t\t\thideHeader\n\t\t\t\tonClose={ restProps.onClose }\n\t\t\t\thasNavigation\n\t\t\t>\n\t\t\t\t<BottomSheet.NavigationContainer animate main>\n\t\t\t\t\t<BottomSheet.NavigationScreen name={ screens.settings }>\n\t\t\t\t\t\t<LinkSettingsScreen\n\t\t\t\t\t\t\tisVisible={ isVisible }\n\t\t\t\t\t\t\t{ ...restProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t\t<BottomSheet.NavigationScreen\n\t\t\t\t\t\tname={ screens.picker }\n\t\t\t\t\t\tisScrollable\n\t\t\t\t\t\tfullScreen\n\t\t\t\t\t>\n\t\t\t\t\t\t<LinkPickerScreen />\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t</BottomSheet.NavigationContainer>\n\t\t\t</BottomSheet>\n\t\t);\n\t}, [ isVisible ] );\n};\n\nexport default withSpokenMessages( ModalLinkUI );\n"]}
@@ -22,6 +22,10 @@ function getKey(_id) {
22
22
 
23
23
 
24
24
  function useLinkInstanceKey(instance) {
25
+ if (!instance) {
26
+ return;
27
+ }
28
+
25
29
  if (weakMap.has(instance)) {
26
30
  return getKey(weakMap.get(instance));
27
31
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/link/use-link-instance-key.js"],"names":["weakMap","WeakMap","id","prefix","getKey","_id","useLinkInstanceKey","instance","has","get","set"],"mappings":";;;;;;AAAA;AACA,MAAMA,OAAO,GAAG,IAAIC,OAAJ,EAAhB,C,CAEA;;AACA,IAAIC,EAAE,GAAG,CAAC,CAAV;AAEA,MAAMC,MAAM,GAAG,uBAAf;;AAEA,SAASC,MAAT,CAAiBC,GAAjB,EAAuB;AACtB,SAAQ,GAAGF,MAAQ,IAAIE,GAAK,EAA5B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,kBAAT,CAA6BC,QAA7B,EAAwC;AACvC,MAAKP,OAAO,CAACQ,GAAR,CAAaD,QAAb,CAAL,EAA+B;AAC9B,WAAOH,MAAM,CAAEJ,OAAO,CAACS,GAAR,CAAaF,QAAb,CAAF,CAAb;AACA;;AAEDL,EAAAA,EAAE,IAAI,CAAN;AAEAF,EAAAA,OAAO,CAACU,GAAR,CAAaH,QAAb,EAAuBL,EAAvB;AAEA,SAAOE,MAAM,CAAEF,EAAF,CAAb;AACA;;eAEcI,kB","sourcesContent":["// Weakly referenced map allows unused ids to be garbage collected.\nconst weakMap = new WeakMap();\n\n// Incrementing zero-based ID value\nlet id = -1;\n\nconst prefix = 'link-control-instance';\n\nfunction getKey( _id ) {\n\treturn `${ prefix }-${ _id }`;\n}\n\n/**\n * Builds a unique link control key for the given object reference.\n *\n * @param {Object} instance an unique object reference specific to this link control instance.\n * @return {string} the unique key to use for this link control.\n */\nfunction useLinkInstanceKey( instance ) {\n\tif ( weakMap.has( instance ) ) {\n\t\treturn getKey( weakMap.get( instance ) );\n\t}\n\n\tid += 1;\n\n\tweakMap.set( instance, id );\n\n\treturn getKey( id );\n}\n\nexport default useLinkInstanceKey;\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/link/use-link-instance-key.js"],"names":["weakMap","WeakMap","id","prefix","getKey","_id","useLinkInstanceKey","instance","has","get","set"],"mappings":";;;;;;AAAA;AACA,MAAMA,OAAO,GAAG,IAAIC,OAAJ,EAAhB,C,CAEA;;AACA,IAAIC,EAAE,GAAG,CAAC,CAAV;AAEA,MAAMC,MAAM,GAAG,uBAAf;;AAEA,SAASC,MAAT,CAAiBC,GAAjB,EAAuB;AACtB,SAAQ,GAAGF,MAAQ,IAAIE,GAAK,EAA5B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,kBAAT,CAA6BC,QAA7B,EAAwC;AACvC,MAAK,CAAEA,QAAP,EAAkB;AACjB;AACA;;AACD,MAAKP,OAAO,CAACQ,GAAR,CAAaD,QAAb,CAAL,EAA+B;AAC9B,WAAOH,MAAM,CAAEJ,OAAO,CAACS,GAAR,CAAaF,QAAb,CAAF,CAAb;AACA;;AAEDL,EAAAA,EAAE,IAAI,CAAN;AAEAF,EAAAA,OAAO,CAACU,GAAR,CAAaH,QAAb,EAAuBL,EAAvB;AAEA,SAAOE,MAAM,CAAEF,EAAF,CAAb;AACA;;eAEcI,kB","sourcesContent":["// Weakly referenced map allows unused ids to be garbage collected.\nconst weakMap = new WeakMap();\n\n// Incrementing zero-based ID value\nlet id = -1;\n\nconst prefix = 'link-control-instance';\n\nfunction getKey( _id ) {\n\treturn `${ prefix }-${ _id }`;\n}\n\n/**\n * Builds a unique link control key for the given object reference.\n *\n * @param {Object} instance an unique object reference specific to this link control instance.\n * @return {string} the unique key to use for this link control.\n */\nfunction useLinkInstanceKey( instance ) {\n\tif ( ! instance ) {\n\t\treturn;\n\t}\n\tif ( weakMap.has( instance ) ) {\n\t\treturn getKey( weakMap.get( instance ) );\n\t}\n\n\tid += 1;\n\n\tweakMap.set( instance, id );\n\n\treturn getKey( id );\n}\n\nexport default useLinkInstanceKey;\n"]}
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isValidHref = isValidHref;
7
6
  exports.createLinkFormat = createLinkFormat;
8
7
  exports.getFormatBoundary = getFormatBoundary;
8
+ exports.isValidHref = isValidHref;
9
9
 
10
10
  var _lodash = require("lodash");
11
11
 
@@ -96,12 +96,13 @@ function isValidHref(href) {
96
96
  */
97
97
 
98
98
 
99
- function createLinkFormat({
100
- url,
101
- type,
102
- id,
103
- opensInNewWindow
104
- }) {
99
+ function createLinkFormat(_ref) {
100
+ let {
101
+ url,
102
+ type,
103
+ id,
104
+ opensInNewWindow
105
+ } = _ref;
105
106
  const format = {
106
107
  type: 'core/link',
107
108
  attributes: {
@@ -134,7 +135,9 @@ function createLinkFormat({
134
135
  /* eslint-enable jsdoc/no-undefined-types */
135
136
 
136
137
 
137
- function getFormatBoundary(value, format, startIndex = value.start, endIndex = value.end) {
138
+ function getFormatBoundary(value, format) {
139
+ let startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : value.start;
140
+ let endIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : value.end;
138
141
  const EMPTY_BOUNDARIES = {
139
142
  start: null,
140
143
  end: null
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/link/utils.js"],"names":["isValidHref","href","trimmedHref","trim","test","protocol","authority","path","queryString","fragment","createLinkFormat","url","type","id","opensInNewWindow","format","attributes","target","rel","getFormatBoundary","value","startIndex","start","endIndex","end","EMPTY_BOUNDARIES","formats","targetFormat","initialIndex","length","newFormats","slice","formatAtStart","formatAtEnd","formatAtEndMinusOne","index","indexOf","walkingArgs","walkToStart","walkToEnd","walkToBoundary","targetFormatRef","formatIndex","direction","directions","forwards","backwards","directionIncrement","inverseDirectionIncrement"],"mappings":";;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAT,CAAsBC,IAAtB,EAA6B;AACnC,MAAK,CAAEA,IAAP,EAAc;AACb,WAAO,KAAP;AACA;;AAED,QAAMC,WAAW,GAAGD,IAAI,CAACE,IAAL,EAApB;;AAEA,MAAK,CAAED,WAAP,EAAqB;AACpB,WAAO,KAAP;AACA,GATkC,CAWnC;;;AACA,MAAK,QAAQE,IAAR,CAAcF,WAAd,CAAL,EAAmC;AAClC,UAAMG,QAAQ,GAAG,sBAAaH,WAAb,CAAjB;;AACA,QAAK,CAAE,0BAAiBG,QAAjB,CAAP,EAAqC;AACpC,aAAO,KAAP;AACA,KAJiC,CAMlC;AACA;;;AACA,QACC,wBAAYA,QAAZ,EAAsB,MAAtB,KACA,CAAE,uBAAuBD,IAAvB,CAA6BF,WAA7B,CAFH,EAGE;AACD,aAAO,KAAP;AACA;;AAED,UAAMI,SAAS,GAAG,uBAAcJ,WAAd,CAAlB;;AACA,QAAK,CAAE,2BAAkBI,SAAlB,CAAP,EAAuC;AACtC,aAAO,KAAP;AACA;;AAED,UAAMC,IAAI,GAAG,kBAASL,WAAT,CAAb;;AACA,QAAKK,IAAI,IAAI,CAAE,sBAAaA,IAAb,CAAf,EAAqC;AACpC,aAAO,KAAP;AACA;;AAED,UAAMC,WAAW,GAAG,yBAAgBN,WAAhB,CAApB;;AACA,QAAKM,WAAW,IAAI,CAAE,6BAAoBA,WAApB,CAAtB,EAA0D;AACzD,aAAO,KAAP;AACA;;AAED,UAAMC,QAAQ,GAAG,sBAAaP,WAAb,CAAjB;;AACA,QAAKO,QAAQ,IAAI,CAAE,0BAAiBA,QAAjB,CAAnB,EAAiD;AAChD,aAAO,KAAP;AACA;AACD,GA9CkC,CAgDnC;;;AACA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;;AACAhB,EAAAA,UAAU,GAAGA,UAAU,GAAG,CAAb,GAAiB,CAAjB,GAAqBA,UAAlC,CA1DC,CA4DD;;AACA,SAAO;AACNC,IAAAA,KAAK,EAAED,UADD;AAENG,IAAAA,GAAG,EAAED;AAFC,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASiB,cAAT,CACCd,OADD,EAECE,YAFD,EAGCa,eAHD,EAICC,WAJD,EAKCC,SALD,EAME;AACD,MAAIR,KAAK,GAAGP,YAAZ;AAEA,QAAMgB,UAAU,GAAG;AAClBC,IAAAA,QAAQ,EAAE,CADQ;AAElBC,IAAAA,SAAS,EAAE,CAAC;AAFM,GAAnB;AAKA,QAAMC,kBAAkB,GAAGH,UAAU,CAAED,SAAF,CAAV,IAA2B,CAAtD,CARC,CAQwD;;AACzD,QAAMK,yBAAyB,GAAGD,kBAAkB,GAAG,CAAC,CAAxD;;AAEA,SACCrB,OAAO,CAAES,KAAF,CAAP,IACAT,OAAO,CAAES,KAAF,CAAP,CAAkBO,WAAlB,MAAoCD,eAFrC,EAGE;AACD;AACAN,IAAAA,KAAK,GAAGA,KAAK,GAAGY,kBAAhB;AACA,GAjBA,CAmBD;AACA;;;AACAZ,EAAAA,KAAK,GAAGA,KAAK,GAAGa,yBAAhB;AAEA,SAAOb,KAAP;AACA;;AAED,MAAMG,WAAW,GAAG,0BAAcE,cAAd,EAA8B,WAA9B,CAApB;AAEA,MAAMD,SAAS,GAAG,0BAAcC,cAAd,EAA8B,UAA9B,CAAlB","sourcesContent":["/**\n * External dependencies\n */\nimport { startsWith, find, partialRight } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tgetProtocol,\n\tisValidProtocol,\n\tgetAuthority,\n\tisValidAuthority,\n\tgetPath,\n\tisValidPath,\n\tgetQueryString,\n\tisValidQueryString,\n\tgetFragment,\n\tisValidFragment,\n} from '@wordpress/url';\n\n/**\n * Check for issues with the provided href.\n *\n * @param {string} href The href.\n *\n * @return {boolean} Is the href invalid?\n */\nexport function isValidHref( href ) {\n\tif ( ! href ) {\n\t\treturn false;\n\t}\n\n\tconst trimmedHref = href.trim();\n\n\tif ( ! trimmedHref ) {\n\t\treturn false;\n\t}\n\n\t// Does the href start with something that looks like a URL protocol?\n\tif ( /^\\S+:/.test( trimmedHref ) ) {\n\t\tconst protocol = getProtocol( trimmedHref );\n\t\tif ( ! isValidProtocol( protocol ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Add some extra checks for http(s) URIs, since these are the most common use-case.\n\t\t// This ensures URIs with an http protocol have exactly two forward slashes following the protocol.\n\t\tif (\n\t\t\tstartsWith( protocol, 'http' ) &&\n\t\t\t! /^https?:\\/\\/[^\\/\\s]/i.test( trimmedHref )\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst authority = getAuthority( trimmedHref );\n\t\tif ( ! isValidAuthority( authority ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst path = getPath( trimmedHref );\n\t\tif ( path && ! isValidPath( path ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst queryString = getQueryString( trimmedHref );\n\t\tif ( queryString && ! isValidQueryString( queryString ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst fragment = getFragment( trimmedHref );\n\t\tif ( fragment && ! isValidFragment( fragment ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Validate anchor links.\n\tif ( startsWith( trimmedHref, '#' ) && ! isValidFragment( trimmedHref ) ) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Generates the format object that will be applied to the link text.\n *\n * @param {Object} options\n * @param {string} options.url The href of the link.\n * @param {string} options.type The type of the link.\n * @param {string} options.id The ID of the link.\n * @param {boolean} options.opensInNewWindow Whether this link will open in a new window.\n *\n * @return {Object} The final format object.\n */\nexport function createLinkFormat( { url, type, id, opensInNewWindow } ) {\n\tconst format = {\n\t\ttype: 'core/link',\n\t\tattributes: {\n\t\t\turl,\n\t\t},\n\t};\n\n\tif ( type ) format.attributes.type = type;\n\tif ( id ) format.attributes.id = id;\n\n\tif ( opensInNewWindow ) {\n\t\tformat.attributes.target = '_blank';\n\t\tformat.attributes.rel = 'noreferrer noopener';\n\t}\n\n\treturn format;\n}\n\n/* eslint-disable jsdoc/no-undefined-types */\n/**\n * Get the start and end boundaries of a given format from a rich text value.\n *\n *\n * @param {RichTextValue} value the rich text value to interrogate.\n * @param {string} format the identifier for the target format (e.g. `core/link`, `core/bold`).\n * @param {number?} startIndex optional startIndex to seek from.\n * @param {number?} endIndex optional endIndex to seek from.\n * @return {Object}\tobject containing start and end values for the given format.\n */\n/* eslint-enable jsdoc/no-undefined-types */\nexport function getFormatBoundary(\n\tvalue,\n\tformat,\n\tstartIndex = value.start,\n\tendIndex = value.end\n) {\n\tconst EMPTY_BOUNDARIES = {\n\t\tstart: null,\n\t\tend: null,\n\t};\n\n\tconst { formats } = value;\n\tlet targetFormat;\n\tlet initialIndex;\n\n\tif ( ! formats?.length ) {\n\t\treturn EMPTY_BOUNDARIES;\n\t}\n\n\t// Clone formats to avoid modifying source formats.\n\tconst newFormats = formats.slice();\n\n\tconst formatAtStart = find( newFormats[ startIndex ], {\n\t\ttype: format.type,\n\t} );\n\n\tconst formatAtEnd = find( newFormats[ endIndex ], {\n\t\ttype: format.type,\n\t} );\n\n\tconst formatAtEndMinusOne = find( newFormats[ endIndex - 1 ], {\n\t\ttype: format.type,\n\t} );\n\n\tif ( !! formatAtStart ) {\n\t\t// Set values to conform to \"start\"\n\t\ttargetFormat = formatAtStart;\n\t\tinitialIndex = startIndex;\n\t} else if ( !! formatAtEnd ) {\n\t\t// Set values to conform to \"end\"\n\t\ttargetFormat = formatAtEnd;\n\t\tinitialIndex = endIndex;\n\t} else if ( !! formatAtEndMinusOne ) {\n\t\t// This is an edge case which will occur if you create a format, then place\n\t\t// the caret just before the format and hit the back ARROW key. The resulting\n\t\t// value object will have start and end +1 beyond the edge of the format boundary.\n\t\ttargetFormat = formatAtEndMinusOne;\n\t\tinitialIndex = endIndex - 1;\n\t} else {\n\t\treturn EMPTY_BOUNDARIES;\n\t}\n\n\tconst index = newFormats[ initialIndex ].indexOf( targetFormat );\n\n\tconst walkingArgs = [ newFormats, initialIndex, targetFormat, index ];\n\n\t// Walk the startIndex \"backwards\" to the leading \"edge\" of the matching format.\n\tstartIndex = walkToStart( ...walkingArgs );\n\n\t// Walk the endIndex \"forwards\" until the trailing \"edge\" of the matching format.\n\tendIndex = walkToEnd( ...walkingArgs );\n\n\t// Safe guard: start index cannot be less than 0\n\tstartIndex = startIndex < 0 ? 0 : startIndex;\n\n\t// // Return the indicies of the \"edges\" as the boundaries.\n\treturn {\n\t\tstart: startIndex,\n\t\tend: endIndex,\n\t};\n}\n\n/**\n * Walks forwards/backwards towards the boundary of a given format within an\n * array of format objects. Returns the index of the boundary.\n *\n * @param {Array} formats the formats to search for the given format type.\n * @param {number} initialIndex the starting index from which to walk.\n * @param {Object} targetFormatRef a reference to the format type object being sought.\n * @param {number} formatIndex the index at which we expect the target format object to be.\n * @param {string} direction either 'forwards' or 'backwards' to indicate the direction.\n * @return {number} the index of the boundary of the given format.\n */\nfunction walkToBoundary(\n\tformats,\n\tinitialIndex,\n\ttargetFormatRef,\n\tformatIndex,\n\tdirection\n) {\n\tlet index = initialIndex;\n\n\tconst directions = {\n\t\tforwards: 1,\n\t\tbackwards: -1,\n\t};\n\n\tconst directionIncrement = directions[ direction ] || 1; // invalid direction arg default to forwards\n\tconst inverseDirectionIncrement = directionIncrement * -1;\n\n\twhile (\n\t\tformats[ index ] &&\n\t\tformats[ index ][ formatIndex ] === targetFormatRef\n\t) {\n\t\t// Increment/decrement in the direction of operation.\n\t\tindex = index + directionIncrement;\n\t}\n\n\t// Restore by one in inverse direction of operation\n\t// to avoid out of bounds.\n\tindex = index + inverseDirectionIncrement;\n\n\treturn index;\n}\n\nconst walkToStart = partialRight( walkToBoundary, 'backwards' );\n\nconst walkToEnd = partialRight( walkToBoundary, 'forwards' );\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/link/utils.js"],"names":["isValidHref","href","trimmedHref","trim","test","protocol","authority","path","queryString","fragment","createLinkFormat","url","type","id","opensInNewWindow","format","attributes","target","rel","getFormatBoundary","value","startIndex","start","endIndex","end","EMPTY_BOUNDARIES","formats","targetFormat","initialIndex","length","newFormats","slice","formatAtStart","formatAtEnd","formatAtEndMinusOne","index","indexOf","walkingArgs","walkToStart","walkToEnd","walkToBoundary","targetFormatRef","formatIndex","direction","directions","forwards","backwards","directionIncrement","inverseDirectionIncrement"],"mappings":";;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAT,CAAsBC,IAAtB,EAA6B;AACnC,MAAK,CAAEA,IAAP,EAAc;AACb,WAAO,KAAP;AACA;;AAED,QAAMC,WAAW,GAAGD,IAAI,CAACE,IAAL,EAApB;;AAEA,MAAK,CAAED,WAAP,EAAqB;AACpB,WAAO,KAAP;AACA,GATkC,CAWnC;;;AACA,MAAK,QAAQE,IAAR,CAAcF,WAAd,CAAL,EAAmC;AAClC,UAAMG,QAAQ,GAAG,sBAAaH,WAAb,CAAjB;;AACA,QAAK,CAAE,0BAAiBG,QAAjB,CAAP,EAAqC;AACpC,aAAO,KAAP;AACA,KAJiC,CAMlC;AACA;;;AACA,QACC,wBAAYA,QAAZ,EAAsB,MAAtB,KACA,CAAE,uBAAuBD,IAAvB,CAA6BF,WAA7B,CAFH,EAGE;AACD,aAAO,KAAP;AACA;;AAED,UAAMI,SAAS,GAAG,uBAAcJ,WAAd,CAAlB;;AACA,QAAK,CAAE,2BAAkBI,SAAlB,CAAP,EAAuC;AACtC,aAAO,KAAP;AACA;;AAED,UAAMC,IAAI,GAAG,kBAASL,WAAT,CAAb;;AACA,QAAKK,IAAI,IAAI,CAAE,sBAAaA,IAAb,CAAf,EAAqC;AACpC,aAAO,KAAP;AAC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AAMD,SAAS,GAAG,0BAAcC,cAAd,EAA8B,UAA9B,CAAlB","sourcesContent":["/**\n * External dependencies\n */\nimport { startsWith, find, partialRight } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tgetProtocol,\n\tisValidProtocol,\n\tgetAuthority,\n\tisValidAuthority,\n\tgetPath,\n\tisValidPath,\n\tgetQueryString,\n\tisValidQueryString,\n\tgetFragment,\n\tisValidFragment,\n} from '@wordpress/url';\n\n/**\n * Check for issues with the provided href.\n *\n * @param {string} href The href.\n *\n * @return {boolean} Is the href invalid?\n */\nexport function isValidHref( href ) {\n\tif ( ! href ) {\n\t\treturn false;\n\t}\n\n\tconst trimmedHref = href.trim();\n\n\tif ( ! trimmedHref ) {\n\t\treturn false;\n\t}\n\n\t// Does the href start with something that looks like a URL protocol?\n\tif ( /^\\S+:/.test( trimmedHref ) ) {\n\t\tconst protocol = getProtocol( trimmedHref );\n\t\tif ( ! isValidProtocol( protocol ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Add some extra checks for http(s) URIs, since these are the most common use-case.\n\t\t// This ensures URIs with an http protocol have exactly two forward slashes following the protocol.\n\t\tif (\n\t\t\tstartsWith( protocol, 'http' ) &&\n\t\t\t! /^https?:\\/\\/[^\\/\\s]/i.test( trimmedHref )\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst authority = getAuthority( trimmedHref );\n\t\tif ( ! isValidAuthority( authority ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst path = getPath( trimmedHref );\n\t\tif ( path && ! isValidPath( path ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst queryString = getQueryString( trimmedHref );\n\t\tif ( queryString && ! isValidQueryString( queryString ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst fragment = getFragment( trimmedHref );\n\t\tif ( fragment && ! isValidFragment( fragment ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Validate anchor links.\n\tif ( startsWith( trimmedHref, '#' ) && ! isValidFragment( trimmedHref ) ) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Generates the format object that will be applied to the link text.\n *\n * @param {Object} options\n * @param {string} options.url The href of the link.\n * @param {string} options.type The type of the link.\n * @param {string} options.id The ID of the link.\n * @param {boolean} options.opensInNewWindow Whether this link will open in a new window.\n *\n * @return {Object} The final format object.\n */\nexport function createLinkFormat( { url, type, id, opensInNewWindow } ) {\n\tconst format = {\n\t\ttype: 'core/link',\n\t\tattributes: {\n\t\t\turl,\n\t\t},\n\t};\n\n\tif ( type ) format.attributes.type = type;\n\tif ( id ) format.attributes.id = id;\n\n\tif ( opensInNewWindow ) {\n\t\tformat.attributes.target = '_blank';\n\t\tformat.attributes.rel = 'noreferrer noopener';\n\t}\n\n\treturn format;\n}\n\n/* eslint-disable jsdoc/no-undefined-types */\n/**\n * Get the start and end boundaries of a given format from a rich text value.\n *\n *\n * @param {RichTextValue} value the rich text value to interrogate.\n * @param {string} format the identifier for the target format (e.g. `core/link`, `core/bold`).\n * @param {number?} startIndex optional startIndex to seek from.\n * @param {number?} endIndex optional endIndex to seek from.\n * @return {Object}\tobject containing start and end values for the given format.\n */\n/* eslint-enable jsdoc/no-undefined-types */\nexport function getFormatBoundary(\n\tvalue,\n\tformat,\n\tstartIndex = value.start,\n\tendIndex = value.end\n) {\n\tconst EMPTY_BOUNDARIES = {\n\t\tstart: null,\n\t\tend: null,\n\t};\n\n\tconst { formats } = value;\n\tlet targetFormat;\n\tlet initialIndex;\n\n\tif ( ! formats?.length ) {\n\t\treturn EMPTY_BOUNDARIES;\n\t}\n\n\t// Clone formats to avoid modifying source formats.\n\tconst newFormats = formats.slice();\n\n\tconst formatAtStart = find( newFormats[ startIndex ], {\n\t\ttype: format.type,\n\t} );\n\n\tconst formatAtEnd = find( newFormats[ endIndex ], {\n\t\ttype: format.type,\n\t} );\n\n\tconst formatAtEndMinusOne = find( newFormats[ endIndex - 1 ], {\n\t\ttype: format.type,\n\t} );\n\n\tif ( !! formatAtStart ) {\n\t\t// Set values to conform to \"start\"\n\t\ttargetFormat = formatAtStart;\n\t\tinitialIndex = startIndex;\n\t} else if ( !! formatAtEnd ) {\n\t\t// Set values to conform to \"end\"\n\t\ttargetFormat = formatAtEnd;\n\t\tinitialIndex = endIndex;\n\t} else if ( !! formatAtEndMinusOne ) {\n\t\t// This is an edge case which will occur if you create a format, then place\n\t\t// the caret just before the format and hit the back ARROW key. The resulting\n\t\t// value object will have start and end +1 beyond the edge of the format boundary.\n\t\ttargetFormat = formatAtEndMinusOne;\n\t\tinitialIndex = endIndex - 1;\n\t} else {\n\t\treturn EMPTY_BOUNDARIES;\n\t}\n\n\tconst index = newFormats[ initialIndex ].indexOf( targetFormat );\n\n\tconst walkingArgs = [ newFormats, initialIndex, targetFormat, index ];\n\n\t// Walk the startIndex \"backwards\" to the leading \"edge\" of the matching format.\n\tstartIndex = walkToStart( ...walkingArgs );\n\n\t// Walk the endIndex \"forwards\" until the trailing \"edge\" of the matching format.\n\tendIndex = walkToEnd( ...walkingArgs );\n\n\t// Safe guard: start index cannot be less than 0\n\tstartIndex = startIndex < 0 ? 0 : startIndex;\n\n\t// // Return the indicies of the \"edges\" as the boundaries.\n\treturn {\n\t\tstart: startIndex,\n\t\tend: endIndex,\n\t};\n}\n\n/**\n * Walks forwards/backwards towards the boundary of a given format within an\n * array of format objects. Returns the index of the boundary.\n *\n * @param {Array} formats the formats to search for the given format type.\n * @param {number} initialIndex the starting index from which to walk.\n * @param {Object} targetFormatRef a reference to the format type object being sought.\n * @param {number} formatIndex the index at which we expect the target format object to be.\n * @param {string} direction either 'forwards' or 'backwards' to indicate the direction.\n * @return {number} the index of the boundary of the given format.\n */\nfunction walkToBoundary(\n\tformats,\n\tinitialIndex,\n\ttargetFormatRef,\n\tformatIndex,\n\tdirection\n) {\n\tlet index = initialIndex;\n\n\tconst directions = {\n\t\tforwards: 1,\n\t\tbackwards: -1,\n\t};\n\n\tconst directionIncrement = directions[ direction ] || 1; // invalid direction arg default to forwards\n\tconst inverseDirectionIncrement = directionIncrement * -1;\n\n\twhile (\n\t\tformats[ index ] &&\n\t\tformats[ index ][ formatIndex ] === targetFormatRef\n\t) {\n\t\t// Increment/decrement in the direction of operation.\n\t\tindex = index + directionIncrement;\n\t}\n\n\t// Restore by one in inverse direction of operation\n\t// to avoid out of bounds.\n\tindex = index + inverseDirectionIncrement;\n\n\treturn index;\n}\n\nconst walkToStart = partialRight( walkToBoundary, 'backwards' );\n\nconst walkToEnd = partialRight( walkToBoundary, 'forwards' );\n"]}
@@ -26,12 +26,14 @@ const strikethrough = {
26
26
  tagName: 's',
27
27
  className: null,
28
28
 
29
- edit({
30
- isActive,
31
- value,
32
- onChange,
33
- onFocus
34
- }) {
29
+ edit(_ref) {
30
+ let {
31
+ isActive,
32
+ value,
33
+ onChange,
34
+ onFocus
35
+ } = _ref;
36
+
35
37
  function onClick() {
36
38
  onChange((0, _richText.toggleFormat)(value, {
37
39
  type: name,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/strikethrough/index.js"],"names":["name","title","strikethrough","tagName","className","edit","isActive","value","onChange","onFocus","onClick","type","formatStrikethrough"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,oBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,eAAJ,CAAd;AAEO,MAAMC,aAAa,GAAG;AAC5BF,EAAAA,IAD4B;AAE5BC,EAAAA,KAF4B;AAG5BE,EAAAA,OAAO,EAAE,GAHmB;AAI5BC,EAAAA,SAAS,EAAE,IAJiB;;AAK5BC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,OAAT,GAAmB;AAClBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACAQ,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGG,0BADR;AAEC,MAAA,KAAK,EAAGX,KAFT;AAGC,MAAA,OAAO,EAAGS,OAHX;AAIC,MAAA,QAAQ,EAAGJ,QAJZ;AAKC,MAAA,IAAI,EAAC;AALN,MADD;AASA;;AApB2B,CAAtB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { formatStrikethrough } from '@wordpress/icons';\n\nconst name = 'core/strikethrough';\nconst title = __( 'Strikethrough' );\n\nexport const strikethrough = {\n\tname,\n\ttitle,\n\ttagName: 's',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onClick() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ formatStrikethrough }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/strikethrough/index.js"],"names":["name","title","strikethrough","tagName","className","edit","isActive","value","onChange","onFocus","onClick","type","formatStrikethrough"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,oBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,eAAJ,CAAd;AAEO,MAAMC,aAAa,GAAG;AAC5BF,EAAAA,IAD4B;AAE5BC,EAAAA,KAF4B;AAG5BE,EAAAA,OAAO,EAAE,GAHmB;AAI5BC,EAAAA,SAAS,EAAE,IAJiB;;AAK5BC,EAAAA,IAAI,OAA2C;AAAA,QAAzC;AAAEC,MAAAA,QAAF;AAAYC,MAAAA,KAAZ;AAAmBC,MAAAA,QAAnB;AAA6BC,MAAAA;AAA7B,KAAyC;;AAC9C,aAASC,OAAT,GAAmB;AAClBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACAQ,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGG,0BADR;AAEC,MAAA,KAAK,EAAGX,KAFT;AAGC,MAAA,OAAO,EAAGS,OAHX;AAIC,MAAA,QAAQ,EAAGJ,QAJZ;AAKC,MAAA,IAAI,EAAC;AALN,MADD;AASA;;AApB2B,CAAtB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { formatStrikethrough } from '@wordpress/icons';\n\nconst name = 'core/strikethrough';\nconst title = __( 'Strikethrough' );\n\nexport const strikethrough = {\n\tname,\n\ttitle,\n\ttagName: 's',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onClick() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ formatStrikethrough }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
@@ -26,12 +26,14 @@ const subscript = {
26
26
  tagName: 'sub',
27
27
  className: null,
28
28
 
29
- edit({
30
- isActive,
31
- value,
32
- onChange,
33
- onFocus
34
- }) {
29
+ edit(_ref) {
30
+ let {
31
+ isActive,
32
+ value,
33
+ onChange,
34
+ onFocus
35
+ } = _ref;
36
+
35
37
  function onToggle() {
36
38
  onChange((0, _richText.toggleFormat)(value, {
37
39
  type: name,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/subscript/index.js"],"names":["name","title","subscript","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","subscriptIcon"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,gBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,WAAJ,CAAd;AAEO,MAAMC,SAAS,GAAG;AACxBF,EAAAA,IADwB;AAExBC,EAAAA,KAFwB;AAGxBE,EAAAA,OAAO,EAAE,KAHe;AAIxBC,EAAAA,SAAS,EAAE,IAJa;;AAKxBC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACA;;AAED,aAASW,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGI,gBADR;AAEC,MAAA,KAAK,EAAGZ,KAFT;AAGC,MAAA,OAAO,EAAGW,OAHX;AAIC,MAAA,QAAQ,EAAGN,QAJZ;AAKC,MAAA,IAAI,EAAC;AALN,MADD;AASA;;AAxBuB,CAAlB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { subscript as subscriptIcon } from '@wordpress/icons';\n\nconst name = 'core/subscript';\nconst title = __( 'Subscript' );\n\nexport const subscript = {\n\tname,\n\ttitle,\n\ttagName: 'sub',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ subscriptIcon }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/subscript/index.js"],"names":["name","title","subscript","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","subscriptIcon"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,gBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,WAAJ,CAAd;AAEO,MAAMC,SAAS,GAAG;AACxBF,EAAAA,IADwB;AAExBC,EAAAA,KAFwB;AAGxBE,EAAAA,OAAO,EAAE,KAHe;AAIxBC,EAAAA,SAAS,EAAE,IAJa;;AAKxBC,EAAAA,IAAI,OAA2C;AAAA,QAAzC;AAAEC,MAAAA,QAAF;AAAYC,MAAAA,KAAZ;AAAmBC,MAAAA,QAAnB;AAA6BC,MAAAA;AAA7B,KAAyC;;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACA;;AAED,aAASW,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGI,gBADR;AAEC,MAAA,KAAK,EAAGZ,KAFT;AAGC,MAAA,OAAO,EAAGW,OAHX;AAIC,MAAA,QAAQ,EAAGN,QAJZ;AAKC,MAAA,IAAI,EAAC;AALN,MADD;AASA;;AAxBuB,CAAlB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { subscript as subscriptIcon } from '@wordpress/icons';\n\nconst name = 'core/subscript';\nconst title = __( 'Subscript' );\n\nexport const subscript = {\n\tname,\n\ttitle,\n\ttagName: 'sub',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ subscriptIcon }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
@@ -26,12 +26,14 @@ const superscript = {
26
26
  tagName: 'sup',
27
27
  className: null,
28
28
 
29
- edit({
30
- isActive,
31
- value,
32
- onChange,
33
- onFocus
34
- }) {
29
+ edit(_ref) {
30
+ let {
31
+ isActive,
32
+ value,
33
+ onChange,
34
+ onFocus
35
+ } = _ref;
36
+
35
37
  function onToggle() {
36
38
  onChange((0, _richText.toggleFormat)(value, {
37
39
  type: name,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/superscript/index.js"],"names":["name","title","superscript","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","superscriptIcon"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,kBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,aAAJ,CAAd;AAEO,MAAMC,WAAW,GAAG;AAC1BF,EAAAA,IAD0B;AAE1BC,EAAAA,KAF0B;AAG1BE,EAAAA,OAAO,EAAE,KAHiB;AAI1BC,EAAAA,SAAS,EAAE,IAJe;;AAK1BC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACA;;AAED,aAASW,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGI,kBADR;AAEC,MAAA,KAAK,EAAGZ,KAFT;AAGC,MAAA,OAAO,EAAGW,OAHX;AAIC,MAAA,QAAQ,EAAGN,QAJZ;AAKC,MAAA,IAAI,EAAC;AALN,MADD;AASA;;AAxByB,CAApB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { superscript as superscriptIcon } from '@wordpress/icons';\n\nconst name = 'core/superscript';\nconst title = __( 'Superscript' );\n\nexport const superscript = {\n\tname,\n\ttitle,\n\ttagName: 'sup',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ superscriptIcon }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/superscript/index.js"],"names":["name","title","superscript","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","superscriptIcon"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,kBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,aAAJ,CAAd;AAEO,MAAMC,WAAW,GAAG;AAC1BF,EAAAA,IAD0B;AAE1BC,EAAAA,KAF0B;AAG1BE,EAAAA,OAAO,EAAE,KAHiB;AAI1BC,EAAAA,SAAS,EAAE,IAJe;;AAK1BC,EAAAA,IAAI,OAA2C;AAAA,QAAzC;AAAEC,MAAAA,QAAF;AAAYC,MAAAA,KAAZ;AAAmBC,MAAAA,QAAnB;AAA6BC,MAAAA;AAA7B,KAAyC;;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACA;;AAED,aAASW,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGI,kBADR;AAEC,MAAA,KAAK,EAAGZ,KAFT;AAGC,MAAA,OAAO,EAAGW,OAHX;AAIC,MAAA,QAAQ,EAAGN,QAJZ;AAKC,MAAA,IAAI,EAAC;AALN,MADD;AASA;;AAxByB,CAApB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { superscript as superscriptIcon } from '@wordpress/icons';\n\nconst name = 'core/superscript';\nconst title = __( 'Superscript' );\n\nexport const superscript = {\n\tname,\n\ttitle,\n\ttagName: 'sup',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ superscriptIcon }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -21,6 +19,10 @@ var _richText = require("@wordpress/rich-text");
21
19
 
22
20
  var _inline = _interopRequireWildcard(require("./inline"));
23
21
 
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+
24
26
  /**
25
27
  * External dependencies
26
28
  */
@@ -53,10 +55,12 @@ function getComputedStyleProperty(element, property) {
53
55
  return value;
54
56
  }
55
57
 
56
- function fillComputedColors(element, {
57
- color,
58
- backgroundColor
59
- }) {
58
+ function fillComputedColors(element, _ref) {
59
+ let {
60
+ color,
61
+ backgroundColor
62
+ } = _ref;
63
+
60
64
  if (!color && !backgroundColor) {
61
65
  return;
62
66
  }
@@ -67,13 +71,14 @@ function fillComputedColors(element, {
67
71
  };
68
72
  }
69
73
 
70
- function TextColorEdit({
71
- value,
72
- onChange,
73
- isActive,
74
- activeAttributes,
75
- contentRef
76
- }) {
74
+ function TextColorEdit(_ref2) {
75
+ let {
76
+ value,
77
+ onChange,
78
+ isActive,
79
+ activeAttributes,
80
+ contentRef
81
+ } = _ref2;
77
82
  const allowCustomControl = (0, _blockEditor.useSetting)('color.custom');
78
83
  const colors = (0, _blockEditor.useSetting)('color.palette') || EMPTY_ARRAY;
79
84
  const [isAddingColor, setIsAddingColor] = (0, _element.useState)(false);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/text-color/index.js"],"names":["name","title","EMPTY_ARRAY","getComputedStyleProperty","element","property","ownerDocument","defaultView","style","getComputedStyle","value","getPropertyValue","parentElement","fillComputedColors","color","backgroundColor","TextColorEdit","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","enableIsAddingColor","disableIsAddingColor","colorIndicatorStyle","current","hasColorsToChoose","textColorIcon","textColor","tagName","className","attributes","class","__unstableFilterAttributeValue","key","includes","addedCSS","join","edit"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AAKA;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AAGA,MAAMA,IAAI,GAAG,iBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,WAAJ,CAAd;AAEA,MAAMC,WAAW,GAAG,EAApB;;AAEA,SAAS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C,EAAAA,SAAS,EAAE,kBAJa;AAKxBC,EAAAA,UAAU,EAAE;AACX1B,IAAAA,KAAK,EAAE,OADI;AAEX2B,IAAAA,KAAK,EAAE;AAFI,GALY;;AASxB;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACCC,EAAAA,8BAA8B,CAAEC,GAAF,EAAO3B,KAAP,EAAe;AAC5C,QAAK2B,GAAG,KAAK,OAAb,EAAuB,OAAO3B,KAAP,CADqB,CAE5C;;AACA,QAAKA,KAAK,IAAIA,KAAK,CAAC4B,QAAN,CAAgB,kBAAhB,CAAd,EAAqD,OAAO5B,KAAP;AACrD,UAAM6B,QAAQ,GAAG,CAAE,kBAAF,EAAsB,kBAAtB,EAA2CC,IAA3C,CAAiD,GAAjD,CAAjB,CAJ4C,CAK5C;AACA;;AACA,WAAO9B,KAAK,GAAG,CAAE6B,QAAF,EAAY7B,KAAZ,EAAoB8B,IAApB,CAA0B,GAA1B,CAAH,GAAqCD,QAAjD;AACA,GA1BuB;;AA2BxBE,EAAAA,IAAI,EAAEzB;AA3BkB,CAAlB","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useMemo, useState } from '@wordpress/element';\nimport { RichTextToolbarButton, useSetting } from '@wordpress/block-editor';\nimport { Icon, textColor as textColorIcon } from '@wordpress/icons';\nimport { removeFormat } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { default as InlineColorUI, getActiveColors } from './inline';\n\nconst name = 'core/text-color';\nconst title = __( 'Highlight' );\n\nconst EMPTY_ARRAY = [];\n\nfunction getComputedStyleProperty( element, property ) {\n\tconst { ownerDocument } = element;\n\tconst { defaultView } = ownerDocument;\n\tconst style = defaultView.getComputedStyle( element );\n\tconst value = style.getPropertyValue( property );\n\n\tif (\n\t\tproperty === 'background-color' &&\n\t\tvalue === 'rgba(0, 0, 0, 0)' &&\n\t\telement.parentElement\n\t) {\n\t\treturn getComputedStyleProperty( element.parentElement, property );\n\t}\n\n\treturn value;\n}\n\nfunction fillComputedColors( element, { color, backgroundColor } ) {\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tcolor: color || getComputedStyleProperty( element, 'color' ),\n\t\tbackgroundColor:\n\t\t\tbackgroundColor === 'rgba(0, 0, 0, 0)'\n\t\t\t\t? getComputedStyleProperty( element, 'background-color' )\n\t\t\t\t: backgroundColor,\n\t};\n}\n\nfunction TextColorEdit( {\n\tvalue,\n\tonChange,\n\tisActive,\n\tactiveAttributes,\n\tcontentRef,\n} ) {\n\tconst allowCustomControl = useSetting( 'color.custom' );\n\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\n\tconst enableIsAddingColor = useCallback( () => setIsAddingColor( true ), [\n\t\tsetIsAddingColor,\n\t] );\n\tconst disableIsAddingColor = useCallback( () => setIsAddingColor( false ), [\n\t\tsetIsAddingColor,\n\t] );\n\tconst colorIndicatorStyle = useMemo(\n\t\t() =>\n\t\t\tfillComputedColors(\n\t\t\t\tcontentRef.current,\n\t\t\t\tgetActiveColors( value, name, colors )\n\t\t\t),\n\t\t[ value, colors ]\n\t);\n\n\tconst hasColorsToChoose = ! isEmpty( colors ) || ! allowCustomControl;\n\tif ( ! hasColorsToChoose && ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<RichTextToolbarButton\n\t\t\t\tclassName=\"format-library-text-color-button\"\n\t\t\t\tisActive={ isActive }\n\t\t\t\ticon={\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ textColorIcon }\n\t\t\t\t\t\tstyle={ colorIndicatorStyle }\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\ttitle={ title }\n\t\t\t\t// If has no colors to choose but a color is active remove the color onClick\n\t\t\t\tonClick={\n\t\t\t\t\thasColorsToChoose\n\t\t\t\t\t\t? enableIsAddingColor\n\t\t\t\t\t\t: () => onChange( removeFormat( value, name ) )\n\t\t\t\t}\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t\t{ isAddingColor && (\n\t\t\t\t<InlineColorUI\n\t\t\t\t\tname={ name }\n\t\t\t\t\tonClose={ disableIsAddingColor }\n\t\t\t\t\tactiveAttributes={ activeAttributes }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const textColor = {\n\tname,\n\ttitle,\n\ttagName: 'mark',\n\tclassName: 'has-inline-color',\n\tattributes: {\n\t\tstyle: 'style',\n\t\tclass: 'class',\n\t},\n\t/*\n\t * Since this format relies on the <mark> tag, it's important to\n\t * prevent the default yellow background color applied by most\n\t * browsers. The solution is to detect when this format is used with a\n\t * text color but no background color, and in such cases to override\n\t * the default styling with a transparent background.\n\t *\n\t * @see https://github.com/WordPress/gutenberg/pull/35516\n\t */\n\t__unstableFilterAttributeValue( key, value ) {\n\t\tif ( key !== 'style' ) return value;\n\t\t// We should not add a background-color if it's already set\n\t\tif ( value && value.includes( 'background-color' ) ) return value;\n\t\tconst addedCSS = [ 'background-color', 'rgba(0, 0, 0, 0)' ].join( ':' );\n\t\t// Prepend `addedCSS` to avoid a double `;;` as any the existing CSS\n\t\t// rules will already include a `;`.\n\t\treturn value ? [ addedCSS, value ].join( ';' ) : addedCSS;\n\t},\n\tedit: TextColorEdit,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/text-color/index.js"],"names":["name","title","EMPTY_ARRAY","getComputedStyleProperty","element","property","ownerDocument","defaultView","style","getComputedStyle","value","getPropertyValue","parentElement","fillComputedColors","color","backgroundColor","TextColorEdit","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","enableIsAddingColor","disableIsAddingColor","colorIndicatorStyle","current","hasColorsToChoose","textColorIcon","textColor","tagName","className","attributes","class","__unstableFilterAttributeValue","key","includes","addedCSS","join","edit"],"mappings":";;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AAKA;;;;;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AAGA,MAAMA,IAAI,GAAG,iBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,WAAJ,CAAd;AAEA,MAAMC,WAAW,GAAG,EAApB;;AAEA,SAASC,wBAAT,CAAmCC,OAAnC,EAA4CC,QAA5C,EAAuD;AACtD,QAAM;AAAEC,IAAAA;AAAF,MAAoBF,OAA1B;AACA,QAAM;AAAEG,IAAAA;AAAF,MAAkBD,aAAxB;AACA,QAAME,KAAK,GAAGD,WAAW,CAACE,gBAAZ,CAA8BL,OAA9B,CAAd;AACA,QAAMM,KAAK,GAAGF,KAAK,CAACG,gBAAN,CAAwBN,QAAxB,CAAd;;AAEA,MACCA,QAAQ,KAAK,kBAAb,IACAK,KAAK,KAAK,kBADV,IAEAN,OAAO,CAACQ,aAHT,EAIE;AACD,WAAOT,wBAAwB,CAAEC,OAAO,CAACQ,aAAV,EAAyBP,QAAzB,CAA/B;AACA;;AAED,SAAOK,KAAP;AACA;;AAED,SAASG,kBAAT,CAA6BT,OAA7B,QAAmE;AAAA,MAA7B;AAAEU,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAA6B;;AAClE,MAAK,CAAED,KAAF,IAAW,CAAEC,eAAlB,EAAoC;AACnC;AACA;;AAED,SAAO;AACND,IAAAA,KAAK,EAAEA,KAAK,IAAIX,wBAAwB,CAAEC,OAAF,EAAW,OAAX,CADlC;AAENW,IAAAA,eAAe,EACdA,eAAe,KAAK,kBAApB,GACGZ,wBAAwB,CAAEC,OAAF,EAAW,kBAAX,CAD3B,GAEGW;AALE,GAAP;AAOA;;AAED,SAASC,aAAT,QAMI;AAAA,MANoB;AACvBN,IAAAA,KADuB;AAEvBO,IAAAA,QAFuB;AAGvBC,I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AAA,IAAI,EAAGvB,IADR;AAEC,IAAA,OAAO,EAAG0B,oBAFX;AAGC,IAAA,gBAAgB,EAAGP,gBAHpB;AAIC,IAAA,KAAK,EAAGT,KAJT;AAKC,IAAA,QAAQ,EAAGO,QALZ;AAMC,IAAA,UAAU,EAAGG;AANd,IApBF,CADD;AAgCA;;AAEM,MAAMW,SAAS,GAAG;AACxB/B,EAAAA,IADwB;AAExBC,EAAAA,KAFwB;AAGxB+B,EAAAA,OAAO,EAAE,MAHe;AAIxBC,EAAAA,SAAS,EAAE,kBAJa;AAKxBC,EAAAA,UAAU,EAAE;AACX1B,IAAAA,KAAK,EAAE,OADI;AAEX2B,IAAAA,KAAK,EAAE;AAFI,GALY;;AASxB;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACCC,EAAAA,8BAA8B,CAAEC,GAAF,EAAO3B,KAAP,EAAe;AAC5C,QAAK2B,GAAG,KAAK,OAAb,EAAuB,OAAO3B,KAAP,CADqB,CAE5C;;AACA,QAAKA,KAAK,IAAIA,KAAK,CAAC4B,QAAN,CAAgB,kBAAhB,CAAd,EAAqD,OAAO5B,KAAP;AACrD,UAAM6B,QAAQ,GAAG,CAAE,kBAAF,EAAsB,kBAAtB,EAA2CC,IAA3C,CAAiD,GAAjD,CAAjB,CAJ4C,CAK5C;AACA;;AACA,WAAO9B,KAAK,GAAG,CAAE6B,QAAF,EAAY7B,KAAZ,EAAoB8B,IAApB,CAA0B,GAA1B,CAAH,GAAqCD,QAAjD;AACA,GA1BuB;;AA2BxBE,EAAAA,IAAI,EAAEzB;AA3BkB,CAAlB","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useMemo, useState } from '@wordpress/element';\nimport { RichTextToolbarButton, useSetting } from '@wordpress/block-editor';\nimport { Icon, textColor as textColorIcon } from '@wordpress/icons';\nimport { removeFormat } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { default as InlineColorUI, getActiveColors } from './inline';\n\nconst name = 'core/text-color';\nconst title = __( 'Highlight' );\n\nconst EMPTY_ARRAY = [];\n\nfunction getComputedStyleProperty( element, property ) {\n\tconst { ownerDocument } = element;\n\tconst { defaultView } = ownerDocument;\n\tconst style = defaultView.getComputedStyle( element );\n\tconst value = style.getPropertyValue( property );\n\n\tif (\n\t\tproperty === 'background-color' &&\n\t\tvalue === 'rgba(0, 0, 0, 0)' &&\n\t\telement.parentElement\n\t) {\n\t\treturn getComputedStyleProperty( element.parentElement, property );\n\t}\n\n\treturn value;\n}\n\nfunction fillComputedColors( element, { color, backgroundColor } ) {\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tcolor: color || getComputedStyleProperty( element, 'color' ),\n\t\tbackgroundColor:\n\t\t\tbackgroundColor === 'rgba(0, 0, 0, 0)'\n\t\t\t\t? getComputedStyleProperty( element, 'background-color' )\n\t\t\t\t: backgroundColor,\n\t};\n}\n\nfunction TextColorEdit( {\n\tvalue,\n\tonChange,\n\tisActive,\n\tactiveAttributes,\n\tcontentRef,\n} ) {\n\tconst allowCustomControl = useSetting( 'color.custom' );\n\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\n\tconst enableIsAddingColor = useCallback( () => setIsAddingColor( true ), [\n\t\tsetIsAddingColor,\n\t] );\n\tconst disableIsAddingColor = useCallback( () => setIsAddingColor( false ), [\n\t\tsetIsAddingColor,\n\t] );\n\tconst colorIndicatorStyle = useMemo(\n\t\t() =>\n\t\t\tfillComputedColors(\n\t\t\t\tcontentRef.current,\n\t\t\t\tgetActiveColors( value, name, colors )\n\t\t\t),\n\t\t[ value, colors ]\n\t);\n\n\tconst hasColorsToChoose = ! isEmpty( colors ) || ! allowCustomControl;\n\tif ( ! hasColorsToChoose && ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<RichTextToolbarButton\n\t\t\t\tclassName=\"format-library-text-color-button\"\n\t\t\t\tisActive={ isActive }\n\t\t\t\ticon={\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ textColorIcon }\n\t\t\t\t\t\tstyle={ colorIndicatorStyle }\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\ttitle={ title }\n\t\t\t\t// If has no colors to choose but a color is active remove the color onClick\n\t\t\t\tonClick={\n\t\t\t\t\thasColorsToChoose\n\t\t\t\t\t\t? enableIsAddingColor\n\t\t\t\t\t\t: () => onChange( removeFormat( value, name ) )\n\t\t\t\t}\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t\t{ isAddingColor && (\n\t\t\t\t<InlineColorUI\n\t\t\t\t\tname={ name }\n\t\t\t\t\tonClose={ disableIsAddingColor }\n\t\t\t\t\tactiveAttributes={ activeAttributes }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const textColor = {\n\tname,\n\ttitle,\n\ttagName: 'mark',\n\tclassName: 'has-inline-color',\n\tattributes: {\n\t\tstyle: 'style',\n\t\tclass: 'class',\n\t},\n\t/*\n\t * Since this format relies on the <mark> tag, it's important to\n\t * prevent the default yellow background color applied by most\n\t * browsers. The solution is to detect when this format is used with a\n\t * text color but no background color, and in such cases to override\n\t * the default styling with a transparent background.\n\t *\n\t * @see https://github.com/WordPress/gutenberg/pull/35516\n\t */\n\t__unstableFilterAttributeValue( key, value ) {\n\t\tif ( key !== 'style' ) return value;\n\t\t// We should not add a background-color if it's already set\n\t\tif ( value && value.includes( 'background-color' ) ) return value;\n\t\tconst addedCSS = [ 'background-color', 'rgba(0, 0, 0, 0)' ].join( ':' );\n\t\t// Prepend `addedCSS` to avoid a double `;;` as any the existing CSS\n\t\t// rules will already include a `;`.\n\t\treturn value ? [ addedCSS, value ].join( ';' ) : addedCSS;\n\t},\n\tedit: TextColorEdit,\n};\n"]}
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getActiveColors = getActiveColors;
7
6
  exports.default = InlineColorUI;
7
+ exports.getActiveColors = getActiveColors;
8
8
 
9
9
  var _element = require("@wordpress/element");
10
10
 
@@ -33,7 +33,8 @@ var _index = require("./index");
33
33
  /**
34
34
  * Internal dependencies
35
35
  */
36
- function parseCSS(css = '') {
36
+ function parseCSS() {
37
+ let css = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
37
38
  return css.split(';').reduce((accumulator, rule) => {
38
39
  if (rule) {
39
40
  const [property, value] = rule.split(':');
@@ -45,7 +46,9 @@ function parseCSS(css = '') {
45
46
  }, {});
46
47
  }
47
48
 
48
- function parseClassName(className = '', colorSettings) {
49
+ function parseClassName() {
50
+ let className = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
51
+ let colorSettings = arguments.length > 1 ? arguments[1] : undefined;
49
52
  return className.split(' ').reduce((accumulator, name) => {
50
53
  const match = name.match(/^has-([^-]+)-color$/);
51
54
 
@@ -112,12 +115,13 @@ function setColors(value, name, colorSettings, colors) {
112
115
  });
113
116
  }
114
117
 
115
- function ColorPicker({
116
- name,
117
- property,
118
- value,
119
- onChange
120
- }) {
118
+ function ColorPicker(_ref) {
119
+ let {
120
+ name,
121
+ property,
122
+ value,
123
+ onChange
124
+ } = _ref;
121
125
  const colors = (0, _data.useSelect)(select => {
122
126
  const {
123
127
  getSettings
@@ -136,13 +140,15 @@ function ColorPicker({
136
140
  });
137
141
  }
138
142
 
139
- function InlineColorUI({
140
- name,
141
- value,
142
- onChange,
143
- onClose,
144
- contentRef
145
- }) {
143
+ function InlineColorUI(_ref2) {
144
+ let {
145
+ name,
146
+ value,
147
+ onChange,
148
+ onClose,
149
+ contentRef
150
+ } = _ref2;
151
+
146
152
  /*
147
153
  As you change the text color by typing a HEX value into a field,
148
154
  the return value of document.getSelection jumps to the field you're editing,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/text-color/inline.js"],"names":["parseCSS","css","split","reduce","accumulator","rule","property","value","color","backgroundColor","parseClassName","className","colorSettings","name","match","colorSlug","colorObject","getActiveColors","activeColorFormat","attributes","style","class","setColors","colors","styles","classNames","push","join","slug","length","type","ColorPicker","onChange","select","getSettings","blockEditorStore","onColorChange","activeColors","InlineColorUI","onClose","contentRef","anchorRef","ref","settings","title","tab"],"mappings":";;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AAMA;;AAQA;;AACA;;AAKA;;AA9BA;AACA;AACA;;AAGA;AACA;AACA;;AAoBA;AACA;AACA;AAGA,SAASA,QAAT,CAAmBC,GAAG,GAAG,EAAzB,EAA8B;AAC7B,SAAOA,GAAG,CAACC,KAAJ,CAAW,GAAX,EAAiBC,MAAjB,CAAyB,CAAEC,WAAF,EAAeC,IAAf,KAAyB;AACxD,QAAKA,IAAL,EAAY;AACX,YAAM,CAAEC,QAAF,EAAYC,KAAZ,IAAsBF,IAAI,CAACH,KAAL,CAAY,GAAZ,CAA5B;AACA,UAAKI,QAAQ,KAAK,OAAlB,EAA4BF,WAAW,CAACI,KAAZ,GAAoBD,KAApB;AAC5B,UAAKD,QAAQ,KAAK,kBAAlB,EACCF,WAAW,CAACK,eAAZ,GAA8BF,KAA9B;AACD;;AACD,WAAOH,WAAP;AACA,GARM,EAQJ,EARI,CAAP;AASA;;AAED,SAASM,cAAT,CAAyBC,SAAS,GAAG,EAArC,EAAyCC,aAAzC,EAAyD;AACxD,SAAOD,SAAS,CAACT,KAAV,CAAiB,GAAjB,EAAuBC,MAAvB,CAA+B,CAAEC,WAAF,EAAeS,IAAf,KAAyB;AAC9D,UAAMC,KAAK,GAAGD,IAAI,CAACC,KAAL,CAAY,qBAAZ,CAAd;;AACA,QAAKA,KAAL,EAAa;AACZ,YAAM,GAAIC,SAAJ,IAAkBF,IAAI,CAACC,KAAL,CAA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AA6BA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchorRef,\n} from '@wordpress/rich-text';\nimport {\n\tColorPalette,\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tstore as blockEditorStore,\n\tuseCachedTruthy,\n} from '@wordpress/block-editor';\nimport { Popover, TabPanel } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings } from './index';\n\nfunction parseCSS( css = '' ) {\n\treturn css.split( ';' ).reduce( ( accumulator, rule ) => {\n\t\tif ( rule ) {\n\t\t\tconst [ property, value ] = rule.split( ':' );\n\t\t\tif ( property === 'color' ) accumulator.color = value;\n\t\t\tif ( property === 'background-color' )\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nfunction parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\tconst match = name.match( /^has-([^-]+)-color$/ );\n\t\tif ( match ) {\n\t\t\tconst [ , colorSlug ] = name.match( /^has-([^-]+)-color$/ );\n\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\tcolorSettings,\n\t\t\t\tcolorSlug\n\t\t\t);\n\t\t\taccumulator.color = colorObject.color;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function getActiveColors( value, name, colorSettings ) {\n\tconst activeColorFormat = getActiveFormat( value, name );\n\n\tif ( ! activeColorFormat ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t...parseCSS( activeColorFormat.attributes.style ),\n\t\t...parseClassName( activeColorFormat.attributes.class, colorSettings ),\n\t};\n}\n\nfunction setColors( value, name, colorSettings, colors ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn removeFormat( value, name );\n\t}\n\n\tconst styles = [];\n\tconst classNames = [];\n\tconst attributes = {};\n\n\tif ( backgroundColor ) {\n\t\tstyles.push( [ 'background-color', backgroundColor ].join( ':' ) );\n\t} else {\n\t\t// Override default browser color for mark element.\n\t\tstyles.push( [ 'background-color', 'rgba(0, 0, 0, 0)' ].join( ':' ) );\n\t}\n\n\tif ( color ) {\n\t\tconst colorObject = getColorObjectByColorValue( colorSettings, color );\n\n\t\tif ( colorObject ) {\n\t\t\tclassNames.push( getColorClassName( 'color', colorObject.slug ) );\n\t\t} else {\n\t\t\tstyles.push( [ 'color', color ].join( ':' ) );\n\t\t}\n\t}\n\n\tif ( styles.length ) attributes.style = styles.join( ';' );\n\tif ( classNames.length ) attributes.class = classNames.join( ' ' );\n\n\treturn applyFormat( value, { type: name, attributes } );\n}\n\nfunction ColorPicker( { name, property, value, onChange } ) {\n\tconst colors = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn get( getSettings(), [ 'colors' ], [] );\n\t}, [] );\n\tconst onColorChange = useCallback(\n\t\t( color ) => {\n\t\t\tonChange(\n\t\t\t\tsetColors( value, name, colors, { [ property ]: color } )\n\t\t\t);\n\t\t},\n\t\t[ colors, onChange, property ]\n\t);\n\tconst activeColors = useMemo(\n\t\t() => getActiveColors( value, name, colors ),\n\t\t[ name, value, colors ]\n\t);\n\n\treturn (\n\t\t<ColorPalette\n\t\t\tvalue={ activeColors[ property ] }\n\t\t\tonChange={ onColorChange }\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n} ) {\n\t/* \n\t As you change the text color by typing a HEX value into a field,\n\t the return value of document.getSelection jumps to the field you're editing,\n\t not the highlighted text. Given that useAnchorRef uses document.getSelection,\n\t it will return null, since it can't find the <mark> element within the HEX input.\n\t This caches the last truthy value of the selection anchor reference.\n\t */\n\tconst anchorRef = useCachedTruthy(\n\t\tuseAnchorRef( { ref: contentRef, value, settings } )\n\t);\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"components-inline-color-popover\"\n\t\t\tanchorRef={ anchorRef }\n\t\t>\n\t\t\t<TabPanel\n\t\t\t\ttabs={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'color',\n\t\t\t\t\t\ttitle: __( 'Text' ),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'backgroundColor',\n\t\t\t\t\t\ttitle: __( 'Background' ),\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t{ ( tab ) => (\n\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tproperty={ tab.name }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</TabPanel>\n\t\t</Popover>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/text-color/inline.js"],"names":["parseCSS","css","split","reduce","accumulator","rule","property","value","color","backgroundColor","parseClassName","className","colorSettings","name","match","colorSlug","colorObject","getActiveColors","activeColorFormat","attributes","style","class","setColors","colors","styles","classNames","push","join","slug","length","type","ColorPicker","onChange","select","getSettings","blockEditorStore","onColorChange","activeColors","InlineColorUI","onClose","contentRef","anchorRef","ref","settings","title","tab"],"mappings":";;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AAMA;;AAQA;;AACA;;AAKA;;AA9BA;AACA;AACA;;AAGA;AACA;AACA;;AAoBA;AACA;AACA;AAGA,SAASA,QAAT,GAA8B;AAAA,MAAXC,GAAW,uEAAL,EAAK;AAC7B,SAAOA,GAAG,CAACC,KAAJ,CAAW,GAAX,EAAiBC,MAAjB,CAAyB,CA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A;AACA;AACC,QAAMC,SAAS,GAAG,kCACjB,4BAAc;AAAEC,IAAAA,GAAG,EAAEF,UAAP;AAAmBjC,IAAAA,KAAnB;AAA0BoC,IAAAA,QAAQ,EAARA;AAA1B,GAAd,CADiB,CAAlB;AAIA,SACC,4BAAC,mBAAD;AACC,IAAA,OAAO,EAAGJ,OADX;AAEC,IAAA,SAAS,EAAC,iCAFX;AAGC,IAAA,SAAS,EAAGE;AAHb,KAKC,4BAAC,oBAAD;AACC,IAAA,IAAI,EAAG,CACN;AACC5B,MAAAA,IAAI,EAAE,OADP;AAEC+B,MAAAA,KAAK,EAAE,cAAI,MAAJ;AAFR,KADM,EAKN;AACC/B,MAAAA,IAAI,EAAE,iBADP;AAEC+B,MAAAA,KAAK,EAAE,cAAI,YAAJ;AAFR,KALM;AADR,KAYKC,GAAF,IACD,4BAAC,WAAD;AACC,IAAA,IAAI,EAAGhC,IADR;AAEC,IAAA,QAAQ,EAAGgC,GAAG,CAAChC,IAFhB;AAGC,IAAA,KAAK,EAAGN,KAHT;AAIC,IAAA,QAAQ,EAAGyB;AAJZ,IAbF,CALD,CADD;AA6BA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchorRef,\n} from '@wordpress/rich-text';\nimport {\n\tColorPalette,\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tstore as blockEditorStore,\n\tuseCachedTruthy,\n} from '@wordpress/block-editor';\nimport { Popover, TabPanel } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings } from './index';\n\nfunction parseCSS( css = '' ) {\n\treturn css.split( ';' ).reduce( ( accumulator, rule ) => {\n\t\tif ( rule ) {\n\t\t\tconst [ property, value ] = rule.split( ':' );\n\t\t\tif ( property === 'color' ) accumulator.color = value;\n\t\t\tif ( property === 'background-color' )\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nfunction parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\tconst match = name.match( /^has-([^-]+)-color$/ );\n\t\tif ( match ) {\n\t\t\tconst [ , colorSlug ] = name.match( /^has-([^-]+)-color$/ );\n\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\tcolorSettings,\n\t\t\t\tcolorSlug\n\t\t\t);\n\t\t\taccumulator.color = colorObject.color;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function getActiveColors( value, name, colorSettings ) {\n\tconst activeColorFormat = getActiveFormat( value, name );\n\n\tif ( ! activeColorFormat ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t...parseCSS( activeColorFormat.attributes.style ),\n\t\t...parseClassName( activeColorFormat.attributes.class, colorSettings ),\n\t};\n}\n\nfunction setColors( value, name, colorSettings, colors ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn removeFormat( value, name );\n\t}\n\n\tconst styles = [];\n\tconst classNames = [];\n\tconst attributes = {};\n\n\tif ( backgroundColor ) {\n\t\tstyles.push( [ 'background-color', backgroundColor ].join( ':' ) );\n\t} else {\n\t\t// Override default browser color for mark element.\n\t\tstyles.push( [ 'background-color', 'rgba(0, 0, 0, 0)' ].join( ':' ) );\n\t}\n\n\tif ( color ) {\n\t\tconst colorObject = getColorObjectByColorValue( colorSettings, color );\n\n\t\tif ( colorObject ) {\n\t\t\tclassNames.push( getColorClassName( 'color', colorObject.slug ) );\n\t\t} else {\n\t\t\tstyles.push( [ 'color', color ].join( ':' ) );\n\t\t}\n\t}\n\n\tif ( styles.length ) attributes.style = styles.join( ';' );\n\tif ( classNames.length ) attributes.class = classNames.join( ' ' );\n\n\treturn applyFormat( value, { type: name, attributes } );\n}\n\nfunction ColorPicker( { name, property, value, onChange } ) {\n\tconst colors = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn get( getSettings(), [ 'colors' ], [] );\n\t}, [] );\n\tconst onColorChange = useCallback(\n\t\t( color ) => {\n\t\t\tonChange(\n\t\t\t\tsetColors( value, name, colors, { [ property ]: color } )\n\t\t\t);\n\t\t},\n\t\t[ colors, onChange, property ]\n\t);\n\tconst activeColors = useMemo(\n\t\t() => getActiveColors( value, name, colors ),\n\t\t[ name, value, colors ]\n\t);\n\n\treturn (\n\t\t<ColorPalette\n\t\t\tvalue={ activeColors[ property ] }\n\t\t\tonChange={ onColorChange }\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n} ) {\n\t/* \n\t As you change the text color by typing a HEX value into a field,\n\t the return value of document.getSelection jumps to the field you're editing,\n\t not the highlighted text. Given that useAnchorRef uses document.getSelection,\n\t it will return null, since it can't find the <mark> element within the HEX input.\n\t This caches the last truthy value of the selection anchor reference.\n\t */\n\tconst anchorRef = useCachedTruthy(\n\t\tuseAnchorRef( { ref: contentRef, value, settings } )\n\t);\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"components-inline-color-popover\"\n\t\t\tanchorRef={ anchorRef }\n\t\t>\n\t\t\t<TabPanel\n\t\t\t\ttabs={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'color',\n\t\t\t\t\t\ttitle: __( 'Text' ),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'backgroundColor',\n\t\t\t\t\t\ttitle: __( 'Background' ),\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t{ ( tab ) => (\n\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tproperty={ tab.name }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</TabPanel>\n\t\t</Popover>\n\t);\n}\n"]}
@@ -27,10 +27,12 @@ const underline = {
27
27
  style: 'style'
28
28
  },
29
29
 
30
- edit({
31
- value,
32
- onChange
33
- }) {
30
+ edit(_ref) {
31
+ let {
32
+ value,
33
+ onChange
34
+ } = _ref;
35
+
34
36
  const onToggle = () => {
35
37
  onChange((0, _richText.toggleFormat)(value, {
36
38
  type: name,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/underline/index.js"],"names":["name","title","underline","tagName","className","attributes","style","edit","value","onChange","onToggle","type"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAQA,MAAMA,IAAI,GAAG,gBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,WAAJ,CAAd;AAEO,MAAMC,SAAS,GAAG;AACxBF,EAAAA,IADwB;AAExBC,EAAAA,KAFwB;AAGxBE,EAAAA,OAAO,EAAE,MAHe;AAIxBC,EAAAA,SAAS,EAAE,IAJa;AAKxBC,EAAAA,UAAU,EAAE;AACXC,IAAAA,KAAK,EAAE;AADI,GALY;;AAQxBC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAAF,EAAwB;AAC3B,UAAMC,QAAQ,GAAG,MAAM;AACtBD,MAAAA,QAAQ,CACP,4BAAcD,KAAd,EAAqB;AACpBG,QAAAA,IAAI,EAAEX,IADc;AAEpBK,QAAAA,UAAU,EAAE;AACXC,UAAAA,KAAK,EAAE;AADI,SAFQ;AAKpBL,QAAAA;AALoB,OAArB,CADO,CAAR;AASA,KAVD;;AAYA,WACC,qDACC,4BAAC,6BAAD;AACC,MAAA,IAAI,EAAC,SADN;AAEC,MAAA,SAAS,EAAC,GAFX;AAGC,MAAA,KAAK,EAAGS;AAHT,MADD,EAMC,4BAAC,yCAAD;AACC,MAAA,SAAS,EAAC,iBADX;AAEC,MAAA,OAAO,EAAGA;AAFX,MAND,CADD;AAaA;;AAlCuB,CAAlB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n} from '@wordpress/block-editor';\n\nconst name = 'core/underline';\nconst title = __( 'Underline' );\n\nexport const underline = {\n\tname,\n\ttitle,\n\ttagName: 'span',\n\tclassName: null,\n\tattributes: {\n\t\tstyle: 'style',\n\t},\n\tedit( { value, onChange } ) {\n\t\tconst onToggle = () => {\n\t\t\tonChange(\n\t\t\t\ttoggleFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\tstyle: 'text-decoration: underline;',\n\t\t\t\t\t},\n\t\t\t\t\ttitle,\n\t\t\t\t} )\n\t\t\t);\n\t\t};\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\tcharacter=\"u\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatUnderline\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/underline/index.js"],"names":["name","title","underline","tagName","className","attributes","style","edit","value","onChange","onToggle","type"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAQA,MAAMA,IAAI,GAAG,gBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,WAAJ,CAAd;AAEO,MAAMC,SAAS,GAAG;AACxBF,EAAAA,IADwB;AAExBC,EAAAA,KAFwB;AAGxBE,EAAAA,OAAO,EAAE,MAHe;AAIxBC,EAAAA,SAAS,EAAE,IAJa;AAKxBC,EAAAA,UAAU,EAAE;AACXC,IAAAA,KAAK,EAAE;AADI,GALY;;AAQxBC,EAAAA,IAAI,OAAwB;AAAA,QAAtB;AAAEC,MAAAA,KAAF;AAASC,MAAAA;AAAT,KAAsB;;AAC3B,UAAMC,QAAQ,GAAG,MAAM;AACtBD,MAAAA,QAAQ,CACP,4BAAcD,KAAd,EAAqB;AACpBG,QAAAA,IAAI,EAAEX,IADc;AAEpBK,QAAAA,UAAU,EAAE;AACXC,UAAAA,KAAK,EAAE;AADI,SAFQ;AAKpBL,QAAAA;AALoB,OAArB,CADO,CAAR;AASA,KAVD;;AAYA,WACC,qDACC,4BAAC,6BAAD;AACC,MAAA,IAAI,EAAC,SADN;AAEC,MAAA,SAAS,EAAC,GAFX;AAGC,MAAA,KAAK,EAAGS;AAHT,MADD,EAMC,4BAAC,yCAAD;AACC,MAAA,SAAS,EAAC,iBADX;AAEC,MAAA,OAAO,EAAGA;AAFX,MAND,CADD;AAaA;;AAlCuB,CAAlB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n} from '@wordpress/block-editor';\n\nconst name = 'core/underline';\nconst title = __( 'Underline' );\n\nexport const underline = {\n\tname,\n\ttitle,\n\ttagName: 'span',\n\tclassName: null,\n\tattributes: {\n\t\tstyle: 'style',\n\t},\n\tedit( { value, onChange } ) {\n\t\tconst onToggle = () => {\n\t\t\tonChange(\n\t\t\t\ttoggleFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\tstyle: 'text-decoration: underline;',\n\t\t\t\t\t},\n\t\t\t\t\ttitle,\n\t\t\t\t} )\n\t\t\t);\n\t\t};\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\tcharacter=\"u\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatUnderline\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"]}
@@ -17,12 +17,14 @@ export const bold = {
17
17
  tagName: 'strong',
18
18
  className: null,
19
19
 
20
- edit({
21
- isActive,
22
- value,
23
- onChange,
24
- onFocus
25
- }) {
20
+ edit(_ref) {
21
+ let {
22
+ isActive,
23
+ value,
24
+ onChange,
25
+ onFocus
26
+ } = _ref;
27
+
26
28
  function onToggle() {
27
29
  onChange(toggleFormat(value, {
28
30
  type: name,