diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/link.js b/addons/web_editor/static/src/js/wysiwyg/widgets/link.js new file mode 100644 index 00000000000..70804bbcd50 --- /dev/null +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/link.js @@ -0,0 +1,421 @@ +odoo.define('wysiwyg.widgets.Link', function (require) { +'use strict'; + +const core = require('web.core'); +const OdooEditorLib = require('web_editor.odoo-editor'); +const wysiwygUtils = require('@web_editor/js/wysiwyg/wysiwyg_utils'); +const Widget = require('web.Widget'); + +const getDeepRange = OdooEditorLib.getDeepRange; +const getInSelection = OdooEditorLib.getInSelection; +const _t = core._t; + +/** + * Allows to customize link content and style. + */ +const Link = Widget.extend({ + xmlDependencies: ['/web_editor/static/src/xml/wysiwyg.xml'], + events: { + 'input': '_onAnyChange', + 'change': '_onAnyChange', + 'input input[name="url"]': '_onURLInput', + }, + + /** + * @constructor + * @param {Boolean} data.isButton - whether if the target is a button element. + */ + init: function (parent, options, editable, data, $button, link) { + this.options = options || {}; + this._super(parent, _.extend({ + title: _t("Link to"), + }, this.options)); + + this.data = data || {}; + this.isButton = this.data.isButton; + this.$button = $button; + + this.data.className = this.data.className || ""; + this.data.iniClassName = this.data.iniClassName || ""; + + // Using explicit type 'link' to preserve style when the target is