Commit graph

814 commits

Author SHA1 Message Date
Arlo Breault 94c4d619a7 Add a checkbox to use the image caption as the alt text for galleries
The need for something like this was anticipated in
I2bf43c7e83283f43e047229eb53c244918fcbb0c.

As of version 2.5.0 of Parsoid's output, if alternate text is missing
for an image but a caption is present and image isn't displaying the
caption (ie. it isn't a thumb or frame), then the text content of the
caption will be set as the alt attribute.  Parsoid will then drop the
alt attribute when serializing if it matches the caption text, since
it's unnecessary.

However, if the caption is modified and the alt text isn't, the alt will
be serialized.  This is likely to be unexpected to editor.  They may
have missed that the both the caption and alt are populated in VE and
only edited one place.

Since all of the above is happening only for images where the caption
isn't visible, it doesn't appear to be a much used feature since, at
least for inline images, the experience of caption editing was already
less than optimal.

However, because of a quirk in how galleries are rendered in Parsoid,
this affects gallery caption editing, which is visible and presumably
used more often.  See T268250 for a discussion on an improved gallery
structure.  But for now, gallery images are effectively inline and set
the alternate text, thus subject to the above.

Here we add a checkbox so that the default is to ignore the alt if it's
the same as the caption.  And only make use of it if it differed
originally or was explicitly unchecked to modify.

Bug: T311677
Change-Id: Idf297d8a98995971c5835b0cea56c3317a3626e2
2022-07-22 15:46:55 -04:00
jenkins-bot b6a4f0b4fa Merge "Use generic "outline item selected" event for top-level parts" 2022-07-20 10:07:22 +00:00
jenkins-bot 28a671a48e Merge "Rename specific "parameter selected" event to be more generic" 2022-07-20 10:05:46 +00:00
jenkins-bot 18dade9ffa Merge "Rename confusing "itemSet" to "active parameter"" 2022-07-20 10:05:01 +00:00
jenkins-bot 4a3d83d087 Merge "Rename confusing "isSet" to "active page indicator"" 2022-07-20 10:04:58 +00:00
jenkins-bot 0d1f035dba Merge "Remove duplicate selection code from template dialog sidebar" 2022-07-20 10:02:07 +00:00
Thiemo Kreuz 7a59c4696a Rename confusing "itemSet" to "active parameter"
The main motivation is to get rid of the vague method name
"setParameter" that was previously used for three different methods
in three different classes. Now the three methods have three
different names.

Change-Id: I938de30b368daf6ce3385b2ed2bca98f316593e1
2022-07-20 11:42:42 +02:00
Thiemo Kreuz 4782987a7f Rename confusing "isSet" to "active page indicator"
We would love to name this state "selected", but that term is already
used for a template parameter that is checked/used. The idea of "set"
was to have a list of parameters where one is "set". But the word is
confusing. I suggest "active page" because the entire purpose of the
blue selection is to highlight the currently active page (i.e. the
one you currently interact with on the right side of the dialog) in
the sidebar.

Change-Id: I5a16ab4c193ea05c21bb3bf89ada2ef550d8d6bc
2022-07-20 09:38:41 +00:00
Thiemo Kreuz 74bffc5d0d Fix sidebar losing focus when unchecking params with space
1. Before, removePages() was calling setPage() with null. This makes
sense for removed top-level parts because these are really removed
from both sides of the dialog. Template parameters are never removed.
Only unchecked (and removed from the right side of the dialog, but
this is not what this code is about). When I navigate a parameter
list and uncheck a parameter I need the focus and highlighting to
stay.

2. We have a dedicated method when a parameter is unchecked. This
can check if the removed parameter is also the selected one (called
"set" in this code) and can reset this state. Without losing the
highlighting or anything else.

Bug: T312213
Change-Id: Ibb717ca49cae805617ebee196937c79daa72f1c1
2022-07-20 09:19:59 +00:00
Thiemo Kreuz e2cce0dd3d Minor fixes and optimizations to ParameterSelectWidget
Optimization: Don't search for a checkbox that represents a not yet
named parameter placeholder. There is never one.

Fix: Store null, not undefined.

Bug: T312213
Change-Id: I395008f15d13133ad456d0a77571b7aa1c7a7fc9
2022-07-19 16:36:30 +02:00
Thiemo Kreuz 7156cd693e Remove duplicate selection code from template dialog sidebar
Steps to reproduce:
* Set a breakpoint or debug.log() at the start of
  TransclusionOutlineWidget.setSelectionByPageName()
* Edit a multi-part template.
* Use the keyboard to navigate to a template name in the sidebar.
* Press space.

This is currently triggered twice. Let's get rid of the more obscure
one. It was introduced as part of Ic4ee673. I don't really know why.

Bug: T313207
Change-Id: I3ddc072f5d42c17249abc82026e0bf1a4be1dc6e
2022-07-19 13:06:44 +02:00
Thiemo Kreuz 60b69c575e Use generic "outline item selected" event for top-level parts
This also means we have to move the declaration/documentation of the
event up one level into the generic "part" widget.

Change-Id: I1b803201f8955b58136ee7f37c04c01edcd47395
2022-07-19 11:05:32 +00:00
Thiemo Kreuz ee7a398ffc Rename specific "parameter selected" event to be more generic
The code that receives this event does not need to know that the
source is a "parameter". It's just some "item" in the sidebar. The
idea is to reuse the event for both top-level parts as well as
parameters. This will be done in the next patch.

Change-Id: I858040f5adf8e156b6013caaa527b3237b7bac0f
2022-07-19 11:05:18 +00:00
Ed Sanders 33546466eb Add 'vector-body' hack to TargetWidgets
Bug: T313221
Change-Id: I06366d4601342435b70d311742ee985e01b0477b
2022-07-18 14:12:10 +01:00
jenkins-bot 684a69c17e Merge "Unhighlight parameter on blur" 2022-07-18 11:47:08 +00:00
jenkins-bot 458264a505 Merge "Merge redundant sidebar selection events in two-pane layout" 2022-07-18 11:38:27 +00:00
Thiemo Kreuz 569ad3d538 Remove/fix obsolete code trying to un-highlight parameters
Fix setParameter() and let it (un)highlight parameters independent
from a selection (called "set" here).

Bug: T312925
Change-Id: Ie4e9ba94659f4f70160193ca6bec804f8a4473e4
2022-07-18 13:04:42 +02:00
Adam Wight 42cbde12a8 Unhighlight parameter on blur
Bug: T312925
Change-Id: I5de5dbb5e0f9f2ae1eb8e5f2c07317cda50680ea
2022-07-18 12:59:23 +02:00
Thiemo Kreuz 58c19747da Move debounce check from outline into part widget class
This just moves code to an – in my opinion – more appropriate place.
Here we can't forget it.

Change-Id: I8fff83b1586fc14d762b324e5443611370470983
2022-07-18 12:48:45 +02:00
Thiemo Kreuz b7fb9e873f Merge redundant sidebar selection events in two-pane layout
Note how the two-pane layout was already handling the two events
identical:

 sidebarPartSelected: 'onSidebarItemSelected',
 templateParameterSelected: 'onSidebarItemSelected'

We move this knowledge up one level into the sidebar. Both actions
now trigger the same event.

This implies that we are now using the event formerly known as
"sidebarPartSelected" to act on both top-level parts as well as
parameters. We reflect this by renaming it to "sidebarItemSelected".

Change-Id: I9a2c95f91f05de7312d38ec4c8b360141a0c447d
2022-07-15 16:21:04 +00:00
Thiemo Kreuz 3f938d3c4f Rename misleading templateParameterAdded event
This is not only fired when a parameter is added. It's also fired
when pressing spacebar on a parameter that already exists.

Change-Id: I245aa9f5938eb38c3a3f224a4d642d57068cf23b
2022-07-15 14:26:41 +02:00
Thiemo Kreuz d57210c1c0 Rename misleading templateParameterSelectionChanged event
This is not only fired when a parameter is checked or unchecked.
It's also not only fired when another parameter in the parameter
SelectWidget is selected. It's always fired just because the
spacebar is pressed. This is so we can scroll that parameter into
view.

Change-Id: Id621405b7ca3116cd4a06f474e49776d0830dccc
2022-07-15 14:19:19 +02:00
jenkins-bot b4b6940c64 Merge "Minor fixes to template dialog related code documentation" 2022-07-14 07:01:11 +00:00
WMDE-Fisch a4aa684308 Don't call parent on SelectWidget focus event
This regression from Iaf089f4b271fd853b17c1aa7f5938510ea8f5431.

Not calling the parent here was is essential, because when clicking
the checkboxes this event will trigger the focus of the whole widget.

That's not what we want in this case though. Also it seems we don't
need any of the logic from the parent and can get rid of that
complexity.

Bug: T312855
Bug: T312856
Bug: T312924
Change-Id: Ib3a2eeeb6d519dfa1bb627049f6b3a4708017e86
2022-07-13 15:27:24 +02:00
Thiemo Kreuz 466a73e730 Minor fixes to template dialog related code documentation
Change-Id: I0b5e0ede45578db23ecd5817baf842eb3cc3dbf4
2022-07-12 20:10:02 +02:00
jenkins-bot 55165649c7 Merge "Document some classes touched in the sidebar rewrite" 2022-07-12 13:53:29 +00:00
jenkins-bot b736727b07 Merge "Use short syntax for transforming one event into another" 2022-07-12 11:28:06 +00:00
WMDE-Fisch ec522938b8 Scroll parameter items into view when hidden behind sticky
Triggers scroll in all situations where highlighting changes.

Including keyboard navigation.

Bug: T312542
Change-Id: I849f64c5cefe0cac3fde6e848b23b7b0cfc489ce
2022-07-12 10:52:19 +00:00
Adam Wight d77728bd4f Document some classes touched in the sidebar rewrite
Depends-On: I385dca1d95033961d3844e888521750443e49c95
Change-Id: Ic515b41863bcf2ac4daa0272f67e1d30238a4b85
2022-07-12 12:49:31 +02:00
WMDE-Fisch b75082009a Differ between setting and highlighting a parameter
Introducing a set method to have a different state for a set
parameter and a highlighted one in the selection.

Allows us to remove a lot of workarounds for missusing the
highlight state and fixes several issues with these workarounds.

Main implications:
- Keyboard navigation and mouse hover now sets the grey highlight
- If a parameter is set (blue highlight) keyboard navigation returns
  when focusing the SelectWidget
- If nothing is set keyboard navigation starts at the top after focus
- Unchecking a parameter using space will not influence the keyboard
  focus in the list
- Highlighting a parameter with the mouse lets keyboard navigation
  continue from there.

Bug: T312647
Bug: T311204
Bug: T312213
Depends-On: I385dca1d95033961d3844e888521750443e49c95
Change-Id: Iaf089f4b271fd853b17c1aa7f5938510ea8f5431
2022-07-12 10:18:56 +00:00
Thiemo Kreuz 6d41da0de7 Use short syntax for transforming one event into another
Change-Id: Id794f2b620edebd6eab71e3380ce1eeffcdc95ef
2022-07-12 11:54:04 +02:00
jenkins-bot 479732f516 Merge "Take parameter list out of tab navigation when empty" 2022-07-08 13:13:26 +00:00
Adam Wight fb81938c74 Take parameter list out of tab navigation when empty
This prevents an invisible and unactionable focus target when the
parameter search field doesn't match anything.

Bug: T312547
Change-Id: Ib29913a547cd68649d29e28d921c4c1358bad7b8
2022-07-08 13:59:37 +02:00
WMDE-Fisch 0850a205df Lessy-fying OutlineTemplateWidget rules
Also renaming one class for convenience.

Change-Id: I0ef079ca40d061f5f2cde0eafdd04737d63c370f
2022-07-08 13:33:23 +02:00
jenkins-bot 768e8517f8 Merge "Revert "Restore selection after keyboard parameter navigation"" 2022-07-07 15:14:31 +00:00
Andrew Kostka 079a1ce6ff Remove highlighting when typing in a search field
Bug: T311204
Change-Id: I583c02df3def6cfeb347e9b63045b62e1d735e24
2022-07-07 13:40:42 +00:00
Adam Wight a83d37d864 Revert "Restore selection after keyboard parameter navigation"
We don't want to restore selection.  Instead, we'll remove all
parameter selections onFocus, in a later patch.

This reverts commit 787d44af66.

Bug: T312017
Change-Id: Ia1dc8061dfd1813a58befff5adc5c3882b54d8e2
2022-07-07 15:24:11 +02:00
Adam Wight f93527e00f Scroll even if sidebar selection hasn't changed
This should be safe because selection is only set from use cases
in which we do want the sidebar scrolled to the matching item.

Bug: T290975
Change-Id: Ib0c66bb048768d633d0f638c775eba24cd652db8
2022-07-06 14:58:55 +02:00
jenkins-bot 4730987f2c Merge "Remove selection when selected parameter is unchecked" 2022-07-06 08:11:01 +00:00
WMDE-Fisch bc4fcfa04a Remove selection when selected parameter is unchecked
Adjusting some methods to support the usecase.

Bug: T312085
Change-Id: I4b97ab912f9ac0046f72167c3b573ee8e14e58d9
2022-07-05 19:22:36 +02:00
Adam Wight 787d44af66 Restore selection after keyboard parameter navigation
When blurring out of keyboard parameter navigation, the
last-selected parameter will be highlighted again.

Bug: T312017
Change-Id: I8b0fb667b44b324529d4c45c39bf21573517f989
2022-07-05 13:37:38 +02:00
Adam Wight 6c16f93504 Prevent highlighting the first parameter when clicking to remove
Tabbing into the parameter select list should highlight the first
parameter, but focusing a checkbox by clicking it to uncheck should
not trigger this highlighting.

Copied from the superclass method.

Bug: T312014
Change-Id: Ia1fd450bad4861eb2815ca21eae69ee31e40ac08
2022-07-04 15:50:56 +02:00
Adam Wight c2e111239b Reuse hard and soft action handlers
New sidebar events take a `soft` parameter allowing reuse between
"hard" and "soft" selection and parameter add.  The "hard" variant
causes a content-pane focus.

Bug: T311987
Change-Id: Ic49718840ae56eb4cfab01ce964a2fbc2d8db63b
2022-07-04 13:42:34 +02:00
WMDE-Fisch 4371c4fde2 Adding lines in doc comments
Change-Id: Ie9a8ae32b4fdf476ad607f805c91357d824474a4
2022-07-01 16:25:40 +02:00
Adam Wight 1653815e8c Rename event to be descriptive, not prescriptive
Events should be named based on what happened, not what the
side-effect will be.

Change-Id: I563db48181e1db79ca22ef2ba1e25d5186976110
2022-07-01 12:42:23 +02:00
Adam Wight d93e35a0d1 Reconnect "soft select" event
Bug: T311296
Bug: T311711
Change-Id: Ic4ee673d339ec0b4b5f54f3d7a878e3ab03f7113
2022-07-01 12:30:01 +02:00
Adam Wight d592c75623 Use short style to wire event reemission
Change-Id: Id39ecc8e96627a228c8da91628f769cab42f71bd
2022-06-30 15:55:17 +02:00
Adam Wight aa7501a8e3 Select parameters like templates
Bug: T311204
Change-Id: I61294087963f4659f065f011a2cac350cfd35dda
2022-06-30 14:23:41 +02:00
jenkins-bot df26e6f9c3 Merge "Template dialog controls default to disabled" 2022-06-30 07:28:48 +00:00
Adam Wight d32303587e Template dialog controls default to disabled
If nothing has been selected, the action buttons should be
initialized in a disabled state.

Bug: T311608
Change-Id: I32fee0d73f6e13e09dc421c944df73b79e0260bb
2022-06-30 07:55:25 +02:00