WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 18 months ago

#36890 new enhancement

TinyMCE: add settings for the wptextpatterns plugin to add or override the default text patterns

Reported by: azaozz Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: TinyMCE Keywords:
Focuses: Cc:

Description

Continues from #33300.

Currently a WordPress plugin has to replace the whole wptextpattern editor plugin to add or change the text patterns. It would be better to let the patterns be changed by setting an editor option in the init array.

Attachments (1)

36890.patch (5.5 KB) - added by azaozz 2 years ago.

Download all attachments as: .zip

Change History (4)

@azaozz
2 years ago

#1 @azaozz
2 years ago

36890.patch is almost identical to https://core.trac.wordpress.org/attachment/ticket/33300/33300.6.patch. It adds editor settings to add or override the default text patterns.

Example:

add_filter( 'tiny_mce_before_init', 'textpatterns_test' );
function textpatterns_test( $init ) {
	$init['wptextpattern_inline_patterns'] = '{
		strong: { start: "*", end: "*", format: "bold" },
		strong2: { start: "**", end: "**", format: "bold" },
		em: { start: "_", end: "_", format: "italic" }
	}';

	return $init;
}

This ticket was mentioned in Slack in #core-editor by mrwweb. View the logs.


2 years ago

#3 @iseulde
18 months ago

We added this in [39075]. :) The question now is if we should add methods to add and remove patterns more easily and/or if we should add any PHP filters just for this. At the moment you can only replace the settings.

Note: See TracTickets for help on using tickets.