(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
/*!
|
2015-05-03 21:21:00 +00:00
|
|
|
* VisualEditor UserInterface LinkAnnotationInspector class.
|
(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
*
|
2023-12-01 16:06:11 +00:00
|
|
|
* @copyright See AUTHORS.txt
|
(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-07-14 21:32:49 +00:00
|
|
|
* Inspector for applying and editing labeled MediaWiki internal and external links.
|
(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
*
|
|
|
|
* @class
|
2015-05-03 21:21:00 +00:00
|
|
|
* @extends ve.ui.LinkAnnotationInspector
|
Context, frame, window, dialog and inspector refactor
This is a major refactor of user interface context, frame, dialog
and inspector classes, including adding several new classes which
generalize managing inspectors/dialogs (which are now subclasses
of window).
New classes:
* ve.ui.Window.js - base class for inspector and dialog classes
* ve.ui.WindowSet.js - manages mutually exclusive windows, used
by surface and context for dialogs and inspectors respectively
* ve.ui.DialogFactory - generates dialogs
* ve.ui.IconButtonWidget - used in inspector for buttons in the head
Refactored classes:
* ve.ui.Context - moved inspector management to window set
* ve.ui.Frame - made iframes initialize asynchronously
* ve.ui.Dialog and ve.ui.Inspector - moved initialization to async
initialize method
Other interesting bits:
ve.ui.*Icons*.css, *.svg, *.png, *.ai
* Merged icon stylesheets so all icons are available inside windows
* Renamed inspector icon to window
ve.ui.*.css
* Reorganized styles so that different windows can include only
what they need
* Moved things to where they belonged (some things were in strange places)
ve.init.Target.js, ve.init.mw.ViewPageTarget.js, ve.init.sa.Target.js
* Removed dialog management - dialogs are managed by the surface now
ve.ui.*Dialog.js
* Renamed title message static property
* Added registration
ve.ui.*Inspector.js
* Switch to accept surface object rather than context, which conforms
to the more general window class without losing any functionality
(in fact, most of the time the surface was what we actually wanted)
ve.ui.MenuWidget.js, ve.ui.MWLinkTargetInputWidget.js
* Using surface overly rather than passing an overlay around
through constructors
Change-Id: Ifd16a1003ff44c48ee7b2c66928cf9cc858b2564
2013-03-13 00:06:57 +00:00
|
|
|
*
|
(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
* @constructor
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
*/
|
2014-08-21 00:50:54 +00:00
|
|
|
ve.ui.MWLinkAnnotationInspector = function VeUiMWLinkAnnotationInspector( config ) {
|
(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
// Parent constructor
|
2017-09-29 15:14:29 +00:00
|
|
|
ve.ui.MWLinkAnnotationInspector.super.call( this, ve.extendObject( { padded: false }, config ) );
|
2019-07-05 16:53:10 +00:00
|
|
|
|
|
|
|
this.$element.addClass( 've-ui-mwLinkAnnotationInspector' );
|
(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2015-05-03 21:21:00 +00:00
|
|
|
OO.inheritClass( ve.ui.MWLinkAnnotationInspector, ve.ui.LinkAnnotationInspector );
|
(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
|
|
|
|
/* Static properties */
|
|
|
|
|
2014-07-27 15:27:16 +00:00
|
|
|
ve.ui.MWLinkAnnotationInspector.static.name = 'link';
|
2013-08-27 23:28:29 +00:00
|
|
|
|
2014-07-27 15:27:16 +00:00
|
|
|
ve.ui.MWLinkAnnotationInspector.static.modelClasses = [
|
2013-11-27 19:16:45 +00:00
|
|
|
ve.dm.MWExternalLinkAnnotation,
|
2014-05-31 04:47:08 +00:00
|
|
|
ve.dm.MWInternalLinkAnnotation
|
2013-04-15 21:35:32 +00:00
|
|
|
];
|
(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
|
2015-08-25 05:48:16 +00:00
|
|
|
ve.ui.MWLinkAnnotationInspector.static.actions = ve.ui.MWLinkAnnotationInspector.static.actions.concat( [
|
|
|
|
{
|
|
|
|
action: 'convert',
|
|
|
|
label: null, // see #updateActions
|
|
|
|
modes: [ 'edit', 'insert' ]
|
|
|
|
}
|
|
|
|
] );
|
|
|
|
|
(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
/* Methods */
|
|
|
|
|
2015-05-03 21:21:00 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.initialize = function () {
|
|
|
|
// Properties
|
|
|
|
this.allowProtocolInInternal = false;
|
2018-06-18 11:09:03 +00:00
|
|
|
this.internalAnnotationInput = this.createInternalAnnotationInput();
|
|
|
|
this.externalAnnotationInput = this.createExternalAnnotationInput();
|
2015-05-03 21:21:00 +00:00
|
|
|
|
2015-09-28 15:05:07 +00:00
|
|
|
this.linkTypeIndex = new OO.ui.IndexLayout( {
|
2019-07-05 16:53:10 +00:00
|
|
|
expanded: false,
|
|
|
|
framed: false
|
2015-05-03 21:21:00 +00:00
|
|
|
} );
|
|
|
|
|
2017-05-10 18:46:49 +00:00
|
|
|
this.linkTypeIndex.addTabPanels( [
|
|
|
|
new OO.ui.TabPanelLayout( 'internal', {
|
2019-07-05 16:53:10 +00:00
|
|
|
label: mw.config.get( 'wgSiteName' ),
|
2015-09-28 15:05:07 +00:00
|
|
|
expanded: false,
|
|
|
|
scrollable: false,
|
|
|
|
padded: true
|
|
|
|
} ),
|
2017-05-10 18:46:49 +00:00
|
|
|
new OO.ui.TabPanelLayout( 'external', {
|
2015-09-28 15:05:07 +00:00
|
|
|
label: ve.msg( 'visualeditor-linkinspector-button-link-external' ),
|
|
|
|
expanded: false,
|
|
|
|
scrollable: false,
|
|
|
|
padded: true
|
|
|
|
} )
|
|
|
|
] );
|
|
|
|
|
2019-07-15 16:32:16 +00:00
|
|
|
// Parent method
|
|
|
|
// Parent requires createAnnotationInput to be callable, but tries to move
|
|
|
|
// inputs in the DOM, so call this before we restructure the DOM.
|
|
|
|
ve.ui.MWLinkAnnotationInspector.super.prototype.initialize.call( this );
|
|
|
|
|
2019-07-29 19:20:17 +00:00
|
|
|
this.internalAnnotationField = this.annotationField;
|
2019-07-15 16:32:16 +00:00
|
|
|
this.externalAnnotationField = new OO.ui.FieldLayout(
|
|
|
|
this.externalAnnotationInput,
|
2019-07-29 19:20:17 +00:00
|
|
|
{
|
|
|
|
align: 'top',
|
|
|
|
label: ve.msg( 'visualeditor-linkinspector-title' )
|
|
|
|
}
|
2019-07-15 16:32:16 +00:00
|
|
|
);
|
|
|
|
|
2015-05-03 21:21:00 +00:00
|
|
|
// Events
|
2015-09-28 15:05:07 +00:00
|
|
|
this.linkTypeIndex.connect( this, { set: 'onLinkTypeIndexSet' } );
|
2019-09-03 14:19:09 +00:00
|
|
|
this.labelInput.connect( this, { change: 'onLabelInputChange' } );
|
2015-05-03 21:21:00 +00:00
|
|
|
this.internalAnnotationInput.connect( this, { change: 'onInternalLinkChange' } );
|
2015-05-29 12:07:05 +00:00
|
|
|
this.externalAnnotationInput.connect( this, { change: 'onExternalLinkChange' } );
|
2015-10-14 10:03:42 +00:00
|
|
|
this.internalAnnotationInput.input.getResults().connect( this, { choose: 'onFormSubmit' } );
|
2015-09-28 15:05:07 +00:00
|
|
|
// Form submit only auto triggers on enter when there is one input
|
2019-07-04 04:37:36 +00:00
|
|
|
this.internalAnnotationInput.getTextInputWidget().connect( this, {
|
|
|
|
change: 'onInternalLinkInputChange',
|
|
|
|
enter: 'onLinkInputEnter'
|
|
|
|
} );
|
|
|
|
this.externalAnnotationInput.getTextInputWidget().connect( this, {
|
|
|
|
change: 'onExternalLinkInputChange',
|
|
|
|
enter: 'onLinkInputEnter'
|
|
|
|
} );
|
2019-07-29 19:20:17 +00:00
|
|
|
// this.internalAnnotationInput is already bound by parent class
|
|
|
|
this.externalAnnotationInput.connect( this, { change: 'onAnnotationInputChange' } );
|
2015-05-03 21:21:00 +00:00
|
|
|
|
2015-09-25 20:29:10 +00:00
|
|
|
this.internalAnnotationInput.input.results.connect( this, {
|
2019-07-04 04:37:36 +00:00
|
|
|
add: 'onInternalLinkChangeResultsChange',
|
2015-09-25 20:29:10 +00:00
|
|
|
// Listening to remove causes a flicker, and is not required
|
|
|
|
// as 'add' is always trigger on a change too
|
2019-07-04 04:37:36 +00:00
|
|
|
choose: 'onInternalLinkSearchResultsChoose'
|
2015-09-25 20:29:10 +00:00
|
|
|
} );
|
|
|
|
|
2015-05-03 21:21:00 +00:00
|
|
|
// Initialization
|
2015-09-28 15:05:07 +00:00
|
|
|
// HACK: IndexLayout is absolutely positioned, so place actions inside it
|
|
|
|
this.linkTypeIndex.$content.append( this.$otherActions );
|
2019-07-15 16:32:16 +00:00
|
|
|
this.linkTypeIndex.getTabPanel( 'internal' ).$element.append( this.internalAnnotationField.$element );
|
2019-07-15 13:53:49 +00:00
|
|
|
this.linkTypeIndex.getTabPanel( 'external' ).$element.append( this.externalAnnotationField.$element );
|
2019-07-29 19:20:17 +00:00
|
|
|
// labelField gets moved between tabs when activated
|
|
|
|
if ( OO.ui.isMobile() ) {
|
|
|
|
this.linkTypeIndex.getTabPanel( 'internal' ).$element.prepend( this.labelField.$element );
|
|
|
|
}
|
2019-06-23 15:58:04 +00:00
|
|
|
this.form.$element.empty().append( this.linkTypeIndex.$element );
|
2019-07-29 19:20:17 +00:00
|
|
|
if ( !OO.ui.isMobile() ) {
|
|
|
|
this.externalAnnotationField.setLabel( null );
|
|
|
|
}
|
2015-05-03 21:21:00 +00:00
|
|
|
};
|
|
|
|
|
2018-06-18 11:09:03 +00:00
|
|
|
/**
|
|
|
|
* @return {ve.ui.MWInternalLinkAnnotationWidget}
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.createInternalAnnotationInput = function () {
|
|
|
|
return new ve.ui.MWInternalLinkAnnotationWidget();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {ve.ui.MWExternalLinkAnnotationWidget}
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.createExternalAnnotationInput = function () {
|
|
|
|
return new ve.ui.MWExternalLinkAnnotationWidget();
|
|
|
|
};
|
|
|
|
|
2015-05-03 21:21:00 +00:00
|
|
|
/**
|
|
|
|
* Check if the current input mode is for external links
|
|
|
|
*
|
|
|
|
* @return {boolean} Input mode is for external links
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.isExternal = function () {
|
2017-05-10 18:46:49 +00:00
|
|
|
return this.linkTypeIndex.getCurrentTabPanelName() === 'external';
|
2015-05-03 21:21:00 +00:00
|
|
|
};
|
|
|
|
|
2019-09-03 14:19:09 +00:00
|
|
|
/**
|
|
|
|
* Handle change events on the label input
|
|
|
|
*
|
|
|
|
* @param {string} value
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.onLabelInputChange = function () {
|
|
|
|
if ( this.isActive && !this.trackedLabelInputChange ) {
|
|
|
|
ve.track( 'activity.' + this.constructor.static.name, { action: 'label-input' } );
|
|
|
|
this.trackedLabelInputChange = true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-29 12:07:05 +00:00
|
|
|
/**
|
|
|
|
* Handle change events on the internal link widget
|
|
|
|
*
|
2021-06-04 11:58:18 +00:00
|
|
|
* @param {ve.dm.MWInternalLinkAnnotation} annotation
|
2015-05-29 12:07:05 +00:00
|
|
|
*/
|
2016-07-28 15:52:58 +00:00
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.onInternalLinkChange = function () {
|
2015-05-29 12:07:05 +00:00
|
|
|
this.updateActions();
|
|
|
|
};
|
|
|
|
|
2015-09-25 20:29:10 +00:00
|
|
|
/**
|
|
|
|
* Handle list change events ('add') from the interal link's result widget
|
|
|
|
*
|
|
|
|
* @param {OO.ui.OptionWidget[]} items Added items
|
|
|
|
* @param {number} index Index of insertion point
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.onInternalLinkChangeResultsChange = function () {
|
|
|
|
this.updateSize();
|
|
|
|
};
|
|
|
|
|
2019-07-04 04:37:36 +00:00
|
|
|
/**
|
|
|
|
* Handle choose events from the result widget
|
|
|
|
*
|
|
|
|
* @param {OO.ui.OptionWidget} item Chosen item
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.onInternalLinkSearchResultsChoose = function () {
|
|
|
|
ve.track( 'activity.' + this.constructor.static.name, { action: 'search-pages-choose' } );
|
|
|
|
};
|
|
|
|
|
2015-05-29 12:07:05 +00:00
|
|
|
/**
|
|
|
|
* Handle change events on the external link widget
|
|
|
|
*
|
2021-06-04 11:58:18 +00:00
|
|
|
* @param {ve.dm.MWExternalLinkAnnotation} annotation
|
2015-05-29 12:07:05 +00:00
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.onExternalLinkChange = function () {
|
|
|
|
this.updateActions();
|
2015-05-03 21:21:00 +00:00
|
|
|
};
|
|
|
|
|
2019-01-24 17:17:04 +00:00
|
|
|
/**
|
|
|
|
* Handle enter events on the external/internal link inputs
|
|
|
|
*
|
|
|
|
* @param {jQuery.Event} e Key press event
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.onLinkInputEnter = function () {
|
|
|
|
if ( this.annotationInput.getTextInputWidget().getValue().trim() === '' ) {
|
|
|
|
this.executeAction( 'done' );
|
|
|
|
}
|
|
|
|
this.annotationInput.getTextInputWidget().getValidity()
|
2024-04-30 16:44:25 +00:00
|
|
|
.done( () => {
|
2024-05-01 12:32:49 +00:00
|
|
|
this.executeAction( 'done' );
|
2019-01-24 17:17:04 +00:00
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
2015-08-25 05:48:16 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.updateActions = function () {
|
2022-02-21 18:07:07 +00:00
|
|
|
var msg = null;
|
2015-08-25 05:48:16 +00:00
|
|
|
|
|
|
|
ve.ui.MWLinkAnnotationInspector.super.prototype.updateActions.call( this );
|
|
|
|
|
|
|
|
// show/hide convert action
|
2022-02-21 18:07:07 +00:00
|
|
|
var content = this.fragment ? this.fragment.getText() : '';
|
|
|
|
var annotation = this.annotationInput.getAnnotation();
|
|
|
|
var href = annotation && annotation.getHref();
|
2015-08-25 05:48:16 +00:00
|
|
|
if ( href && ve.dm.MWMagicLinkNode.static.validateHref( content, href ) ) {
|
2022-02-21 18:07:07 +00:00
|
|
|
var type = ve.dm.MWMagicLinkType.static.fromContent( content ).type;
|
2015-08-25 05:48:16 +00:00
|
|
|
msg = 'visualeditor-linkinspector-convert-link-' + type.toLowerCase();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Once we toggle the visibility of the ActionWidget, we can't filter
|
|
|
|
// it with `get` any more. So we have to use `forEach`:
|
2024-04-30 16:44:25 +00:00
|
|
|
this.actions.forEach( null, ( action ) => {
|
2015-08-25 05:48:16 +00:00
|
|
|
if ( action.getAction() === 'convert' ) {
|
|
|
|
if ( msg ) {
|
2019-11-01 16:20:22 +00:00
|
|
|
// The following messages are used here:
|
|
|
|
// * visualeditor-linkinspector-convert-link-isbn
|
|
|
|
// * visualeditor-linkinspector-convert-link-pmid
|
|
|
|
// * visualeditor-linkinspector-convert-link-rfc
|
2015-08-25 05:48:16 +00:00
|
|
|
action.setLabel( OO.ui.deferMsg( msg ) );
|
|
|
|
action.toggle( true );
|
|
|
|
} else {
|
|
|
|
action.toggle( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
2016-07-28 15:52:58 +00:00
|
|
|
/**
|
|
|
|
* Handle change events on the internal link widget's input
|
|
|
|
*
|
|
|
|
* @param {string} value Current value of input widget
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.onInternalLinkInputChange = function ( value ) {
|
2017-05-10 18:46:49 +00:00
|
|
|
// If this looks like an external link, switch to the correct tabPanel.
|
2016-07-28 15:52:58 +00:00
|
|
|
// Note: We don't care here if it's a *valid* link, so we just
|
|
|
|
// check whether it looks like a URI -- i.e. whether it starts with
|
|
|
|
// something that appears to be a schema per RFC1630. Later the external
|
|
|
|
// link inspector will use getExternalLinkUrlProtocolsRegExp for validity
|
|
|
|
// checking.
|
|
|
|
// Note 2: RFC1630 might be too broad in practice. You don't really see
|
|
|
|
// schemas that use the full set of allowed characters, and we might get
|
|
|
|
// more false positives by checking for them.
|
|
|
|
// Note 3: We allow protocol-relative URIs here.
|
2016-09-22 16:23:48 +00:00
|
|
|
if ( this.internalAnnotationInput.getTextInputWidget().getValue() !== value ) {
|
|
|
|
return;
|
|
|
|
}
|
2019-07-04 04:37:36 +00:00
|
|
|
if ( this.isActive && !this.trackedInternalLinkInputChange && !this.switchingLinkTypes ) {
|
|
|
|
ve.track( 'activity.' + this.constructor.static.name, { action: 'search-pages-input' } );
|
|
|
|
this.trackedInternalLinkInputChange = true;
|
|
|
|
}
|
2016-07-28 15:52:58 +00:00
|
|
|
if (
|
|
|
|
!this.allowProtocolInInternal &&
|
2019-07-09 08:08:23 +00:00
|
|
|
( /^(?:[a-z][a-z0-9$\-_@.&!*"'(),]*:)?\/\//i ).test( value.trim() )
|
2016-07-28 15:52:58 +00:00
|
|
|
) {
|
2017-05-10 18:46:49 +00:00
|
|
|
this.linkTypeIndex.setTabPanel( 'external' );
|
|
|
|
// Changing tabPanel focuses and selects the input, so collapse the cursor back to the end.
|
2016-07-28 15:52:58 +00:00
|
|
|
this.externalAnnotationInput.getTextInputWidget().moveCursorToEnd();
|
|
|
|
}
|
2019-07-15 16:32:16 +00:00
|
|
|
|
|
|
|
this.internalAnnotationInput.getTextInputWidget().getValidity()
|
|
|
|
.then(
|
2024-04-30 16:44:25 +00:00
|
|
|
() => {
|
2024-05-01 12:32:49 +00:00
|
|
|
this.internalAnnotationField.setErrors( [] );
|
|
|
|
this.updateSize();
|
2024-04-30 16:44:25 +00:00
|
|
|
}, () => {
|
2024-05-01 12:32:49 +00:00
|
|
|
this.internalAnnotationField.setErrors( [ ve.msg( 'visualeditor-linkinspector-illegal-title' ) ] );
|
|
|
|
this.updateSize();
|
2019-07-15 16:32:16 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2016-07-28 15:52:58 +00:00
|
|
|
};
|
|
|
|
|
2019-07-04 04:37:36 +00:00
|
|
|
/**
|
|
|
|
* Handle change events on the external link widget's input
|
|
|
|
*
|
|
|
|
* @param {string} value Current value of input widget
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.onExternalLinkInputChange = function () {
|
2019-07-15 13:53:49 +00:00
|
|
|
this.externalAnnotationInput.getTextInputWidget().getValidity()
|
|
|
|
.then(
|
2024-04-30 16:44:25 +00:00
|
|
|
() => {
|
2024-05-01 12:32:49 +00:00
|
|
|
this.externalAnnotationField.setErrors( [] );
|
|
|
|
this.updateSize();
|
2024-04-30 16:44:25 +00:00
|
|
|
}, () => {
|
2024-05-01 12:32:49 +00:00
|
|
|
this.externalAnnotationField.setErrors( [ ve.msg( 'visualeditor-linkinspector-invalid-external' ) ] );
|
|
|
|
this.updateSize();
|
2019-07-15 13:53:49 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2019-07-04 04:37:36 +00:00
|
|
|
if ( this.isActive && !this.trackedExternalLinkInputChange && !this.switchingLinkTypes ) {
|
|
|
|
ve.track( 'activity.' + this.constructor.static.name, { action: 'external-link-input' } );
|
|
|
|
this.trackedExternalLinkInputChange = true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-03 21:21:00 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.createAnnotationInput = function () {
|
|
|
|
return this.isExternal() ? this.externalAnnotationInput : this.internalAnnotationInput;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.getSetupProcess = function ( data ) {
|
|
|
|
return ve.ui.MWLinkAnnotationInspector.super.prototype.getSetupProcess.call( this, data )
|
2024-04-30 21:25:39 +00:00
|
|
|
.next( () => {
|
2022-11-18 13:25:40 +00:00
|
|
|
this.isReady = false;
|
|
|
|
|
2019-02-08 19:18:22 +00:00
|
|
|
var isReadOnly = this.isReadOnly();
|
2017-05-10 18:46:49 +00:00
|
|
|
this.linkTypeIndex.setTabPanel(
|
2015-05-08 15:15:16 +00:00
|
|
|
this.initialAnnotation instanceof ve.dm.MWExternalLinkAnnotation ? 'external' : 'internal'
|
2015-05-03 21:21:00 +00:00
|
|
|
);
|
|
|
|
this.annotationInput.setAnnotation( this.initialAnnotation );
|
2019-02-08 19:18:22 +00:00
|
|
|
this.internalAnnotationInput.setReadOnly( isReadOnly );
|
|
|
|
this.externalAnnotationInput.setReadOnly( isReadOnly );
|
2019-07-04 04:37:36 +00:00
|
|
|
|
|
|
|
this.trackedInternalLinkInputChange = false;
|
|
|
|
this.trackedExternalLinkInputChange = false;
|
|
|
|
this.isActive = true;
|
2024-04-30 21:25:39 +00:00
|
|
|
} );
|
2015-05-03 21:21:00 +00:00
|
|
|
};
|
|
|
|
|
2022-11-18 13:25:40 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.getReadyProcess = function ( data ) {
|
|
|
|
return ve.ui.MWLinkAnnotationInspector.super.prototype.getReadyProcess.call( this, data )
|
2024-04-30 21:25:39 +00:00
|
|
|
.next( () => {
|
2022-11-18 13:25:40 +00:00
|
|
|
this.isReady = true;
|
|
|
|
// Focus is skipped during setup. (T321026)
|
|
|
|
this.annotationInput.getTextInputWidget().focus();
|
2024-04-30 21:25:39 +00:00
|
|
|
} );
|
2022-11-18 13:25:40 +00:00
|
|
|
};
|
|
|
|
|
2015-08-25 05:48:16 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.getActionProcess = function ( action ) {
|
|
|
|
if ( action === 'convert' ) {
|
2024-04-30 21:25:39 +00:00
|
|
|
return new OO.ui.Process( () => {
|
2015-08-25 05:48:16 +00:00
|
|
|
this.close( { action: 'done', convert: true } );
|
2024-04-30 21:25:39 +00:00
|
|
|
} );
|
2015-08-25 05:48:16 +00:00
|
|
|
}
|
|
|
|
return ve.ui.MWLinkAnnotationInspector.super.prototype.getActionProcess.call( this, action );
|
|
|
|
};
|
|
|
|
|
2015-05-03 21:21:00 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.getTeardownProcess = function ( data ) {
|
2015-08-25 05:48:16 +00:00
|
|
|
var fragment;
|
2015-05-03 21:21:00 +00:00
|
|
|
return ve.ui.MWLinkAnnotationInspector.super.prototype.getTeardownProcess.call( this, data )
|
2024-04-30 21:25:39 +00:00
|
|
|
.first( () => {
|
2015-08-25 05:48:16 +00:00
|
|
|
// Save the original fragment for later.
|
|
|
|
fragment = this.getFragment();
|
2019-07-04 04:37:36 +00:00
|
|
|
|
|
|
|
this.isActive = false;
|
2024-04-30 21:25:39 +00:00
|
|
|
} )
|
|
|
|
.next( () => {
|
2022-02-21 18:07:07 +00:00
|
|
|
var selection = fragment && fragment.getSelection();
|
2015-08-25 05:48:16 +00:00
|
|
|
|
|
|
|
// Handle conversion to magic link.
|
2015-09-02 20:30:51 +00:00
|
|
|
if ( data && data.convert && selection instanceof ve.dm.LinearSelection ) {
|
2022-02-21 18:07:07 +00:00
|
|
|
var annotations = fragment.getDocument().data
|
2015-09-15 21:27:28 +00:00
|
|
|
.getAnnotationsFromRange( selection.getRange() )
|
|
|
|
// Remove link annotations
|
2024-04-30 16:44:25 +00:00
|
|
|
.filter( ( annotation ) => !/^link/.test( annotation.name ) );
|
2022-02-21 18:07:07 +00:00
|
|
|
var linearData = new ve.dm.ElementLinearData( annotations.store, [
|
2015-08-25 05:48:16 +00:00
|
|
|
{
|
|
|
|
type: 'link/mwMagic',
|
|
|
|
attributes: {
|
|
|
|
content: fragment.getText()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: '/link/mwMagic'
|
|
|
|
}
|
2015-09-15 21:27:28 +00:00
|
|
|
] );
|
2020-08-18 12:16:49 +00:00
|
|
|
linearData.setAnnotationsAtOffset( 0, annotations );
|
|
|
|
fragment.insertContent( linearData.getData(), true );
|
2015-08-25 05:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Clear dialog state.
|
2015-05-03 21:21:00 +00:00
|
|
|
this.allowProtocolInInternal = false;
|
2015-06-05 15:17:29 +00:00
|
|
|
// Make sure both inputs are cleared
|
|
|
|
this.internalAnnotationInput.setAnnotation( null );
|
|
|
|
this.externalAnnotationInput.setAnnotation( null );
|
2024-04-30 21:25:39 +00:00
|
|
|
} );
|
2015-05-03 21:21:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2015-09-28 15:05:07 +00:00
|
|
|
* Handle set events from the linkTypeIndex layout
|
2015-05-03 21:21:00 +00:00
|
|
|
*
|
2017-05-10 18:46:49 +00:00
|
|
|
* @param {OO.ui.TabPanelLayout} tabPanel Current tabPanel
|
2015-05-03 21:21:00 +00:00
|
|
|
*/
|
2019-07-29 19:20:17 +00:00
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.onLinkTypeIndexSet = function ( tabPanel ) {
|
2015-09-25 20:25:31 +00:00
|
|
|
var text = this.annotationInput.getTextInputWidget().getValue(),
|
2015-06-04 17:23:34 +00:00
|
|
|
end = text.length,
|
2015-05-03 21:21:00 +00:00
|
|
|
isExternal = this.isExternal(),
|
|
|
|
inputHasProtocol = ve.init.platform.getExternalLinkUrlProtocolsRegExp().test( text );
|
|
|
|
|
2019-07-04 04:37:36 +00:00
|
|
|
this.switchingLinkTypes = true;
|
|
|
|
|
2015-09-28 15:05:07 +00:00
|
|
|
this.annotationInput = isExternal ? this.externalAnnotationInput : this.internalAnnotationInput;
|
2015-05-03 21:21:00 +00:00
|
|
|
|
2019-07-29 19:20:17 +00:00
|
|
|
if ( OO.ui.isMobile() ) {
|
|
|
|
tabPanel.$element.prepend( this.labelField.$element );
|
|
|
|
}
|
|
|
|
|
2015-09-25 20:29:10 +00:00
|
|
|
this.updateSize();
|
|
|
|
|
2015-06-02 21:03:08 +00:00
|
|
|
// If the user manually switches to internal links with an external link in the input, remember this
|
|
|
|
if ( !isExternal && inputHasProtocol ) {
|
|
|
|
this.allowProtocolInInternal = true;
|
2015-05-03 21:21:00 +00:00
|
|
|
}
|
|
|
|
|
2022-11-18 13:25:40 +00:00
|
|
|
this.annotationInput.getTextInputWidget().setValue( text );
|
|
|
|
if ( this.isReady ) {
|
|
|
|
// Focussing an element that isn't visible yet triggers a
|
|
|
|
// bug in jQuery that prevents future focusses. (T321026)
|
|
|
|
this.annotationInput.getTextInputWidget().focus();
|
|
|
|
}
|
2016-03-28 16:38:45 +00:00
|
|
|
// Select entire link when switching, for ease of replacing entire contents.
|
|
|
|
// Most common case:
|
|
|
|
// 1. Inspector opened, internal-link shown with the selected-word prefilled
|
|
|
|
// 2. User clicks external link tab (unnecessary, because we'd auto-switch, but the user doesn't know that)
|
|
|
|
// 3. User pastes a link, intending to replace the existing prefilled link
|
|
|
|
this.annotationInput.getTextInputWidget().$input[ 0 ].setSelectionRange( 0, end );
|
2017-08-29 16:28:29 +00:00
|
|
|
// Focusing a TextInputWidget normally unsets validity. However, because
|
|
|
|
// we're kind of pretending this is the same input, just in a different
|
|
|
|
// mode, it doesn't make sense to the user that the focus behavior occurs.
|
|
|
|
this.annotationInput.getTextInputWidget().setValidityFlag();
|
2015-05-03 21:21:00 +00:00
|
|
|
|
2019-07-29 19:20:17 +00:00
|
|
|
this.onAnnotationInputChange();
|
2019-07-04 04:37:36 +00:00
|
|
|
|
|
|
|
if ( this.isActive ) {
|
|
|
|
ve.track( 'activity.' + this.constructor.static.name, { action: 'panel-switch' } );
|
|
|
|
}
|
|
|
|
|
|
|
|
this.switchingLinkTypes = false;
|
2015-05-03 21:21:00 +00:00
|
|
|
};
|
|
|
|
|
(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
/**
|
2014-01-27 21:11:06 +00:00
|
|
|
* Gets an annotation object from a fragment.
|
(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
*
|
|
|
|
* The type of link is automatically detected based on some crude heuristics.
|
|
|
|
*
|
2014-01-27 21:11:06 +00:00
|
|
|
* @param {ve.dm.SurfaceFragment} fragment Current selection
|
2015-08-19 18:09:34 +00:00
|
|
|
* @return {ve.dm.MWInternalLinkAnnotation|ve.dm.MWExternalLinkAnnotation|null}
|
(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
*/
|
2014-07-27 15:27:16 +00:00
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.getAnnotationFromFragment = function ( fragment ) {
|
2014-01-27 21:11:06 +00:00
|
|
|
var target = fragment.getText(),
|
|
|
|
title = mw.Title.newFromText( target );
|
2013-04-25 01:18:27 +00:00
|
|
|
|
(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
// Figure out if this is an internal or external link
|
|
|
|
if ( ve.init.platform.getExternalLinkUrlProtocolsRegExp().test( target ) ) {
|
|
|
|
// External link
|
2018-06-18 11:09:03 +00:00
|
|
|
return this.newExternalLinkAnnotation( {
|
2014-08-22 20:50:48 +00:00
|
|
|
type: 'link/mwExternal',
|
|
|
|
attributes: {
|
|
|
|
href: target
|
Great Annotation Refactor of 2013
This changes the annotation API to be the same as the node API, sans
a few boolean flags that don't apply. The APIs were different, but
there was really no good reason why, so this makes things simpler for
API users. It also means we'll be able to factor a bunch of things out
because they're now duplicated between nodes, meta items and annotations.
Linear model annotations are now objects with 'type' and 'attributes'
properties (rather than 'name' and 'data'), for consistency with elements.
They now also contain html/0/* attributes for HTML attribute preservation,
which obsoletes the htmlTagName and htmlAttributes properties.
dm.Annotation subclasses take a reference to such an object and implement
conversion using .static.toDataElement and .static.toDomElements just
like nodes do. The custom .getHash() functions are no longer necessary
because of the way HTML attribute preservation was reimplemented.
CE rendering has been moved out of dm.Annotation (it never made sense to
have CE rendering functions in DM classes, this was bothering me) and into
separate ce.Annotation subclasses. These are very similar to CE nodes in
that they have a this.$ generated based on something in the DM; the main
difference is that nodes listen to events and update themselves, whereas
annotations are static and are simply destroyed and rebuilt when they
change. This change also adds whitelisted HTML attribute rendering for
annotations, as well as class="ve-ce-FooAnnotation" attributes.
Now that annotation classes produce real DOM nodes rather than weird
objects describing HTML tags, we can't generate HTML as a string in
ce.ContentBranchNode anymore. getRenderedContents() has been rewritten
to be much more similar to the way the converter renders annotations;
in fact, significant parts of it were copied from the converter, so that
should be factored out in the future. This change actually fixes an
annotation rendering discrepancy between ce.ContentBranchNode and
dm.Converter; see the diff of ve.ce.ContentBranchNode.test.js.
ve.ce.MWEntityNode.js:
* Remove stray property
ve.dm.MWExternalLinkAnnotation.js:
* Store 'rel' attribute
ve.dm.TextStyleAnnotation.js:
* Put all the conversion logic in the abstract base class
ve.dm.Converter.js:
* Also feed annotations through getDomElementsFromDataElement() and
createDataElement()
ve.dm.Node.js:
* Fix undocumented property
ve.ce.ContentBranchNode.test.js:
* Add descriptive messages for each test case
* Compare DOM trees, not HTML strings
* Compare without all the class="ve-ce-WhateverAnnotation" clutter
ve.ui.LinkInspector.js:
* Replace direct .getHash() calls (evil!) with ve.getHash()
Bug: 46464
Bug: 44808
Change-Id: I31991488579b8cce6d98ed8b29b486ba5ec38cdc
2013-04-02 17:23:33 +00:00
|
|
|
}
|
|
|
|
} );
|
2013-10-09 21:29:29 +00:00
|
|
|
} else if ( title ) {
|
(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
// Internal link
|
2018-06-18 11:09:03 +00:00
|
|
|
return this.newInternalLinkAnnotationFromTitle( title );
|
2013-08-01 11:53:11 +00:00
|
|
|
} else {
|
2013-10-09 21:29:29 +00:00
|
|
|
// Doesn't look like an external link and mw.Title considered it an illegal value,
|
|
|
|
// for an internal link.
|
2013-08-01 11:53:11 +00:00
|
|
|
return null;
|
(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-06-18 11:09:03 +00:00
|
|
|
/**
|
|
|
|
* @param {mw.Title} title The title to link to.
|
|
|
|
* @return {ve.dm.MWInternalLinkAnnotation} The annotation.
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.newInternalLinkAnnotationFromTitle = function ( title ) {
|
|
|
|
return ve.dm.MWInternalLinkAnnotation.static.newFromTitle( title );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Object} element
|
|
|
|
* @return {ve.dm.MWExternalLinkAnnotation} The annotation.
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.newExternalLinkAnnotation = function ( element ) {
|
|
|
|
return new ve.dm.MWExternalLinkAnnotation( element );
|
|
|
|
};
|
|
|
|
|
2019-07-29 19:20:17 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.getInsertionText = function () {
|
2024-02-22 17:39:29 +00:00
|
|
|
// Prefer user input, not normalized annotation, to preserve case
|
|
|
|
var label = this.labelInput.getValue().trim();
|
|
|
|
if ( label ) {
|
|
|
|
return label;
|
|
|
|
} else if ( this.isNew && this.isExternal() ) {
|
2019-07-29 19:20:17 +00:00
|
|
|
return '';
|
|
|
|
} else {
|
2024-02-22 17:39:29 +00:00
|
|
|
return this.annotationInput.getTextInputWidget().getValue();
|
2019-07-29 19:20:17 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-07-01 16:50:08 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWLinkAnnotationInspector.prototype.getInsertionData = function () {
|
2024-02-22 17:39:29 +00:00
|
|
|
// If this is a new external link with no label, insert an autonumbered link instead of a link annotation
|
2020-06-10 11:15:18 +00:00
|
|
|
// (applying the annotation on this later does nothing because of disallowedAnnotationTypes).
|
2019-07-30 22:21:45 +00:00
|
|
|
// Otherwise call parent method to figure out the text to insert and annotate.
|
2024-02-22 17:39:29 +00:00
|
|
|
if ( this.isNew && this.isExternal() && !this.labelInput.getValue().trim() ) {
|
2014-07-01 16:50:08 +00:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
type: 'link/mwNumberedExternal',
|
|
|
|
attributes: {
|
2015-05-03 21:21:00 +00:00
|
|
|
href: this.annotationInput.getHref()
|
2014-07-01 16:50:08 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{ type: '/link/mwNumberedExternal' }
|
|
|
|
];
|
|
|
|
} else {
|
2019-07-29 19:20:17 +00:00
|
|
|
return this.getInsertionText().split( '' );
|
2014-07-01 16:50:08 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-05-05 13:31:20 +00:00
|
|
|
// #getInsertionText call annotationInput#getHref, which returns the link title,
|
|
|
|
// so no custmisation is needed.
|
2015-07-09 01:01:38 +00:00
|
|
|
|
(bug 43841) Major ve.ui rewrite, especially ve.ui.LinkInspector
Objectives:
* Make the link inspector easier to use
* Try to resolve a few bugs (bug 43841, bug 43063, bug 42986)
* Stop using jquery.multiSuggest (which didn't really understand annotations)
* Better divide MediaWiki specifics from generic implementations
Changes:
VisualEditor.php, modules/ve/test/index.php, demos/ve/index.php
* Updated links to files
ve.Registry
* Fixed mistake where registry was initialized as an array - this didn't cause any errors because you can add arbitrary properties to an array and use it like any other object
ve.Factory
* Removed duplicate initialization of registry property
* Added entries property, which is an array that's appended to for tracking the order of registrations
ve.CommandRegistry
* Added mwLink command which opens the mwLink inspector
ve.ui.TextInputWidget
* Added basic widget class for text inputs
ve.ui.TextInputMenuWidget
* Added widget that provides a menu of options for a text input widget
ve.ui.MWLinkTargetInputWidget
* Added MediaWiki specific link target widget
ve.ui.MenuWidget
* Converted ve.ui.Menu into a widget
* Moved the body of onSelect to onMouseUp
ve.ui.LinkTargetInputWidget
* Added link target widget which adds link annotation functionality to a normal text input
ve.ui.InputWidget
* Added generic input widget which emits reliable and instant change events and synchronizes a value property with the DOM value
ve.ui.Widget
* Added base widget class
* Widgets can be used in any frame
ve.ui.Tool
* Fixed line length issues
ve.ui.InspectorFactory
* Made use of new entries property for factories to select the most recently added inspector if more than one match a given annotation
ve.ui.Inspector
* Added auto-focus on the first visible input element on open
* Moved afterClose event to after re-focus on document on close
* Added documentation
ve.ui.Frame
* Adjusted documentation
* Added binding of $$ to the frame context so it can be passed around
* Added documentation
ve.ui.Context
* Added ve.ui.Widget.css to iframes
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
* Removed unused positionBelowOverlay method
* Added CSS settings to set overlay left and width properties according to context size
* Added documentation
ve.ui.DropdownTool
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.FormatDropdownTool
* Added documentation
ve.ui.MWLinkButtonTool
* Added MediaWiki specific version of ve.ui.LinkButtonTool, which opens the mwLink inspector
ve.ui.Widget.css
* Added styles for all widgets
ve.ui.Tool.css, ve.init.sa.css, ve.init.mw.ViewPageTarget.css, ve.init.mw.ViewPageTarget-apex.css
* Updated code as per moving of ve.ui.Menu to ve.ui.MenuWidget
ve.ui.Menu.css
* Deleted (merged into ve.ui.Widget.css)
ve.ui.Menu.css
* Deleted suggest styles (no longer used)
pending.gif, pending.psd
* Added diagonal stripe animation to indicate a pending request to the API
ve.ui.MWLinkInspector
* Added MediaWiki specific inspector which uses MediaWiki specific annotations and widgets
ve.ui.LinkInspector
* Removed mw global hint (not needed anymore)
* Switched from comparing targets to annotations (since the target text is ambiguous in some situations)
* Switched to using input widget, which is configured using a static property
* Removed use of jquery.multiSuggest
* Moved MediaWiki specifics to their own class (ve.ui.MWLinkInspector)
ve.init.mw.ViewPageTarget
* Added MediaWiki specific toolbar and command options
Change-Id: I859b5871a9d2f17d970c002067c8ff24f3513e9f
2013-01-09 21:34:23 +00:00
|
|
|
/* Registration */
|
|
|
|
|
2014-07-27 15:27:16 +00:00
|
|
|
ve.ui.windowFactory.register( ve.ui.MWLinkAnnotationInspector );
|