@wordpress/format-library 5.35.0 → 5.35.1-next.dc3f6d3c1.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.
- package/build/bold/index.js +2 -2
- package/build/bold/index.js.map +2 -2
- package/build/italic/index.js +2 -2
- package/build/italic/index.js.map +2 -2
- package/build/link/index.js +4 -3
- package/build/link/index.js.map +2 -2
- package/build-module/bold/index.js +2 -2
- package/build-module/bold/index.js.map +2 -2
- package/build-module/italic/index.js +2 -2
- package/build-module/italic/index.js.map +2 -2
- package/build-module/link/index.js +4 -3
- package/build-module/link/index.js.map +2 -2
- package/package.json +15 -15
- package/src/bold/index.js +12 -10
- package/src/italic/index.js +12 -10
- package/src/link/index.js +17 -14
package/build/bold/index.js
CHANGED
|
@@ -37,7 +37,7 @@ var bold = {
|
|
|
37
37
|
tagName: "strong",
|
|
38
38
|
className: null,
|
|
39
39
|
[essentialFormatKey]: true,
|
|
40
|
-
edit({ isActive, value, onChange, onFocus }) {
|
|
40
|
+
edit({ isActive, value, onChange, onFocus, isVisible = true }) {
|
|
41
41
|
function onToggle() {
|
|
42
42
|
onChange((0, import_rich_text.toggleFormat)(value, { type: name, title }));
|
|
43
43
|
}
|
|
@@ -54,7 +54,7 @@ var bold = {
|
|
|
54
54
|
onUse: onToggle
|
|
55
55
|
}
|
|
56
56
|
),
|
|
57
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
57
|
+
isVisible && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
58
58
|
import_block_editor.RichTextToolbarButton,
|
|
59
59
|
{
|
|
60
60
|
name: "bold",
|
package/build/bold/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/bold/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { formatBold } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { essentialFormatKey } = unlock( blockEditorPrivateApis );\n\nconst name = 'core/bold';\nconst title = __( 'Bold' );\n\nexport const bold = {\n\tname,\n\ttitle,\n\ttagName: 'strong',\n\tclassName: null,\n\t[ essentialFormatKey ]: true,\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\tonChange( toggleFormat( value, { type: name } ) );\n\t\t\tonFocus();\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=\"b\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\tname=\"bold\"\n\t\t\t\t\ticon={ formatBold }\n\t\t\t\t\ttitle={ title }\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\tshortcutType=\"primary\"\n\t\t\t\t\tshortcutCharacter=\"b\"\n\t\t\t\t/>\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatBold\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,uBAA6B;AAC7B,0BAKO;AACP,mBAA2B;AAK3B,yBAAuB;AAwBpB;AAtBH,IAAM,EAAE,mBAAmB,QAAI,2BAAQ,oBAAAA,WAAuB;AAE9D,IAAM,OAAO;AACb,IAAM,YAAQ,gBAAI,MAAO;AAElB,IAAM,OAAO;AAAA,EACnB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,CAAE,kBAAmB,GAAG;AAAA,EACxB,KAAM,EAAE,UAAU,OAAO,UAAU,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { formatBold } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { essentialFormatKey } = unlock( blockEditorPrivateApis );\n\nconst name = 'core/bold';\nconst title = __( 'Bold' );\n\nexport const bold = {\n\tname,\n\ttitle,\n\ttagName: 'strong',\n\tclassName: null,\n\t[ essentialFormatKey ]: true,\n\tedit( { isActive, value, onChange, onFocus, isVisible = true } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonChange( toggleFormat( value, { type: name } ) );\n\t\t\tonFocus();\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=\"b\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t{ isVisible && (\n\t\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\t\tname=\"bold\"\n\t\t\t\t\t\ticon={ formatBold }\n\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\t\tshortcutType=\"primary\"\n\t\t\t\t\t\tshortcutCharacter=\"b\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatBold\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,uBAA6B;AAC7B,0BAKO;AACP,mBAA2B;AAK3B,yBAAuB;AAwBpB;AAtBH,IAAM,EAAE,mBAAmB,QAAI,2BAAQ,oBAAAA,WAAuB;AAE9D,IAAM,OAAO;AACb,IAAM,YAAQ,gBAAI,MAAO;AAElB,IAAM,OAAO;AAAA,EACnB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,CAAE,kBAAmB,GAAG;AAAA,EACxB,KAAM,EAAE,UAAU,OAAO,UAAU,SAAS,YAAY,KAAK,GAAI;AAChE,aAAS,WAAW;AACnB,mBAAU,+BAAc,OAAO,EAAE,MAAM,MAAM,MAAM,CAAE,CAAE;AAAA,IACxD;AAEA,aAAS,UAAU;AAClB,mBAAU,+BAAc,OAAO,EAAE,MAAM,KAAK,CAAE,CAAE;AAChD,cAAQ;AAAA,IACT;AAEA,WACC,4EACC;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,MAAK;AAAA,UACL,WAAU;AAAA,UACV,OAAQ;AAAA;AAAA,MACT;AAAA,MACE,aACD;AAAA,QAAC;AAAA;AAAA,UACA,MAAK;AAAA,UACL,MAAO;AAAA,UACP;AAAA,UACA;AAAA,UACA;AAAA,UACA,cAAa;AAAA,UACb,mBAAkB;AAAA;AAAA,MACnB;AAAA,MAED;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,SAAU;AAAA;AAAA,MACX;AAAA,OACD;AAAA,EAEF;AACD;",
|
|
6
6
|
"names": ["blockEditorPrivateApis"]
|
|
7
7
|
}
|
package/build/italic/index.js
CHANGED
|
@@ -37,7 +37,7 @@ var italic = {
|
|
|
37
37
|
tagName: "em",
|
|
38
38
|
className: null,
|
|
39
39
|
[essentialFormatKey]: true,
|
|
40
|
-
edit({ isActive, value, onChange, onFocus }) {
|
|
40
|
+
edit({ isActive, value, onChange, onFocus, isVisible = true }) {
|
|
41
41
|
function onToggle() {
|
|
42
42
|
onChange((0, import_rich_text.toggleFormat)(value, { type: name, title }));
|
|
43
43
|
}
|
|
@@ -54,7 +54,7 @@ var italic = {
|
|
|
54
54
|
onUse: onToggle
|
|
55
55
|
}
|
|
56
56
|
),
|
|
57
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
57
|
+
isVisible && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
58
58
|
import_block_editor.RichTextToolbarButton,
|
|
59
59
|
{
|
|
60
60
|
name: "italic",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/italic/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { formatItalic } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { essentialFormatKey } = unlock( blockEditorPrivateApis );\n\nconst name = 'core/italic';\nconst title = __( 'Italic' );\n\nexport const italic = {\n\tname,\n\ttitle,\n\ttagName: 'em',\n\tclassName: null,\n\t[ essentialFormatKey ]: true,\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\tonChange( toggleFormat( value, { type: name } ) );\n\t\t\tonFocus();\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=\"i\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\tname=\"italic\"\n\t\t\t\t\ticon={ formatItalic }\n\t\t\t\t\ttitle={ title }\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\tshortcutType=\"primary\"\n\t\t\t\t\tshortcutCharacter=\"i\"\n\t\t\t\t/>\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatItalic\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,uBAA6B;AAC7B,0BAKO;AACP,mBAA6B;AAK7B,yBAAuB;AAwBpB;AAtBH,IAAM,EAAE,mBAAmB,QAAI,2BAAQ,oBAAAA,WAAuB;AAE9D,IAAM,OAAO;AACb,IAAM,YAAQ,gBAAI,QAAS;AAEpB,IAAM,SAAS;AAAA,EACrB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,CAAE,kBAAmB,GAAG;AAAA,EACxB,KAAM,EAAE,UAAU,OAAO,UAAU,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { formatItalic } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { essentialFormatKey } = unlock( blockEditorPrivateApis );\n\nconst name = 'core/italic';\nconst title = __( 'Italic' );\n\nexport const italic = {\n\tname,\n\ttitle,\n\ttagName: 'em',\n\tclassName: null,\n\t[ essentialFormatKey ]: true,\n\tedit( { isActive, value, onChange, onFocus, isVisible = true } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonChange( toggleFormat( value, { type: name } ) );\n\t\t\tonFocus();\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=\"i\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t{ isVisible && (\n\t\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\t\tname=\"italic\"\n\t\t\t\t\t\ticon={ formatItalic }\n\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\t\tshortcutType=\"primary\"\n\t\t\t\t\t\tshortcutCharacter=\"i\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatItalic\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,uBAA6B;AAC7B,0BAKO;AACP,mBAA6B;AAK7B,yBAAuB;AAwBpB;AAtBH,IAAM,EAAE,mBAAmB,QAAI,2BAAQ,oBAAAA,WAAuB;AAE9D,IAAM,OAAO;AACb,IAAM,YAAQ,gBAAI,QAAS;AAEpB,IAAM,SAAS;AAAA,EACrB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,CAAE,kBAAmB,GAAG;AAAA,EACxB,KAAM,EAAE,UAAU,OAAO,UAAU,SAAS,YAAY,KAAK,GAAI;AAChE,aAAS,WAAW;AACnB,mBAAU,+BAAc,OAAO,EAAE,MAAM,MAAM,MAAM,CAAE,CAAE;AAAA,IACxD;AAEA,aAAS,UAAU;AAClB,mBAAU,+BAAc,OAAO,EAAE,MAAM,KAAK,CAAE,CAAE;AAChD,cAAQ;AAAA,IACT;AAEA,WACC,4EACC;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,MAAK;AAAA,UACL,WAAU;AAAA,UACV,OAAQ;AAAA;AAAA,MACT;AAAA,MACE,aACD;AAAA,QAAC;AAAA;AAAA,UACA,MAAK;AAAA,UACL,MAAO;AAAA,UACP;AAAA,UACA;AAAA,UACA;AAAA,UACA,cAAa;AAAA,UACb,mBAAkB;AAAA;AAAA,MACnB;AAAA,MAED;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,SAAU;AAAA;AAAA,MACX;AAAA,OACD;AAAA,EAEF;AACD;",
|
|
6
6
|
"names": ["blockEditorPrivateApis"]
|
|
7
7
|
}
|
package/build/link/index.js
CHANGED
|
@@ -53,7 +53,8 @@ function Edit({
|
|
|
53
53
|
value,
|
|
54
54
|
onChange,
|
|
55
55
|
onFocus,
|
|
56
|
-
contentRef
|
|
56
|
+
contentRef,
|
|
57
|
+
isVisible = true
|
|
57
58
|
}) {
|
|
58
59
|
const [addingLink, setAddingLink] = (0, import_element.useState)(false);
|
|
59
60
|
const [openedBy, setOpenedBy] = (0, import_element.useState)(null);
|
|
@@ -154,7 +155,7 @@ function Edit({
|
|
|
154
155
|
onUse: onRemoveFormat
|
|
155
156
|
}
|
|
156
157
|
),
|
|
157
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
158
|
+
isVisible && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
158
159
|
import_block_editor.RichTextToolbarButton,
|
|
159
160
|
{
|
|
160
161
|
name: "link",
|
|
@@ -170,7 +171,7 @@ function Edit({
|
|
|
170
171
|
"aria-expanded": addingLink
|
|
171
172
|
}
|
|
172
173
|
),
|
|
173
|
-
addingLink && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
174
|
+
isVisible && addingLink && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
174
175
|
import_inline.default,
|
|
175
176
|
{
|
|
176
177
|
stopAddingLink,
|
package/build/link/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/link/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useLayoutEffect, useEffect } from '@wordpress/element';\nimport {\n\tgetTextContent,\n\tapplyFormat,\n\tremoveFormat,\n\tslice,\n\tisCollapsed,\n\tinsert,\n\tcreate,\n} from '@wordpress/rich-text';\nimport { isURL, isEmail, isPhoneNumber } from '@wordpress/url';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { link as linkIcon } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport InlineLinkUI from './inline';\nimport { isValidHref } from './utils';\nimport { unlock } from '../lock-unlock';\n\nconst { essentialFormatKey } = unlock( blockEditorPrivateApis );\n\nconst name = 'core/link';\nconst title = __( 'Link' );\n\nfunction Edit( {\n\tisActive,\n\tactiveAttributes,\n\tvalue,\n\tonChange,\n\tonFocus,\n\tcontentRef,\n} ) {\n\tconst [ addingLink, setAddingLink ] = useState( false );\n\n\t// We only need to store the button element that opened the popover. We can ignore the other states, as they will be handled by the onFocus prop to return to the rich text field.\n\tconst [ openedBy, setOpenedBy ] = useState( null );\n\n\tuseEffect( () => {\n\t\t// When the link becomes inactive (i.e. isActive is false), reset the editingLink state\n\t\t// and the creatingLink state. This means that if the Link UI is displayed and the link\n\t\t// becomes inactive (e.g. used arrow keys to move cursor outside of link bounds), the UI will close.\n\t\tif ( ! isActive ) {\n\t\t\tsetAddingLink( false );\n\t\t}\n\t}, [ isActive ] );\n\n\tuseLayoutEffect( () => {\n\t\tconst editableContentElement = contentRef.current;\n\t\tif ( ! editableContentElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction handleClick( event ) {\n\t\t\t// There is a situation whereby there is an existing link in the rich text\n\t\t\t// and the user clicks on the leftmost edge of that link and fails to activate\n\t\t\t// the link format, but the click event still fires on the `<a>` element.\n\t\t\t// This causes the `editingLink` state to be set to `true` and the link UI\n\t\t\t// to be rendered in \"creating\" mode. We need to check isActive to see if\n\t\t\t// we have an active link format.\n\t\t\tconst link = event.target.closest( '[contenteditable] a' );\n\t\t\tif (\n\t\t\t\t! link || // other formats (e.g. bold) may be nested within the link.\n\t\t\t\t! isActive\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetAddingLink( true );\n\t\t\tsetOpenedBy( {\n\t\t\t\tel: link,\n\t\t\t\taction: 'click',\n\t\t\t} );\n\t\t}\n\n\t\teditableContentElement.addEventListener( 'click', handleClick );\n\n\t\treturn () => {\n\t\t\teditableContentElement.removeEventListener( 'click', handleClick );\n\t\t};\n\t}, [ contentRef, isActive ] );\n\n\tfunction addLink( target ) {\n\t\tconst text = getTextContent( slice( value ) );\n\n\t\tif ( ! isActive && text && isURL( text ) && isValidHref( text ) ) {\n\t\t\tonChange(\n\t\t\t\tapplyFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: { url: text },\n\t\t\t\t} )\n\t\t\t);\n\t\t} else if ( ! isActive && text && isEmail( text ) ) {\n\t\t\tonChange(\n\t\t\t\tapplyFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: { url: `mailto:${ text }` },\n\t\t\t\t} )\n\t\t\t);\n\t\t} else if ( ! isActive && text && isPhoneNumber( text ) ) {\n\t\t\tonChange(\n\t\t\t\tapplyFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: { url: `tel:${ text.replace( /\\D/g, '' ) }` },\n\t\t\t\t} )\n\t\t\t);\n\t\t} else {\n\t\t\tif ( target ) {\n\t\t\t\tsetOpenedBy( {\n\t\t\t\t\tel: target,\n\t\t\t\t\taction: null, // We don't need to distinguish between click or keyboard here\n\t\t\t\t} );\n\t\t\t}\n\t\t\tsetAddingLink( true );\n\t\t}\n\t}\n\n\t/**\n\t * Runs when the popover is closed via escape keypress, unlinking the selected text,\n\t * but _not_ on a click outside the popover. onFocusOutside handles that.\n\t */\n\tfunction stopAddingLink() {\n\t\t// Don't let the click handler on the toolbar button trigger again.\n\n\t\t// There are two places for us to return focus to on Escape keypress:\n\t\t// 1. The rich text field.\n\t\t// 2. The toolbar button.\n\n\t\t// The toolbar button is the only one we need to handle returning focus to.\n\t\t// Otherwise, we rely on the passed in onFocus to return focus to the rich text field.\n\n\t\t// Close the popover\n\t\tsetAddingLink( false );\n\n\t\t// Return focus to the toolbar button or the rich text field\n\t\tif ( openedBy?.el?.tagName === 'BUTTON' ) {\n\t\t\topenedBy.el.focus();\n\t\t} else {\n\t\t\tonFocus();\n\t\t}\n\t\t// Remove the openedBy state\n\t\tsetOpenedBy( null );\n\t}\n\n\t// Test for this:\n\t// 1. Click on the link button\n\t// 2. Click the Options button in the top right of header\n\t// 3. Focus should be in the dropdown of the Options button\n\t// 4. Press Escape\n\t// 5. Focus should be on the Options button\n\tfunction onFocusOutside() {\n\t\tsetAddingLink( false );\n\t\tsetOpenedBy( null );\n\t}\n\n\tfunction onRemoveFormat() {\n\t\tonChange( removeFormat( value, name ) );\n\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t}\n\n\t// Only autofocus if we have clicked a link within the editor\n\tconst shouldAutoFocus = ! (\n\t\topenedBy?.el?.tagName === 'A' && openedBy?.action === 'click'\n\t);\n\n\tconst hasSelection = ! isCollapsed( value );\n\n\treturn (\n\t\t<>\n\t\t\t{ hasSelection && (\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\tcharacter=\"k\"\n\t\t\t\t\tonUse={ addLink }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<RichTextShortcut\n\t\t\t\ttype=\"primaryShift\"\n\t\t\t\tcharacter=\"k\"\n\t\t\t\tonUse={ onRemoveFormat }\n\t\t\t/>\n\t\t\t<RichTextToolbarButton\n\t\t\t\tname=\"link\"\n\t\t\t\ticon={ linkIcon }\n\t\t\t\ttitle={ isActive ? __( 'Link' ) : title }\n\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\taddLink( event.currentTarget );\n\t\t\t\t} }\n\t\t\t\tisActive={ isActive || addingLink }\n\t\t\t\tshortcutType=\"primary\"\n\t\t\t\tshortcutCharacter=\"k\"\n\t\t\t\taria-haspopup=\"true\"\n\t\t\t\taria-expanded={ addingLink }\n\t\t\t/>\n\t\t\t{ addingLink && (\n\t\t\t\t<InlineLinkUI\n\t\t\t\t\tstopAddingLink={ stopAddingLink }\n\t\t\t\t\tonFocusOutside={ onFocusOutside }\n\t\t\t\t\tisActive={ isActive }\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\tfocusOnMount={ shouldAutoFocus ? 'firstElement' : false }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const link = {\n\tname,\n\ttitle,\n\ttagName: 'a',\n\tclassName: null,\n\tattributes: {\n\t\turl: 'href',\n\t\ttype: 'data-type',\n\t\tid: 'data-id',\n\t\t_id: 'id',\n\t\ttarget: 'target',\n\t\trel: 'rel',\n\t\tclass: 'class',\n\t},\n\t[ essentialFormatKey ]: true,\n\t__unstablePasteRule( value, { html, plainText } ) {\n\t\tconst pastedText = ( html || plainText )\n\t\t\t.replace( /<[^>]+>/g, '' )\n\t\t\t.trim();\n\n\t\t// A URL was pasted, turn the selection into a link.\n\t\t// For the link pasting feature, allow only http(s) protocols.\n\t\tif ( ! isURL( pastedText ) || ! /^https?:/.test( pastedText ) ) {\n\t\t\treturn value;\n\t\t}\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\twindow.console.log( 'Created link:\\n\\n', pastedText );\n\n\t\tconst format = {\n\t\t\ttype: name,\n\t\t\tattributes: {\n\t\t\t\turl: decodeEntities( pastedText ),\n\t\t\t},\n\t\t};\n\n\t\tif ( isCollapsed( value ) ) {\n\t\t\treturn insert(\n\t\t\t\tvalue,\n\t\t\t\tapplyFormat(\n\t\t\t\t\tcreate( { text: plainText } ),\n\t\t\t\t\tformat,\n\t\t\t\t\t0,\n\t\t\t\t\tplainText.length\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\treturn applyFormat( value, format );\n\t},\n\tedit: Edit,\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,qBAAqD;AACrD,uBAQO;AACP,iBAA8C;AAC9C,0BAIO;AACP,2BAA+B;AAC/B,mBAAiC;AACjC,kBAAsB;AAKtB,oBAAyB;AACzB,mBAA4B;AAC5B,yBAAuB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useLayoutEffect, useEffect } from '@wordpress/element';\nimport {\n\tgetTextContent,\n\tapplyFormat,\n\tremoveFormat,\n\tslice,\n\tisCollapsed,\n\tinsert,\n\tcreate,\n} from '@wordpress/rich-text';\nimport { isURL, isEmail, isPhoneNumber } from '@wordpress/url';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { link as linkIcon } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport InlineLinkUI from './inline';\nimport { isValidHref } from './utils';\nimport { unlock } from '../lock-unlock';\n\nconst { essentialFormatKey } = unlock( blockEditorPrivateApis );\n\nconst name = 'core/link';\nconst title = __( 'Link' );\n\nfunction Edit( {\n\tisActive,\n\tactiveAttributes,\n\tvalue,\n\tonChange,\n\tonFocus,\n\tcontentRef,\n\tisVisible = true,\n} ) {\n\tconst [ addingLink, setAddingLink ] = useState( false );\n\n\t// We only need to store the button element that opened the popover. We can ignore the other states, as they will be handled by the onFocus prop to return to the rich text field.\n\tconst [ openedBy, setOpenedBy ] = useState( null );\n\n\tuseEffect( () => {\n\t\t// When the link becomes inactive (i.e. isActive is false), reset the editingLink state\n\t\t// and the creatingLink state. This means that if the Link UI is displayed and the link\n\t\t// becomes inactive (e.g. used arrow keys to move cursor outside of link bounds), the UI will close.\n\t\tif ( ! isActive ) {\n\t\t\tsetAddingLink( false );\n\t\t}\n\t}, [ isActive ] );\n\n\tuseLayoutEffect( () => {\n\t\tconst editableContentElement = contentRef.current;\n\t\tif ( ! editableContentElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction handleClick( event ) {\n\t\t\t// There is a situation whereby there is an existing link in the rich text\n\t\t\t// and the user clicks on the leftmost edge of that link and fails to activate\n\t\t\t// the link format, but the click event still fires on the `<a>` element.\n\t\t\t// This causes the `editingLink` state to be set to `true` and the link UI\n\t\t\t// to be rendered in \"creating\" mode. We need to check isActive to see if\n\t\t\t// we have an active link format.\n\t\t\tconst link = event.target.closest( '[contenteditable] a' );\n\t\t\tif (\n\t\t\t\t! link || // other formats (e.g. bold) may be nested within the link.\n\t\t\t\t! isActive\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetAddingLink( true );\n\t\t\tsetOpenedBy( {\n\t\t\t\tel: link,\n\t\t\t\taction: 'click',\n\t\t\t} );\n\t\t}\n\n\t\teditableContentElement.addEventListener( 'click', handleClick );\n\n\t\treturn () => {\n\t\t\teditableContentElement.removeEventListener( 'click', handleClick );\n\t\t};\n\t}, [ contentRef, isActive ] );\n\n\tfunction addLink( target ) {\n\t\tconst text = getTextContent( slice( value ) );\n\n\t\tif ( ! isActive && text && isURL( text ) && isValidHref( text ) ) {\n\t\t\tonChange(\n\t\t\t\tapplyFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: { url: text },\n\t\t\t\t} )\n\t\t\t);\n\t\t} else if ( ! isActive && text && isEmail( text ) ) {\n\t\t\tonChange(\n\t\t\t\tapplyFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: { url: `mailto:${ text }` },\n\t\t\t\t} )\n\t\t\t);\n\t\t} else if ( ! isActive && text && isPhoneNumber( text ) ) {\n\t\t\tonChange(\n\t\t\t\tapplyFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: { url: `tel:${ text.replace( /\\D/g, '' ) }` },\n\t\t\t\t} )\n\t\t\t);\n\t\t} else {\n\t\t\tif ( target ) {\n\t\t\t\tsetOpenedBy( {\n\t\t\t\t\tel: target,\n\t\t\t\t\taction: null, // We don't need to distinguish between click or keyboard here\n\t\t\t\t} );\n\t\t\t}\n\t\t\tsetAddingLink( true );\n\t\t}\n\t}\n\n\t/**\n\t * Runs when the popover is closed via escape keypress, unlinking the selected text,\n\t * but _not_ on a click outside the popover. onFocusOutside handles that.\n\t */\n\tfunction stopAddingLink() {\n\t\t// Don't let the click handler on the toolbar button trigger again.\n\n\t\t// There are two places for us to return focus to on Escape keypress:\n\t\t// 1. The rich text field.\n\t\t// 2. The toolbar button.\n\n\t\t// The toolbar button is the only one we need to handle returning focus to.\n\t\t// Otherwise, we rely on the passed in onFocus to return focus to the rich text field.\n\n\t\t// Close the popover\n\t\tsetAddingLink( false );\n\n\t\t// Return focus to the toolbar button or the rich text field\n\t\tif ( openedBy?.el?.tagName === 'BUTTON' ) {\n\t\t\topenedBy.el.focus();\n\t\t} else {\n\t\t\tonFocus();\n\t\t}\n\t\t// Remove the openedBy state\n\t\tsetOpenedBy( null );\n\t}\n\n\t// Test for this:\n\t// 1. Click on the link button\n\t// 2. Click the Options button in the top right of header\n\t// 3. Focus should be in the dropdown of the Options button\n\t// 4. Press Escape\n\t// 5. Focus should be on the Options button\n\tfunction onFocusOutside() {\n\t\tsetAddingLink( false );\n\t\tsetOpenedBy( null );\n\t}\n\n\tfunction onRemoveFormat() {\n\t\tonChange( removeFormat( value, name ) );\n\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t}\n\n\t// Only autofocus if we have clicked a link within the editor\n\tconst shouldAutoFocus = ! (\n\t\topenedBy?.el?.tagName === 'A' && openedBy?.action === 'click'\n\t);\n\n\tconst hasSelection = ! isCollapsed( value );\n\n\treturn (\n\t\t<>\n\t\t\t{ hasSelection && (\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\tcharacter=\"k\"\n\t\t\t\t\tonUse={ addLink }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<RichTextShortcut\n\t\t\t\ttype=\"primaryShift\"\n\t\t\t\tcharacter=\"k\"\n\t\t\t\tonUse={ onRemoveFormat }\n\t\t\t/>\n\t\t\t{ isVisible && (\n\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\tname=\"link\"\n\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\ttitle={ isActive ? __( 'Link' ) : title }\n\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\taddLink( event.currentTarget );\n\t\t\t\t\t} }\n\t\t\t\t\tisActive={ isActive || addingLink }\n\t\t\t\t\tshortcutType=\"primary\"\n\t\t\t\t\tshortcutCharacter=\"k\"\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\taria-expanded={ addingLink }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isVisible && addingLink && (\n\t\t\t\t<InlineLinkUI\n\t\t\t\t\tstopAddingLink={ stopAddingLink }\n\t\t\t\t\tonFocusOutside={ onFocusOutside }\n\t\t\t\t\tisActive={ isActive }\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\tfocusOnMount={ shouldAutoFocus ? 'firstElement' : false }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const link = {\n\tname,\n\ttitle,\n\ttagName: 'a',\n\tclassName: null,\n\tattributes: {\n\t\turl: 'href',\n\t\ttype: 'data-type',\n\t\tid: 'data-id',\n\t\t_id: 'id',\n\t\ttarget: 'target',\n\t\trel: 'rel',\n\t\tclass: 'class',\n\t},\n\t[ essentialFormatKey ]: true,\n\t__unstablePasteRule( value, { html, plainText } ) {\n\t\tconst pastedText = ( html || plainText )\n\t\t\t.replace( /<[^>]+>/g, '' )\n\t\t\t.trim();\n\n\t\t// A URL was pasted, turn the selection into a link.\n\t\t// For the link pasting feature, allow only http(s) protocols.\n\t\tif ( ! isURL( pastedText ) || ! /^https?:/.test( pastedText ) ) {\n\t\t\treturn value;\n\t\t}\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\twindow.console.log( 'Created link:\\n\\n', pastedText );\n\n\t\tconst format = {\n\t\t\ttype: name,\n\t\t\tattributes: {\n\t\t\t\turl: decodeEntities( pastedText ),\n\t\t\t},\n\t\t};\n\n\t\tif ( isCollapsed( value ) ) {\n\t\t\treturn insert(\n\t\t\t\tvalue,\n\t\t\t\tapplyFormat(\n\t\t\t\t\tcreate( { text: plainText } ),\n\t\t\t\t\tformat,\n\t\t\t\t\t0,\n\t\t\t\t\tplainText.length\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\treturn applyFormat( value, format );\n\t},\n\tedit: Edit,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,qBAAqD;AACrD,uBAQO;AACP,iBAA8C;AAC9C,0BAIO;AAC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A;AAAA,UACA,UAAU;AAAA,QACX;AAAA,MACD;AAAA,IACD;AAEA,eAAO,8BAAa,OAAO,MAAO;AAAA,EACnC;AAAA,EACA,MAAM;AACP;",
|
|
6
6
|
"names": ["blockEditorPrivateApis", "link", "linkIcon", "InlineLinkUI"]
|
|
7
7
|
}
|
|
@@ -19,7 +19,7 @@ var bold = {
|
|
|
19
19
|
tagName: "strong",
|
|
20
20
|
className: null,
|
|
21
21
|
[essentialFormatKey]: true,
|
|
22
|
-
edit({ isActive, value, onChange, onFocus }) {
|
|
22
|
+
edit({ isActive, value, onChange, onFocus, isVisible = true }) {
|
|
23
23
|
function onToggle() {
|
|
24
24
|
onChange(toggleFormat(value, { type: name, title }));
|
|
25
25
|
}
|
|
@@ -36,7 +36,7 @@ var bold = {
|
|
|
36
36
|
onUse: onToggle
|
|
37
37
|
}
|
|
38
38
|
),
|
|
39
|
-
/* @__PURE__ */ jsx(
|
|
39
|
+
isVisible && /* @__PURE__ */ jsx(
|
|
40
40
|
RichTextToolbarButton,
|
|
41
41
|
{
|
|
42
42
|
name: "bold",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/bold/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { formatBold } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { essentialFormatKey } = unlock( blockEditorPrivateApis );\n\nconst name = 'core/bold';\nconst title = __( 'Bold' );\n\nexport const bold = {\n\tname,\n\ttitle,\n\ttagName: 'strong',\n\tclassName: null,\n\t[ essentialFormatKey ]: true,\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\tonChange( toggleFormat( value, { type: name } ) );\n\t\t\tonFocus();\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=\"b\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\tname=\"bold\"\n\t\t\t\t\ticon={ formatBold }\n\t\t\t\t\ttitle={ title }\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\tshortcutType=\"primary\"\n\t\t\t\t\tshortcutCharacter=\"b\"\n\t\t\t\t/>\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatBold\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,kBAAkB;AAK3B,SAAS,cAAc;AAwBpB,mBACC,KADD;AAtBH,IAAM,EAAE,mBAAmB,IAAI,OAAQ,sBAAuB;AAE9D,IAAM,OAAO;AACb,IAAM,QAAQ,GAAI,MAAO;AAElB,IAAM,OAAO;AAAA,EACnB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,CAAE,kBAAmB,GAAG;AAAA,EACxB,KAAM,EAAE,UAAU,OAAO,UAAU,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { formatBold } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { essentialFormatKey } = unlock( blockEditorPrivateApis );\n\nconst name = 'core/bold';\nconst title = __( 'Bold' );\n\nexport const bold = {\n\tname,\n\ttitle,\n\ttagName: 'strong',\n\tclassName: null,\n\t[ essentialFormatKey ]: true,\n\tedit( { isActive, value, onChange, onFocus, isVisible = true } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonChange( toggleFormat( value, { type: name } ) );\n\t\t\tonFocus();\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=\"b\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t{ isVisible && (\n\t\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\t\tname=\"bold\"\n\t\t\t\t\t\ticon={ formatBold }\n\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\t\tshortcutType=\"primary\"\n\t\t\t\t\t\tshortcutCharacter=\"b\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatBold\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,kBAAkB;AAK3B,SAAS,cAAc;AAwBpB,mBACC,KADD;AAtBH,IAAM,EAAE,mBAAmB,IAAI,OAAQ,sBAAuB;AAE9D,IAAM,OAAO;AACb,IAAM,QAAQ,GAAI,MAAO;AAElB,IAAM,OAAO;AAAA,EACnB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,CAAE,kBAAmB,GAAG;AAAA,EACxB,KAAM,EAAE,UAAU,OAAO,UAAU,SAAS,YAAY,KAAK,GAAI;AAChE,aAAS,WAAW;AACnB,eAAU,aAAc,OAAO,EAAE,MAAM,MAAM,MAAM,CAAE,CAAE;AAAA,IACxD;AAEA,aAAS,UAAU;AAClB,eAAU,aAAc,OAAO,EAAE,MAAM,KAAK,CAAE,CAAE;AAChD,cAAQ;AAAA,IACT;AAEA,WACC,iCACC;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,MAAK;AAAA,UACL,WAAU;AAAA,UACV,OAAQ;AAAA;AAAA,MACT;AAAA,MACE,aACD;AAAA,QAAC;AAAA;AAAA,UACA,MAAK;AAAA,UACL,MAAO;AAAA,UACP;AAAA,UACA;AAAA,UACA;AAAA,UACA,cAAa;AAAA,UACb,mBAAkB;AAAA;AAAA,MACnB;AAAA,MAED;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,SAAU;AAAA;AAAA,MACX;AAAA,OACD;AAAA,EAEF;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -19,7 +19,7 @@ var italic = {
|
|
|
19
19
|
tagName: "em",
|
|
20
20
|
className: null,
|
|
21
21
|
[essentialFormatKey]: true,
|
|
22
|
-
edit({ isActive, value, onChange, onFocus }) {
|
|
22
|
+
edit({ isActive, value, onChange, onFocus, isVisible = true }) {
|
|
23
23
|
function onToggle() {
|
|
24
24
|
onChange(toggleFormat(value, { type: name, title }));
|
|
25
25
|
}
|
|
@@ -36,7 +36,7 @@ var italic = {
|
|
|
36
36
|
onUse: onToggle
|
|
37
37
|
}
|
|
38
38
|
),
|
|
39
|
-
/* @__PURE__ */ jsx(
|
|
39
|
+
isVisible && /* @__PURE__ */ jsx(
|
|
40
40
|
RichTextToolbarButton,
|
|
41
41
|
{
|
|
42
42
|
name: "italic",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/italic/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { formatItalic } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { essentialFormatKey } = unlock( blockEditorPrivateApis );\n\nconst name = 'core/italic';\nconst title = __( 'Italic' );\n\nexport const italic = {\n\tname,\n\ttitle,\n\ttagName: 'em',\n\tclassName: null,\n\t[ essentialFormatKey ]: true,\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\tonChange( toggleFormat( value, { type: name } ) );\n\t\t\tonFocus();\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=\"i\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\tname=\"italic\"\n\t\t\t\t\ticon={ formatItalic }\n\t\t\t\t\ttitle={ title }\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\tshortcutType=\"primary\"\n\t\t\t\t\tshortcutCharacter=\"i\"\n\t\t\t\t/>\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatItalic\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,oBAAoB;AAK7B,SAAS,cAAc;AAwBpB,mBACC,KADD;AAtBH,IAAM,EAAE,mBAAmB,IAAI,OAAQ,sBAAuB;AAE9D,IAAM,OAAO;AACb,IAAM,QAAQ,GAAI,QAAS;AAEpB,IAAM,SAAS;AAAA,EACrB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,CAAE,kBAAmB,GAAG;AAAA,EACxB,KAAM,EAAE,UAAU,OAAO,UAAU,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { formatItalic } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { essentialFormatKey } = unlock( blockEditorPrivateApis );\n\nconst name = 'core/italic';\nconst title = __( 'Italic' );\n\nexport const italic = {\n\tname,\n\ttitle,\n\ttagName: 'em',\n\tclassName: null,\n\t[ essentialFormatKey ]: true,\n\tedit( { isActive, value, onChange, onFocus, isVisible = true } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonChange( toggleFormat( value, { type: name } ) );\n\t\t\tonFocus();\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=\"i\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t{ isVisible && (\n\t\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\t\tname=\"italic\"\n\t\t\t\t\t\ticon={ formatItalic }\n\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\t\tshortcutType=\"primary\"\n\t\t\t\t\t\tshortcutCharacter=\"i\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatItalic\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,oBAAoB;AAK7B,SAAS,cAAc;AAwBpB,mBACC,KADD;AAtBH,IAAM,EAAE,mBAAmB,IAAI,OAAQ,sBAAuB;AAE9D,IAAM,OAAO;AACb,IAAM,QAAQ,GAAI,QAAS;AAEpB,IAAM,SAAS;AAAA,EACrB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,CAAE,kBAAmB,GAAG;AAAA,EACxB,KAAM,EAAE,UAAU,OAAO,UAAU,SAAS,YAAY,KAAK,GAAI;AAChE,aAAS,WAAW;AACnB,eAAU,aAAc,OAAO,EAAE,MAAM,MAAM,MAAM,CAAE,CAAE;AAAA,IACxD;AAEA,aAAS,UAAU;AAClB,eAAU,aAAc,OAAO,EAAE,MAAM,KAAK,CAAE,CAAE;AAChD,cAAQ;AAAA,IACT;AAEA,WACC,iCACC;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,MAAK;AAAA,UACL,WAAU;AAAA,UACV,OAAQ;AAAA;AAAA,MACT;AAAA,MACE,aACD;AAAA,QAAC;AAAA;AAAA,UACA,MAAK;AAAA,UACL,MAAO;AAAA,UACP;AAAA,UACA;AAAA,UACA;AAAA,UACA,cAAa;AAAA,UACb,mBAAkB;AAAA;AAAA,MACnB;AAAA,MAED;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,SAAU;AAAA;AAAA,MACX;AAAA,OACD;AAAA,EAEF;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -32,7 +32,8 @@ function Edit({
|
|
|
32
32
|
value,
|
|
33
33
|
onChange,
|
|
34
34
|
onFocus,
|
|
35
|
-
contentRef
|
|
35
|
+
contentRef,
|
|
36
|
+
isVisible = true
|
|
36
37
|
}) {
|
|
37
38
|
const [addingLink, setAddingLink] = useState(false);
|
|
38
39
|
const [openedBy, setOpenedBy] = useState(null);
|
|
@@ -133,7 +134,7 @@ function Edit({
|
|
|
133
134
|
onUse: onRemoveFormat
|
|
134
135
|
}
|
|
135
136
|
),
|
|
136
|
-
/* @__PURE__ */ jsx(
|
|
137
|
+
isVisible && /* @__PURE__ */ jsx(
|
|
137
138
|
RichTextToolbarButton,
|
|
138
139
|
{
|
|
139
140
|
name: "link",
|
|
@@ -149,7 +150,7 @@ function Edit({
|
|
|
149
150
|
"aria-expanded": addingLink
|
|
150
151
|
}
|
|
151
152
|
),
|
|
152
|
-
addingLink && /* @__PURE__ */ jsx(
|
|
153
|
+
isVisible && addingLink && /* @__PURE__ */ jsx(
|
|
153
154
|
InlineLinkUI,
|
|
154
155
|
{
|
|
155
156
|
stopAddingLink,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/link/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useLayoutEffect, useEffect } from '@wordpress/element';\nimport {\n\tgetTextContent,\n\tapplyFormat,\n\tremoveFormat,\n\tslice,\n\tisCollapsed,\n\tinsert,\n\tcreate,\n} from '@wordpress/rich-text';\nimport { isURL, isEmail, isPhoneNumber } from '@wordpress/url';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { link as linkIcon } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport InlineLinkUI from './inline';\nimport { isValidHref } from './utils';\nimport { unlock } from '../lock-unlock';\n\nconst { essentialFormatKey } = unlock( blockEditorPrivateApis );\n\nconst name = 'core/link';\nconst title = __( 'Link' );\n\nfunction Edit( {\n\tisActive,\n\tactiveAttributes,\n\tvalue,\n\tonChange,\n\tonFocus,\n\tcontentRef,\n} ) {\n\tconst [ addingLink, setAddingLink ] = useState( false );\n\n\t// We only need to store the button element that opened the popover. We can ignore the other states, as they will be handled by the onFocus prop to return to the rich text field.\n\tconst [ openedBy, setOpenedBy ] = useState( null );\n\n\tuseEffect( () => {\n\t\t// When the link becomes inactive (i.e. isActive is false), reset the editingLink state\n\t\t// and the creatingLink state. This means that if the Link UI is displayed and the link\n\t\t// becomes inactive (e.g. used arrow keys to move cursor outside of link bounds), the UI will close.\n\t\tif ( ! isActive ) {\n\t\t\tsetAddingLink( false );\n\t\t}\n\t}, [ isActive ] );\n\n\tuseLayoutEffect( () => {\n\t\tconst editableContentElement = contentRef.current;\n\t\tif ( ! editableContentElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction handleClick( event ) {\n\t\t\t// There is a situation whereby there is an existing link in the rich text\n\t\t\t// and the user clicks on the leftmost edge of that link and fails to activate\n\t\t\t// the link format, but the click event still fires on the `<a>` element.\n\t\t\t// This causes the `editingLink` state to be set to `true` and the link UI\n\t\t\t// to be rendered in \"creating\" mode. We need to check isActive to see if\n\t\t\t// we have an active link format.\n\t\t\tconst link = event.target.closest( '[contenteditable] a' );\n\t\t\tif (\n\t\t\t\t! link || // other formats (e.g. bold) may be nested within the link.\n\t\t\t\t! isActive\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetAddingLink( true );\n\t\t\tsetOpenedBy( {\n\t\t\t\tel: link,\n\t\t\t\taction: 'click',\n\t\t\t} );\n\t\t}\n\n\t\teditableContentElement.addEventListener( 'click', handleClick );\n\n\t\treturn () => {\n\t\t\teditableContentElement.removeEventListener( 'click', handleClick );\n\t\t};\n\t}, [ contentRef, isActive ] );\n\n\tfunction addLink( target ) {\n\t\tconst text = getTextContent( slice( value ) );\n\n\t\tif ( ! isActive && text && isURL( text ) && isValidHref( text ) ) {\n\t\t\tonChange(\n\t\t\t\tapplyFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: { url: text },\n\t\t\t\t} )\n\t\t\t);\n\t\t} else if ( ! isActive && text && isEmail( text ) ) {\n\t\t\tonChange(\n\t\t\t\tapplyFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: { url: `mailto:${ text }` },\n\t\t\t\t} )\n\t\t\t);\n\t\t} else if ( ! isActive && text && isPhoneNumber( text ) ) {\n\t\t\tonChange(\n\t\t\t\tapplyFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: { url: `tel:${ text.replace( /\\D/g, '' ) }` },\n\t\t\t\t} )\n\t\t\t);\n\t\t} else {\n\t\t\tif ( target ) {\n\t\t\t\tsetOpenedBy( {\n\t\t\t\t\tel: target,\n\t\t\t\t\taction: null, // We don't need to distinguish between click or keyboard here\n\t\t\t\t} );\n\t\t\t}\n\t\t\tsetAddingLink( true );\n\t\t}\n\t}\n\n\t/**\n\t * Runs when the popover is closed via escape keypress, unlinking the selected text,\n\t * but _not_ on a click outside the popover. onFocusOutside handles that.\n\t */\n\tfunction stopAddingLink() {\n\t\t// Don't let the click handler on the toolbar button trigger again.\n\n\t\t// There are two places for us to return focus to on Escape keypress:\n\t\t// 1. The rich text field.\n\t\t// 2. The toolbar button.\n\n\t\t// The toolbar button is the only one we need to handle returning focus to.\n\t\t// Otherwise, we rely on the passed in onFocus to return focus to the rich text field.\n\n\t\t// Close the popover\n\t\tsetAddingLink( false );\n\n\t\t// Return focus to the toolbar button or the rich text field\n\t\tif ( openedBy?.el?.tagName === 'BUTTON' ) {\n\t\t\topenedBy.el.focus();\n\t\t} else {\n\t\t\tonFocus();\n\t\t}\n\t\t// Remove the openedBy state\n\t\tsetOpenedBy( null );\n\t}\n\n\t// Test for this:\n\t// 1. Click on the link button\n\t// 2. Click the Options button in the top right of header\n\t// 3. Focus should be in the dropdown of the Options button\n\t// 4. Press Escape\n\t// 5. Focus should be on the Options button\n\tfunction onFocusOutside() {\n\t\tsetAddingLink( false );\n\t\tsetOpenedBy( null );\n\t}\n\n\tfunction onRemoveFormat() {\n\t\tonChange( removeFormat( value, name ) );\n\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t}\n\n\t// Only autofocus if we have clicked a link within the editor\n\tconst shouldAutoFocus = ! (\n\t\topenedBy?.el?.tagName === 'A' && openedBy?.action === 'click'\n\t);\n\n\tconst hasSelection = ! isCollapsed( value );\n\n\treturn (\n\t\t<>\n\t\t\t{ hasSelection && (\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\tcharacter=\"k\"\n\t\t\t\t\tonUse={ addLink }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<RichTextShortcut\n\t\t\t\ttype=\"primaryShift\"\n\t\t\t\tcharacter=\"k\"\n\t\t\t\tonUse={ onRemoveFormat }\n\t\t\t/>\n\t\t\t<RichTextToolbarButton\n\t\t\t\tname=\"link\"\n\t\t\t\ticon={ linkIcon }\n\t\t\t\ttitle={ isActive ? __( 'Link' ) : title }\n\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\taddLink( event.currentTarget );\n\t\t\t\t} }\n\t\t\t\tisActive={ isActive || addingLink }\n\t\t\t\tshortcutType=\"primary\"\n\t\t\t\tshortcutCharacter=\"k\"\n\t\t\t\taria-haspopup=\"true\"\n\t\t\t\taria-expanded={ addingLink }\n\t\t\t/>\n\t\t\t{ addingLink && (\n\t\t\t\t<InlineLinkUI\n\t\t\t\t\tstopAddingLink={ stopAddingLink }\n\t\t\t\t\tonFocusOutside={ onFocusOutside }\n\t\t\t\t\tisActive={ isActive }\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\tfocusOnMount={ shouldAutoFocus ? 'firstElement' : false }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const link = {\n\tname,\n\ttitle,\n\ttagName: 'a',\n\tclassName: null,\n\tattributes: {\n\t\turl: 'href',\n\t\ttype: 'data-type',\n\t\tid: 'data-id',\n\t\t_id: 'id',\n\t\ttarget: 'target',\n\t\trel: 'rel',\n\t\tclass: 'class',\n\t},\n\t[ essentialFormatKey ]: true,\n\t__unstablePasteRule( value, { html, plainText } ) {\n\t\tconst pastedText = ( html || plainText )\n\t\t\t.replace( /<[^>]+>/g, '' )\n\t\t\t.trim();\n\n\t\t// A URL was pasted, turn the selection into a link.\n\t\t// For the link pasting feature, allow only http(s) protocols.\n\t\tif ( ! isURL( pastedText ) || ! /^https?:/.test( pastedText ) ) {\n\t\t\treturn value;\n\t\t}\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\twindow.console.log( 'Created link:\\n\\n', pastedText );\n\n\t\tconst format = {\n\t\t\ttype: name,\n\t\t\tattributes: {\n\t\t\t\turl: decodeEntities( pastedText ),\n\t\t\t},\n\t\t};\n\n\t\tif ( isCollapsed( value ) ) {\n\t\t\treturn insert(\n\t\t\t\tvalue,\n\t\t\t\tapplyFormat(\n\t\t\t\t\tcreate( { text: plainText } ),\n\t\t\t\t\tformat,\n\t\t\t\t\t0,\n\t\t\t\t\tplainText.length\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\treturn applyFormat( value, format );\n\t},\n\tedit: Edit,\n};\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,UAAU,iBAAiB,iBAAiB;AACrD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,OAAO,SAAS,qBAAqB;AAC9C;AAAA,EACC;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,sBAAsB;AAC/B,SAAS,QAAQ,gBAAgB;AACjC,SAAS,aAAa;AAKtB,OAAO,kBAAkB;AACzB,SAAS,mBAAmB;AAC5B,SAAS,cAAc;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useLayoutEffect, useEffect } from '@wordpress/element';\nimport {\n\tgetTextContent,\n\tapplyFormat,\n\tremoveFormat,\n\tslice,\n\tisCollapsed,\n\tinsert,\n\tcreate,\n} from '@wordpress/rich-text';\nimport { isURL, isEmail, isPhoneNumber } from '@wordpress/url';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { link as linkIcon } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport InlineLinkUI from './inline';\nimport { isValidHref } from './utils';\nimport { unlock } from '../lock-unlock';\n\nconst { essentialFormatKey } = unlock( blockEditorPrivateApis );\n\nconst name = 'core/link';\nconst title = __( 'Link' );\n\nfunction Edit( {\n\tisActive,\n\tactiveAttributes,\n\tvalue,\n\tonChange,\n\tonFocus,\n\tcontentRef,\n\tisVisible = true,\n} ) {\n\tconst [ addingLink, setAddingLink ] = useState( false );\n\n\t// We only need to store the button element that opened the popover. We can ignore the other states, as they will be handled by the onFocus prop to return to the rich text field.\n\tconst [ openedBy, setOpenedBy ] = useState( null );\n\n\tuseEffect( () => {\n\t\t// When the link becomes inactive (i.e. isActive is false), reset the editingLink state\n\t\t// and the creatingLink state. This means that if the Link UI is displayed and the link\n\t\t// becomes inactive (e.g. used arrow keys to move cursor outside of link bounds), the UI will close.\n\t\tif ( ! isActive ) {\n\t\t\tsetAddingLink( false );\n\t\t}\n\t}, [ isActive ] );\n\n\tuseLayoutEffect( () => {\n\t\tconst editableContentElement = contentRef.current;\n\t\tif ( ! editableContentElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction handleClick( event ) {\n\t\t\t// There is a situation whereby there is an existing link in the rich text\n\t\t\t// and the user clicks on the leftmost edge of that link and fails to activate\n\t\t\t// the link format, but the click event still fires on the `<a>` element.\n\t\t\t// This causes the `editingLink` state to be set to `true` and the link UI\n\t\t\t// to be rendered in \"creating\" mode. We need to check isActive to see if\n\t\t\t// we have an active link format.\n\t\t\tconst link = event.target.closest( '[contenteditable] a' );\n\t\t\tif (\n\t\t\t\t! link || // other formats (e.g. bold) may be nested within the link.\n\t\t\t\t! isActive\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetAddingLink( true );\n\t\t\tsetOpenedBy( {\n\t\t\t\tel: link,\n\t\t\t\taction: 'click',\n\t\t\t} );\n\t\t}\n\n\t\teditableContentElement.addEventListener( 'click', handleClick );\n\n\t\treturn () => {\n\t\t\teditableContentElement.removeEventListener( 'click', handleClick );\n\t\t};\n\t}, [ contentRef, isActive ] );\n\n\tfunction addLink( target ) {\n\t\tconst text = getTextContent( slice( value ) );\n\n\t\tif ( ! isActive && text && isURL( text ) && isValidHref( text ) ) {\n\t\t\tonChange(\n\t\t\t\tapplyFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: { url: text },\n\t\t\t\t} )\n\t\t\t);\n\t\t} else if ( ! isActive && text && isEmail( text ) ) {\n\t\t\tonChange(\n\t\t\t\tapplyFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: { url: `mailto:${ text }` },\n\t\t\t\t} )\n\t\t\t);\n\t\t} else if ( ! isActive && text && isPhoneNumber( text ) ) {\n\t\t\tonChange(\n\t\t\t\tapplyFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: { url: `tel:${ text.replace( /\\D/g, '' ) }` },\n\t\t\t\t} )\n\t\t\t);\n\t\t} else {\n\t\t\tif ( target ) {\n\t\t\t\tsetOpenedBy( {\n\t\t\t\t\tel: target,\n\t\t\t\t\taction: null, // We don't need to distinguish between click or keyboard here\n\t\t\t\t} );\n\t\t\t}\n\t\t\tsetAddingLink( true );\n\t\t}\n\t}\n\n\t/**\n\t * Runs when the popover is closed via escape keypress, unlinking the selected text,\n\t * but _not_ on a click outside the popover. onFocusOutside handles that.\n\t */\n\tfunction stopAddingLink() {\n\t\t// Don't let the click handler on the toolbar button trigger again.\n\n\t\t// There are two places for us to return focus to on Escape keypress:\n\t\t// 1. The rich text field.\n\t\t// 2. The toolbar button.\n\n\t\t// The toolbar button is the only one we need to handle returning focus to.\n\t\t// Otherwise, we rely on the passed in onFocus to return focus to the rich text field.\n\n\t\t// Close the popover\n\t\tsetAddingLink( false );\n\n\t\t// Return focus to the toolbar button or the rich text field\n\t\tif ( openedBy?.el?.tagName === 'BUTTON' ) {\n\t\t\topenedBy.el.focus();\n\t\t} else {\n\t\t\tonFocus();\n\t\t}\n\t\t// Remove the openedBy state\n\t\tsetOpenedBy( null );\n\t}\n\n\t// Test for this:\n\t// 1. Click on the link button\n\t// 2. Click the Options button in the top right of header\n\t// 3. Focus should be in the dropdown of the Options button\n\t// 4. Press Escape\n\t// 5. Focus should be on the Options button\n\tfunction onFocusOutside() {\n\t\tsetAddingLink( false );\n\t\tsetOpenedBy( null );\n\t}\n\n\tfunction onRemoveFormat() {\n\t\tonChange( removeFormat( value, name ) );\n\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t}\n\n\t// Only autofocus if we have clicked a link within the editor\n\tconst shouldAutoFocus = ! (\n\t\topenedBy?.el?.tagName === 'A' && openedBy?.action === 'click'\n\t);\n\n\tconst hasSelection = ! isCollapsed( value );\n\n\treturn (\n\t\t<>\n\t\t\t{ hasSelection && (\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\tcharacter=\"k\"\n\t\t\t\t\tonUse={ addLink }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<RichTextShortcut\n\t\t\t\ttype=\"primaryShift\"\n\t\t\t\tcharacter=\"k\"\n\t\t\t\tonUse={ onRemoveFormat }\n\t\t\t/>\n\t\t\t{ isVisible && (\n\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\tname=\"link\"\n\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\ttitle={ isActive ? __( 'Link' ) : title }\n\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\taddLink( event.currentTarget );\n\t\t\t\t\t} }\n\t\t\t\t\tisActive={ isActive || addingLink }\n\t\t\t\t\tshortcutType=\"primary\"\n\t\t\t\t\tshortcutCharacter=\"k\"\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\taria-expanded={ addingLink }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isVisible && addingLink && (\n\t\t\t\t<InlineLinkUI\n\t\t\t\t\tstopAddingLink={ stopAddingLink }\n\t\t\t\t\tonFocusOutside={ onFocusOutside }\n\t\t\t\t\tisActive={ isActive }\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\tfocusOnMount={ shouldAutoFocus ? 'firstElement' : false }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const link = {\n\tname,\n\ttitle,\n\ttagName: 'a',\n\tclassName: null,\n\tattributes: {\n\t\turl: 'href',\n\t\ttype: 'data-type',\n\t\tid: 'data-id',\n\t\t_id: 'id',\n\t\ttarget: 'target',\n\t\trel: 'rel',\n\t\tclass: 'class',\n\t},\n\t[ essentialFormatKey ]: true,\n\t__unstablePasteRule( value, { html, plainText } ) {\n\t\tconst pastedText = ( html || plainText )\n\t\t\t.replace( /<[^>]+>/g, '' )\n\t\t\t.trim();\n\n\t\t// A URL was pasted, turn the selection into a link.\n\t\t// For the link pasting feature, allow only http(s) protocols.\n\t\tif ( ! isURL( pastedText ) || ! /^https?:/.test( pastedText ) ) {\n\t\t\treturn value;\n\t\t}\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\twindow.console.log( 'Created link:\\n\\n', pastedText );\n\n\t\tconst format = {\n\t\t\ttype: name,\n\t\t\tattributes: {\n\t\t\t\turl: decodeEntities( pastedText ),\n\t\t\t},\n\t\t};\n\n\t\tif ( isCollapsed( value ) ) {\n\t\t\treturn insert(\n\t\t\t\tvalue,\n\t\t\t\tapplyFormat(\n\t\t\t\t\tcreate( { text: plainText } ),\n\t\t\t\t\tformat,\n\t\t\t\t\t0,\n\t\t\t\t\tplainText.length\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\treturn applyFormat( value, format );\n\t},\n\tedit: Edit,\n};\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,UAAU,iBAAiB,iBAAiB;AACrD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,OAAO,SAAS,qBAAqB;AAC9C;AAAA,EACC;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,sBAAsB;AAC/B,SAAS,QAAQ,gBAAgB;AACjC,SAAS,aAAa;AAKtB,OAAO,kBAAkB;AACzB,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AAuJrB,mBAEE,KAFF;AArJF,IAAM,EAAE,mBAAmB,IAAI,OAAQ,sBAAuB;AAE9D,IAAM,OAAO;AACb,IAAM,QAAQ,GAAI,MAAO;AAEzB,SAAS,KAAM;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,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IACjB;AAAA,IAEC,aAAa,cACd;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAe,kBAAkB,iBAAiB;AAAA;AAAA,IACnD;AAAA,KAEF;AAEF;AAEO,IAAM,OAAO;AAAA,EACnB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,YAAY;AAAA,IACX,KAAK;AAAA,IACL,MAAM;AAAA,IACN,IAAI;AAAA,IACJ,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,KAAK;AAAA,IACL,OAAO;AAAA,EACR;AAAA,EACA,CAAE,kBAAmB,GAAG;AAAA,EACxB,oBAAqB,OAAO,EAAE,MAAM,UAAU,GAAI;AACjD,UAAM,cAAe,QAAQ,WAC3B,QAAS,YAAY,EAAG,EACxB,KAAK;AAIP,QAAK,CAAE,MAAO,UAAW,KAAK,CAAE,WAAW,KAAM,UAAW,GAAI;AAC/D,aAAO;AAAA,IACR;AAGA,WAAO,QAAQ,IAAK,qBAAqB,UAAW;AAEpD,UAAM,SAAS;AAAA,MACd,MAAM;AAAA,MACN,YAAY;AAAA,QACX,KAAK,eAAgB,UAAW;AAAA,MACjC;AAAA,IACD;AAEA,QAAK,YAAa,KAAM,GAAI;AAC3B,aAAO;AAAA,QACN;AAAA,QACA;AAAA,UACC,OAAQ,EAAE,MAAM,UAAU,CAAE;AAAA,UAC5B;AAAA,UACA;AAAA,UACA,UAAU;AAAA,QACX;AAAA,MACD;AAAA,IACD;AAEA,WAAO,YAAa,OAAO,MAAO;AAAA,EACnC;AAAA,EACA,MAAM;AACP;",
|
|
6
6
|
"names": ["link"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/format-library",
|
|
3
|
-
"version": "5.35.0",
|
|
3
|
+
"version": "5.35.1-next.dc3f6d3c1.0",
|
|
4
4
|
"description": "Format library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
"react-native": "src/index",
|
|
35
35
|
"wpScript": true,
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@wordpress/a11y": "^4.35.0",
|
|
38
|
-
"@wordpress/block-editor": "^15.8.0",
|
|
39
|
-
"@wordpress/components": "^30.8.0",
|
|
40
|
-
"@wordpress/compose": "^7.35.0",
|
|
41
|
-
"@wordpress/data": "^10.35.0",
|
|
42
|
-
"@wordpress/element": "^6.35.0",
|
|
43
|
-
"@wordpress/html-entities": "^4.35.0",
|
|
44
|
-
"@wordpress/i18n": "^6.8.0",
|
|
45
|
-
"@wordpress/icons": "^11.2.0",
|
|
46
|
-
"@wordpress/latex-to-mathml": "^1.3.0",
|
|
47
|
-
"@wordpress/private-apis": "^1.35.0",
|
|
48
|
-
"@wordpress/rich-text": "^7.35.0",
|
|
49
|
-
"@wordpress/url": "^4.35.0"
|
|
37
|
+
"@wordpress/a11y": "^4.35.1-next.dc3f6d3c1.0",
|
|
38
|
+
"@wordpress/block-editor": "^15.8.1-next.dc3f6d3c1.0",
|
|
39
|
+
"@wordpress/components": "^30.8.2-next.dc3f6d3c1.0",
|
|
40
|
+
"@wordpress/compose": "^7.35.1-next.dc3f6d3c1.0",
|
|
41
|
+
"@wordpress/data": "^10.35.1-next.dc3f6d3c1.0",
|
|
42
|
+
"@wordpress/element": "^6.35.1-next.dc3f6d3c1.0",
|
|
43
|
+
"@wordpress/html-entities": "^4.35.1-next.dc3f6d3c1.0",
|
|
44
|
+
"@wordpress/i18n": "^6.8.1-next.dc3f6d3c1.0",
|
|
45
|
+
"@wordpress/icons": "^11.2.1-next.dc3f6d3c1.0",
|
|
46
|
+
"@wordpress/latex-to-mathml": "^1.3.1-next.dc3f6d3c1.0",
|
|
47
|
+
"@wordpress/private-apis": "^1.35.1-next.dc3f6d3c1.0",
|
|
48
|
+
"@wordpress/rich-text": "^7.35.1-next.dc3f6d3c1.0",
|
|
49
|
+
"@wordpress/url": "^4.35.1-next.dc3f6d3c1.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"react": "^18.0.0",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "f73b5e69b34fbaccfb8c47783f4f993059ff1a41"
|
|
59
59
|
}
|
package/src/bold/index.js
CHANGED
|
@@ -27,7 +27,7 @@ export const bold = {
|
|
|
27
27
|
tagName: 'strong',
|
|
28
28
|
className: null,
|
|
29
29
|
[ essentialFormatKey ]: true,
|
|
30
|
-
edit( { isActive, value, onChange, onFocus } ) {
|
|
30
|
+
edit( { isActive, value, onChange, onFocus, isVisible = true } ) {
|
|
31
31
|
function onToggle() {
|
|
32
32
|
onChange( toggleFormat( value, { type: name, title } ) );
|
|
33
33
|
}
|
|
@@ -44,15 +44,17 @@ export const bold = {
|
|
|
44
44
|
character="b"
|
|
45
45
|
onUse={ onToggle }
|
|
46
46
|
/>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
{ isVisible && (
|
|
48
|
+
<RichTextToolbarButton
|
|
49
|
+
name="bold"
|
|
50
|
+
icon={ formatBold }
|
|
51
|
+
title={ title }
|
|
52
|
+
onClick={ onClick }
|
|
53
|
+
isActive={ isActive }
|
|
54
|
+
shortcutType="primary"
|
|
55
|
+
shortcutCharacter="b"
|
|
56
|
+
/>
|
|
57
|
+
) }
|
|
56
58
|
<__unstableRichTextInputEvent
|
|
57
59
|
inputType="formatBold"
|
|
58
60
|
onInput={ onToggle }
|
package/src/italic/index.js
CHANGED
|
@@ -27,7 +27,7 @@ export const italic = {
|
|
|
27
27
|
tagName: 'em',
|
|
28
28
|
className: null,
|
|
29
29
|
[ essentialFormatKey ]: true,
|
|
30
|
-
edit( { isActive, value, onChange, onFocus } ) {
|
|
30
|
+
edit( { isActive, value, onChange, onFocus, isVisible = true } ) {
|
|
31
31
|
function onToggle() {
|
|
32
32
|
onChange( toggleFormat( value, { type: name, title } ) );
|
|
33
33
|
}
|
|
@@ -44,15 +44,17 @@ export const italic = {
|
|
|
44
44
|
character="i"
|
|
45
45
|
onUse={ onToggle }
|
|
46
46
|
/>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
{ isVisible && (
|
|
48
|
+
<RichTextToolbarButton
|
|
49
|
+
name="italic"
|
|
50
|
+
icon={ formatItalic }
|
|
51
|
+
title={ title }
|
|
52
|
+
onClick={ onClick }
|
|
53
|
+
isActive={ isActive }
|
|
54
|
+
shortcutType="primary"
|
|
55
|
+
shortcutCharacter="i"
|
|
56
|
+
/>
|
|
57
|
+
) }
|
|
56
58
|
<__unstableRichTextInputEvent
|
|
57
59
|
inputType="formatItalic"
|
|
58
60
|
onInput={ onToggle }
|
package/src/link/index.js
CHANGED
|
@@ -41,6 +41,7 @@ function Edit( {
|
|
|
41
41
|
onChange,
|
|
42
42
|
onFocus,
|
|
43
43
|
contentRef,
|
|
44
|
+
isVisible = true,
|
|
44
45
|
} ) {
|
|
45
46
|
const [ addingLink, setAddingLink ] = useState( false );
|
|
46
47
|
|
|
@@ -190,20 +191,22 @@ function Edit( {
|
|
|
190
191
|
character="k"
|
|
191
192
|
onUse={ onRemoveFormat }
|
|
192
193
|
/>
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
194
|
+
{ isVisible && (
|
|
195
|
+
<RichTextToolbarButton
|
|
196
|
+
name="link"
|
|
197
|
+
icon={ linkIcon }
|
|
198
|
+
title={ isActive ? __( 'Link' ) : title }
|
|
199
|
+
onClick={ ( event ) => {
|
|
200
|
+
addLink( event.currentTarget );
|
|
201
|
+
} }
|
|
202
|
+
isActive={ isActive || addingLink }
|
|
203
|
+
shortcutType="primary"
|
|
204
|
+
shortcutCharacter="k"
|
|
205
|
+
aria-haspopup="true"
|
|
206
|
+
aria-expanded={ addingLink }
|
|
207
|
+
/>
|
|
208
|
+
) }
|
|
209
|
+
{ isVisible && addingLink && (
|
|
207
210
|
<InlineLinkUI
|
|
208
211
|
stopAddingLink={ stopAddingLink }
|
|
209
212
|
onFocusOutside={ onFocusOutside }
|