[REM] web_editor: remove dead base.js code again

Here is a long but incomplete history of events:
- At some point, a web_editor "base.js" file was created, mainly to be
  able to wait for all resources before doing some operations.
- For the upcoming release of 13.0, a new editor was merged with [1] and
  the file was moved to website instead of web_editor.
- Shortly after, with [2], the file was moved from website to portal.
- A month later, the file was removed thanks to [3] as there was no need
  for the utils it provided anymore.
- Before the 13.0 release, the new editor made at [1] was reverted with
  [4]... but reintroduced the base.js web_editor file by mistake.
- Post 13.0-release, [5] saw the mistake and commented the file to
  indicate that it should be removed again... however it was not able to
  be removed at forward-port at the time because some new code was using
  the utils of the file again (probably by mistake).
- With [6], part of the file was removed, probably because the related
  behavior was refactored.

With this commit, we hopefully get rid of this file for good. No code
uses it anymore so it could simply be dropped.

[1]: https://github.com/odoo/odoo/commit/f296992317e96562c66bd7ad59a5080d6c551ed5
[2]: https://github.com/odoo/odoo/commit/6521cf4f662a62912b54f52a1236935634913053
[3]: https://github.com/odoo/odoo/commit/da1899af48902edec7ac6ed8dd5ae2f8b02ec689
[4]: https://github.com/odoo/odoo/commit/0c52c94f8ece6a7e5ddd905256f5507cf7bab199
[5]: https://github.com/odoo/odoo/commit/5ac269d722f9ff8c206215dd1c07b8544cfd5382
[6]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b

Following task-2687506

closes odoo/odoo#94794

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
qsm-odoo
2022-06-28 19:33:54 +02:00
parent 63e175d9ec
commit 69d89577c8
2 changed files with 0 additions and 137 deletions
-1
View File
@@ -70,7 +70,6 @@ Odoo Web Editor widget.
'web_editor/static/src/scss/wysiwyg_iframe.scss',
'web_editor/static/src/scss/wysiwyg_snippets.scss',
'web_editor/static/src/js/base.js',
'web_editor/static/src/js/editor/perspective_utils.js',
'web_editor/static/src/js/editor/image_processing.js',
'web_editor/static/src/js/editor/custom_colors.js',
-136
View File
@@ -1,136 +0,0 @@
odoo.define('web_editor.base', function (require) {
'use strict';
// TODO this should be re-removed as soon as possible.
var ajax = require('web.ajax');
var session = require('web.session');
var domReady = new Promise(function(resolve) {
$(resolve);
});
return {
/**
* Retrieves all the CSS rules which match the given parser (Regex).
*
* @param {Regex} filter
* @returns {Object[]} Array of CSS rules descriptions (objects). A rule is
* defined by 3 values: 'selector', 'css' and 'names'. 'selector'
* is a string which contains the whole selector, 'css' is a string
* which contains the css properties and 'names' is an array of the
* first captured groups for each selector part. E.g.: if the
* filter is set to match .fa-* rules and capture the icon names,
* the rule:
* '.fa-alias1::before, .fa-alias2::before { hello: world; }'
* will be retrieved as
* {
* selector: '.fa-alias1::before, .fa-alias2::before',
* css: 'hello: world;',
* names: ['.fa-alias1', '.fa-alias2'],
* }
*/
cacheCssSelectors: {},
getCssSelectors: function (filter) {
if (this.cacheCssSelectors[filter]) {
return this.cacheCssSelectors[filter];
}
this.cacheCssSelectors[filter] = [];
var sheets = document.styleSheets;
for (var i = 0; i < sheets.length; i++) {
var rules;
try {
// try...catch because Firefox not able to enumerate
// document.styleSheets[].cssRules[] for cross-domain
// stylesheets.
rules = sheets[i].rules || sheets[i].cssRules;
} catch (e) {
console.warn("Can't read the css rules of: " + sheets[i].href, e);
continue;
}
if (!rules) {
continue;
}
for (var r = 0 ; r < rules.length ; r++) {
var selectorText = rules[r].selectorText;
if (!selectorText) {
continue;
}
var selectors = selectorText.split(/\s*,\s*/);
var data = null;
for (var s = 0; s < selectors.length; s++) {
var match = selectors[s].trim().match(filter);
if (!match) {
continue;
}
if (!data) {
data = {
selector: match[0],
css: rules[r].cssText.replace(/(^.*\{\s*)|(\s*\}\s*$)/g, ''),
names: [match[1]]
};
} else {
data.selector += (', ' + match[0]);
data.names.push(match[1]);
}
}
if (data) {
this.cacheCssSelectors[filter].push(data);
}
}
}
return this.cacheCssSelectors[filter];
},
/**
* List of font icons to load by editor. The icons are displayed in the media
* editor and identified like font and image (can be colored, spinned, resized
* with fa classes).
* To add font, push a new object {base, parser}
*
* - base: class who appear on all fonts
* - parser: regular expression used to select all font in css stylesheets
*
* @type Array
*/
fontIcons: [{base: 'fa', parser: /\.(fa-(?:\w|-)+)::?before/i}],
/**
* Searches the fonts described by the @see fontIcons variable.
*/
computeFonts: _.once(function () {
var self = this;
_.each(this.fontIcons, function (data) {
data.cssData = self.getCssSelectors(data.parser);
data.alias = _.flatten(_.map(data.cssData, _.property('names')));
});
}),
/**
* If a widget needs to be instantiated on page loading, it needs to wait
* for appropriate resources to be loaded. This function returns a Promise
* which is resolved when the dom is ready, the session is bound
* (translations loaded) and the XML is loaded. This should however not be
* necessary anymore as widgets should not be parentless and should then be
* instantiated (directly or not) by the page main component (webclient,
* website root, editor bar, ...). The DOM will be ready then, the main
* component is in charge of waiting for the session and the XML can be
* lazy loaded thanks to the @see Widget.xmlDependencies key.
*
* @returns {Promise}
*/
ready: function () {
return Promise.all([domReady, session.is_bound, ajax.loadXML()]);
},
};
});
//==============================================================================
odoo.define('web_editor.ready', function (require) {
'use strict';
// TODO this should be re-removed as soon as possible.
var base = require('web_editor.base');
return base.ready();
});