Commit graph

817 commits

Author SHA1 Message Date
jenkins-bot 6a7da15fe5 Merge "Support the upcoming mw:File typeof" 2022-06-14 15:25:11 +00:00
jenkins-bot 888f346909 Merge "Change TransclusionModel.nextUniquePartId() to return a string" 2022-06-14 08:30:09 +00:00
jenkins-bot 3162a007c6 Merge "Change template model to not merge conflicting aliased parameters" 2022-06-13 12:27:33 +00:00
jenkins-bot f79cecc32e Merge "Remove/update template related comments that just repeat the code" 2022-06-13 12:26:01 +00:00
Arlo Breault 0533f49fd5 Support the upcoming mw:File typeof
The "mediaClass" property now only serves to capture the original class
found on the media so that it can be roundtripped without causing dirty
diffs.  In the 2.4.0 version of Parsoid's output, that will still be
the usual Image/Audio/Video.  As of 2.5.0, it will always be File and
the mediaClass property can be dropped.

Parsoid is currently forward compatible with serializing mw:File, so
edited or new media can use that type already.

The contextmenu item for media has been updated to make use of the
"mediaTag" instead of mediaClass to continue distinguishing media types.
That was the only place a grep of mediaClass turned up any use.

Bug: T273505
Change-Id: If5dc6b794dacd6973d3b2093e6b385591b91d539
2022-06-10 14:29:31 -04:00
Thiemo Kreuz 4c7167b571 Change template model to not merge conflicting aliased parameters
Before the (intentional) design decision was to not do anything special
when the same parameter is used multiple times (via aliases). Garbage
in, garbage out. Only the first usage of the parameter would work as
intended. The rest was ignored and subsequently removed from the
wikitext.

New design decision: Track and display duplicates as they appear in the
wikitext.

Notes:
* It's not possible to create such a situation in VE. Do this via
  wikitext.
* Labels will be made distinguishable via T309198.
* Possible warning messages will be added later.
* The behavior when unchecking a duplicate will be specified later.

Bug: T309198
Bug: T310248
Change-Id: I6011344638cdad8529d8f57513ef51b5237eb878
2022-06-09 09:26:41 +00:00
Arlo Breault d8bbed42ec Get rid of figure-inline compatibility
Parsoid stopped emitting figure-inline in content version 2.2.0 and VE
requests 2.4.0, which isn't satisfied by the earlier versions.

Change-Id: I5f47fbe85fdca7fe429952709b62f5d1cc548daf
2022-06-07 14:39:09 -04:00
Thiemo Kreuz 64005eb41a Fix template dialog sometimes deleting unrelated params
The previous comment was true, but we forgot another edge-case. The
same parameter can appear multiple times. The old code tried to
delete it 2 times, which deleted something else.

Note that the behavior for duplicates is larely unspecified. We
will work on this soon. This is only a first quick step to fix this
specific bug.

Bug: T309203
Change-Id: If0afb2c19626c3d9db0d109d6559ae74698ed378
2022-05-25 16:01:44 +02:00
Ed Sanders 5d060c34cc GalleryImageNode: Handle broken images
Most of this logic copied from MWBlockImageNode.

Change-Id: I92c860c53741c5ee48c8bce216987d97a92bc05f
2022-05-23 15:29:42 +01:00
Ed Sanders 0aa4ee1356 ve.dm.MWGalleryImageNode: Add width/height attributes back to images
These aren't used by Parsoid but help with rendering.

Change-Id: Ifff3be45ab2046ee32f0665285581c1013102dfe
2022-05-23 14:55:06 +01:00
Ed Sanders c64f5a78cf MWImageNode: Skip empty change descriptions
As in parent method.

Change-Id: I320d5d7a8b2f5f7c7e2715c95cbc943533c8b335
2022-05-21 04:09:41 +02:00
Ed Sanders fb1ed9e700 MWGalleryImageNode: Avoid converting altText from null to ''
Bug: T308747
Change-Id: Icd811a6baaa2213d8615bdcb3690d26aa35ab302
2022-05-21 04:09:41 +02:00
Ed Sanders f4a7dfa059 Improve visual diff of gallery when image replaced
* Implement ve.dm.MWGalleryImageNode.static.isDiffComparable to
  match ve.dm.MWImageNode, in that images with different resources
  are not compared.
