Our "init" hasn't been init for a long time. We load a lot of classes (ext.visualEditor.base and ext.visualEditor.mediawiki) for the ViewPageTarget.
Goal
Integration layers in MediaWiki and elsewhere would only need the visualeditor.init module at first. This should provide them with tools to determine whether the current environment supports VE (feature test / browser sniffing), and the ability to then (on demand) proceed and actually load the editor, with an edit surface.
The init module would provide only a lightweight ve and ve.init object with little to no dependencies. Only jquery and oojs as dependency. Not oojs-ui or anything else.
For MediaWiki this means the mw.ve.init module would also take care of checking user preferences and wiki configuration with regards to skin/namespace/contentmodel etc. And mw.ve.init would also continue to handle the various skin transformations and loading bars (which would be readily available).
Thoughts
Do we need Platform to bootstrap Target? Right now in standalone we do, but in MediaWiki we don't. It's up to the Target implementation to decide this. So let's keep Platform shipped in init.
Class structure:
- ve.init.Platform
- ve.init.Target.
- ve.init.sa.Platform becomes ve.sa.init.Platform. ve/sa becomes a showcase for how to bootstrap VE. Assuming we keep this generic, we can keep it under ve.* and ship it by default. If it becomes a demo instead that people should not extend but instead copy from, we should move it to a global VEDemo javascript namespace or something like that.
- ve.init.sa.Target becomes ve.sa.init.Target.
- ve.init.mw.Target becomes mw.ve.init.Platform.
Also relevant are the feature tests. Currently only our MediaWiki platform has these feature tests, we should move these into the base hardcoded in the MediaWiki platform. These should be moved to ve.support and become part of the lightweight init module.
- Feature detection (ve.support)
- support.es5
- support.contentEditable
- (maybe) support.svg, since we're currently repeating` ( document.createElementNS && document.createElementNS( 'http://www.w3.org/2000/svg', 'svg' ).createSVGRect` in five places.
- Browser sniffing (ve.support.browsers.{whitelist,blacklist})
See also:
T52612: VisualEditor: Split mw.ViewPageTarget init from integration handling
T75593: VisualEditor: mw.Target / ViewPageTarget re-write (and its dependencies)