portagenetwork / roadmap

Developed by the the Alliance in collaboration with University of Alberta, DMP Assistant a data management planning tool, forking the DMP Roadmap codebase

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TinyMCE Related Console Warnings

aaronskiba opened this issue · comments

Please complete the following fields as applicable:

What version of the DMPRoadmap code are you running? (e.g. v2.2.0)
4.1.1+portage-4.1.0-uat-3
4.1.1+portage-4.1.0-alpha-2

Actual behaviour:

$(() => {
  Tinymce.init({ selector: '#notification_body', forced_root_block: '' });
    1. URL: http://127.0.0.1:3000/plans/10523
    • Screenshot from 2024-06-12 11-10-18
  • Related code
    • app/javascript/src/utils/conditionalFields.js
      // Resize any TinyMCE editors
      container.find('.toggleable-field').find('.tinymce').each((_idx, el) => {
        const tinymceEditor = Tinymce.findEditorById($(el).attr('id'));
        if (tinymceEditor) {
          $(tinymceEditor.iframeElement).height(tinymceEditor.settings.autoresize_min_height);
        }
      });

The current production instance, 4.0.2+portage-4.0.4, is using "tinymce": "^5.10.9",. The following deprecation warning is visible there:
Screenshot from 2024-06-10 11-30-09

(There is no autoresize_min_height warning/error there.)

DMPRoadmap v4.1.0 included the upgrade to TinyMCE v6 https://github.com/DMPRoadmap/roadmap/releases/tag/v4.1.0.
Our codebase upgraded to TinyMCE v7 via the following Dependabot security PR: #704

The following TinyMCE console warnings are rendered for DMPRoadmap v4.2.0 (using "tinymce": "^6.4.1"):
Screenshot from 2024-06-12 12-56-13
Screenshot from 2024-06-12 13-15-42

So even if Portage Network were to revert from TinyMCE v7 back to TinyMCE v6, the same console warnings would still render.

forced_root_block: '' seems to default to forced_root_block: 'p', which is the same behaviour as not explicitly stating the forced_root_block: arg at all.

rails assets:clobber && rails assets:precompile was executed between code changes:

forced_root_block: ''

// app/javascript/src/superAdmin/notifications/edit.js
$(() => {
  Tinymce.init({ selector: '#notification_body', forced_root_block: '' });

Screenshot from 2024-06-12 15-40-28

3.0.5 :001 > Notification.last.body
  Notification Load (0.7ms)  SELECT "notifications".* FROM "notifications" ORDER BY "notifications"."id" DESC LIMIT $1  [["LIMIT", 1]]
 => "<p>Test 1</p>" 
3.0.5 :002 > 

forced_root_block: 'div'

// app/javascript/src/superAdmin/notifications/edit.js
$(() => {
  Tinymce.init({ selector: '#notification_body', forced_root_block: 'div' });

Screenshot from 2024-06-12 15-44-21

3.0.5 :002 > Notification.last.body
  Notification Load (1.9ms)  SELECT "notifications".* FROM "notifications" ORDER BY "notifications"."id" DESC LIMIT $1  [["LIMIT", 1]]
 => "<div>Test 2</div>" 
3.0.5 :003 > 

forced_root_block: 'p'

$(() => {
  Tinymce.init({ selector: '#notification_body', forced_root_block: 'p' });

Screenshot from 2024-06-12 15-46-38

3.0.5 :003 > Notification.last.body
  Notification Load (1.6ms)  SELECT "notifications".* FROM "notifications" ORDER BY "notifications"."id" DESC LIMIT $1  [["LIMIT", 1]]
 => "<p>Test 3</p>" 
3.0.5 :004 > 

Without forced_root_block: arg

$(() => {
  Tinymce.init({ selector: '#notification_body' });

Screenshot from 2024-06-12 15-50-02

3.0.5 :004 > Notification.last.body
  Notification Load (2.0ms)  SELECT "notifications".* FROM "notifications" ORDER BY "notifications"."id" DESC LIMIT $1  [["LIMIT", 1]]
 => "<p>Test 4</p>" 
3.0.5 :005 >