* Diff galleries as documents so remove/inserts are rendered.

Bug: T308747
Change-Id: Ide6f4110e65cad7f6bb6d13766815413602fd991
2022-05-21 04:09:41 +02:00
Ed Sanders 184106418e Update VE core submodule to master (86de64d69)
New changes:
72bd71dbc Localisation updates from https://translatewiki.net.
b7f38d993 Re-apply "Fix for showing "invisible icon" when root node is hidden""

Local changes:
* Ensure templates are attached to DOM before rendering invisible
  icon in converter hack.

Bug: T305110
Change-Id: I0e4c02619b2a06b9932f214ae482093fdb0cb22c
2022-04-20 23:45:31 +01:00
Thiemo Kreuz c72d8abdc3 Remove/update template related comments that just repeat the code
Such comments don't add any new information. The method signature
alone already tells the full story.

We did this already to a lot of the template related code we touched.
This is just a bit of cleanup to make it consistent.

Change-Id: I932b620910924a16dc0d31d6c8a3ab11818316fe
2022-04-19 13:58:32 +02:00
Thiemo Kreuz d59a4366db Change TransclusionModel.nextUniquePartId() to return a string
The numeric part of these ids is never used on it's own. There is no
need to expose it.

Note we renamed the method not long ago in I6eeab8b to reflect better
what it does. This is the next step. We just forgot it back then.

Change-Id: I5da82855e99ea3a42a5d91379c6974ae9c154518
2022-04-19 13:48:30 +02:00
jenkins-bot 2daec32db2 Merge "Use boolean RegExp.test() instead of .match() where possible" 2022-03-31 21:20:44 +00:00
Bartosz Dziewoński 130f3e80fc Update VE core submodule to master (38b8213b5)
New changes:
91a762803 ve.dm.ModelRegistry: Disallow unknown types on tag and tag+func matches
8575e8ad8 PreviewElement: Document event
d24f96874 Allow unknown types for ve.dm.AlienMetaItem
106354b38 Follow-up I534ce003d: Fix height restriction calculation of desktop context

Local changes:
* Allow unknown types for ve.dm.MWExternalLinkAnnotation, it is meant
  to match all <a> tags and handles unknown types in toDataElement()

Depends-On: I785be75f389136769084a8e14832a09e3a519fc1
Bug: T303298
Bug: T304847
Change-Id: I75d1e82a43f5f96a9093cd334c524527918efaa5
2022-03-31 13:01:51 +02:00
Thiemo Kreuz c8af207681 Use boolean RegExp.test() instead of .match() where possible
.test() is the dedicated syntax for a boolean "does match? yes/no?"
check. .match() returns an array of matches, or null. This is just not
needed in these situations.

Change-Id: Ibb996ab843d1a6c7d7af98d6a112990665d543b2
2022-03-24 11:04:43 +01:00
Arlo Breault dfa1c315bb Preserve classes on broken media elements
A class, mw-broken-media, was added in
I92359048b42d32fe8a0f2cb79cd348cf5f2c56cc

Bug: T304010
Bug: T270150
Change-Id: I542d7d879868c9030ce00b2686cdfd0077e49491
2022-03-21 17:42:39 -04:00
Arlo Breault 79120fc16c Preserve classes on media wrapper links
Parsoid added a class and, without it, we get selser complaining
about wrappers being modified, similar to T214649.

The "image" class is removed since Parsoid never added it (although it
now has "mw-file-description" for a similar purpose) and the legacy
parser doesn't apply it indiscriminately.

It doesn't seem like VE supports editing the |link= media option; it
just tries to roundtrip what's there and drops it on edit.  The patch
here works with that limitation.

Galleries are found to drop href's, breaking selser, and should be fixed
in a follow up.

Bug: T292657
Bug: T303469
Change-Id: I92359048b42d32fe8a0f2cb79cd348cf5f2c56cc
2022-03-10 10:41:14 -05:00
David Lynch d09c241549 MWEntityNode: Remove now-unnecessary allowedRdfaTypes
This was added back in 2020 so mw:DisplaySpace would work while the
RESTBase cache still contained old data. It's been two years, it should
be good now.

Follow-up to ed3579245e

Change-Id: I65665231b78198633682d52c48068c89807df55e
2022-03-08 11:27:29 -06:00
jenkins-bot 839a62829d Merge "Add and fix default values in parameter documentation" 2022-02-21 13:41:51 +00:00
Thiemo Kreuz bc0a34b0ed Add and fix default values in parameter documentation
Same random finds while working on something else. I carefully
checked and made sure these methods are actually called without the
optional parameter.

Change-Id: Iab36fd130258322985b5d6e7f8e1f7b4ee235ba2
2022-02-21 13:19:21 +00:00
Thiemo Kreuz 58e27f56d6 Remove not needed self = this indirections
These are only needed when we need to access a specific `this` from
within another `function () {}` context. This is not the case in the
situations here.

This is split from Ibf25d7e to make it smaller and easier to argue
about.

Change-Id: Ide1476de91fc343aa992ad92a1321d3a38b06dd0
2022-02-21 10:52:24 +01:00
Ed Sanders b80b09f88a Ignore originalWidth/Height when diffing images
Change-Id: Ieec25165a61df8f89e18c01ca4fdf70ac882eb52
2022-01-26 14:51:52 +00:00
jenkins-bot 8e5de75d12 Merge "MWImage: Fix handling of error-image dimensions" 2022-01-22 01:07:39 +00:00
jenkins-bot 7fe6ce8701 Merge "Broken image: Fix DM HTML for preview to include redlink text" 2022-01-22 01:07:36 +00:00
jenkins-bot 06a9074c44 Merge "MWImage: Cache dataElement.attributes" 2022-01-22 01:07:34 +00:00
Ed Sanders 63603e0cba MWImage: Fix handling of error-image dimensions
Change-Id: Ic808930bbd49bab779bd2ed174e6ec2408d51554
2022-01-19 00:51:39 +00:00
Ed Sanders 658a08bc30 Broken image: Fix DM HTML for preview to include redlink text
Bug: T265655
Change-Id: I1283975fdafb219ae2b0c703ecf7c7b23bb0c067
2022-01-19 00:51:39 +00:00
Ed Sanders 64fa1d909f MWImage: Cache dataElement.attributes
Change-Id: I24a4d436a00e6300bf4234153188d02fd648f9ce
2022-01-19 00:51:39 +00:00
Ed Sanders 2dd810da85 Image model: Clear originalWidth/originalHeight attributes when changing source
Bug: T269035
Change-Id: I52e5e7fd46ce86a2190b9ef5484898f741105646
2022-01-17 15:32:30 +00:00
Thiemo Kreuz 454dc53126 Give getUniquePartId method a better name
It's not a getter, but a generator. I found the name confusing.
Getters typically don't return something different every time you
call them.

Change-Id: I6eeab8b6a8644e430003f6e1ad77ab4b28e0d8c9
2021-12-22 13:03:01 +01:00
Ed Sanders 5c0344aeda Use new select[First|Last]SelectableContentOffset methods
* Make ve.ce.MWBlockImageNode autofocus=false, remove
  unused transition property
* Remove ignoreChildren from ve.dm.MWBlockImageNode
  based on new definition
* Remove tests which assert that deleting in a list next
  to a block image always de-indents. If this is desired
  behaviour it should be fixed without reference to
  ignoreChildren.

