Skip to content

Commit

Permalink
Get thresholds from config + fix cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudio-Emmolo committed Jul 1, 2024
1 parent 36f3c14 commit e3bb247
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/previewAdv.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/* global tinymce */

tinymce.PluginManager.add('previewAdv', (editor, url) => {

editor.on('init', function () {
const thresholds = {
1: 0,
2: 2,
3: 8
}
const params = editor.getParam('previewAdv')
const thresholds = params.thresholds

let pCount = 0 // Counter for <p> tags
let advCount = 1 // Counter for adv divs
Expand Down Expand Up @@ -45,9 +43,16 @@ tinymce.PluginManager.add('previewAdv', (editor, url) => {
insertAdv()

editor.on('change', function () {
const bookmark = editor.selection.getBookmark(2, true)

pCount = 0
advCount = 1
insertAdv()

setTimeout(function () {
editor.selection.moveToBookmark(bookmark)
editor.focus()
}, 0)
})
})

Expand Down

0 comments on commit e3bb247

Please sign in to comment.