0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-25 05:02:57 +01:00
Commit Graph

1804 Commits

Author SHA1 Message Date
Sage Abdullah
0b45e6112c
Drop all trailing punctuations from URLs in a pasted text
This matches the common behaviour of various places, e.g. GitHub and
Slack.
2024-10-21 16:53:00 +01:00
Thibaud Colas
6b04961654
Account for terminal punctuation right after a pasted URL within text 2024-10-21 16:53:00 +01:00
Thibaud Colas
b31319934a
Add unit tests for new auto-link paste behavior 2024-10-21 16:53:00 +01:00
Thibaud Colas
ba6360446e
Add support for auto-linking URLs and emails within pasted rich text 2024-10-21 16:53:00 +01:00
Thibaud Colas
611d942c10
Refactor onPasteLink implementation to better support multi-link pasting 2024-10-21 16:53:00 +01:00
Thibaud Colas
9b6f617be1
Fix link paste detection concatenating URLs. Fix #12393 2024-10-21 16:52:59 +01:00
Matt Westcott
93f8600c31
ImageBlock for StreamField (rebase of #11791) (#12416)
Co-authored-by: Chiemezuo <chiemezuoakujobi@gmail.com>
Co-authored-by: Thibaud Colas <thibaudcolas@gmail.com>
2024-10-21 16:11:34 +01:00
Rohit Singh
105338d0d6
Fix datetime fields overflowing its parent wrapper in listing filters 2024-10-21 09:45:19 +01:00
frankyiu
97fadba582 Fix long name issue in document chooser table cell (#12430, #12431)
Fixes #12357
2024-10-20 13:47:35 +01:00
Sage Abdullah
bf139d688c
Tweak preview panel styles to accommodate more than three preview device sizes 2024-10-18 18:19:18 +01:00
Sage Abdullah
aa4ceaddd0
Remove data-default-size from preview panel
Now that the preview sizes are customizable, we can't rely on the
default being the mobile size when we want to force the size of the
preview unavailable screen.
2024-10-18 18:19:18 +01:00
Sage Abdullah
47c2c0c82e Fix color contrast of bulk actions' 'Select all' button 2024-10-17 13:33:08 +01:00
Sage Abdullah
efaa00d57c Remove action-secondary class from footer actions
It doesn't have good color contrast with the background, and these
'potentially-destructive' actions have a confirmation step anyway.
2024-10-17 13:33:08 +01:00
Sage Abdullah
5c4f83df72 Apply new footer actions styles 2024-10-17 13:33:08 +01:00
Sage Abdullah
4b54e79d7b Fix rounded border radius after closing footer actions dropdown 2024-10-17 13:33:08 +01:00
Albina
488c3583b7
'Prefers-contrast' admin theming (#12348)
Co-authored-by: Victoria Ottah <82820329+Toriasdesign@users.noreply.github.com>
2024-10-17 09:13:22 +01:00
Albina
9a7427a589
Incremental dashboard enhancements. Fix #12089 (#12233)
Co-authored-by: Thibaud Colas <thibaudcolas@gmail.com>
2024-10-14 14:39:39 +01:00
Sage Abdullah
897b0415cd Ensure form is always dirty after doing edits when forceValue is true 2024-10-11 16:33:28 +10:00
LB Johnston
9cbe1a507a Deprecate window.wagtailConfig.BULK_ACTION_ITEM_TYPE usage in JS
- Avoid using a window global and inline scripts to declare the current bulk action's item time
- Deprecate the usage of `window.wagtailConfig.BULK_ACTION_ITEM_TYPE` with a release note and code comment so that it can be removed in a future release
- Update bulk actions footer template to accept a `item_type` arg, adding this to the DOM element for access within the JavaScript
- Allow a fallback on the model name for core models (e.g. page)
- Also ensure that `{{ block.super }}` is consistently added at the top of the `{% block extra_js %}` (as it is with most usage)
- Relates to #9771 and supports a future migration for bulk actions towards Stimulus
- Relates to ongoing work for CSP compliance #1288
2024-10-08 17:55:28 +10:00
LB Johnston
39e188d040 Use correct ACTIVE_CONTENT_LOCALE name in wagtailConfig stubs
Fix up from #11166
2024-10-03 13:26:53 +10:00
LB Johnston
d80193ff30 Fix bulk controller example code in JSDoc 2024-10-03 13:26:34 +10:00
LB Johnston
3d5c20863c Clean up JSDoc on Slugify
- Ensure it's added directly above the function
- Update the description to match the options
2024-10-02 20:02:01 +10:00
Ishwari8104
f86161ba00
Ensure dropdown toggles show with border in high contrast mode
Update _dropdown.scss (#12365)
2024-09-29 16:37:38 +10:00
Sage Abdullah
3a9b975ba1 Fix UnsavedController.forceValue not immediately notifying the unsaved changes
Fixes #12355
2024-09-28 17:41:48 +10:00
Shubham
e7de2f8955 Refactor UnsavedController to use event.preventDefault() to trigger browser confirmation dialog
Per https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event

"best practice is to trigger the dialog by invoking `preventDefault()`
on the event object, while also setting `returnValue` to support legacy
cases."

We don't need to support legacy cases, as our supported browsers all
support the `preventDefault()` approach.

See also:
https://caniuse.com/mdn-api_window_beforeunload_event_preventdefault_activation

Fixes #12132

From PR #12139
2024-09-28 17:41:48 +10:00
LB Johnston
fa8fdaf72d
Simplify wagtailConfig.ts mocks in unit tests
- Avoid mock values that are already in the stub
- Only mock values that are needing to be mocked for unit tess
2024-09-25 14:45:43 -04:00
Sage Abdullah
4bb47f7e25
Move wagtailConfig values to wagtail_config template tag
The first step on cleaning up our client-side metadata configuration. With this approach, the values are computed in the `wagtail_config` template tag and passed into the template using Django's json_script.

Then, it's parsed on the client-side and set as `global.wagtailConfig` to retain compatibility with existing code that rely on `window.wagtailConfig`.

This allows us to remove our existing approach of putting metadata values in a `<script>` tag using Django templates directly in the HTML, without changing too much of the existing code, and allowing new code to import the values as `WAGTAIL_CONFIG` from `wagtailConfig.js` instead of using `window.wagtailConfig`. It also means we remove the inline script tag from the core admin base template.

Refactor wagtailConfig util

- Avoid extraneous named exports when they are included in the named WAGTAIL_CONFIG
- Simplify locale map generation
- Avoid reading from global, instead export util that can be used as a global
- Update unit tests for more robust checks
2024-09-25 14:45:09 -04:00
LB Johnston
b52ca03702
Rename wagtailConfig.js to ts file 2024-09-25 14:45:07 -04:00
LB Johnston
46947fe740
Simplify unit tests for TooltipEntity
- Avoid the entire stubbed document element being in snapshots
- Reset the JSDom each test for better snapshot usage
2024-09-25 14:21:20 -04:00
Albina
722b79d9be
Fix minimap toggle visibility (#12279)
Co-authored-by: Thibaud Colas <thibaudcolas@gmail.com>
2024-09-24 10:58:23 +01:00
Sage Abdullah
3b22cbf0a5 Fix content path links in usage view to scroll to the correct element 2024-09-24 10:52:01 +01:00
Sage Abdullah
86610560e6 Fix scrolling to anchored panels on Chromium-based browsers
On Chrome, using scrollIntoView() while elements are still being
rendered does not work as expected (i.e. it would intermittently stop
midway).

We start by using getElementById instead of selecting :target, as the
latter doesn't always yield result until the 'load' event is fired. This
does not fix the issue.

The initAnchoredPanels() function is already being called in a 'load'
event handler, so this is as late as it can be, even after the
StreamField blocks have been initialized. However, clearly this doesn't
seem to be enough.

The only solution that seems to work is to use setTimeout, and that does
not even consistently work if the delay isn't high enough for the
elements to render. For now, use 100ms as it seems to be enough in most
cases.
2024-09-24 10:52:01 +01:00
Sage Abdullah
42262484ce Fix editor crash when the URL anchor starts with a number 2024-09-24 10:52:01 +01:00
Sage Abdullah
3388f265a3 Remove ineffective code for scrolling to top on tab select
This never really had any effect. Since the new tabs and slim header
designs in v3.0, window.scrollY always equals 0 because the scroll
container is a content element rather than the window itself.

You can verify this by opening the page editor, scrolling down a bit,
and checking window.scrollY on the browser console. It will print 0,
and if you call window.scrollTo(0, 0) it does not do anything.

Even if it did work, we don't want this behaviour either, because this
would interfere with the functionality of scrolling into a panel that
is selected by the URL anchor (#).
2024-09-24 10:52:01 +01:00
sag​e
e529b5b84e
Fix content metrics plugin to work on the main element before falling back to body (#12295)
Co-authored-by: Thibaud Colas <thibaudcolas@gmail.com>
2024-09-19 08:53:12 +01:00
Sage Abdullah
e6bcfb710b Remove focus-visible fallback in preview panel code
We're dropping support for Safari 15 soon
2024-09-19 08:22:54 +10:00
Sage Abdullah
8d6d772da0 Final clean up of PreviewController and usage
Move all bind() to connect()

Add renderUrl value to use different URLs for sending vs rendering preview data

Add docstrings for PreviewController properties

Rename cleared property to ready and dispatch w-preview:ready

Add events to PreviewController update lifecycle

Use zero interval delay to disable preview auto update

Rearrange PreviewController methods to better follow the update flow

Ensure only one preview iframe has the w-preview-iframe ID at a given time

This doesn't really affect how it functions, but it's semantically more correct

Ensure runContentChecks function does not crash in tests

Only clear stale data if there is a valid stale preview available

Fix preview on Firefox by not removing the only iframe

Reorder targets and values alphabetically and add JSDoc for events

Introduce w-preview__proxy class for invisible elements in preview panel
2024-09-19 08:22:54 +10:00
Sage Abdullah
054e72b4c2 Setup main PreviewController unit tests
Test loading the last device size from localStorage

Ensure selected device size class is applied on connect

Add test for using ResizeObserver in PreviewController

Add tests for default PreviewController behaviour

Add test for opening preview in a new tab

Add test for handling a request error when opening preview in a new tab

Add test for showing the spinner when loading the preview

Add test for enforcing rendered preview width when there are errors

Split PreviewController tests into separate describe blocks

Use fake timers for all PreviewController tests

Add more detailed assertions in initializeOpenedPanel

Add assertions for setTimeout in PreviewController test

Add test for auto-update cycle

Add test for disabling auto update on panel close

Add tests for manually updating the preview

Add tests for switching preview modes

Only add the mode select element for these tests, to ensure that the
preview panel works even without it (e.g. for models that only define a
single preview mode)

Add tests for PreviewController.disconnect and for requiring the url value

Add test for assuming the first size input is the default

Add ResizeObserver test for preview controller

Reuse url variable in PreviewController tests
2024-09-19 08:22:54 +10:00
Sage Abdullah
db4e86a2c1 Rename preview-panel class to w-preview 2024-09-19 08:22:54 +10:00
Sage Abdullah
55d57be7c5 Initial migration of preview panel to Stimulus PreviewController
Initialise preview panel as a Stimulus PreviewController

Fix TypeScript issues in PreviewController

Use Stimulus targets for preview device size inputs

Use Stimulus target for preview panel new tab button

Use Stimulus target for preview panel loading spinner

Use Stimulus target for preview panel refresh button

Use Stimulus target for preview panel mode select

Use Stimulus target for preview panel iframe

Also rename the id to w-preview-iframe to follow our new conventions for
singleton elements

Rely on Stimulus to replace the iframe target

Because we copy all the attributes from the old iframe to the new one,
this means that the new iframe will also become a target. When we remove
the old iframe, the target is disconnected, and subsequent references to
this.iframeTarget should point to the new one.

Access the preview panel's parent side panel element via this.element.parentElement

Bind preview device size inputs using Stimulus data-action

Extract PreviewController.observePanelSize() method

Extract PreviewController.restoreLastSavedPreferences() method

Use Stimulus value for preview panel url

Use Stimulus value for preview panel pending update state

Move edit form and spinner timeout references into instance variables

Extract PreviewController.finishUpdate() method

Extract PreviewController.reloadIframe() method

Extract PreviewController.clearPreviewData() and setPreviewData() methods

Replace preview panel refresh button target with data-action

Extract openPreviewInNewTab method and use it via data-action

Do not close the preview tab if the data is not valid

Use Stimulus values for preview panel auto update config

Extract PreviewController.initAutoUpdate() method

Extract handlePreviewModeChange method and use it via data-action

Use Stimulus classes for preview panel unavailable and has-errors CSS classes

Use Stimulus class for preview panel selected input size

This removes the reliance of having a predefined set of classes for each
device name, making it easier to add support for custom sizes later.

The outline styles have also been updated to make use of focus-visible
when available.

Use hidden attribute for hiding preview panel spinner

Replace PreviewController isUpdating value with an updatePromise instance variable

Extract PreviewController.hasChanges() method

Extract PreviewController.checkAndUpdatePreview() method

Add default values for PreviewController values

Use ProgressController outlet for preview panel refresh button

This allows the use of the button-longrunning handling for the loading state.

Also, turn the button into an icon-only button as there might not be enough space when the panel is resized to the smallest size

Use cloneNode() instead of manually copying the attributes

Extract PreviewController.replaceIframe() and use it as the iframe's action

Extract PreviewController.sidePanelContainer instance attribute

Extract PreviewController.checksSidePanel instance attribute

Extract PreviewController.updateInterval instance attribute

Clean up PreviewController event listeners on disconnect

Extract preview panel device localStorage key into PreviewController Stimulus value

Extract preview panel's width CSS property names into Stimulus values

Disconnect preview panel ResizeObserver on controller disconnect

Use an instance variable for tracking preview availability
2024-09-19 08:22:54 +10:00
Sage Abdullah
5aa0dde2a4 Move preview-panel.js to PreviewController.ts 2024-09-19 08:22:54 +10:00
Sage Abdullah
a5b42936ec Extract setOptionalInterval util from SessionController 2024-09-19 08:22:54 +10:00
Sage Abdullah
7b67723da9 Fix error if the preview iframe does not have the userbar loaded 2024-09-19 08:22:54 +10:00
Sage Abdullah
014ffb5ce9 Ensure the side panel's show event is dispatched after any hide events
If the event is dispatched in the loop, then the show event may be
dispatched before the hide event is dispatched. For example, if you're
switching from the checks panel to the preview panel, as the preview
panel is ordered before the checks panel in the DOM.

This could cause an issue with the preview panel code, where we listen
for the show event to activate the auto update, and listen to the hide
event to deactivate it. We're listening to both the preview and checks
side panels.

Without this fix, the preview auto-update will get deactivated upon
switching from the checks panel to the preview panel, as the hide event
is dispatched after the show event.
2024-09-19 08:22:54 +10:00
Sage Abdullah
30f1115353 Fix debounce() return type to follow original function
Without typing Promise and Promise.resolve with R, it defaults to
unknown, so the R generic type can't be used.

Also, the debounced function's args should take the generic A parameter
instead of redefining it as any[].
2024-09-19 08:22:54 +10:00
Atif2077
96f8324458 Modified slugify/urlify to according to django's slug validator (#12319)
Fixes #12300
2024-09-17 13:14:51 +01:00
Matt Westcott
b3e68b69fc Upgrade puppeteer to 22.x 2024-09-06 11:46:43 +01:00
Matt Westcott
3567c15e72 Upgrade puppeteer to 21.x 2024-09-06 11:46:43 +01:00
Matt Westcott
726d4c05e1 Upgrade puppeteer to 19.x 2024-09-06 11:46:43 +01:00
Matt Westcott
83562ab03c Upgrade puppeteer to 16.x 2024-09-06 11:46:43 +01:00