@wordpress/format-library 5.39.1-next.v.202602111440.0 → 5.40.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 +2 -0
- package/build/language/index.cjs +6 -2
- package/build/language/index.cjs.map +2 -2
- package/build/link/inline.cjs +1 -1
- package/build/link/inline.cjs.map +2 -2
- package/build/link/utils.cjs.map +2 -2
- package/build-module/language/index.mjs +6 -2
- package/build-module/language/index.mjs.map +2 -2
- package/build-module/link/inline.mjs +2 -2
- package/build-module/link/inline.mjs.map +2 -2
- package/build-module/link/utils.mjs.map +2 -2
- package/package.json +16 -16
- package/src/language/index.js +5 -1
- package/src/link/inline.js +2 -2
- package/src/link/utils.js +2 -3
package/CHANGELOG.md
CHANGED
package/build/language/index.cjs
CHANGED
|
@@ -33,10 +33,14 @@ var name = "core/language";
|
|
|
33
33
|
var title = (0, import_i18n.__)("Language");
|
|
34
34
|
var language = {
|
|
35
35
|
name,
|
|
36
|
+
title,
|
|
36
37
|
tagName: "bdo",
|
|
37
38
|
className: null,
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
attributes: {
|
|
40
|
+
lang: "lang",
|
|
41
|
+
dir: "dir"
|
|
42
|
+
},
|
|
43
|
+
edit: Edit
|
|
40
44
|
};
|
|
41
45
|
function Edit({ isActive, value, onChange, contentRef }) {
|
|
42
46
|
const [isPopoverVisible, setIsPopoverVisible] = (0, import_element.useState)(false);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/language/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * WordPress dependencies\n */\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport {\n\tTextControl,\n\tSelectControl,\n\tButton,\n\tPopover,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { applyFormat, removeFormat, useAnchor } from '@wordpress/rich-text';\nimport { language as languageIcon } from '@wordpress/icons';\n\nconst name = 'core/language';\nconst title = __( 'Language' );\n\nexport const language = {\n\tname,\n\ttagName: 'bdo',\n\tclassName: null,\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AAKnB,0BAAsC;AACtC,wBAOO;AACP,qBAAyB;AACzB,uBAAqD;AACrD,mBAAyC;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * WordPress dependencies\n */\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport {\n\tTextControl,\n\tSelectControl,\n\tButton,\n\tPopover,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { applyFormat, removeFormat, useAnchor } from '@wordpress/rich-text';\nimport { language as languageIcon } from '@wordpress/icons';\n\nconst name = 'core/language';\nconst title = __( 'Language' );\n\nexport const language = {\n\tname,\n\ttitle,\n\ttagName: 'bdo',\n\tclassName: null,\n\tattributes: {\n\t\tlang: 'lang',\n\t\tdir: 'dir',\n\t},\n\tedit: Edit,\n};\n\nfunction Edit( { isActive, value, onChange, contentRef } ) {\n\tconst [ isPopoverVisible, setIsPopoverVisible ] = useState( false );\n\tconst togglePopover = () => {\n\t\tsetIsPopoverVisible( ( state ) => ! state );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ languageIcon }\n\t\t\t\tlabel={ title }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tif ( isActive ) {\n\t\t\t\t\t\tonChange( removeFormat( value, name ) );\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttogglePopover();\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t\t{ isPopoverVisible && (\n\t\t\t\t<InlineLanguageUI\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonClose={ togglePopover }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction InlineLanguageUI( { value, contentRef, onChange, onClose } ) {\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings: language,\n\t} );\n\n\tconst [ lang, setLang ] = useState( '' );\n\tconst [ dir, setDir ] = useState( 'ltr' );\n\n\treturn (\n\t\t<Popover\n\t\t\tclassName=\"block-editor-format-toolbar__language-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t\tonClose={ onClose }\n\t\t>\n\t\t\t<VStack\n\t\t\t\tas=\"form\"\n\t\t\t\tspacing={ 4 }\n\t\t\t\tclassName=\"block-editor-format-toolbar__language-container-content\"\n\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tonChange(\n\t\t\t\t\t\tapplyFormat( value, {\n\t\t\t\t\t\t\ttype: name,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\tlang,\n\t\t\t\t\t\t\t\tdir,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ title }\n\t\t\t\t\tvalue={ lang }\n\t\t\t\t\tonChange={ ( val ) => setLang( val ) }\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'A valid language attribute, like \"en\" or \"fr\".'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t\t<SelectControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Text direction' ) }\n\t\t\t\t\tvalue={ dir }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Left to right' ),\n\t\t\t\t\t\t\tvalue: 'ltr',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Right to left' ),\n\t\t\t\t\t\t\tvalue: 'rtl',\n\t\t\t\t\t\t},\n\t\t\t\t\t] }\n\t\t\t\t\tonChange={ ( val ) => setDir( val ) }\n\t\t\t\t/>\n\t\t\t\t<HStack alignment=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\ttext={ __( 'Apply' ) }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</Popover>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AAKnB,0BAAsC;AACtC,wBAOO;AACP,qBAAyB;AACzB,uBAAqD;AACrD,mBAAyC;AAwBvC;AAtBF,IAAM,OAAO;AACb,IAAM,YAAQ,gBAAI,UAAW;AAEtB,IAAM,WAAW;AAAA,EACvB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,YAAY;AAAA,IACX,MAAM;AAAA,IACN,KAAK;AAAA,EACN;AAAA,EACA,MAAM;AACP;AAEA,SAAS,KAAM,EAAE,UAAU,OAAO,UAAU,WAAW,GAAI;AAC1D,QAAM,CAAE,kBAAkB,mBAAoB,QAAI,yBAAU,KAAM;AAClE,QAAM,gBAAgB,MAAM;AAC3B,wBAAqB,CAAE,UAAW,CAAE,KAAM;AAAA,EAC3C;AAEA,SACC,4EACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,MAAO,aAAAA;AAAA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B,OAAQ;AAAA,gBACR,SAAU;AAAA,kBACT;AAAA,oBACC,WAAO,gBAAI,eAAgB;AAAA,oBAC3B,OAAO;AAAA,kBACR;AAAA,kBACA;AAAA,oBACC,WAAO,gBAAI,eAAgB;AAAA,oBAC3B,OAAO;AAAA,kBACR;AAAA,gBACD;AAAA,gBACA,UAAW,CAAE,QAAS,OAAQ,GAAI;AAAA;AAAA,YACnC;AAAA,YACA,4CAAC,kBAAAC,sBAAA,EAAO,WAAU,SACjB;AAAA,cAAC;AAAA;AAAA,gBACA,uBAAqB;AAAA,gBACrB,SAAQ;AAAA,gBACR,MAAK;AAAA,gBACL,UAAO,gBAAI,OAAQ;AAAA;AAAA,YACpB,GACD;AAAA;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": ["languageIcon", "VStack", "HStack"]
|
|
7
7
|
}
|
package/build/link/inline.cjs
CHANGED
|
@@ -123,7 +123,7 @@ function InlineLinkUI({
|
|
|
123
123
|
...linkValue,
|
|
124
124
|
...nextValue
|
|
125
125
|
};
|
|
126
|
-
const newUrl = (0, import_url.
|
|
126
|
+
const newUrl = (0, import_url.prependHTTPS)(nextValue.url);
|
|
127
127
|
const linkFormat = (0, import_utils.createLinkFormat)({
|
|
128
128
|
url: newUrl,
|
|
129
129
|
type: nextValue.type,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/link/inline.js"],
|
|
4
|
-
"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 {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAkD;AAClD,kBAA4B;AAC5B,kBAAsB;AACtB,wBAAwB;AACxB,
|
|
4
|
+
"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 { prependHTTPS } 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\tLinkControl,\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';\nimport CSSClassesSettingComponent from './css-classes-setting';\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\t{\n\t\tid: 'cssClasses',\n\t\ttitle: __( 'Additional CSS class(es)' ),\n\t\trender: ( setting, value, onChange ) => {\n\t\t\treturn (\n\t\t\t\t<CSSClassesSettingComponent\n\t\t\t\t\tsetting={ setting }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\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\tcssClasses: activeAttributes.class,\n\t\t} ),\n\t\t[\n\t\t\tactiveAttributes.class,\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 = prependHTTPS( 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\tcssClasses: nextValue.cssClasses,\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\t// Use explicit format boundaries rather than relying on\n\t\t\t// the current selection which may be collapsed or\n\t\t\t// misaligned after external value changes.\n\t\t\tconst boundary = getFormatBoundary( value, {\n\t\t\t\ttype: 'core/link',\n\t\t\t} );\n\t\t\tnewValue = applyFormat(\n\t\t\t\tvalue,\n\t\t\t\tlinkFormat,\n\t\t\t\tboundary.start,\n\t\t\t\tboundary.end\n\t\t\t);\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 targeted 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\t\ttextEnd = boundary.end;\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAkD;AAClD,kBAA4B;AAC5B,kBAAsB;AACtB,wBAAwB;AACxB,iBAA6B;AAC7B,uBAWO;AACP,0BAGO;AACP,kBAAuC;AAKvC,mBAAiE;AACjE,mBAAiC;AACjC,iCAAuC;AAanC;AAXJ,IAAM,gBAAgB;AAAA,EACrB,GAAG,gCAAY;AAAA,EACf;AAAA,IACC,IAAI;AAAA,IACJ,WAAO,gBAAI,kBAAmB;AAAA,EAC/B;AAAA,EACA;AAAA,IACC,IAAI;AAAA,IACJ,WAAO,gBAAI,0BAA2B;AAAA,IACtC,QAAQ,CAAE,SAAS,OAAO,aAAc;AACvC,aACC;AAAA,QAAC,2BAAAA;AAAA,QAAA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACD;AAAA,IAEF;AAAA,EACD;AACD;AAEA,SAAS,aAAc;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,oBAAoB,8BAA+B,OAAO,QAAS;AAGzE,QAAM,eAAe,kBAAkB;AAEvC,QAAM,EAAE,gBAAgB,QAAI,yBAAa,oBAAAC,KAAiB;AAE1D,QAAM,EAAE,kBAAkB,oBAAoB,eAAe,QAAI;AAAA,IAChE,CAAE,WAAY;AACb,YAAM,EAAE,aAAa,kBAAkB,IACtC,OAAQ,oBAAAA,KAAiB;AAC1B,YAAM,YAAY,YAAY;AAE9B,aAAO;AAAA,QACN,kBAAkB,UAAU;AAAA,QAC5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C;AAEA,IAAO,iBAAQ;",
|
|
6
6
|
"names": ["CSSClassesSettingComponent", "blockEditorStore", "settings"]
|
|
7
7
|
}
|
package/build/link/utils.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/link/utils.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tgetProtocol,\n\tisValidProtocol,\n\tgetAuthority,\n\tisValidAuthority,\n\tgetPath,\n\tisValidPath,\n\tgetQueryString,\n\tisValidQueryString,\n\tgetFragment,\n\tisValidFragment,\n} from '@wordpress/url';\n\n/**\n * Check for issues with the provided href.\n *\n * @param {string} href The href.\n *\n * @return {boolean} Is the href invalid?\n */\nexport function isValidHref( href ) {\n\tif ( ! href ) {\n\t\treturn false;\n\t}\n\n\tconst trimmedHref = href.trim();\n\n\tif ( ! trimmedHref ) {\n\t\treturn false;\n\t}\n\n\t// Does the href start with something that looks like a URL protocol?\n\tif ( /^\\S+:/.test( trimmedHref ) ) {\n\t\tconst protocol = getProtocol( trimmedHref );\n\t\tif ( ! isValidProtocol( protocol ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Add some extra checks for http(s) URIs, since these are the most common use-case.\n\t\t// This ensures URIs with an http protocol have exactly two forward slashes following the protocol.\n\t\tif (\n\t\t\tprotocol.startsWith( 'http' ) &&\n\t\t\t! /^https?:\\/\\/[^\\/\\s]/i.test( trimmedHref )\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst authority = getAuthority( trimmedHref );\n\t\tif ( ! isValidAuthority( authority ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst path = getPath( trimmedHref );\n\t\tif ( path && ! isValidPath( path ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst queryString = getQueryString( trimmedHref );\n\t\tif ( queryString && ! isValidQueryString( queryString ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst fragment = getFragment( trimmedHref );\n\t\tif ( fragment && ! isValidFragment( fragment ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Validate anchor links.\n\tif ( trimmedHref.startsWith( '#' ) && ! isValidFragment( trimmedHref ) ) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Generates the format object that will be applied to the link text.\n *\n * @param {Object} options\n * @param {string} options.url The href of the link.\n * @param {string} options.type The type of the link.\n * @param {string} options.id The ID of the link.\n * @param {boolean} options.opensInNewWindow Whether this link will open in a new window.\n * @param {boolean} options.nofollow Whether this link is marked as no follow relationship.\n * @param {string} options.cssClasses The CSS classes to apply to the link.\n * @return {Object} The final format object.\n */\nexport function createLinkFormat( {\n\turl,\n\ttype,\n\tid,\n\topensInNewWindow,\n\tnofollow,\n\tcssClasses,\n} ) {\n\tconst format = {\n\t\ttype: 'core/link',\n\t\tattributes: {\n\t\t\turl,\n\t\t},\n\t};\n\n\tif ( type ) {\n\t\tformat.attributes.type = type;\n\t}\n\tif ( id ) {\n\t\tformat.attributes.id = id;\n\t}\n\n\tif ( opensInNewWindow ) {\n\t\tformat.attributes.target = '_blank';\n\t\tformat.attributes.rel = format.attributes.rel\n\t\t\t? format.attributes.rel + ' noreferrer noopener'\n\t\t\t: 'noreferrer noopener';\n\t}\n\n\tif ( nofollow ) {\n\t\tformat.attributes.rel = format.attributes.rel\n\t\t\t? format.attributes.rel + ' nofollow'\n\t\t\t: 'nofollow';\n\t}\n\n\tconst trimmedCssClasses = cssClasses?.trim();\n\n\tif ( trimmedCssClasses?.length ) {\n\t\tformat.attributes.class = trimmedCssClasses;\n\t}\n\n\treturn format;\n}\n\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAWO;AASA,SAAS,YAAa,MAAO;AACnC,MAAK,CAAE,MAAO;AACb,WAAO;AAAA,EACR;AAEA,QAAM,cAAc,KAAK,KAAK;AAE9B,MAA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MACvC,OAAO,WAAW,MAAM,cACxB;AAAA,EACJ;AAEA,QAAM,oBAAoB,YAAY,KAAK;AAE3C,MAAK,mBAAmB,QAAS;AAChC,WAAO,WAAW,QAAQ;AAAA,EAC3B;AAEA,SAAO;AACR;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tgetProtocol,\n\tisValidProtocol,\n\tgetAuthority,\n\tisValidAuthority,\n\tgetPath,\n\tisValidPath,\n\tgetQueryString,\n\tisValidQueryString,\n\tgetFragment,\n\tisValidFragment,\n} from '@wordpress/url';\n\n/**\n * Check for issues with the provided href.\n *\n * @param {string} href The href.\n *\n * @return {boolean} Is the href invalid?\n */\nexport function isValidHref( href ) {\n\tif ( ! href ) {\n\t\treturn false;\n\t}\n\n\tconst trimmedHref = href.trim();\n\n\tif ( ! trimmedHref ) {\n\t\treturn false;\n\t}\n\n\t// Does the href start with something that looks like a URL protocol?\n\tif ( /^\\S+:/.test( trimmedHref ) ) {\n\t\tconst protocol = getProtocol( trimmedHref );\n\t\tif ( ! isValidProtocol( protocol ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Add some extra checks for http(s) URIs, since these are the most common use-case.\n\t\t// This ensures URIs with an http protocol have exactly two forward slashes following the protocol.\n\t\tif (\n\t\t\tprotocol.startsWith( 'http' ) &&\n\t\t\t! /^https?:\\/\\/[^\\/\\s]/i.test( trimmedHref )\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst authority = getAuthority( trimmedHref );\n\t\tif ( ! isValidAuthority( authority ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst path = getPath( trimmedHref );\n\t\tif ( path && ! isValidPath( path ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst queryString = getQueryString( trimmedHref );\n\t\tif ( queryString && ! isValidQueryString( queryString ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst fragment = getFragment( trimmedHref );\n\t\tif ( fragment && ! isValidFragment( fragment ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Validate anchor links.\n\tif ( trimmedHref.startsWith( '#' ) && ! isValidFragment( trimmedHref ) ) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Generates the format object that will be applied to the link text.\n *\n * @param {Object} options\n * @param {string} options.url The href of the link.\n * @param {string} options.type The type of the link.\n * @param {string} options.id The ID of the link.\n * @param {boolean} options.opensInNewWindow Whether this link will open in a new window.\n * @param {boolean} options.nofollow Whether this link is marked as no follow relationship.\n * @param {string} options.cssClasses The CSS classes to apply to the link.\n * @return {Object} The final format object.\n */\nexport function createLinkFormat( {\n\turl,\n\ttype,\n\tid,\n\topensInNewWindow,\n\tnofollow,\n\tcssClasses,\n} ) {\n\tconst format = {\n\t\ttype: 'core/link',\n\t\tattributes: {\n\t\t\turl,\n\t\t},\n\t};\n\n\tif ( type ) {\n\t\tformat.attributes.type = type;\n\t}\n\tif ( id ) {\n\t\tformat.attributes.id = id;\n\t}\n\n\tif ( opensInNewWindow ) {\n\t\tformat.attributes.target = '_blank';\n\t\tformat.attributes.rel = format.attributes.rel\n\t\t\t? format.attributes.rel + ' noreferrer noopener'\n\t\t\t: 'noreferrer noopener';\n\t}\n\n\tif ( nofollow ) {\n\t\tformat.attributes.rel = format.attributes.rel\n\t\t\t? format.attributes.rel + ' nofollow'\n\t\t\t: 'nofollow';\n\t}\n\n\tconst trimmedCssClasses = cssClasses?.trim();\n\n\tif ( trimmedCssClasses?.length ) {\n\t\tformat.attributes.class = trimmedCssClasses;\n\t}\n\n\treturn format;\n}\n\n/**\n * @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue\n *\n * Get the start and end boundaries of a given format from a rich text value.\n *\n * @param {RichTextValue} value the rich text value to interrogate.\n * @param {string} format the identifier for the target format (e.g. `core/link`, `core/bold`).\n * @param {number?} startIndex optional startIndex to seek from.\n * @param {number?} endIndex optional endIndex to seek from.\n * @return {Object}\tobject containing start and end values for the given format.\n */\nexport function getFormatBoundary(\n\tvalue,\n\tformat,\n\tstartIndex = value.start,\n\tendIndex = value.end\n) {\n\tconst EMPTY_BOUNDARIES = {\n\t\tstart: undefined,\n\t\tend: undefined,\n\t};\n\n\tconst { formats } = value;\n\tlet targetFormat;\n\tlet initialIndex;\n\n\tif ( ! formats?.length ) {\n\t\treturn EMPTY_BOUNDARIES;\n\t}\n\n\t// Clone formats to avoid modifying source formats.\n\tconst newFormats = formats.slice();\n\n\tconst formatAtStart = newFormats[ startIndex ]?.find(\n\t\t( { type } ) => type === format.type\n\t);\n\n\tconst formatAtEnd = newFormats[ endIndex ]?.find(\n\t\t( { type } ) => type === format.type\n\t);\n\n\tconst formatAtEndMinusOne = newFormats[ endIndex - 1 ]?.find(\n\t\t( { type } ) => type === format.type\n\t);\n\n\tif ( !! formatAtStart ) {\n\t\t// Set values to conform to \"start\"\n\t\ttargetFormat = formatAtStart;\n\t\tinitialIndex = startIndex;\n\t} else if ( !! formatAtEnd ) {\n\t\t// Set values to conform to \"end\"\n\t\ttargetFormat = formatAtEnd;\n\t\tinitialIndex = endIndex;\n\t} else if ( !! formatAtEndMinusOne ) {\n\t\t// This is an edge case which will occur if you create a format, then place\n\t\t// the caret just before the format and hit the back ARROW key. The resulting\n\t\t// value object will have start and end +1 beyond the edge of the format boundary.\n\t\ttargetFormat = formatAtEndMinusOne;\n\t\tinitialIndex = endIndex - 1;\n\t} else {\n\t\treturn EMPTY_BOUNDARIES;\n\t}\n\n\tconst index = newFormats[ initialIndex ].indexOf( targetFormat );\n\n\tconst walkingArgs = [ newFormats, initialIndex, targetFormat, index ];\n\n\t// Walk the startIndex \"backwards\" to the leading \"edge\" of the matching format.\n\tstartIndex = walkToStart( ...walkingArgs );\n\n\t// Walk the endIndex \"forwards\" until the trailing \"edge\" of the matching format.\n\tendIndex = walkToEnd( ...walkingArgs );\n\n\t// Safe guard: start index cannot be less than 0.\n\tstartIndex = startIndex < 0 ? 0 : startIndex;\n\n\t// Return the indices of the \"edges\" as the boundaries.\n\t// walkToEnd returns the last index that has the format (e.g. 10),\n\t// but rich-text APIs like applyFormat and slice expect the end to be\n\t// one position past the last character (e.g. 11), just like\n\t// String.prototype.slice. Adding 1 here so consumers don't have to.\n\treturn {\n\t\tstart: startIndex,\n\t\tend: endIndex + 1,\n\t};\n}\n\n/**\n * Walks forwards/backwards towards the boundary of a given format within an\n * array of format objects. Returns the index of the boundary.\n *\n * @param {Array} formats the formats to search for the given format type.\n * @param {number} initialIndex the starting index from which to walk.\n * @param {Object} targetFormatRef a reference to the format type object being sought.\n * @param {number} formatIndex the index at which we expect the target format object to be.\n * @param {string} direction either 'forwards' or 'backwards' to indicate the direction.\n * @return {number} the index of the boundary of the given format.\n */\nfunction walkToBoundary(\n\tformats,\n\tinitialIndex,\n\ttargetFormatRef,\n\tformatIndex,\n\tdirection\n) {\n\tlet index = initialIndex;\n\n\tconst directions = {\n\t\tforwards: 1,\n\t\tbackwards: -1,\n\t};\n\n\tconst directionIncrement = directions[ direction ] || 1; // invalid direction arg default to forwards\n\tconst inverseDirectionIncrement = directionIncrement * -1;\n\n\twhile (\n\t\tformats[ index ] &&\n\t\tformats[ index ][ formatIndex ] === targetFormatRef\n\t) {\n\t\t// Increment/decrement in the direction of operation.\n\t\tindex = index + directionIncrement;\n\t}\n\n\t// Restore by one in inverse direction of operation\n\t// to avoid out of bounds.\n\tindex = index + inverseDirectionIncrement;\n\n\treturn index;\n}\n\nconst partialRight =\n\t( fn, ...partialArgs ) =>\n\t( ...args ) =>\n\t\tfn( ...args, ...partialArgs );\n\nconst walkToStart = partialRight( walkToBoundary, 'backwards' );\n\nconst walkToEnd = partialRight( walkToBoundary, 'forwards' );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAWO;AASA,SAAS,YAAa,MAAO;AACnC,MAAK,CAAE,MAAO;AACb,WAAO;AAAA,EACR;AAEA,QAAM,cAAc,KAAK,KAAK;AAE9B,MAAK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AS,eACR,SACA,cACA,iBACA,aACA,WACC;AACD,MAAI,QAAQ;AAEZ,QAAM,aAAa;AAAA,IAClB,UAAU;AAAA,IACV,WAAW;AAAA,EACZ;AAEA,QAAM,qBAAqB,WAAY,SAAU,KAAK;AACtD,QAAM,4BAA4B,qBAAqB;AAEvD,SACC,QAAS,KAAM,KACf,QAAS,KAAM,EAAG,WAAY,MAAM,iBACnC;AAED,YAAQ,QAAQ;AAAA,EACjB;AAIA,UAAQ,QAAQ;AAEhB,SAAO;AACR;AAEA,IAAM,eACL,CAAE,OAAO,gBACT,IAAK,SACJ,GAAI,GAAG,MAAM,GAAG,WAAY;AAE9B,IAAM,cAAc,aAAc,gBAAgB,WAAY;AAE9D,IAAM,YAAY,aAAc,gBAAgB,UAAW;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,10 +17,14 @@ var name = "core/language";
|
|
|
17
17
|
var title = __("Language");
|
|
18
18
|
var language = {
|
|
19
19
|
name,
|
|
20
|
+
title,
|
|
20
21
|
tagName: "bdo",
|
|
21
22
|
className: null,
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
attributes: {
|
|
24
|
+
lang: "lang",
|
|
25
|
+
dir: "dir"
|
|
26
|
+
},
|
|
27
|
+
edit: Edit
|
|
24
28
|
};
|
|
25
29
|
function Edit({ isActive, value, onChange, contentRef }) {
|
|
26
30
|
const [isPopoverVisible, setIsPopoverVisible] = useState(false);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/language/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * WordPress dependencies\n */\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport {\n\tTextControl,\n\tSelectControl,\n\tButton,\n\tPopover,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { applyFormat, removeFormat, useAnchor } from '@wordpress/rich-text';\nimport { language as languageIcon } from '@wordpress/icons';\n\nconst name = 'core/language';\nconst title = __( 'Language' );\n\nexport const language = {\n\tname,\n\ttagName: 'bdo',\n\tclassName: null,\n\
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AAKnB,SAAS,6BAA6B;AACtC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP,SAAS,gBAAgB;AACzB,SAAS,aAAa,cAAc,iBAAiB;AACrD,SAAS,YAAY,oBAAoB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * WordPress dependencies\n */\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport {\n\tTextControl,\n\tSelectControl,\n\tButton,\n\tPopover,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { applyFormat, removeFormat, useAnchor } from '@wordpress/rich-text';\nimport { language as languageIcon } from '@wordpress/icons';\n\nconst name = 'core/language';\nconst title = __( 'Language' );\n\nexport const language = {\n\tname,\n\ttitle,\n\ttagName: 'bdo',\n\tclassName: null,\n\tattributes: {\n\t\tlang: 'lang',\n\t\tdir: 'dir',\n\t},\n\tedit: Edit,\n};\n\nfunction Edit( { isActive, value, onChange, contentRef } ) {\n\tconst [ isPopoverVisible, setIsPopoverVisible ] = useState( false );\n\tconst togglePopover = () => {\n\t\tsetIsPopoverVisible( ( state ) => ! state );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ languageIcon }\n\t\t\t\tlabel={ title }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tif ( isActive ) {\n\t\t\t\t\t\tonChange( removeFormat( value, name ) );\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttogglePopover();\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t\t{ isPopoverVisible && (\n\t\t\t\t<InlineLanguageUI\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonClose={ togglePopover }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction InlineLanguageUI( { value, contentRef, onChange, onClose } ) {\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings: language,\n\t} );\n\n\tconst [ lang, setLang ] = useState( '' );\n\tconst [ dir, setDir ] = useState( 'ltr' );\n\n\treturn (\n\t\t<Popover\n\t\t\tclassName=\"block-editor-format-toolbar__language-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t\tonClose={ onClose }\n\t\t>\n\t\t\t<VStack\n\t\t\t\tas=\"form\"\n\t\t\t\tspacing={ 4 }\n\t\t\t\tclassName=\"block-editor-format-toolbar__language-container-content\"\n\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tonChange(\n\t\t\t\t\t\tapplyFormat( value, {\n\t\t\t\t\t\t\ttype: name,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\tlang,\n\t\t\t\t\t\t\t\tdir,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ title }\n\t\t\t\t\tvalue={ lang }\n\t\t\t\t\tonChange={ ( val ) => setLang( val ) }\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'A valid language attribute, like \"en\" or \"fr\".'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t\t<SelectControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Text direction' ) }\n\t\t\t\t\tvalue={ dir }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Left to right' ),\n\t\t\t\t\t\t\tvalue: 'ltr',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Right to left' ),\n\t\t\t\t\t\t\tvalue: 'rtl',\n\t\t\t\t\t\t},\n\t\t\t\t\t] }\n\t\t\t\t\tonChange={ ( val ) => setDir( val ) }\n\t\t\t\t/>\n\t\t\t\t<HStack alignment=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\ttext={ __( 'Apply' ) }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</Popover>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AAKnB,SAAS,6BAA6B;AACtC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP,SAAS,gBAAgB;AACzB,SAAS,aAAa,cAAc,iBAAiB;AACrD,SAAS,YAAY,oBAAoB;AAwBvC,mBACC,KADD;AAtBF,IAAM,OAAO;AACb,IAAM,QAAQ,GAAI,UAAW;AAEtB,IAAM,WAAW;AAAA,EACvB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,YAAY;AAAA,IACX,MAAM;AAAA,IACN,KAAK;AAAA,EACN;AAAA,EACA,MAAM;AACP;AAEA,SAAS,KAAM,EAAE,UAAU,OAAO,UAAU,WAAW,GAAI;AAC1D,QAAM,CAAE,kBAAkB,mBAAoB,IAAI,SAAU,KAAM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,gBACD;AAAA;AAAA,YACD;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACA,uBAAqB;AAAA,gBACrB,OAAQ,GAAI,gBAAiB;AAAA,gBAC7B,OAAQ;AAAA,gBACR,SAAU;AAAA,kBACT;AAAA,oBACC,OAAO,GAAI,eAAgB;AAAA,oBAC3B,OAAO;AAAA,kBACR;AAAA,kBACA;AAAA,oBACC,OAAO,GAAI,eAAgB;AAAA,oBAC3B,OAAO;AAAA,kBACR;AAAA,gBACD;AAAA,gBACA,UAAW,CAAE,QAAS,OAAQ,GAAI;AAAA;AAAA,YACnC;AAAA,YACA,oBAAC,UAAO,WAAU,SACjB;AAAA,cAAC;AAAA;AAAA,gBACA,uBAAqB;AAAA,gBACrB,SAAQ;AAAA,gBACR,MAAK;AAAA,gBACL,MAAO,GAAI,OAAQ;AAAA;AAAA,YACpB,GACD;AAAA;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,7 +3,7 @@ import { useMemo, createInterpolateElement } from "@wordpress/element";
|
|
|
3
3
|
import { __, sprintf } from "@wordpress/i18n";
|
|
4
4
|
import { speak } from "@wordpress/a11y";
|
|
5
5
|
import { Popover } from "@wordpress/components";
|
|
6
|
-
import {
|
|
6
|
+
import { prependHTTPS } from "@wordpress/url";
|
|
7
7
|
import {
|
|
8
8
|
create,
|
|
9
9
|
insert,
|
|
@@ -104,7 +104,7 @@ function InlineLinkUI({
|
|
|
104
104
|
...linkValue,
|
|
105
105
|
...nextValue
|
|
106
106
|
};
|
|
107
|
-
const newUrl =
|
|
107
|
+
const newUrl = prependHTTPS(nextValue.url);
|
|
108
108
|
const linkFormat = createLinkFormat({
|
|
109
109
|
url: newUrl,
|
|
110
110
|
type: nextValue.type,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/link/inline.js"],
|
|
4
|
-
"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 {
|
|
5
|
-
"mappings": ";AAGA,SAAS,SAAS,gCAAgC;AAClD,SAAS,IAAI,eAAe;AAC5B,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,
|
|
4
|
+
"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 { prependHTTPS } 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\tLinkControl,\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';\nimport CSSClassesSettingComponent from './css-classes-setting';\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\t{\n\t\tid: 'cssClasses',\n\t\ttitle: __( 'Additional CSS class(es)' ),\n\t\trender: ( setting, value, onChange ) => {\n\t\t\treturn (\n\t\t\t\t<CSSClassesSettingComponent\n\t\t\t\t\tsetting={ setting }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\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\tcssClasses: activeAttributes.class,\n\t\t} ),\n\t\t[\n\t\t\tactiveAttributes.class,\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 = prependHTTPS( 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\tcssClasses: nextValue.cssClasses,\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\t// Use explicit format boundaries rather than relying on\n\t\t\t// the current selection which may be collapsed or\n\t\t\t// misaligned after external value changes.\n\t\t\tconst boundary = getFormatBoundary( value, {\n\t\t\t\ttype: 'core/link',\n\t\t\t} );\n\t\t\tnewValue = applyFormat(\n\t\t\t\tvalue,\n\t\t\t\tlinkFormat,\n\t\t\t\tboundary.start,\n\t\t\t\tboundary.end\n\t\t\t);\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 targeted 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\t\ttextEnd = boundary.end;\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"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,SAAS,gCAAgC;AAClD,SAAS,IAAI,eAAe;AAC5B,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,aAAa,iBAAiB;AAKvC,SAAS,kBAAkB,aAAa,yBAAyB;AACjE,SAAS,QAAQ,gBAAgB;AACjC,OAAO,gCAAgC;AAanC;AAXJ,IAAM,gBAAgB;AAAA,EACrB,GAAG,YAAY;AAAA,EACf;AAAA,IACC,IAAI;AAAA,IACJ,OAAO,GAAI,kBAAmB;AAAA,EAC/B;AAAA,EACA;AAAA,IACC,IAAI;AAAA,IACJ,OAAO,GAAI,0BAA2B;AAAA,IACtC,QAAQ,CAAE,SAAS,OAAO,aAAc;AACvC,aACC;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACD;AAAA,IAEF;AAAA,EACD;AACD;AAEA,SAAS,aAAc;AAAA,EACtB;AAAA,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ChC,MAAM;AAAA,cACN,SAAS;AAAA,cACT,SAAS;AAAA,YACV;AAAA,UACD;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;AAEA,SAAS,8BAA+B,OAAO,UAAW;AAEzD,MAAI,YAAY,MAAM;AACtB,MAAI,UAAU,MAAM;AAKpB,MAAK,UAAW;AACf,UAAM,WAAW,kBAAmB,OAAO;AAAA,MAC1C,MAAM;AAAA,IACP,CAAE;AAEF,gBAAY,SAAS;AACrB,cAAU,SAAS;AAAA,EACpB;AAGA,SAAO,MAAO,OAAO,WAAW,OAAQ;AACzC;AAEA,IAAO,iBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/link/utils.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tgetProtocol,\n\tisValidProtocol,\n\tgetAuthority,\n\tisValidAuthority,\n\tgetPath,\n\tisValidPath,\n\tgetQueryString,\n\tisValidQueryString,\n\tgetFragment,\n\tisValidFragment,\n} from '@wordpress/url';\n\n/**\n * Check for issues with the provided href.\n *\n * @param {string} href The href.\n *\n * @return {boolean} Is the href invalid?\n */\nexport function isValidHref( href ) {\n\tif ( ! href ) {\n\t\treturn false;\n\t}\n\n\tconst trimmedHref = href.trim();\n\n\tif ( ! trimmedHref ) {\n\t\treturn false;\n\t}\n\n\t// Does the href start with something that looks like a URL protocol?\n\tif ( /^\\S+:/.test( trimmedHref ) ) {\n\t\tconst protocol = getProtocol( trimmedHref );\n\t\tif ( ! isValidProtocol( protocol ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Add some extra checks for http(s) URIs, since these are the most common use-case.\n\t\t// This ensures URIs with an http protocol have exactly two forward slashes following the protocol.\n\t\tif (\n\t\t\tprotocol.startsWith( 'http' ) &&\n\t\t\t! /^https?:\\/\\/[^\\/\\s]/i.test( trimmedHref )\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst authority = getAuthority( trimmedHref );\n\t\tif ( ! isValidAuthority( authority ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst path = getPath( trimmedHref );\n\t\tif ( path && ! isValidPath( path ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst queryString = getQueryString( trimmedHref );\n\t\tif ( queryString && ! isValidQueryString( queryString ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst fragment = getFragment( trimmedHref );\n\t\tif ( fragment && ! isValidFragment( fragment ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Validate anchor links.\n\tif ( trimmedHref.startsWith( '#' ) && ! isValidFragment( trimmedHref ) ) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Generates the format object that will be applied to the link text.\n *\n * @param {Object} options\n * @param {string} options.url The href of the link.\n * @param {string} options.type The type of the link.\n * @param {string} options.id The ID of the link.\n * @param {boolean} options.opensInNewWindow Whether this link will open in a new window.\n * @param {boolean} options.nofollow Whether this link is marked as no follow relationship.\n * @param {string} options.cssClasses The CSS classes to apply to the link.\n * @return {Object} The final format object.\n */\nexport function createLinkFormat( {\n\turl,\n\ttype,\n\tid,\n\topensInNewWindow,\n\tnofollow,\n\tcssClasses,\n} ) {\n\tconst format = {\n\t\ttype: 'core/link',\n\t\tattributes: {\n\t\t\turl,\n\t\t},\n\t};\n\n\tif ( type ) {\n\t\tformat.attributes.type = type;\n\t}\n\tif ( id ) {\n\t\tformat.attributes.id = id;\n\t}\n\n\tif ( opensInNewWindow ) {\n\t\tformat.attributes.target = '_blank';\n\t\tformat.attributes.rel = format.attributes.rel\n\t\t\t? format.attributes.rel + ' noreferrer noopener'\n\t\t\t: 'noreferrer noopener';\n\t}\n\n\tif ( nofollow ) {\n\t\tformat.attributes.rel = format.attributes.rel\n\t\t\t? format.attributes.rel + ' nofollow'\n\t\t\t: 'nofollow';\n\t}\n\n\tconst trimmedCssClasses = cssClasses?.trim();\n\n\tif ( trimmedCssClasses?.length ) {\n\t\tformat.attributes.class = trimmedCssClasses;\n\t}\n\n\treturn format;\n}\n\n
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AASA,SAAS,YAAa,MAAO;AACnC,MAAK,CAAE,MAAO;AACb,WAAO;AAAA,EACR;AAEA,QAAM,cAAc,KAAK,KAAK;AAE9B,MAAK,CAAE,aAAc;AACpB,WAAO;AAAA,EACR;AAGA,MAAK,QAAQ,KAAM,WAAY,GAAI;AAClC,UAAM,WAAW,YAAa,WAAY;AAC1C,QAAK,CAAE,gBAAiB,QAAS,GAAI;AACpC,aAAO;AAAA,IACR;AAIA,QACC,SAAS,WAAY,MAAO,KAC5B,CAAE,uBAAuB,KAAM,WAAY,GAC1C;AACD,aAAO;AAAA,IACR;AAEA,UAAM,YAAY,aAAc,WAAY;AAC5C,QAAK,CAAE,iBAAkB,SAAU,GAAI;AACtC,aAAO;AAAA,IACR;AAEA,UAAM,OAAO,QAAS,WAAY;AAClC,QAAK,QAAQ,CAAE,YAAa,IAAK,GAAI;AACpC,aAAO;AAAA,IACR;AAEA,UAAM,cAAc,eAAgB,WAAY;AAChD,QAAK,eAAe,CAAE,mBAAoB,WAAY,GAAI;AACzD,aAAO;AAAA,IACR;AAEA,UAAM,WAAW,YAAa,WAAY;AAC1C,QAAK,YAAY,CAAE,gBAAiB,QAAS,GAAI;AAChD,aAAO;AAAA,IACR;AAAA,EACD;AAGA,MAAK,YAAY,WAAY,GAAI,KAAK,CAAE,gBAAiB,WAAY,GAAI;AACxE,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAcO,SAAS,iBAAkB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,SAAS;AAAA,IACd,MAAM;AAAA,IACN,YAAY;AAAA,MACX;AAAA,IACD;AAAA,EACD;AAEA,MAAK,MAAO;AACX,WAAO,WAAW,OAAO;AAAA,EAC1B;AACA,MAAK,IAAK;AACT,WAAO,WAAW,KAAK;AAAA,EACxB;AAEA,MAAK,kBAAmB;AACvB,WAAO,WAAW,SAAS;AAC3B,WAAO,WAAW,MAAM,OAAO,WAAW,MACvC,OAAO,WAAW,MAAM,yBACxB;AAAA,EACJ;AAEA,MAAK,UAAW;AACf,WAAO,WAAW,MAAM,OAAO,WAAW,MACvC,OAAO,WAAW,MAAM,cACxB;AAAA,EACJ;AAEA,QAAM,oBAAoB,YAAY,KAAK;AAE3C,MAAK,mBAAmB,QAAS;AAChC,WAAO,WAAW,QAAQ;AAAA,EAC3B;AAEA,SAAO;AACR;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tgetProtocol,\n\tisValidProtocol,\n\tgetAuthority,\n\tisValidAuthority,\n\tgetPath,\n\tisValidPath,\n\tgetQueryString,\n\tisValidQueryString,\n\tgetFragment,\n\tisValidFragment,\n} from '@wordpress/url';\n\n/**\n * Check for issues with the provided href.\n *\n * @param {string} href The href.\n *\n * @return {boolean} Is the href invalid?\n */\nexport function isValidHref( href ) {\n\tif ( ! href ) {\n\t\treturn false;\n\t}\n\n\tconst trimmedHref = href.trim();\n\n\tif ( ! trimmedHref ) {\n\t\treturn false;\n\t}\n\n\t// Does the href start with something that looks like a URL protocol?\n\tif ( /^\\S+:/.test( trimmedHref ) ) {\n\t\tconst protocol = getProtocol( trimmedHref );\n\t\tif ( ! isValidProtocol( protocol ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Add some extra checks for http(s) URIs, since these are the most common use-case.\n\t\t// This ensures URIs with an http protocol have exactly two forward slashes following the protocol.\n\t\tif (\n\t\t\tprotocol.startsWith( 'http' ) &&\n\t\t\t! /^https?:\\/\\/[^\\/\\s]/i.test( trimmedHref )\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst authority = getAuthority( trimmedHref );\n\t\tif ( ! isValidAuthority( authority ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst path = getPath( trimmedHref );\n\t\tif ( path && ! isValidPath( path ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst queryString = getQueryString( trimmedHref );\n\t\tif ( queryString && ! isValidQueryString( queryString ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst fragment = getFragment( trimmedHref );\n\t\tif ( fragment && ! isValidFragment( fragment ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Validate anchor links.\n\tif ( trimmedHref.startsWith( '#' ) && ! isValidFragment( trimmedHref ) ) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Generates the format object that will be applied to the link text.\n *\n * @param {Object} options\n * @param {string} options.url The href of the link.\n * @param {string} options.type The type of the link.\n * @param {string} options.id The ID of the link.\n * @param {boolean} options.opensInNewWindow Whether this link will open in a new window.\n * @param {boolean} options.nofollow Whether this link is marked as no follow relationship.\n * @param {string} options.cssClasses The CSS classes to apply to the link.\n * @return {Object} The final format object.\n */\nexport function createLinkFormat( {\n\turl,\n\ttype,\n\tid,\n\topensInNewWindow,\n\tnofollow,\n\tcssClasses,\n} ) {\n\tconst format = {\n\t\ttype: 'core/link',\n\t\tattributes: {\n\t\t\turl,\n\t\t},\n\t};\n\n\tif ( type ) {\n\t\tformat.attributes.type = type;\n\t}\n\tif ( id ) {\n\t\tformat.attributes.id = id;\n\t}\n\n\tif ( opensInNewWindow ) {\n\t\tformat.attributes.target = '_blank';\n\t\tformat.attributes.rel = format.attributes.rel\n\t\t\t? format.attributes.rel + ' noreferrer noopener'\n\t\t\t: 'noreferrer noopener';\n\t}\n\n\tif ( nofollow ) {\n\t\tformat.attributes.rel = format.attributes.rel\n\t\t\t? format.attributes.rel + ' nofollow'\n\t\t\t: 'nofollow';\n\t}\n\n\tconst trimmedCssClasses = cssClasses?.trim();\n\n\tif ( trimmedCssClasses?.length ) {\n\t\tformat.attributes.class = trimmedCssClasses;\n\t}\n\n\treturn format;\n}\n\n/**\n * @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue\n *\n * Get the start and end boundaries of a given format from a rich text value.\n *\n * @param {RichTextValue} value the rich text value to interrogate.\n * @param {string} format the identifier for the target format (e.g. `core/link`, `core/bold`).\n * @param {number?} startIndex optional startIndex to seek from.\n * @param {number?} endIndex optional endIndex to seek from.\n * @return {Object}\tobject containing start and end values for the given format.\n */\nexport function getFormatBoundary(\n\tvalue,\n\tformat,\n\tstartIndex = value.start,\n\tendIndex = value.end\n) {\n\tconst EMPTY_BOUNDARIES = {\n\t\tstart: undefined,\n\t\tend: undefined,\n\t};\n\n\tconst { formats } = value;\n\tlet targetFormat;\n\tlet initialIndex;\n\n\tif ( ! formats?.length ) {\n\t\treturn EMPTY_BOUNDARIES;\n\t}\n\n\t// Clone formats to avoid modifying source formats.\n\tconst newFormats = formats.slice();\n\n\tconst formatAtStart = newFormats[ startIndex ]?.find(\n\t\t( { type } ) => type === format.type\n\t);\n\n\tconst formatAtEnd = newFormats[ endIndex ]?.find(\n\t\t( { type } ) => type === format.type\n\t);\n\n\tconst formatAtEndMinusOne = newFormats[ endIndex - 1 ]?.find(\n\t\t( { type } ) => type === format.type\n\t);\n\n\tif ( !! formatAtStart ) {\n\t\t// Set values to conform to \"start\"\n\t\ttargetFormat = formatAtStart;\n\t\tinitialIndex = startIndex;\n\t} else if ( !! formatAtEnd ) {\n\t\t// Set values to conform to \"end\"\n\t\ttargetFormat = formatAtEnd;\n\t\tinitialIndex = endIndex;\n\t} else if ( !! formatAtEndMinusOne ) {\n\t\t// This is an edge case which will occur if you create a format, then place\n\t\t// the caret just before the format and hit the back ARROW key. The resulting\n\t\t// value object will have start and end +1 beyond the edge of the format boundary.\n\t\ttargetFormat = formatAtEndMinusOne;\n\t\tinitialIndex = endIndex - 1;\n\t} else {\n\t\treturn EMPTY_BOUNDARIES;\n\t}\n\n\tconst index = newFormats[ initialIndex ].indexOf( targetFormat );\n\n\tconst walkingArgs = [ newFormats, initialIndex, targetFormat, index ];\n\n\t// Walk the startIndex \"backwards\" to the leading \"edge\" of the matching format.\n\tstartIndex = walkToStart( ...walkingArgs );\n\n\t// Walk the endIndex \"forwards\" until the trailing \"edge\" of the matching format.\n\tendIndex = walkToEnd( ...walkingArgs );\n\n\t// Safe guard: start index cannot be less than 0.\n\tstartIndex = startIndex < 0 ? 0 : startIndex;\n\n\t// Return the indices of the \"edges\" as the boundaries.\n\t// walkToEnd returns the last index that has the format (e.g. 10),\n\t// but rich-text APIs like applyFormat and slice expect the end to be\n\t// one position past the last character (e.g. 11), just like\n\t// String.prototype.slice. Adding 1 here so consumers don't have to.\n\treturn {\n\t\tstart: startIndex,\n\t\tend: endIndex + 1,\n\t};\n}\n\n/**\n * Walks forwards/backwards towards the boundary of a given format within an\n * array of format objects. Returns the index of the boundary.\n *\n * @param {Array} formats the formats to search for the given format type.\n * @param {number} initialIndex the starting index from which to walk.\n * @param {Object} targetFormatRef a reference to the format type object being sought.\n * @param {number} formatIndex the index at which we expect the target format object to be.\n * @param {string} direction either 'forwards' or 'backwards' to indicate the direction.\n * @return {number} the index of the boundary of the given format.\n */\nfunction walkToBoundary(\n\tformats,\n\tinitialIndex,\n\ttargetFormatRef,\n\tformatIndex,\n\tdirection\n) {\n\tlet index = initialIndex;\n\n\tconst directions = {\n\t\tforwards: 1,\n\t\tbackwards: -1,\n\t};\n\n\tconst directionIncrement = directions[ direction ] || 1; // invalid direction arg default to forwards\n\tconst inverseDirectionIncrement = directionIncrement * -1;\n\n\twhile (\n\t\tformats[ index ] &&\n\t\tformats[ index ][ formatIndex ] === targetFormatRef\n\t) {\n\t\t// Increment/decrement in the direction of operation.\n\t\tindex = index + directionIncrement;\n\t}\n\n\t// Restore by one in inverse direction of operation\n\t// to avoid out of bounds.\n\tindex = index + inverseDirectionIncrement;\n\n\treturn index;\n}\n\nconst partialRight =\n\t( fn, ...partialArgs ) =>\n\t( ...args ) =>\n\t\tfn( ...args, ...partialArgs );\n\nconst walkToStart = partialRight( walkToBoundary, 'backwards' );\n\nconst walkToEnd = partialRight( walkToBoundary, 'forwards' );\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AASA,SAAS,YAAa,MAAO;AACnC,MAAK,CAAE,MAAO;AACb,WAAO;AAAA,EACR;AAEA,QAAM,cAAc,KAAK,KAAK;AAE9B,MAAK,CAAE,aAAc;AACpB,WAAO;AAAA,EACR;AAGA,MAAK,QAAQ,KAAM,WAAY,GAAI;AAClC,UAAM,WAAW,YAAa,WAAY;AAC1C,QAAK,CAAE,gBAAiB,QAAS,GAAI;AACpC,aAAO;AAAA,IACR;AAIA,QACC,SAAS,WAAY,MAAO,KAC5B,CAAE,uBAAuB,KAAM,WAAY,GAC1C;AACD,aAAO;AAAA,IACR;AAEA,UAAM,YAAY,aAAc,WAAY;AAC5C,QAAK,CAAE,iBAAkB,SAAU,GAAI;AACtC,aAAO;AAAA,IACR;AAEA,UAAM,OAAO,QAAS,WAAY;AAClC,QAAK,QAAQ,CAAE,YAAa,IAAK,GAAI;AACpC,aAAO;AAAA,IACR;AAEA,UAAM,cAAc,eAAgB,WAAY;AAChD,QAAK,eAAe,CAAE,mBAAoB,WAAY,GAAI;AACzD,aAAO;AAAA,IACR;AAEA,UAAM,WAAW,YAAa,WAAY;AAC1C,QAAK,YAAY,CAAE,gBAAiB,QAAS,GAAI;AAChD,aAAO;AAAA,IACR;AAAA,EACD;AAGA,MAAK,YAAY,WAAY,GAAI,KAAK,CAAE,gBAAiB,WAAY,GAAI;AACxE,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAcO,SAAS,iBAAkB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAC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AAA,EAChB,WAAY,CAAC,CAAE,qBAAsB;AAIpC,mBAAe;AACf,mBAAe,WAAW;AAAA,EAC3B,OAAO;AACN,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,WAAY,YAAa,EAAE,QAAS,YAAa;AAE/D,QAAM,cAAc,CAAE,YAAY,cAAc,cAAc,KAAM;AAGpE,eAAa,YAAa,GAAG,WAAY;AAGzC,aAAW,UAAW,GAAG,WAAY;AAGrC,eAAa,aAAa,IAAI,IAAI;AAOlC,SAAO;AAAA,IACN,OAAO;AAAA,IACP,KAAK,WAAW;AAAA,EACjB;AACD;AAaA,SAAS,eACR,SACA,cACA,iBACA,aACA,WACC;AACD,MAAI,QAAQ;AAEZ,QAAM,aAAa;AAAA,IAClB,UAAU;AAAA,IACV,WAAW;AAAA,EACZ;AAEA,QAAM,qBAAqB,WAAY,SAAU,KAAK;AACtD,QAAM,4BAA4B,qBAAqB;AAEvD,SACC,QAAS,KAAM,KACf,QAAS,KAAM,EAAG,WAAY,MAAM,iBACnC;AAED,YAAQ,QAAQ;AAAA,EACjB;AAIA,UAAQ,QAAQ;AAEhB,SAAO;AACR;AAEA,IAAM,eACL,CAAE,OAAO,gBACT,IAAK,SACJ,GAAI,GAAG,MAAM,GAAG,WAAY;AAE9B,IAAM,cAAc,aAAc,gBAAgB,WAAY;AAE9D,IAAM,YAAY,aAAc,gBAAgB,UAAW;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/format-library",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.40.0",
|
|
4
4
|
"description": "Format library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -42,20 +42,20 @@
|
|
|
42
42
|
"react-native": "src/index",
|
|
43
43
|
"wpScript": true,
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@wordpress/a11y": "^4.
|
|
46
|
-
"@wordpress/base-styles": "^6.
|
|
47
|
-
"@wordpress/block-editor": "^15.
|
|
48
|
-
"@wordpress/components": "^32.2.
|
|
49
|
-
"@wordpress/compose": "^7.
|
|
50
|
-
"@wordpress/data": "^10.
|
|
51
|
-
"@wordpress/element": "^6.
|
|
52
|
-
"@wordpress/html-entities": "^4.
|
|
53
|
-
"@wordpress/i18n": "^6.
|
|
54
|
-
"@wordpress/icons": "^11.
|
|
55
|
-
"@wordpress/latex-to-mathml": "^1.
|
|
56
|
-
"@wordpress/private-apis": "^1.
|
|
57
|
-
"@wordpress/rich-text": "^7.
|
|
58
|
-
"@wordpress/url": "^4.
|
|
45
|
+
"@wordpress/a11y": "^4.40.0",
|
|
46
|
+
"@wordpress/base-styles": "^6.16.0",
|
|
47
|
+
"@wordpress/block-editor": "^15.13.0",
|
|
48
|
+
"@wordpress/components": "^32.2.0",
|
|
49
|
+
"@wordpress/compose": "^7.40.0",
|
|
50
|
+
"@wordpress/data": "^10.40.0",
|
|
51
|
+
"@wordpress/element": "^6.40.0",
|
|
52
|
+
"@wordpress/html-entities": "^4.40.0",
|
|
53
|
+
"@wordpress/i18n": "^6.13.0",
|
|
54
|
+
"@wordpress/icons": "^11.7.0",
|
|
55
|
+
"@wordpress/latex-to-mathml": "^1.8.0",
|
|
56
|
+
"@wordpress/private-apis": "^1.40.0",
|
|
57
|
+
"@wordpress/rich-text": "^7.40.0",
|
|
58
|
+
"@wordpress/url": "^4.40.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"react": "^18.0.0",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "376124aa10dbc2cc0c81c964ec00b99fcfee5382"
|
|
68
68
|
}
|
package/src/language/index.js
CHANGED
|
@@ -24,10 +24,14 @@ const title = __( 'Language' );
|
|
|
24
24
|
|
|
25
25
|
export const language = {
|
|
26
26
|
name,
|
|
27
|
+
title,
|
|
27
28
|
tagName: 'bdo',
|
|
28
29
|
className: null,
|
|
30
|
+
attributes: {
|
|
31
|
+
lang: 'lang',
|
|
32
|
+
dir: 'dir',
|
|
33
|
+
},
|
|
29
34
|
edit: Edit,
|
|
30
|
-
title,
|
|
31
35
|
};
|
|
32
36
|
|
|
33
37
|
function Edit( { isActive, value, onChange, contentRef } ) {
|
package/src/link/inline.js
CHANGED
|
@@ -5,7 +5,7 @@ import { useMemo, createInterpolateElement } from '@wordpress/element';
|
|
|
5
5
|
import { __, sprintf } from '@wordpress/i18n';
|
|
6
6
|
import { speak } from '@wordpress/a11y';
|
|
7
7
|
import { Popover } from '@wordpress/components';
|
|
8
|
-
import {
|
|
8
|
+
import { prependHTTPS } from '@wordpress/url';
|
|
9
9
|
import {
|
|
10
10
|
create,
|
|
11
11
|
insert,
|
|
@@ -122,7 +122,7 @@ function InlineLinkUI( {
|
|
|
122
122
|
...nextValue,
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
-
const newUrl =
|
|
125
|
+
const newUrl = prependHTTPS( nextValue.url );
|
|
126
126
|
const linkFormat = createLinkFormat( {
|
|
127
127
|
url: newUrl,
|
|
128
128
|
type: nextValue.type,
|
package/src/link/utils.js
CHANGED
|
@@ -133,10 +133,10 @@ export function createLinkFormat( {
|
|
|
133
133
|
return format;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
/* eslint-disable jsdoc/no-undefined-types */
|
|
137
136
|
/**
|
|
138
|
-
*
|
|
137
|
+
* @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue
|
|
139
138
|
*
|
|
139
|
+
* Get the start and end boundaries of a given format from a rich text value.
|
|
140
140
|
*
|
|
141
141
|
* @param {RichTextValue} value the rich text value to interrogate.
|
|
142
142
|
* @param {string} format the identifier for the target format (e.g. `core/link`, `core/bold`).
|
|
@@ -144,7 +144,6 @@ export function createLinkFormat( {
|
|
|
144
144
|
* @param {number?} endIndex optional endIndex to seek from.
|
|
145
145
|
* @return {Object} object containing start and end values for the given format.
|
|
146
146
|
*/
|
|
147
|
-
/* eslint-enable jsdoc/no-undefined-types */
|
|
148
147
|
export function getFormatBoundary(
|
|
149
148
|
value,
|
|
150
149
|
format,
|