mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-15 23:55:50 +00:00
sync, 当前笔记冲突问题
sync当前笔记时, 1) 把服务器上的content->本地 2) changeNote此时会触发saveContent, 此时拿之前的content与新的content对比, 所以导致isDirty
This commit is contained in:
5
node_modules/evt.js
generated
vendored
5
node_modules/evt.js
generated
vendored
@@ -16,8 +16,9 @@ if(!fs.existsSync(dataBasePath)) {
|
||||
// dataBasePath = '';
|
||||
|
||||
var Evt = {
|
||||
leanoteUrl: 'http://leanote.com',
|
||||
// leanoteUrl: 'http://127.0.0.1:9000',
|
||||
// leanoteUrl: 'http://leanote.com',
|
||||
leanoteUrl: 'http://localhost:9000',
|
||||
|
||||
port: 8008,
|
||||
localUrl: 'http://127.0.0.1:8008',
|
||||
dataBasePath: '',
|
||||
|
5
node_modules/note.js
generated
vendored
5
node_modules/note.js
generated
vendored
@@ -117,6 +117,11 @@ var Note = {
|
||||
console.error(isDirty);
|
||||
|
||||
updates['IsDirty'] = isDirty;
|
||||
|
||||
if(isDirty) {
|
||||
console.error("NONO----------");
|
||||
Web.alertWeb("NONO");
|
||||
}
|
||||
updates['LocalIsDelete'] = false;
|
||||
updates.UpdatedTime = date;
|
||||
|
||||
|
@@ -19,7 +19,7 @@
|
||||
|
||||
<!-- theme -->
|
||||
<link rel="stylesheet" href="public/css/theme/simple.css" type="text/css"/>
|
||||
<link rel="stylesheet" href="public/css/theme/ok.css" type="text/css" id="theme"/>
|
||||
<link rel="stylesheet" href="" type="text/css" id="theme"/>
|
||||
<link rel="stylesheet" href="public/css/theme/presentation.css" type="text/css" disabled id="themePresentation"/>
|
||||
<link rel="stylesheet" href="public/css/theme/writting.css" type="text/css" disabled id="themeWritting"/>
|
||||
|
||||
|
@@ -5,9 +5,9 @@
|
||||
"main": "note.html",
|
||||
"window": {
|
||||
"icon": "public/images/logo/leanote_icon_blue.png",
|
||||
"toolbar": false,
|
||||
"toolbar": true,
|
||||
|
||||
"frame": false,
|
||||
"frame": true,
|
||||
"transparent": true,
|
||||
|
||||
"min_width": 258,
|
||||
|
@@ -19,8 +19,13 @@
|
||||
width: 100px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
&.loading {
|
||||
animation: rond 2s infinite;
|
||||
-webkit-animation: rond 2s infinite;
|
||||
}
|
||||
}
|
||||
.loading-spin {
|
||||
animation: rond 2s infinite;
|
||||
-webkit-animation: rond 2s infinite;
|
||||
}
|
||||
|
@@ -30,6 +30,10 @@
|
||||
animation: rond 2s infinite;
|
||||
-webkit-animation: rond 2s infinite;
|
||||
}
|
||||
.loading-spin {
|
||||
animation: rond 2s infinite;
|
||||
-webkit-animation: rond 2s infinite;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Open Sans';
|
||||
font-style: normal;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#leftNotebook {
|
||||
background: none !important;
|
||||
background-color: rgba(37, 49, 62, 0.9) !important;
|
||||
background-color: rgba(37, 49, 62, 0.96) !important;
|
||||
}
|
||||
.folderHeader .fa-left,
|
||||
.folderHeader span {
|
||||
@@ -12,6 +12,10 @@
|
||||
#notebookList {
|
||||
border-top: none;
|
||||
}
|
||||
#notebookList input {
|
||||
background: transparent;
|
||||
color: #fff;
|
||||
}
|
||||
.folderBody a:hover {
|
||||
background-color: transparent !important;
|
||||
font-weight: bold;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#leftNotebook {
|
||||
background: none !important;
|
||||
background-color: rgba(37,49,62, 0.9) !important;
|
||||
background-color: rgba(37,49,62, 0.96) !important;
|
||||
// background: url(images/mohu.png) !important;
|
||||
// background-repeat: repeat;
|
||||
}
|
||||
@@ -13,6 +13,12 @@
|
||||
}
|
||||
#notebookList {
|
||||
border-top: none;
|
||||
|
||||
// 添加笔记本框
|
||||
input {
|
||||
background: transparent;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
.folderBody a:hover {
|
||||
background-color: transparent !important;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#leftNotebook {
|
||||
background: none !important;
|
||||
background-color: rgba(40, 167, 233, 0.9) !important;
|
||||
background-color: rgba(40, 167, 233, 0.96) !important;
|
||||
}
|
||||
.folderHeader .fa-left,
|
||||
.folderHeader span {
|
||||
@@ -12,6 +12,10 @@
|
||||
#notebookList {
|
||||
border-top: none;
|
||||
}
|
||||
#notebookList input {
|
||||
background: transparent;
|
||||
color: #fff;
|
||||
}
|
||||
.folderBody a:hover {
|
||||
background-color: transparent !important;
|
||||
font-weight: bold;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#leftNotebook {
|
||||
background: none !important;
|
||||
background-color: rgba(40,167,233, 0.9) !important;
|
||||
background-color: rgba(40,167,233, 0.96) !important;
|
||||
// background: url(images/mohu.png) !important;
|
||||
// background-repeat: repeat;
|
||||
}
|
||||
@@ -13,6 +13,11 @@
|
||||
}
|
||||
#notebookList {
|
||||
border-top: none;
|
||||
// 添加笔记本框
|
||||
input {
|
||||
background: transparent;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
.folderBody a:hover {
|
||||
background-color: transparent !important;
|
||||
|
@@ -29,6 +29,9 @@ body {
|
||||
#presentation svg {
|
||||
border-radius: 5px;
|
||||
}
|
||||
#presentation a {
|
||||
color: #2a6496;
|
||||
}
|
||||
#presentation.writting,
|
||||
#presentation.black {
|
||||
background-color: #F9F9F5;
|
||||
|
@@ -34,6 +34,10 @@ body {
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #2a6496;
|
||||
}
|
||||
|
||||
&.writting, &.black {
|
||||
background-color: #F9F9F5;
|
||||
|
||||
@@ -73,6 +77,7 @@ body {
|
||||
&.black {
|
||||
background-color: #000;
|
||||
color: #fff;
|
||||
|
||||
blockquote {
|
||||
background-color: rgba(192, 182, 182, 0.5);
|
||||
border-left-color: #988F8F;
|
||||
|
@@ -1622,6 +1622,10 @@ body.init #pageInner {
|
||||
animation: rond 2s infinite;
|
||||
-webkit-animation: rond 2s infinite;
|
||||
}
|
||||
.loading-spin {
|
||||
animation: rond 2s infinite;
|
||||
-webkit-animation: rond 2s infinite;
|
||||
}
|
||||
::selection {
|
||||
background: #000000;
|
||||
color: #ffffff;
|
||||
|
@@ -27,11 +27,11 @@ body.writting #note #mdEditor {
|
||||
bottom: 0;
|
||||
}
|
||||
body.writting #note #editor {
|
||||
background-color: #fbfcf7;
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
body.writting #note #editorContentWrap {
|
||||
position: absolute;
|
||||
padding: 5px 0;
|
||||
padding: 10px 0;
|
||||
top: 40px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
@@ -44,10 +44,11 @@ body.writting #note #editorContent {
|
||||
margin: auto;
|
||||
background-color: #fff;
|
||||
top: 0 !important;
|
||||
border-radius: 5px;
|
||||
border-radius: 0px;
|
||||
min-height: 100%;
|
||||
box-shadow: 0 1px 10px #ccc;
|
||||
font-size: 16px;
|
||||
padding: 50px;
|
||||
}
|
||||
body.writting #note #editorContent p {
|
||||
margin: 10px 0;
|
||||
@@ -101,6 +102,10 @@ body.writting #editor.all-tool #editorContentWrap {
|
||||
}
|
||||
.mce-btn {
|
||||
background-color: #fbfcf7 !important;
|
||||
overflow: hidden;
|
||||
}
|
||||
.mce-btn button span {
|
||||
overflow: hidden;
|
||||
}
|
||||
.mce-menubtn.mce-btn-small span {
|
||||
line-height: 20px !important;
|
||||
@@ -140,3 +145,6 @@ body.writting #editor.all-tool #editorContentWrap {
|
||||
font-size: 16px;
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
}
|
||||
.pren-tool {
|
||||
right: 6px;
|
||||
}
|
||||
|
@@ -43,11 +43,12 @@ body.writting {
|
||||
}
|
||||
|
||||
#editor {
|
||||
background-color: @bgColor;
|
||||
// background-color: @bgColor;
|
||||
background-color: rgba(242,242,242,1);
|
||||
}
|
||||
#editorContentWrap {
|
||||
position: absolute;
|
||||
padding: 5px 0;
|
||||
padding: 10px 0;
|
||||
top: 40px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
@@ -61,10 +62,11 @@ body.writting {
|
||||
background-color: #fff;
|
||||
top: 0 !important;
|
||||
// margin-top: 5px;
|
||||
border-radius: 5px;
|
||||
border-radius: 0px;
|
||||
min-height: 100%;
|
||||
box-shadow: 0 1px 10px #ccc;
|
||||
font-size: 16px;
|
||||
padding: 50px;
|
||||
p {
|
||||
margin: 10px 0;
|
||||
}
|
||||
@@ -129,7 +131,15 @@ body.writting {
|
||||
}
|
||||
.mce-btn {
|
||||
background-color: @bgColor !important;
|
||||
overflow: hidden;
|
||||
button {
|
||||
span {
|
||||
// windows, linux下有滚动
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.mce-menubtn.mce-btn-small span {
|
||||
line-height: 20px !important;
|
||||
}
|
||||
@@ -166,3 +176,8 @@ body.writting {
|
||||
font-size: 16px;
|
||||
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
||||
}
|
||||
|
||||
// 为了滚动条能拖动
|
||||
.pren-tool {
|
||||
right: 6px;
|
||||
}
|
||||
|
@@ -280,13 +280,16 @@ Note.curHasChanged = function(force) {
|
||||
if(hasChanged.IsNew) {
|
||||
$.extend(hasChanged, cacheNote);
|
||||
} else {
|
||||
/*
|
||||
if(!cacheNote.isDirty) { // 不是dirty
|
||||
// dirty操作在后台控制吧, 因为有些命令如添加链接不会触发keydown的
|
||||
console.log("no dirty");
|
||||
hasChanged.hasChanged = false;
|
||||
return hasChanged;
|
||||
} else {
|
||||
console.log("is dirty");
|
||||
// console.log("is dirty");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
if(cacheNote.Title != title) {
|
||||
@@ -474,6 +477,10 @@ Note.curChangedSaveIt = function(force, callback) {
|
||||
me.saveInProcess[hasChanged.NoteId] = true;
|
||||
|
||||
// console.error('保存当前的笔记: ' + hasChanged.NoteId);
|
||||
//
|
||||
|
||||
console.error("why====================");
|
||||
console.trace("why");
|
||||
|
||||
NoteService.updateNoteOrContent(hasChanged, function(ret) {
|
||||
me.saveInProcess[hasChanged.NoteId] = false;
|
||||
@@ -728,7 +735,23 @@ Note.changeNote = function(selectNoteId, isShare, needSaveChanged, callback) {
|
||||
// console.trace();
|
||||
|
||||
Service.noteService.getNoteContent(cacheNote.NoteId, setContent); // ajaxGet(url, param, setContent);
|
||||
}
|
||||
};
|
||||
|
||||
// 重新渲染笔记, 因为sync更新了
|
||||
Note.reRenderNote = function(noteId) {
|
||||
var me = this;
|
||||
me.showContentLoading();
|
||||
var note = Note.getNote(noteId);
|
||||
Note.renderNote(note);
|
||||
NoteService.getNoteContent(noteId, function(noteContent) {
|
||||
if(noteContent) {
|
||||
Note.setNoteCache(noteContent, false);
|
||||
Attach.renderNoteAttachNum(noteId, true);
|
||||
Note.renderNoteContent(noteContent);
|
||||
}
|
||||
me.hideContentLoading();
|
||||
});
|
||||
};
|
||||
|
||||
// 渲染
|
||||
|
||||
@@ -1194,7 +1217,6 @@ Note.saveNote = function(e) {
|
||||
} else {
|
||||
}
|
||||
|
||||
|
||||
// copy, paste
|
||||
if(e.ctrlKey || e.metaKey) {
|
||||
if(num == 67) { // ctrl + c
|
||||
@@ -1932,7 +1954,7 @@ Note.contentSynced = function(noteId, content) {
|
||||
if(me.curNoteId == noteId || me.inChangeNoteId == noteId) {
|
||||
// alert(note.Title);
|
||||
// 重新渲染
|
||||
Note.changeNote(noteId);
|
||||
Note.reRenderNote(noteId);
|
||||
} else {
|
||||
// 生成desc
|
||||
me.renderNoteDesc(note);
|
||||
@@ -2716,8 +2738,8 @@ Note.updateSync = function(notes) {
|
||||
console.log('->>>');
|
||||
console.log(Note.curNoteId);
|
||||
if(Note.curNoteId == note.NoteId) {
|
||||
console.log('yes---');
|
||||
Note.changeNote(Note.curNoteId);
|
||||
// 这里, 如果当前就是更新的, 则重新render, 有个问题, server新内容已经在服务器上了
|
||||
Note.reRenderNote(Note.curNoteId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -699,65 +699,72 @@ LeaAce = {
|
||||
return "leanote_ace_" + (new Date()).getTime() + "_" + this._aceId;
|
||||
},
|
||||
initAce: function(id, val, force) {
|
||||
var me = this;
|
||||
if(!force && !me.canAndIsAce()) {
|
||||
return;
|
||||
try {
|
||||
var me = this;
|
||||
if(!force && !me.canAndIsAce()) {
|
||||
return;
|
||||
}
|
||||
me.disableAddHistory();
|
||||
var $pre = $('#' + id);
|
||||
if($pre.length == 0) {
|
||||
return;
|
||||
}
|
||||
$pre.find('.toggle-raw').remove();
|
||||
var preHtml = $pre.html();
|
||||
|
||||
$pre.removeClass('ace-to-pre');
|
||||
$pre.attr("contenteditable", false); // ? 避免tinymce编辑
|
||||
var aceEditor = ace.edit(id);
|
||||
aceEditor.setTheme("ace/theme/tomorrow");
|
||||
|
||||
var brush = me.getPreBrush($pre);
|
||||
var b = "";
|
||||
if(brush) {
|
||||
try {
|
||||
b = brush.split(':')[1];
|
||||
} catch(e) {}
|
||||
}
|
||||
b = b || "javascript";
|
||||
aceEditor.session.setMode("ace/mode/" + b);
|
||||
aceEditor.getSession().setUseWorker(false); // 不用语法检查
|
||||
aceEditor.setOption("showInvisibles", false); // 不显示空格, 没用
|
||||
aceEditor.setOption("wrap", "free");
|
||||
aceEditor.setShowInvisibles(false);
|
||||
aceEditor.setAutoScrollEditorIntoView(true);
|
||||
aceEditor.setOption("maxLines", 100);
|
||||
aceEditor.commands.addCommand({
|
||||
name: "undo",
|
||||
bindKey: {win: "Ctrl-z", mac: "Command-z"},
|
||||
exec: function(editor) {
|
||||
var undoManager = editor.getSession().getUndoManager();
|
||||
if(undoManager.hasUndo()){
|
||||
undoManager.undo();
|
||||
} else {
|
||||
undoManager.reset();
|
||||
tinymce.activeEditor.undoManager.undo();
|
||||
}
|
||||
}
|
||||
});
|
||||
this._aceEditors[id] = aceEditor;
|
||||
if(val) {
|
||||
aceEditor.setValue(val);
|
||||
// 不要选择代码
|
||||
// TODO
|
||||
} else {
|
||||
// 防止 <pre><div>xx</div></pre> 这里的<div>消失
|
||||
// preHtml = preHtml.replace('/ /g', ' '); // 以前是把' ' 全换成了
|
||||
// aceEditor.setValue(preHtml);
|
||||
// 全不选
|
||||
// aceEditor.selection.clearSelection();
|
||||
}
|
||||
|
||||
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
|
||||
me.resetAddHistory();
|
||||
return aceEditor;
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
me.disableAddHistory();
|
||||
var $pre = $('#' + id);
|
||||
$pre.find('.toggle-raw').remove();
|
||||
var preHtml = $pre.html();
|
||||
|
||||
$pre.removeClass('ace-to-pre');
|
||||
$pre.attr("contenteditable", false); // ? 避免tinymce编辑
|
||||
var aceEditor = ace.edit(id);
|
||||
aceEditor.setTheme("ace/theme/tomorrow");
|
||||
|
||||
var brush = me.getPreBrush($pre);
|
||||
var b = "";
|
||||
if(brush) {
|
||||
try {
|
||||
b = brush.split(':')[1];
|
||||
} catch(e) {}
|
||||
}
|
||||
b = b || "javascript";
|
||||
aceEditor.session.setMode("ace/mode/" + b);
|
||||
aceEditor.getSession().setUseWorker(false); // 不用语法检查
|
||||
aceEditor.setOption("showInvisibles", false); // 不显示空格, 没用
|
||||
aceEditor.setOption("wrap", "free");
|
||||
aceEditor.setShowInvisibles(false);
|
||||
aceEditor.setAutoScrollEditorIntoView(true);
|
||||
aceEditor.setOption("maxLines", 100);
|
||||
aceEditor.commands.addCommand({
|
||||
name: "undo",
|
||||
bindKey: {win: "Ctrl-z", mac: "Command-z"},
|
||||
exec: function(editor) {
|
||||
var undoManager = editor.getSession().getUndoManager();
|
||||
if(undoManager.hasUndo()){
|
||||
undoManager.undo();
|
||||
} else {
|
||||
undoManager.reset();
|
||||
tinymce.activeEditor.undoManager.undo();
|
||||
}
|
||||
}
|
||||
});
|
||||
this._aceEditors[id] = aceEditor;
|
||||
if(val) {
|
||||
aceEditor.setValue(val);
|
||||
// 不要选择代码
|
||||
// TODO
|
||||
} else {
|
||||
// 防止 <pre><div>xx</div></pre> 这里的<div>消失
|
||||
// preHtml = preHtml.replace('/ /g', ' '); // 以前是把' ' 全换成了
|
||||
// aceEditor.setValue(preHtml);
|
||||
// 全不选
|
||||
// aceEditor.selection.clearSelection();
|
||||
}
|
||||
|
||||
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
|
||||
me.resetAddHistory();
|
||||
return aceEditor;
|
||||
},
|
||||
clearIntervalForInitAce: null,
|
||||
initAceFromContent: function(editor) {
|
||||
@@ -1485,8 +1492,10 @@ function userMenu() {
|
||||
// ----------
|
||||
// 全局菜单
|
||||
|
||||
Pren.init();
|
||||
var mode = new gui.Menu();
|
||||
|
||||
Pren.init();
|
||||
|
||||
mode.append(Pren.pren);
|
||||
mode.append(Pren.fullScreen);
|
||||
var modes = new gui.MenuItem({ label: 'Mode', submenu: mode});
|
||||
@@ -1568,8 +1577,16 @@ function userMenu() {
|
||||
var height = 130;
|
||||
if(!isMac()) {
|
||||
this.menu.append(new gui.MenuItem({ type: 'separator' }));
|
||||
|
||||
this.menu.append(Pren.pren);
|
||||
this.menu.append(Pren.fullScreen);
|
||||
/*
|
||||
this.menu.append(new gui.MenuItem(
|
||||
{label: 'Toggle Presentation', click: function() {
|
||||
// me.togglePren();
|
||||
}
|
||||
}));
|
||||
*/
|
||||
height = 220;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user