Skip to content

Commit

Permalink
get the editor id for tinyMCE
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafauysal committed Sep 20, 2024
1 parent 432523a commit 3b7eb1d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions assets/js/admin/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 = () => {
Expand Down

0 comments on commit 3b7eb1d

Please sign in to comment.