Commit graph

65 commits

Author SHA1 Message Date
Andrew Kostka aaf67a9c0b Update color scheme to meet accessibility standards
These changes to the color scheme are hidden behind a feature
flag for the time being.

Bug: T271895
Change-Id: I0a4b03e0f3bc8239f31edbbd5ae55661607b76f6
2021-03-05 16:39:14 +01:00
jenkins-bot 92524135c0 Merge "Revert "Lower maxHighlightLineLength limit to 5000"" 2021-02-10 16:35:47 +00:00
Thiemo Kreuz (WMDE) 0268f68170 Revert "Lower maxHighlightLineLength limit to 5000"
This does not have an effect any more with all the other
optimizations in place.

This reverts commit 094f20902c.

Bug: T274369
Change-Id: I288039a35270093bd22b5a073e70f6b769088c13
2021-02-10 16:19:10 +00:00
Adam Wight 81bd2fe546 Clean-up: inline array merge
Change-Id: Ie976bf70f4117db09b53e6192f983930c7e6a458
2021-02-01 13:24:05 +01:00
Adam Wight 36212a7877 Log user edit count bucket
Bug: T269986
Change-Id: Iff3c983a59738312bc39bf65e2428526724fe139
2021-01-27 09:03:28 +00:00
Thiemo Kreuz 094f20902c Lower maxHighlightLineLength limit to 5000
While working on T270317, I realized the performance of the
matchbrackets addon is not as good as described in
T270237#6739993. The issue with my original benchmark was that
I did it with a single pair of brackets with thousands of
characters between. A paragraph with thousands of brackets
behaves much worse. So bad that I feels painful when moving
the cursor.

Lowering the limit to something in the middle (between the
original 1000 and my 10000) makes it behave much, much better
on my machine.

Bug: T270237
Bug: T270317
Change-Id: I31f850f4c7778d6b5ff1d0eb17fdaf0edf7ae019
2021-01-19 15:04:14 +01:00
Thiemo Kreuz 18a64328bb Disable non-matching highlighting via config flag
My upstream patch was accepted within 9 minutes:
https://github.com/codemirror/CodeMirror/pull/6565

Note: This backport includes another upstream commit that fixed
some typos.

Bug: T269096
Change-Id: Ib5b64214d7536bc952886f45290d537eab2f9bbb
2021-01-18 09:51:05 +00:00
Thiemo Kreuz a43acbeb6b Activate bracket matching for longer lines
The addon does have 3 settings:
- maxHighlightLineLength is for the current line where the
  cursor is. Bracket matching is simply not done when the
  current line is longer. The default is 1000, which is rather
  low.
- maxScanLineLength is for every other line that is scanned in
  the process. I don't understand why, but this limit is 10x
  higher.
- maxScanLines is the number of lines that can be scanned.

Simply raising the first to be 10000 as well fixes our issue.

Note that CodeMirror does have a limit of 10000 anyway. It's
called maxHighlightLength there. Lines that are longer get
syntax highlighting only for the first 10000 characters. The
rest of the line is black. Using the same limit in the addon
makes it's behavior consistent. Means: The user can see when
the syntax highlighting stops, and bracket matching stops
working the same time.

I benchmarked with both settings. It doesn't have a measurable
effect. Bracket matching is done in <1ms in both cases.

Bug: T270237
Change-Id: Ia56bf4c2fb023c9f117376242221d39f51196173
2021-01-14 11:28:02 +00:00
jenkins-bot 0bebeea02f Merge "Make private convertOffset function a shared method" 2021-01-13 07:22:29 +00:00
WMDE-Fisch de49f2c02a Enable bracket matching addon by defining the addons options
The addon does support some configuration options. These are passed
as properties of the `matchBrackets` CodeMirror option. Just passing
the boolean there hides that fact.

