/**
 * TinyMCE code to add FAQ functionality JavaScript part
 *
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
 * obtain one at http://mozilla.org/MPL/2.0/.
 *
 * @package phpMyFAQ
 * @author Thorsten Rinne
 * @copyright 2017-2020 phpMyFAQ Team
 * @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
 * @link https://www.phpmyfaq.de
 * @since 2017-08-02
 */

/*global document: false, $: false, tinyMCE: false */

$(document).ready(function() {
  'use strict';
  if (typeof tinyMCE !== 'undefined' && undefined !== tinyMCE) {
    tinyMCE.init({
      // General options
      mode: 'exact',
      language: 'en',
      selector: 'textarea#answer',
      theme: 'modern',
      plugins: [
        'advlist autolink lists link image charmap print preview hr anchor pagebreak',
        'searchreplace wordcount visualblocks visualchars code fullscreen',
        'insertdatetime media nonbreaking save table contextmenu directionality',
        'emoticons template paste textcolor',
      ],
      relative_urls: false,
      convert_urls: false,
      remove_linebreaks: false,
      use_native_selects: true,
      paste_remove_spans: true,
      entities: '10',
      entity_encoding: 'raw',

      toolbar1:
        'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent',
      toolbar2: 'link | forecolor backcolor emoticons | print',
      image_advtab: true,

      // Formatting
      style_formats: [
        {
          title: 'Headers',
          items: [
            { title: 'h1', block: 'h1' },
            { title: 'h2', block: 'h2' },
            { title: 'h3', block: 'h3' },
            { title: 'h4', block: 'h4' },
            { title: 'h5', block: 'h5' },
            { title: 'h6', block: 'h6' },
          ],
        },

        {
          title: 'Blocks',
          items: [
            { title: 'p', block: 'p' },
            { title: 'div', block: 'div' },
            { title: 'pre', block: 'pre' },
            { title: 'code', block: 'code' },
          ],
        },

        {
          title: 'Containers',
          items: [
            { title: 'blockquote', block: 'blockquote', wrapper: true },
            { title: 'figure', block: 'figure', wrapper: true },
          ],
        },
      ],

      visualblocks_default_state: true,
      end_container_on_empty_block: true,
      extended_valid_elements: 'code[class],video[*],audio[*],source[*]',
      removeformat: [
        {
          selector: '*',
          attributes: ['style'],
          split: false,
          expand: false,
          deep: true,
        },
      ],
      importcss_append: true,
    });
  }
});

@@ -831,16 +831,23 @@
 advlist 
+anchor 
 autolink
@@ -864,16 +864,27 @@
 k image 
+imagetools 
 charmap 
@@ -986,18 +986,46 @@
 ode 
-fullscreen
+codesample fullscreen colorpicker help
 ',%0A 
@@ -1102,16 +1102,28 @@
 ionality
+ textpattern
 ',%0A     
@@ -1160,16 +1160,29 @@
 extcolor
+ autosave toc
 ',%0A     
@@ -1388,17 +1388,16 @@
  'raw',%0A
-%0A
       to
@@ -1417,28 +1417,20 @@
    '
-insertfile undo redo
+formatselect
  %7C s
@@ -1454,16 +1454,57 @@
  italic 
+strikethrough forecolor backcolor %7C link 
 %7C alignl
@@ -1549,19 +1549,19 @@
 y %7C 
-bul
+num
 list 
-num
+bul
 list
@@ -1575,16 +1575,31 @@
 t indent
+ %7C removeformat
 ',%0A     
@@ -1610,20 +1610,72 @@
 lbar2: '
-link
+insertfile %7C paste codesample %7C link image preview media
  %7C forec
@@ -1702,20 +1702,23 @@
 cons %7C p
-rint
+hpmyfaq
 ',%0A     
@@ -1737,16 +1737,172 @@
 b: true,
+%0A      image_class_list: %5B%0A        %7B title: 'None', value: '' %7D,%0A        %7B title: 'Responsive', value: 'img-fluid' %7D,%0A      %5D,%0A      image_dimensions: true,
 %0A%0A      
@@ -2759,16 +2759,115 @@
     %5D,%0A%0A
+      paste_word_valid_elements: 'b,strong,i,em,h1,h2,h3,h4,h5,h6',%0A      paste_data_images: true,%0A
       vi
@@ -3011,16 +3011,26 @@
 ource%5B*%5D
+,iframe%5B*%5D
 ',%0A     
@@ -3045,36 +3045,17 @@
 ormat: %5B
-%0A        %7B%0A         
+%7B
  selecto
@@ -3061,26 +3061,16 @@
 or: '*',
-%0A         
  attribu
@@ -3084,26 +3084,16 @@
 style'%5D,
-%0A         
  split: 
@@ -3098,26 +3098,16 @@
 : false,
-%0A         
  expand:
@@ -3113,26 +3113,16 @@
 : false,
-%0A         
  deep: t
@@ -3124,35 +3124,18 @@
 ep: true
-,%0A        %7D,%0A     
  
+%7D
 %5D,%0A     

fix drag n drop in the frontend, closes #1729