Plugin Directory

Changeset 2769673


Ignore:
Timestamp:
08/12/2022 08:55:07 AM (4 years ago)
Author:
unfluff
Message:

TinyMCE work improvement

Location:
unfluff-io-content-optimization
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • unfluff-io-content-optimization/tags/1.0.0/assets/js/classic_editor.js

    r2768986 r2769673  
    1414        return;
    1515    } else { // We are in tinyMCE mode
    16         let activeEditor = tinyMCE.get('content');
    17         if(activeEditor!==null){ // Make sure we're not calling setContent on null
    18         editor_content = tinymce.activeEditor.getContent(); // get tinyMCE's content
    19       }
    20     }
    21     // return if content is empty
    22     if(editor_content == ''){
     16        editor_content = tinymce.get('content').getContent();; // get tinyMCE's content
     17    }
     18    // return if no content
     19    if(!editor_content){
     20      console.log('no content');
     21      clearInterval(loading_effect);
    2322      return;
    2423    }
     
    9190  // get announcements
    9291  function announcement_call() {
    93 
    9492    var ann_settings = {
    9593      'url': 'https://unfluff.io/wp-json/unfluff/ann',
     
    105103        $('#unfluff-announcement').html(ann_html);
    106104      }
    107      
    108105    });
    109 
    110106  }
    111107
     
    124120      alert('Unfluff works with the visual editor only! Please switch to the visual editor and click the unfluff button again.');
    125121    } else { // We are in tinyMCE mode
    126         let activeEditor = tinymce.activeEditor.getContent()
    127         if(activeEditor!==null){ // Make sure we're not calling setContent on null
    128           highlighted_content = activeEditor; // get tinyMCE's content
     122        let activeEditor = tinymce.get('content');
     123        if(activeEditor){ // Make sure we're not calling setContent on null
     124          highlighted_content = activeEditor.getContent(); // get tinyMCE's content
    129125          $('.fluff-sentence .fulff-sentence-text').each(function(i, obj) {
    130126            let fluff_sentence = $(this).text();
     
    167163  function unfluff_single_highlight(sentence){
    168164    remove_highlights(); // remove previous highlights if any
    169     let activeEditor = tinymce.activeEditor.getContent();
     165    let activeEditor = tinyMCE.get('content');
     166    let editor_content = activeEditor.getContent();
    170167    let single_higlight = '';
    171     if (activeEditor.indexOf(sentence) >= 0) { // text exists without html tags
    172       single_higlight = activeEditor.replaceAll( sentence, '<unfluffmark class="unfluff-highlight">' + sentence + '</unfluffmark>');
     168    if (editor_content.indexOf(sentence) >= 0) { // text exists without html tags
     169      single_higlight = editor_content.replaceAll( sentence, '<unfluffmark class="unfluff-highlight">' + sentence + '</unfluffmark>');
    173170    } else{ // text has html tags, or maybe does not exist!!!
    174171      // covvert Active editor string to html markup
    175       let editor_html = ConvertStringToHTML(activeEditor);
     172      let editor_html = ConvertStringToHTML(editor_content);
    176173      let sentence_with_html = $(editor_html).find("p:contains('" + fluff_sentence + "'), div:contains('" + fluff_sentence + "'), span:contains('" + fluff_sentence + "')");
    177174      sentence_with_html = sentence_with_html.html(); console.log(sentence_with_html);
    178       single_higlight = activeEditor.replaceAll( sentence_with_html, '<unfluffmark class="unfluff-highlight">' + sentence_with_html + '</unfluffmark>');
     175      single_higlight = editor_content.replaceAll( sentence_with_html, '<unfluffmark class="unfluff-highlight">' + sentence_with_html + '</unfluffmark>');
    179176    }
    180177    tinymce.activeEditor.setContent(single_higlight); // Update tinyMCE's content
     
    234231  $('#fluff-sentences').on('click', '.unfluff-single-highlight', function() {
    235232    let single_sentence = $(this).parent().find('.fulff-sentence-text').text();
    236     console.log(single_sentence);
     233    //console.log(single_sentence);
    237234    unfluff_single_highlight(single_sentence);
    238235  });
     
    240237  // remove highlights in update hover
    241238  $('#publishing-action').on('mouseover', '#publish',function(){
    242     let activeEditor = tinymce.activeEditor.getContent();
     239    let activeEditor = tinyMCE.get('content').getContent();
    243240    let highlight_mark = '<unfluffmark class="unfluff-highlight">'
    244241    if(activeEditor.indexOf(highlight_mark) >= 0) { // text exis
  • unfluff-io-content-optimization/tags/1.0.0/readme.txt

    r2769200 r2769673  
    22221. Upload the plugin folder to your /wp-content/plugins/ folder
    23232. Go to the **Plugins** page and activate the plugin
    24 3. Go to the plugin setting page and add your license key
     243. Go to the plugin settings page and add your license key
    2525
    2626== Frequently Asked Questions ==
  • unfluff-io-content-optimization/trunk/assets/js/classic_editor.js

    r2768988 r2769673  
    1414        return;
    1515    } else { // We are in tinyMCE mode
    16         let activeEditor = tinyMCE.get('content');
    17         if(activeEditor!==null){ // Make sure we're not calling setContent on null
    18         editor_content = tinymce.activeEditor.getContent(); // get tinyMCE's content
    19       }
    20     }
    21     // return if content is empty
    22     if(editor_content == ''){
     16        editor_content = tinymce.get('content').getContent();; // get tinyMCE's content
     17    }
     18    // return if no content
     19    if(!editor_content){
     20      console.log('no content');
     21      clearInterval(loading_effect);
    2322      return;
    2423    }
     
    9190  // get announcements
    9291  function announcement_call() {
    93 
    9492    var ann_settings = {
    9593      'url': 'https://unfluff.io/wp-json/unfluff/ann',
     
    105103        $('#unfluff-announcement').html(ann_html);
    106104      }
    107      
    108105    });
    109 
    110106  }
    111107
     
    124120      alert('Unfluff works with the visual editor only! Please switch to the visual editor and click the unfluff button again.');
    125121    } else { // We are in tinyMCE mode
    126         let activeEditor = tinymce.activeEditor.getContent()
    127         if(activeEditor!==null){ // Make sure we're not calling setContent on null
    128           highlighted_content = activeEditor; // get tinyMCE's content
     122        let activeEditor = tinymce.get('content');
     123        if(activeEditor){ // Make sure we're not calling setContent on null
     124          highlighted_content = activeEditor.getContent(); // get tinyMCE's content
    129125          $('.fluff-sentence .fulff-sentence-text').each(function(i, obj) {
    130126            let fluff_sentence = $(this).text();
     
    167163  function unfluff_single_highlight(sentence){
    168164    remove_highlights(); // remove previous highlights if any
    169     let activeEditor = tinymce.activeEditor.getContent();
     165    let activeEditor = tinyMCE.get('content');
     166    let editor_content = activeEditor.getContent();
    170167    let single_higlight = '';
    171     if (activeEditor.indexOf(sentence) >= 0) { // text exists without html tags
    172       single_higlight = activeEditor.replaceAll( sentence, '<unfluffmark class="unfluff-highlight">' + sentence + '</unfluffmark>');
     168    if (editor_content.indexOf(sentence) >= 0) { // text exists without html tags
     169      single_higlight = editor_content.replaceAll( sentence, '<unfluffmark class="unfluff-highlight">' + sentence + '</unfluffmark>');
    173170    } else{ // text has html tags, or maybe does not exist!!!
    174171      // covvert Active editor string to html markup
    175       let editor_html = ConvertStringToHTML(activeEditor);
     172      let editor_html = ConvertStringToHTML(editor_content);
    176173      let sentence_with_html = $(editor_html).find("p:contains('" + fluff_sentence + "'), div:contains('" + fluff_sentence + "'), span:contains('" + fluff_sentence + "')");
    177174      sentence_with_html = sentence_with_html.html(); console.log(sentence_with_html);
    178       single_higlight = activeEditor.replaceAll( sentence_with_html, '<unfluffmark class="unfluff-highlight">' + sentence_with_html + '</unfluffmark>');
     175      single_higlight = editor_content.replaceAll( sentence_with_html, '<unfluffmark class="unfluff-highlight">' + sentence_with_html + '</unfluffmark>');
    179176    }
    180177    tinymce.activeEditor.setContent(single_higlight); // Update tinyMCE's content
     
    234231  $('#fluff-sentences').on('click', '.unfluff-single-highlight', function() {
    235232    let single_sentence = $(this).parent().find('.fulff-sentence-text').text();
    236     console.log(single_sentence);
     233    //console.log(single_sentence);
    237234    unfluff_single_highlight(single_sentence);
    238235  });
     
    240237  // remove highlights in update hover
    241238  $('#publishing-action').on('mouseover', '#publish',function(){
    242     let activeEditor = tinymce.activeEditor.getContent();
     239    let activeEditor = tinyMCE.get('content').getContent();
    243240    let highlight_mark = '<unfluffmark class="unfluff-highlight">'
    244241    if(activeEditor.indexOf(highlight_mark) >= 0) { // text exis
  • unfluff-io-content-optimization/trunk/readme.txt

    r2769200 r2769673  
    22221. Upload the plugin folder to your /wp-content/plugins/ folder
    23232. Go to the **Plugins** page and activate the plugin
    24 3. Go to the plugin setting page and add your license key
     243. Go to the plugin settings page and add your license key
    2525
    2626== Frequently Asked Questions ==
Note: See TracChangeset for help on using the changeset viewer.