Bug: T270317
Bug: T270237
Change-Id: Iaa4b5ed8ef538e76cd1c96a09485e143112f1ae0
2021-01-12 11:55:22 +01:00
Ed Sanders 7aceb6d65c Make private convertOffset function a shared method
Change-Id: I7e644ff998bd44e854b26dd9b11ba9a5d3bd0435
2021-01-06 14:57:32 +00:00
Thiemo Kreuz a43984fc67 Simplify onSelect handler implementation
Optimizations for the code introduced in Ic403e0a:
* Skip this entirely when something is selected (as discussed
  in Ic403e0a).
* Use a combination of existing methods. I benchmarked these
  again. This approach is "significantly" slower compared to
  the custom code from before. However, "significantly" here
  means something like 1 nanosecond vs. 4 nanoseconds. Both
  is effectively nothing.
* Use the same approach in another place. This one is triggered
  every time a change is made, e.g. a character typed. I
  benchmarked this as well. The new code is about 500x faster
  (yes, seriously).

Bug: T269094
Change-Id: I00fe595a89be7a257e27ed28d38568c81483338b
2021-01-05 22:50:04 +00:00
jenkins-bot 773b308fab Merge "Integrated bracket matching for CodeMirror with VisualEditor" 2021-01-05 11:37:57 +00:00
WMDE-Fisch 17fb4ceb7e Integrated bracket matching for CodeMirror with VisualEditor
Bug: T269094
Change-Id: Ic403e0a037127ed006e8d1168d710e6160a922d5
2020-12-29 21:34:16 +00:00
Ed Sanders 0c681f5300 ve-cm: Fix selection opacity when using fallback technique
The fallback technique makes the whole edit surface semi-transparent,
so reset native selections to full opacity.

Change-Id: If6cd585b1a09c549781fe82a3bdf18d64ac597b5
2020-12-28 23:38:16 +00:00
Thiemo Kreuz 4a3c2dcad5 Update CodeMirror to 5.58.3
I had to make some CSS selectors more specific, because the
library changed

 .CodeMirror pre

to

 .CodeMirror pre.CodeMirror-line,
 .CodeMirror pre.CodeMirror-line-like

This is only relevant for entire lines (implemented as <pre>
elements). Most of the custom CSS is for characters, not lines.

In my tests in the Wikitext editor as well as VisualEditor I
could not spot any difference between the old and new version.

Bug: T258999
Change-Id: I6f0f030f972838727f3ef220feb105264f122798
2020-12-07 20:20:49 +00:00
Andrew Kostka 7d01567c4f Record usage statistics for syntax highlighting
Bug: T260138
Change-Id: Ic9b95d6331bf85704822a69483880faaaa578a0e
2020-11-25 15:18:01 +01:00
Pavel Astakhov a9da1fa59e Load pluginModules in CodeMirrorAction class
Change-Id: Ia698be63171868cf568b136df89ce3e48eab1340
2020-07-10 17:12:23 +06:00
Ed Sanders 89f52f6fbb VE: Add explicit dependency on targetLoader
Change-Id: I3d67837b462e0b79e124eff158bd7f88b5aaf63e
2020-06-30 22:47:41 +01:00
Ed Sanders 2518861bc1 build: Update devDependencies
Change-Id: I2f2967a1525c6a66eba2f5fc225e74b89380c5dd
2020-06-12 22:51:38 +01:00
Bartosz Dziewoński d23ffa17cb Update VisualEditor styles for Vector changes
Bug: T252471
Change-Id: I6ba64f2deaa27172842ee5f71363708758324aff
2020-05-12 00:42:03 +02:00
Ed Sanders 4d53bcbe09 VE: Don't load CodeMirror code until tool is activated
This saves about 300k uncompressed / 80k compressed whenever VE loads!

