Commit 97a50d3e authored by techird's avatar techird

分享页面备注查看支持

parent 64b8dbcf
...@@ -139,6 +139,7 @@ ...@@ -139,6 +139,7 @@
{ path: 'ui/eve.js', pack: 'edit|share|m-share' }, { path: 'ui/eve.js', pack: 'edit|share|m-share' },
{ path: 'ui/memory.js', pack: 'edit|share|m-share' }, { path: 'ui/memory.js', pack: 'edit|share|m-share' },
{ path: 'ui/fuix.js', pack: 'edit|share|m-share' }, { path: 'ui/fuix.js', pack: 'edit|share|m-share' },
{ path: 'ui/axss.js', pack: 'edit|share|m-share' },
{ path: 'ui/fiox.js', pack: 'edit' }, { path: 'ui/fiox.js', pack: 'edit' },
/* UI 组件 */ /* UI 组件 */
...@@ -212,6 +213,7 @@ ...@@ -212,6 +213,7 @@
{ path: 'ui/ribbon/idea/link.js', pack: 'edit' }, { path: 'ui/ribbon/idea/link.js', pack: 'edit' },
{ path: 'ui/ribbon/idea/image.js', pack: 'edit' }, { path: 'ui/ribbon/idea/image.js', pack: 'edit' },
{ path: 'ui/ribbon/idea/note.js', pack: 'edit' }, { path: 'ui/ribbon/idea/note.js', pack: 'edit' },
{ path: 'ui/ribbon/idea/notepreview.js', pack: 'edit|share' },
{ path: 'ui/ribbon/idea/priority.js', pack: 'edit' }, { path: 'ui/ribbon/idea/priority.js', pack: 'edit' },
{ path: 'ui/ribbon/idea/progress.js', pack: 'edit' }, { path: 'ui/ribbon/idea/progress.js', pack: 'edit' },
{ path: 'ui/ribbon/idea/resource.js', pack: 'edit' }, { path: 'ui/ribbon/idea/resource.js', pack: 'edit' },
......
...@@ -72,7 +72,8 @@ KityMinder.registerModule('Expand', function() { ...@@ -72,7 +72,8 @@ KityMinder.registerModule('Expand', function() {
if (node.getLevel() == level) node.collapse(); if (node.getLevel() == level) node.collapse();
}); });
km.refresh(100); km.refresh(100);
} },
enableReadOnly: true
}); });
var Expander = kity.createClass('Expander', { var Expander = kity.createClass('Expander', {
......
/**
* @fileOverview
*
* XSS Protection
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('axss', function() {
function axss(value) {
var div = document.createElement('div');
div.innerHTML = value;
$(div).find('script, iframe, link').remove();
for (var name in div) {
if (name.indexOf('on') === 0) {
div.removeAttribute(name);
}
}
return div.innerHTML;
}
return axss;
});
\ No newline at end of file
...@@ -66,8 +66,10 @@ KityMinder.registerUI('contextmenu', function(minder) { ...@@ -66,8 +66,10 @@ KityMinder.registerUI('contextmenu', function(minder) {
var lastDivider = true; var lastDivider = true;
ctxmenu.forEach(function(item) { ctxmenu.forEach(function(item) {
if (item.query && !item.query()) return; var query = item.query || function() {
if (item.command && minder.queryCommandState(item.command) === 0) { return item.command && minder.queryCommandState(item.command) === 0;
};
if (query()) {
var label = minder.getLang('ui.command.' + item.command); var label = minder.getLang('ui.command.' + item.command);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
*/ */
/* global marked: true */ /* global marked: true */
KityMinder.registerUI('ribbon/idea/note', function(minder) { KityMinder.registerUI('ribbon/idea/note', function(minder) {
var axss = minder.getUI('axss');
marked.setOptions({ marked.setOptions({
gfm: true, gfm: true,
...@@ -48,8 +49,6 @@ KityMinder.registerUI('ribbon/idea/note', function(minder) { ...@@ -48,8 +49,6 @@ KityMinder.registerUI('ribbon/idea/note', function(minder) {
var $editor = $('<div class="note-editor"></div>').appendTo($notePanel); var $editor = $('<div class="note-editor"></div>').appendTo($notePanel);
var $preview = $('<div class="note-preview"></div>').appendTo($notePanel); var $preview = $('<div class="note-preview"></div>').appendTo($notePanel);
var $previewer = $('<div id="note-previewer"></div>').appendTo('#content-wrapper');
var noteVisible = false; var noteVisible = false;
$editor.on('keydown keyup keypress mouedown mouseup click contextmenu', function(e) { $editor.on('keydown keyup keypress mouedown mouseup click contextmenu', function(e) {
...@@ -69,18 +68,6 @@ KityMinder.registerUI('ribbon/idea/note', function(minder) { ...@@ -69,18 +68,6 @@ KityMinder.registerUI('ribbon/idea/note', function(minder) {
var visible = false; var visible = false;
var selectedNode = null; var selectedNode = null;
function axss(value) {
var div = document.createElement('div');
div.innerHTML = value;
$(div).find('script').remove();
for (var name in div) {
if (name.indexOf('on') === 0) {
div.removeAttribute(name);
}
}
return div.innerHTML;
}
function updateEditorView() { function updateEditorView() {
if (noteVisible && selectedNode != minder.getSelectedNode()) { if (noteVisible && selectedNode != minder.getSelectedNode()) {
selectedNode = minder.getSelectedNode(); selectedNode = minder.getSelectedNode();
...@@ -112,48 +99,10 @@ KityMinder.registerUI('ribbon/idea/note', function(minder) { ...@@ -112,48 +99,10 @@ KityMinder.registerUI('ribbon/idea/note', function(minder) {
$noteButtonMenu.bindCommandState(minder, 'note'); $noteButtonMenu.bindCommandState(minder, 'note');
$noteButtonMenu.on('buttonclick', show); $noteButtonMenu.on('buttonclick', show);
minder.on('editnoterequest', show); minder.on('editnoterequest', show);
minder.on('shownoterequest', preview);
$('#kityminder').after($notePanel); $('#kityminder').after($notePanel);
hide(); hide();
var previewLive = false;
$('#kityminder').on('mousedown mousewheel DOMMouseScroll', function() {
if (!previewLive) return;
$previewer.fadeOut();
previewLive = false;
});
$previewer.hide();
function preview(e) {
var icon = e.icon;
var node = e.node;
var b = icon.getRenderBox('screen');
var note = node.getData('note');
$previewer.html(axss(marked(note)));
var cw = $('#content-wrapper').width();
var ch = $('#content-wrapper').height();
var pw = $previewer.outerWidth();
var ph = $previewer.outerHeight();
var x = b.cx - pw / 2;
var y = b.bottom + 10;
if (x < 0) x = 10;
if (x + pw > cw) x = cw - pw - 10;
if (y + ph > ch) y = b.top - ph - 10;
$previewer.css({
left: Math.round(x),
top: Math.round(y)
});
$previewer.show();
previewLive = true;
}
var activeTabClass = 'active-tab'; var activeTabClass = 'active-tab';
function editMode() { function editMode() {
......
/**
* @fileOverview
*
* 节点笔记支持
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
/* global marked: true */
KityMinder.registerUI('ribbon/idea/note', function(minder) {
var axss = minder.getUI('axss');
marked.setOptions({
gfm: true,
breaks: true
});
var $previewer = $('<div id="note-previewer"></div>').appendTo('#content-wrapper');
var visible = false;
var selectedNode = null;
minder.on('shownoterequest', preview);
var previewLive = false;
$('#kityminder').on('mousedown mousewheel DOMMouseScroll', function() {
if (!previewLive) return;
$previewer.fadeOut();
previewLive = false;
});
$previewer.hide();
function preview(e) {
var icon = e.icon;
var node = e.node;
var b = icon.getRenderBox('screen');
var note = node.getData('note');
$previewer[0].scrollTop = 0;
$previewer.html(axss(marked(note)));
var cw = $('#content-wrapper').width();
var ch = $('#content-wrapper').height();
var pw = $previewer.outerWidth();
var ph = $previewer.outerHeight();
var x = b.cx - pw / 2;
var y = b.bottom + 10;
if (x < 0) x = 10;
if (x + pw > cw) x = cw - pw - 10;
if (y + ph > ch) y = b.top - ph - 10;
$previewer.css({
left: Math.round(x),
top: Math.round(y)
});
$previewer.show();
previewLive = true;
}
});
\ No newline at end of file
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