Skip to content

Commit

Permalink
Add export format pdf,markdown,text
Browse files Browse the repository at this point in the history
  • Loading branch information
ACTom committed Aug 21, 2019
1 parent 866274b commit a221796
Show file tree
Hide file tree
Showing 15 changed files with 380 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source_dir=$(build_dir)/source
sign_dir=$(build_dir)/sign
package_name=$(app_name)
cert_dir=$(CURDIR)/../../key
version+=0.0.14
version+=0.0.15

all: appstore

Expand Down
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<name>Mind Map</name>
<summary>A Mind map editor</summary>
<description><![CDATA[This application enables Nextcloud users to open, save and edit mind map files in the web browser. If enabled, an entry in the New button at the top of the web browser the Mindmap file entry appears. When clicked, a new mindmap file opens in the browser and the file can be saved into the current Nextcloud directory.]]></description>
<version>0.0.14</version>
<version>0.0.15</version>
<licence>agpl</licence>
<author mail="i@actom.me" homepage="https://actom.me">Jingtao Yan</author>
<namespace>Files_MindMap</namespace>
Expand Down
41 changes: 41 additions & 0 deletions js/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ redirectIfNotDisplayedInFrame();
$('#export-svg').click(function(){
self.exportSVG();
});
$('#export-pdf').click(function(){
self.exportPDF();
});
$('#export-markdown').click(function(){
self.exportMarkdown();
});
$('#export-text').click(function(){
self.exportText();
});
},
startSaveTimer: function() {
var self = this;
Expand Down Expand Up @@ -183,6 +192,38 @@ redirectIfNotDisplayedInFrame();
}, function (data){
console.error('export svg fail', data);
});
},

exportMarkdown: function () {
var self = this;
minder.exportData('markdown').then(function (data) {
var url = 'data:text/markdown;base64,' + Base64.encode(data);
self.download(url, 'export.md');
}, function (data){
console.error('export markdown fail', data);
});
},

exportText: function () {
var self = this;
minder.exportData('text').then(function (data) {
var url = 'data:text/plain;base64,' + Base64.encode(data);
self.download(url, 'export.txt');
}, function (data){
console.error('export text fail', data);
});
},

exportPDF: function () {
var self = this;
minder.exportData('png').then(function (data) {
var pdf = new jsPDF('p', 'mm', 'a4', false);
//pdf.addImage(data, 'png', 100, 200, 280, 210, undefined, 'none');
pdf.addImage(data, 'PNG', 5, 10, 200, 0, undefined, 'SLOW');
self.download(pdf.output('datauristring'), 'export.pdf');
}, function (data){
console.error('export png fail', data);
});
}
};

