@wordpress/block-library 9.41.1-next.v.202603161435.0 → 9.42.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.
@@ -29,8 +29,6 @@ function HTMLEditModal({
29
29
  const [editedHtml, setEditedHtml] = useState(html);
30
30
  const [editedCss, setEditedCss] = useState(css);
31
31
  const [editedJs, setEditedJs] = useState(js);
32
- const [isDirty, setIsDirty] = useState(false);
33
- const [showUnsavedWarning, setShowUnsavedWarning] = useState(false);
34
32
  const [isFullscreen, setIsFullscreen] = useState(false);
35
33
  const isMobileViewport = useViewportMatch("small", "<");
36
34
  const { canUserUseUnfilteredHTML } = useSelect((select) => {
@@ -43,18 +41,6 @@ function HTMLEditModal({
43
41
  if (!isOpen) {
44
42
  return null;
45
43
  }
46
- const handleHtmlChange = (value) => {
47
- setEditedHtml(value);
48
- setIsDirty(true);
49
- };
50
- const handleCssChange = (value) => {
51
- setEditedCss(value);
52
- setIsDirty(true);
53
- };
54
- const handleJsChange = (value) => {
55
- setEditedJs(value);
56
- setIsDirty(true);
57
- };
58
44
  const handleUpdate = () => {
59
45
  setAttributes({
60
46
  content: serializeContent({
@@ -63,25 +49,6 @@ function HTMLEditModal({
63
49
  js: canUserUseUnfilteredHTML ? editedJs : ""
64
50
  })
65
51
  });
66
- setIsDirty(false);
67
- };
68
- const handleCancel = () => {
69
- setIsDirty(false);
70
- onRequestClose();
71
- };
72
- const handleRequestClose = () => {
73
- if (isDirty) {
74
- setShowUnsavedWarning(true);
75
- } else {
76
- onRequestClose();
77
- }
78
- };
79
- const handleDiscardChanges = () => {
80
- setShowUnsavedWarning(false);
81
- onRequestClose();
82
- };
83
- const handleContinueEditing = () => {
84
- setShowUnsavedWarning(false);
85
52
  };
86
53
  const handleUpdateAndClose = () => {
87
54
  handleUpdate();
@@ -90,211 +57,166 @@ function HTMLEditModal({
90
57
  const toggleFullscreen = () => {
91
58
  setIsFullscreen((prevState) => !prevState);
92
59
  };
93
- return /* @__PURE__ */ jsxs(Fragment, { children: [
94
- /* @__PURE__ */ jsx(
95
- Modal,
96
- {
97
- title: __("Edit HTML"),
98
- onRequestClose: handleRequestClose,
99
- className: "block-library-html__modal",
100
- size: "large",
101
- isDismissible: false,
102
- shouldCloseOnClickOutside: !isDirty,
103
- shouldCloseOnEsc: !isDirty,
104
- isFullScreen: isFullscreen,
105
- __experimentalHideHeader: true,
106
- children: /* @__PURE__ */ jsx(Tabs, { orientation: "horizontal", defaultTabId: "html", children: /* @__PURE__ */ jsxs(VStack, { expanded: true, children: [
107
- /* @__PURE__ */ jsxs(
108
- HStack,
109
- {
110
- justify: "space-between",
111
- className: "block-library-html__modal-header",
112
- children: [
113
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(Tabs.TabList, { children: [
114
- /* @__PURE__ */ jsx(Tabs.Tab, { tabId: "html", children: "HTML" }),
115
- canUserUseUnfilteredHTML && /* @__PURE__ */ jsx(Tabs.Tab, { tabId: "css", children: "CSS" }),
116
- canUserUseUnfilteredHTML && /* @__PURE__ */ jsx(Tabs.Tab, { tabId: "js", children: __("JavaScript") })
117
- ] }) }),
118
- !isMobileViewport && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
119
- Button,
120
- {
121
- __next40pxDefaultSize: true,
122
- icon: isFullscreen ? square : fullscreen,
123
- label: __(
124
- "Enable/disable fullscreen"
125
- ),
126
- onClick: toggleFullscreen,
127
- variant: "tertiary"
128
- }
129
- ) })
130
- ]
131
- }
132
- ),
133
- hasRestrictedContent && /* @__PURE__ */ jsx(
134
- Notice,
135
- {
136
- status: "warning",
137
- isDismissible: false,
138
- className: "block-library-html__modal-notice",
139
- children: __(
140
- "This block contains CSS or JavaScript that will be removed when you save because you do not have permission to use unfiltered HTML."
141
- )
142
- }
143
- ),
144
- /* @__PURE__ */ jsxs(
145
- Flex,
146
- {
147
- direction: isMobileViewport ? "column" : "row",
148
- className: "block-library-html__modal-tabs",
149
- align: "stretch",
150
- gap: 8,
151
- children: [
152
- /* @__PURE__ */ jsxs("div", { className: "block-library-html__modal-content", children: [
153
- /* @__PURE__ */ jsx(
154
- Tabs.TabPanel,
155
- {
156
- tabId: "html",
157
- focusable: false,
158
- className: "block-library-html__modal-tab",
159
- children: /* @__PURE__ */ jsx(
160
- PlainText,
161
- {
162
- value: editedHtml,
163
- onChange: handleHtmlChange,
164
- placeholder: __("Write HTML\u2026"),
165
- "aria-label": __("HTML"),
166
- className: "block-library-html__modal-editor"
167
- }
168
- )
169
- }
170
- ),
171
- canUserUseUnfilteredHTML && /* @__PURE__ */ jsx(
172
- Tabs.TabPanel,
173
- {
174
- tabId: "css",
175
- focusable: false,
176
- className: "block-library-html__modal-tab",
177
- children: /* @__PURE__ */ jsx(
178
- PlainText,
179
- {
180
- value: editedCss,
181
- onChange: handleCssChange,
182
- placeholder: __("Write CSS\u2026"),
183
- "aria-label": __("CSS"),
184
- className: "block-library-html__modal-editor"
185
- }
186
- )
187
- }
60
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
61
+ Modal,
62
+ {
63
+ title: __("Edit HTML"),
64
+ onRequestClose,
65
+ className: "block-library-html__modal",
66
+ size: "large",
67
+ isDismissible: false,
68
+ shouldCloseOnClickOutside: false,
69
+ isFullScreen: isFullscreen,
70
+ __experimentalHideHeader: true,
71
+ children: /* @__PURE__ */ jsx(Tabs, { orientation: "horizontal", defaultTabId: "html", children: /* @__PURE__ */ jsxs(VStack, { expanded: true, children: [
72
+ /* @__PURE__ */ jsxs(
73
+ HStack,
74
+ {
75
+ justify: "space-between",
76
+ className: "block-library-html__modal-header",
77
+ children: [
78
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(Tabs.TabList, { children: [
79
+ /* @__PURE__ */ jsx(Tabs.Tab, { tabId: "html", children: "HTML" }),
80
+ canUserUseUnfilteredHTML && /* @__PURE__ */ jsx(Tabs.Tab, { tabId: "css", children: "CSS" }),
81
+ canUserUseUnfilteredHTML && /* @__PURE__ */ jsx(Tabs.Tab, { tabId: "js", children: __("JavaScript") })
82
+ ] }) }),
83
+ !isMobileViewport && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
84
+ Button,
85
+ {
86
+ __next40pxDefaultSize: true,
87
+ icon: isFullscreen ? square : fullscreen,
88
+ label: __(
89
+ "Enable/disable fullscreen"
188
90
  ),
189
- canUserUseUnfilteredHTML && /* @__PURE__ */ jsx(
190
- Tabs.TabPanel,
191
- {
192
- tabId: "js",
193
- focusable: false,
194
- className: "block-library-html__modal-tab",
195
- children: /* @__PURE__ */ jsx(
196
- PlainText,
197
- {
198
- value: editedJs,
199
- onChange: handleJsChange,
200
- placeholder: __(
201
- "Write JavaScript\u2026"
202
- ),
203
- "aria-label": __("JavaScript"),
204
- className: "block-library-html__modal-editor"
205
- }
206
- )
207
- }
208
- )
209
- ] }),
210
- /* @__PURE__ */ jsx("div", { className: "block-library-html__preview", children: /* @__PURE__ */ jsx(
211
- Preview,
91
+ onClick: toggleFullscreen,
92
+ variant: "tertiary"
93
+ }
94
+ ) })
95
+ ]
96
+ }
97
+ ),
98
+ hasRestrictedContent && /* @__PURE__ */ jsx(
99
+ Notice,
100
+ {
101
+ status: "warning",
102
+ isDismissible: false,
103
+ className: "block-library-html__modal-notice",
104
+ children: __(
105
+ "This block contains CSS or JavaScript that will be removed when you save because you do not have permission to use unfiltered HTML."
106
+ )
107
+ }
108
+ ),
109
+ /* @__PURE__ */ jsxs(
110
+ Flex,
111
+ {
112
+ direction: isMobileViewport ? "column" : "row",
113
+ className: "block-library-html__modal-tabs",
114
+ align: "stretch",
115
+ gap: 8,
116
+ children: [
117
+ /* @__PURE__ */ jsxs("div", { className: "block-library-html__modal-content", children: [
118
+ /* @__PURE__ */ jsx(
119
+ Tabs.TabPanel,
212
120
  {
213
- content: serializeContent({
214
- html: editedHtml,
215
- css: editedCss,
216
- js: editedJs
217
- })
121
+ tabId: "html",
122
+ focusable: false,
123
+ className: "block-library-html__modal-tab",
124
+ children: /* @__PURE__ */ jsx(
125
+ PlainText,
126
+ {
127
+ value: editedHtml,
128
+ onChange: setEditedHtml,
129
+ placeholder: __("Write HTML\u2026"),
130
+ "aria-label": __("HTML"),
131
+ className: "block-library-html__modal-editor"
132
+ }
133
+ )
218
134
  }
219
- ) })
220
- ]
221
- }
222
- ),
223
- /* @__PURE__ */ jsxs(
224
- HStack,
225
- {
226
- alignment: "center",
227
- justify: "flex-end",
228
- spacing: 4,
229
- className: "block-library-html__modal-footer",
230
- children: [
231
- /* @__PURE__ */ jsx(
232
- Button,
135
+ ),
136
+ canUserUseUnfilteredHTML && /* @__PURE__ */ jsx(
137
+ Tabs.TabPanel,
233
138
  {
234
- __next40pxDefaultSize: true,
235
- variant: "tertiary",
236
- onClick: handleCancel,
237
- children: __("Cancel")
139
+ tabId: "css",
140
+ focusable: false,
141
+ className: "block-library-html__modal-tab",
142
+ children: /* @__PURE__ */ jsx(
143
+ PlainText,
144
+ {
145
+ value: editedCss,
146
+ onChange: setEditedCss,
147
+ placeholder: __("Write CSS\u2026"),
148
+ "aria-label": __("CSS"),
149
+ className: "block-library-html__modal-editor"
150
+ }
151
+ )
238
152
  }
239
153
  ),
240
- /* @__PURE__ */ jsx(
241
- Button,
154
+ canUserUseUnfilteredHTML && /* @__PURE__ */ jsx(
155
+ Tabs.TabPanel,
242
156
  {
243
- __next40pxDefaultSize: true,
244
- variant: "primary",
245
- onClick: handleUpdateAndClose,
246
- children: __("Update")
157
+ tabId: "js",
158
+ focusable: false,
159
+ className: "block-library-html__modal-tab",
160
+ children: /* @__PURE__ */ jsx(
161
+ PlainText,
162
+ {
163
+ value: editedJs,
164
+ onChange: setEditedJs,
165
+ placeholder: __(
166
+ "Write JavaScript\u2026"
167
+ ),
168
+ "aria-label": __("JavaScript"),
169
+ className: "block-library-html__modal-editor"
170
+ }
171
+ )
247
172
  }
248
173
  )
249
- ]
250
- }
251
- )
252
- ] }) })
253
- }
254
- ),
255
- showUnsavedWarning && /* @__PURE__ */ jsxs(
256
- Modal,
257
- {
258
- title: __("Unsaved changes"),
259
- onRequestClose: handleContinueEditing,
260
- size: "medium",
261
- children: [
262
- /* @__PURE__ */ jsx("p", { children: __(
263
- "You have unsaved changes. What would you like to do?"
264
- ) }),
265
- /* @__PURE__ */ jsxs(Flex, { direction: "row", justify: "flex-end", gap: 2, children: [
266
- /* @__PURE__ */ jsx(
267
- Button,
268
- {
269
- __next40pxDefaultSize: true,
270
- variant: "secondary",
271
- onClick: handleDiscardChanges,
272
- children: __("Discard unsaved changes")
273
- }
274
- ),
275
- /* @__PURE__ */ jsx(
276
- Button,
277
- {
278
- __next40pxDefaultSize: true,
279
- variant: "secondary",
280
- onClick: handleContinueEditing,
281
- children: __("Continue editing")
282
- }
283
- ),
284
- /* @__PURE__ */ jsx(
285
- Button,
286
- {
287
- __next40pxDefaultSize: true,
288
- variant: "primary",
289
- onClick: handleUpdateAndClose,
290
- children: __("Update and close")
291
- }
292
- )
293
- ] })
294
- ]
295
- }
296
- )
297
- ] });
174
+ ] }),
175
+ /* @__PURE__ */ jsx("div", { className: "block-library-html__preview", children: /* @__PURE__ */ jsx(
176
+ Preview,
177
+ {
178
+ content: serializeContent({
179
+ html: editedHtml,
180
+ css: editedCss,
181
+ js: editedJs
182
+ })
183
+ }
184
+ ) })
185
+ ]
186
+ }
187
+ ),
188
+ /* @__PURE__ */ jsxs(
189
+ HStack,
190
+ {
191
+ alignment: "center",
192
+ justify: "flex-end",
193
+ spacing: 4,
194
+ className: "block-library-html__modal-footer",
195
+ children: [
196
+ /* @__PURE__ */ jsx(
197
+ Button,
198
+ {
199
+ __next40pxDefaultSize: true,
200
+ variant: "tertiary",
201
+ onClick: onRequestClose,
202
+ children: __("Cancel")
203
+ }
204
+ ),
205
+ /* @__PURE__ */ jsx(
206
+ Button,
207
+ {
208
+ __next40pxDefaultSize: true,
209
+ variant: "primary",
210
+ onClick: handleUpdateAndClose,
211
+ children: __("Update")
212
+ }
213
+ )
214
+ ]
215
+ }
216
+ )
217
+ ] }) })
218
+ }
219
+ ) });
298
220
  }
299
221
  export {
300
222
  HTMLEditModal as default
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/html/modal.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tModal,\n\tButton,\n\tFlex,\n\tNotice,\n\tprivateApis as componentsPrivateApis,\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { PlainText, store as blockEditorStore } from '@wordpress/block-editor';\nimport { fullscreen, square } from '@wordpress/icons';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport Preview from './preview';\nimport { parseContent, serializeContent } from './utils';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nexport default function HTMLEditModal( {\n\tisOpen,\n\tonRequestClose,\n\tcontent,\n\tsetAttributes,\n} ) {\n\t// Parse content into separate sections and use as initial state\n\tconst { html, css, js } = parseContent( content );\n\tconst [ editedHtml, setEditedHtml ] = useState( html );\n\tconst [ editedCss, setEditedCss ] = useState( css );\n\tconst [ editedJs, setEditedJs ] = useState( js );\n\tconst [ isDirty, setIsDirty ] = useState( false );\n\tconst [ showUnsavedWarning, setShowUnsavedWarning ] = useState( false );\n\tconst [ isFullscreen, setIsFullscreen ] = useState( false );\n\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\n\t// Check if user has permission to save scripts and get editor styles\n\tconst { canUserUseUnfilteredHTML } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tcanUserUseUnfilteredHTML:\n\t\t\t\tsettings.__experimentalCanUserUseUnfilteredHTML,\n\t\t};\n\t}, [] );\n\n\t// Determine if we should show a warning about CSS/JS content being stripped\n\tconst hasRestrictedContent =\n\t\t! canUserUseUnfilteredHTML && ( css.trim() || js.trim() );\n\n\tif ( ! isOpen ) {\n\t\treturn null;\n\t}\n\n\tconst handleHtmlChange = ( value ) => {\n\t\tsetEditedHtml( value );\n\t\tsetIsDirty( true );\n\t};\n\tconst handleCssChange = ( value ) => {\n\t\tsetEditedCss( value );\n\t\tsetIsDirty( true );\n\t};\n\tconst handleJsChange = ( value ) => {\n\t\tsetEditedJs( value );\n\t\tsetIsDirty( true );\n\t};\n\tconst handleUpdate = () => {\n\t\t// For users without unfiltered_html capability, strip CSS and JS content\n\t\t// to prevent kses from leaving broken content\n\t\tsetAttributes( {\n\t\t\tcontent: serializeContent( {\n\t\t\t\thtml: editedHtml,\n\t\t\t\tcss: canUserUseUnfilteredHTML ? editedCss : '',\n\t\t\t\tjs: canUserUseUnfilteredHTML ? editedJs : '',\n\t\t\t} ),\n\t\t} );\n\t\tsetIsDirty( false );\n\t};\n\tconst handleCancel = () => {\n\t\tsetIsDirty( false );\n\t\tonRequestClose();\n\t};\n\tconst handleRequestClose = () => {\n\t\tif ( isDirty ) {\n\t\t\tsetShowUnsavedWarning( true );\n\t\t} else {\n\t\t\tonRequestClose();\n\t\t}\n\t};\n\tconst handleDiscardChanges = () => {\n\t\tsetShowUnsavedWarning( false );\n\t\tonRequestClose();\n\t};\n\tconst handleContinueEditing = () => {\n\t\tsetShowUnsavedWarning( false );\n\t};\n\tconst handleUpdateAndClose = () => {\n\t\thandleUpdate();\n\t\tonRequestClose();\n\t};\n\tconst toggleFullscreen = () => {\n\t\tsetIsFullscreen( ( prevState ) => ! prevState );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<Modal\n\t\t\t\ttitle={ __( 'Edit HTML' ) }\n\t\t\t\tonRequestClose={ handleRequestClose }\n\t\t\t\tclassName=\"block-library-html__modal\"\n\t\t\t\tsize=\"large\"\n\t\t\t\tisDismissible={ false }\n\t\t\t\tshouldCloseOnClickOutside={ ! isDirty }\n\t\t\t\tshouldCloseOnEsc={ ! isDirty }\n\t\t\t\tisFullScreen={ isFullscreen }\n\t\t\t\t__experimentalHideHeader\n\t\t\t>\n\t\t\t\t<Tabs orientation=\"horizontal\" defaultTabId=\"html\">\n\t\t\t\t\t<VStack expanded>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t\t\t\tclassName=\"block-library-html__modal-header\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t\t\t\t\t<Tabs.Tab tabId=\"html\">HTML</Tabs.Tab>\n\t\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t\t<Tabs.Tab tabId=\"css\">CSS</Tabs.Tab>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t\t<Tabs.Tab tabId=\"js\">\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'JavaScript' ) }\n\t\t\t\t\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Tabs.TabList>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\tisFullscreen ? square : fullscreen\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Enable/disable fullscreen'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tonClick={ toggleFullscreen }\n\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t{ hasRestrictedContent && (\n\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-notice\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'This block contains CSS or JavaScript that will be removed when you save because you do not have permission to use unfiltered HTML.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tdirection={ isMobileViewport ? 'column' : 'row' }\n\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tabs\"\n\t\t\t\t\t\t\talign=\"stretch\"\n\t\t\t\t\t\t\tgap={ 8 }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"block-library-html__modal-content\">\n\t\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\t\ttabId=\"html\"\n\t\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tab\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t\t\t\tvalue={ editedHtml }\n\t\t\t\t\t\t\t\t\t\tonChange={ handleHtmlChange }\n\t\t\t\t\t\t\t\t\t\tplaceholder={ __( 'Write HTML\u2026' ) }\n\t\t\t\t\t\t\t\t\t\taria-label={ __( 'HTML' ) }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-editor\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\t\t\ttabId=\"css\"\n\t\t\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tab\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t\t\t\t\tvalue={ editedCss }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ handleCssChange }\n\t\t\t\t\t\t\t\t\t\t\tplaceholder={ __( 'Write CSS\u2026' ) }\n\t\t\t\t\t\t\t\t\t\t\taria-label={ __( 'CSS' ) }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-editor\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\t\t\ttabId=\"js\"\n\t\t\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tab\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t\t\t\t\tvalue={ editedJs }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ handleJsChange }\n\t\t\t\t\t\t\t\t\t\t\tplaceholder={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Write JavaScript\u2026'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\taria-label={ __( 'JavaScript' ) }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-editor\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"block-library-html__preview\">\n\t\t\t\t\t\t\t\t<Preview\n\t\t\t\t\t\t\t\t\tcontent={ serializeContent( {\n\t\t\t\t\t\t\t\t\t\thtml: editedHtml,\n\t\t\t\t\t\t\t\t\t\tcss: editedCss,\n\t\t\t\t\t\t\t\t\t\tjs: editedJs,\n\t\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\talignment=\"center\"\n\t\t\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\t\t\tspacing={ 4 }\n\t\t\t\t\t\t\tclassName=\"block-library-html__modal-footer\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\tonClick={ handleCancel }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tonClick={ handleUpdateAndClose }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Update' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</VStack>\n\t\t\t\t</Tabs>\n\t\t\t</Modal>\n\n\t\t\t{ showUnsavedWarning && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Unsaved changes' ) }\n\t\t\t\t\tonRequestClose={ handleContinueEditing }\n\t\t\t\t\tsize=\"medium\"\n\t\t\t\t>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'You have unsaved changes. What would you like to do?'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<Flex direction=\"row\" justify=\"flex-end\" gap={ 2 }>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tonClick={ handleDiscardChanges }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Discard unsaved changes' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tonClick={ handleContinueEditing }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Continue editing' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tonClick={ handleUpdateAndClose }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Update and close' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</Flex>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
5
- "mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP,SAAS,WAAW,SAAS,wBAAwB;AACrD,SAAS,YAAY,cAAc;AACnC,SAAS,wBAAwB;AAKjC,SAAS,cAAc;AACvB,OAAO,aAAa;AACpB,SAAS,cAAc,wBAAwB;AAyF7C,mBAoBO,KADD,YAnBN;AAvFF,IAAM,EAAE,KAAK,IAAI,OAAQ,qBAAsB;AAEhC,SAAR,cAAgC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AAEH,QAAM,EAAE,MAAM,KAAK,GAAG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["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tModal,\n\tButton,\n\tFlex,\n\tNotice,\n\tprivateApis as componentsPrivateApis,\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { PlainText, store as blockEditorStore } from '@wordpress/block-editor';\nimport { fullscreen, square } from '@wordpress/icons';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport Preview from './preview';\nimport { parseContent, serializeContent } from './utils';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nexport default function HTMLEditModal( {\n\tisOpen,\n\tonRequestClose,\n\tcontent,\n\tsetAttributes,\n} ) {\n\t// Parse content into separate sections and use as initial state\n\tconst { html, css, js } = parseContent( content );\n\tconst [ editedHtml, setEditedHtml ] = useState( html );\n\tconst [ editedCss, setEditedCss ] = useState( css );\n\tconst [ editedJs, setEditedJs ] = useState( js );\n\tconst [ isFullscreen, setIsFullscreen ] = useState( false );\n\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\n\t// Check if user has permission to save scripts and get editor styles\n\tconst { canUserUseUnfilteredHTML } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tcanUserUseUnfilteredHTML:\n\t\t\t\tsettings.__experimentalCanUserUseUnfilteredHTML,\n\t\t};\n\t}, [] );\n\n\t// Determine if we should show a warning about CSS/JS content being stripped\n\tconst hasRestrictedContent =\n\t\t! canUserUseUnfilteredHTML && ( css.trim() || js.trim() );\n\n\tif ( ! isOpen ) {\n\t\treturn null;\n\t}\n\n\tconst handleUpdate = () => {\n\t\t// For users without unfiltered_html capability, strip CSS and JS content\n\t\t// to prevent kses from leaving broken content\n\t\tsetAttributes( {\n\t\t\tcontent: serializeContent( {\n\t\t\t\thtml: editedHtml,\n\t\t\t\tcss: canUserUseUnfilteredHTML ? editedCss : '',\n\t\t\t\tjs: canUserUseUnfilteredHTML ? editedJs : '',\n\t\t\t} ),\n\t\t} );\n\t};\n\tconst handleUpdateAndClose = () => {\n\t\thandleUpdate();\n\t\tonRequestClose();\n\t};\n\tconst toggleFullscreen = () => {\n\t\tsetIsFullscreen( ( prevState ) => ! prevState );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<Modal\n\t\t\t\ttitle={ __( 'Edit HTML' ) }\n\t\t\t\tonRequestClose={ onRequestClose }\n\t\t\t\tclassName=\"block-library-html__modal\"\n\t\t\t\tsize=\"large\"\n\t\t\t\tisDismissible={ false }\n\t\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\t\tisFullScreen={ isFullscreen }\n\t\t\t\t__experimentalHideHeader\n\t\t\t>\n\t\t\t\t<Tabs orientation=\"horizontal\" defaultTabId=\"html\">\n\t\t\t\t\t<VStack expanded>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t\t\t\tclassName=\"block-library-html__modal-header\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t\t\t\t\t<Tabs.Tab tabId=\"html\">HTML</Tabs.Tab>\n\t\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t\t<Tabs.Tab tabId=\"css\">CSS</Tabs.Tab>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t\t<Tabs.Tab tabId=\"js\">\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'JavaScript' ) }\n\t\t\t\t\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Tabs.TabList>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\tisFullscreen ? square : fullscreen\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Enable/disable fullscreen'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tonClick={ toggleFullscreen }\n\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t{ hasRestrictedContent && (\n\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-notice\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'This block contains CSS or JavaScript that will be removed when you save because you do not have permission to use unfiltered HTML.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tdirection={ isMobileViewport ? 'column' : 'row' }\n\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tabs\"\n\t\t\t\t\t\t\talign=\"stretch\"\n\t\t\t\t\t\t\tgap={ 8 }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"block-library-html__modal-content\">\n\t\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\t\ttabId=\"html\"\n\t\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tab\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t\t\t\tvalue={ editedHtml }\n\t\t\t\t\t\t\t\t\t\tonChange={ setEditedHtml }\n\t\t\t\t\t\t\t\t\t\tplaceholder={ __( 'Write HTML\u2026' ) }\n\t\t\t\t\t\t\t\t\t\taria-label={ __( 'HTML' ) }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-editor\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\t\t\ttabId=\"css\"\n\t\t\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tab\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t\t\t\t\tvalue={ editedCss }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ setEditedCss }\n\t\t\t\t\t\t\t\t\t\t\tplaceholder={ __( 'Write CSS\u2026' ) }\n\t\t\t\t\t\t\t\t\t\t\taria-label={ __( 'CSS' ) }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-editor\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\t\t\ttabId=\"js\"\n\t\t\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tab\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t\t\t\t\tvalue={ editedJs }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ setEditedJs }\n\t\t\t\t\t\t\t\t\t\t\tplaceholder={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Write JavaScript\u2026'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\taria-label={ __( 'JavaScript' ) }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-editor\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"block-library-html__preview\">\n\t\t\t\t\t\t\t\t<Preview\n\t\t\t\t\t\t\t\t\tcontent={ serializeContent( {\n\t\t\t\t\t\t\t\t\t\thtml: editedHtml,\n\t\t\t\t\t\t\t\t\t\tcss: editedCss,\n\t\t\t\t\t\t\t\t\t\tjs: editedJs,\n\t\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\talignment=\"center\"\n\t\t\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\t\t\tspacing={ 4 }\n\t\t\t\t\t\t\tclassName=\"block-library-html__modal-footer\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\tonClick={ onRequestClose }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tonClick={ handleUpdateAndClose }\n\t\t\t\t\t\t\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IAAI;AAAA,kBACL,CAAE;AAAA;AAAA,cACH,GACD;AAAA;AAAA;AAAA,QACD;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,SAAQ;AAAA,YACR,SAAU;AAAA,YACV,WAAU;AAAA,YAEV;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACA,uBAAqB;AAAA,kBACrB,SAAQ;AAAA,kBACR,SAAU;AAAA,kBAER,aAAI,QAAS;AAAA;AAAA,cAChB;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACA,uBAAqB;AAAA,kBACrB,SAAQ;AAAA,kBACR,SAAU;AAAA,kBAER,aAAI,QAAS;AAAA;AAAA,cAChB;AAAA;AAAA;AAAA,QACD;AAAA,SACD,GACD;AAAA;AAAA,EACD,GACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -11,9 +11,6 @@
11
11
  "type": "string",
12
12
  "role": "content"
13
13
  },
14
- "textAlign": {
15
- "type": "string"
16
- },
17
14
  "format": {
18
15
  "type": "string"
19
16
  },
@@ -46,6 +43,7 @@
46
43
  "typography": {
47
44
  "fontSize": true,
48
45
  "lineHeight": true,
46
+ "textAlign": true,
49
47
  "__experimentalFontFamily": true,
50
48
  "__experimentalFontWeight": true,
51
49
  "__experimentalFontStyle": true,
@@ -1,6 +1,80 @@
1
1
  // packages/block-library/src/post-date/deprecated.js
2
2
  import clsx from "clsx";
3
3
  import migrateFontFamily from "../utils/migrate-font-family.mjs";
4
+ import migrateTextAlign from "../utils/migrate-text-align.mjs";
5
+ var v4 = {
6
+ attributes: {
7
+ datetime: {
8
+ type: "string",
9
+ role: "content"
10
+ },
11
+ textAlign: {
12
+ type: "string"
13
+ },
14
+ format: {
15
+ type: "string"
16
+ },
17
+ isLink: {
18
+ type: "boolean",
19
+ default: false,
20
+ role: "content"
21
+ }
22
+ },
23
+ supports: {
24
+ anchor: true,
25
+ html: false,
26
+ color: {
27
+ gradients: true,
28
+ link: true,
29
+ __experimentalDefaultControls: {
30
+ background: true,
31
+ text: true,
32
+ link: true
33
+ }
34
+ },
35
+ spacing: {
36
+ margin: true,
37
+ padding: true
38
+ },
39
+ typography: {
40
+ fontSize: true,
41
+ lineHeight: true,
42
+ __experimentalFontFamily: true,
43
+ __experimentalFontWeight: true,
44
+ __experimentalFontStyle: true,
45
+ __experimentalTextTransform: true,
46
+ __experimentalTextDecoration: true,
47
+ __experimentalLetterSpacing: true,
48
+ __experimentalDefaultControls: {
49
+ fontSize: true
50
+ }
51
+ },
52
+ interactivity: {
53
+ clientNavigation: true
54
+ },
55
+ __experimentalBorder: {
56
+ radius: true,
57
+ color: true,
58
+ width: true,
59
+ style: true,
60
+ __experimentalDefaultControls: {
61
+ radius: true,
62
+ color: true,
63
+ width: true,
64
+ style: true
65
+ }
66
+ }
67
+ },
68
+ save() {
69
+ return null;
70
+ },
71
+ migrate: migrateTextAlign,
72
+ isEligible(attributes) {
73
+ return !!attributes.textAlign || !!attributes.className?.match(
74
+ /\bhas-text-align-(left|center|right)\b/
75
+ );
76
+ }
77
+ };
4
78
  var v3 = {
5
79
  attributes: {
6
80
  datetime: {
@@ -79,7 +153,7 @@ var v3 = {
79
153
  },
80
154
  ...otherAttributes
81
155
  }) {
82
- return {
156
+ return migrateTextAlign({
83
157
  metadata: {
84
158
  bindings: {
85
159
  datetime: {
@@ -91,7 +165,7 @@ var v3 = {
91
165
  ...otherMetadata
92
166
  },
93
167
  ...otherAttributes
94
- };
168
+ });
95
169
  },
96
170
  isEligible(attributes) {
97
171
  return attributes?.metadata?.bindings?.datetime?.source === "core/post-data" && !!attributes?.metadata?.bindings?.datetime?.args?.key;
@@ -170,7 +244,7 @@ var v2 = {
170
244
  "wp-block-post-date__modified-date"
171
245
  );
172
246
  }
173
- return {
247
+ return migrateTextAlign({
174
248
  ...otherAttributes,
175
249
  className,
176
250
  metadata: {
@@ -182,7 +256,7 @@ var v2 = {
182
256
  }
183
257
  }
184
258
  }
185
- };
259
+ });
186
260
  }
187
261
  },
188
262
  isEligible(attributes) {
@@ -221,12 +295,14 @@ var v1 = {
221
295
  save() {
222
296
  return null;
223
297
  },
224
- migrate: migrateFontFamily,
298
+ migrate(attributes) {
299
+ return migrateTextAlign(migrateFontFamily(attributes));
300
+ },
225
301
  isEligible({ style }) {
226
302
  return style?.typography?.fontFamily;
227
303
  }
228
304
  };
229
- var deprecated_default = [v3, v2, v1];
305
+ var deprecated_default = [v4, v3, v2, v1];
230
306
  export {
231
307
  deprecated_default as default
232
308
  };