From 3b7eb1dfcc0ab97fd054b581ac1e1a0a5c7aab6c Mon Sep 17 00:00:00 2001 From: mustafauysal Date: Fri, 20 Sep 2024 15:22:49 +0300 Subject: [PATCH] get the editor id for tinyMCE --- assets/js/admin/utils.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/assets/js/admin/utils.js b/assets/js/admin/utils.js index baf9d4b..95ea440 100644 --- a/assets/js/admin/utils.js +++ b/assets/js/admin/utils.js @@ -24,8 +24,8 @@ export const getTypewriterSpeed = (strLen) => { return 30; }; -export const isTinyMCEActive = () => { - if (jQuery('#wp-content-wrap').hasClass('tmce-active')) { +export const isTinyMCEActive = (editor) => { + if (jQuery('#wp-' + editor + '-wrap').hasClass('tmce-active')) { return true; } @@ -88,7 +88,11 @@ export const getTinymceContent = (editor_id, textarea_id) => { export const getSelectedText = (textarea) => { const start = textarea.prop('selectionStart'); const finish = textarea.prop('selectionEnd'); - return textarea.val().substring(start, finish); + const value = textarea.val(); + if (value && start !== undefined && finish !== undefined) { + return value.substring(start, finish); + } + return ''; } export const isBlockEditor = () => {