Expand Down
5 changes: 4 additions & 1 deletion l10n/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ OC.L10N.register(
"The file is locked.":"The file is locked.",
"Share not found":"Share not found",
"You are not authorized to open this share":"You are not authorized to open this share",
"Could not write to file.":"Could not write to file."
"Could not write to file.":"Could not write to file.",
"Export to Markdown":"Export to Markdown",
"Export to Text":"Export to Text",
"Export to PDF":"Export to PDF"
},"nplurals=1; plural=0;"
);
5 changes: 4 additions & 1 deletion l10n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"The file is locked.":"The file is locked.",
"Share not found":"Share not found",
"You are not authorized to open this share":"You are not authorized to open this share",
"Could not write to file.":"Could not write to file."
"Could not write to file.":"Could not write to file.",
"Export to Markdown":"Export to Markdown",
"Export to Text":"Export to Text",
"Export to PDF":"Export to PDF"
},"pluralForm" :"nplurals=1; plural=0;"
}
5 changes: 4 additions & 1 deletion l10n/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ OC.L10N.register(
"The file is locked.":"The file is locked.",
"Share not found":"Share not found",
"You are not authorized to open this share":"You are not authorized to open this share",
"Could not write to file.":"Could not write to file."
"Could not write to file.":"Could not write to file.",
"Export to Markdown":"Export to Markdown",
"Export to Text":"Export to Text",
"Export to PDF":"Export to PDF"
},"nplurals=1; plural=0;"
);
5 changes: 4 additions & 1 deletion l10n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"The file is locked.":"The file is locked.",
"Share not found":"Share not found",
"You are not authorized to open this share":"You are not authorized to open this share",
"Could not write to file.":"Could not write to file."
"Could not write to file.":"Could not write to file.",
"Export to Markdown":"Export to Markdown",
"Export to Text":"Export to Text",
"Export to PDF":"Export to PDF"
},"nplurals=1; plural=0;"
}
5 changes: 4 additions & 1 deletion l10n/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ OC.L10N.register(
"The file is locked.":"The file is locked.",
"Share not found":"Share not found",
"You are not authorized to open this share":"You are not authorized to open this share",
"Could not write to file.":"Could not write to file."
"Could not write to file.":"Could not write to file.",
"Export to Markdown":"Export to Markdown",
"Export to Text":"Export to Text",
"Export to PDF":"Export to PDF"
},"nplurals=1; plural=0;"
);
5 changes: 4 additions & 1 deletion l10n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"The file is locked.":"The file is locked.",
"Share not found":"Share not found",
"You are not authorized to open this share":"You are not authorized to open this share",
"Could not write to file.":"Could not write to file."
"Could not write to file.":"Could not write to file.",
"Export to Markdown":"Export to Markdown",
"Export to Text":"Export to Text",
"Export to PDF":"Export to PDF"
},"pluralForm" :"nplurals=1; plural=0;"
}
5 changes: 4 additions & 1 deletion l10n/sk.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ OC.L10N.register(
"The file is locked.":"The file is locked.",
"Share not found":"Share not found",
"You are not authorized to open this share":"You are not authorized to open this share",
"Could not write to file.":"Could not write to file."
"Could not write to file.":"Could not write to file.",
"Export to Markdown":"Export to Markdown",
"Export to Text":"Export to Text",
"Export to PDF":"Export to PDF"
},"nplurals=1; plural=0;"
);
5 changes: 4 additions & 1 deletion l10n/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"The file is locked.":"The file is locked.",
"Share not found":"Share not found",
"You are not authorized to open this share":"You are not authorized to open this share",
"Could not write to file.":"Could not write to file."
"Could not write to file.":"Could not write to file.",
"Export to Markdown":"Export to Markdown",
"Export to Text":"Export to Text",
"Export to PDF":"Export to PDF"
},"pluralForm" :"nplurals=1; plural=0;"
}
5 changes: 4 additions & 1 deletion l10n/zh_CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ OC.L10N.register(
"The file is locked.":"文件被锁定",
"Share not found":"共享未找到",
"You are not authorized to open this share":"您没有权限打开这个共享",
"Could not write to file.":"无法写入文件。"
"Could not write to file.":"无法写入文件。",
"Export to Markdown":"导出为Markdown文本",
"Export to Text":"导出为Text文本",
"Export to PDF":"导出为PDF文件"
},"nplurals=1; plural=0;"
);
5 changes: 4 additions & 1 deletion l10n/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"The file is locked.":"文件被锁定",
"Share not found":"共享未找到",
"You are not authorized to open this share":"您没有权限打开这个共享",
"Could not write to file.":"无法写入文件。"
"Could not write to file.":"无法写入文件。",
"Export to Markdown":"导出为Markdown文本",
"Export to Text":"导出为Text文本",
"Export to PDF":"导出为PDF文件"
},"pluralForm" :"nplurals=1; plural=0;"
}
11 changes: 11 additions & 0 deletions templates/viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ class="btn btn-default export-caption dropdown-toggle"
<li>
<a id="export-svg" href"><?php p($l->t('Export to SVG')); ?></a>
</li>
<li>
<a id="export-pdf" href"><?php p($l->t('Export to PDF')); ?></a>
</li>
<li>
<a id="export-markdown" href"><?php p($l->t('Export to Markdown')); ?></a>
</li>
<li>
<a id="export-text" href"><?php p($l->t('Export to Text')); ?></a>
</li>
</ul>
</div>
<kityminder-editor id="viewer" on-init="initEditor(editor, minder)"></kityminder-editor>
Expand Down Expand Up @@ -155,5 +164,7 @@ class="btn btn-default export-caption dropdown-toggle"
<script nonce="<?=$nonce?>" src="<?php p($urlGenerator->linkTo('files_mindmap', 'vendor/kityminder-editor/kityminder.editor.min.js')) ?>?v=<?php p($version) ?>"></script>

<script nonce="<?=$nonce?>" src="<?php p($urlGenerator->linkTo('files_mindmap', 'js/viewer.js')) ?>?v=<?php p($version) ?>"></script>
<script nonce="<?=$nonce?>" src="<?php p($urlGenerator->linkTo('files_mindmap', 'vendor/jsPDF/dist/jspdf.min.js')) ?>?v=<?php p($version) ?>"></script>
<script nonce="<?=$nonce?>" src="<?php p($urlGenerator->linkTo('files_mindmap', 'vendor/svg2pdf.js/dist/svg2pdf.min.js')) ?>?v=<?php p($version) ?>"></script>
</html>

286 changes: 286 additions & 0 deletions vendor/jsPDF/dist/jspdf.min.js

Large diffs are not rendered by default.

0 comments on commit a221796

Please sign in to comment.