@wordpress/format-library 4.19.2 → 4.20.0

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 (71) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/bold/index.js +4 -4
  3. package/build/bold/index.js.map +1 -1
  4. package/build/code/index.js +3 -3
  5. package/build/code/index.js.map +1 -1
  6. package/build/image/index.js +12 -11
  7. package/build/image/index.js.map +1 -1
  8. package/build/italic/index.js +4 -4
  9. package/build/italic/index.js.map +1 -1
  10. package/build/keyboard/index.js +2 -2
  11. package/build/keyboard/index.js.map +1 -1
  12. package/build/language/index.js +10 -9
  13. package/build/language/index.js.map +1 -1
  14. package/build/link/index.js +8 -6
  15. package/build/link/index.js.map +1 -1
  16. package/build/link/index.native.js +4 -3
  17. package/build/link/index.native.js.map +1 -1
  18. package/build/link/inline.js +4 -3
  19. package/build/link/inline.js.map +1 -1
  20. package/build/link/modal-screens/link-picker-screen.native.js +3 -2
  21. package/build/link/modal-screens/link-picker-screen.native.js.map +1 -1
  22. package/build/link/modal-screens/link-settings-screen.native.js +6 -5
  23. package/build/link/modal-screens/link-settings-screen.native.js.map +1 -1
  24. package/build/link/modal.native.js +7 -6
  25. package/build/link/modal.native.js.map +1 -1
  26. package/build/strikethrough/index.js +3 -3
  27. package/build/strikethrough/index.js.map +1 -1
  28. package/build/subscript/index.js +2 -2
  29. package/build/subscript/index.js.map +1 -1
  30. package/build/superscript/index.js +2 -2
  31. package/build/superscript/index.js.map +1 -1
  32. package/build/text-color/index.js +5 -4
  33. package/build/text-color/index.js.map +1 -1
  34. package/build/text-color/index.native.js +6 -5
  35. package/build/text-color/index.native.js.map +1 -1
  36. package/build/text-color/inline.js +12 -8
  37. package/build/text-color/inline.js.map +1 -1
  38. package/build/text-color/inline.native.js +6 -5
  39. package/build/text-color/inline.native.js.map +1 -1
  40. package/build/underline/index.js +3 -3
  41. package/build/underline/index.js.map +1 -1
  42. package/build/unknown/index.js +2 -2
  43. package/build/unknown/index.js.map +1 -1
  44. package/build-module/bold/index.js +1 -1
  45. package/build-module/code/index.js +1 -1
  46. package/build-module/image/index.js +1 -1
  47. package/build-module/italic/index.js +1 -1
  48. package/build-module/keyboard/index.js +1 -1
  49. package/build-module/language/index.js +1 -1
  50. package/build-module/link/index.js +2 -1
  51. package/build-module/link/index.js.map +1 -1
  52. package/build-module/link/index.native.js +1 -1
  53. package/build-module/link/inline.js +1 -1
  54. package/build-module/link/modal-screens/link-picker-screen.native.js +1 -1
  55. package/build-module/link/modal-screens/link-settings-screen.native.js +1 -1
  56. package/build-module/link/modal.native.js +1 -1
  57. package/build-module/strikethrough/index.js +1 -1
  58. package/build-module/subscript/index.js +1 -1
  59. package/build-module/superscript/index.js +1 -1
  60. package/build-module/text-color/index.js +1 -1
  61. package/build-module/text-color/index.native.js +1 -1
  62. package/build-module/text-color/inline.js +8 -5
  63. package/build-module/text-color/inline.js.map +1 -1
  64. package/build-module/text-color/inline.native.js +1 -1
  65. package/build-module/underline/index.js +1 -1
  66. package/build-module/unknown/index.js +1 -1
  67. package/build-style/style-rtl.css +1 -1
  68. package/build-style/style.css +1 -1
  69. package/package.json +13 -13
  70. package/src/link/index.js +1 -0
  71. package/src/text-color/inline.js +7 -6
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","useMemo","useSelect","applyFormat","removeFormat","getActiveFormat","useAnchor","ColorPalette","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","store","blockEditorStore","useCachedTruthy","Popover","TabPanel","__","textColor","settings","transparentValue","parseCSS","css","split","reduce","accumulator","rule","property","value","color","backgroundColor","parseClassName","className","colorSettings","name","startsWith","endsWith","colorSlug","replace","colorObject","getActiveColors","activeColorFormat","attributes","style","class","setColors","colors","styles","classNames","push","join","slug","length","type","ColorPicker","onChange","select","_getSettings$colors","getSettings","onColorChange","activeColors","createElement","InlineColorUI","onClose","contentRef","popoverAnchor","editableContentElement","current","anchor","tabs","title","tab"],"sources":["@wordpress/format-library/src/text-color/inline.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchor,\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, transparentValue } 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' && value !== transparentValue )\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\t// `colorSlug` could contain dashes, so simply match the start and end.\n\t\tif ( name.startsWith( 'has-' ) && name.endsWith( '-color' ) ) {\n\t\t\tconst colorSlug = name\n\t\t\t\t.replace( /^has-/, '' )\n\t\t\t\t.replace( /-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', transparentValue ].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 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 useAnchor 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 popoverAnchor = useCachedTruthy(\n\t\tuseAnchor( {\n\t\t\teditableContentElement: contentRef.current,\n\t\t\tsettings,\n\t\t} )\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\tanchor={ popoverAnchor }\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"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,OAAO,QAAQ,oBAAoB;AACzD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,WAAW,EACXC,YAAY,EACZC,eAAe,EACfC,SAAS,QACH,sBAAsB;AAC7B,SACCC,YAAY,EACZC,iBAAiB,EACjBC,0BAA0B,EAC1BC,+BAA+B,EAC/BC,KAAK,IAAIC,gBAAgB,EACzBC,eAAe,QACT,yBAAyB;AAChC,SAASC,OAAO,EAAEC,QAAQ,QAAQ,uBAAuB;AACzD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,SAAS,IAAIC,QAAQ,EAAEC,gBAAgB,QAAQ,SAAS;AAEjE,SAASC,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AAC;AAEJ;AAEA,eAAe,SAASG,aAAaA,CAAE;EACtC5B,IAAI;EACJN,KAAK;EACL2B,QAAQ;EACRQ,OAAO;EACPC;AACD,CAAC,EAAG;EACH;AACD;AACA;AACA;AACA;AACA;AACA;EACC,MAAMC,aAAa,GAAGnD,eAAe,CACpCP,SAAS,CAAE;IACV2D,sBAAsB,EAAEF,UAAU,CAACG,OAAO;IAC1ChD;EACD,CAAE,CACH,CAAC;EAED,OACC0C,aAAA,CAAC9C,OAAO;IACPgD,OAAO,EAAGA,OAAS;IACnB/B,SAAS,EAAC,iCAAiC;IAC3CoC,MAAM,EAAGH;EAAe,GAExBJ,aAAA,CAAC7C,QAAQ;IACRqD,IAAI,EAAG,CACN;MACCnC,IAAI,EAAE,OAAO;MACboC,KAAK,EAAErD,EAAE,CAAE,MAAO;IACnB,CAAC,EACD;MACCiB,IAAI,EAAE,iBAAiB;MACvBoC,KAAK,EAAErD,EAAE,CAAE,YAAa;IACzB,CAAC;EACC,GAECsD,GAAG,IACNV,aAAA,CAACP,WAAW;IACXpB,IAAI,EAAGA,IAAM;IACbP,QAAQ,EAAG4C,GAAG,CAACrC,IAAM;IACrBN,KAAK,EAAGA,KAAO;IACf2B,QAAQ,EAAGA;EAAU,CACrB,CAEO,CACF,CAAC;AAEZ"}
1
+ {"version":3,"names":["useCallback","useMemo","useSelect","applyFormat","removeFormat","getActiveFormat","useAnchor","ColorPalette","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","store","blockEditorStore","useCachedTruthy","Popover","TabPanel","__","textColor","settings","transparentValue","parseCSS","css","split","reduce","accumulator","rule","property","value","color","backgroundColor","parseClassName","className","colorSettings","name","startsWith","endsWith","colorSlug","replace","colorObject","getActiveColors","activeColorFormat","attributes","style","class","setColors","colors","styles","classNames","push","join","slug","length","type","ColorPicker","onChange","select","_getSettings$colors","getSettings","onColorChange","activeColors","createElement","InlineColorUI","onClose","contentRef","popoverAnchor","editableContentElement","current","cachedRect","getBoundingClientRect","anchor","tabs","title","tab"],"sources":["@wordpress/format-library/src/text-color/inline.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchor,\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, transparentValue } 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' && value !== transparentValue )\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\t// `colorSlug` could contain dashes, so simply match the start and end.\n\t\tif ( name.startsWith( 'has-' ) && name.endsWith( '-color' ) ) {\n\t\t\tconst colorSlug = name\n\t\t\t\t.replace( /^has-/, '' )\n\t\t\t\t.replace( /-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', transparentValue ].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 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\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings,\n\t} );\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 useAnchor 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 cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() );\n\tpopoverAnchor.getBoundingClientRect = () => cachedRect;\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"components-inline-color-popover\"\n\t\t\tanchor={ popoverAnchor }\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"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,OAAO,QAAQ,oBAAoB;AACzD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,WAAW,EACXC,YAAY,EACZC,eAAe,EACfC,SAAS,QACH,sBAAsB;AAC7B,SACCC,YAAY,EACZC,iBAAiB,EACjBC,0BAA0B,EAC1BC,+BAA+B,EAC/BC,KAAK,IAAIC,gBAAgB,EACzBC,eAAe,QACT,yBAAyB;AAChC,SAASC,OAAO,EAAEC,QAAQ,QAAQ,uBAAuB;AACzD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;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oB,KAAK,EAAGgC,YAAY,CAAEjC,QAAQ,CAAI;IAClC4B,QAAQ,EAAGI;EAAe,CAC1B,CAAC;AAEJ;AAEA,eAAe,SAASG,aAAaA,CAAE;EACtC5B,IAAI;EACJN,KAAK;EACL2B,QAAQ;EACRQ,OAAO;EACPC;AACD,CAAC,EAAG;EACH,MAAMC,aAAa,GAAG1D,SAAS,CAAE;IAChC2D,sBAAsB,EAAEF,UAAU,CAACG,OAAO;IAC1ChD;EACD,CAAE,CAAC;;EAEH;AACD;AACA;AACA;AACA;AACA;AACA;EACC,MAAMiD,UAAU,GAAGtD,eAAe,CAAEmD,aAAa,CAACI,qBAAqB,CAAC,CAAE,CAAC;EAC3EJ,aAAa,CAACI,qBAAqB,GAAG,MAAMD,UAAU;EAEtD,OACCP,aAAA,CAAC9C,OAAO;IACPgD,OAAO,EAAGA,OAAS;IACnB/B,SAAS,EAAC,iCAAiC;IAC3CsC,MAAM,EAAGL;EAAe,GAExBJ,aAAA,CAAC7C,QAAQ;IACRuD,IAAI,EAAG,CACN;MACCrC,IAAI,EAAE,OAAO;MACbsC,KAAK,EAAEvD,EAAE,CAAE,MAAO;IACnB,CAAC,EACD;MACCiB,IAAI,EAAE,iBAAiB;MACvBsC,KAAK,EAAEvD,EAAE,CAAE,YAAa;IACzB,CAAC;EACC,GAECwD,GAAG,IACNZ,aAAA,CAACP,WAAW;IACXpB,IAAI,EAAGA,IAAM;IACbP,QAAQ,EAAG8C,GAAG,CAACvC,IAAM;IACrBN,KAAK,EAAGA,KAAO;IACf2B,QAAQ,EAAGA;EAAU,CACrB,CAEO,CACF,CAAC;AAEZ"}
@@ -1,4 +1,4 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
@@ -1,4 +1,4 @@
1
- import { createElement, Fragment } from "@wordpress/element";
1
+ import { createElement, Fragment } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
@@ -1,4 +1,4 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
@@ -97,7 +97,7 @@
97
97
  --wp-block-synced-color: #7a00df;
98
98
  --wp-block-synced-color--rgb: 122, 0, 223;
99
99
  }
100
- @media (min-resolution: 192dpi) {
100
+ @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
101
101
  :root {
102
102
  --wp-admin-border-width-focus: 1.5px;
103
103
  }
@@ -97,7 +97,7 @@
97
97
  --wp-block-synced-color: #7a00df;
98
98
  --wp-block-synced-color--rgb: 122, 0, 223;
99
99
  }
100
- @media (min-resolution: 192dpi) {
100
+ @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
101
101
  :root {
102
102
  --wp-admin-border-width-focus: 1.5px;
103
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/format-library",
3
- "version": "4.19.2",
3
+ "version": "4.20.0",
4
4
  "description": "Format library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -26,17 +26,17 @@
26
26
  "react-native": "src/index",
27
27
  "dependencies": {
28
28
  "@babel/runtime": "^7.16.0",
29
- "@wordpress/a11y": "^3.42.2",
30
- "@wordpress/block-editor": "^12.10.2",
31
- "@wordpress/components": "^25.8.2",
32
- "@wordpress/compose": "^6.19.2",
33
- "@wordpress/data": "^9.12.2",
34
- "@wordpress/element": "^5.19.2",
35
- "@wordpress/html-entities": "^3.42.2",
36
- "@wordpress/i18n": "^4.42.2",
37
- "@wordpress/icons": "^9.33.2",
38
- "@wordpress/rich-text": "^6.19.2",
39
- "@wordpress/url": "^3.43.2"
29
+ "@wordpress/a11y": "^3.43.0",
30
+ "@wordpress/block-editor": "^12.11.0",
31
+ "@wordpress/components": "^25.9.0",
32
+ "@wordpress/compose": "^6.20.0",
33
+ "@wordpress/data": "^9.13.0",
34
+ "@wordpress/element": "^5.20.0",
35
+ "@wordpress/html-entities": "^3.43.0",
36
+ "@wordpress/i18n": "^4.43.0",
37
+ "@wordpress/icons": "^9.34.0",
38
+ "@wordpress/rich-text": "^6.20.0",
39
+ "@wordpress/url": "^3.44.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": "^18.0.0",
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "5d2e3d07cc97af8090fc32c1e5d5013a2967e752"
48
+ "gitHead": "9b8e598c5418d38fe72197c24ef1d3dd6c712151"
49
49
  }
package/src/link/index.js CHANGED
@@ -130,6 +130,7 @@ export const link = {
130
130
  url: 'href',
131
131
  type: 'data-type',
132
132
  id: 'data-id',
133
+ _id: 'id',
133
134
  target: 'target',
134
135
  rel: 'rel',
135
136
  },
@@ -137,6 +137,11 @@ export default function InlineColorUI( {
137
137
  onClose,
138
138
  contentRef,
139
139
  } ) {
140
+ const popoverAnchor = useAnchor( {
141
+ editableContentElement: contentRef.current,
142
+ settings,
143
+ } );
144
+
140
145
  /*
141
146
  As you change the text color by typing a HEX value into a field,
142
147
  the return value of document.getSelection jumps to the field you're editing,
@@ -144,12 +149,8 @@ export default function InlineColorUI( {
144
149
  it will return null, since it can't find the <mark> element within the HEX input.
145
150
  This caches the last truthy value of the selection anchor reference.
146
151
  */
147
- const popoverAnchor = useCachedTruthy(
148
- useAnchor( {
149
- editableContentElement: contentRef.current,
150
- settings,
151
- } )
152
- );
152
+ const cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() );
153
+ popoverAnchor.getBoundingClientRect = () => cachedRect;
153
154
 
154
155
  return (
155
156
  <Popover