Commit graph

22 commits

Author SHA1 Message Date
Adam Wight 5b2cbc48bd Wire subref counting into the numbering renderer
Significant change is that footnote marker numbers are changed from
being a CSS-rendered marker to using the rendered "fallback" text.
This could be avoided using the same trick as is implemented for the
reflist: send an inline style variable with the marker content; but
let's only do this if really necessary for user experience.

Template-produced refs are still wrong, but this patch continues to
render them as they come from Parsoid, in the content script.

TODO in later patches:
* reuse of a subref is rendered as '3.2.1' in reader view but '3.0'
and '3.1' in the editor.
* subref numbering is backwards in RTL languages

Bug: T247921
Change-Id: Ieff73769f8ebbc3724f6a9b498487c4e7d09aa2e
2024-07-15 07:08:06 +00:00
thiemowmde 6c5c2dc6cb Remove separate private deferDoc property in ve.dm.MWReferenceModel
This is a direct follow-up for what I started in I3c9b9bb. Again all
this does is moving existing code around. The separate this.deferDoc
property is never used anywhere:
https://codesearch.wmcloud.org/search/?q=deferDoc&files=%5C.js%24
Instead I store the deferred function directly in the target property
this.doc and resolve it when needed.

Note that the concept of a parentDoc still exists. I tried to make
this as obvious as possible via comments and by arranging the code
accordingly:
1. A lot of code calls setDocument which directly sets this.doc. The
   parentDoc is never used in this case.
2. The parentDoc is only needed to auto-generate the (empty) document
   for the reference when a new reference is created.

That's also why the existing code always calls the constructor with
the parentDoc, even if this ends being unused in many cases: It's a
simple fallback.

Bug: T363096
Change-Id: I7874f187b2b397ed511b695ca9ff95838fcff302
2024-05-13 22:25:06 +02:00
thiemowmde 81f774c789 Don't call things "attrs" that aren't mw.attrs
mw.attrs does have a special meaning in this code. Together with
mw.body it reflects 1:1 what was written in the original wikitext
in the <ref …> and <references …> tags. Let's avoid using the same
(or almost same) variable name for other kinds of attributes.

Bug: T363096
Change-Id: I3e599ab910b9639e121f9b9d532b0f57f08f1e73
2024-05-13 18:37:17 +02:00
jenkins-bot f9ba47d7f0 Merge "Drop separate MWReferenceModel.parentDoc property" 2024-05-13 13:01:26 +00:00
thiemowmde f61b840dc8 Drop separate MWReferenceModel.parentDoc property
We can re-use the existing this.deferDoc property to achieve the
same. There is apparently no need for a separate "parentDoc"
property for anything else but what can be seen in this patch.

https://codesearch.wmcloud.org/search/?q=%5CbparentDoc%5Cb

And no need to keep neither the parentDoc reference nor deferDoc
callback indefinitely. We can drop it after it got resolved.

This really just moves existing code around without changing
anything.

Bug: T363096
Change-Id: I3c9b9bbdff29a3f35d5a0710b48ca59bf592c6ab
2024-04-24 14:49:05 +02:00
thiemowmde 1391f43d03 Drop unused setters from MWReferenceModel class
These aren't used anywhere:
https://codesearch.wmcloud.org/search/?q=%5Cbset%28ExtendsRef%7CList%28Key%7CGroup%7CIndex%29%29%5Cb
These setters are reaching into internal details that currently
aren't ever modified from outside of the class, and shouldn't.
If it turns out we ever need to modify one of these we can easily
re-introduce setter functions, but probably give them more
meaningful names.

Bug: T363096
Change-Id: I2c9efc114bdc110a29b8d7fb48ea8c1814cdeb21
2024-04-24 14:17:49 +02:00
thiemowmde 14fe315c62 Mark private MWReferenceModel setters as such
This just documents the current status quo. These methods are not
used anywhere, and probably shouldn't:
https://codesearch.wmcloud.org/search/?q=%5Cbset%28ExtendsRef%7CList%28Key%7CGroup%7CIndex%29%29%5Cb
The only place these should ever be called from is from
newFromReferenceNode in the same class.

Bug: T363096
Change-Id: Ic28dbb5cbb2beb98c9fe6d283ed87d879728da0f
2024-04-24 14:16:52 +02:00
Adam Wight 73c90a0e7d Clean up and fix some jsdoc annotations
Some of the annotations were used in a way that confused jsdoc.  This
cleans up redundant annotations and uses more canonical tags.

