@wordpress/format-library 4.16.0 → 4.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/bold/index.js +1 -10
  3. package/build/bold/index.js.map +1 -1
  4. package/build/code/index.js +3 -17
  5. package/build/code/index.js.map +1 -1
  6. package/build/default-formats.js +0 -14
  7. package/build/default-formats.js.map +1 -1
  8. package/build/default-formats.native.js +0 -6
  9. package/build/default-formats.native.js.map +1 -1
  10. package/build/image/index.js +5 -14
  11. package/build/image/index.js.map +1 -1
  12. package/build/index.js +1 -3
  13. package/build/index.js.map +1 -1
  14. package/build/italic/index.js +1 -10
  15. package/build/italic/index.js.map +1 -1
  16. package/build/keyboard/index.js +1 -10
  17. package/build/keyboard/index.js.map +1 -1
  18. package/build/language/index.js +1 -11
  19. package/build/language/index.js.map +1 -1
  20. package/build/link/index.js +5 -26
  21. package/build/link/index.js.map +1 -1
  22. package/build/link/index.native.js +14 -39
  23. package/build/link/index.native.js.map +1 -1
  24. package/build/link/inline.js +41 -78
  25. package/build/link/inline.js.map +1 -1
  26. package/build/link/modal-screens/link-picker-screen.native.js +1 -13
  27. package/build/link/modal-screens/link-picker-screen.native.js.map +1 -1
  28. package/build/link/modal-screens/link-settings-screen.native.js +9 -36
  29. package/build/link/modal-screens/link-settings-screen.native.js.map +1 -1
  30. package/build/link/modal-screens/screens.native.js.map +1 -1
  31. package/build/link/modal.native.js +1 -9
  32. package/build/link/modal.native.js.map +1 -1
  33. package/build/link/use-link-instance-key.js +3 -7
  34. package/build/link/use-link-instance-key.js.map +1 -1
  35. package/build/link/utils.js +23 -47
  36. package/build/link/utils.js.map +1 -1
  37. package/build/strikethrough/index.js +1 -9
  38. package/build/strikethrough/index.js.map +1 -1
  39. package/build/subscript/index.js +1 -10
  40. package/build/subscript/index.js.map +1 -1
  41. package/build/superscript/index.js +1 -10
  42. package/build/superscript/index.js.map +1 -1
  43. package/build/text-color/index.js +7 -25
  44. package/build/text-color/index.js.map +1 -1
  45. package/build/text-color/index.native.js +11 -34
  46. package/build/text-color/index.native.js.map +1 -1
  47. package/build/text-color/inline.js +5 -26
  48. package/build/text-color/inline.js.map +1 -1
  49. package/build/text-color/inline.native.js +9 -25
  50. package/build/text-color/inline.native.js.map +1 -1
  51. package/build/underline/index.js +1 -8
  52. package/build/underline/index.js.map +1 -1
  53. package/build/unknown/index.js +1 -11
  54. package/build/unknown/index.js.map +1 -1
  55. package/build-module/bold/index.js +0 -7
  56. package/build-module/bold/index.js.map +1 -1
  57. package/build-module/code/index.js +2 -14
  58. package/build-module/code/index.js.map +1 -1
  59. package/build-module/default-formats.js.map +1 -1
  60. package/build-module/default-formats.native.js.map +1 -1
  61. package/build-module/image/index.js +4 -10
  62. package/build-module/image/index.js.map +1 -1
  63. package/build-module/index.js +1 -1
  64. package/build-module/index.js.map +1 -1
  65. package/build-module/italic/index.js +0 -7
  66. package/build-module/italic/index.js.map +1 -1
  67. package/build-module/keyboard/index.js +0 -7
  68. package/build-module/keyboard/index.js.map +1 -1
  69. package/build-module/language/index.js +1 -8
  70. package/build-module/language/index.js.map +1 -1
  71. package/build-module/link/index.js +5 -17
  72. package/build-module/link/index.js.map +1 -1
  73. package/build-module/link/index.native.js +15 -30
  74. package/build-module/link/index.native.js.map +1 -1
  75. package/build-module/link/inline.js +42 -69
  76. package/build-module/link/inline.js.map +1 -1
  77. package/build-module/link/modal-screens/link-picker-screen.native.js +2 -8
  78. package/build-module/link/modal-screens/link-picker-screen.native.js.map +1 -1
  79. package/build-module/link/modal-screens/link-settings-screen.native.js +10 -28
  80. package/build-module/link/modal-screens/link-settings-screen.native.js.map +1 -1
  81. package/build-module/link/modal-screens/screens.native.js.map +1 -1
  82. package/build-module/link/modal.native.js +1 -4
  83. package/build-module/link/modal.native.js.map +1 -1
  84. package/build-module/link/use-link-instance-key.js +3 -7
  85. package/build-module/link/use-link-instance-key.js.map +1 -1
  86. package/build-module/link/utils.js +24 -43
  87. package/build-module/link/utils.js.map +1 -1
  88. package/build-module/strikethrough/index.js +0 -6
  89. package/build-module/strikethrough/index.js.map +1 -1
  90. package/build-module/subscript/index.js +0 -7
  91. package/build-module/subscript/index.js.map +1 -1
  92. package/build-module/superscript/index.js +0 -7
  93. package/build-module/superscript/index.js.map +1 -1
  94. package/build-module/text-color/index.js +7 -20
  95. package/build-module/text-color/index.js.map +1 -1
  96. package/build-module/text-color/index.native.js +12 -24
  97. package/build-module/text-color/index.native.js.map +1 -1
  98. package/build-module/text-color/inline.js +5 -20
  99. package/build-module/text-color/inline.js.map +1 -1
  100. package/build-module/text-color/inline.native.js +9 -21
  101. package/build-module/text-color/inline.native.js.map +1 -1
  102. package/build-module/underline/index.js +0 -6
  103. package/build-module/underline/index.js.map +1 -1
  104. package/build-module/unknown/index.js +0 -8
  105. package/build-module/unknown/index.js.map +1 -1
  106. package/package.json +13 -13
  107. package/src/link/inline.js +11 -34
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/unknown/index.js"],"names":["__","removeFormat","slice","RichTextToolbarButton","help","name","title","unknown","tagName","className","edit","isActive","value","onChange","onFocus","onClick","selectedValue","hasUnknownFormats","formats","some","format","type"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,EAAuBC,KAAvB,QAAoC,sBAApC;AACA,SAASC,qBAAT,QAAsC,yBAAtC;AACA,SAASC,IAAT,QAAqB,kBAArB;AAEA,MAAMC,IAAI,GAAG,cAAb;;AACA,MAAMC,KAAK,GAAGN,EAAE,CAAE,0BAAF,CAAhB;;AAEA,OAAO,MAAMO,OAAO,GAAG;AACtBF,EAAAA,IADsB;AAEtBC,EAAAA,KAFsB;AAGtBE,EAAAA,OAAO,EAAE,GAHa;AAItBC,EAAAA,SAAS,EAAE,IAJW;;AAKtBC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,OAAT,GAAmB;AAClBF,MAAAA,QAAQ,CAAEZ,YAAY,CAAEW,KAAF,EAASP,IAAT,CAAd,CAAR;AACAS,MAAAA,OAAO;AACP;;AAED,UAAME,aAAa,GAAGd,KAAK,CAAEU,KAAF,CAA3B;AACA,UAAMK,iBAAiB,GAAGD,aAAa,CAACE,OAAd,CAAsBC,IAAtB,CAA8BD,OAAF,IAAe;AACpE,aAAOA,OAAO,CAACC,IAAR,CAAgBC,MAAF,IAAcA,MAAM,CAACC,IAAP,KAAgBhB,IAA5C,CAAP;AACA,KAFyB,CAA1B;;AAIA,QAAK,CAAEM,QAAF,IAAc,CAAEM,iBAArB,EAAyC;AACxC,aAAO,IAAP;AACA;;AAED,WACC,cAAC,qBAAD;AACC,MAAA,IAAI,EAAC,SADN;AAEC,MAAA,IAAI,EAAGb,IAFR;AAGC,MAAA,KAAK,EAAGE,KAHT;AAIC,MAAA,OAAO,EAAGS,OAJX;AAKC,MAAA,QAAQ,EAAG;AALZ,MADD;AASA;;AA7BqB,CAAhB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { removeFormat, slice } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { help } from '@wordpress/icons';\n\nconst name = 'core/unknown';\nconst title = __( 'Clear Unknown Formatting' );\n\nexport const unknown = {\n\tname,\n\ttitle,\n\ttagName: '*',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onClick() {\n\t\t\tonChange( removeFormat( value, name ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\tconst selectedValue = slice( value );\n\t\tconst hasUnknownFormats = selectedValue.formats.some( ( formats ) => {\n\t\t\treturn formats.some( ( format ) => format.type === name );\n\t\t} );\n\n\t\tif ( ! isActive && ! hasUnknownFormats ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\tname=\"unknown\"\n\t\t\t\ticon={ help }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ true }\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
1
+ {"version":3,"names":["__","removeFormat","slice","RichTextToolbarButton","help","name","title","unknown","tagName","className","edit","isActive","value","onChange","onFocus","onClick","selectedValue","hasUnknownFormats","formats","some","format","type","createElement","icon"],"sources":["@wordpress/format-library/src/unknown/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { removeFormat, slice } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { help } from '@wordpress/icons';\n\nconst name = 'core/unknown';\nconst title = __( 'Clear Unknown Formatting' );\n\nexport const unknown = {\n\tname,\n\ttitle,\n\ttagName: '*',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onClick() {\n\t\t\tonChange( removeFormat( value, name ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\tconst selectedValue = slice( value );\n\t\tconst hasUnknownFormats = selectedValue.formats.some( ( formats ) => {\n\t\t\treturn formats.some( ( format ) => format.type === name );\n\t\t} );\n\n\t\tif ( ! isActive && ! hasUnknownFormats ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\tname=\"unknown\"\n\t\t\t\ticon={ help }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ true }\n\t\t\t/>\n\t\t);\n\t},\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,EAAEC,KAAK,QAAQ,sBAAsB;AAC1D,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,IAAI,QAAQ,kBAAkB;AAEvC,MAAMC,IAAI,GAAG,cAAc;AAC3B,MAAMC,KAAK,GAAGN,EAAE,CAAE,0BAA2B,CAAC;AAE9C,OAAO,MAAMO,OAAO,GAAG;EACtBF,IAAI;EACJC,KAAK;EACLE,OAAO,EAAE,GAAG;EACZC,SAAS,EAAE,IAAI;EACfC,IAAIA,CAAE;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,QAAQ;IAAEC;EAAQ,CAAC,EAAG;IAC9C,SAASC,OAAOA,CAAA,EAAG;MAClBF,QAAQ,CAAEZ,YAAY,CAAEW,KAAK,EAAEP,IAAK,CAAE,CAAC;MACvCS,OAAO,CAAC,CAAC;IACV;IAEA,MAAME,aAAa,GAAGd,KAAK,CAAEU,KAAM,CAAC;IACpC,MAAMK,iBAAiB,GAAGD,aAAa,CAACE,OAAO,CAACC,IAAI,CAAID,OAAO,IAAM;MACpE,OAAOA,OAAO,CAACC,IAAI,CAAIC,MAAM,IAAMA,MAAM,CAACC,IAAI,KAAKhB,IAAK,CAAC;IAC1D,CAAE,CAAC;IAEH,IAAK,CAAEM,QAAQ,IAAI,CAAEM,iBAAiB,EAAG;MACxC,OAAO,IAAI;IACZ;IAEA,OACCK,aAAA,CAACnB,qBAAqB;MACrBE,IAAI,EAAC,SAAS;MACdkB,IAAI,EAAGnB,IAAM;MACbE,KAAK,EAAGA,KAAO;MACfS,OAAO,EAAGA,OAAS;MACnBJ,QAAQ,EAAG;IAAM,CACjB,CAAC;EAEJ;AACD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/format-library",
3
- "version": "4.16.0",
3
+ "version": "4.17.1",
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.39.0",
30
- "@wordpress/block-editor": "^12.7.0",
31
- "@wordpress/components": "^25.5.0",
32
- "@wordpress/compose": "^6.16.0",
33
- "@wordpress/data": "^9.9.0",
34
- "@wordpress/element": "^5.16.0",
35
- "@wordpress/html-entities": "^3.39.0",
36
- "@wordpress/i18n": "^4.39.0",
37
- "@wordpress/icons": "^9.30.0",
38
- "@wordpress/rich-text": "^6.16.0",
39
- "@wordpress/url": "^3.40.0"
29
+ "@wordpress/a11y": "^3.40.1",
30
+ "@wordpress/block-editor": "^12.8.1",
31
+ "@wordpress/components": "^25.6.1",
32
+ "@wordpress/compose": "^6.17.1",
33
+ "@wordpress/data": "^9.10.1",
34
+ "@wordpress/element": "^5.17.1",
35
+ "@wordpress/html-entities": "^3.40.1",
36
+ "@wordpress/i18n": "^4.40.1",
37
+ "@wordpress/icons": "^9.31.1",
38
+ "@wordpress/rich-text": "^6.17.1",
39
+ "@wordpress/url": "^3.41.1"
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": "b898cf1dc8e70841d1647ea0994ac6278acc18a7"
48
+ "gitHead": "bb1fbf87bb0f451744530fc6a85de2dff1263bed"
49
49
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useState, useRef, createInterpolateElement } from '@wordpress/element';
4
+ import { useRef, createInterpolateElement } from '@wordpress/element';
5
5
  import { __, sprintf } from '@wordpress/i18n';
6
6
  import { speak } from '@wordpress/a11y';
7
7
  import { Popover } from '@wordpress/components';
@@ -45,16 +45,6 @@ function InlineLinkUI( {
45
45
  // Get the text content minus any HTML tags.
46
46
  const richTextText = richLinkTextValue.text;
47
47
 
48
- /**
49
- * Pending settings to be applied to the next link. When inserting a new
50
- * link, toggle values cannot be applied immediately, because there is not
51
- * yet a link for them to apply to. Thus, they are maintained in a state
52
- * value until the time that the link can be inserted or edited.
53
- *
54
- * @type {[Object|undefined,Function]}
55
- */
56
- const [ nextLinkValue, setNextLinkValue ] = useState();
57
-
58
48
  const { createPageEntity, userCanCreatePages } = useSelect( ( select ) => {
59
49
  const { getSettings } = select( blockEditorStore );
60
50
  const _settings = getSettings();
@@ -71,7 +61,6 @@ function InlineLinkUI( {
71
61
  id: activeAttributes.id,
72
62
  opensInNewTab: activeAttributes.target === '_blank',
73
63
  title: richTextText,
74
- ...nextLinkValue,
75
64
  };
76
65
 
77
66
  function removeLink() {
@@ -82,32 +71,18 @@ function InlineLinkUI( {
82
71
  }
83
72
 
84
73
  function onChangeLink( nextValue ) {
85
- // Merge with values from state, both for the purpose of assigning the
86
- // next state value, and for use in constructing the new link format if
87
- // the link is ready to be applied.
88
- nextValue = {
89
- ...nextLinkValue,
90
- ...nextValue,
91
- };
92
-
93
74
  // LinkControl calls `onChange` immediately upon the toggling a setting.
75
+ // Before merging the next value with the current link value, check if
76
+ // the setting was toggled.
94
77
  const didToggleSetting =
95
78
  linkValue.opensInNewTab !== nextValue.opensInNewTab &&
96
- linkValue.url === nextValue.url;
97
-
98
- // If change handler was called as a result of a settings change during
99
- // link insertion, it must be held in state until the link is ready to
100
- // be applied.
101
- const didToggleSettingForNewLink =
102
- didToggleSetting && nextValue.url === undefined;
79
+ nextValue.url === undefined;
103
80
 
104
- // If link will be assigned, the state value can be considered flushed.
105
- // Otherwise, persist the pending changes.
106
- setNextLinkValue( didToggleSettingForNewLink ? nextValue : undefined );
107
-
108
- if ( didToggleSettingForNewLink ) {
109
- return;
110
- }
81
+ // Merge the next value with the current link value.
82
+ nextValue = {
83
+ ...linkValue,
84
+ ...nextValue,
85
+ };
111
86
 
112
87
  const newUrl = prependHTTP( nextValue.url );
113
88
  const linkFormat = createLinkFormat( {
@@ -185,6 +160,8 @@ function InlineLinkUI( {
185
160
  }
186
161
 
187
162
  newValue.start = newValue.end;
163
+
164
+ // Hides the Link UI.
188
165
  newValue.activeFormats = [];
189
166
  onChange( newValue );
190
167
  }