@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,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import {
|
|
2
|
+
getProtocol,
|
|
3
|
+
isValidProtocol,
|
|
4
|
+
getAuthority,
|
|
5
|
+
isValidAuthority,
|
|
6
|
+
getPath,
|
|
7
|
+
isValidPath,
|
|
8
|
+
getQueryString,
|
|
9
|
+
isValidQueryString,
|
|
10
|
+
getFragment,
|
|
11
|
+
isValidFragment
|
|
12
|
+
} from "@wordpress/url";
|
|
13
|
+
function isValidHref(href) {
|
|
14
14
|
if (!href) {
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
@@ -18,17 +18,12 @@ export function isValidHref(href) {
|
|
|
18
18
|
if (!trimmedHref) {
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
// Does the href start with something that looks like a URL protocol?
|
|
23
21
|
if (/^\S+:/.test(trimmedHref)) {
|
|
24
22
|
const protocol = getProtocol(trimmedHref);
|
|
25
23
|
if (!isValidProtocol(protocol)) {
|
|
26
24
|
return false;
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
// Add some extra checks for http(s) URIs, since these are the most common use-case.
|
|
30
|
-
// This ensures URIs with an http protocol have exactly two forward slashes following the protocol.
|
|
31
|
-
if (protocol.startsWith('http') && !/^https?:\/\/[^\/\s]/i.test(trimmedHref)) {
|
|
26
|
+
if (protocol.startsWith("http") && !/^https?:\/\/[^\/\s]/i.test(trimmedHref)) {
|
|
32
27
|
return false;
|
|
33
28
|
}
|
|
34
29
|
const authority = getAuthority(trimmedHref);
|
|
@@ -48,34 +43,21 @@ export function isValidHref(href) {
|
|
|
48
43
|
return false;
|
|
49
44
|
}
|
|
50
45
|
}
|
|
51
|
-
|
|
52
|
-
// Validate anchor links.
|
|
53
|
-
if (trimmedHref.startsWith('#') && !isValidFragment(trimmedHref)) {
|
|
46
|
+
if (trimmedHref.startsWith("#") && !isValidFragment(trimmedHref)) {
|
|
54
47
|
return false;
|
|
55
48
|
}
|
|
56
49
|
return true;
|
|
57
50
|
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Generates the format object that will be applied to the link text.
|
|
61
|
-
*
|
|
62
|
-
* @param {Object} options
|
|
63
|
-
* @param {string} options.url The href of the link.
|
|
64
|
-
* @param {string} options.type The type of the link.
|
|
65
|
-
* @param {string} options.id The ID of the link.
|
|
66
|
-
* @param {boolean} options.opensInNewWindow Whether this link will open in a new window.
|
|
67
|
-
* @param {boolean} options.nofollow Whether this link is marked as no follow relationship.
|
|
68
|
-
* @return {Object} The final format object.
|
|
69
|
-
*/
|
|
70
|
-
export function createLinkFormat({
|
|
51
|
+
function createLinkFormat({
|
|
71
52
|
url,
|
|
72
53
|
type,
|
|
73
54
|
id,
|
|
74
55
|
opensInNewWindow,
|
|
75
|
-
nofollow
|
|
56
|
+
nofollow,
|
|
57
|
+
cssClasses
|
|
76
58
|
}) {
|
|
77
59
|
const format = {
|
|
78
|
-
type:
|
|
60
|
+
type: "core/link",
|
|
79
61
|
attributes: {
|
|
80
62
|
url
|
|
81
63
|
}
|
|
@@ -87,64 +69,46 @@ export function createLinkFormat({
|
|
|
87
69
|
format.attributes.id = id;
|
|
88
70
|
}
|
|
89
71
|
if (opensInNewWindow) {
|
|
90
|
-
format.attributes.target =
|
|
91
|
-
format.attributes.rel = format.attributes.rel ? format.attributes.rel +
|
|
72
|
+
format.attributes.target = "_blank";
|
|
73
|
+
format.attributes.rel = format.attributes.rel ? format.attributes.rel + " noreferrer noopener" : "noreferrer noopener";
|
|
92
74
|
}
|
|
93
75
|
if (nofollow) {
|
|
94
|
-
format.attributes.rel = format.attributes.rel ? format.attributes.rel +
|
|
76
|
+
format.attributes.rel = format.attributes.rel ? format.attributes.rel + " nofollow" : "nofollow";
|
|
77
|
+
}
|
|
78
|
+
const trimmedCssClasses = cssClasses?.trim();
|
|
79
|
+
if (trimmedCssClasses?.length) {
|
|
80
|
+
format.attributes.class = trimmedCssClasses;
|
|
95
81
|
}
|
|
96
82
|
return format;
|
|
97
83
|
}
|
|
98
|
-
|
|
99
|
-
/* eslint-disable jsdoc/no-undefined-types */
|
|
100
|
-
/**
|
|
101
|
-
* Get the start and end boundaries of a given format from a rich text value.
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* @param {RichTextValue} value the rich text value to interrogate.
|
|
105
|
-
* @param {string} format the identifier for the target format (e.g. `core/link`, `core/bold`).
|
|
106
|
-
* @param {number?} startIndex optional startIndex to seek from.
|
|
107
|
-
* @param {number?} endIndex optional endIndex to seek from.
|
|
108
|
-
* @return {Object} object containing start and end values for the given format.
|
|
109
|
-
*/
|
|
110
|
-
/* eslint-enable jsdoc/no-undefined-types */
|
|
111
|
-
export function getFormatBoundary(value, format, startIndex = value.start, endIndex = value.end) {
|
|
84
|
+
function getFormatBoundary(value, format, startIndex = value.start, endIndex = value.end) {
|
|
112
85
|
const EMPTY_BOUNDARIES = {
|
|
113
86
|
start: null,
|
|
114
87
|
end: null
|
|
115
88
|
};
|
|
116
|
-
const {
|
|
117
|
-
formats
|
|
118
|
-
} = value;
|
|
89
|
+
const { formats } = value;
|
|
119
90
|
let targetFormat;
|
|
120
91
|
let initialIndex;
|
|
121
92
|
if (!formats?.length) {
|
|
122
93
|
return EMPTY_BOUNDARIES;
|
|
123
94
|
}
|
|
124
|
-
|
|
125
|
-
// Clone formats to avoid modifying source formats.
|
|
126
95
|
const newFormats = formats.slice();
|
|
127
|
-
const formatAtStart = newFormats[startIndex]?.find(
|
|
128
|
-
type
|
|
129
|
-
|
|
130
|
-
const formatAtEnd = newFormats[endIndex]?.find(
|
|
131
|
-
type
|
|
132
|
-
|
|
133
|
-
const formatAtEndMinusOne = newFormats[endIndex - 1]?.find(
|
|
134
|
-
type
|
|
135
|
-
|
|
96
|
+
const formatAtStart = newFormats[startIndex]?.find(
|
|
97
|
+
({ type }) => type === format.type
|
|
98
|
+
);
|
|
99
|
+
const formatAtEnd = newFormats[endIndex]?.find(
|
|
100
|
+
({ type }) => type === format.type
|
|
101
|
+
);
|
|
102
|
+
const formatAtEndMinusOne = newFormats[endIndex - 1]?.find(
|
|
103
|
+
({ type }) => type === format.type
|
|
104
|
+
);
|
|
136
105
|
if (!!formatAtStart) {
|
|
137
|
-
// Set values to conform to "start"
|
|
138
106
|
targetFormat = formatAtStart;
|
|
139
107
|
initialIndex = startIndex;
|
|
140
108
|
} else if (!!formatAtEnd) {
|
|
141
|
-
// Set values to conform to "end"
|
|
142
109
|
targetFormat = formatAtEnd;
|
|
143
110
|
initialIndex = endIndex;
|
|
144
111
|
} else if (!!formatAtEndMinusOne) {
|
|
145
|
-
// This is an edge case which will occur if you create a format, then place
|
|
146
|
-
// the caret just before the format and hit the back ARROW key. The resulting
|
|
147
|
-
// value object will have start and end +1 beyond the edge of the format boundary.
|
|
148
112
|
targetFormat = formatAtEndMinusOne;
|
|
149
113
|
initialIndex = endIndex - 1;
|
|
150
114
|
} else {
|
|
@@ -152,53 +116,34 @@ export function getFormatBoundary(value, format, startIndex = value.start, endIn
|
|
|
152
116
|
}
|
|
153
117
|
const index = newFormats[initialIndex].indexOf(targetFormat);
|
|
154
118
|
const walkingArgs = [newFormats, initialIndex, targetFormat, index];
|
|
155
|
-
|
|
156
|
-
// Walk the startIndex "backwards" to the leading "edge" of the matching format.
|
|
157
119
|
startIndex = walkToStart(...walkingArgs);
|
|
158
|
-
|
|
159
|
-
// Walk the endIndex "forwards" until the trailing "edge" of the matching format.
|
|
160
120
|
endIndex = walkToEnd(...walkingArgs);
|
|
161
|
-
|
|
162
|
-
// Safe guard: start index cannot be less than 0.
|
|
163
121
|
startIndex = startIndex < 0 ? 0 : startIndex;
|
|
164
|
-
|
|
165
|
-
// // Return the indices of the "edges" as the boundaries.
|
|
166
122
|
return {
|
|
167
123
|
start: startIndex,
|
|
168
124
|
end: endIndex
|
|
169
125
|
};
|
|
170
126
|
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Walks forwards/backwards towards the boundary of a given format within an
|
|
174
|
-
* array of format objects. Returns the index of the boundary.
|
|
175
|
-
*
|
|
176
|
-
* @param {Array} formats the formats to search for the given format type.
|
|
177
|
-
* @param {number} initialIndex the starting index from which to walk.
|
|
178
|
-
* @param {Object} targetFormatRef a reference to the format type object being sought.
|
|
179
|
-
* @param {number} formatIndex the index at which we expect the target format object to be.
|
|
180
|
-
* @param {string} direction either 'forwards' or 'backwards' to indicate the direction.
|
|
181
|
-
* @return {number} the index of the boundary of the given format.
|
|
182
|
-
*/
|
|
183
127
|
function walkToBoundary(formats, initialIndex, targetFormatRef, formatIndex, direction) {
|
|
184
128
|
let index = initialIndex;
|
|
185
129
|
const directions = {
|
|
186
130
|
forwards: 1,
|
|
187
131
|
backwards: -1
|
|
188
132
|
};
|
|
189
|
-
const directionIncrement = directions[direction] || 1;
|
|
133
|
+
const directionIncrement = directions[direction] || 1;
|
|
190
134
|
const inverseDirectionIncrement = directionIncrement * -1;
|
|
191
135
|
while (formats[index] && formats[index][formatIndex] === targetFormatRef) {
|
|
192
|
-
// Increment/decrement in the direction of operation.
|
|
193
136
|
index = index + directionIncrement;
|
|
194
137
|
}
|
|
195
|
-
|
|
196
|
-
// Restore by one in inverse direction of operation
|
|
197
|
-
// to avoid out of bounds.
|
|
198
138
|
index = index + inverseDirectionIncrement;
|
|
199
139
|
return index;
|
|
200
140
|
}
|
|
201
141
|
const partialRight = (fn, ...partialArgs) => (...args) => fn(...args, ...partialArgs);
|
|
202
|
-
const walkToStart = partialRight(walkToBoundary,
|
|
203
|
-
const walkToEnd = partialRight(walkToBoundary,
|
|
204
|
-
|
|
142
|
+
const walkToStart = partialRight(walkToBoundary, "backwards");
|
|
143
|
+
const walkToEnd = partialRight(walkToBoundary, "forwards");
|
|
144
|
+
export {
|
|
145
|
+
createLinkFormat,
|
|
146
|
+
getFormatBoundary,
|
|
147
|
+
isValidHref
|
|
148
|
+
};
|
|
149
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"names":["getProtocol","isValidProtocol","getAuthority","isValidAuthority","getPath","isValidPath","getQueryString","isValidQueryString","getFragment","isValidFragment","isValidHref","href","trimmedHref","trim","test","protocol","startsWith","authority","path","queryString","fragment","createLinkFormat","url","type","id","opensInNewWindow","nofollow","format","attributes","target","rel","getFormatBoundary","value","startIndex","start","endIndex","end","EMPTY_BOUNDARIES","formats","targetFormat","initialIndex","length","newFormats","slice","formatAtStart","find","formatAtEnd","formatAtEndMinusOne","index","indexOf","walkingArgs","walkToStart","walkToEnd","walkToBoundary","targetFormatRef","formatIndex","direction","directions","forwards","backwards","directionIncrement","inverseDirectionIncrement","partialRight","fn","partialArgs","args"],"sources":["@wordpress/format-library/src/link/utils.js"],"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 * @return {Object} The final format object.\n */\nexport function createLinkFormat( {\n\turl,\n\ttype,\n\tid,\n\topensInNewWindow,\n\tnofollow,\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\treturn format;\n}\n\n/* eslint-disable jsdoc/no-undefined-types */\n/**\n * Get the start and end boundaries of a given format from a rich text value.\n *\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 */\n/* eslint-enable jsdoc/no-undefined-types */\nexport function getFormatBoundary(\n\tvalue,\n\tformat,\n\tstartIndex = value.start,\n\tendIndex = value.end\n) {\n\tconst EMPTY_BOUNDARIES = {\n\t\tstart: null,\n\t\tend: null,\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\treturn {\n\t\tstart: startIndex,\n\t\tend: endIndex,\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"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,WAAW,EACXC,eAAe,EACfC,YAAY,EACZC,gBAAgB,EAChBC,OAAO,EACPC,WAAW,EACXC,cAAc,EACdC,kBAAkB,EAClBC,WAAW,EACXC,eAAe,QACT,gBAAgB;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAAEC,IAAI,EAAG;EACnC,IAAK,CAAEA,IAAI,EAAG;IACb,OAAO,KAAK;EACb;EAEA,MAAMC,WAAW,G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AU;IACjBG,GAAG,EAAED;EACN,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASkB,cAAcA,CACtBf,OAAO,EACPE,YAAY,EACZc,eAAe,EACfC,WAAW,EACXC,SAAS,EACR;EACD,IAAIR,KAAK,GAAGR,YAAY;EAExB,MAAMiB,UAAU,GAAG;IAClBC,QAAQ,EAAE,CAAC;IACXC,SAAS,EAAE,CAAC;EACb,CAAC;EAED,MAAMC,kBAAkB,GAAGH,UAAU,CAAED,SAAS,CAAE,IAAI,CAAC,CAAC,CAAC;EACzD,MAAMK,yBAAyB,GAAGD,kBAAkB,GAAG,CAAC,CAAC;EAEzD,OACCtB,OAAO,CAAEU,KAAK,CAAE,IAChBV,OAAO,CAAEU,KAAK,CAAE,CAAEO,WAAW,CAAE,KAAKD,eAAe,EAClD;IACD;IACAN,KAAK,GAAGA,KAAK,GAAGY,kBAAkB;EACnC;;EAEA;EACA;EACAZ,KAAK,GAAGA,KAAK,GAAGa,yBAAyB;EAEzC,OAAOb,KAAK;AACb;AAEA,MAAMc,YAAY,GACjBA,CAAEC,EAAE,EAAE,GAAGC,WAAW,KACpB,CAAE,GAAGC,IAAI,KACRF,EAAE,CAAE,GAAGE,IAAI,EAAE,GAAGD,WAAY,CAAC;AAE/B,MAAMb,WAAW,GAAGW,YAAY,CAAET,cAAc,EAAE,WAAY,CAAC;AAE/D,MAAMD,SAAS,GAAGU,YAAY,CAAET,cAAc,EAAE,UAAW,CAAC","ignoreList":[]}
|
|
1
|
+
{
|
|
2
|
+
"version": 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/* eslint-disable jsdoc/no-undefined-types */\n/**\n * Get the start and end boundaries of a given format from a rich text value.\n *\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 */\n/* eslint-enable jsdoc/no-undefined-types */\nexport function getFormatBoundary(\n\tvalue,\n\tformat,\n\tstartIndex = value.start,\n\tendIndex = value.end\n) {\n\tconst EMPTY_BOUNDARIES = {\n\t\tstart: null,\n\t\tend: null,\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\treturn {\n\t\tstart: startIndex,\n\t\tend: endIndex,\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,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AAc,gBAAgB,UAAW;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from "@wordpress/private-apis";
|
|
2
|
+
const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules(
|
|
3
|
+
"I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
|
|
4
|
+
"@wordpress/format-library"
|
|
5
|
+
);
|
|
6
|
+
export {
|
|
6
7
|
lock,
|
|
7
8
|
unlock
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=lock-unlock.js.map
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=lock-unlock.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lock-unlock.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/format-library'\n\t);\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,wDAAwD;AAE1D,MAAM,EAAE,MAAM,OAAO,IAC3B;AAAA,EACC;AAAA,EACA;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const name = 'core/non-breaking-space';
|
|
9
|
-
const title = __('Non breaking space');
|
|
10
|
-
export const nonBreakingSpace = {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import { insert } from "@wordpress/rich-text";
|
|
4
|
+
import { RichTextShortcut } from "@wordpress/block-editor";
|
|
5
|
+
const name = "core/non-breaking-space";
|
|
6
|
+
const title = __("Non breaking space");
|
|
7
|
+
const nonBreakingSpace = {
|
|
11
8
|
name,
|
|
12
9
|
title,
|
|
13
|
-
tagName:
|
|
10
|
+
tagName: "nbsp",
|
|
14
11
|
className: null,
|
|
15
|
-
edit({
|
|
16
|
-
value,
|
|
17
|
-
onChange
|
|
18
|
-
}) {
|
|
12
|
+
edit({ value, onChange }) {
|
|
19
13
|
function addNonBreakingSpace() {
|
|
20
|
-
onChange(insert(value,
|
|
14
|
+
onChange(insert(value, "\xA0"));
|
|
21
15
|
}
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
return /* @__PURE__ */ jsx(
|
|
17
|
+
RichTextShortcut,
|
|
18
|
+
{
|
|
19
|
+
type: "primaryShift",
|
|
20
|
+
character: " ",
|
|
21
|
+
onUse: addNonBreakingSpace
|
|
22
|
+
}
|
|
23
|
+
);
|
|
27
24
|
}
|
|
28
25
|
};
|
|
29
|
-
|
|
26
|
+
export {
|
|
27
|
+
nonBreakingSpace
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/non-breaking-space/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { insert } from '@wordpress/rich-text';\nimport { RichTextShortcut } from '@wordpress/block-editor';\n\nconst name = 'core/non-breaking-space';\nconst title = __( 'Non breaking space' );\n\nexport const nonBreakingSpace = {\n\tname,\n\ttitle,\n\ttagName: 'nbsp',\n\tclassName: null,\n\tedit( { value, onChange } ) {\n\t\tfunction addNonBreakingSpace() {\n\t\t\tonChange( insert( value, '\\u00a0' ) );\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextShortcut\n\t\t\t\ttype=\"primaryShift\"\n\t\t\t\tcharacter=\" \"\n\t\t\t\tonUse={ addNonBreakingSpace }\n\t\t\t/>\n\t\t);\n\t},\n};\n"],
|
|
5
|
+
"mappings": "AAqBG;AAlBH,SAAS,UAAU;AACnB,SAAS,cAAc;AACvB,SAAS,wBAAwB;AAEjC,MAAM,OAAO;AACb,MAAM,QAAQ,GAAI,oBAAqB;AAEhC,MAAM,mBAAmB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAM,EAAE,OAAO,SAAS,GAAI;AAC3B,aAAS,sBAAsB;AAC9B,eAAU,OAAQ,OAAO,MAAS,CAAE;AAAA,IACrC;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,WAAU;AAAA,QACV,OAAQ;AAAA;AAAA,IACT;AAAA,EAEF;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,44 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
const name =
|
|
10
|
-
const title = __(
|
|
11
|
-
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import { toggleFormat } from "@wordpress/rich-text";
|
|
4
|
+
import {
|
|
5
|
+
RichTextToolbarButton,
|
|
6
|
+
RichTextShortcut
|
|
7
|
+
} from "@wordpress/block-editor";
|
|
8
|
+
import { formatStrikethrough } from "@wordpress/icons";
|
|
9
|
+
const name = "core/strikethrough";
|
|
10
|
+
const title = __("Strikethrough");
|
|
11
|
+
const strikethrough = {
|
|
12
12
|
name,
|
|
13
13
|
title,
|
|
14
|
-
tagName:
|
|
14
|
+
tagName: "s",
|
|
15
15
|
className: null,
|
|
16
|
-
edit({
|
|
17
|
-
isActive,
|
|
18
|
-
value,
|
|
19
|
-
onChange,
|
|
20
|
-
onFocus
|
|
21
|
-
}) {
|
|
16
|
+
edit({ isActive, value, onChange, onFocus }) {
|
|
22
17
|
function onClick() {
|
|
23
|
-
onChange(toggleFormat(value, {
|
|
24
|
-
type: name,
|
|
25
|
-
title
|
|
26
|
-
}));
|
|
18
|
+
onChange(toggleFormat(value, { type: name, title }));
|
|
27
19
|
onFocus();
|
|
28
20
|
}
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
21
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
22
|
+
/* @__PURE__ */ jsx(
|
|
23
|
+
RichTextShortcut,
|
|
24
|
+
{
|
|
25
|
+
type: "access",
|
|
26
|
+
character: "d",
|
|
27
|
+
onUse: onClick
|
|
28
|
+
}
|
|
29
|
+
),
|
|
30
|
+
/* @__PURE__ */ jsx(
|
|
31
|
+
RichTextToolbarButton,
|
|
32
|
+
{
|
|
33
|
+
icon: formatStrikethrough,
|
|
34
|
+
title,
|
|
35
|
+
onClick,
|
|
36
|
+
isActive,
|
|
37
|
+
role: "menuitemcheckbox"
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
] });
|
|
42
41
|
}
|
|
43
42
|
};
|
|
44
|
-
|
|
43
|
+
export {
|
|
44
|
+
strikethrough
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/strikethrough/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n} from '@wordpress/block-editor';\nimport { formatStrikethrough } from '@wordpress/icons';\n\nconst name = 'core/strikethrough';\nconst title = __( 'Strikethrough' );\n\nexport const strikethrough = {\n\tname,\n\ttitle,\n\ttagName: 's',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onClick() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"access\"\n\t\t\t\t\tcharacter=\"d\"\n\t\t\t\t\tonUse={ onClick }\n\t\t\t\t/>\n\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\ticon={ formatStrikethrough }\n\t\t\t\t\ttitle={ title }\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"],
|
|
5
|
+
"mappings": "AA0BG,mBACC,KADD;AAvBH,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP,SAAS,2BAA2B;AAEpC,MAAM,OAAO;AACb,MAAM,QAAQ,GAAI,eAAgB;AAE3B,MAAM,gBAAgB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAM,EAAE,UAAU,OAAO,UAAU,QAAQ,GAAI;AAC9C,aAAS,UAAU;AAClB,eAAU,aAAc,OAAO,EAAE,MAAM,MAAM,MAAM,CAAE,CAAE;AACvD,cAAQ;AAAA,IACT;AAEA,WACC,iCACC;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,MAAK;AAAA,UACL,WAAU;AAAA,UACV,OAAQ;AAAA;AAAA,MACT;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACA,MAAO;AAAA,UACP;AAAA,UACA;AAAA,UACA;AAAA,UACA,MAAK;AAAA;AAAA,MACN;AAAA,OACD;AAAA,EAEF;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,41 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const name = 'core/subscript';
|
|
10
|
-
const title = __('Subscript');
|
|
11
|
-
export const subscript = {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import { toggleFormat } from "@wordpress/rich-text";
|
|
4
|
+
import { RichTextToolbarButton } from "@wordpress/block-editor";
|
|
5
|
+
import { subscript as subscriptIcon } from "@wordpress/icons";
|
|
6
|
+
const name = "core/subscript";
|
|
7
|
+
const title = __("Subscript");
|
|
8
|
+
const subscript = {
|
|
12
9
|
name,
|
|
13
10
|
title,
|
|
14
|
-
tagName:
|
|
11
|
+
tagName: "sub",
|
|
15
12
|
className: null,
|
|
16
|
-
edit({
|
|
17
|
-
isActive,
|
|
18
|
-
value,
|
|
19
|
-
onChange,
|
|
20
|
-
onFocus
|
|
21
|
-
}) {
|
|
13
|
+
edit({ isActive, value, onChange, onFocus }) {
|
|
22
14
|
function onToggle() {
|
|
23
|
-
onChange(toggleFormat(value, {
|
|
24
|
-
type: name,
|
|
25
|
-
title
|
|
26
|
-
}));
|
|
15
|
+
onChange(toggleFormat(value, { type: name, title }));
|
|
27
16
|
}
|
|
28
17
|
function onClick() {
|
|
29
18
|
onToggle();
|
|
30
19
|
onFocus();
|
|
31
20
|
}
|
|
32
|
-
return
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
21
|
+
return /* @__PURE__ */ jsx(
|
|
22
|
+
RichTextToolbarButton,
|
|
23
|
+
{
|
|
24
|
+
icon: subscriptIcon,
|
|
25
|
+
title,
|
|
26
|
+
onClick,
|
|
27
|
+
isActive,
|
|
28
|
+
role: "menuitemcheckbox"
|
|
29
|
+
}
|
|
30
|
+
);
|
|
39
31
|
}
|
|
40
32
|
};
|
|
41
|
-
|
|
33
|
+
export {
|
|
34
|
+
subscript
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/subscript/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 { subscript as subscriptIcon } from '@wordpress/icons';\n\nconst name = 'core/subscript';\nconst title = __( 'Subscript' );\n\nexport const subscript = {\n\tname,\n\ttitle,\n\ttagName: 'sub',\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={ subscriptIcon }\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,aAAa,qBAAqB;AAE3C,MAAM,OAAO;AACb,MAAM,QAAQ,GAAI,WAAY;AAEvB,MAAM,YAAY;AAAA,EACxB;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
|
+
}
|