Commit graph

29 commits

Author SHA1 Message Date
Sam Wilson 623e6e7a46 Realtime Preview: remove the scroll linking between source and preview
It doesn't work well when there are infoboxes etc. and the actual
scroll behaviour is jerky and not very pleasing.

Bug: T294977
Change-Id: I8fbba61ddd902c16b3c63b41fc361afb5d1c1a1b
2022-06-17 11:09:04 +08:00
jenkins-bot 82e7d45aa5 Merge "Realtime preview: match scroll positions between textarea and preview" 2022-06-10 19:42:50 +00:00
Sam Wilson 9a5e7dd919 Realtime preview: allow loading as a gadget
* Prevent the realtimepreview module loading on anything
  other than wikitext pages (as is already done PHP-side
  but that is bypassed when loaded as a gadget).
* Give the #wpTextbox1 a class so we don't always style it.

Bug: T307039
Bug: T308176
Bug: T309330
Change-Id: I26111a61c8cf37520b3619faf09d76445973edd3
2022-06-09 17:27:24 +08:00
Sam Wilson e575822c73 Realtime preview: match scroll positions between textarea and preview
When either the textarea or the preview pane is scrolled, match the
other to the same vertical scroll percentage.

Bug: T294977
Change-Id: Ieda15868162caf06ef9099065ba55cfd8d8bfd0f
2022-06-09 12:57:54 +08:00
Sam Wilson 4fc6cb53b8 Realtime preview: keep original scroll position when enabling/disabling
Because the DOM and layout changes reset the scroll position of the
editing text area, it must be manually saved before enabling/disabling
and reset afterwards.

Bug: T294977
Change-Id: I7722213e682401d29b6b53d672a487da042be6a9
2022-06-01 10:41:54 +00:00
Sam Wilson 4ff946aea4 Realtime Preview onboarding popup
Add a pulsating blue dot to the Realtime Preview toolbar button
that displays an onboarding popup when clicked and disappears
forever when dismissed.

Bug: T294589
Change-Id: I7f4dd0858349b0e7c4f4bedea5c7a62a51c6fa3a
2022-06-01 14:11:49 +08:00
samtar 45501cfd92 Realtime preview: Suppress reopening pane
Change the handling of the manual reload button's accessKey to
only refresh the preview if the pane is currently open.
Duplicate change to ManualWidget's handler.

Bug: T307805
Change-Id: I0f07ff346eef4bd93d13d55548381a71c0f660d3
2022-05-07 01:21:40 +01:00
Sam Wilson be4ee228aa Realtime Preview: show and hide preview and error areas appropriately
* Always hide the error message after a successful preview.
* Before previewing, make sure the preview node is un-hidden, in
  case it was previously hidden by showError().
* Stop checkResponseTimes() from hiding any error (it only handles the
  manual mode).
