Skip to content

Commit

Permalink
Fix the initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Feb 22, 2024
1 parent f2ab694 commit 13bf6e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Change log
Next version
============

- Fixed the content editor initialization: The active region was only set after
saving and not initially.


6.4 (2024-02-16)
================

Expand Down
13 changes: 8 additions & 5 deletions content_editor/static/content_editor/content_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,9 +658,12 @@ django.jQuery(function ($) {
}

const restoreEditorState = () => {
const state = SS.get(location.pathname)
let tabs = $(".tabs.regions .tab")

const state = location.hash.includes("restore")
? SS.get(location.pathname)
: null
if (state) {
let tabs = $(".tabs.regions .tab")
let tab = tabs.filter(`[data-region="${state.region}"]`)
if (tab.length) {
tab.click()
Expand All @@ -680,16 +683,16 @@ django.jQuery(function ($) {
setTimeout(() => {
window.scrollTo(0, state.scrollY)
}, 200)
} else {
tabs.eq(0).click()
}
}

$("form").submit(function () {
this.action += "#restore"
saveEditorState()
})
setTimeout(() => {
if (location.hash.includes("restore")) restoreEditorState()
}, 1)
setTimeout(restoreEditorState, 1)

ContentEditor.plugins.forEach(function (plugin) {
ContentEditor.addPluginButton(plugin.prefix, plugin.button)
Expand Down

0 comments on commit 13bf6e1

Please sign in to comment.