Disable sorting of element attributes

前端 未结 3 1468
春和景丽
春和景丽 2021-01-23 02:49

Is there a way to disable the sorting of element attributes so that checkDirty() will work correctly when allowedContent is set to true?

Example of the sorting of attrib

3条回答
  •  清歌不尽
    2021-01-23 03:27

    Your code does strange things like calling editor.resetDirty() on editor#contentDom (what for?). Additionally, CKEditor does not sort attributes, because the only thing that getSnapshot() does is taking the editable's innerHTML. So if anything sorts attributes it's browsers and if they do this (I remember that some do this randomly), then there's nothing you can do.

    You need to start from scratch. Define first what you want to achieve and do this with least code possible. I would also advise you to not use editor.checkDirty() because it's a legacy method that won't work in specific cases (yes, this is missing in the docs). Use editor#change to get live notifications about changes, or simply compare editor.getData() from time to time.

提交回复
热议问题