Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TinyMCE format icon names for alignment styles. #322

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion news/3095.bugfix
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Update TinyMCE format icon names.
[petschki]
[petschki, maurits]
35 changes: 25 additions & 10 deletions plone/app/upgrade/v60/final.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,21 +208,36 @@ def fix_syndication_settings(context):
del registry.records[key]


def fix_tinymce_format_iconnames(context):
"""Fix 'strike-through' and 'sourcecode'.

See https://github.com/plone/Products.CMFPlone/issues/3905
"""
def _replace_values_in_record(record_name, *replacements):
"""Take the values of a registry record and replace some of them."""
registry = getUtility(IRegistry)
record = registry.records.get("plone.inline_styles")
record = registry.records.get(record_name)
if record is None:
return
values = record.value
replacements = [
("Strikethrough|strikethrough|strikethrough", "Strikethrough|strikethrough|strike-through"),
("Code|code|code", "Code|code|sourcecode")
]
for _old, _new in replacements:
if _old in values:
values[values.index(_old)] = _new
record.value = values


def fix_tinymce_format_iconnames(context):
"""Fix various TinyMCE formats to have the correct icon name.

See https://github.com/plone/Products.CMFPlone/issues/3905
"""
_replace_values_in_record(
"plone.inline_styles",
(
"Strikethrough|strikethrough|strikethrough",
"Strikethrough|strikethrough|strike-through",
),
("Code|code|code", "Code|code|sourcecode"),
)
_replace_values_in_record(
"plone.alignment_styles",
("Left|alignleft|alignleft", "Left|alignleft|align-left"),
("Center|aligncenter|aligncenter", "Center|aligncenter|align-center"),
("Right|alignright|alignright", "Right|alignright|align-right"),
("Justify|alignjustify|alignjustify", "Justify|alignjustify|align-justify"),
)