Merge pull request #99 from VE-FORBRYDERNE/mutation-observer
Re-enable the editor mutation observer
This commit is contained in:
commit
c8ece04b1d
|
@ -1628,6 +1628,21 @@ function highlightEditingChunks() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This gets run every time the text in a chunk is edited
|
||||||
|
// or a chunk is deleted
|
||||||
|
function chunkOnDOMMutate(mutations, observer) {
|
||||||
|
if(!gametext_bound || !allowedit) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var nodes = [];
|
||||||
|
for(var i = 0; i < mutations.length; i++) {
|
||||||
|
var mutation = mutations[i];
|
||||||
|
nodes = nodes.concat(Array.from(mutation.addedNodes), Array.from(mutation.removedNodes));
|
||||||
|
nodes.push(mutation.target);
|
||||||
|
}
|
||||||
|
applyChunkDeltas(nodes);
|
||||||
|
}
|
||||||
|
|
||||||
// This gets run every time you try to paste text into the editor
|
// This gets run every time you try to paste text into the editor
|
||||||
function chunkOnPaste(event) {
|
function chunkOnPaste(event) {
|
||||||
// Register the chunk we're pasting in as having been modified
|
// Register the chunk we're pasting in as having been modified
|
||||||
|
@ -1705,10 +1720,12 @@ function chunkOnFocusOut(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindGametext() {
|
function bindGametext() {
|
||||||
|
mutation_observer.observe(game_text[0], {characterData: true, childList: true, subtree: true});
|
||||||
gametext_bound = true;
|
gametext_bound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function unbindGametext() {
|
function unbindGametext() {
|
||||||
|
mutation_observer.disconnect();
|
||||||
gametext_bound = false;
|
gametext_bound = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2280,6 +2297,7 @@ $(document).ready(function(){
|
||||||
).on('focusout',
|
).on('focusout',
|
||||||
chunkOnFocusOut
|
chunkOnFocusOut
|
||||||
);
|
);
|
||||||
|
mutation_observer = new MutationObserver(chunkOnDOMMutate);
|
||||||
|
|
||||||
// This is required for the editor to work correctly in Firefox on desktop
|
// This is required for the editor to work correctly in Firefox on desktop
|
||||||
// because the gods of HTML and JavaScript say so
|
// because the gods of HTML and JavaScript say so
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<script src="static/bootstrap.min.js"></script>
|
<script src="static/bootstrap.min.js"></script>
|
||||||
<script src="static/bootstrap-toggle.min.js"></script>
|
<script src="static/bootstrap-toggle.min.js"></script>
|
||||||
<script src="static/rangy-core.min.js"></script>
|
<script src="static/rangy-core.min.js"></script>
|
||||||
<script src="static/application.js?ver=1.17"></script>
|
<script src="static/application.js?ver=1.17a"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<input type="file" id="remote-save-select" accept="application/json" style="display:none">
|
<input type="file" id="remote-save-select" accept="application/json" style="display:none">
|
||||||
|
|
Loading…
Reference in New Issue