Commit 77374cbd authored by Robin Tissot's avatar Robin Tissot
Browse files

Attempt at fixing pasting in text panel, disables history on multi line paste.

parent 84417828
......@@ -73,7 +73,7 @@ var DiploPanel = BasePanel.extend({
if (pos === undefined) {
this.editor.appendChild(div);
} else {
this.editor.insertBefore(div, pos.nextSibling);
this.editor.insertBefore(div, pos);
}
return div;
},
......@@ -188,7 +188,7 @@ var DiploPanel = BasePanel.extend({
},
cleanSource(dirtyText) {
// cleanup html and possibly other tags (?)
var tmp = document.createElement("DIV");
var tmp = document.createElement("div");
tmp.innerHTML = dirtyText;
let clean = tmp.textContent || tmp.innerText || "";
tmp.remove();
......@@ -205,21 +205,17 @@ var DiploPanel = BasePanel.extend({
const selection = window.getSelection();
let range = selection.getRangeAt(0);
let target = range.startContainer.nodeType==Node.TEXT_NODE?range.startContainer.parentNode:range.startContainer;
let start = Array.prototype.indexOf.call(target.parentNode.children, target);
let start = Array.prototype.indexOf.call(this.editor.children, target);
let newDiv, child = this.editor.children[start];
for (let i = 0; i < pasted_data_split.length; i++) {
let content = pasted_data_split[i];
let child = target.parentNode.children[start+i];
let newDiv;
if (child) {
newDiv = this.appendLine(child);
} else {
newDiv = this.appendLine();
}
newDiv = this.appendLine(child);
newDiv.textContent = this.cleanSource(pasted_data_split[i]);
// trick to get at least 'some' ctrl+z functionality
range.setStart(newDiv, 0);
selection.removeAllRanges();
selection.addRange(range);
document.execCommand("insertText", false, this.cleanSource(content));
// this fails in spectacular ways differently in firefox and chrome... so no ctrl+z
/* range.setStart(newDiv, 0);
* selection.removeAllRanges();
* selection.addRange(range);
* document.execCommand("insertText", false, this.cleanSource(content)); */
}
}
......
......@@ -86,7 +86,7 @@
data-target="diplomatic"
class="open-panel nav-item btn"
v-bind:class="[ show.diplomatic ? 'btn-primary' : 'btn-secondary' ]"
title="{% trans "Diplomatic" %}"><i class="click-through fas fa-list-ol"></i></button>
title="{% trans "Text" %}"><i class="click-through fas fa-list-ol"></i></button>
</div>
{% endblock %}
......@@ -548,7 +548,7 @@
inline-template>
<div class="col panel">
<div class="tools">
<i title="{% trans 'Transcription Panel' %}" class="panel-icon fas fa-list-ol"></i>
<i title="{% trans 'Text Panel' %}" class="panel-icon fas fa-list-ol"></i>
<i id="save-notif" title="{% trans "There is content waiting to be saved (don't leave the page)" %}" class="notice fas fa-save hide"></i>
<button id="sortMode"
title="{% trans "Toggle sorting mode." %}"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment