plone / Products.CMFPlone

The core of the Plone content management system
https://plone.org
GNU General Public License v2.0
254 stars 191 forks source link

Wysiwyg Use site default in @@personal-preferences crashes Wysiwyg Editor #3173

Closed Nimo-19 closed 3 years ago

Nimo-19 commented 4 years ago

BUG/PROBLEM REPORT

Not shure if this is the right place to put this issue (but I seems this is the right place for not being sure). Please direct me to the correct repo if I am wrong.

What I did:

On a fresh vanilla plone-5.2.2 installation I changed my personal Wysiwyg editor under @@personal-preferences to something other than Use site default saved and changed it back to Use site default. I never changed the sites Default editor.

After that I created a page document.

What I expect to happen:

I expected the Wysiwyg editor in the edit view to be tinyMCE

What actually happened:

No Wysiwyg editor was presented. Only plain HTML code. No Error logged server side as far as I can see. Only a js error in the browsers console:

patterns.pat.textareamimetypeselector: Failed while initializing 'textareamimetypeselector' pattern. TypeError: r.patterns[n.pattern] is not a constructor
    initTextarea plone-tinymce-compiled.min.js:1
    init plone-tinymce-compiled.min.js:1
    c plone-base-compiled.js:3600
    e plone-base-compiled.js:3635
    o plone-base-compiled.js:3588
    initPattern plone-base-compiled.js:3427
    F plone-base-compiled.js:762
    u plone-base-compiled.js:793
    scan plone-base-compiled.js:3466
    scan plone-base-compiled.js:3465
    register plone-base-compiled.js:3498
    extend plone-base-compiled.js:3666
    <anonymous> plone-tinymce-compiled.min.js:1
    execCb require.js:1696
    check require.js:883
    enable require.js:1176
    enable require.js:1557
    enable require.js:1161
    bind require.js:134
    each require.js:59
    enable require.js:1113
    init require.js:788
    localRequire require.js:1460
    setTimeout handler*req.nextTick< require.js:1815
    localRequire require.js:1449
    requirejs require.js:1797
    <anonymous> plone-tinymce-compiled.min.js:1
plone-base-compiled.js:1795:30
    output plone-base-compiled.js:1795
    log plone-base-compiled.js:1862
    error plone-base-compiled.js:1878
    o plone-base-compiled.js:3590
    initPattern plone-base-compiled.js:3427
    F plone-base-compiled.js:762
    u plone-base-compiled.js:793
    scan plone-base-compiled.js:3466
    scan plone-base-compiled.js:3465
    register plone-base-compiled.js:3498
    extend plone-base-compiled.js:3666
    <anonymous> plone-tinymce-compiled.min.js:1
    execCb require.js:1696
    check require.js:883
    enable require.js:1176
    enable require.js:1557
    enable require.js:1161
    bind require.js:134
    each require.js:59
    enable require.js:1113
    init require.js:788
    localRequire require.js:1460
    (Async: setTimeout handler)
    nextTick require.js:1815
    localRequire require.js:1449
    requirejs require.js:1797
    <anonymous> plone-tinymce-compiled.min.js:1

What version of Plone/ Addons I am using:

plain Plone 5.2.2

Buildout

[buildout]
extends =
    http://dist.plone.org/release/5-latest/versions.cfg

parts =
    instance

[instance]
recipe = plone.recipe.zope2instance
user = admin:admin
http-address = 8080
eggs =
    Plone
pbauer commented 3 years ago

The same still happens with Plone 6 coredev

pbauer commented 3 years ago

The problem is that both None and 'None' result in plaintexteditor being used while the value of the option "Use site default" ends up as None

The fix is to set it as '' instead in plone.app.users.browser.account.AccountPanelSchemaAdapter.

    @property
    def wysiwyg_editor(self):
        return self._getProperty('wysiwyg_editor')

    @wysiwyg_editor.setter
    def wysiwyg_editor(self, value):
        if value is None:
            # set property that the site-default from the registry is used
            # since both 'None' and None result in plaintexteditor
            value = ''
        return self._setProperty('wysiwyg_editor', value)

A pull-request is coming.