@wordpress/format-library 5.8.6 → 5.10.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/CHANGELOG.md +4 -0
- package/build/image/index.js.map +1 -1
- package/build/link/index.js.map +1 -1
- package/build/link/inline.js +1 -1
- package/build/link/inline.js.map +1 -1
- package/build/link/use-link-instance-key.js.map +1 -1
- package/build-module/bold/index.js +1 -3
- package/build-module/bold/index.js.map +1 -1
- package/build-module/code/index.js +1 -3
- package/build-module/code/index.js.map +1 -1
- package/build-module/image/index.js +1 -3
- package/build-module/image/index.js.map +1 -1
- package/build-module/italic/index.js +1 -3
- package/build-module/italic/index.js.map +1 -1
- package/build-module/language/index.js +1 -3
- package/build-module/language/index.js.map +1 -1
- package/build-module/link/index.js +1 -3
- package/build-module/link/index.js.map +1 -1
- package/build-module/link/index.native.js +1 -3
- package/build-module/link/index.native.js.map +1 -1
- package/build-module/link/inline.js +1 -1
- package/build-module/link/inline.js.map +1 -1
- package/build-module/link/modal-screens/link-settings-screen.native.js +1 -3
- package/build-module/link/modal-screens/link-settings-screen.native.js.map +1 -1
- package/build-module/link/modal.native.js +1 -2
- package/build-module/link/modal.native.js.map +1 -1
- package/build-module/link/use-link-instance-key.js.map +1 -1
- package/build-module/strikethrough/index.js +1 -3
- package/build-module/strikethrough/index.js.map +1 -1
- package/build-module/text-color/index.js +1 -3
- package/build-module/text-color/index.js.map +1 -1
- package/build-module/text-color/index.native.js +1 -3
- package/build-module/text-color/index.native.js.map +1 -1
- package/build-module/text-color/inline.js +1 -2
- package/build-module/text-color/inline.js.map +1 -1
- package/build-module/underline/index.js +1 -3
- package/build-module/underline/index.js.map +1 -1
- package/build-style/style-rtl.css +10 -1
- package/build-style/style.css +10 -1
- package/package.json +15 -15
|
@@ -19,9 +19,7 @@ import { link as linkIcon } from '@wordpress/icons';
|
|
|
19
19
|
*/
|
|
20
20
|
import ModalLinkUI from './modal';
|
|
21
21
|
import { isValidHref } from './utils';
|
|
22
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
24
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
23
|
const name = 'core/link';
|
|
26
24
|
export const link = {
|
|
27
25
|
name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Clipboard","__","Component","withSpokenMessages","RichTextToolbarButton","applyFormat","getActiveFormat","getTextContent","isCollapsed","removeFormat","slice","isURL","link","linkIcon","ModalLinkUI","isValidHref","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","name","title","tagName","className","attributes","url","target","rel","edit","LinkEdit","constructor","arguments","addLink","bind","stopAddingLink","onRemoveFormat","getURLFromClipboard","state","addingLink","value","onChange","props","text","newValue","type","start","end","activeFormats","needsSelectionUpdate","setState","clipboardURL","undefined","getLinkSelection","isActive","startFormat","startIndex","endIndex","formats","find","format","speak","linkSelection","clipboardText","getString","render","activeAttributes","children","isVisible","onClose","onRemove","icon","onClick","shortcutType","shortcutCharacter"],"sources":["@wordpress/format-library/src/link/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport Clipboard from '@react-native-clipboard/clipboard';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Component } from '@wordpress/element';\nimport { withSpokenMessages } from '@wordpress/components';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport {\n\tapplyFormat,\n\tgetActiveFormat,\n\tgetTextContent,\n\tisCollapsed,\n\tremoveFormat,\n\tslice,\n} from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\nimport { link as linkIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport ModalLinkUI from './modal';\nimport { isValidHref } from './utils';\n\nconst name = 'core/link';\n\nexport const link = {\n\tname,\n\ttitle: __( 'Link' ),\n\ttagName: 'a',\n\tclassName: null,\n\tattributes: {\n\t\turl: 'href',\n\t\ttarget: 'target',\n\t\trel: 'rel',\n\t},\n\tedit: withSpokenMessages(\n\t\tclass LinkEdit extends Component {\n\t\t\tconstructor() {\n\t\t\t\tsuper( ...arguments );\n\n\t\t\t\tthis.addLink = this.addLink.bind( this );\n\t\t\t\tthis.stopAddingLink = this.stopAddingLink.bind( this );\n\t\t\t\tthis.onRemoveFormat = this.onRemoveFormat.bind( this );\n\t\t\t\tthis.getURLFromClipboard =\n\t\t\t\t\tthis.getURLFromClipboard.bind( this );\n\t\t\t\tthis.state = {\n\t\t\t\t\taddingLink: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\taddLink() {\n\t\t\t\tconst { value, onChange } = this.props;\n\t\t\t\tconst text = getTextContent( slice( value ) );\n\n\t\t\t\tif ( text && isURL( text ) && isValidHref( text ) ) {\n\t\t\t\t\tconst newValue = applyFormat( value, {\n\t\t\t\t\t\ttype: name,\n\t\t\t\t\t\tattributes: { url: text },\n\t\t\t\t\t} );\n\t\t\t\t\tnewValue.start = newValue.end;\n\t\t\t\t\tnewValue.activeFormats = [];\n\t\t\t\t\tonChange( { ...newValue, needsSelectionUpdate: true } );\n\t\t\t\t} else {\n\t\t\t\t\tthis.setState( { addingLink: true } );\n\t\t\t\t\tthis.getURLFromClipboard();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstopAddingLink() {\n\t\t\t\tthis.setState( { addingLink: false, clipboardURL: undefined } );\n\t\t\t}\n\n\t\t\tgetLinkSelection() {\n\t\t\t\tconst { value, isActive } = this.props;\n\t\t\t\tconst startFormat = getActiveFormat( value, 'core/link' );\n\n\t\t\t\t// If the link isn't selected, get the link manually by looking around the cursor\n\t\t\t\t// TODO: handle partly selected links.\n\t\t\t\tif ( startFormat && isCollapsed( value ) && isActive ) {\n\t\t\t\t\tlet startIndex = value.start;\n\t\t\t\t\tlet endIndex = value.end;\n\n\t\t\t\t\twhile (\n\t\t\t\t\t\tvalue.formats[ startIndex ]?.find(\n\t\t\t\t\t\t\t( format ) => format?.type === startFormat.type\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tstartIndex--;\n\t\t\t\t\t}\n\n\t\t\t\t\tendIndex++;\n\n\t\t\t\t\twhile (\n\t\t\t\t\t\tvalue.formats[ endIndex ]?.find(\n\t\t\t\t\t\t\t( format ) => format?.type === startFormat.type\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tendIndex++;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...value,\n\t\t\t\t\t\tstart: startIndex + 1,\n\t\t\t\t\t\tend: endIndex,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\tonRemoveFormat() {\n\t\t\t\tconst { onChange, speak, value } = this.props;\n\t\t\t\tconst startFormat = getActiveFormat( value, 'core/link' );\n\n\t\t\t\t// Before we try to remove anything we check if there is something at the caret position to remove.\n\t\t\t\tif ( isCollapsed( value ) && startFormat === undefined ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst linkSelection = this.getLinkSelection();\n\n\t\t\t\tonChange( removeFormat( linkSelection, name ) );\n\t\t\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t\t\t}\n\n\t\t\tasync getURLFromClipboard() {\n\t\t\t\tconst clipboardText = await Clipboard.getString();\n\t\t\t\tif ( ! clipboardText ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Check if pasted text is URL.\n\t\t\t\tif ( ! isURL( clipboardText ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.setState( { clipboardURL: clipboardText } );\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\tconst { isActive, activeAttributes, onChange } = this.props;\n\t\t\t\tconst linkSelection = this.getLinkSelection();\n\t\t\t\t// If no URL is set and we have a clipboard URL let's use it.\n\t\t\t\tif ( ! activeAttributes.url && this.state.clipboardURL ) {\n\t\t\t\t\tactiveAttributes.url = this.state.clipboardURL;\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<ModalLinkUI\n\t\t\t\t\t\t\tisVisible={ this.state.addingLink }\n\t\t\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\t\t\tactiveAttributes={ activeAttributes }\n\t\t\t\t\t\t\tonClose={ this.stopAddingLink }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tonRemove={ this.onRemoveFormat }\n\t\t\t\t\t\t\tvalue={ linkSelection }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\t\tonClick={ this.addLink }\n\t\t\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\t\t\tshortcutType=\"primary\"\n\t\t\t\t\t\t\tshortcutCharacter=\"k\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t),\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,mCAAmC;;AAEzD;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,kBAAkB,QAAQ,uBAAuB;AAC1D,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SACCC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,WAAW,EACXC,YAAY,EACZC,KAAK,QACC,sBAAsB;AAC7B,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,IAAI,IAAIC,QAAQ,QAAQ,kBAAkB;;AAEnD;AACA;AACA;AACA,OAAOC,WAAW,MAAM,SAAS;AACjC,SAASC,WAAW,QAAQ,SAAS;AAAC,SAAAC,G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A,CAACH,WAAW;UACXuD,SAAS,EAAG,IAAI,CAAC9B,KAAK,CAACC,UAAY;UACnCe,QAAQ,EAAGA,QAAU;UACrBY,gBAAgB,EAAGA,gBAAkB;UACrCG,OAAO,EAAG,IAAI,CAAClC,cAAgB;UAC/BM,QAAQ,EAAGA,QAAU;UACrB6B,QAAQ,EAAG,IAAI,CAAClC,cAAgB;UAChCI,KAAK,EAAGsB;QAAe,CACvB,CAAC,eACF9C,IAAA,CAACb,qBAAqB;UACrBkB,IAAI,EAAC,MAAM;UACXkD,IAAI,EAAG3D,QAAU;UACjBU,KAAK,EAAGtB,EAAE,CAAE,MAAO,CAAG;UACtBwE,OAAO,EAAG,IAAI,CAACvC,OAAS;UACxBqB,QAAQ,EAAGA,QAAU;UACrBmB,YAAY,EAAC,SAAS;UACtBC,iBAAiB,EAAC;QAAG,CACrB,CAAC;MAAA,CACD,CAAC;IAEL;EACD,CACD;AACD,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Clipboard","__","Component","withSpokenMessages","RichTextToolbarButton","applyFormat","getActiveFormat","getTextContent","isCollapsed","removeFormat","slice","isURL","link","linkIcon","ModalLinkUI","isValidHref","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","name","title","tagName","className","attributes","url","target","rel","edit","LinkEdit","constructor","arguments","addLink","bind","stopAddingLink","onRemoveFormat","getURLFromClipboard","state","addingLink","value","onChange","props","text","newValue","type","start","end","activeFormats","needsSelectionUpdate","setState","clipboardURL","undefined","getLinkSelection","isActive","startFormat","startIndex","endIndex","formats","find","format","speak","linkSelection","clipboardText","getString","render","activeAttributes","children","isVisible","onClose","onRemove","icon","onClick","shortcutType","shortcutCharacter"],"sources":["@wordpress/format-library/src/link/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport Clipboard from '@react-native-clipboard/clipboard';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Component } from '@wordpress/element';\nimport { withSpokenMessages } from '@wordpress/components';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport {\n\tapplyFormat,\n\tgetActiveFormat,\n\tgetTextContent,\n\tisCollapsed,\n\tremoveFormat,\n\tslice,\n} from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\nimport { link as linkIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport ModalLinkUI from './modal';\nimport { isValidHref } from './utils';\n\nconst name = 'core/link';\n\nexport const link = {\n\tname,\n\ttitle: __( 'Link' ),\n\ttagName: 'a',\n\tclassName: null,\n\tattributes: {\n\t\turl: 'href',\n\t\ttarget: 'target',\n\t\trel: 'rel',\n\t},\n\tedit: withSpokenMessages(\n\t\tclass LinkEdit extends Component {\n\t\t\tconstructor() {\n\t\t\t\tsuper( ...arguments );\n\n\t\t\t\tthis.addLink = this.addLink.bind( this );\n\t\t\t\tthis.stopAddingLink = this.stopAddingLink.bind( this );\n\t\t\t\tthis.onRemoveFormat = this.onRemoveFormat.bind( this );\n\t\t\t\tthis.getURLFromClipboard =\n\t\t\t\t\tthis.getURLFromClipboard.bind( this );\n\t\t\t\tthis.state = {\n\t\t\t\t\taddingLink: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\taddLink() {\n\t\t\t\tconst { value, onChange } = this.props;\n\t\t\t\tconst text = getTextContent( slice( value ) );\n\n\t\t\t\tif ( text && isURL( text ) && isValidHref( text ) ) {\n\t\t\t\t\tconst newValue = applyFormat( value, {\n\t\t\t\t\t\ttype: name,\n\t\t\t\t\t\tattributes: { url: text },\n\t\t\t\t\t} );\n\t\t\t\t\tnewValue.start = newValue.end;\n\t\t\t\t\tnewValue.activeFormats = [];\n\t\t\t\t\tonChange( { ...newValue, needsSelectionUpdate: true } );\n\t\t\t\t} else {\n\t\t\t\t\tthis.setState( { addingLink: true } );\n\t\t\t\t\tthis.getURLFromClipboard();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstopAddingLink() {\n\t\t\t\tthis.setState( { addingLink: false, clipboardURL: undefined } );\n\t\t\t}\n\n\t\t\tgetLinkSelection() {\n\t\t\t\tconst { value, isActive } = this.props;\n\t\t\t\tconst startFormat = getActiveFormat( value, 'core/link' );\n\n\t\t\t\t// If the link isn't selected, get the link manually by looking around the cursor\n\t\t\t\t// TODO: handle partly selected links.\n\t\t\t\tif ( startFormat && isCollapsed( value ) && isActive ) {\n\t\t\t\t\tlet startIndex = value.start;\n\t\t\t\t\tlet endIndex = value.end;\n\n\t\t\t\t\twhile (\n\t\t\t\t\t\tvalue.formats[ startIndex ]?.find(\n\t\t\t\t\t\t\t( format ) => format?.type === startFormat.type\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tstartIndex--;\n\t\t\t\t\t}\n\n\t\t\t\t\tendIndex++;\n\n\t\t\t\t\twhile (\n\t\t\t\t\t\tvalue.formats[ endIndex ]?.find(\n\t\t\t\t\t\t\t( format ) => format?.type === startFormat.type\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tendIndex++;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...value,\n\t\t\t\t\t\tstart: startIndex + 1,\n\t\t\t\t\t\tend: endIndex,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\tonRemoveFormat() {\n\t\t\t\tconst { onChange, speak, value } = this.props;\n\t\t\t\tconst startFormat = getActiveFormat( value, 'core/link' );\n\n\t\t\t\t// Before we try to remove anything we check if there is something at the caret position to remove.\n\t\t\t\tif ( isCollapsed( value ) && startFormat === undefined ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst linkSelection = this.getLinkSelection();\n\n\t\t\t\tonChange( removeFormat( linkSelection, name ) );\n\t\t\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t\t\t}\n\n\t\t\tasync getURLFromClipboard() {\n\t\t\t\tconst clipboardText = await Clipboard.getString();\n\t\t\t\tif ( ! clipboardText ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Check if pasted text is URL.\n\t\t\t\tif ( ! isURL( clipboardText ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.setState( { clipboardURL: clipboardText } );\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\tconst { isActive, activeAttributes, onChange } = this.props;\n\t\t\t\tconst linkSelection = this.getLinkSelection();\n\t\t\t\t// If no URL is set and we have a clipboard URL let's use it.\n\t\t\t\tif ( ! activeAttributes.url && this.state.clipboardURL ) {\n\t\t\t\t\tactiveAttributes.url = this.state.clipboardURL;\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<ModalLinkUI\n\t\t\t\t\t\t\tisVisible={ this.state.addingLink }\n\t\t\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\t\t\tactiveAttributes={ activeAttributes }\n\t\t\t\t\t\t\tonClose={ this.stopAddingLink }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tonRemove={ this.onRemoveFormat }\n\t\t\t\t\t\t\tvalue={ linkSelection }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\t\tonClick={ this.addLink }\n\t\t\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\t\t\tshortcutType=\"primary\"\n\t\t\t\t\t\t\tshortcutCharacter=\"k\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t),\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,mCAAmC;;AAEzD;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,kBAAkB,QAAQ,uBA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,IAAI,CAACC,KAAK;MAC3D,MAAMoB,aAAa,GAAG,IAAI,CAACT,gBAAgB,CAAC,CAAC;MAC7C;MACA,IAAK,CAAEa,gBAAgB,CAACxC,GAAG,IAAI,IAAI,CAACY,KAAK,CAACa,YAAY,EAAG;QACxDe,gBAAgB,CAACxC,GAAG,GAAG,IAAI,CAACY,KAAK,CAACa,YAAY;MAC/C;MACA,oBACC/B,KAAA,CAAAF,SAAA;QAAAiD,QAAA,gBACCnD,IAAA,CAACH,WAAW;UACXuD,SAAS,EAAG,IAAI,CAAC9B,KAAK,CAACC,UAAY;UACnCe,QAAQ,EAAGA,QAAU;UACrBY,gBAAgB,EAAGA,gBAAkB;UACrCG,OAAO,EAAG,IAAI,CAAClC,cAAgB;UAC/BM,QAAQ,EAAGA,QAAU;UACrB6B,QAAQ,EAAG,IAAI,CAAClC,cAAgB;UAChCI,KAAK,EAAGsB;QAAe,CACvB,CAAC,eACF9C,IAAA,CAACb,qBAAqB;UACrBkB,IAAI,EAAC,MAAM;UACXkD,IAAI,EAAG3D,QAAU;UACjBU,KAAK,EAAGtB,EAAE,CAAE,MAAO,CAAG;UACtBwE,OAAO,EAAG,IAAI,CAACvC,OAAS;UACxBqB,QAAQ,EAAGA,QAAU;UACrBmB,YAAY,EAAC,SAAS;UACtBC,iBAAiB,EAAC;QAAG,CACrB,CAAC;MAAA,CACD,CAAC;IAEL;EACD,CACD;AACD,CAAC","ignoreList":[]}
|
|
@@ -183,7 +183,7 @@ function InlineLinkUI({
|
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
185
|
function createButtonText(searchTerm) {
|
|
186
|
-
return createInterpolateElement(sprintf(
|
|
186
|
+
return createInterpolateElement(sprintf(/* translators: %s: search term. */
|
|
187
187
|
__('Create page: <mark>%s</mark>'), searchTerm), {
|
|
188
188
|
mark: /*#__PURE__*/_jsx("mark", {})
|
|
189
189
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","createInterpolateElement","__","sprintf","speak","Popover","prependHTTP","create","insert","isCollapsed","applyFormat","removeFormat","slice","replace","split","concat","useAnchor","__experimentalLinkControl","LinkControl","store","blockEditorStore","useDispatch","useSelect","createLinkFormat","isValidHref","getFormatBoundary","link","settings","jsx","_jsx","LINK_SETTINGS","DEFAULT_LINK_SETTINGS","id","title","InlineLinkUI","isActive","activeAttributes","value","onChange","onFocusOutside","stopAddingLink","contentRef","focusOnMount","richLinkTextValue","getRichTextValueFromSelection","richTextText","text","selectionChange","createPageEntity","userCanCreatePages","selectionStart","select","getSettings","getSelectionStart","_settings","__experimentalCreatePageEntity","__experimentalUserCanCreatePages","linkValue","url","type","opensInNewTab","target","nofollow","rel","includes","removeLink","newValue","onChangeLink","nextValue","hasLink","isNewLink","newUrl","linkFormat","undefined","String","opensInNewWindow","newText","inserted","start","length","clientId","identifier","attributeKey","boundary","valBefore","valAfter","newValAfter","popoverAnchor","editableContentElement","current","handleCreate","pageTitle","page","status","rendered","kind","createButtonText","searchTerm","mark","anchor","animate","onClose","placement","offset","shift","constrainTabbing","children","onRemove","hasRichPreviews","createSuggestion","withCreateSuggestion","createSuggestionButtonText","hasTextControl","showInitialSuggestions","suggestionsQuery","initialSuggestionsSearchOptions","subtype","perPage","textStart","textEnd","end"],"sources":["@wordpress/format-library/src/link/inline.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, createInterpolateElement } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport { Popover } from '@wordpress/components';\nimport { prependHTTP } from '@wordpress/url';\nimport {\n\tcreate,\n\tinsert,\n\tisCollapsed,\n\tapplyFormat,\n\tremoveFormat,\n\tslice,\n\treplace,\n\tsplit,\n\tconcat,\n\tuseAnchor,\n} from '@wordpress/rich-text';\nimport {\n\t__experimentalLinkControl as LinkControl,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { createLinkFormat, isValidHref, getFormatBoundary } from './utils';\nimport { link as settings } from './index';\n\nconst LINK_SETTINGS = [\n\t...LinkControl.DEFAULT_LINK_SETTINGS,\n\t{\n\t\tid: 'nofollow',\n\t\ttitle: __( 'Mark as nofollow' ),\n\t},\n];\n\nfunction InlineLinkUI( {\n\tisActive,\n\tactiveAttributes,\n\tvalue,\n\tonChange,\n\tonFocusOutside,\n\tstopAddingLink,\n\tcontentRef,\n\tfocusOnMount,\n} ) {\n\tconst richLinkTextValue = getRichTextValueFromSelection( value, isActive );\n\n\t// Get the text content minus any HTML tags.\n\tconst richTextText = richLinkTextValue.text;\n\n\tconst { selectionChange } = useDispatch( blockEditorStore );\n\n\tconst { createPageEntity, userCanCreatePages, selectionStart } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, getSelectionStart } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst _settings = getSettings();\n\n\t\t\treturn {\n\t\t\t\tcreatePageEntity: _settings.__experimentalCreatePageEntity,\n\t\t\t\tuserCanCreatePages: _settings.__experimentalUserCanCreatePages,\n\t\t\t\tselectionStart: getSelectionStart(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst linkValue = useMemo(\n\t\t() => ( {\n\t\t\turl: activeAttributes.url,\n\t\t\ttype: activeAttributes.type,\n\t\t\tid: activeAttributes.id,\n\t\t\topensInNewTab: activeAttributes.target === '_blank',\n\t\t\tnofollow: activeAttributes.rel?.includes( 'nofollow' ),\n\t\t\ttitle: richTextText,\n\t\t} ),\n\t\t[\n\t\t\tactiveAttributes.id,\n\t\t\tactiveAttributes.rel,\n\t\t\tactiveAttributes.target,\n\t\t\tactiveAttributes.type,\n\t\t\tactiveAttributes.url,\n\t\t\trichTextText,\n\t\t]\n\t);\n\n\tfunction removeLink() {\n\t\tconst newValue = removeFormat( value, 'core/link' );\n\t\tonChange( newValue );\n\t\tstopAddingLink();\n\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t}\n\n\tfunction onChangeLink( nextValue ) {\n\t\tconst hasLink = linkValue?.url;\n\t\tconst isNewLink = ! hasLink;\n\n\t\t// Merge the next value with the current link value.\n\t\tnextValue = {\n\t\t\t...linkValue,\n\t\t\t...nextValue,\n\t\t};\n\n\t\tconst newUrl = prependHTTP( nextValue.url );\n\t\tconst linkFormat = createLinkFormat( {\n\t\t\turl: newUrl,\n\t\t\ttype: nextValue.type,\n\t\t\tid:\n\t\t\t\tnextValue.id !== undefined && nextValue.id !== null\n\t\t\t\t\t? String( nextValue.id )\n\t\t\t\t\t: undefined,\n\t\t\topensInNewWindow: nextValue.opensInNewTab,\n\t\t\tnofollow: nextValue.nofollow,\n\t\t} );\n\n\t\tconst newText = nextValue.title || newUrl;\n\n\t\t// Scenario: we have any active text selection or an active format.\n\t\tlet newValue;\n\t\tif ( isCollapsed( value ) && ! isActive ) {\n\t\t\t// Scenario: we don't have any actively selected text or formats.\n\t\t\tconst inserted = insert( value, newText );\n\n\t\t\tnewValue = applyFormat(\n\t\t\t\tinserted,\n\t\t\t\tlinkFormat,\n\t\t\t\tvalue.start,\n\t\t\t\tvalue.start + newText.length\n\t\t\t);\n\n\t\t\tonChange( newValue );\n\n\t\t\t// Close the Link UI.\n\t\t\tstopAddingLink();\n\n\t\t\t// Move the selection to the end of the inserted link outside of the format boundary\n\t\t\t// so the user can continue typing after the link.\n\t\t\tselectionChange( {\n\t\t\t\tclientId: selectionStart.clientId,\n\t\t\t\tidentifier: selectionStart.attributeKey,\n\t\t\t\tstart: value.start + newText.length + 1,\n\t\t\t} );\n\n\t\t\treturn;\n\t\t} else if ( newText === richTextText ) {\n\t\t\tnewValue = applyFormat( value, linkFormat );\n\t\t} else {\n\t\t\t// Scenario: Editing an existing link.\n\n\t\t\t// Create new RichText value for the new text in order that we\n\t\t\t// can apply formats to it.\n\t\t\tnewValue = create( { text: newText } );\n\t\t\t// Apply the new Link format to this new text value.\n\t\t\tnewValue = applyFormat( newValue, linkFormat, 0, newText.length );\n\n\t\t\t// Get the boundaries of the active link format.\n\t\t\tconst boundary = getFormatBoundary( value, {\n\t\t\t\ttype: 'core/link',\n\t\t\t} );\n\n\t\t\t// Split the value at the start of the active link format.\n\t\t\t// Passing \"start\" as the 3rd parameter is required to ensure\n\t\t\t// the second half of the split value is split at the format's\n\t\t\t// start boundary and avoids relying on the value's \"end\" property\n\t\t\t// which may not correspond correctly.\n\t\t\tconst [ valBefore, valAfter ] = split(\n\t\t\t\tvalue,\n\t\t\t\tboundary.start,\n\t\t\t\tboundary.start\n\t\t\t);\n\n\t\t\t// Update the original (full) RichTextValue replacing the\n\t\t\t// target text with the *new* RichTextValue containing:\n\t\t\t// 1. The new text content.\n\t\t\t// 2. The new link format.\n\t\t\t// As \"replace\" will operate on the first match only, it is\n\t\t\t// run only against the second half of the value which was\n\t\t\t// split at the active format's boundary. This avoids a bug\n\t\t\t// with incorrectly targetted replacements.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/41771.\n\t\t\t// Note original formats will be lost when applying this change.\n\t\t\t// That is expected behaviour.\n\t\t\t// See: https://github.com/WordPress/gutenberg/pull/33849#issuecomment-936134179.\n\t\t\tconst newValAfter = replace( valAfter, richTextText, newValue );\n\n\t\t\tnewValue = concat( valBefore, newValAfter );\n\t\t}\n\n\t\tonChange( newValue );\n\n\t\t// Focus should only be returned to the rich text on submit if this link is not\n\t\t// being created for the first time. If it is then focus should remain within the\n\t\t// Link UI because it should remain open for the user to modify the link they have\n\t\t// just created.\n\t\tif ( ! isNewLink ) {\n\t\t\tstopAddingLink();\n\t\t}\n\n\t\tif ( ! isValidHref( newUrl ) ) {\n\t\t\tspeak(\n\t\t\t\t__(\n\t\t\t\t\t'Warning: the link has been inserted but may have errors. Please test it.'\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t} else if ( isActive ) {\n\t\t\tspeak( __( 'Link edited.' ), 'assertive' );\n\t\t} else {\n\t\t\tspeak( __( 'Link inserted.' ), 'assertive' );\n\t\t}\n\t}\n\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings: {\n\t\t\t...settings,\n\t\t\tisActive,\n\t\t},\n\t} );\n\n\tasync function handleCreate( pageTitle ) {\n\t\tconst page = await createPageEntity( {\n\t\t\ttitle: pageTitle,\n\t\t\tstatus: 'draft',\n\t\t} );\n\n\t\treturn {\n\t\t\tid: page.id,\n\t\t\ttype: page.type,\n\t\t\ttitle: page.title.rendered,\n\t\t\turl: page.link,\n\t\t\tkind: 'post-type',\n\t\t};\n\t}\n\n\tfunction createButtonText( searchTerm ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Create page: <mark>%s</mark>' ),\n\t\t\t\tsearchTerm\n\t\t\t),\n\t\t\t{ mark: <mark /> }\n\t\t);\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tanchor={ popoverAnchor }\n\t\t\tanimate={ false }\n\t\t\tonClose={ stopAddingLink }\n\t\t\tonFocusOutside={ onFocusOutside }\n\t\t\tplacement=\"bottom\"\n\t\t\toffset={ 8 }\n\t\t\tshift\n\t\t\tfocusOnMount={ focusOnMount }\n\t\t\tconstrainTabbing\n\t\t>\n\t\t\t<LinkControl\n\t\t\t\tvalue={ linkValue }\n\t\t\t\tonChange={ onChangeLink }\n\t\t\t\tonRemove={ removeLink }\n\t\t\t\thasRichPreviews\n\t\t\t\tcreateSuggestion={ createPageEntity && handleCreate }\n\t\t\t\twithCreateSuggestion={ userCanCreatePages }\n\t\t\t\tcreateSuggestionButtonText={ createButtonText }\n\t\t\t\thasTextControl\n\t\t\t\tsettings={ LINK_SETTINGS }\n\t\t\t\tshowInitialSuggestions\n\t\t\t\tsuggestionsQuery={ {\n\t\t\t\t\t// always show Pages as initial suggestions\n\t\t\t\t\tinitialSuggestionsSearchOptions: {\n\t\t\t\t\t\ttype: 'post',\n\t\t\t\t\t\tsubtype: 'page',\n\t\t\t\t\t\tperPage: 20,\n\t\t\t\t\t},\n\t\t\t\t} }\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n\nfunction getRichTextValueFromSelection( value, isActive ) {\n\t// Default to the selection ranges on the RichTextValue object.\n\tlet textStart = value.start;\n\tlet textEnd = value.end;\n\n\t// If the format is currently active then the rich text value\n\t// should always be taken from the bounds of the active format\n\t// and not the selected text.\n\tif ( isActive ) {\n\t\tconst boundary = getFormatBoundary( value, {\n\t\t\ttype: 'core/link',\n\t\t} );\n\n\t\ttextStart = boundary.start;\n\n\t\t// Text *selection* always extends +1 beyond the edge of the format.\n\t\t// We account for that here.\n\t\ttextEnd = boundary.end + 1;\n\t}\n\n\t// Get a RichTextValue containing the selected text content.\n\treturn slice( value, textStart, textEnd );\n}\n\nexport default InlineLinkUI;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,wBAAwB,QAAQ,oBAAoB;AACtE,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,OAAO,QAAQ,uBAAuB;AAC/C,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SACCC,MAAM,EACNC,MAAM,EACNC,WAAW,EACXC,WAAW,EACXC,YAAY,EACZC,KAAK,EACLC,OAAO,EACPC,KAAK,EACLC,MAAM,EACNC,SAAS,QACH,sBAAsB;AAC7B,SACCC,yBAAyB,IAAIC,WAAW,EACxCC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,SAASC,gBAAgB,EAAEC,WAAW,EAAEC,iBAAiB,QAAQ,SAAS;AAC1E,SAASC,IAAI,IAAIC,QAAQ,QAAQ,SAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE3C,MAAMC,aAAa,GAAG,CACrB,GAAGZ,WAAW,CAACa,qBAAqB,EACpC;EACCC,EAAE,EAAE,UAAU;EACdC,KAA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AgB;IACjC+D,SAAS,EAAC,QAAQ;IAClBC,MAAM,EAAG,CAAG;IACZC,KAAK;IACL9D,YAAY,EAAGA,YAAc;IAC7B+D,gBAAgB;IAAAC,QAAA,eAEhB7E,IAAA,CAACX,WAAW;MACXmB,KAAK,EAAGoB,SAAW;MACnBnB,QAAQ,EAAG6B,YAAc;MACzBwC,QAAQ,EAAG1C,UAAY;MACvB2C,eAAe;MACfC,gBAAgB,EAAG7D,gBAAgB,IAAI0C,YAAc;MACrDoB,oBAAoB,EAAG7D,kBAAoB;MAC3C8D,0BAA0B,EAAGf,gBAAkB;MAC/CgB,cAAc;MACdrF,QAAQ,EAAGG,aAAe;MAC1BmF,sBAAsB;MACtBC,gBAAgB,EAAG;QAClB;QACAC,+BAA+B,EAAE;UAChCxD,IAAI,EAAE,MAAM;UACZyD,OAAO,EAAE,MAAM;UACfC,OAAO,EAAE;QACV;MACD;IAAG,CACH;EAAC,CACM,CAAC;AAEZ;AAEA,SAASzE,6BAA6BA,CAAEP,KAAK,EAAEF,QAAQ,EAAG;EACzD;EACA,IAAImF,SAAS,GAAGjF,KAAK,CAACyC,KAAK;EAC3B,IAAIyC,OAAO,GAAGlF,KAAK,CAACmF,GAAG;;EAEvB;EACA;EACA;EACA,IAAKrF,QAAQ,EAAG;IACf,MAAMgD,QAAQ,GAAG1D,iBAAiB,CAAEY,KAAK,EAAE;MAC1CsB,IAAI,EAAE;IACP,CAAE,CAAC;IAEH2D,SAAS,GAAGnC,QAAQ,CAACL,KAAK;;IAE1B;IACA;IACAyC,OAAO,GAAGpC,QAAQ,CAACqC,GAAG,GAAG,CAAC;EAC3B;;EAEA;EACA,OAAO5G,KAAK,CAAEyB,KAAK,EAAEiF,SAAS,EAAEC,OAAQ,CAAC;AAC1C;AAEA,eAAerF,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useMemo","createInterpolateElement","__","sprintf","speak","Popover","prependHTTP","create","insert","isCollapsed","applyFormat","removeFormat","slice","replace","split","concat","useAnchor","__experimentalLinkControl","LinkControl","store","blockEditorStore","useDispatch","useSelect","createLinkFormat","isValidHref","getFormatBoundary","link","settings","jsx","_jsx","LINK_SETTINGS","DEFAULT_LINK_SETTINGS","id","title","InlineLinkUI","isActive","activeAttributes","value","onChange","onFocusOutside","stopAddingLink","contentRef","focusOnMount","richLinkTextValue","getRichTextValueFromSelection","richTextText","text","selectionChange","createPageEntity","userCanCreatePages","selectionStart","select","getSettings","getSelectionStart","_settings","__experimentalCreatePageEntity","__experimentalUserCanCreatePages","linkValue","url","type","opensInNewTab","target","nofollow","rel","includes","removeLink","newValue","onChangeLink","nextValue","hasLink","isNewLink","newUrl","linkFormat","undefined","String","opensInNewWindow","newText","inserted","start","length","clientId","identifier","attributeKey","boundary","valBefore","valAfter","newValAfter","popoverAnchor","editableContentElement","current","handleCreate","pageTitle","page","status","rendered","kind","createButtonText","searchTerm","mark","anchor","animate","onClose","placement","offset","shift","constrainTabbing","children","onRemove","hasRichPreviews","createSuggestion","withCreateSuggestion","createSuggestionButtonText","hasTextControl","showInitialSuggestions","suggestionsQuery","initialSuggestionsSearchOptions","subtype","perPage","textStart","textEnd","end"],"sources":["@wordpress/format-library/src/link/inline.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, createInterpolateElement } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport { Popover } from '@wordpress/components';\nimport { prependHTTP } from '@wordpress/url';\nimport {\n\tcreate,\n\tinsert,\n\tisCollapsed,\n\tapplyFormat,\n\tremoveFormat,\n\tslice,\n\treplace,\n\tsplit,\n\tconcat,\n\tuseAnchor,\n} from '@wordpress/rich-text';\nimport {\n\t__experimentalLinkControl as LinkControl,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { createLinkFormat, isValidHref, getFormatBoundary } from './utils';\nimport { link as settings } from './index';\n\nconst LINK_SETTINGS = [\n\t...LinkControl.DEFAULT_LINK_SETTINGS,\n\t{\n\t\tid: 'nofollow',\n\t\ttitle: __( 'Mark as nofollow' ),\n\t},\n];\n\nfunction InlineLinkUI( {\n\tisActive,\n\tactiveAttributes,\n\tvalue,\n\tonChange,\n\tonFocusOutside,\n\tstopAddingLink,\n\tcontentRef,\n\tfocusOnMount,\n} ) {\n\tconst richLinkTextValue = getRichTextValueFromSelection( value, isActive );\n\n\t// Get the text content minus any HTML tags.\n\tconst richTextText = richLinkTextValue.text;\n\n\tconst { selectionChange } = useDispatch( blockEditorStore );\n\n\tconst { createPageEntity, userCanCreatePages, selectionStart } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, getSelectionStart } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst _settings = getSettings();\n\n\t\t\treturn {\n\t\t\t\tcreatePageEntity: _settings.__experimentalCreatePageEntity,\n\t\t\t\tuserCanCreatePages: _settings.__experimentalUserCanCreatePages,\n\t\t\t\tselectionStart: getSelectionStart(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst linkValue = useMemo(\n\t\t() => ( {\n\t\t\turl: activeAttributes.url,\n\t\t\ttype: activeAttributes.type,\n\t\t\tid: activeAttributes.id,\n\t\t\topensInNewTab: activeAttributes.target === '_blank',\n\t\t\tnofollow: activeAttributes.rel?.includes( 'nofollow' ),\n\t\t\ttitle: richTextText,\n\t\t} ),\n\t\t[\n\t\t\tactiveAttributes.id,\n\t\t\tactiveAttributes.rel,\n\t\t\tactiveAttributes.target,\n\t\t\tactiveAttributes.type,\n\t\t\tactiveAttributes.url,\n\t\t\trichTextText,\n\t\t]\n\t);\n\n\tfunction removeLink() {\n\t\tconst newValue = removeFormat( value, 'core/link' );\n\t\tonChange( newValue );\n\t\tstopAddingLink();\n\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t}\n\n\tfunction onChangeLink( nextValue ) {\n\t\tconst hasLink = linkValue?.url;\n\t\tconst isNewLink = ! hasLink;\n\n\t\t// Merge the next value with the current link value.\n\t\tnextValue = {\n\t\t\t...linkValue,\n\t\t\t...nextValue,\n\t\t};\n\n\t\tconst newUrl = prependHTTP( nextValue.url );\n\t\tconst linkFormat = createLinkFormat( {\n\t\t\turl: newUrl,\n\t\t\ttype: nextValue.type,\n\t\t\tid:\n\t\t\t\tnextValue.id !== undefined && nextValue.id !== null\n\t\t\t\t\t? String( nextValue.id )\n\t\t\t\t\t: undefined,\n\t\t\topensInNewWindow: nextValue.opensInNewTab,\n\t\t\tnofollow: nextValue.nofollow,\n\t\t} );\n\n\t\tconst newText = nextValue.title || newUrl;\n\n\t\t// Scenario: we have any active text selection or an active format.\n\t\tlet newValue;\n\t\tif ( isCollapsed( value ) && ! isActive ) {\n\t\t\t// Scenario: we don't have any actively selected text or formats.\n\t\t\tconst inserted = insert( value, newText );\n\n\t\t\tnewValue = applyFormat(\n\t\t\t\tinserted,\n\t\t\t\tlinkFormat,\n\t\t\t\tvalue.start,\n\t\t\t\tvalue.start + newText.length\n\t\t\t);\n\n\t\t\tonChange( newValue );\n\n\t\t\t// Close the Link UI.\n\t\t\tstopAddingLink();\n\n\t\t\t// Move the selection to the end of the inserted link outside of the format boundary\n\t\t\t// so the user can continue typing after the link.\n\t\t\tselectionChange( {\n\t\t\t\tclientId: selectionStart.clientId,\n\t\t\t\tidentifier: selectionStart.attributeKey,\n\t\t\t\tstart: value.start + newText.length + 1,\n\t\t\t} );\n\n\t\t\treturn;\n\t\t} else if ( newText === richTextText ) {\n\t\t\tnewValue = applyFormat( value, linkFormat );\n\t\t} else {\n\t\t\t// Scenario: Editing an existing link.\n\n\t\t\t// Create new RichText value for the new text in order that we\n\t\t\t// can apply formats to it.\n\t\t\tnewValue = create( { text: newText } );\n\t\t\t// Apply the new Link format to this new text value.\n\t\t\tnewValue = applyFormat( newValue, linkFormat, 0, newText.length );\n\n\t\t\t// Get the boundaries of the active link format.\n\t\t\tconst boundary = getFormatBoundary( value, {\n\t\t\t\ttype: 'core/link',\n\t\t\t} );\n\n\t\t\t// Split the value at the start of the active link format.\n\t\t\t// Passing \"start\" as the 3rd parameter is required to ensure\n\t\t\t// the second half of the split value is split at the format's\n\t\t\t// start boundary and avoids relying on the value's \"end\" property\n\t\t\t// which may not correspond correctly.\n\t\t\tconst [ valBefore, valAfter ] = split(\n\t\t\t\tvalue,\n\t\t\t\tboundary.start,\n\t\t\t\tboundary.start\n\t\t\t);\n\n\t\t\t// Update the original (full) RichTextValue replacing the\n\t\t\t// target text with the *new* RichTextValue containing:\n\t\t\t// 1. The new text content.\n\t\t\t// 2. The new link format.\n\t\t\t// As \"replace\" will operate on the first match only, it is\n\t\t\t// run only against the second half of the value which was\n\t\t\t// split at the active format's boundary. This avoids a bug\n\t\t\t// with incorrectly targetted replacements.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/41771.\n\t\t\t// Note original formats will be lost when applying this change.\n\t\t\t// That is expected behaviour.\n\t\t\t// See: https://github.com/WordPress/gutenberg/pull/33849#issuecomment-936134179.\n\t\t\tconst newValAfter = replace( valAfter, richTextText, newValue );\n\n\t\t\tnewValue = concat( valBefore, newValAfter );\n\t\t}\n\n\t\tonChange( newValue );\n\n\t\t// Focus should only be returned to the rich text on submit if this link is not\n\t\t// being created for the first time. If it is then focus should remain within the\n\t\t// Link UI because it should remain open for the user to modify the link they have\n\t\t// just created.\n\t\tif ( ! isNewLink ) {\n\t\t\tstopAddingLink();\n\t\t}\n\n\t\tif ( ! isValidHref( newUrl ) ) {\n\t\t\tspeak(\n\t\t\t\t__(\n\t\t\t\t\t'Warning: the link has been inserted but may have errors. Please test it.'\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t} else if ( isActive ) {\n\t\t\tspeak( __( 'Link edited.' ), 'assertive' );\n\t\t} else {\n\t\t\tspeak( __( 'Link inserted.' ), 'assertive' );\n\t\t}\n\t}\n\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings: {\n\t\t\t...settings,\n\t\t\tisActive,\n\t\t},\n\t} );\n\n\tasync function handleCreate( pageTitle ) {\n\t\tconst page = await createPageEntity( {\n\t\t\ttitle: pageTitle,\n\t\t\tstatus: 'draft',\n\t\t} );\n\n\t\treturn {\n\t\t\tid: page.id,\n\t\t\ttype: page.type,\n\t\t\ttitle: page.title.rendered,\n\t\t\turl: page.link,\n\t\t\tkind: 'post-type',\n\t\t};\n\t}\n\n\tfunction createButtonText( searchTerm ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Create page: <mark>%s</mark>' ),\n\t\t\t\tsearchTerm\n\t\t\t),\n\t\t\t{ mark: <mark /> }\n\t\t);\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tanchor={ popoverAnchor }\n\t\t\tanimate={ false }\n\t\t\tonClose={ stopAddingLink }\n\t\t\tonFocusOutside={ onFocusOutside }\n\t\t\tplacement=\"bottom\"\n\t\t\toffset={ 8 }\n\t\t\tshift\n\t\t\tfocusOnMount={ focusOnMount }\n\t\t\tconstrainTabbing\n\t\t>\n\t\t\t<LinkControl\n\t\t\t\tvalue={ linkValue }\n\t\t\t\tonChange={ onChangeLink }\n\t\t\t\tonRemove={ removeLink }\n\t\t\t\thasRichPreviews\n\t\t\t\tcreateSuggestion={ createPageEntity && handleCreate }\n\t\t\t\twithCreateSuggestion={ userCanCreatePages }\n\t\t\t\tcreateSuggestionButtonText={ createButtonText }\n\t\t\t\thasTextControl\n\t\t\t\tsettings={ LINK_SETTINGS }\n\t\t\t\tshowInitialSuggestions\n\t\t\t\tsuggestionsQuery={ {\n\t\t\t\t\t// always show Pages as initial suggestions\n\t\t\t\t\tinitialSuggestionsSearchOptions: {\n\t\t\t\t\t\ttype: 'post',\n\t\t\t\t\t\tsubtype: 'page',\n\t\t\t\t\t\tperPage: 20,\n\t\t\t\t\t},\n\t\t\t\t} }\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n\nfunction getRichTextValueFromSelection( value, isActive ) {\n\t// Default to the selection ranges on the RichTextValue object.\n\tlet textStart = value.start;\n\tlet textEnd = value.end;\n\n\t// If the format is currently active then the rich text value\n\t// should always be taken from the bounds of the active format\n\t// and not the selected text.\n\tif ( isActive ) {\n\t\tconst boundary = getFormatBoundary( value, {\n\t\t\ttype: 'core/link',\n\t\t} );\n\n\t\ttextStart = boundary.start;\n\n\t\t// Text *selection* always extends +1 beyond the edge of the format.\n\t\t// We account for that here.\n\t\ttextEnd = boundary.end + 1;\n\t}\n\n\t// Get a RichTextValue containing the selected text content.\n\treturn slice( value, textStart, textEnd );\n}\n\nexport default InlineLinkUI;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,wBAAwB,QAAQ,oBAAoB;AACtE,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,OAAO,QAAQ,uBAAuB;AAC/C,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SACCC,MAAM,EACNC,MAAM,EACNC,WAAW,EACXC,WAAW,EACXC,YAAY,EACZC,KAAK,EACLC,OAAO,EACPC,KAAK,EACLC,MAAM,EACNC,SAAS,QACH,sBAAsB;AAC7B,SACCC,yBAAyB,IAAIC,WAAW,EACxCC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,SAASC,gBAAgB,EAAEC,WAAW,EAAEC,iBAAiB,QAAQ,SAAS;AAC1E,SAASC,IAAI,IAAIC,QAAQ,QAAQ,SAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE3C,MAAMC,aAAa,GAAG,CACrB,GAAGZ,WAAW,CAACa,qBAAqB,EACpC;EACCC,EAAE,EAAE,UAAU;EACdC,KAAK,EAAE/B,EAAE,CAAE,kBAAmB;AAC/B,CAAC,CACD;AAED,SAASgC,YAAY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AK;IACL9D,YAAY,EAAGA,YAAc;IAC7B+D,gBAAgB;IAAAC,QAAA,eAEhB7E,IAAA,CAACX,WAAW;MACXmB,KAAK,EAAGoB,SAAW;MACnBnB,QAAQ,EAAG6B,YAAc;MACzBwC,QAAQ,EAAG1C,UAAY;MACvB2C,eAAe;MACfC,gBAAgB,EAAG7D,gBAAgB,IAAI0C,YAAc;MACrDoB,oBAAoB,EAAG7D,kBAAoB;MAC3C8D,0BAA0B,EAAGf,gBAAkB;MAC/CgB,cAAc;MACdrF,QAAQ,EAAGG,aAAe;MAC1BmF,sBAAsB;MACtBC,gBAAgB,EAAG;QAClB;QACAC,+BAA+B,EAAE;UAChCxD,IAAI,EAAE,MAAM;UACZyD,OAAO,EAAE,MAAM;UACfC,OAAO,EAAE;QACV;MACD;IAAG,CACH;EAAC,CACM,CAAC;AAEZ;AAEA,SAASzE,6BAA6BA,CAAEP,KAAK,EAAEF,QAAQ,EAAG;EACzD;EACA,IAAImF,SAAS,GAAGjF,KAAK,CAACyC,KAAK;EAC3B,IAAIyC,OAAO,GAAGlF,KAAK,CAACmF,GAAG;;EAEvB;EACA;EACA;EACA,IAAKrF,QAAQ,EAAG;IACf,MAAMgD,QAAQ,GAAG1D,iBAAiB,CAAEY,KAAK,EAAE;MAC1CsB,IAAI,EAAE;IACP,CAAE,CAAC;IAEH2D,SAAS,GAAGnC,QAAQ,CAACL,KAAK;;IAE1B;IACA;IACAyC,OAAO,GAAGpC,QAAQ,CAACqC,GAAG,GAAG,CAAC;EAC3B;;EAEA;EACA,OAAO5G,KAAK,CAAEyB,KAAK,EAAEiF,SAAS,EAAEC,OAAQ,CAAC;AAC1C;AAEA,eAAerF,YAAY","ignoreList":[]}
|
|
@@ -19,9 +19,7 @@ import { external, textColor } from '@wordpress/icons';
|
|
|
19
19
|
import { createLinkFormat, isValidHref } from '../utils';
|
|
20
20
|
import linkSettingsScreens from './screens';
|
|
21
21
|
import styles from '../modal.scss';
|
|
22
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
24
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
23
|
const LinkSettingsScreen = ({
|
|
26
24
|
onRemove,
|
|
27
25
|
onClose,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useNavigation","useRoute","__","useState","useContext","useEffect","useMemo","prependHTTP","BottomSheet","BottomSheetContext","create","insert","isCollapsed","applyFormat","getTextContent","slice","external","textColor","createLinkFormat","isValidHref","linkSettingsScreens","styles","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","LinkSettingsScreen","onRemove","onClose","onChange","speak","value","isActive","activeAttributes","isVisible","text","setText","opensInNewWindow","setOpensInNewWindows","target","linkValues","setLinkValues","isActiveLink","isRemovingLink","shouldEnableBottomSheetMaxHeight","onHandleClosingBottomSheet","listProps","navigation","route","inputValue","url","params","onLinkCellPressed","navigate","picker","submit","skipStateUpdates","submitLink","shouldCloseBottomSheet","removeLink","clearFormat","activeFormats","linkText","format","newAttributes","toInsert","length","start","end","textLength","needsSelectionUpdate","submitValue","unsubscribe","addListener","shouldShowLinkOptions","children","LinkCell","onPress","Cell","icon","label","placeholder","onChangeValue","onSubmit","separatorType","undefined","SwitchCell","onValueChange","labelStyle","clearLinkButton","safeAreaBottomInset"],"sources":["@wordpress/format-library/src/link/modal-screens/link-settings-screen.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { useNavigation, useRoute } from '@react-navigation/native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useContext, useEffect, useMemo } from '@wordpress/element';\nimport { prependHTTP } from '@wordpress/url';\nimport { BottomSheet, BottomSheetContext } from '@wordpress/components';\nimport {\n\tcreate,\n\tinsert,\n\tisCollapsed,\n\tapplyFormat,\n\tgetTextContent,\n\tslice,\n} from '@wordpress/rich-text';\nimport { external, textColor } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { createLinkFormat, isValidHref } from '../utils';\nimport linkSettingsScreens from './screens';\n\nimport styles from '../modal.scss';\n\nconst LinkSettingsScreen = ( {\n\tonRemove,\n\tonClose,\n\tonChange,\n\tspeak,\n\tvalue,\n\tisActive,\n\tactiveAttributes,\n\tisVisible,\n} ) => {\n\tconst [ text, setText ] = useState( getTextContent( slice( value ) ) );\n\tconst [ opensInNewWindow, setOpensInNewWindows ] = useState(\n\t\tactiveAttributes.target === '_blank'\n\t);\n\tconst [ linkValues, setLinkValues ] = useState( {\n\t\tisActiveLink: isActive,\n\t\tisRemovingLink: false,\n\t} );\n\n\tconst {\n\t\tshouldEnableBottomSheetMaxHeight,\n\t\tonHandleClosingBottomSheet,\n\t\tlistProps,\n\t} = useContext( BottomSheetContext );\n\n\tconst navigation = useNavigation();\n\tconst route = useRoute();\n\tconst { inputValue = activeAttributes.url || '' } = route.params || {};\n\tconst onLinkCellPressed = () => {\n\t\tshouldEnableBottomSheetMaxHeight( false );\n\t\tnavigation.navigate( linkSettingsScreens.picker, { inputValue } );\n\t};\n\tuseEffect( () => {\n\t\tonHandleClosingBottomSheet( () => {\n\t\t\tsubmit( inputValue, { skipStateUpdates: true } );\n\t\t} );\n\t}, [ inputValue, opensInNewWindow, text ] );\n\n\tuseEffect( () => {\n\t\tconst { isActiveLink, isRemovingLink } = linkValues;\n\t\tif ( !! inputValue && ! isActiveLink && isVisible ) {\n\t\t\tsubmitLink( { shouldCloseBottomSheet: false } );\n\t\t} else if (\n\t\t\t( ( inputValue === '' && isActiveLink ) || isRemovingLink ) &&\n\t\t\tisVisible\n\t\t) {\n\t\t\tremoveLink( { shouldCloseBottomSheet: false } );\n\t\t}\n\t}, [\n\t\tinputValue,\n\t\tisVisible,\n\t\tlinkValues.isActiveLink,\n\t\tlinkValues.isRemovingLink,\n\t] );\n\n\tconst clearFormat = ( { skipStateUpdates = false } = {} ) => {\n\t\tonChange( { ...value, activeFormats: [] } );\n\t\tif ( ! skipStateUpdates ) {\n\t\t\tsetLinkValues( { isActiveLink: false, isRemovingLink: true } );\n\t\t}\n\t};\n\n\tconst submitLink = ( {\n\t\tshouldCloseBottomSheet = true,\n\t\tskipStateUpdates = false,\n\t} = {} ) => {\n\t\tconst url = prependHTTP( inputValue );\n\t\tconst linkText = text || inputValue;\n\t\tconst format = createLinkFormat( {\n\t\t\turl,\n\t\t\topensInNewWindow,\n\t\t\ttext: linkText,\n\t\t} );\n\t\tlet newAttributes;\n\t\tif ( isCollapsed( value ) && ! isActive ) {\n\t\t\t// Insert link.\n\t\t\tconst toInsert = applyFormat(\n\t\t\t\tcreate( { text: linkText } ),\n\t\t\t\tformat,\n\t\t\t\t0,\n\t\t\t\tlinkText.length\n\t\t\t);\n\t\t\tnewAttributes = insert( value, toInsert );\n\t\t} else if ( text !== getTextContent( slice( value ) ) ) {\n\t\t\t// Edit text in selected link.\n\t\t\tconst toInsert = applyFormat(\n\t\t\t\tcreate( { text } ),\n\t\t\t\tformat,\n\t\t\t\t0,\n\t\t\t\ttext.length\n\t\t\t);\n\t\t\tnewAttributes = insert( value, toInsert, value.start, value.end );\n\t\t} else {\n\t\t\t// Transform selected text into link.\n\t\t\tnewAttributes = applyFormat( value, format );\n\t\t}\n\t\t// Move selection to end of link.\n\t\tconst textLength = newAttributes.text.length;\n\t\t// check for zero width spaces\n\t\tif ( newAttributes.end > textLength ) {\n\t\t\tnewAttributes.start = textLength;\n\t\t\tnewAttributes.end = textLength;\n\t\t} else {\n\t\t\tnewAttributes.start = newAttributes.end;\n\t\t}\n\t\tnewAttributes.activeFormats = [];\n\t\tonChange( { ...newAttributes, needsSelectionUpdate: true } );\n\t\tif ( ! skipStateUpdates ) {\n\t\t\tsetLinkValues( { isActiveLink: true, isRemovingLink: false } );\n\t\t}\n\n\t\tif ( ! isValidHref( url ) ) {\n\t\t\tspeak(\n\t\t\t\t__(\n\t\t\t\t\t'Warning: the link has been inserted but may have errors. Please test it.'\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t} else if ( isActive ) {\n\t\t\tspeak( __( 'Link edited.' ), 'assertive' );\n\t\t} else {\n\t\t\tspeak( __( 'Link inserted' ), 'assertive' );\n\t\t}\n\n\t\tif ( shouldCloseBottomSheet ) {\n\t\t\tonClose();\n\t\t}\n\t};\n\n\tconst removeLink = ( {\n\t\tshouldCloseBottomSheet = true,\n\t\tskipStateUpdates = false,\n\t} = {} ) => {\n\t\tclearFormat( { skipStateUpdates } );\n\t\tonRemove();\n\t\tif ( shouldCloseBottomSheet ) {\n\t\t\tonClose();\n\t\t}\n\t};\n\n\tconst submit = ( submitValue, { skipStateUpdates = false } = {} ) => {\n\t\tif ( submitValue === '' ) {\n\t\t\tremoveLink( { skipStateUpdates } );\n\t\t} else {\n\t\t\tsubmitLink( { skipStateUpdates } );\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tconst unsubscribe = navigation.addListener( 'focus', () => {\n\t\t\tconst { params = {} } = route;\n\t\t\tif ( ! text && params.text ) {\n\t\t\t\tsetText( params.text );\n\t\t\t}\n\t\t} );\n\t\treturn unsubscribe;\n\t}, [ navigation, route.params?.text, text ] );\n\n\treturn useMemo( () => {\n\t\tconst shouldShowLinkOptions = !! inputValue;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BottomSheet.LinkCell\n\t\t\t\t\tvalue={ inputValue }\n\t\t\t\t\tonPress={ onLinkCellPressed }\n\t\t\t\t/>\n\t\t\t\t<BottomSheet.Cell\n\t\t\t\t\ticon={ textColor }\n\t\t\t\t\tlabel={ __( 'Link text' ) }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tplaceholder={ __( 'Add link text' ) }\n\t\t\t\t\tonChangeValue={ setText }\n\t\t\t\t\tonSubmit={ submit }\n\t\t\t\t\tseparatorType={ shouldShowLinkOptions ? undefined : 'none' }\n\t\t\t\t/>\n\t\t\t\t{ shouldShowLinkOptions && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BottomSheet.SwitchCell\n\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\tvalue={ opensInNewWindow }\n\t\t\t\t\t\t\tonValueChange={ setOpensInNewWindows }\n\t\t\t\t\t\t\tseparatorType=\"fullWidth\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BottomSheet.Cell\n\t\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\t\tlabelStyle={ styles.clearLinkButton }\n\t\t\t\t\t\t\tseparatorType=\"none\"\n\t\t\t\t\t\t\tonPress={ removeLink }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}, [ inputValue, text, opensInNewWindow, listProps.safeAreaBottomInset ] );\n};\n\nexport default LinkSettingsScreen;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,0BAA0B;;AAElE;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,QAAQ,oBAAoB;AAC7E,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,WAAW,EAAEC,kBAAkB,QAAQ,uBAAuB;AACvE,SACCC,MAAM,EACNC,MAAM,EACNC,WAAW,EACXC,WAAW,EACXC,cAAc,EACdC,KAAK,QACC,sBAAsB;AAC7B,SAASC,QAAQ,EAAEC,SAAS,QAAQ,kBAAkB;;AAEtD;AACA;AACA;AACA,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,UAAU;AACxD,OAAOC,mBAAmB,MAAM,WAAW;AAE3C,OAAOC,MAAM,MAAM,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAEnC,MAA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oute","__","useState","useContext","useEffect","useMemo","prependHTTP","BottomSheet","BottomSheetContext","create","insert","isCollapsed","applyFormat","getTextContent","slice","external","textColor","createLinkFormat","isValidHref","linkSettingsScreens","styles","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","LinkSettingsScreen","onRemove","onClose","onChange","speak","value","isActive","activeAttributes","isVisible","text","setText","opensInNewWindow","setOpensInNewWindows","target","linkValues","setLinkValues","isActiveLink","isRemovingLink","shouldEnableBottomSheetMaxHeight","onHandleClosingBottomSheet","listProps","navigation","route","inputValue","url","params","onLinkCellPressed","navigate","picker","submit","skipStateUpdates","submitLink","shouldCloseBottomSheet","removeLink","clearFormat","activeFormats","linkText","format","newAttributes","toInsert","length","start","end","textLength","needsSelectionUpdate","submitValue","unsubscribe","addListener","shouldShowLinkOptions","children","LinkCell","onPress","Cell","icon","label","placeholder","onChangeValue","onSubmit","separatorType","undefined","SwitchCell","onValueChange","labelStyle","clearLinkButton","safeAreaBottomInset"],"sources":["@wordpress/format-library/src/link/modal-screens/link-settings-screen.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { useNavigation, useRoute } from '@react-navigation/native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useContext, useEffect, useMemo } from '@wordpress/element';\nimport { prependHTTP } from '@wordpress/url';\nimport { BottomSheet, BottomSheetContext } from '@wordpress/components';\nimport {\n\tcreate,\n\tinsert,\n\tisCollapsed,\n\tapplyFormat,\n\tgetTextContent,\n\tslice,\n} from '@wordpress/rich-text';\nimport { external, textColor } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { createLinkFormat, isValidHref } from '../utils';\nimport linkSettingsScreens from './screens';\n\nimport styles from '../modal.scss';\n\nconst LinkSettingsScreen = ( {\n\tonRemove,\n\tonClose,\n\tonChange,\n\tspeak,\n\tvalue,\n\tisActive,\n\tactiveAttributes,\n\tisVisible,\n} ) => {\n\tconst [ text, setText ] = useState( getTextContent( slice( value ) ) );\n\tconst [ opensInNewWindow, setOpensInNewWindows ] = useState(\n\t\tactiveAttributes.target === '_blank'\n\t);\n\tconst [ linkValues, setLinkValues ] = useState( {\n\t\tisActiveLink: isActive,\n\t\tisRemovingLink: false,\n\t} );\n\n\tconst {\n\t\tshouldEnableBottomSheetMaxHeight,\n\t\tonHandleClosingBottomSheet,\n\t\tlistProps,\n\t} = useContext( BottomSheetContext );\n\n\tconst navigation = useNavigation();\n\tconst route = useRoute();\n\tconst { inputValue = activeAttributes.url || '' } = route.params || {};\n\tconst onLinkCellPressed = () => {\n\t\tshouldEnableBottomSheetMaxHeight( false );\n\t\tnavigation.navigate( linkSettingsScreens.picker, { inputValue } );\n\t};\n\tuseEffect( () => {\n\t\tonHandleClosingBottomSheet( () => {\n\t\t\tsubmit( inputValue, { skipStateUpdates: true } );\n\t\t} );\n\t}, [ inputValue, opensInNewWindow, text ] );\n\n\tuseEffect( () => {\n\t\tconst { isActiveLink, isRemovingLink } = linkValues;\n\t\tif ( !! inputValue && ! isActiveLink && isVisible ) {\n\t\t\tsubmitLink( { shouldCloseBottomSheet: false } );\n\t\t} else if (\n\t\t\t( ( inputValue === '' && isActiveLink ) || isRemovingLink ) &&\n\t\t\tisVisible\n\t\t) {\n\t\t\tremoveLink( { shouldCloseBottomSheet: false } );\n\t\t}\n\t}, [\n\t\tinputValue,\n\t\tisVisible,\n\t\tlinkValues.isActiveLink,\n\t\tlinkValues.isRemovingLink,\n\t] );\n\n\tconst clearFormat = ( { skipStateUpdates = false } = {} ) => {\n\t\tonChange( { ...value, activeFormats: [] } );\n\t\tif ( ! skipStateUpdates ) {\n\t\t\tsetLinkValues( { isActiveLink: false, isRemovingLink: true } );\n\t\t}\n\t};\n\n\tconst submitLink = ( {\n\t\tshouldCloseBottomSheet = true,\n\t\tskipStateUpdates = false,\n\t} = {} ) => {\n\t\tconst url = prependHTTP( inputValue );\n\t\tconst linkText = text || inputValue;\n\t\tconst format = createLinkFormat( {\n\t\t\turl,\n\t\t\topensInNewWindow,\n\t\t\ttext: linkText,\n\t\t} );\n\t\tlet newAttributes;\n\t\tif ( isCollapsed( value ) && ! isActive ) {\n\t\t\t// Insert link.\n\t\t\tconst toInsert = applyFormat(\n\t\t\t\tcreate( { text: linkText } ),\n\t\t\t\tformat,\n\t\t\t\t0,\n\t\t\t\tlinkText.length\n\t\t\t);\n\t\t\tnewAttributes = insert( value, toInsert );\n\t\t} else if ( text !== getTextContent( slice( value ) ) ) {\n\t\t\t// Edit text in selected link.\n\t\t\tconst toInsert = applyFormat(\n\t\t\t\tcreate( { text } ),\n\t\t\t\tformat,\n\t\t\t\t0,\n\t\t\t\ttext.length\n\t\t\t);\n\t\t\tnewAttributes = insert( value, toInsert, value.start, value.end );\n\t\t} else {\n\t\t\t// Transform selected text into link.\n\t\t\tnewAttributes = applyFormat( value, format );\n\t\t}\n\t\t// Move selection to end of link.\n\t\tconst textLength = newAttributes.text.length;\n\t\t// check for zero width spaces\n\t\tif ( newAttributes.end > textLength ) {\n\t\t\tnewAttributes.start = textLength;\n\t\t\tnewAttributes.end = textLength;\n\t\t} else {\n\t\t\tnewAttributes.start = newAttributes.end;\n\t\t}\n\t\tnewAttributes.activeFormats = [];\n\t\tonChange( { ...newAttributes, needsSelectionUpdate: true } );\n\t\tif ( ! skipStateUpdates ) {\n\t\t\tsetLinkValues( { isActiveLink: true, isRemovingLink: false } );\n\t\t}\n\n\t\tif ( ! isValidHref( url ) ) {\n\t\t\tspeak(\n\t\t\t\t__(\n\t\t\t\t\t'Warning: the link has been inserted but may have errors. Please test it.'\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t} else if ( isActive ) {\n\t\t\tspeak( __( 'Link edited.' ), 'assertive' );\n\t\t} else {\n\t\t\tspeak( __( 'Link inserted' ), 'assertive' );\n\t\t}\n\n\t\tif ( shouldCloseBottomSheet ) {\n\t\t\tonClose();\n\t\t}\n\t};\n\n\tconst removeLink = ( {\n\t\tshouldCloseBottomSheet = true,\n\t\tskipStateUpdates = false,\n\t} = {} ) => {\n\t\tclearFormat( { skipStateUpdates } );\n\t\tonRemove();\n\t\tif ( shouldCloseBottomSheet ) {\n\t\t\tonClose();\n\t\t}\n\t};\n\n\tconst submit = ( submitValue, { skipStateUpdates = false } = {} ) => {\n\t\tif ( submitValue === '' ) {\n\t\t\tremoveLink( { skipStateUpdates } );\n\t\t} else {\n\t\t\tsubmitLink( { skipStateUpdates } );\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tconst unsubscribe = navigation.addListener( 'focus', () => {\n\t\t\tconst { params = {} } = route;\n\t\t\tif ( ! text && params.text ) {\n\t\t\t\tsetText( params.text );\n\t\t\t}\n\t\t} );\n\t\treturn unsubscribe;\n\t}, [ navigation, route.params?.text, text ] );\n\n\treturn useMemo( () => {\n\t\tconst shouldShowLinkOptions = !! inputValue;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BottomSheet.LinkCell\n\t\t\t\t\tvalue={ inputValue }\n\t\t\t\t\tonPress={ onLinkCellPressed }\n\t\t\t\t/>\n\t\t\t\t<BottomSheet.Cell\n\t\t\t\t\ticon={ textColor }\n\t\t\t\t\tlabel={ __( 'Link text' ) }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tplaceholder={ __( 'Add link text' ) }\n\t\t\t\t\tonChangeValue={ setText }\n\t\t\t\t\tonSubmit={ submit }\n\t\t\t\t\tseparatorType={ shouldShowLinkOptions ? undefined : 'none' }\n\t\t\t\t/>\n\t\t\t\t{ shouldShowLinkOptions && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BottomSheet.SwitchCell\n\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\tvalue={ opensInNewWindow }\n\t\t\t\t\t\t\tonValueChange={ setOpensInNewWindows }\n\t\t\t\t\t\t\tseparatorType=\"fullWidth\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BottomSheet.Cell\n\t\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\t\tlabelStyle={ styles.clearLinkButton }\n\t\t\t\t\t\t\tseparatorType=\"none\"\n\t\t\t\t\t\t\tonPress={ removeLink }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}, [ inputValue, text, opensInNewWindow, listProps.safeAreaBottomInset ] );\n};\n\nexport default LinkSettingsScreen;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,0BAA0B;;AAElE;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,QAAQ,oBAAoB;AAC7E,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,WAAW,EAAEC,kBAAkB,QAAQ,uBAAuB;AACvE,SACCC,MAAM,EACNC,MAAM,EACNC,WAAW,EACXC,WAAW,EACXC,cAAc,EACdC,KAAK,QACC,sBAAsB;AAC7B,SAASC,QAAQ,EAAEC,SAAS,QAAQ,kBAAkB;;AAEtD;AACA;AACA;AACA,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,UAAU;AACxD,OAAOC,mBAAmB,MAAM,WAAW;AAE3C,OAAOC,MAAM,MAAM,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAEnC,MAAMC,kBAAkB,GAAGA,CAAE;EAC5BC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,KAAK;EACLC,KAAK;EACLC,QAAQ;EACRC,gBAAgB;EAChBC;AACD,CAAC,KAAM;EACN,MAAM,CAAEC,IAAI,EAAEC,OAAO,CAAE,GAAGnC,QAAQ,CAAEW,cAAc,CAAEC,KAAK,CAAEkB,KAAM,CAAE,CAAE,CAAC;EACtE,MAAM,CAAEM,gBAAgB,EAAEC,oBAAoB,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E,KAAK,EAAGhF,EAAE,CAAE,WAAY,CAAG;QAC3B+B,KAAK,EAAGI,IAAM;QACd8C,WAAW,EAAGjF,EAAE,CAAE,eAAgB,CAAG;QACrCkF,aAAa,EAAG9C,OAAS;QACzB+C,QAAQ,EAAG5B,MAAQ;QACnB6B,aAAa,EAAGV,qBAAqB,GAAGW,SAAS,GAAG;MAAQ,CAC5D,CAAC,EACAX,qBAAqB,iBACtBjD,KAAA,CAAAF,SAAA;QAAAoD,QAAA,gBACCtD,IAAA,CAACf,WAAW,CAACgF,UAAU;UACtBP,IAAI,EAAGjE,QAAU;UACjBkE,KAAK,EAAGhF,EAAE,CAAE,iBAAkB,CAAG;UACjC+B,KAAK,EAAGM,gBAAkB;UAC1BkD,aAAa,EAAGjD,oBAAsB;UACtC8C,aAAa,EAAC;QAAW,CACzB,CAAC,eACF/D,IAAA,CAACf,WAAW,CAACwE,IAAI;UAChBE,KAAK,EAAGhF,EAAE,CAAE,aAAc,CAAG;UAC7BwF,UAAU,EAAGrE,MAAM,CAACsE,eAAiB;UACrCL,aAAa,EAAC,MAAM;UACpBP,OAAO,EAAGlB;QAAY,CACtB,CAAC;MAAA,CACD,CACF;IAAA,CACA,CAAC;EAEL,CAAC,EAAE,CAAEV,UAAU,EAAEd,IAAI,EAAEE,gBAAgB,EAAES,SAAS,CAAC4C,mBAAmB,CAAG,CAAC;AAC3E,CAAC;AAED,eAAehE,kBAAkB","ignoreList":[]}
|
|
@@ -10,8 +10,7 @@ import { BottomSheet, withSpokenMessages } from '@wordpress/components';
|
|
|
10
10
|
import screens from './modal-screens/screens';
|
|
11
11
|
import LinkSettingsScreen from './modal-screens/link-settings-screen';
|
|
12
12
|
import LinkPickerScreen from './modal-screens/link-picker-screen';
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
14
|
const ModalLinkUI = ({
|
|
16
15
|
isVisible,
|
|
17
16
|
...restProps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","BottomSheet","withSpokenMessages","screens","LinkSettingsScreen","LinkPickerScreen","jsx","_jsx","jsxs","_jsxs","ModalLinkUI","isVisible","restProps","hideHeader","onClose","hasNavigation","testID","children","NavigationContainer","animate","main","NavigationScreen","name","settings","picker","isScrollable","fullScreen"],"sources":["@wordpress/format-library/src/link/modal.native.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { BottomSheet, withSpokenMessages } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport screens from './modal-screens/screens';\nimport LinkSettingsScreen from './modal-screens/link-settings-screen';\nimport LinkPickerScreen from './modal-screens/link-picker-screen';\n\nconst ModalLinkUI = ( { isVisible, ...restProps } ) => {\n\treturn useMemo( () => {\n\t\treturn (\n\t\t\t<BottomSheet\n\t\t\t\tisVisible={ isVisible }\n\t\t\t\thideHeader\n\t\t\t\tonClose={ restProps.onClose }\n\t\t\t\thasNavigation\n\t\t\t\ttestID=\"link-settings-modal\"\n\t\t\t>\n\t\t\t\t<BottomSheet.NavigationContainer animate main>\n\t\t\t\t\t<BottomSheet.NavigationScreen name={ screens.settings }>\n\t\t\t\t\t\t<LinkSettingsScreen\n\t\t\t\t\t\t\tisVisible={ isVisible }\n\t\t\t\t\t\t\t{ ...restProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t\t<BottomSheet.NavigationScreen\n\t\t\t\t\t\tname={ screens.picker }\n\t\t\t\t\t\tisScrollable\n\t\t\t\t\t\tfullScreen\n\t\t\t\t\t>\n\t\t\t\t\t\t<LinkPickerScreen />\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t</BottomSheet.NavigationContainer>\n\t\t\t</BottomSheet>\n\t\t);\n\t}, [ isVisible ] );\n};\n\nexport default withSpokenMessages( ModalLinkUI );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,WAAW,EAAEC,kBAAkB,QAAQ,uBAAuB;;AAEvE;AACA;AACA;AACA,OAAOC,OAAO,MAAM,yBAAyB;AAC7C,OAAOC,kBAAkB,MAAM,sCAAsC;AACrE,OAAOC,gBAAgB,MAAM,oCAAoC;AAAC,SAAAC,GAAA,IAAAC,IAAA
|
|
1
|
+
{"version":3,"names":["useMemo","BottomSheet","withSpokenMessages","screens","LinkSettingsScreen","LinkPickerScreen","jsx","_jsx","jsxs","_jsxs","ModalLinkUI","isVisible","restProps","hideHeader","onClose","hasNavigation","testID","children","NavigationContainer","animate","main","NavigationScreen","name","settings","picker","isScrollable","fullScreen"],"sources":["@wordpress/format-library/src/link/modal.native.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { BottomSheet, withSpokenMessages } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport screens from './modal-screens/screens';\nimport LinkSettingsScreen from './modal-screens/link-settings-screen';\nimport LinkPickerScreen from './modal-screens/link-picker-screen';\n\nconst ModalLinkUI = ( { isVisible, ...restProps } ) => {\n\treturn useMemo( () => {\n\t\treturn (\n\t\t\t<BottomSheet\n\t\t\t\tisVisible={ isVisible }\n\t\t\t\thideHeader\n\t\t\t\tonClose={ restProps.onClose }\n\t\t\t\thasNavigation\n\t\t\t\ttestID=\"link-settings-modal\"\n\t\t\t>\n\t\t\t\t<BottomSheet.NavigationContainer animate main>\n\t\t\t\t\t<BottomSheet.NavigationScreen name={ screens.settings }>\n\t\t\t\t\t\t<LinkSettingsScreen\n\t\t\t\t\t\t\tisVisible={ isVisible }\n\t\t\t\t\t\t\t{ ...restProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t\t<BottomSheet.NavigationScreen\n\t\t\t\t\t\tname={ screens.picker }\n\t\t\t\t\t\tisScrollable\n\t\t\t\t\t\tfullScreen\n\t\t\t\t\t>\n\t\t\t\t\t\t<LinkPickerScreen />\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t</BottomSheet.NavigationContainer>\n\t\t\t</BottomSheet>\n\t\t);\n\t}, [ isVisible ] );\n};\n\nexport default withSpokenMessages( ModalLinkUI );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,WAAW,EAAEC,kBAAkB,QAAQ,uBAAuB;;AAEvE;AACA;AACA;AACA,OAAOC,OAAO,MAAM,yBAAyB;AAC7C,OAAOC,kBAAkB,MAAM,sCAAsC;AACrE,OAAOC,gBAAgB,MAAM,oCAAoC;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAElE,MAAMC,WAAW,GAAGA,CAAE;EAAEC,SAAS;EAAE,GAAGC;AAAU,CAAC,KAAM;EACtD,OAAOZ,OAAO,CAAE,MAAM;IACrB,oBACCO,IAAA,CAACN,WAAW;MACXU,SAAS,EAAGA,SAAW;MACvBE,UAAU;MACVC,OAAO,EAAGF,SAAS,CAACE,OAAS;MAC7BC,aAAa;MACbC,MAAM,EAAC,qBAAqB;MAAAC,QAAA,eAE5BR,KAAA,CAACR,WAAW,CAACiB,mBAAmB;QAACC,OAAO;QAACC,IAAI;QAAAH,QAAA,gBAC5CV,IAAA,CAACN,WAAW,CAACoB,gBAAgB;UAACC,IAAI,EAAGnB,OAAO,CAACoB,QAAU;UAAAN,QAAA,eACtDV,IAAA,CAACH,kBAAkB;YAClBO,SAAS,EAAGA,SAAW;YAAA,GAClBC;UAAS,CACd;QAAC,CAC2B,CAAC,eAC/BL,IAAA,CAACN,WAAW,CAACoB,gBAAgB;UAC5BC,IAAI,EAAGnB,OAAO,CAACqB,MAAQ;UACvBC,YAAY;UACZC,UAAU;UAAAT,QAAA,eAEVV,IAAA,CAACF,gBAAgB,IAAE;QAAC,CACS,CAAC;MAAA,CACC;IAAC,CACtB,CAAC;EAEhB,CAAC,EAAE,CAAEM,SAAS,CAAG,CAAC;AACnB,CAAC;AAED,eAAeT,kBAAkB,CAAEQ,WAAY,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["weakMap","WeakMap","id","prefix","getKey","_id","useLinkInstanceKey","instance","has","get","set"],"sources":["@wordpress/format-library/src/link/use-link-instance-key.js"],"sourcesContent":["// Weakly referenced map allows unused ids to be garbage collected.\nconst weakMap = new WeakMap();\n\n// Incrementing zero-based ID value.\nlet id = -1;\n\nconst prefix = 'link-control-instance';\n\nfunction getKey( _id ) {\n\treturn `${ prefix }-${ _id }`;\n}\n\n/**\n * Builds a unique link control key for the given object reference.\n *\n * @param {Object} instance an unique object reference specific to this link control instance.\n * @return {string | undefined} the unique key to use for this link control.\n */\nfunction useLinkInstanceKey( instance ) {\n\tif ( ! instance ) {\n\t\treturn;\n\t}\n\tif ( weakMap.has( instance ) ) {\n\t\treturn getKey( weakMap.get( instance ) );\n\t}\n\n\tid += 1;\n\n\tweakMap.set( instance, id );\n\n\treturn getKey( id );\n}\n\nexport default useLinkInstanceKey;\n"],"mappings":"AAAA;AACA,MAAMA,OAAO,GAAG,IAAIC,OAAO,CAAC,CAAC;;AAE7B;AACA,IAAIC,EAAE,GAAG,CAAC,CAAC;AAEX,MAAMC,MAAM,GAAG,uBAAuB;AAEtC,SAASC,MAAMA,CAAEC,GAAG,EAAG;EACtB,
|
|
1
|
+
{"version":3,"names":["weakMap","WeakMap","id","prefix","getKey","_id","useLinkInstanceKey","instance","has","get","set"],"sources":["@wordpress/format-library/src/link/use-link-instance-key.js"],"sourcesContent":["// Weakly referenced map allows unused ids to be garbage collected.\nconst weakMap = new WeakMap();\n\n// Incrementing zero-based ID value.\nlet id = -1;\n\nconst prefix = 'link-control-instance';\n\nfunction getKey( _id ) {\n\treturn `${ prefix }-${ _id }`;\n}\n\n/**\n * Builds a unique link control key for the given object reference.\n *\n * @param {Object} instance an unique object reference specific to this link control instance.\n * @return {string | undefined} the unique key to use for this link control.\n */\nfunction useLinkInstanceKey( instance ) {\n\tif ( ! instance ) {\n\t\treturn;\n\t}\n\tif ( weakMap.has( instance ) ) {\n\t\treturn getKey( weakMap.get( instance ) );\n\t}\n\n\tid += 1;\n\n\tweakMap.set( instance, id );\n\n\treturn getKey( id );\n}\n\nexport default useLinkInstanceKey;\n"],"mappings":"AAAA;AACA,MAAMA,OAAO,GAAG,IAAIC,OAAO,CAAC,CAAC;;AAE7B;AACA,IAAIC,EAAE,GAAG,CAAC,CAAC;AAEX,MAAMC,MAAM,GAAG,uBAAuB;AAEtC,SAASC,MAAMA,CAAEC,GAAG,EAAG;EACtB,OAAO,GAAIF,MAAM,IAAME,GAAG,EAAG;AAC9B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,kBAAkBA,CAAEC,QAAQ,EAAG;EACvC,IAAK,CAAEA,QAAQ,EAAG;IACjB;EACD;EACA,IAAKP,OAAO,CAACQ,GAAG,CAAED,QAAS,CAAC,EAAG;IAC9B,OAAOH,MAAM,CAAEJ,OAAO,CAACS,GAAG,CAAEF,QAAS,CAAE,CAAC;EACzC;EAEAL,EAAE,IAAI,CAAC;EAEPF,OAAO,CAACU,GAAG,CAAEH,QAAQ,EAAEL,EAAG,CAAC;EAE3B,OAAOE,MAAM,CAAEF,EAAG,CAAC;AACpB;AAEA,eAAeI,kBAAkB","ignoreList":[]}
|
|
@@ -5,9 +5,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
5
5
|
import { toggleFormat } from '@wordpress/rich-text';
|
|
6
6
|
import { RichTextToolbarButton, RichTextShortcut } from '@wordpress/block-editor';
|
|
7
7
|
import { formatStrikethrough } from '@wordpress/icons';
|
|
8
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
9
|
const name = 'core/strikethrough';
|
|
12
10
|
const title = __('Strikethrough');
|
|
13
11
|
export const strikethrough = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","toggleFormat","RichTextToolbarButton","RichTextShortcut","formatStrikethrough","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","name","title","strikethrough","tagName","className","edit","isActive","value","onChange","onFocus","onClick","type","children","character","onUse","icon","role"],"sources":["@wordpress/format-library/src/strikethrough/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n} from '@wordpress/block-editor';\nimport { formatStrikethrough } from '@wordpress/icons';\n\nconst name = 'core/strikethrough';\nconst title = __( 'Strikethrough' );\n\nexport const strikethrough = {\n\tname,\n\ttitle,\n\ttagName: 's',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onClick() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"access\"\n\t\t\t\t\tcharacter=\"d\"\n\t\t\t\t\tonUse={ onClick }\n\t\t\t\t/>\n\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\ticon={ formatStrikethrough }\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\trole=\"menuitemcheckbox\"\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SACCC,qBAAqB,EACrBC,gBAAgB,QACV,yBAAyB;AAChC,SAASC,mBAAmB,QAAQ,kBAAkB;AAAC,SAAAC,GAAA,IAAAC,IAAA
|
|
1
|
+
{"version":3,"names":["__","toggleFormat","RichTextToolbarButton","RichTextShortcut","formatStrikethrough","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","name","title","strikethrough","tagName","className","edit","isActive","value","onChange","onFocus","onClick","type","children","character","onUse","icon","role"],"sources":["@wordpress/format-library/src/strikethrough/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n} from '@wordpress/block-editor';\nimport { formatStrikethrough } from '@wordpress/icons';\n\nconst name = 'core/strikethrough';\nconst title = __( 'Strikethrough' );\n\nexport const strikethrough = {\n\tname,\n\ttitle,\n\ttagName: 's',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onClick() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"access\"\n\t\t\t\t\tcharacter=\"d\"\n\t\t\t\t\tonUse={ onClick }\n\t\t\t\t/>\n\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\ticon={ formatStrikethrough }\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\trole=\"menuitemcheckbox\"\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SACCC,qBAAqB,EACrBC,gBAAgB,QACV,yBAAyB;AAChC,SAASC,mBAAmB,QAAQ,kBAAkB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAEvD,MAAMC,IAAI,GAAG,oBAAoB;AACjC,MAAMC,KAAK,GAAGZ,EAAE,CAAE,eAAgB,CAAC;AAEnC,OAAO,MAAMa,aAAa,GAAG;EAC5BF,IAAI;EACJC,KAAK;EACLE,OAAO,EAAE,GAAG;EACZC,SAAS,EAAE,IAAI;EACfC,IAAIA,CAAE;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,QAAQ;IAAEC;EAAQ,CAAC,EAAG;IAC9C,SAASC,OAAOA,CAAA,EAAG;MAClBF,QAAQ,CAAElB,YAAY,CAAEiB,KAAK,EAAE;QAAEI,IAAI,EAAEX,IAAI;QAAEC;MAAM,CAAE,CAAE,CAAC;MACxDQ,OAAO,CAAC,CAAC;IACV;IAEA,oBACCV,KAAA,CAAAF,SAAA;MAAAe,QAAA,gBACCjB,IAAA,CAACH,gBAAgB;QAChBmB,IAAI,EAAC,QAAQ;QACbE,SAAS,EAAC,GAAG;QACbC,KAAK,EAAGJ;MAAS,CACjB,CAAC,eACFf,IAAA,CAACJ,qBAAqB;QACrBwB,IAAI,EAAGtB,mBAAqB;QAC5BQ,KAAK,EAAGA,KAAO;QACfS,OAAO,EAAGA,OAAS;QACnBJ,QAAQ,EAAGA,QAAU;QACrBU,IAAI,EAAC;MAAkB,CACvB,CAAC;IAAA,CACD,CAAC;EAEL;AACD,CAAC","ignoreList":[]}
|
|
@@ -11,9 +11,7 @@ import { removeFormat } from '@wordpress/rich-text';
|
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
13
|
import { default as InlineColorUI, getActiveColors } from './inline';
|
|
14
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
16
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
15
|
export const transparentValue = 'rgba(0, 0, 0, 0)';
|
|
18
16
|
const name = 'core/text-color';
|
|
19
17
|
const title = __('Highlight');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","useMemo","useState","RichTextToolbarButton","useSettings","Icon","color","colorIcon","textColor","textColorIcon","removeFormat","default","InlineColorUI","getActiveColors","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","transparentValue","name","title","EMPTY_ARRAY","getComputedStyleProperty","element","property","ownerDocument","defaultView","style","getComputedStyle","value","getPropertyValue","parentElement","fillComputedColors","backgroundColor","TextColorEdit","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","colorIndicatorStyle","current","hasColorsToChoose","length","children","className","icon","Object","keys","onClick","role","onClose","tagName","attributes","class","edit"],"sources":["@wordpress/format-library/src/text-color/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { RichTextToolbarButton, useSettings } from '@wordpress/block-editor';\nimport {\n\tIcon,\n\tcolor as colorIcon,\n\ttextColor as textColorIcon,\n} from '@wordpress/icons';\nimport { removeFormat } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { default as InlineColorUI, getActiveColors } from './inline';\n\nexport const transparentValue = 'rgba(0, 0, 0, 0)';\n\nconst name = 'core/text-color';\nconst title = __( 'Highlight' );\n\nconst EMPTY_ARRAY = [];\n\nfunction getComputedStyleProperty( element, property ) {\n\tconst { ownerDocument } = element;\n\tconst { defaultView } = ownerDocument;\n\tconst style = defaultView.getComputedStyle( element );\n\tconst value = style.getPropertyValue( property );\n\n\tif (\n\t\tproperty === 'background-color' &&\n\t\tvalue === transparentValue &&\n\t\telement.parentElement\n\t) {\n\t\treturn getComputedStyleProperty( element.parentElement, property );\n\t}\n\n\treturn value;\n}\n\nfunction fillComputedColors( element, { color, backgroundColor } ) {\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tcolor: color || getComputedStyleProperty( element, 'color' ),\n\t\tbackgroundColor:\n\t\t\tbackgroundColor === transparentValue\n\t\t\t\t? getComputedStyleProperty( element, 'background-color' )\n\t\t\t\t: backgroundColor,\n\t};\n}\n\nfunction TextColorEdit( {\n\tvalue,\n\tonChange,\n\tisActive,\n\tactiveAttributes,\n\tcontentRef,\n} ) {\n\tconst [ allowCustomControl, colors = EMPTY_ARRAY ] = useSettings(\n\t\t'color.custom',\n\t\t'color.palette'\n\t);\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\n\tconst colorIndicatorStyle = useMemo(\n\t\t() =>\n\t\t\tfillComputedColors(\n\t\t\t\tcontentRef.current,\n\t\t\t\tgetActiveColors( value, name, colors )\n\t\t\t),\n\t\t[ contentRef, value, colors ]\n\t);\n\n\tconst hasColorsToChoose = colors.length || ! allowCustomControl;\n\tif ( ! hasColorsToChoose && ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<RichTextToolbarButton\n\t\t\t\tclassName=\"format-library-text-color-button\"\n\t\t\t\tisActive={ isActive }\n\t\t\t\ticon={\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\tObject.keys( activeAttributes ).length\n\t\t\t\t\t\t\t\t? textColorIcon\n\t\t\t\t\t\t\t\t: colorIcon\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstyle={ colorIndicatorStyle }\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\ttitle={ title }\n\t\t\t\t// If has no colors to choose but a color is active remove the color onClick.\n\t\t\t\tonClick={\n\t\t\t\t\thasColorsToChoose\n\t\t\t\t\t\t? () => setIsAddingColor( true )\n\t\t\t\t\t\t: () => onChange( removeFormat( value, name ) )\n\t\t\t\t}\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t\t{ isAddingColor && (\n\t\t\t\t<InlineColorUI\n\t\t\t\t\tname={ name }\n\t\t\t\t\tonClose={ () => setIsAddingColor( false ) }\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\tisActive={ isActive }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const textColor = {\n\tname,\n\ttitle,\n\ttagName: 'mark',\n\tclassName: 'has-inline-color',\n\tattributes: {\n\t\tstyle: 'style',\n\t\tclass: 'class',\n\t},\n\tedit: TextColorEdit,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,qBAAqB,EAAEC,WAAW,QAAQ,yBAAyB;AAC5E,SACCC,IAAI,EACJC,KAAK,IAAIC,SAAS,EAClBC,SAAS,IAAIC,aAAa,QACpB,kBAAkB;AACzB,SAASC,YAAY,QAAQ,sBAAsB;;AAEnD;AACA;AACA;AACA,SAASC,OAAO,IAAIC,aAAa,EAAEC,eAAe,QAAQ,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA
|
|
1
|
+
{"version":3,"names":["__","useMemo","useState","RichTextToolbarButton","useSettings","Icon","color","colorIcon","textColor","textColorIcon","removeFormat","default","InlineColorUI","getActiveColors","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","transparentValue","name","title","EMPTY_ARRAY","getComputedStyleProperty","element","property","ownerDocument","defaultView","style","getComputedStyle","value","getPropertyValue","parentElement","fillComputedColors","backgroundColor","TextColorEdit","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","colorIndicatorStyle","current","hasColorsToChoose","length","children","className","icon","Object","keys","onClick","role","onClose","tagName","attributes","class","edit"],"sources":["@wordpress/format-library/src/text-color/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { RichTextToolbarButton, useSettings } from '@wordpress/block-editor';\nimport {\n\tIcon,\n\tcolor as colorIcon,\n\ttextColor as textColorIcon,\n} from '@wordpress/icons';\nimport { removeFormat } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { default as InlineColorUI, getActiveColors } from './inline';\n\nexport const transparentValue = 'rgba(0, 0, 0, 0)';\n\nconst name = 'core/text-color';\nconst title = __( 'Highlight' );\n\nconst EMPTY_ARRAY = [];\n\nfunction getComputedStyleProperty( element, property ) {\n\tconst { ownerDocument } = element;\n\tconst { defaultView } = ownerDocument;\n\tconst style = defaultView.getComputedStyle( element );\n\tconst value = style.getPropertyValue( property );\n\n\tif (\n\t\tproperty === 'background-color' &&\n\t\tvalue === transparentValue &&\n\t\telement.parentElement\n\t) {\n\t\treturn getComputedStyleProperty( element.parentElement, property );\n\t}\n\n\treturn value;\n}\n\nfunction fillComputedColors( element, { color, backgroundColor } ) {\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tcolor: color || getComputedStyleProperty( element, 'color' ),\n\t\tbackgroundColor:\n\t\t\tbackgroundColor === transparentValue\n\t\t\t\t? getComputedStyleProperty( element, 'background-color' )\n\t\t\t\t: backgroundColor,\n\t};\n}\n\nfunction TextColorEdit( {\n\tvalue,\n\tonChange,\n\tisActive,\n\tactiveAttributes,\n\tcontentRef,\n} ) {\n\tconst [ allowCustomControl, colors = EMPTY_ARRAY ] = useSettings(\n\t\t'color.custom',\n\t\t'color.palette'\n\t);\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\n\tconst colorIndicatorStyle = useMemo(\n\t\t() =>\n\t\t\tfillComputedColors(\n\t\t\t\tcontentRef.current,\n\t\t\t\tgetActiveColors( value, name, colors )\n\t\t\t),\n\t\t[ contentRef, value, colors ]\n\t);\n\n\tconst hasColorsToChoose = colors.length || ! allowCustomControl;\n\tif ( ! hasColorsToChoose && ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<RichTextToolbarButton\n\t\t\t\tclassName=\"format-library-text-color-button\"\n\t\t\t\tisActive={ isActive }\n\t\t\t\ticon={\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\tObject.keys( activeAttributes ).length\n\t\t\t\t\t\t\t\t? textColorIcon\n\t\t\t\t\t\t\t\t: colorIcon\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstyle={ colorIndicatorStyle }\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\ttitle={ title }\n\t\t\t\t// If has no colors to choose but a color is active remove the color onClick.\n\t\t\t\tonClick={\n\t\t\t\t\thasColorsToChoose\n\t\t\t\t\t\t? () => setIsAddingColor( true )\n\t\t\t\t\t\t: () => onChange( removeFormat( value, name ) )\n\t\t\t\t}\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t\t{ isAddingColor && (\n\t\t\t\t<InlineColorUI\n\t\t\t\t\tname={ name }\n\t\t\t\t\tonClose={ () => setIsAddingColor( false ) }\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\tisActive={ isActive }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const textColor = {\n\tname,\n\ttitle,\n\ttagName: 'mark',\n\tclassName: 'has-inline-color',\n\tattributes: {\n\t\tstyle: 'style',\n\t\tclass: 'class',\n\t},\n\tedit: TextColorEdit,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,qBAAqB,EAAEC,WAAW,QAAQ,yBAAyB;AAC5E,SACCC,IAAI,EACJC,KAAK,IAAIC,SAAS,EAClBC,SAAS,IAAIC,aAAa,QACpB,kBAAkB;AACz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AAG;MAC3CL,gBAAgB,EAAGA,gBAAkB;MACrCR,KAAK,EAAGA,KAAO;MACfM,QAAQ,EAAGA,QAAU;MACrBG,UAAU,EAAGA,UAAY;MACzBF,QAAQ,EAAGA;IAAU,CACrB,CACD;EAAA,CACA,CAAC;AAEL;AAEA,OAAO,MAAM9B,SAAS,GAAG;EACxBa,IAAI;EACJC,KAAK;EACLmC,OAAO,EAAE,MAAM;EACfP,SAAS,EAAE,kBAAkB;EAC7BQ,UAAU,EAAE;IACX7B,KAAK,EAAE,OAAO;IACd8B,KAAK,EAAE;EACR,CAAC;EACDC,IAAI,EAAExB;AACP,CAAC","ignoreList":[]}
|
|
@@ -20,9 +20,7 @@ import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
|
20
20
|
import { getActiveColors } from './inline.native.js';
|
|
21
21
|
import { default as InlineColorUI } from './inline';
|
|
22
22
|
import styles from './style.scss';
|
|
23
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
23
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
26
24
|
const name = 'core/text-color';
|
|
27
25
|
const title = __('Text color');
|
|
28
26
|
function getComputedStyleProperty(element, property) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["StyleSheet","View","__","useMemo","useState","BlockControls","useSettings","useMobileGlobalStylesColors","ToolbarGroup","ToolbarButton","Icon","color","colorIcon","textColor","textColorIcon","removeFormat","usePreferredColorSchemeStyle","getActiveColors","default","InlineColorUI","styles","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","name","title","getComputedStyleProperty","element","property","_element$props$style","style","props","backgroundColor","baseColors","background","fillComputedColors","TextColorEdit","value","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","colorIndicatorStyle","hasColorsToChoose","length","outlineStyle","borderWidth","hairlineWidth","isActiveStyle","customContainerStyles","children","pointerEvents","icon","Object","keys","extraProps","onClick","onClose","tagName","className","attributes","class","edit"],"sources":["@wordpress/format-library/src/text-color/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { StyleSheet, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tuseSettings,\n\tuseMobileGlobalStylesColors,\n} from '@wordpress/block-editor';\nimport { ToolbarGroup, ToolbarButton } from '@wordpress/components';\nimport {\n\tIcon,\n\tcolor as colorIcon,\n\ttextColor as textColorIcon,\n} from '@wordpress/icons';\nimport { removeFormat } from '@wordpress/rich-text';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getActiveColors } from './inline.native.js';\nimport { default as InlineColorUI } from './inline';\nimport styles from './style.scss';\n\nconst name = 'core/text-color';\nconst title = __( 'Text color' );\n\nfunction getComputedStyleProperty( element, property ) {\n\tconst style = element?.props?.style ?? {};\n\n\tif ( property === 'background-color' ) {\n\t\tconst { backgroundColor, baseColors } = style;\n\n\t\tif ( backgroundColor !== 'transparent' ) {\n\t\t\treturn backgroundColor;\n\t\t} else if ( baseColors && baseColors?.color?.background ) {\n\t\t\treturn baseColors?.color?.background;\n\t\t}\n\n\t\treturn 'transparent';\n\t}\n}\n\nfunction fillComputedColors( element, { color, backgroundColor } ) {\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tcolor: color || getComputedStyleProperty( element, 'color' ),\n\t\tbackgroundColor: getComputedStyleProperty(\n\t\t\telement,\n\t\t\t'background-color'\n\t\t),\n\t};\n}\n\nfunction TextColorEdit( {\n\tvalue,\n\tonChange,\n\tisActive,\n\tactiveAttributes,\n\tcontentRef,\n} ) {\n\tconst [ allowCustomControl ] = useSettings( 'color.custom' );\n\tconst colors = useMobileGlobalStylesColors();\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\n\tconst colorIndicatorStyle = useMemo(\n\t\t() =>\n\t\t\tfillComputedColors(\n\t\t\t\tcontentRef,\n\t\t\t\tgetActiveColors( value, name, colors )\n\t\t\t),\n\t\t[ contentRef, value, colors ]\n\t);\n\n\tconst hasColorsToChoose = colors.length || ! allowCustomControl;\n\n\tconst outlineStyle = [\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-inline-color__outline' ],\n\t\t\tstyles[ 'components-inline-color__outline--dark' ]\n\t\t),\n\t\t{ borderWidth: StyleSheet.hairlineWidth },\n\t];\n\n\tif ( ! hasColorsToChoose && ! isActive ) {\n\t\treturn null;\n\t}\n\n\tconst isActiveStyle = {\n\t\t...colorIndicatorStyle,\n\t\t...( ! colorIndicatorStyle?.backgroundColor\n\t\t\t? { backgroundColor: 'transparent' }\n\t\t\t: {} ),\n\t\t...styles[ 'components-inline-color--is-active' ],\n\t};\n\n\tconst customContainerStyles =\n\t\tstyles[ 'components-inline-color__button-container' ];\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ isActive && (\n\t\t\t\t\t\t<View style={ outlineStyle } pointerEvents=\"none\" />\n\t\t\t\t\t) }\n\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"text-color\"\n\t\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\tObject.keys( activeAttributes ).length\n\t\t\t\t\t\t\t\t\t\t? textColorIcon\n\t\t\t\t\t\t\t\t\t\t: colorIcon\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\tcolorIndicatorStyle?.color && {\n\t\t\t\t\t\t\t\t\t\tcolor: colorIndicatorStyle.color,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\textraProps={ {\n\t\t\t\t\t\t\tisActiveStyle,\n\t\t\t\t\t\t\tcustomContainerStyles,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\t// If has no colors to choose but a color is active remove the color onClick\n\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\thasColorsToChoose\n\t\t\t\t\t\t\t\t? () => setIsAddingColor( true )\n\t\t\t\t\t\t\t\t: () => onChange( removeFormat( value, name ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ isAddingColor && (\n\t\t\t\t<InlineColorUI\n\t\t\t\t\tname={ name }\n\t\t\t\t\tonClose={ () => setIsAddingColor( false ) }\n\t\t\t\t\tactiveAttributes={ activeAttributes }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const textColor = {\n\tname,\n\ttitle,\n\ttagName: 'mark',\n\tclassName: 'has-inline-color',\n\tattributes: {\n\t\tstyle: 'style',\n\t\tclass: 'class',\n\t},\n\tedit: TextColorEdit,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,IAAI,QAAQ,cAAc;;AAE/C;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SACCC,aAAa,EACbC,WAAW,EACXC,2BAA2B,QACrB,yBAAyB;AAChC,SAASC,YAAY,EAAEC,aAAa,QAAQ,uBAAuB;AACnE,SACCC,IAAI,EACJC,KAAK,IAAIC,SAAS,EAClBC,SAAS,IAAIC,aAAa,QACpB,kBAAkB;AACzB,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,4BAA4B,QAAQ,oBAAoB;;AAEjE;AACA;AACA;AACA,SAASC,eAAe,QAAQ,oBAAoB;AACpD,SAASC,OAAO,IAAIC,aAAa,QAAQ,UAAU;AACnD,OAAOC,MAAM,MAAM,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA
|
|
1
|
+
{"version":3,"names":["StyleSheet","View","__","useMemo","useState","BlockControls","useSettings","useMobileGlobalStylesColors","ToolbarGroup","ToolbarButton","Icon","color","colorIcon","textColor","textColorIcon","removeFormat","usePreferredColorSchemeStyle","getActiveColors","default","InlineColorUI","styles","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","name","title","getComputedStyleProperty","element","property","_element$props$style","style","props","backgroundColor","baseColors","background","fillComputedColors","TextColorEdit","value","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","colorIndicatorStyle","hasColorsToChoose","length","outlineStyle","borderWidth","hairlineWidth","isActiveStyle","customContainerStyles","children","pointerEvents","icon","Object","keys","extraProps","onClick","onClose","tagName","className","attributes","class","edit"],"sources":["@wordpress/format-library/src/text-color/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { StyleSheet, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tuseSettings,\n\tuseMobileGlobalStylesColors,\n} from '@wordpress/block-editor';\nimport { ToolbarGroup, ToolbarButton } from '@wordpress/components';\nimport {\n\tIcon,\n\tcolor as colorIcon,\n\ttextColor as textColorIcon,\n} from '@wordpress/icons';\nimport { removeFormat } from '@wordpress/rich-text';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getActiveColors } from './inline.native.js';\nimport { default as InlineColorUI } from './inline';\nimport styles from './style.scss';\n\nconst name = 'core/text-color';\nconst title = __( 'Text color' );\n\nfunction getComputedStyleProperty( element, property ) {\n\tconst style = element?.props?.style ?? {};\n\n\tif ( property === 'background-color' ) {\n\t\tconst { backgroundColor, baseColors } = style;\n\n\t\tif ( backgroundColor !== 'transparent' ) {\n\t\t\treturn backgroundColor;\n\t\t} else if ( baseColors && baseColors?.color?.background ) {\n\t\t\treturn baseColors?.color?.background;\n\t\t}\n\n\t\treturn 'transparent';\n\t}\n}\n\nfunction fillComputedColors( element, { color, backgroundColor } ) {\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tcolor: color || getComputedStyleProperty( element, 'color' ),\n\t\tbackgroundColor: getComputedStyleProperty(\n\t\t\telement,\n\t\t\t'background-color'\n\t\t),\n\t};\n}\n\nfunction TextColorEdit( {\n\tvalue,\n\tonChange,\n\tisActive,\n\tactiveAttributes,\n\tcontentRef,\n} ) {\n\tconst [ allowCustomControl ] = useSettings( 'color.custom' );\n\tconst colors = useMobileGlobalStylesColors();\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\n\tconst colorIndicatorStyle = useMemo(\n\t\t() =>\n\t\t\tfillComputedColors(\n\t\t\t\tcontentRef,\n\t\t\t\tgetActiveColors( value, name, colors )\n\t\t\t),\n\t\t[ contentRef, value, colors ]\n\t);\n\n\tconst hasColorsToChoose = colors.length || ! allowCustomControl;\n\n\tconst outlineStyle = [\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-inline-color__outline' ],\n\t\t\tstyles[ 'components-inline-color__outline--dark' ]\n\t\t),\n\t\t{ borderWidth: StyleSheet.hairlineWidth },\n\t];\n\n\tif ( ! hasColorsToChoose && ! isActive ) {\n\t\treturn null;\n\t}\n\n\tconst isActiveStyle = {\n\t\t...colorIndicatorStyle,\n\t\t...( ! colorIndicatorStyle?.backgroundColor\n\t\t\t? { backgroundColor: 'transparent' }\n\t\t\t: {} ),\n\t\t...styles[ 'components-inline-color--is-active' ],\n\t};\n\n\tconst customContainerStyles =\n\t\tstyles[ 'components-inline-color__button-container' ];\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ isActive && (\n\t\t\t\t\t\t<View style={ outlineStyle } pointerEvents=\"none\" />\n\t\t\t\t\t) }\n\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"text-color\"\n\t\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\tObject.keys( activeAttributes ).length\n\t\t\t\t\t\t\t\t\t\t? textColorIcon\n\t\t\t\t\t\t\t\t\t\t: colorIcon\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\tcolorIndicatorStyle?.color && {\n\t\t\t\t\t\t\t\t\t\tcolor: colorIndicatorStyle.color,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\textraProps={ {\n\t\t\t\t\t\t\tisActiveStyle,\n\t\t\t\t\t\t\tcustomContainerStyles,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\t// If has no colors to choose but a color is active remove the color onClick\n\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\thasColorsToChoose\n\t\t\t\t\t\t\t\t? () => setIsAddingColor( true )\n\t\t\t\t\t\t\t\t: () => onChange( removeFormat( value, name ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ isAddingColor && (\n\t\t\t\t<InlineColorUI\n\t\t\t\t\tname={ name }\n\t\t\t\t\tonClose={ () => setIsAddingColor( false ) }\n\t\t\t\t\tactiveAttributes={ activeAttributes }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const textColor = {\n\tname,\n\ttitle,\n\ttagName: 'mark',\n\tclassName: 'has-inline-color',\n\tattributes: {\n\t\tstyle: 'style',\n\t\tclass: 'class',\n\t},\n\tedit: TextColorEdit,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,IAAI,QAAQ,cAAc;;AAE/C;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SACCC,aAAa,EACbC,WAAW,EACXC,2BAA2B,QACrB,yBAAyB;AAChC,SAASC,YAAY,EAAEC,aAAa,QAAQ,uBAAuB;AACnE,SACCC,IAAI,EACJC,KAAK,IAAIC,SAAS,EAClBC,SAAS,IAAIC,aAAa,QACpB,kBAAkB;AACzB,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,4BAA4B,QAAQ,oBAAoB;;AAEjE;AACA;AACA;AACA,SAASC,eAAe,QAAQ,oBAAoB;AACpD,SAASC,OAAO,IAAIC,aAAa,QAAQ,UAAU;AACnD,OAAOC,MAAM,MAAM,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAElC,MAAMC,IAAI,GAAG,iBAAiB;AAC9B,MAAMC,KAAK,GAAG1B,EAAE,CAAE,YAAa,CAAC;AAEhC,SAAS2B,wBAAwBA,CAAEC,OAAO,EAAEC,QAAQ,EAAG;EAAA,IAAAC,oBAAA;EACtD,MAAMC,KAAK,IAAAD,oBAAA,GAAGF,OAAO,EAAEI,KAAK,EAAED,KAAK,cAAAD,oBAAA,cAAAA,oBAAA,GAAI,CAAC,CAAC;EAEzC,IAAKD,QAAQ,KAAK,kBAAkB,EAAG;IACtC,MAAM;MAAEI,eAAe;MAAEC;IAAW,CAAC,GAAGH,KAAK;IAE7C,IAAKE,eAAe,KAAK,aAA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OAAO,EAAGA,CAAA,KAAMhB,gBAAgB,CAAE,KAAM,CAAG;MAC3CL,gBAAgB,EAAGA,gBAAkB;MACrCH,KAAK,EAAGA,KAAO;MACfC,QAAQ,EAAGA,QAAU;MACrBG,UAAU,EAAGA;IAAY,CACzB,CACD;EAAA,CACA,CAAC;AAEL;AAEA,OAAO,MAAM/B,SAAS,GAAG;EACxBc,IAAI;EACJC,KAAK;EACLqC,OAAO,EAAE,MAAM;EACfC,SAAS,EAAE,kBAAkB;EAC7BC,UAAU,EAAE;IACXlC,KAAK,EAAE,OAAO;IACdmC,KAAK,EAAE;EACR,CAAC;EACDC,IAAI,EAAE9B;AACP,CAAC","ignoreList":[]}
|
|
@@ -13,8 +13,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
13
13
|
*/
|
|
14
14
|
import { textColor as settings, transparentValue } from './index';
|
|
15
15
|
import { unlock } from '../lock-unlock';
|
|
16
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
17
|
const {
|
|
19
18
|
Tabs
|
|
20
19
|
} = unlock(componentsPrivateApis);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useSelect","applyFormat","removeFormat","getActiveFormat","useAnchor","ColorPalette","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","store","blockEditorStore","Popover","privateApis","componentsPrivateApis","__","textColor","settings","transparentValue","unlock","jsx","_jsx","jsxs","_jsxs","Tabs","TABS","name","title","parseCSS","css","split","reduce","accumulator","rule","property","value","color","backgroundColor","parseClassName","className","colorSettings","startsWith","endsWith","colorSlug","replace","colorObject","getActiveColors","activeColorFormat","attributes","style","class","setColors","colors","styles","classNames","push","join","slug","length","type","ColorPicker","onChange","select","_getSettings$colors","getSettings","activeColors","InlineColorUI","onClose","contentRef","isActive","popoverAnchor","editableContentElement","current","anchor","children","TabList","map","tab","Tab","tabId","TabPanel","focusable"],"sources":["@wordpress/format-library/src/text-color/inline.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchor,\n} from '@wordpress/rich-text';\nimport {\n\tColorPalette,\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tPopover,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings, transparentValue } from './index';\nimport { unlock } from '../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst TABS = [\n\t{ name: 'color', title: __( 'Text' ) },\n\t{ name: 'backgroundColor', title: __( 'Background' ) },\n];\n\nfunction parseCSS( css = '' ) {\n\treturn css.split( ';' ).reduce( ( accumulator, rule ) => {\n\t\tif ( rule ) {\n\t\t\tconst [ property, value ] = rule.split( ':' );\n\t\t\tif ( property === 'color' ) {\n\t\t\t\taccumulator.color = value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tproperty === 'background-color' &&\n\t\t\t\tvalue !== transparentValue\n\t\t\t) {\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t\t}\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\t// `colorSlug` could contain dashes, so simply match the start and end.\n\t\tif ( name.startsWith( 'has-' ) && name.endsWith( '-color' ) ) {\n\t\t\tconst colorSlug = name\n\t\t\t\t.replace( /^has-/, '' )\n\t\t\t\t.replace( /-color$/, '' );\n\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\tcolorSettings,\n\t\t\t\tcolorSlug\n\t\t\t);\n\t\t\taccumulator.color = colorObject.color;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function getActiveColors( value, name, colorSettings ) {\n\tconst activeColorFormat = getActiveFormat( value, name );\n\n\tif ( ! activeColorFormat ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t...parseCSS( activeColorFormat.attributes.style ),\n\t\t...parseClassName( activeColorFormat.attributes.class, colorSettings ),\n\t};\n}\n\nfunction setColors( value, name, colorSettings, colors ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn removeFormat( value, name );\n\t}\n\n\tconst styles = [];\n\tconst classNames = [];\n\tconst attributes = {};\n\n\tif ( backgroundColor ) {\n\t\tstyles.push( [ 'background-color', backgroundColor ].join( ':' ) );\n\t} else {\n\t\t// Override default browser color for mark element.\n\t\tstyles.push( [ 'background-color', transparentValue ].join( ':' ) );\n\t}\n\n\tif ( color ) {\n\t\tconst colorObject = getColorObjectByColorValue( colorSettings, color );\n\n\t\tif ( colorObject ) {\n\t\t\tclassNames.push( getColorClassName( 'color', colorObject.slug ) );\n\t\t} else {\n\t\t\tstyles.push( [ 'color', color ].join( ':' ) );\n\t\t}\n\t}\n\n\tif ( styles.length ) {\n\t\tattributes.style = styles.join( ';' );\n\t}\n\tif ( classNames.length ) {\n\t\tattributes.class = classNames.join( ' ' );\n\t}\n\n\treturn applyFormat( value, { type: name, attributes } );\n}\n\nfunction ColorPicker( { name, property, value, onChange } ) {\n\tconst colors = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().colors ?? [];\n\t}, [] );\n\tconst activeColors = useMemo(\n\t\t() => getActiveColors( value, name, colors ),\n\t\t[ name, value, colors ]\n\t);\n\n\treturn (\n\t\t<ColorPalette\n\t\t\tvalue={ activeColors[ property ] }\n\t\t\tonChange={ ( color ) => {\n\t\t\t\tonChange(\n\t\t\t\t\tsetColors( value, name, colors, { [ property ]: color } )\n\t\t\t\t);\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n\tisActive,\n} ) {\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings: { ...settings, isActive },\n\t} );\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"format-library__inline-color-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t>\n\t\t\t<Tabs>\n\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t\t<Tabs.Tab tabId={ tab.name } key={ tab.name }>\n\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t) ) }\n\t\t\t\t</Tabs.TabList>\n\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\t\tproperty={ tab.name }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t) ) }\n\t\t\t</Tabs>\n\t\t</Popover>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,WAAW,EACXC,YAAY,EACZC,eAAe,EACfC,SAAS,QACH,sBAAsB;AAC7B,SACCC,YAAY,EACZC,iBAAiB,EACjBC,0BAA0B,EAC1BC,+BAA+B,EAC/BC,KAA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,EACbD,IAAI,CAACmD,GAAG,CAAIC,GAAG,iBAChBxD,IAAA,CAACG,IAAI,CAACwD,QAAQ;QACbD,KAAK,EAAGF,GAAG,CAACnD,IAAM;QAClBuD,SAAS,EAAG,KAAO;QAAAP,QAAA,eAGnBrD,IAAA,CAACuC,WAAW;UACXlC,IAAI,EAAGA,IAAM;UACbQ,QAAQ,EAAG2C,GAAG,CAACnD,IAAM;UACrBS,KAAK,EAAGA,KAAO;UACf0B,QAAQ,EAAGA;QAAU,CACrB;MAAC,GAPIgB,GAAG,CAACnD,IAQI,CACd,CAAC;IAAA,CACE;EAAC,CACC,CAAC;AAEZ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useMemo","useSelect","applyFormat","removeFormat","getActiveFormat","useAnchor","ColorPalette","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","store","blockEditorStore","Popover","privateApis","componentsPrivateApis","__","textColor","settings","transparentValue","unlock","jsx","_jsx","jsxs","_jsxs","Tabs","TABS","name","title","parseCSS","css","split","reduce","accumulator","rule","property","value","color","backgroundColor","parseClassName","className","colorSettings","startsWith","endsWith","colorSlug","replace","colorObject","getActiveColors","activeColorFormat","attributes","style","class","setColors","colors","styles","classNames","push","join","slug","length","type","ColorPicker","onChange","select","_getSettings$colors","getSettings","activeColors","InlineColorUI","onClose","contentRef","isActive","popoverAnchor","editableContentElement","current","anchor","children","TabList","map","tab","Tab","tabId","TabPanel","focusable"],"sources":["@wordpress/format-library/src/text-color/inline.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchor,\n} from '@wordpress/rich-text';\nimport {\n\tColorPalette,\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tPopover,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings, transparentValue } from './index';\nimport { unlock } from '../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst TABS = [\n\t{ name: 'color', title: __( 'Text' ) },\n\t{ name: 'backgroundColor', title: __( 'Background' ) },\n];\n\nfunction parseCSS( css = '' ) {\n\treturn css.split( ';' ).reduce( ( accumulator, rule ) => {\n\t\tif ( rule ) {\n\t\t\tconst [ property, value ] = rule.split( ':' );\n\t\t\tif ( property === 'color' ) {\n\t\t\t\taccumulator.color = value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tproperty === 'background-color' &&\n\t\t\t\tvalue !== transparentValue\n\t\t\t) {\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t\t}\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\t// `colorSlug` could contain dashes, so simply match the start and end.\n\t\tif ( name.startsWith( 'has-' ) && name.endsWith( '-color' ) ) {\n\t\t\tconst colorSlug = name\n\t\t\t\t.replace( /^has-/, '' )\n\t\t\t\t.replace( /-color$/, '' );\n\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\tcolorSettings,\n\t\t\t\tcolorSlug\n\t\t\t);\n\t\t\taccumulator.color = colorObject.color;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function getActiveColors( value, name, colorSettings ) {\n\tconst activeColorFormat = getActiveFormat( value, name );\n\n\tif ( ! activeColorFormat ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t...parseCSS( activeColorFormat.attributes.style ),\n\t\t...parseClassName( activeColorFormat.attributes.class, colorSettings ),\n\t};\n}\n\nfunction setColors( value, name, colorSettings, colors ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn removeFormat( value, name );\n\t}\n\n\tconst styles = [];\n\tconst classNames = [];\n\tconst attributes = {};\n\n\tif ( backgroundColor ) {\n\t\tstyles.push( [ 'background-color', backgroundColor ].join( ':' ) );\n\t} else {\n\t\t// Override default browser color for mark element.\n\t\tstyles.push( [ 'background-color', transparentValue ].join( ':' ) );\n\t}\n\n\tif ( color ) {\n\t\tconst colorObject = getColorObjectByColorValue( colorSettings, color );\n\n\t\tif ( colorObject ) {\n\t\t\tclassNames.push( getColorClassName( 'color', colorObject.slug ) );\n\t\t} else {\n\t\t\tstyles.push( [ 'color', color ].join( ':' ) );\n\t\t}\n\t}\n\n\tif ( styles.length ) {\n\t\tattributes.style = styles.join( ';' );\n\t}\n\tif ( classNames.length ) {\n\t\tattributes.class = classNames.join( ' ' );\n\t}\n\n\treturn applyFormat( value, { type: name, attributes } );\n}\n\nfunction ColorPicker( { name, property, value, onChange } ) {\n\tconst colors = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().colors ?? [];\n\t}, [] );\n\tconst activeColors = useMemo(\n\t\t() => getActiveColors( value, name, colors ),\n\t\t[ name, value, colors ]\n\t);\n\n\treturn (\n\t\t<ColorPalette\n\t\t\tvalue={ activeColors[ property ] }\n\t\t\tonChange={ ( color ) => {\n\t\t\t\tonChange(\n\t\t\t\t\tsetColors( value, name, colors, { [ property ]: color } )\n\t\t\t\t);\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n\tisActive,\n} ) {\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings: { ...settings, isActive },\n\t} );\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"format-library__inline-color-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t>\n\t\t\t<Tabs>\n\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t\t<Tabs.Tab tabId={ tab.name } key={ tab.name }>\n\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t) ) }\n\t\t\t\t</Tabs.TabList>\n\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\t\tproperty={ tab.name }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t) ) }\n\t\t\t</Tabs>\n\t\t</Popover>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,WAAW,EACXC,YAAY,EACZC,eAAe,EACfC,SAAS,QACH,sBAAsB;AAC7B,SACCC,YAAY,EACZC,iBAAiB,EACjBC,0BAA0B,EAC1BC,+BAA+B,EAC/BC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SACCC,OAAO,EACPC,WAAW,IAAIC,qBAAqB,QAC9B,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,SAAS,IAAIC,QAAQ,EAAEC,gBAAgB,QAAQ,SAAS;AACjE,SAASC,MAAM,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAExC,MAAM;EAAEC;AAAK,CAAC,GAAGL,MAAM,CAAEL,qBAAsB,CAAC;AAEhD,MAAM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CAAC;AAEZ","ignoreList":[]}
|
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { toggleFormat } from '@wordpress/rich-text';
|
|
6
6
|
import { RichTextShortcut, __unstableRichTextInputEvent } from '@wordpress/block-editor';
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
8
|
const name = 'core/underline';
|
|
11
9
|
const title = __('Underline');
|
|
12
10
|
export const underline = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","toggleFormat","RichTextShortcut","__unstableRichTextInputEvent","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","name","title","underline","tagName","className","attributes","style","edit","value","onChange","onToggle","type","children","character","onUse","inputType","onInput"],"sources":["@wordpress/format-library/src/underline/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n} from '@wordpress/block-editor';\n\nconst name = 'core/underline';\nconst title = __( 'Underline' );\n\nexport const underline = {\n\tname,\n\ttitle,\n\ttagName: 'span',\n\tclassName: null,\n\tattributes: {\n\t\tstyle: 'style',\n\t},\n\tedit( { value, onChange } ) {\n\t\tconst onToggle = () => {\n\t\t\tonChange(\n\t\t\t\ttoggleFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\tstyle: 'text-decoration: underline;',\n\t\t\t\t\t},\n\t\t\t\t\ttitle,\n\t\t\t\t} )\n\t\t\t);\n\t\t};\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\tcharacter=\"u\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatUnderline\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SACCC,gBAAgB,EAChBC,4BAA4B,QACtB,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA
|
|
1
|
+
{"version":3,"names":["__","toggleFormat","RichTextShortcut","__unstableRichTextInputEvent","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","name","title","underline","tagName","className","attributes","style","edit","value","onChange","onToggle","type","children","character","onUse","inputType","onInput"],"sources":["@wordpress/format-library/src/underline/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextShortcut,\n\t__unstableRichTextInputEvent,\n} from '@wordpress/block-editor';\n\nconst name = 'core/underline';\nconst title = __( 'Underline' );\n\nexport const underline = {\n\tname,\n\ttitle,\n\ttagName: 'span',\n\tclassName: null,\n\tattributes: {\n\t\tstyle: 'style',\n\t},\n\tedit( { value, onChange } ) {\n\t\tconst onToggle = () => {\n\t\t\tonChange(\n\t\t\t\ttoggleFormat( value, {\n\t\t\t\t\ttype: name,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\tstyle: 'text-decoration: underline;',\n\t\t\t\t\t},\n\t\t\t\t\ttitle,\n\t\t\t\t} )\n\t\t\t);\n\t\t};\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\tcharacter=\"u\"\n\t\t\t\t\tonUse={ onToggle }\n\t\t\t\t/>\n\t\t\t\t<__unstableRichTextInputEvent\n\t\t\t\t\tinputType=\"formatUnderline\"\n\t\t\t\t\tonInput={ onToggle }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SACCC,gBAAgB,EAChBC,4BAA4B,QACtB,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAEjC,MAAMC,IAAI,GAAG,gBAAgB;AAC7B,MAAMC,KAAK,GAAGX,EAAE,CAAE,WAAY,CAAC;AAE/B,OAAO,MAAMY,SAAS,GAAG;EACxBF,IAAI;EACJC,KAAK;EACLE,OAAO,EAAE,MAAM;EACfC,SAAS,EAAE,IAAI;EACfC,UAAU,EAAE;IACXC,KAAK,EAAE;EACR,CAAC;EACDC,IAAIA,CAAE;IAAEC,KAAK;IAAEC;EAAS,CAAC,EAAG;IAC3B,MAAMC,QAAQ,GAAGA,CAAA,KAAM;MACtBD,QAAQ,CACPlB,YAAY,CAAEiB,KAAK,EAAE;QACpBG,IAAI,EAAEX,IAAI;QACVK,UAAU,EAAE;UACXC,KAAK,EAAE;QACR,CAAC;QACDL;MACD,CAAE,CACH,CAAC;IACF,CAAC;IAED,oBACCF,KAAA,CAAAF,SAAA;MAAAe,QAAA,gBACCjB,IAAA,CAACH,gBAAgB;QAChBmB,IAAI,EAAC,SAAS;QACdE,SAAS,EAAC,GAAG;QACbC,KAAK,EAAGJ;MAAU,CAClB,CAAC,eACFf,IAAA,CAACF,4BAA4B;QAC5BsB,SAAS,EAAC,iBAAiB;QAC3BC,OAAO,EAAGN;MAAU,CACpB,CAAC;IAAA,CACD,CAAC;EAEL;AACD,CAAC","ignoreList":[]}
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
/**
|
|
30
30
|
* Fonts & basic variables.
|
|
31
31
|
*/
|
|
32
|
+
/**
|
|
33
|
+
* Typography
|
|
34
|
+
*/
|
|
32
35
|
/**
|
|
33
36
|
* Grid System.
|
|
34
37
|
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
|
|
@@ -43,7 +46,10 @@
|
|
|
43
46
|
* Dimensions.
|
|
44
47
|
*/
|
|
45
48
|
/**
|
|
46
|
-
*
|
|
49
|
+
* Mobile specific styles
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Editor styles.
|
|
47
53
|
*/
|
|
48
54
|
/**
|
|
49
55
|
* Block & Editor UI.
|
|
@@ -67,6 +73,9 @@
|
|
|
67
73
|
* Creates a fading overlay to signify that the content is longer
|
|
68
74
|
* than the space allows.
|
|
69
75
|
*/
|
|
76
|
+
/**
|
|
77
|
+
* Typography
|
|
78
|
+
*/
|
|
70
79
|
/**
|
|
71
80
|
* Breakpoint mixins
|
|
72
81
|
*/
|