Skip to content

Commit

Permalink
update iframes from container changes
Browse files Browse the repository at this point in the history
SQUASHED: AUTO-COMMIT-src-client-utils.js,AUTO-COMMIT-src-components-tools-lively-container.js,
  • Loading branch information
onsetsu committed Aug 12, 2024
1 parent adb0ecb commit fcd1879
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/client/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ export function shake(target) {
}

export function updateEditors(url, excludedEditors = []) {

url = url.toString().replace(/[#?].*/,"")

const editors = lively.findAllElements(ea => ea.localName == "lively-editor", true)
Expand All @@ -414,6 +413,17 @@ export function updateEditors(url, excludedEditors = []) {
})
}

export function updateLivelyIFrames(url, excludedFrames = []) {
url = url.toString().replace(/[#?].*/,"")

const frames = lively.findAllElements(ea => ea.localName == "lively-iframe", true)
const framesToUpdate = frames.filter(ea => ea.getURL().replace(/[#?].*/,"") === url && !excludedFrames.includes(ea))

framesToUpdate.forEach(ea => {
ea.update()
})
}

/*MD Source Code Locations and Ranges MD*/
function babelToCM(babelPosition) {
return {
Expand Down
3 changes: 2 additions & 1 deletion src/components/tools/lively-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import files from "src/client/files.js"
import Strings from "src/client/strings.js"
let ScopedScripts; // lazy load this... #TODO fix #ContextJS #Bug actual stack overflow
import Clipboard from "src/client/clipboard.js"
import {fileEnding, replaceFileEndingWith, updateEditors} from "utils"
import {fileEnding, replaceFileEndingWith, updateEditors, updateLivelyIFrames} from "utils"
import ViewNav from "src/client/viewnav.js"
import Upndown from 'src/external/upndown.js'
import {AnnotatedText, Annotation, default as AnnotationSet} from "src/client/annotations.js"
Expand Down Expand Up @@ -2391,6 +2391,7 @@ export default class Container extends Morph {
await lively.sleep(100) // save is async...

updateEditors(url, [this.get("lively-editor")])
updateLivelyIFrames(url)

document.body.querySelectorAll('lively-container').forEach(ea => {
if (ea !== this && !ea.isEditing()
Expand Down

0 comments on commit fcd1879

Please sign in to comment.