WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#33393 closed defect (bug) (fixed)

tinymce plugin wplink throw js TypeError: editor.wp undefined

Reported by: hauvong Owned by: azaozz
Milestone: 4.3.1 Priority: normal
Severity: normal Version: 4.3
Component: TinyMCE Keywords: has-patch fixed-major
Focuses: Cc:

Description

When TinyMCE initialize with plugin wplink enable but not wordpress, the wplink js throw TypeError: editor.wp undefined

To reproduce, initialize a new TinyMCE editor with wplink plugins enable.

tinyMCE.init({
	plugins: "wplink"
});
tinyMCE.execCommand( 'mceAddEditor', true, "textarea" )

To fix, the js should check for wp object exist before calling the function:

editor.on( 'preinit', function() {
	// editor may not have wp object if tinymce wordpress plugin isn't loaded.
	if ( editor.wp && editor.wp._createToolbar ) {
		toolbar = editor.wp._createToolbar( [
			'wp_link_preview',
			'wp_link_edit',
			'wp_link_remove'
		], true );
	}
} );

The patch file is attached.

Attachments (1)

tinymce-wp-link-plugin.js.patch (762 bytes) - added by hauvong 3 years ago.
fix exception TypeError: editor.wp undefined

Download all attachments as: .zip

Change History (12)

@hauvong
3 years ago

fix exception TypeError: editor.wp undefined

#1 follow-up: @helen
3 years ago

  • Keywords reporter-feedback added
  • Version changed from trunk to 3.3

Does wplink work without the wordpress plugin?

#2 in reply to: ↑ 1 @hauvong
3 years ago

Replying to helen:

Does wplink work without the wordpress plugin?

Yes, wplink work without the wordpress plugin and there is no error prior to r32902, #32604

This ticket was mentioned in Slack in #core by lumberhack. View the logs.


3 years ago

#4 @LumberHack
3 years ago

  • Version changed from 3.3 to 4.3

#5 @LumberHack
3 years ago

Tested the fix suggested by @hauvong and it works.

#6 @azaozz
3 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In 33728:

TinyMCE: ensure the wordpress plugin is loaded before calling _createToolbar().
Props hauvong, azaozz. Fixes #33393.

#7 follow-up: @azaozz
3 years ago

  • Milestone changed from Awaiting Review to 4.3.1
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopen for 4.3 consideration.

Last edited 3 years ago by azaozz (previous) (diff)

#8 in reply to: ↑ 7 ; follow-up: @LumberHack
3 years ago

Replying to azaozz:

Reopen for 4.3.

Any insights on why this got reopened ?

#9 in reply to: ↑ 8 @azaozz
3 years ago

  • Keywords has-patch added; reporter-feedback removed

Replying to LumberHack:

Disabling the wordpress plugin when using the other custom plugins for TinyMCE is a rare edge case that was fixed in trunk. It affects 4.3 so moved it to the 4.3.1 milestone for consideration.

#10 @samuelsidler
3 years ago

  • Keywords fixed-major added

#11 @azaozz
3 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 34032:

TinyMCE: ensure the wordpress plugin is loaded before calling _createToolbar().

Props hauvong, azaozz.
Fixes #33393 for 4.3.

Note: See TracTickets for help on using tickets.