Commit graph

67 commits

Author SHA1 Message Date
Richard Hansen
b547ce9a47 contentcollector: Invert logic to improve readability 2021-01-27 04:59:36 +00:00
Richard Hansen
b811030846 contentcollector: Delete unnecessary truthiness check 2021-01-27 04:59:36 +00:00
Richard Hansen
fc2420c244 contentcollector: Fix iteration over child Nodes
In the DOM, `.children` only includes children that are Element
objects. In cheerio 0.22.0, `.children` includes all child Nodes, not
just Elements. Use `dom.numChildNodes()` and `dom.childNode()` so that
browsers behave the same as cheerio.
2021-01-27 04:59:36 +00:00
Richard Hansen
d0bfb54c0a contentcollector: Avoid for..in iteration of object properties
`for..in` iterates over inherited properties, which is almost never
desired. In most cases there aren't any inherited enumerable
properties so it's not that big of a deal, but in the case of
HTMLCollection it's very bad because it iterates over every entry
twice (once by numerical index and once by name) plus it includes the
`length` property in the iteration.
2021-01-27 04:59:36 +00:00
Richard Hansen
3cfec58948 contentcollector: Rename dom functions for consistency with DOM spec 2021-01-27 04:59:36 +00:00
Richard Hansen
8763c3bb29 contentcollector: Fix Element attribute accesses
The `attribs` property is only available on cheerio's Element-like
objects; DOM Element objects do not have an `attribs` property. Switch
to `dom.nodeAttr()` to fix the logic for browsers.
2021-01-27 04:59:36 +00:00
Richard Hansen
99625950c8 contentcollector: Factor out call to .toLowerCase() 2021-01-27 04:59:36 +00:00
Richard Hansen
dd7fb1babe contentcollector: Document the dom object 2021-01-27 04:59:36 +00:00
Richard Hansen
74bb2f76cc contentcollector: Delete unused domInterface parameter 2021-01-27 04:59:36 +00:00
John McLear
f0a77cb98c
lint: contentcollector and domline
Various tidy up and linting of contentcollector.js and domline.js.

3 Tests disabled which are not due to be covered.

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2021-01-22 20:41:14 +00:00
John McLear
c38c34bef4
linting: ace2_inner
* remove IE and add strict headers

* linting: kids are back, need to stop for today

* linting: farbtastic fix

* lint: more lint fixes

* more lint fixes

* linting: sub 100 errors

* comments where I need help

* ready to be helped :)

* small fixes

* fixes

* linting: all errors resolved

* linting: remove note to self

* fix as per nulli/wezz000li suggestion

* fix as per nulli/wezz000li suggestion

* resolve merge conflicts

* better use if to silence eslint

* Use `for..of` with `Object.keys` instead of `for..in`

* lint: move setSelection to before call

Co-authored-by: webzwo0i <webzwo0i@c3d2.de>
Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2021-01-14 10:00:14 +00:00
Richard Hansen
b82bf5c726 Drop support for Internet Explorer 2020-12-19 19:13:31 +00:00
Richard Hansen
f54dcbc766 lint: Re-run eslint --fix 2020-12-16 22:09:48 +00:00
Richard Hansen
8e5fd19db2 lint: Run eslint --fix on src/ 2020-11-24 20:06:12 +00:00
Richard Hansen
7df3ded66f lint: Put opening brace on same line as function
Normally I would let `eslint --fix` do this for me, but there's a bug
that causes:

    const x = function ()
    {
      // ...
    };

to become:

    const x = ()
    => {
      // ...
    };

which ESLint thinks is a syntax error. (It probably is; I don't know
enough about the automatic semicolon insertion rules to be confident.)
2020-11-24 20:06:12 +00:00
John McLear
a4bdcc3392
tests/editor/ul/li/ol/import/export: Introduce contentcollector.js tests & various OL/UL/LI related bugfixes
1. Introduce contentcollector.js backend tests
1. Fix issue with OL LI items not being properly numbered after import
1. Fix issue with nested OL LI items being improperly numbered on export
1. Fix issue with new lines not being introduced after lists in on import #3961
1. Sanitize HTML on the way in (import)
1. Fix ExportHTML CSS because it needs to support OL > LI > OL not OL > OL [The latter being the correct format]
1. Fix backend tests.
2020-06-05 20:54:16 +01:00
John McLear
2011c24f57
editor: Don't restrict plugins from being able to bring in newline content
#2412 broke this, it was discovered in https://github.com/JohnMcLear/ep_copy_paste_images/issues/20.

The limitation means that images can't be pasted within lists which IMHO is fine.  I could refine this down to OL only but I think images within lists would be fine not to include.
2020-05-29 16:53:08 +01:00
John McLear
f6907c5fad contentcollector: remove weird stuff LibreOffice adds to DOM before importing 2020-04-08 22:51:25 +02:00
John McLear
85217b55e0 contentcollector: pasting an OL in Chrome inserted an additional line break. Fixed.
This comments out some code that was probably a quirk from ie6 era.
See PR: https://github.com/ether/etherpad-lite/issues/2412

Fixes #2412.
2020-03-30 02:28:08 +02:00
muxator
840b4a0988 contentcollector: backed out changeset 3292429ab3
That commit (merged recently with PR #3622) was part of an effort to fix #3620,
but introduced a very bad bug that broke the cursor behaviour when pressing
space, making the program unusable.

This commit completes the revert of PR #3622 and fixes #3728.

--HG--
branch : revert-3622
2020-03-19 02:53:41 +01:00
Tom Briles
3292429ab3 trim text entries upon import. Fixes: #3620 2020-03-15 11:35:08 +00:00
muxator
dc7e49f89d Remove trailing whitespaces
Hoping to minimize future diffs. Not touching vendorized libraries.
2019-04-16 00:34:29 +02:00
Olivier Tétard
275a7d31e0 Avoid space removal when pasting text from word processor.
Since bf380eea50, some spaces were removed when pasting text from a word processor (at least using Libre Office). To avoid double space creations and space removal, we only remove line break which are tight to a space character.
2015-07-27 16:38:57 +02:00
Luiza Pagliari
58ab17bf9e Fix the way Content Collector gets the node class. Fixes #2640 2015-04-28 05:31:07 -07:00
John McLear
b6ff1807da Merge pull request #2482 from ether/chrome-list-handling
chrome list handling fix for #2412
2015-03-31 23:19:47 +01:00
Thomas Muehlichen
1c05933dc9 Feature #2567 Added workaround to enable contentcollector to write key-value attributes 2015-03-26 18:49:35 +01:00
John McLear
35da64be5c hrm bit of a hack, anyone any ideas on better way? 2015-01-28 19:09:47 +00:00
John McLear
0216a10a12 better variable name 2015-01-27 20:10:38 +00:00
John McLear
bdfce1cbef change to cc.. 2015-01-27 19:41:01 +00:00
John McLear
8fbd7d83b6 content collector should also register the blocks, no idea why this wasnt in before 2015-01-27 19:16:36 +00:00
John McLear
c4f1189ebd even cleaner 2015-01-26 02:39:43 +00:00
John McLear
18121a1507 much cleaner 2015-01-26 02:32:58 +00:00
John McLear
8156930208 clean support for image hook 2015-01-26 01:44:40 +00:00
John McLear
5dce72d419 chrome list handling fix for #2412 2015-01-23 01:47:12 +00:00
John McLear
3fd6e72657 try again 2015-01-21 15:06:29 +00:00
John McLear
990e14c904 working with a big hack 2015-01-21 14:25:24 +00:00
John McLear
eacf1118f8 blind attempt to try 2015-01-21 02:55:03 +00:00
John McLear
ab71bc7c20 hrm 2015-01-19 14:45:49 +00:00
John McLear
83fae22279 allow list text entry up to 16 items 2015-01-18 15:32:48 +00:00
webzwo0i
82efcdb430 fix for uls without class 2015-01-09 02:04:03 +01:00
John McLear
8eb723b906 patch for e1c683be3f 2014-12-31 14:16:10 +00:00
webzwo0i
e1c683be3f differentiate between indents and bullets in unordered lists 2014-12-29 16:12:07 +01:00
John McLear
cfa3f15f94 Merge pull request #2373 from webzwo0i/avoid-global-vairables
dont make local variables global
2014-12-16 00:41:41 +00:00
webzwo0i
5d15f655f0 dont make local variables global 2014-12-14 22:01:28 +01:00
John McLear
2c728b8e1b sanitizer change 2014-11-27 00:45:22 +00:00
John McLear
60d44cd3df use cheerio instead of jsdom 2014-11-25 17:26:09 +00:00
John McLear
bf380eea50 take line breaks and treat them appropriatly instead of creating a space for them.. 2014-11-01 18:07:34 +00:00
Luc Didry
3d8452b143 Replace tabs indentation with spaces indentation
Some files are obviously external libraries, I didn't touch them
2013-12-05 08:41:29 +01:00
Marcel Klehr
146c75e703 Remove console.log in content collector
fixes #1731
2013-04-17 16:37:45 +03:00
Chia-liang Kao
4827cdbd96 fix imported ol that were turned into ul 2012-11-02 21:39:40 +08:00