@wordpress/format-library 5.33.8 → 5.33.9
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 +0 -3
- package/build/bold/index.js.map +3 -3
- package/build/italic/index.js +0 -3
- package/build/italic/index.js.map +3 -3
- package/build/link/index.js +0 -3
- package/build/link/index.js.map +3 -3
- package/build-module/bold/index.js +1 -5
- package/build-module/bold/index.js.map +2 -2
- package/build-module/italic/index.js +1 -5
- package/build-module/italic/index.js.map +2 -2
- package/build-module/link/index.js +1 -5
- package/build-module/link/index.js.map +2 -2
- package/package.json +4 -4
- package/src/bold/index.js +0 -9
- package/src/italic/index.js +0 -9
- package/src/link/index.js +0 -5
package/build/bold/index.js
CHANGED
|
@@ -25,8 +25,6 @@ var import_i18n = require("@wordpress/i18n");
|
|
|
25
25
|
var import_rich_text = require("@wordpress/rich-text");
|
|
26
26
|
var import_block_editor = require("@wordpress/block-editor");
|
|
27
27
|
var import_icons = require("@wordpress/icons");
|
|
28
|
-
var import_lock_unlock = require("../lock-unlock");
|
|
29
|
-
const { essentialFormatKey } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
|
|
30
28
|
const name = "core/bold";
|
|
31
29
|
const title = (0, import_i18n.__)("Bold");
|
|
32
30
|
const bold = {
|
|
@@ -34,7 +32,6 @@ const bold = {
|
|
|
34
32
|
title,
|
|
35
33
|
tagName: "strong",
|
|
36
34
|
className: null,
|
|
37
|
-
[essentialFormatKey]: true,
|
|
38
35
|
edit({ isActive, value, onChange, onFocus }) {
|
|
39
36
|
function onToggle() {
|
|
40
37
|
onChange((0, import_rich_text.toggleFormat)(value, { type: name, title }));
|
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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
6
|
-
"names": [
|
|
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} from '@wordpress/block-editor';\nimport { formatBold } from '@wordpress/icons';\n\nconst name = 'core/bold';\nconst title = __( 'Bold' );\n\nexport const bold = {\n\tname,\n\ttitle,\n\ttagName: 'strong',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\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;AA+BG;AA5BH,kBAAmB;AACnB,uBAA6B;AAC7B,0BAIO;AACP,mBAA2B;AAE3B,MAAM,OAAO;AACb,MAAM,YAAQ,gBAAI,MAAO;AAElB,MAAM,OAAO;AAAA,EACnB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAM,EAAE,UAAU,OAAO,UAAU,QAAQ,GAAI;AAC9C,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,MACA;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,MACA;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,SAAU;AAAA;AAAA,MACX;AAAA,OACD;AAAA,EAEF;AACD;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/build/italic/index.js
CHANGED
|
@@ -25,8 +25,6 @@ var import_i18n = require("@wordpress/i18n");
|
|
|
25
25
|
var import_rich_text = require("@wordpress/rich-text");
|
|
26
26
|
var import_block_editor = require("@wordpress/block-editor");
|
|
27
27
|
var import_icons = require("@wordpress/icons");
|
|
28
|
-
var import_lock_unlock = require("../lock-unlock");
|
|
29
|
-
const { essentialFormatKey } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
|
|
30
28
|
const name = "core/italic";
|
|
31
29
|
const title = (0, import_i18n.__)("Italic");
|
|
32
30
|
const italic = {
|
|
@@ -34,7 +32,6 @@ const italic = {
|
|
|
34
32
|
title,
|
|
35
33
|
tagName: "em",
|
|
36
34
|
className: null,
|
|
37
|
-
[essentialFormatKey]: true,
|
|
38
35
|
edit({ isActive, value, onChange, onFocus }) {
|
|
39
36
|
function onToggle() {
|
|
40
37
|
onChange((0, import_rich_text.toggleFormat)(value, { type: name, title }));
|
|
@@ -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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
6
|
-
"names": [
|
|
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} from '@wordpress/block-editor';\nimport { formatItalic } from '@wordpress/icons';\n\nconst name = 'core/italic';\nconst title = __( 'Italic' );\n\nexport const italic = {\n\tname,\n\ttitle,\n\ttagName: 'em',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\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;AA+BG;AA5BH,kBAAmB;AACnB,uBAA6B;AAC7B,0BAIO;AACP,mBAA6B;AAE7B,MAAM,OAAO;AACb,MAAM,YAAQ,gBAAI,QAAS;AAEpB,MAAM,SAAS;AAAA,EACrB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAM,EAAE,UAAU,OAAO,UAAU,QAAQ,GAAI;AAC9C,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,MACA;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,MACA;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,SAAU;AAAA;AAAA,MACX;AAAA,OACD;AAAA,EAEF;AACD;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/build/link/index.js
CHANGED
|
@@ -41,8 +41,6 @@ var import_icons = require("@wordpress/icons");
|
|
|
41
41
|
var import_a11y = require("@wordpress/a11y");
|
|
42
42
|
var import_inline = __toESM(require("./inline"));
|
|
43
43
|
var import_utils = require("./utils");
|
|
44
|
-
var import_lock_unlock = require("../lock-unlock");
|
|
45
|
-
const { essentialFormatKey } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
|
|
46
44
|
const name = "core/link";
|
|
47
45
|
const title = (0, import_i18n.__)("Link");
|
|
48
46
|
function Edit({
|
|
@@ -197,7 +195,6 @@ const link = {
|
|
|
197
195
|
rel: "rel",
|
|
198
196
|
class: "class"
|
|
199
197
|
},
|
|
200
|
-
[essentialFormatKey]: true,
|
|
201
198
|
__unstablePasteRule(value, { html, plainText }) {
|
|
202
199
|
const pastedText = (html || plainText).replace(/<[^>]+>/g, "").trim();
|
|
203
200
|
if (!(0, import_url.isURL)(pastedText) || !/^https?:/.test(pastedText)) {
|
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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
6
|
-
"names": ["
|
|
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} 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';\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__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;A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D;AAAA,IACD;AAEA,eAAO,8BAAa,OAAO,MAAO;AAAA,EACnC;AAAA,EACA,MAAM;AACP;",
|
|
6
|
+
"names": ["link", "linkIcon", "InlineLinkUI"]
|
|
7
7
|
}
|
|
@@ -4,12 +4,9 @@ import { toggleFormat } from "@wordpress/rich-text";
|
|
|
4
4
|
import {
|
|
5
5
|
RichTextToolbarButton,
|
|
6
6
|
RichTextShortcut,
|
|
7
|
-
__unstableRichTextInputEvent
|
|
8
|
-
privateApis as blockEditorPrivateApis
|
|
7
|
+
__unstableRichTextInputEvent
|
|
9
8
|
} from "@wordpress/block-editor";
|
|
10
9
|
import { formatBold } from "@wordpress/icons";
|
|
11
|
-
import { unlock } from "../lock-unlock";
|
|
12
|
-
const { essentialFormatKey } = unlock(blockEditorPrivateApis);
|
|
13
10
|
const name = "core/bold";
|
|
14
11
|
const title = __("Bold");
|
|
15
12
|
const bold = {
|
|
@@ -17,7 +14,6 @@ const bold = {
|
|
|
17
14
|
title,
|
|
18
15
|
tagName: "strong",
|
|
19
16
|
className: null,
|
|
20
|
-
[essentialFormatKey]: true,
|
|
21
17
|
edit({ isActive, value, onChange, onFocus }) {
|
|
22
18
|
function onToggle() {
|
|
23
19
|
onChange(toggleFormat(value, { type: name, title }));
|
|
@@ -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
|
|
5
|
-
"mappings": "
|
|
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} from '@wordpress/block-editor';\nimport { formatBold } from '@wordpress/icons';\n\nconst name = 'core/bold';\nconst title = __( 'Bold' );\n\nexport const bold = {\n\tname,\n\ttitle,\n\ttagName: 'strong',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\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": "AA+BG,mBACC,KADD;AA5BH,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,kBAAkB;AAE3B,MAAM,OAAO;AACb,MAAM,QAAQ,GAAI,MAAO;AAElB,MAAM,OAAO;AAAA,EACnB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAM,EAAE,UAAU,OAAO,UAAU,QAAQ,GAAI;AAC9C,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,MACA;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,MACA;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,SAAU;AAAA;AAAA,MACX;AAAA,OACD;AAAA,EAEF;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,12 +4,9 @@ import { toggleFormat } from "@wordpress/rich-text";
|
|
|
4
4
|
import {
|
|
5
5
|
RichTextToolbarButton,
|
|
6
6
|
RichTextShortcut,
|
|
7
|
-
__unstableRichTextInputEvent
|
|
8
|
-
privateApis as blockEditorPrivateApis
|
|
7
|
+
__unstableRichTextInputEvent
|
|
9
8
|
} from "@wordpress/block-editor";
|
|
10
9
|
import { formatItalic } from "@wordpress/icons";
|
|
11
|
-
import { unlock } from "../lock-unlock";
|
|
12
|
-
const { essentialFormatKey } = unlock(blockEditorPrivateApis);
|
|
13
10
|
const name = "core/italic";
|
|
14
11
|
const title = __("Italic");
|
|
15
12
|
const italic = {
|
|
@@ -17,7 +14,6 @@ const italic = {
|
|
|
17
14
|
title,
|
|
18
15
|
tagName: "em",
|
|
19
16
|
className: null,
|
|
20
|
-
[essentialFormatKey]: true,
|
|
21
17
|
edit({ isActive, value, onChange, onFocus }) {
|
|
22
18
|
function onToggle() {
|
|
23
19
|
onChange(toggleFormat(value, { type: name, title }));
|
|
@@ -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
|
|
5
|
-
"mappings": "
|
|
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} from '@wordpress/block-editor';\nimport { formatItalic } from '@wordpress/icons';\n\nconst name = 'core/italic';\nconst title = __( 'Italic' );\n\nexport const italic = {\n\tname,\n\ttitle,\n\ttagName: 'em',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\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": "AA+BG,mBACC,KADD;AA5BH,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,oBAAoB;AAE7B,MAAM,OAAO;AACb,MAAM,QAAQ,GAAI,QAAS;AAEpB,MAAM,SAAS;AAAA,EACrB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAM,EAAE,UAAU,OAAO,UAAU,QAAQ,GAAI;AAC9C,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,MACA;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,MACA;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,SAAU;AAAA;AAAA,MACX;AAAA,OACD;AAAA,EAEF;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -13,16 +13,13 @@ import {
|
|
|
13
13
|
import { isURL, isEmail, isPhoneNumber } from "@wordpress/url";
|
|
14
14
|
import {
|
|
15
15
|
RichTextToolbarButton,
|
|
16
|
-
RichTextShortcut
|
|
17
|
-
privateApis as blockEditorPrivateApis
|
|
16
|
+
RichTextShortcut
|
|
18
17
|
} from "@wordpress/block-editor";
|
|
19
18
|
import { decodeEntities } from "@wordpress/html-entities";
|
|
20
19
|
import { link as linkIcon } from "@wordpress/icons";
|
|
21
20
|
import { speak } from "@wordpress/a11y";
|
|
22
21
|
import InlineLinkUI from "./inline";
|
|
23
22
|
import { isValidHref } from "./utils";
|
|
24
|
-
import { unlock } from "../lock-unlock";
|
|
25
|
-
const { essentialFormatKey } = unlock(blockEditorPrivateApis);
|
|
26
23
|
const name = "core/link";
|
|
27
24
|
const title = __("Link");
|
|
28
25
|
function Edit({
|
|
@@ -177,7 +174,6 @@ const link = {
|
|
|
177
174
|
rel: "rel",
|
|
178
175
|
class: "class"
|
|
179
176
|
},
|
|
180
|
-
[essentialFormatKey]: true,
|
|
181
177
|
__unstablePasteRule(value, { html, plainText }) {
|
|
182
178
|
const pastedText = (html || plainText).replace(/<[^>]+>/g, "").trim();
|
|
183
179
|
if (!isURL(pastedText) || !/^https?:/.test(pastedText)) {
|
|
@@ -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
|
|
5
|
-
"mappings": "
|
|
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} 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';\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__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": "AA+KE,mBAEE,KAFF;AA5KF,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,OACM;AACP,SAAS,sBAAsB;AAC/B,SAAS,QAAQ,gBAAgB;AACjC,SAAS,aAAa;AAKtB,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@wordpress/format-library",
|
|
3
|
-
"version": "5.33.
|
|
3
|
+
"version": "5.33.9",
|
|
4
4
|
"description": "Format library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"wpScript": true,
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@wordpress/a11y": "^4.33.1",
|
|
38
|
-
"@wordpress/block-editor": "^15.6.
|
|
39
|
-
"@wordpress/components": "^30.6.
|
|
38
|
+
"@wordpress/block-editor": "^15.6.9",
|
|
39
|
+
"@wordpress/components": "^30.6.5",
|
|
40
40
|
"@wordpress/compose": "^7.33.1",
|
|
41
41
|
"@wordpress/data": "^10.33.1",
|
|
42
42
|
"@wordpress/element": "^6.33.1",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "ece3841462592f9e9b99cfa7cac0fe98bdce8fd7"
|
|
59
59
|
}
|
package/src/bold/index.js
CHANGED
|
@@ -7,17 +7,9 @@ import {
|
|
|
7
7
|
RichTextToolbarButton,
|
|
8
8
|
RichTextShortcut,
|
|
9
9
|
__unstableRichTextInputEvent,
|
|
10
|
-
privateApis as blockEditorPrivateApis,
|
|
11
10
|
} from '@wordpress/block-editor';
|
|
12
11
|
import { formatBold } from '@wordpress/icons';
|
|
13
12
|
|
|
14
|
-
/**
|
|
15
|
-
* Internal dependencies
|
|
16
|
-
*/
|
|
17
|
-
import { unlock } from '../lock-unlock';
|
|
18
|
-
|
|
19
|
-
const { essentialFormatKey } = unlock( blockEditorPrivateApis );
|
|
20
|
-
|
|
21
13
|
const name = 'core/bold';
|
|
22
14
|
const title = __( 'Bold' );
|
|
23
15
|
|
|
@@ -26,7 +18,6 @@ export const bold = {
|
|
|
26
18
|
title,
|
|
27
19
|
tagName: 'strong',
|
|
28
20
|
className: null,
|
|
29
|
-
[ essentialFormatKey ]: true,
|
|
30
21
|
edit( { isActive, value, onChange, onFocus } ) {
|
|
31
22
|
function onToggle() {
|
|
32
23
|
onChange( toggleFormat( value, { type: name, title } ) );
|
package/src/italic/index.js
CHANGED
|
@@ -7,17 +7,9 @@ import {
|
|
|
7
7
|
RichTextToolbarButton,
|
|
8
8
|
RichTextShortcut,
|
|
9
9
|
__unstableRichTextInputEvent,
|
|
10
|
-
privateApis as blockEditorPrivateApis,
|
|
11
10
|
} from '@wordpress/block-editor';
|
|
12
11
|
import { formatItalic } from '@wordpress/icons';
|
|
13
12
|
|
|
14
|
-
/**
|
|
15
|
-
* Internal dependencies
|
|
16
|
-
*/
|
|
17
|
-
import { unlock } from '../lock-unlock';
|
|
18
|
-
|
|
19
|
-
const { essentialFormatKey } = unlock( blockEditorPrivateApis );
|
|
20
|
-
|
|
21
13
|
const name = 'core/italic';
|
|
22
14
|
const title = __( 'Italic' );
|
|
23
15
|
|
|
@@ -26,7 +18,6 @@ export const italic = {
|
|
|
26
18
|
title,
|
|
27
19
|
tagName: 'em',
|
|
28
20
|
className: null,
|
|
29
|
-
[ essentialFormatKey ]: true,
|
|
30
21
|
edit( { isActive, value, onChange, onFocus } ) {
|
|
31
22
|
function onToggle() {
|
|
32
23
|
onChange( toggleFormat( value, { type: name, title } ) );
|
package/src/link/index.js
CHANGED
|
@@ -16,7 +16,6 @@ import { isURL, isEmail, isPhoneNumber } from '@wordpress/url';
|
|
|
16
16
|
import {
|
|
17
17
|
RichTextToolbarButton,
|
|
18
18
|
RichTextShortcut,
|
|
19
|
-
privateApis as blockEditorPrivateApis,
|
|
20
19
|
} from '@wordpress/block-editor';
|
|
21
20
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
22
21
|
import { link as linkIcon } from '@wordpress/icons';
|
|
@@ -27,9 +26,6 @@ import { speak } from '@wordpress/a11y';
|
|
|
27
26
|
*/
|
|
28
27
|
import InlineLinkUI from './inline';
|
|
29
28
|
import { isValidHref } from './utils';
|
|
30
|
-
import { unlock } from '../lock-unlock';
|
|
31
|
-
|
|
32
|
-
const { essentialFormatKey } = unlock( blockEditorPrivateApis );
|
|
33
29
|
|
|
34
30
|
const name = 'core/link';
|
|
35
31
|
const title = __( 'Link' );
|
|
@@ -233,7 +229,6 @@ export const link = {
|
|
|
233
229
|
rel: 'rel',
|
|
234
230
|
class: 'class',
|
|
235
231
|
},
|
|
236
|
-
[ essentialFormatKey ]: true,
|
|
237
232
|
__unstablePasteRule( value, { html, plainText } ) {
|
|
238
233
|
const pastedText = ( html || plainText )
|
|
239
234
|
.replace( /<[^>]+>/g, '' )
|