Skip to content
This repository was archived by the owner on Oct 2, 2018. It is now read-only.

Commit f176125

Browse files
committed
Merge pull request #344 from twiss/txt-lines
Make lines, not paragraphs, in .txt documents
2 parents 35d89e9 + 329185e commit f176125

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

modules/editor/scripts/contentscript.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
(function(mainOrigin, _parentMessageProxy, initNight, filetype, odtdoc, readOnly) {
22
function fixupDocument(evt) {
33
if(document.body.children.length === 0) {
4-
var p = document.createElement('p');
5-
p.appendChild(document.createElement('br'));
6-
document.body.appendChild(p);
4+
if(filetype === '.txt') {
5+
document.body.appendChild(document.createElement('br'));
6+
} else {
7+
var p = document.createElement('p');
8+
p.appendChild(document.createElement('br'));
9+
document.body.appendChild(p);
10+
}
711
}
812
if(filetype === '.odt') {
913
try {
@@ -26,8 +30,10 @@
2630
document.execCommand('enableObjectResizing', false, 'true');
2731
}
2832

29-
// Make p, not div
30-
document.execCommand('defaultParagraphSeparator', false, 'p'); // Chrome
33+
if(filetype !== '.txt') {
34+
// Make p, not div
35+
document.execCommand('defaultParagraphSeparator', false, 'p'); // Chrome
36+
}
3137
if(document.getElementsByTagName('style').length === 0) {
3238
var style = document.createElement('style');
3339
style.textContent = [

0 commit comments

Comments
 (0)