These changes cause all classes to now appear in the generated pages.

Includes linking to external docs.

Bug: T358641
Change-Id: Iaee1dadcc19a70c27839d0d27dfa6a07a70fb46b
2024-02-29 13:05:42 +01:00
Esanders f7c8b63ed1 Revert "Accessors to find MWReferenceNode in the document"
This reverts commit 0566a495f3.

Reason for revert: Merged too soon, while discussion of the whole
approach is still ongoing.

Change-Id: I2d3d6455cd4ea12067e2020f6b41cfbb4672bbb5
2024-02-13 12:57:02 +00:00
Adam Wight 0566a495f3 Accessors to find MWReferenceNode in the document
These are provides as a replacement for internalList indexes.

Bug: T336417
Change-Id: Ifd3a1b667369074e2cefa4d70e4c090e91b010b5
2024-02-09 15:37:27 +01:00
Adam Wight 9535126304 [lint] Satisfy max-len rule
These changes mostly improve the code, and align the lint rules with
the MediaWiki base.

Change-Id: Ib4b0595fd9a9298039b8b44a0f1d4a9e90731527
2024-01-30 12:18:52 +01:00
mareikeheuer 1eb405eb54 Convert Cite extention to ES6
Bug: T343220
Change-Id: I769f0bfaa5af14d6ea4861ea738b44c98feb6193
2023-08-23 12:39:29 +00:00
Svantje Lilienthal 227b50d964 Adding extendsRef to reference model
* reads the new attribute extends from wikitext
* saves it into the reference model
* adds a message to the VE popup of an extension as a first demo
* tests will be added in a separate patch

Bug: T247922
Change-Id: If4d309c4678022642f39e21565950dc45e557d47
2023-05-30 11:56:47 +02:00
Ed Sanders 1e6968b5c0 ve-cite: Ensure references are always unique by generating originalDomElementsHash
This is a bit of an abuse of the originalDomElementsHash property.
In future we could add a 'uniqueId' attribute, but this would need
to be ignored in a few places in core.

Bug: T299378
Change-Id: I7d1eb362aeb74ba93f5225330226a95535746b92
2022-01-27 01:14:52 +00:00
Ed Sanders 0d4bb626f1 Move eslint client config to modules, fix warnings
Change-Id: I86857b82fa7d5c47c0056da4ad270fcb2a4d965f
2021-11-03 16:38:31 +00:00
Ed Sanders cf95dbd4be Move var declarations inline
Change-Id: I824a65e72a72e5acf65c54a63299469f7acb649d
2021-11-03 16:38:31 +00:00
Thiemo Mättig bbc1f2c91d Use standard form for @license tags
See https://spdx.org/licenses/

Change-Id: Ic091ebc3844abcd6de90b3241382fb4732200a6d
2018-03-20 03:18:37 +00:00
James D. Forrester 0999d771b6 doc: Bump copyright year
Also make the overly-terse statement clearer.

Change-Id: I752bb82444bf7cb41480076bace42331dc35a598
2018-01-02 17:05:50 -08:00
James D. Forrester 0d20873fa6 doc: Bump copyright year notice, 'team' name
Change-Id: Ia090c417a1aa716b255613199b5e49616bf0517a
2017-04-20 16:50:43 +00:00
Ed Sanders 099b8f8153 Use canonical ve.dm.TransactionBuilder.static.newFrom* methods
Change-Id: I9ce6860e19e833b576f7b9fb239b96de394b667c
2016-11-30 19:06:13 +00:00
Ed Sanders 7d9693d090 Use cloneWithData
Change-Id: Ibab88f333cd39aabc73a579e1b05fc9b830b6d86
2016-05-30 22:34:15 +01:00
Ed Sanders 18f616b9b8 VisualEditor: Move code for Cite into this repo
This code has been developed over three years now in the repo of MediaWiki's
integration of VisualEditor. It has grown and developed significantly during
that time, but now is pretty stable. A number of hacks inside the MediaWiki-
VisualEditor code base have been used to prevent this code from being loaded
on wikis where the Cite extension is not deployed, but this state of affairs
is and always was meant to be temporary.

This code is under the MIT licence which is a tad messy, but not impossible.
It's clearly labelled as such. The list of authors has been updated to take
into account the influx of new functionality.

Bug: T41621
Bug: T104928
Change-Id: I39936ed83d5a60471a0a75da753f498e80aef234
2016-02-04 08:41:54 -08:00