Bug: T295905
Depends-On: Idc0cccbe73d1b49d07b60c14a192a40f47d64608
Change-Id: Ib79a070f5d36dbe7742fa0760f8cdf55fe3046ed
2021-12-08 15:53:35 +00:00
jenkins-bot a932e5b6b3 Merge "Fix/cleanup template dialog methods dealing with parts vs. items" 2021-10-25 10:02:04 +00:00
jenkins-bot c9222cf111 Merge "Fix strange dialog title when using subst:" 2021-10-25 09:12:13 +00:00
jenkins-bot 6484f8dad3 Merge "Rework all code using template type related conditions" 2021-10-25 08:55:32 +00:00
jenkins-bot db07d0c290 Merge "Move var declarations inline" 2021-10-22 19:40:49 +00:00
Thiemo Kreuz 29ef00fa29 Rework all code using template type related conditions
This is a more radical change, compared to the previous patch.
I will post more detailled explanations as comments on Gerrit.

Change-Id: I6909b3f0b2c153b7ee9995441e995ffa793eab40
2021-10-22 10:42:16 +00:00
Isabelle Hurbain-Palatin 3a3437007a Handle annotation tags as nodes rather than metaitems.
Preserve the place of annotation meta tags; adds information for the
users about annotation and, if necessary, annotation range extension.
The messages and individual handling of annotations for the annotation
range can be defined by the extensions: see I0b58a418 for an example
of how that can look like.

The structure of this patch closely follows the one from I104e7abbd
(handling of <noinclude> et al.).

Bug: T261181
Change-Id: I39029e4a63d22b37107edec066006557bcff34bf
2021-10-21 10:39:04 +02:00
Ed Sanders abcd8428fa Fix rendering of render-less templates in preview snippets
The signature of createInvisibleIcon was changed but this
was never updated.

This fixes invisible template renderings inside previews, e.g.
inside the reference context item for:
<ref>{{InvisibleTemplate}} Content</ref>

Change-Id: I3d1b7a177408032957ac3fa8ead813438aa6bda7
2021-10-19 15:32:00 +01:00
Ed Sanders 295d139ef1 Minor documentation fixes
Change-Id: I6822c04c8d160431510e62752783e6829950dc36
2021-10-13 14:02:57 +01:00
Ed Sanders 3801aa1bac Move var declarations inline
Change-Id: I12639c515e33b3d9e7a819581b5022ea42fd7046
2021-10-13 14:02:31 +01:00
Bartosz Dziewoński e603613a7c ve.dm.MWExtensionNode: Clarify documentation of 'extensionName'
Bug: T291900
Change-Id: I70db47747aef7693ade6b8b7ea68e6212f78fe29
2021-10-12 00:16:42 +02:00
Thiemo Kreuz 74e3dd3f4b Fix strange dialog title when using subst:
When I type e.g. "subst:example" as the template name, we made this
work as the user would expect: the template named "Example" is found
and it's TemplateData documentation used. But the dialog title shows
"Subst:example". Note the uppercase "S". It means this string is
parsed as a title, including the "subst:". This is confusing. Just
show the template name.

Change-Id: I9817786991a8379cf48b0a664aef1413abddee2d
2021-10-08 16:00:29 +02:00
Thiemo Kreuz f77ef7d7f4 Fix/cleanup template dialog methods dealing with parts vs. items
Some cleanup to improve readability and reduce the amount of code.
Relevant bits:
* One method name was wrong. It can actually return parameter ids,
  not only top-level part ids.
* I got rid of some fail-safe checks that are never needed or moved
  them to a more central place.

Change-Id: I08f2ad7bc7d3f985d6189dff170dda554f3d37c2
2021-10-08 07:43:23 +00:00
Andrew Kostka 7e9d50ff05 Use .localeCompare() when sorting undocumented parameters
Bug: T292643
Change-Id: I5d89d64bcce656fa0881f69b5d0d0fef65871c0c
2021-10-07 11:57:18 +02:00
Thiemo Kreuz 1904698105 Move some logic into the TransclusionModel class
I moved some code around and found that quite a lot of code wants to
know:
* Is the length of this transclusion exactly 1?
* I need that 1st part.

There is more that can potentially moved from the dialog to the model.
But I don't want to make this patch to big.

Bug: T292371
Change-Id: Ia94ed0450d04dd97c4c41f5bf7c266f9a534e821
2021-10-06 16:00:18 +00:00
jenkins-bot 9213741db4 Merge "Pages outside of Template: namespace can have TemplateData" 2021-10-06 10:30:10 +00:00