mirror of
https://github.com/zadam/trilium.git
synced 2024-09-20 15:45:58 +08:00
parent
8fcc76ad6d
commit
5fbaed61c1
2
libraries/ckeditor/ckeditor.js
vendored
2
libraries/ckeditor/ckeditor.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -248,6 +248,13 @@ class NoteContext extends Component {
|
|||
ntxId: this.ntxId
|
||||
}));
|
||||
}
|
||||
|
||||
async getTypeWidget() {
|
||||
return new Promise(resolve => appContext.triggerCommand('executeWithTypeWidget', {
|
||||
resolve,
|
||||
ntxId: this.ntxId
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
export default NoteContext;
|
||||
|
|
|
@ -24,8 +24,8 @@ async function createNote(parentNotePath, options = {}) {
|
|||
options.saveSelection = false;
|
||||
}
|
||||
|
||||
if (options.saveSelection && utils.isCKEditorInitialized()) {
|
||||
[options.title, options.content] = parseSelectedHtml(window.cutToNote.getSelectedHtml());
|
||||
if (options.saveSelection) {
|
||||
[options.title, options.content] = parseSelectedHtml(options.textEditor.getSelectedHtml());
|
||||
}
|
||||
|
||||
const parentNoteId = treeService.getNoteIdFromNotePath(parentNotePath);
|
||||
|
@ -46,9 +46,9 @@ async function createNote(parentNotePath, options = {}) {
|
|||
mime: options.mime
|
||||
});
|
||||
|
||||
if (options.saveSelection && utils.isCKEditorInitialized()) {
|
||||
if (options.saveSelection) {
|
||||
// we remove the selection only after it was saved to server to make sure we don't lose anything
|
||||
window.cutToNote.removeSelection();
|
||||
options.textEditor.removeSelection();
|
||||
}
|
||||
|
||||
await ws.waitForMaxKnownEntityChangeId();
|
||||
|
|
|
@ -292,10 +292,6 @@ function copySelectionToClipboard() {
|
|||
}
|
||||
}
|
||||
|
||||
function isCKEditorInitialized() {
|
||||
return !!(window && window.cutToNote);
|
||||
}
|
||||
|
||||
function dynamicRequire(moduleName) {
|
||||
if (typeof __non_webpack_require__ !== 'undefined') {
|
||||
return __non_webpack_require__(moduleName);
|
||||
|
@ -405,7 +401,6 @@ export default {
|
|||
clearBrowserCache,
|
||||
normalizeShortcut,
|
||||
copySelectionToClipboard,
|
||||
isCKEditorInitialized,
|
||||
dynamicRequire,
|
||||
timeLimit,
|
||||
initHelpDropdown,
|
||||
|
|
|
@ -327,7 +327,8 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
|||
// without await as this otherwise causes deadlock through component mutex
|
||||
noteCreateService.createNote(appContext.tabManager.getActiveContextNotePath(), {
|
||||
isProtected: note.isProtected,
|
||||
saveSelection: true
|
||||
saveSelection: true,
|
||||
textEditor: await this.noteContext.getTextEditor()
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -341,4 +342,16 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
|||
this.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
async executeWithTypeWidgetEvent({resolve, ntxId}) {
|
||||
if (!this.isNoteContext(ntxId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.initialized;
|
||||
|
||||
await this.getWidgetType();
|
||||
|
||||
resolve(this.getTypeWidget());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue