mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
88f6089952
'''Kranitor commits''' are commits by Krinkle with his janitor hat on. Must never contain functional changes mixed with miscellaneous changes. .gitignore: * Add .DS_Store to the ignore list so that browsing the directories on Mac OS X, will not add these files to the list of untracked files. * Fix missing newline at end of file .jshintrc * raises -> throws * +module (QUnit.module) * remove 'Node' (as of node-jshint 1.7.2 this is now part of 'browser:true', as it should be) Authors: * Adding myself MWExtension/VisualEditor.php * Fix default value of wgVisualEditorParsoidURL to not point to the experimental instance in WMF Labs. Issues: * ve.ce.TextNode: - Fix TODO: Don't perform a useless clone of an already-jQuerified object. - Use .html() to set html content instead of encapsulating between two strings. This is slightly faster but more importantly safer, and prevents situations where the resulting jQuery collection actually contains 2 elements instead of 1, thus messing up what .contents() is iterating over. * ve.ce.Document.test.js - Fix: ReferenceError: assert is not defined * ve.dm.Document.test.js - Fix: ReferenceError: assert is not defined * ve.dm.Transaction.test.js - Fix: ReferenceError: assert is not defined * ve.dm.TransactionProcessor.test.js - Fix: ReferenceError: assert is not defined * ext.visualEditor.viewPageTarget - Missing dependency on 'mediawiki.Title' Code conventions / Misc cleanup * Various JSHint warnings. * Whitespace * jQuery(): Use '<tag>' for element creation, use '<valid><xml/></valid>' for parsing * Use the default operator instead of ternary when the condition and first value are the same. x = foo ? foo : bar; -> x = foo || bar; Because contrary to some programming language (PHP...), in JS the default operator does not enforce a boolean result but returns the original value, hence it being called the 'default' operator, as opposed to the 'or' operator. * No need to call addClass() twice, it takes a space-separated list (jQuery splits by space and adds if needed) * Use .on( event[, selector], fn ) instead of the deprecated routers to it such as .bind(), .delegate() and .live(). All these three are now built-in and fully compatible with .on() * Add 'XXX:' comments for suspicious code that I don't want to change as part of a clean up commit. * Remove unused variables (several var x = this; where x was not used anywhere, possibly from boilerplate copy/paste) * Follows-up Trevor's commit that converts test suites to the new QUnit format. Also removed the globals since we no longer use those any more. Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
279 lines
8.2 KiB
PHP
279 lines
8.2 KiB
PHP
<?php
|
|
/**
|
|
* VisualEditor extension
|
|
*
|
|
* @file
|
|
* @ingroup Extensions
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/* Configuration */
|
|
|
|
// URL to the parsoid instance
|
|
$wgVisualEditorParsoidURL = 'http://localhost:8000';
|
|
|
|
/* Setup */
|
|
|
|
$wgExtensionCredits['other'][] = array(
|
|
'path' => __FILE__,
|
|
'name' => 'VisualEditor',
|
|
'author' => array(
|
|
'Trevor Parscal',
|
|
'Inez Korczyński',
|
|
'Roan Kattouw',
|
|
'Neil Kandalgaonkar',
|
|
'Gabriel Wicke',
|
|
'Brion Vibber',
|
|
'Christian Williams',
|
|
'Rob Moen',
|
|
'Subramanya Sastry',
|
|
),
|
|
'version' => '0.1.0',
|
|
'url' => 'https://www.mediawiki.org/wiki/Extension:VisualEditor',
|
|
'descriptionmsg' => 'visualeditor-desc',
|
|
);
|
|
$dir = dirname( __FILE__ ) . '/';
|
|
$wgExtensionMessagesFiles['VisualEditor'] = $dir . 'VisualEditor.i18n.php';
|
|
|
|
$wgVisualEditorResourceTemplate = array(
|
|
'localBasePath' => dirname( __FILE__ ) . '/modules',
|
|
'remoteExtPath' => 'VisualEditor/modules',
|
|
'group' => 'ext.visualEditor',
|
|
);
|
|
|
|
$wgResourceModules += array(
|
|
'rangy' => $wgVisualEditorResourceTemplate + array(
|
|
'scripts' => array(
|
|
'rangy/rangy-core.js',
|
|
'rangy/rangy-position.js',
|
|
),
|
|
),
|
|
// Alias for backwards compat, safe to remove after
|
|
'ext.visualEditor.editPageInit' => $wgVisualEditorResourceTemplate + array(
|
|
'dependencies' => array(
|
|
'ext.visualEditor.viewPageTarget',
|
|
)
|
|
),
|
|
'ext.visualEditor.viewPageTarget' => $wgVisualEditorResourceTemplate + array(
|
|
'scripts' => array(
|
|
've/init/ve.init.js',
|
|
've/init/ve.init.Platform.js',
|
|
've/init/mw/ve.init.mw.js',
|
|
've/init/mw/ve.init.mw.Platform.js',
|
|
've/init/mw/ve.init.mw.Target.js',
|
|
've/init/mw/targets/ve.init.mw.ViewPageTarget.js',
|
|
),
|
|
'styles' => array(
|
|
've/init/mw/styles/ve.init.mw.ViewPageTarget.css',
|
|
've/init/mw/styles/ve.init.mw.ViewPageTarget-hd.css' => array(
|
|
'media' => 'screen and (min-width: 982px)'
|
|
),
|
|
),
|
|
'dependencies' => array(
|
|
'ext.visualEditor.base',
|
|
'mediawiki.util',
|
|
'mediawiki.feedback',
|
|
'mediawiki.Uri',
|
|
'mediawiki.Title'
|
|
),
|
|
'messages' => array(
|
|
'minoredit',
|
|
'savearticle',
|
|
'watchthis',
|
|
'summary',
|
|
'tooltip-save',
|
|
'copyrightwarning',
|
|
'copyrightpage',
|
|
'edit',
|
|
'create',
|
|
'accesskey-ca-edit',
|
|
'tooltip-ca-edit',
|
|
'viewsource',
|
|
'visualeditor-ca-editsource',
|
|
'visualeditor-loadwarning',
|
|
'visualeditor-feedback-prompt',
|
|
'visualeditor-feedback-dialog-title'
|
|
),
|
|
),
|
|
'ext.visualEditor.base' => $wgVisualEditorResourceTemplate + array(
|
|
'scripts' => array(
|
|
// ve
|
|
'jquery/jquery.json.js',
|
|
've/ve.js',
|
|
've/ve.EventEmitter.js',
|
|
),
|
|
'debugScripts' => array(
|
|
've/ve.debug.js',
|
|
),
|
|
),
|
|
'ext.visualEditor.specialMessages' => $wgVisualEditorResourceTemplate + array(
|
|
'class' => 'VisualEditorMessagesModule'
|
|
),
|
|
'ext.visualEditor.core' => $wgVisualEditorResourceTemplate + array(
|
|
'scripts' => array(
|
|
// ve
|
|
've/ve.Factory.js',
|
|
've/ve.Position.js',
|
|
've/ve.Range.js',
|
|
've/ve.Node.js',
|
|
've/ve.BranchNode.js',
|
|
've/ve.LeafNode.js',
|
|
've/ve.Surface.js',
|
|
've/ve.Document.js',
|
|
|
|
// dm
|
|
've/dm/ve.dm.js',
|
|
've/dm/ve.dm.NodeFactory.js',
|
|
've/dm/ve.dm.AnnotationFactory.js',
|
|
've/dm/ve.dm.Node.js',
|
|
've/dm/ve.dm.BranchNode.js',
|
|
've/dm/ve.dm.LeafNode.js',
|
|
've/dm/ve.dm.Annotation.js',
|
|
've/dm/ve.dm.TransactionProcessor.js',
|
|
've/dm/ve.dm.Transaction.js',
|
|
've/dm/ve.dm.Surface.js',
|
|
've/dm/ve.dm.Document.js',
|
|
've/dm/ve.dm.DocumentSynchronizer.js',
|
|
've/dm/ve.dm.Converter.js',
|
|
|
|
've/dm/nodes/ve.dm.AlienInlineNode.js',
|
|
've/dm/nodes/ve.dm.AlienBlockNode.js',
|
|
've/dm/nodes/ve.dm.DefinitionListItemNode.js',
|
|
've/dm/nodes/ve.dm.DefinitionListNode.js',
|
|
've/dm/nodes/ve.dm.DocumentNode.js',
|
|
've/dm/nodes/ve.dm.HeadingNode.js',
|
|
've/dm/nodes/ve.dm.ImageNode.js',
|
|
've/dm/nodes/ve.dm.ListItemNode.js',
|
|
've/dm/nodes/ve.dm.ListNode.js',
|
|
've/dm/nodes/ve.dm.ParagraphNode.js',
|
|
've/dm/nodes/ve.dm.PreformattedNode.js',
|
|
've/dm/nodes/ve.dm.TableCellNode.js',
|
|
've/dm/nodes/ve.dm.TableNode.js',
|
|
've/dm/nodes/ve.dm.TableRowNode.js',
|
|
've/dm/nodes/ve.dm.TableSectionNode.js',
|
|
've/dm/nodes/ve.dm.TextNode.js',
|
|
|
|
've/dm/annotations/ve.dm.LinkAnnotation.js',
|
|
've/dm/annotations/ve.dm.TextStyleAnnotation.js',
|
|
|
|
// ce
|
|
've/ce/ve.ce.js',
|
|
've/ce/ve.ce.NodeFactory.js',
|
|
've/ce/ve.ce.Document.js',
|
|
've/ce/ve.ce.Node.js',
|
|
've/ce/ve.ce.BranchNode.js',
|
|
've/ce/ve.ce.LeafNode.js',
|
|
've/ce/ve.ce.Surface.js',
|
|
|
|
've/ce/nodes/ve.ce.AlienInlineNode.js',
|
|
've/ce/nodes/ve.ce.AlienBlockNode.js',
|
|
've/ce/nodes/ve.ce.DefinitionListItemNode.js',
|
|
've/ce/nodes/ve.ce.DefinitionListNode.js',
|
|
've/ce/nodes/ve.ce.DocumentNode.js',
|
|
've/ce/nodes/ve.ce.HeadingNode.js',
|
|
've/ce/nodes/ve.ce.ImageNode.js',
|
|
've/ce/nodes/ve.ce.ListItemNode.js',
|
|
've/ce/nodes/ve.ce.ListNode.js',
|
|
've/ce/nodes/ve.ce.ParagraphNode.js',
|
|
've/ce/nodes/ve.ce.PreformattedNode.js',
|
|
've/ce/nodes/ve.ce.TableCellNode.js',
|
|
've/ce/nodes/ve.ce.TableNode.js',
|
|
've/ce/nodes/ve.ce.TableRowNode.js',
|
|
've/ce/nodes/ve.ce.TableSectionNode.js',
|
|
've/ce/nodes/ve.ce.TextNode.js',
|
|
|
|
// ui
|
|
've/ui/ve.ui.js',
|
|
've/ui/ve.ui.Inspector.js',
|
|
've/ui/ve.ui.Tool.js',
|
|
've/ui/ve.ui.Toolbar.js',
|
|
've/ui/ve.ui.Context.js',
|
|
've/ui/ve.ui.Menu.js',
|
|
|
|
've/ui/inspectors/ve.ui.LinkInspector.js',
|
|
|
|
've/ui/tools/ve.ui.ButtonTool.js',
|
|
've/ui/tools/ve.ui.AnnotationButtonTool.js',
|
|
've/ui/tools/ve.ui.ClearButtonTool.js',
|
|
've/ui/tools/ve.ui.HistoryButtonTool.js',
|
|
've/ui/tools/ve.ui.ListButtonTool.js',
|
|
've/ui/tools/ve.ui.IndentationButtonTool.js',
|
|
've/ui/tools/ve.ui.DropdownTool.js',
|
|
've/ui/tools/ve.ui.FormatDropdownTool.js'
|
|
),
|
|
'styles' => array(
|
|
// ce
|
|
've/ce/styles/ve.ce.DocumentNode.css',
|
|
've/ce/styles/ve.ce.Node.css',
|
|
've/ce/styles/ve.ce.Surface.css',
|
|
// ui
|
|
've/ui/styles/ve.ui.Context.css',
|
|
've/ui/styles/ve.ui.Inspector.css',
|
|
've/ui/styles/ve.ui.Menu.css',
|
|
've/ui/styles/ve.ui.Surface.css',
|
|
've/ui/styles/ve.ui.Toolbar.css',
|
|
),
|
|
'dependencies' => array(
|
|
'jquery',
|
|
'rangy',
|
|
'ext.visualEditor.base',
|
|
'mediawiki.Title',
|
|
),
|
|
'messages' => array(
|
|
'visualeditor',
|
|
'visualeditor-linkinspector-title',
|
|
'visualeditor-linkinspector-label-pagetitle',
|
|
'visualeditor-formatdropdown-title',
|
|
'visualeditor-formatdropdown-format-paragraph',
|
|
'visualeditor-formatdropdown-format-heading1',
|
|
'visualeditor-formatdropdown-format-heading2',
|
|
'visualeditor-formatdropdown-format-heading3',
|
|
'visualeditor-formatdropdown-format-heading4',
|
|
'visualeditor-formatdropdown-format-heading5',
|
|
'visualeditor-formatdropdown-format-heading6',
|
|
'visualeditor-formatdropdown-format-preformatted',
|
|
'visualeditor-annotationbutton-bold-tooltip',
|
|
'visualeditor-annotationbutton-italic-tooltip',
|
|
'visualeditor-annotationbutton-link-tooltip',
|
|
'visualeditor-indentationbutton-indent-tooltip',
|
|
'visualeditor-indentationbutton-outdent-tooltip',
|
|
'visualeditor-listbutton-number-tooltip',
|
|
'visualeditor-listbutton-bullet-tooltip',
|
|
'visualeditor-clearbutton-tooltip',
|
|
'visualeditor-historybutton-undo-tooltip',
|
|
'visualeditor-historybutton-redo-tooltip',
|
|
'visualeditor-viewpage-savewarning',
|
|
'visualeditor-saveerror',
|
|
),
|
|
)
|
|
);
|
|
|
|
/*
|
|
* VisualEditor Namespace
|
|
* Using 2500 and 2501 as per registration on mediawiki.org
|
|
*
|
|
* @see http://www.mediawiki.org/wiki/Extension_default_namespaces
|
|
*/
|
|
define( 'NS_VISUALEDITOR', 2500 );
|
|
define( 'NS_VISUALEDITOR_TALK', 2501 );
|
|
$wgExtraNamespaces[NS_VISUALEDITOR] = 'VisualEditor';
|
|
$wgExtraNamespaces[NS_VISUALEDITOR_TALK] = 'VisualEditor_talk';
|
|
$wgContentNamespaces[] = NS_VISUALEDITOR;
|
|
$wgContentNamespaces[] = NS_VISUALEDITOR_TALK;
|
|
|
|
// VE Namespace protection
|
|
$wgNamespaceProtection[NS_VISUALEDITOR] = array( 've-edit' );
|
|
$wgGroupPermissions['sysop']['ve-edit'] = true;
|
|
|
|
// Parsoid Wrapper API
|
|
$wgAutoloadClasses['ApiVisualEditor'] = $dir . 'ApiVisualEditor.php';
|
|
$wgAPIModules['ve-parsoid'] = 'ApiVisualEditor';
|
|
|
|
// Integration Hooks
|
|
$wgAutoloadClasses['VisualEditorHooks'] = $dir . 'VisualEditor.hooks.php';
|
|
$wgHooks['BeforePageDisplay'][] = 'VisualEditorHooks::onBeforePageDisplay';
|
|
$wgHooks['MakeGlobalVariablesScript'][] = 'VisualEditorHooks::onMakeGlobalVariablesScript';
|
|
|
|
$wgAutoloadClasses['VisualEditorMessagesModule'] = $dir . 'VisualEditorMessagesModule.php';
|