@wordpress/format-library 5.32.0 → 5.32.1-next.ff1cebbba.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bold/index.js +69 -58
- package/build/bold/index.js.map +7 -1
- package/build/code/index.js +62 -54
- package/build/code/index.js.map +7 -1
- package/build/default-formats.js +52 -24
- package/build/default-formats.js.map +7 -1
- package/build/image/index.js +185 -153
- package/build/image/index.js.map +7 -1
- package/build/index.js +28 -18
- package/build/index.js.map +7 -1
- package/build/italic/index.js +69 -58
- package/build/italic/index.js.map +7 -1
- package/build/keyboard/index.js +47 -36
- package/build/keyboard/index.js.map +7 -1
- package/build/language/index.js +145 -113
- package/build/language/index.js.map +7 -1
- package/build/link/css-classes-setting.js +81 -0
- package/build/link/css-classes-setting.js.map +7 -0
- package/build/link/index.js +162 -167
- package/build/link/index.js.map +7 -1
- package/build/link/inline.js +186 -174
- package/build/link/inline.js.map +7 -1
- package/build/link/use-link-instance-key.js +25 -19
- package/build/link/use-link-instance-key.js.map +7 -1
- package/build/link/utils.js +66 -115
- package/build/link/utils.js.map +7 -1
- package/build/lock-unlock.js +31 -15
- package/build/lock-unlock.js.map +7 -1
- package/build/non-breaking-space/index.js +44 -28
- package/build/non-breaking-space/index.js.map +7 -1
- package/build/strikethrough/index.js +57 -42
- package/build/strikethrough/index.js.map +7 -1
- package/build/subscript/index.js +47 -36
- package/build/subscript/index.js.map +7 -1
- package/build/superscript/index.js +47 -36
- package/build/superscript/index.js.map +7 -1
- package/build/text-color/index.js +102 -70
- package/build/text-color/index.js.map +7 -1
- package/build/text-color/inline.js +118 -116
- package/build/text-color/inline.js.map +7 -1
- package/build/underline/index.js +62 -40
- package/build/underline/index.js.map +7 -1
- package/build/unknown/index.js +51 -37
- package/build/unknown/index.js.map +7 -1
- package/build-module/bold/index.js +52 -52
- package/build-module/bold/index.js.map +7 -1
- package/build-module/code/index.js +41 -46
- package/build-module/code/index.js.map +7 -1
- package/build-module/default-formats.js +34 -19
- package/build-module/default-formats.js.map +7 -1
- package/build-module/image/index.js +174 -144
- package/build-module/image/index.js.map +7 -1
- package/build-module/index.js +6 -14
- package/build-module/index.js.map +7 -1
- package/build-module/italic/index.js +52 -52
- package/build-module/italic/index.js.map +7 -1
- package/build-module/keyboard/index.js +25 -30
- package/build-module/keyboard/index.js.map +7 -1
- package/build-module/language/index.js +128 -105
- package/build-module/language/index.js.map +7 -1
- package/build-module/link/css-classes-setting.js +67 -0
- package/build-module/link/css-classes-setting.js.map +7 -0
- package/build-module/link/index.js +128 -146
- package/build-module/link/index.js.map +7 -1
- package/build-module/link/inline.js +158 -154
- package/build-module/link/inline.js.map +7 -1
- package/build-module/link/use-link-instance-key.js +7 -14
- package/build-module/link/use-link-instance-key.js.map +7 -1
- package/build-module/link/utils.js +46 -101
- package/build-module/link/utils.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/non-breaking-space/index.js +22 -22
- package/build-module/non-breaking-space/index.js.map +7 -1
- package/build-module/strikethrough/index.js +38 -36
- package/build-module/strikethrough/index.js.map +7 -1
- package/build-module/subscript/index.js +25 -30
- package/build-module/subscript/index.js.map +7 -1
- package/build-module/superscript/index.js +25 -30
- package/build-module/superscript/index.js.map +7 -1
- package/build-module/text-color/index.js +72 -61
- package/build-module/text-color/index.js.map +7 -1
- package/build-module/text-color/inline.js +107 -106
- package/build-module/text-color/inline.js.map +7 -1
- package/build-module/underline/index.js +43 -34
- package/build-module/underline/index.js.map +7 -1
- package/build-module/unknown/index.js +26 -28
- package/build-module/unknown/index.js.map +7 -1
- package/build-style/style-rtl.css +0 -194
- package/build-style/style.css +0 -194
- package/package.json +21 -15
- package/src/image/style.scss +3 -0
- package/src/link/css-classes-setting.js +89 -0
- package/src/link/index.js +1 -0
- package/src/link/inline.js +19 -0
- package/src/link/style.scss +3 -0
- package/src/link/test/css-classes-setting.js +144 -0
- package/src/link/utils.js +8 -0
- package/src/style.scss +4 -4
- package/src/text-color/style.scss +2 -0
- package/build/default-formats.native.js +0 -16
- package/build/default-formats.native.js.map +0 -1
- package/build/link/index.native.js +0 -174
- package/build/link/index.native.js.map +0 -1
- package/build/link/modal-screens/link-picker-screen.native.js +0 -67
- package/build/link/modal-screens/link-picker-screen.native.js.map +0 -1
- package/build/link/modal-screens/link-settings-screen.native.js +0 -226
- package/build/link/modal-screens/link-settings-screen.native.js.map +0 -1
- package/build/link/modal-screens/screens.native.js +0 -11
- package/build/link/modal-screens/screens.native.js.map +0 -1
- package/build/link/modal.native.js +0 -53
- package/build/link/modal.native.js.map +0 -1
- package/build/text-color/index.native.js +0 -134
- package/build/text-color/index.native.js.map +0 -1
- package/build/text-color/inline.native.js +0 -150
- package/build/text-color/inline.native.js.map +0 -1
- package/build-module/default-formats.native.js +0 -10
- package/build-module/default-formats.native.js.map +0 -1
- package/build-module/link/index.native.js +0 -166
- package/build-module/link/index.native.js.map +0 -1
- package/build-module/link/modal-screens/link-picker-screen.native.js +0 -59
- package/build-module/link/modal-screens/link-picker-screen.native.js.map +0 -1
- package/build-module/link/modal-screens/link-settings-screen.native.js +0 -218
- package/build-module/link/modal-screens/link-settings-screen.native.js.map +0 -1
- package/build-module/link/modal-screens/screens.native.js +0 -5
- package/build-module/link/modal-screens/screens.native.js.map +0 -1
- package/build-module/link/modal.native.js +0 -45
- package/build-module/link/modal.native.js.map +0 -1
- package/build-module/text-color/index.native.js +0 -126
- package/build-module/text-color/index.native.js.map +0 -1
- package/build-module/text-color/inline.native.js +0 -142
- package/build-module/text-color/inline.native.js.map +0 -1
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/keyboard/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { button } from '@wordpress/icons';\n\nconst name = 'core/keyboard';\nconst title = __( 'Keyboard input' );\n\nexport const keyboard = {\n\tname,\n\ttitle,\n\ttagName: 'kbd',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ button }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"],
|
|
5
|
+
"mappings": "AA2BG;AAxBH,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AACtC,SAAS,cAAc;AAEvB,MAAM,OAAO;AACb,MAAM,QAAQ,GAAI,gBAAiB;AAE5B,MAAM,WAAW;AAAA,EACvB;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAM,EAAE,UAAU,OAAO,UAAU,QAAQ,GAAI;AAC9C,aAAS,WAAW;AACnB,eAAU,aAAc,OAAO,EAAE,MAAM,MAAM,MAAM,CAAE,CAAE;AAAA,IACxD;AAEA,aAAS,UAAU;AAClB,eAAS;AACT,cAAQ;AAAA,IACT;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA,MAAO;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,QACA,MAAK;AAAA;AAAA,IACN;AAAA,EAEF;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,119 +1,142 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
const name =
|
|
16
|
-
const title = __(
|
|
17
|
-
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import { RichTextToolbarButton } from "@wordpress/block-editor";
|
|
4
|
+
import {
|
|
5
|
+
TextControl,
|
|
6
|
+
SelectControl,
|
|
7
|
+
Button,
|
|
8
|
+
Popover,
|
|
9
|
+
__experimentalHStack as HStack,
|
|
10
|
+
__experimentalVStack as VStack
|
|
11
|
+
} from "@wordpress/components";
|
|
12
|
+
import { useState } from "@wordpress/element";
|
|
13
|
+
import { applyFormat, removeFormat, useAnchor } from "@wordpress/rich-text";
|
|
14
|
+
import { language as languageIcon } from "@wordpress/icons";
|
|
15
|
+
const name = "core/language";
|
|
16
|
+
const title = __("Language");
|
|
17
|
+
const language = {
|
|
18
18
|
name,
|
|
19
|
-
tagName:
|
|
19
|
+
tagName: "bdo",
|
|
20
20
|
className: null,
|
|
21
21
|
edit: Edit,
|
|
22
22
|
title
|
|
23
23
|
};
|
|
24
|
-
function Edit({
|
|
25
|
-
isActive,
|
|
26
|
-
value,
|
|
27
|
-
onChange,
|
|
28
|
-
contentRef
|
|
29
|
-
}) {
|
|
24
|
+
function Edit({ isActive, value, onChange, contentRef }) {
|
|
30
25
|
const [isPopoverVisible, setIsPopoverVisible] = useState(false);
|
|
31
26
|
const togglePopover = () => {
|
|
32
|
-
setIsPopoverVisible(state => !state);
|
|
27
|
+
setIsPopoverVisible((state) => !state);
|
|
33
28
|
};
|
|
34
|
-
return
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
29
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
30
|
+
/* @__PURE__ */ jsx(
|
|
31
|
+
RichTextToolbarButton,
|
|
32
|
+
{
|
|
33
|
+
icon: languageIcon,
|
|
34
|
+
label: title,
|
|
35
|
+
title,
|
|
36
|
+
onClick: () => {
|
|
37
|
+
if (isActive) {
|
|
38
|
+
onChange(removeFormat(value, name));
|
|
39
|
+
} else {
|
|
40
|
+
togglePopover();
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
isActive,
|
|
44
|
+
role: "menuitemcheckbox"
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
isPopoverVisible && /* @__PURE__ */ jsx(
|
|
48
|
+
InlineLanguageUI,
|
|
49
|
+
{
|
|
50
|
+
value,
|
|
51
|
+
onChange,
|
|
52
|
+
onClose: togglePopover,
|
|
53
|
+
contentRef
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
] });
|
|
55
57
|
}
|
|
56
|
-
function InlineLanguageUI({
|
|
57
|
-
value,
|
|
58
|
-
contentRef,
|
|
59
|
-
onChange,
|
|
60
|
-
onClose
|
|
61
|
-
}) {
|
|
58
|
+
function InlineLanguageUI({ value, contentRef, onChange, onClose }) {
|
|
62
59
|
const popoverAnchor = useAnchor({
|
|
63
60
|
editableContentElement: contentRef.current,
|
|
64
61
|
settings: language
|
|
65
62
|
});
|
|
66
|
-
const [lang, setLang] = useState(
|
|
67
|
-
const [dir, setDir] = useState(
|
|
68
|
-
return
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
63
|
+
const [lang, setLang] = useState("");
|
|
64
|
+
const [dir, setDir] = useState("ltr");
|
|
65
|
+
return /* @__PURE__ */ jsx(
|
|
66
|
+
Popover,
|
|
67
|
+
{
|
|
68
|
+
className: "block-editor-format-toolbar__language-popover",
|
|
69
|
+
anchor: popoverAnchor,
|
|
70
|
+
onClose,
|
|
71
|
+
children: /* @__PURE__ */ jsxs(
|
|
72
|
+
VStack,
|
|
73
|
+
{
|
|
74
|
+
as: "form",
|
|
75
|
+
spacing: 4,
|
|
76
|
+
className: "block-editor-format-toolbar__language-container-content",
|
|
77
|
+
onSubmit: (event) => {
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
onChange(
|
|
80
|
+
applyFormat(value, {
|
|
81
|
+
type: name,
|
|
82
|
+
attributes: {
|
|
83
|
+
lang,
|
|
84
|
+
dir
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
);
|
|
88
|
+
onClose();
|
|
89
|
+
},
|
|
90
|
+
children: [
|
|
91
|
+
/* @__PURE__ */ jsx(
|
|
92
|
+
TextControl,
|
|
93
|
+
{
|
|
94
|
+
__next40pxDefaultSize: true,
|
|
95
|
+
__nextHasNoMarginBottom: true,
|
|
96
|
+
label: title,
|
|
97
|
+
value: lang,
|
|
98
|
+
onChange: (val) => setLang(val),
|
|
99
|
+
help: __(
|
|
100
|
+
'A valid language attribute, like "en" or "fr".'
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
),
|
|
104
|
+
/* @__PURE__ */ jsx(
|
|
105
|
+
SelectControl,
|
|
106
|
+
{
|
|
107
|
+
__next40pxDefaultSize: true,
|
|
108
|
+
__nextHasNoMarginBottom: true,
|
|
109
|
+
label: __("Text direction"),
|
|
110
|
+
value: dir,
|
|
111
|
+
options: [
|
|
112
|
+
{
|
|
113
|
+
label: __("Left to right"),
|
|
114
|
+
value: "ltr"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
label: __("Right to left"),
|
|
118
|
+
value: "rtl"
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
onChange: (val) => setDir(val)
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
/* @__PURE__ */ jsx(HStack, { alignment: "right", children: /* @__PURE__ */ jsx(
|
|
125
|
+
Button,
|
|
126
|
+
{
|
|
127
|
+
__next40pxDefaultSize: true,
|
|
128
|
+
variant: "primary",
|
|
129
|
+
type: "submit",
|
|
130
|
+
text: __("Apply")
|
|
131
|
+
}
|
|
132
|
+
) })
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
);
|
|
118
138
|
}
|
|
119
|
-
|
|
139
|
+
export {
|
|
140
|
+
language
|
|
141
|
+
};
|
|
142
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 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\tedit: Edit,\n\ttitle,\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\t__nextHasNoMarginBottom\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\t__nextHasNoMarginBottom\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": "AAuCE,mBACC,KADD;AApCF,SAAS,UAAU;AAKnB,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A;AAAA,QAAC;AAAA;AAAA,UACA,IAAG;AAAA,UACH,SAAU;AAAA,UACV,WAAU;AAAA,UACV,UAAW,CAAE,UAAW;AACvB,kBAAM,eAAe;AACrB;AAAA,cACC,YAAa,OAAO;AAAA,gBACnB,MAAM;AAAA,gBACN,YAAY;AAAA,kBACX;AAAA,kBACA;AAAA,gBACD;AAAA,cACD,CAAE;AAAA,YACH;AACA,oBAAQ;AAAA,UACT;AAAA,UAEA;AAAA;AAAA,cAAC;AAAA;AAAA,gBACA,uBAAqB;AAAA,gBACrB,yBAAuB;AAAA,gBACvB,OAAQ;AAAA,gBACR,OAAQ;AAAA,gBACR,UAAW,CAAE,QAAS,QAAS,GAAI;AAAA,gBACnC,MAAO;AAAA,kBACN;AAAA,gBACD;AAAA;AAAA,YACD;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACA,uBAAqB;AAAA,gBACrB,yBAAuB;AAAA,gBACvB,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
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "@wordpress/element";
|
|
3
|
+
import { useInstanceId } from "@wordpress/compose";
|
|
4
|
+
import { __ } from "@wordpress/i18n";
|
|
5
|
+
import {
|
|
6
|
+
__experimentalInputControl as InputControl,
|
|
7
|
+
CheckboxControl,
|
|
8
|
+
VisuallyHidden,
|
|
9
|
+
__experimentalVStack as VStack
|
|
10
|
+
} from "@wordpress/components";
|
|
11
|
+
const CSSClassesSettingComponent = ({ setting, value, onChange }) => {
|
|
12
|
+
const hasValue = value ? value?.cssClasses?.length > 0 : false;
|
|
13
|
+
const [isSettingActive, setIsSettingActive] = useState(hasValue);
|
|
14
|
+
const instanceId = useInstanceId(CSSClassesSettingComponent);
|
|
15
|
+
const controlledRegionId = `css-classes-setting-${instanceId}`;
|
|
16
|
+
const handleSettingChange = (newValue) => {
|
|
17
|
+
const sanitizedValue = typeof newValue === "string" ? newValue.replace(/,/g, " ").replace(/\s+/g, " ").trim() : newValue;
|
|
18
|
+
onChange({
|
|
19
|
+
...value,
|
|
20
|
+
[setting.id]: sanitizedValue
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const handleCheckboxChange = () => {
|
|
24
|
+
if (isSettingActive) {
|
|
25
|
+
if (hasValue) {
|
|
26
|
+
handleSettingChange("");
|
|
27
|
+
}
|
|
28
|
+
setIsSettingActive(false);
|
|
29
|
+
} else {
|
|
30
|
+
setIsSettingActive(true);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return /* @__PURE__ */ jsxs("fieldset", { children: [
|
|
34
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { as: "legend", children: setting.title }),
|
|
35
|
+
/* @__PURE__ */ jsxs(VStack, { spacing: 3, children: [
|
|
36
|
+
/* @__PURE__ */ jsx(
|
|
37
|
+
CheckboxControl,
|
|
38
|
+
{
|
|
39
|
+
__nextHasNoMarginBottom: true,
|
|
40
|
+
label: setting.title,
|
|
41
|
+
onChange: handleCheckboxChange,
|
|
42
|
+
checked: isSettingActive || hasValue,
|
|
43
|
+
"aria-expanded": isSettingActive,
|
|
44
|
+
"aria-controls": isSettingActive ? controlledRegionId : void 0
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
isSettingActive && /* @__PURE__ */ jsx("div", { id: controlledRegionId, children: /* @__PURE__ */ jsx(
|
|
48
|
+
InputControl,
|
|
49
|
+
{
|
|
50
|
+
label: __("CSS classes"),
|
|
51
|
+
value: value?.cssClasses,
|
|
52
|
+
onChange: handleSettingChange,
|
|
53
|
+
help: __(
|
|
54
|
+
"Separate multiple classes with spaces."
|
|
55
|
+
),
|
|
56
|
+
__unstableInputWidth: "100%",
|
|
57
|
+
__next40pxDefaultSize: true
|
|
58
|
+
}
|
|
59
|
+
) })
|
|
60
|
+
] })
|
|
61
|
+
] });
|
|
62
|
+
};
|
|
63
|
+
var css_classes_setting_default = CSSClassesSettingComponent;
|
|
64
|
+
export {
|
|
65
|
+
css_classes_setting_default as default
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=css-classes-setting.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/link/css-classes-setting.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__experimentalInputControl as InputControl,\n\tCheckboxControl,\n\tVisuallyHidden,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\n\n/**\n * CSSClassesSettingComponent\n *\n * Presents a toggleable text input for editing link CSS classes. The input\n * is shown when the toggle is enabled or when there is already a value. When\n * toggled off and a value exists, it resets the value to an empty string.\n *\n * @param {Object} props - Component props.\n * @param {Object} props.setting - Setting configuration object.\n * @param {Object} props.value - Current link value object.\n * @param {Function} props.onChange - Callback when value changes.\n */\nconst CSSClassesSettingComponent = ( { setting, value, onChange } ) => {\n\tconst hasValue = value ? value?.cssClasses?.length > 0 : false;\n\tconst [ isSettingActive, setIsSettingActive ] = useState( hasValue );\n\tconst instanceId = useInstanceId( CSSClassesSettingComponent );\n\tconst controlledRegionId = `css-classes-setting-${ instanceId }`;\n\n\t// Sanitize user input: replace commas with spaces, collapse repeated spaces, and trim\n\tconst handleSettingChange = ( newValue ) => {\n\t\tconst sanitizedValue =\n\t\t\ttypeof newValue === 'string'\n\t\t\t\t? newValue.replace( /,/g, ' ' ).replace( /\\s+/g, ' ' ).trim()\n\t\t\t\t: newValue;\n\t\tonChange( {\n\t\t\t...value,\n\t\t\t[ setting.id ]: sanitizedValue,\n\t\t} );\n\t};\n\n\tconst handleCheckboxChange = () => {\n\t\tif ( isSettingActive ) {\n\t\t\tif ( hasValue ) {\n\t\t\t\t// Reset the value when hiding the input and a value exists.\n\t\t\t\thandleSettingChange( '' );\n\t\t\t}\n\t\t\tsetIsSettingActive( false );\n\t\t} else {\n\t\t\tsetIsSettingActive( true );\n\t\t}\n\t};\n\n\treturn (\n\t\t<fieldset>\n\t\t\t<VisuallyHidden as=\"legend\">{ setting.title }</VisuallyHidden>\n\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t<CheckboxControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ setting.title }\n\t\t\t\t\tonChange={ handleCheckboxChange }\n\t\t\t\t\tchecked={ isSettingActive || hasValue }\n\t\t\t\t\taria-expanded={ isSettingActive }\n\t\t\t\t\taria-controls={\n\t\t\t\t\t\tisSettingActive ? controlledRegionId : undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t{ isSettingActive && (\n\t\t\t\t\t<div id={ controlledRegionId }>\n\t\t\t\t\t\t<InputControl\n\t\t\t\t\t\t\tlabel={ __( 'CSS classes' ) }\n\t\t\t\t\t\t\tvalue={ value?.cssClasses }\n\t\t\t\t\t\t\tonChange={ handleSettingChange }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Separate multiple classes with spaces.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t__unstableIn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