* Stop showError() from hiding the manual bar (it's okay to see both).

Bug: T306965
Change-Id: Ic2ad52fea41070adb196ef2fbd740e808d373e5e
2022-05-06 08:23:50 +08:00
Sam Wilson 96c905f1dc Realtime Preview: Make whole manual-loading bar clickable
Make the manual-mode loading bar clickable by turing it all into
an anchor element with various mixins for functionality.

Also adds a tooltip to the whole bar, and makes the same accesskey
work (including when the preview pane is closed).

Bug: T306590
Bug: T306906
Bug: T306880
Change-Id: I915a430300c75256d89b929e3925d0ea714807bb
2022-05-06 07:32:37 +08:00
jenkins-bot 6a91c1f3ea Merge "Realtime preview: improve toolbar button style" 2022-05-04 11:31:57 +00:00
hmonroy 090929cf1d Realtime preview: disable preview when screen is small
Disable preview functionality when screen is less than 600px.

Bug: T293337
Change-Id: I4615f629a0c97fb325721bbddee5c9eb074c3a5c
2022-05-02 15:26:20 -07:00
Sam Wilson 37836d7fcc Realtime preview: don't show reload button on error message
When the error layout is shown, hide the hover reload button,
and only re-show it if the preview is successful.

Bug: T306866
Change-Id: I5e72295069ee9e8279c5786c3959db5902da0e25
2022-04-26 16:23:51 +08:00
Sam Wilson 3ab9a863a2 Realtime preview: improve toolbar button style
* Add hover and active styles to match normal toolbar state styling.
* Move border from right to left on `.section-secondary .group`.
* Add a skinStyle for MonoBook so it doesn't get the button style,
  because it provides its own.

Bug: T303991
Change-Id: I6f08906156a9768729d779b6c50c9e804f51fb98
2022-04-26 15:08:28 +08:00
Sam Wilson a8833fcd3b Disable the realtime preview reload button during loading
Make the reloadButton into a class member so that it's
accessible in doRealtimePreview().

Bug: T304568
Change-Id: I81c1870becd81884894353921f878653cd690d7a
2022-04-21 11:16:54 +08:00
jenkins-bot e0aa0ee307 Merge "Realtime Preview: display manual-reload bar when previews are slow" 2022-04-21 00:55:21 +00:00
MusikAnimal 472cf0c07c Realtime Preview: make button toggle state more visible in MonoBook
Bug: T305953
Change-Id: Ibb0ee08837b7e3f5e98fa11d9e7a97dcef2dee9e
2022-04-20 12:30:30 -04:00
Sam Wilson 4c760f8634 Realtime Preview: display manual-reload bar when previews are slow
After three slow preview requests, switch to showing a bar at the
top of the preview area that contains a manual 'reload' button.

The manual bar will be hidden when an error message is show, but
re-shown again after the error is dismissed. Closing and
re-opening the preview pane doesn't reset the manual mode.

Bug: T304568
Change-Id: Ia72bd1ceab68fdaed5de53137bd8ac5961db4714
2022-04-20 13:01:14 +08:00
Sam Wilson 94d4912103 Realtime Preview: add hover button for reloading
Add a 'reload' button to the right-side preview pane (that shows
on hover, and stays in the same place when the preview is
scrolled), and also an accesskey to trigger the preview. If the
preview is not open when the accesskey is pressed, it'll be
opened.

Bug: T303532
Change-Id: Ifa77ad7cf6d2ed6a8b955f9a324986d1c6f9a993
2022-04-14 08:08:58 +08:00
Sam Wilson f5f39d41d4 Realtime Preview: Move loading bar to be a proper element
Change from a pseudoelement ::before the left pane, to its own
element. This is so that when we introduce the top manual-reload
bar the blue bouncing loading bar can be shifted down below it.

Also moves the CSS out of TwoPaneLayout.less and into
RealtimePreview.less where it more properly belongs.

Bug: T304568
Change-Id: I540f68d528d92b7db8594d729985e5dad3d90ac1
2022-04-13 19:08:23 +00:00
Sam Wilson 981a9c762a Realtime Preview: Refactor event handler for easier re-use
Instead of exposing a way of adding event listeners, just expose
the event handler and let consumers (i.e. CodeMirror) add it
to whatever events it wants.

Bug: T303767
Follow-Up: I8c8c25fe56be55a61f4b8d1d2ef8cf74483aa241
Change-Id: Iee4c885f92dd9ec985a3f9fd92a2fafc00f2e9ff
2022-04-06 13:25:12 +08:00
Sam Wilson e6b77fb2ab Persist Realtime Preview state in a user preference
Store the current state (enabled/disabled) of Realtime Preview in
a new user preference `wikieditor-realtimepreview` and set it
when enabling or disabling the preview pane.

Bug: T294599
Change-Id: Id5f51c6d77ed0077906d5d5178cbfa785cc04dcf
2022-03-31 21:01:36 +08:00
MusikAnimal f1a2ba96eb Realtime Preview: disable if average response time is very slow
$wgWikiEditorRealtimeDisableDuration is introduced which allows
sysadmins to control the average time after which Realtime Preview
should be disabled. For now, this shows a simple error message that is
intentionally not localized. In a future patch, we will force the
user into a 'manual preview' workflow. See T304568 for more.

Bug: T302282
Change-Id: I2f01eef19fe81c19efedcc0073a28884f0055359
2022-03-30 12:28:23 -04:00
Sam Wilson cdd01171cc Log realtime preview errors to console
Bug: T303545
Change-Id: Iaa23b85eeb8d9951cbbbf350e55da006d49c84fa
2022-03-24 16:02:03 -04:00
jenkins-bot 07423d1a9f Merge "Add nicer realtime preview error messages" 2022-03-24 20:00:40 +00:00
Sam Wilson 6175e2c519 Add nicer realtime preview error messages
Add a new ErrorLayout to display error messages along with an
image.

Bug: T303383
Change-Id: I1ec27a212b5ab67d3e805c0d7756432850de89ea
2022-03-24 14:56:19 +08:00
jenkins-bot bb2072b5d2 Merge "RealtimePreview: add config setting for debounce time" 2022-03-24 06:35:44 +00:00
MusikAnimal 68e6561857 RealtimePreview: add config setting for debounce time
Change-Id: Iaf49f076c5a290ab9049267b0aede1e6b13a9136
2022-03-24 02:00:19 -04:00
MusikAnimal 2cbf638f54 Realtime Preview: wait for a response before making new requests
If a preview is requested before one finishes, one final request is
fired off to ensure the preview is up-to-date.

Bug: T302282
Change-Id: I2399fc7cc08cd0987d2d689ca9f297db1ec5edf0
2022-03-21 21:17:26 -04:00
Sam Wilson 411be83bc3 Add toggle button and two-pane layout for realtime preview
* Toolbar button to toggle a two-pane layout on and off.
* Resizable bar for the width of the two panes.
* Resizable bar for the edit box height, even when realtime preview is off.
* Only enabled when $wgWikiEditorRealtimePreview = true.
* Fires JS hooks when enabled, resized, and disabled.

Bug: T293347
Change-Id: Id09d44519249c0b7f5c33d48d524b7c92a5a9106
2022-03-13 07:28:01 +08:00