Change-Id: I7cf1c35292c2ea48cc15ceb4c22d4473a25484e9
2020-03-19 20:23:24 +00:00
AronDemian f0e689d203 Remove the unnecessary 1.5em padding in MinervaNeue skin that misaligns highlights.
Bug: T245532
Bug: T245568
Change-Id: Ib29678eb38ebb5a5d2975a087e55b2ddd2a4b35d
Related: I135bf0f7bf73e0d9faaa43c565cef43c5c934a34 - T245476
2020-02-19 15:00:43 +01:00
Bartosz Dziewoński 5a1501d46f VE: Update padding to match VisualEditor changes
See Ib7ffbf09d5aa23fddb894aa3b081ec993ddcee2d.

Bug: T238678
Change-Id: Ia9d38599e76b63147318c6604dbd9b9fabf35b16
2019-12-13 14:54:03 +00:00
Ed Sanders a134e66777 Don't replace whitespace characters in VE
Bug: T153434
Depends-On: Ic4a5ab803c89b3671f452579bca0da08b779bdfe
Change-Id: Ic3d848ff86cceceeeea9385bfc49ad2241e3801b
2019-11-14 22:30:32 +00:00
Ed Sanders cf9885b586 Match tabSize to surface view CSS property
For browsers that don't support the property, assume
the default value of 8 is used.

Change-Id: Icb9a97fa79e08458bf717903f1d7b68e433e7904
2019-11-14 22:30:32 +00:00
Isarra 90ac9d3475 Remove Timeless VE styles, too many variables to do them properly here
Move this stuff to Timeless itself since we can just reuse the width cutoff
and padding variables directly there and don't need to worry about them
randomly changing.

Corresponding change: Ic64b9786cb7186dba3eb2042a3238149c3bb44c6

Bug: T230756
Change-Id: Ia7168341bcadbc60e307b58b67afc1975a2424f9
2019-08-20 20:26:45 +00:00
Ed Sanders 7604581cc1 Remove obsolete aliases from closures
Bug: T208951
Change-Id: I64c2966b7c41d6b2b1911e2fb52e4c7364bf7964
2018-11-12 13:19:41 +00:00
Bartosz Dziewoński 079d240a2c ve.ui.CodeMirror: Fix padding to match VisualEditor's padding
VisualEditor's default padding for the source editing surface was
changed in Icdc6f1e2a7544ebbd828f85ff370113a0e06983a (June 2018).

Since then the alignment of editing surface and CodeMirror syntax
highlighting surface was broken in skins that don't override the
default padding (basically every skin except Vector and MonoBook).
Unfortunately Vector and MonoBook happen to be the only skins we
officially support and actually test, so the issue went unnoticed.

Bug: T205154
Bug: T205658
Change-Id: Ic85a6c20b266f6b93ab8ec9c2d35acff679f31bc
2018-09-27 22:06:00 +02:00
Ed Sanders ef8c62c74b Use renamed ve.visibleWhitespaceCharacters
Change-Id: I246079505d4c37406b3f99ca17b7e8e926adaec5
2018-09-24 16:34:54 +01:00
Ed Sanders 1be09a9a1d build: Update linters
Change-Id: I8d3aaf0b7d453033b72e5d6622b8f54df2c86bca
2018-09-12 00:03:19 +01:00
Derk-Jan Hartman 736c63fd0b Accessibility: Disable both directions of tabbing in CodeMirror
Bug: T197534
Change-Id: Ia05c3ccbdb4baa8e701bf46478c42d2473777535
2018-06-17 19:24:14 +02:00
Ed Sanders 341a67496a Simplify target lookup
Change-Id: I00449f043c391c7648e2c17651d15c2807044402
2018-05-12 13:10:05 +01:00
Ed Sanders fca1d62a6c Apply line height selector to CodeMirror line wrapper
Bug: T193219
Change-Id: I7973b5e1a4f602c0fc371d78a1ebead093c48e74
2018-04-27 21:42:45 +01:00
jenkins-bot d3c7f3cdd4 Merge "Use CM API for setting document direction" 2018-04-25 18:36:32 +00:00
Niharika Kohli 7c848abd8d Load CodeMirror with VE always
This patch makes Codemirror on VE independent of the beta feature,
making it always load.

This is a first step to graduating CodeMirror out of beta.

Bug: T191923
Change-Id: Ide794e8f986d3f0455ff282819c71d9144dd75db
2018-04-23 20:54:43 +00:00
Ed Sanders dcf28f37a1 Use CM API for setting document direction
Bug: T191923
Change-Id: I68ee7de8ff2d26044fc8a71a04ade65b5d4420c8
2018-04-16 16:53:29 +01:00
Ed Sanders d428893b80 Merge selectors for VE & CM surfaces, and add 'hyphens' rule
Keep all our font rule settings in one place to make it
easier to keep them in sync. Also add a rule for 'hyphens' in
case the browser default has changed.

Bug: T192019
Change-Id: I2c27e5075a9bc6aaed9fe048d163f57976708357
2018-04-16 16:43:35 +01:00
Ed Sanders c09151d659 Fix some small edge cases with font matching
Change-Id: I6e2df8e13f19a29a3a80fbbfc0ed5332c33eb584
2018-03-27 22:35:00 +01:00
Ed Sanders 4f2ace3ad9 Unbreak VE integration in IE11
Element.remove is not supported in IE11 so use
parentNode.removeChild.

Change-Id: Iacfdc2fb563d5ed168dc691ecf439e60e94d4e2a
2018-03-27 21:46:00 +01:00
Ed Sanders 1dc74c66fe Avoid using bold with VE+CodeMirror
We can't guarantee the preserve glyph width, e.g.
on Firefox with Chinese characters.

Bug: T184467
Change-Id: I6fc92fcd034bda3d9a94749935aae03c8373f7c5
2018-03-07 19:56:51 +00:00
Ed Sanders 06af670325 VE: Use different approach for transparent text issue
Deferring the insertions can lead to sync issues, so use
a different technique to selective refresh the CodeMirror
view when the height changes.

This reverts commit 8e3d96f75f.

Bug: T188473
Bug: T185184
Change-Id: I502501cc0325db64f29a67716306733859d102a9
2018-02-28 12:38:44 +00:00
jenkins-bot b0ee15034a Merge "VE: Match whitespace rendering of ve.ce.TextNode" 2018-02-25 22:40:46 +00:00
jenkins-bot 348949d15b Merge "Defer update of CM surface to avoid invisible text" 2018-02-25 20:58:45 +00:00
Ed Sanders 8e3d96f75f Defer update of CM surface to avoid invisible text
Bug: T185184
Change-Id: I0b115d892ab322911c895dda030b77f35cc9195a
2018-02-25 18:05:19 +00:00
Ed Sanders 8b27277b20 VE: Refresh rendering after surfaceReady
Bug: T188215
Change-Id: I4c53f554d8091aa71ce59fe04857b588209639d3
2018-02-25 17:58:32 +00:00
Ed Sanders 452d6d0a80 VE: Match whitespace rendering of ve.ce.TextNode
Bug: T187694
Change-Id: Ie27e9862e0f55fcc10af91a2bdd9c5d21d49ddc4
2018-02-19 10:43:53 +00:00
Ed Sanders e795883f0d NWE: Fix padding in Vector
Bug: T185299
Change-Id: Iea8e61654608259ddc90286aef59014a37e4f44d
2018-01-19 10:13:53 +00:00
Ed Sanders 8d998f97ed Make NWE integration background transparent
Allows for VE's placeholder text feature to work.

Change-Id: Ieee01baf3dc049f248a97408af70499dcea8f4c9
2018-01-04 12:37:42 +00:00
Ed Sanders 9960ed601f Remove font-size now it is set by editfont
Bug: T180678
Change-Id: Ic9e8bdb3b34dbb2f2c5748d6bb57e9da90112118
2017-12-21 12:21:57 +00:00