Skip to content

Commit

Permalink
feat(Export): export toolbar handler api (#38)
Browse files Browse the repository at this point in the history
* feat(Export): export toolbar handler api
* fix(api-demo): add export toolbar
  • Loading branch information
joriewong committed Nov 25, 2021
1 parent f269eb3 commit 360de5f
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 88 deletions.
2 changes: 1 addition & 1 deletion dist/cherry-markdown.core.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cherry-markdown.engine.core.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cherry-markdown.esm.js

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions dist/cherry-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -50266,8 +50266,11 @@
value: function onClick() {
var type = arguments.length > 1 ? arguments[1] : undefined;

/** @type {HTMLElement}*/
document.querySelector('.cherry-dropdown[name=export]').style.display = 'none';
if (document.querySelector('.cherry-dropdown[name=export]')) {
/** @type {HTMLElement}*/
document.querySelector('.cherry-dropdown[name=export]').style.display = 'none';
}

if (type === 'pdf') this.exportPDF();else if (type === 'screenShot') this.exportScreenShot();
}
}, {
Expand Down Expand Up @@ -81718,7 +81721,7 @@
});
}

var VERSION = "0.5.14-463e03ea";
var VERSION = "0.5.14-97bf5b5e";
var CherryStatic = /*#__PURE__*/function () {
function CherryStatic() {
_classCallCheck(this, CherryStatic);
Expand Down
2 changes: 1 addition & 1 deletion dist/cherry-markdown.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cherry-markdown.min.js

Large diffs are not rendered by default.

Binary file modified dist/fonts/ch-icon.eot
Binary file not shown.
Binary file modified dist/fonts/ch-icon.ttf
Binary file not shown.
Binary file modified dist/fonts/ch-icon.woff
Binary file not shown.
Binary file modified dist/fonts/ch-icon.woff2
Binary file not shown.
32 changes: 32 additions & 0 deletions examples/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,38 @@ <h2 class="one-api__name">toolbar.toolbarHandlers.graph(type:string)</h2>
</div>
</div>

<div class="one-api">
<h2 class="one-api__name">toolbar.toolbarHandlers.export(type:string)</h2>
<p class="one-api__desc">cherry编辑器导出PDF/长图</p>
<table class="cherry-api-table">
<thead>
<tr>
<th>type</th>
<th>效果</th>
</tr>
</thead>
<tbody>
<tr>
<td>'pdf'</td>
<td>PDF</td>
</tr>
<tr>
<td>'screenShot'</td>
<td>长图</td>
</tr>
</tbody>
</table>
<div class="one-api__try">
<textarea id="setMarkdown" placeholder="输入内容">
cherryObj.toolbar.toolbarHandlers.export('pdf')</textarea>
<a class="one-api__btn" onclick="dealClick(this, event)">试一试</a>
</div>
<div class="one-api__try">
<textarea id="setMarkdown" placeholder="输入内容">
cherryObj.toolbar.toolbarHandlers.export('screenShot')</textarea>
<a class="one-api__btn" onclick="dealClick(this, event)">试一试</a>
</div>
</div>
</div>
<div id="markdown"></div>

Expand Down
1 change: 1 addition & 0 deletions examples/scripts/api-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ var cherryConfig = {
{ insert: ['image', 'audio', 'video', 'link', 'hr', 'br', 'code', 'formula', 'toc', 'table', 'pdf', 'word'] },
'graph',
'settings',
'export'
],
},
editor: {},
Expand Down
158 changes: 79 additions & 79 deletions src/sass/ch-icon.scss
Original file line number Diff line number Diff line change
@@ -1,79 +1,79 @@
@font-face {
font-family: "ch-icon";
src: url('./fonts/ch-icon.eot');
src: url('./fonts/ch-icon.eot?#iefix') format('eot'),
url('./fonts/ch-icon.woff2') format('woff2'),
url('./fonts/ch-icon.woff') format('woff'),
url('./fonts/ch-icon.ttf') format('truetype'),
url('./fonts/ch-icon.svg#ch-icon') format('svg');
font-weight: normal;
font-style: normal;
}

.ch-icon:before {
display: inline-block;
font-family: "ch-icon";
font-style: normal;
font-weight: normal;
//line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

.ch-icon-list:before { content: "\EA03" }
.ch-icon-check:before { content: "\EA04" }
.ch-icon-square:before { content: "\EA09" }
.ch-icon-bold:before { content: "\EA0A" }
.ch-icon-code:before { content: "\EA0B" }
.ch-icon-color:before { content: "\EA0C" }
.ch-icon-header:before { content: "\EA0D" }
.ch-icon-image:before { content: "\EA0E" }
.ch-icon-italic:before { content: "\EA0F" }
.ch-icon-link:before { content: "\EA10" }
.ch-icon-ol:before { content: "\EA11" }
.ch-icon-size:before { content: "\EA12" }
.ch-icon-strike:before { content: "\EA13" }
.ch-icon-table:before { content: "\EA14" }
.ch-icon-ul:before { content: "\EA15" }
.ch-icon-underline:before { content: "\EA16" }
.ch-icon-word:before { content: "\EA17" }
.ch-icon-blockquote:before { content: "\EA18" }
.ch-icon-font:before { content: "\EA19" }
.ch-icon-insertClass:before { content: "\EA1F" }
.ch-icon-insertFlow:before { content: "\EA20" }
.ch-icon-insertFormula:before { content: "\EA21" }
.ch-icon-insertGantt:before { content: "\EA22" }
.ch-icon-insertGraph:before { content: "\EA23" }
.ch-icon-insertPie:before { content: "\EA24" }
.ch-icon-insertSeq:before { content: "\EA25" }
.ch-icon-insertState:before { content: "\EA26" }
.ch-icon-line:before { content: "\EA27" }
.ch-icon-preview:before { content: "\EA28" }
.ch-icon-previewClose:before { content: "\EA29" }
.ch-icon-toc:before { content: "\EA2A" }
.ch-icon-sub:before { content: "\EA2D" }
.ch-icon-sup:before { content: "\EA2E" }
.ch-icon-h1:before { content: "\EA2F" }
.ch-icon-h2:before { content: "\EA30" }
.ch-icon-h3:before { content: "\EA31" }
.ch-icon-h4:before { content: "\EA32" }
.ch-icon-h5:before { content: "\EA33" }
.ch-icon-h6:before { content: "\EA34" }
.ch-icon-video:before { content: "\EA35" }
.ch-icon-insert:before { content: "\EA36" }
.ch-icon-little_table:before { content: "\EA37" }
.ch-icon-pdf:before { content: "\EA38" }
.ch-icon-checklist:before { content: "\EA39" }
.ch-icon-close:before { content: "\EA40" }
.ch-icon-fullscreen:before { content: "\EA41" }
.ch-icon-minscreen:before { content: "\EA42" }
.ch-icon-insertChart:before { content: "\EA43" }
.ch-icon-question:before { content: "\EA44" }
.ch-icon-settings:before { content: "\EA45" }
.ch-icon-ok:before { content: "\EA46" }
.ch-icon-br:before { content: "\EA47" }
.ch-icon-normal:before { content: "\EA48" }
.ch-icon-undo:before { content: "\EA49" }
.ch-icon-redo:before { content: "\EA50" }
.ch-icon-copy:before { content: "\EA51" }
.ch-icon-phone:before { content: "\EA52" }
@font-face {
font-family: "ch-icon";
src: url('./fonts/ch-icon.eot');
src: url('./fonts/ch-icon.eot?#iefix') format('eot'),
url('./fonts/ch-icon.woff2') format('woff2'),
url('./fonts/ch-icon.woff') format('woff'),
url('./fonts/ch-icon.ttf') format('truetype'),
url('./fonts/ch-icon.svg#ch-icon') format('svg');
font-weight: normal;
font-style: normal;
}

.ch-icon:before {
display: inline-block;
font-family: "ch-icon";
font-style: normal;
font-weight: normal;
//line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

.ch-icon-list:before { content: "\EA03" }
.ch-icon-check:before { content: "\EA04" }
.ch-icon-square:before { content: "\EA09" }
.ch-icon-bold:before { content: "\EA0A" }
.ch-icon-code:before { content: "\EA0B" }
.ch-icon-color:before { content: "\EA0C" }
.ch-icon-header:before { content: "\EA0D" }
.ch-icon-image:before { content: "\EA0E" }
.ch-icon-italic:before { content: "\EA0F" }
.ch-icon-link:before { content: "\EA10" }
.ch-icon-ol:before { content: "\EA11" }
.ch-icon-size:before { content: "\EA12" }
.ch-icon-strike:before { content: "\EA13" }
.ch-icon-table:before { content: "\EA14" }
.ch-icon-ul:before { content: "\EA15" }
.ch-icon-underline:before { content: "\EA16" }
.ch-icon-word:before { content: "\EA17" }
.ch-icon-blockquote:before { content: "\EA18" }
.ch-icon-font:before { content: "\EA19" }
.ch-icon-insertClass:before { content: "\EA1F" }
.ch-icon-insertFlow:before { content: "\EA20" }
.ch-icon-insertFormula:before { content: "\EA21" }
.ch-icon-insertGantt:before { content: "\EA22" }
.ch-icon-insertGraph:before { content: "\EA23" }
.ch-icon-insertPie:before { content: "\EA24" }
.ch-icon-insertSeq:before { content: "\EA25" }
.ch-icon-insertState:before { content: "\EA26" }
.ch-icon-line:before { content: "\EA27" }
.ch-icon-preview:before { content: "\EA28" }
.ch-icon-previewClose:before { content: "\EA29" }
.ch-icon-toc:before { content: "\EA2A" }
.ch-icon-sub:before { content: "\EA2D" }
.ch-icon-sup:before { content: "\EA2E" }
.ch-icon-h1:before { content: "\EA2F" }
.ch-icon-h2:before { content: "\EA30" }
.ch-icon-h3:before { content: "\EA31" }
.ch-icon-h4:before { content: "\EA32" }
.ch-icon-h5:before { content: "\EA33" }
.ch-icon-h6:before { content: "\EA34" }
.ch-icon-video:before { content: "\EA35" }
.ch-icon-insert:before { content: "\EA36" }
.ch-icon-little_table:before { content: "\EA37" }
.ch-icon-pdf:before { content: "\EA38" }
.ch-icon-checklist:before { content: "\EA39" }
.ch-icon-close:before { content: "\EA40" }
.ch-icon-fullscreen:before { content: "\EA41" }
.ch-icon-minscreen:before { content: "\EA42" }
.ch-icon-insertChart:before { content: "\EA43" }
.ch-icon-question:before { content: "\EA44" }
.ch-icon-settings:before { content: "\EA45" }
.ch-icon-ok:before { content: "\EA46" }
.ch-icon-br:before { content: "\EA47" }
.ch-icon-normal:before { content: "\EA48" }
.ch-icon-undo:before { content: "\EA49" }
.ch-icon-redo:before { content: "\EA50" }
.ch-icon-copy:before { content: "\EA51" }
.ch-icon-phone:before { content: "\EA52" }
4 changes: 3 additions & 1 deletion src/toolbars/hooks/Export.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ export default class Export extends MenuBase {
}

onClick(shortKey = '', type) {
/** @type {HTMLElement}*/ (document.querySelector('.cherry-dropdown[name=export]')).style.display = 'none';
if (document.querySelector('.cherry-dropdown[name=export]')) {
/** @type {HTMLElement}*/ (document.querySelector('.cherry-dropdown[name=export]')).style.display = 'none';
}
if (type === 'pdf') this.exportPDF();
else if (type === 'screenShot') this.exportScreenShot();
}
Expand Down

0 comments on commit 360de5f

Please sign in to comment.