mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 09:58:32 +02:00
Merge branch 'master' into next53
This commit is contained in:
commit
4211d0feda
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
@ -2,7 +2,7 @@
|
||||
"name": "trilium",
|
||||
"productName": "Trilium Notes",
|
||||
"description": "Trilium Notes",
|
||||
"version": "0.52.0-beta",
|
||||
"version": "0.52.1-beta",
|
||||
"license": "AGPL-3.0-only",
|
||||
"main": "electron.js",
|
||||
"bin": {
|
||||
|
@ -5,9 +5,9 @@ const AbstractEntity = require("./abstract_entity");
|
||||
const sql = require("../../services/sql");
|
||||
const dateUtils = require("../../services/date_utils");
|
||||
const utils = require("../../services/utils.js");
|
||||
const TaskContext = require("../../services/task_context.js");
|
||||
const cls = require("../../services/cls.js");
|
||||
const log = require("../../services/log.js");
|
||||
const TaskContext = require("../../services/task_context");
|
||||
const cls = require("../../services/cls");
|
||||
const log = require("../../services/log");
|
||||
|
||||
/**
|
||||
* Branch represents a relationship between a child note and its parent note. Trilium allows a note to have multiple
|
||||
@ -137,6 +137,18 @@ class Branch extends AbstractEntity {
|
||||
|
||||
taskContext.increaseProgressCount();
|
||||
|
||||
const note = this.getNote();
|
||||
|
||||
if (!taskContext.noteDeletionHandlerTriggered) {
|
||||
const parentBranches = note.getParentBranches();
|
||||
|
||||
if (parentBranches.length === 1 && parentBranches[0] === this) {
|
||||
// needs to be run before branches and attributes are deleted and thus attached relations disappear
|
||||
const handlers = require("../../services/handlers");
|
||||
handlers.runAttachedRelations(note, 'runOnNoteDeletion', note);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.branchId === 'root'
|
||||
|| this.noteId === 'root'
|
||||
|| this.noteId === cls.getHoistedNoteId()) {
|
||||
@ -146,7 +158,6 @@ class Branch extends AbstractEntity {
|
||||
|
||||
this.markAsDeleted(deleteId);
|
||||
|
||||
const note = this.getNote();
|
||||
const notDeletedBranches = note.getParentBranches();
|
||||
|
||||
if (notDeletedBranches.length === 0) {
|
||||
|
@ -8,9 +8,8 @@ const dateUtils = require('../../services/date_utils');
|
||||
const entityChangesService = require('../../services/entity_changes');
|
||||
const AbstractEntity = require("./abstract_entity");
|
||||
const NoteRevision = require("./note_revision");
|
||||
const TaskContext = require("../../services/task_context.js");
|
||||
const optionService = require("../../services/options.js");
|
||||
const noteRevisionService = require("../../services/note_revisions.js");
|
||||
const TaskContext = require("../../services/task_context");
|
||||
const handlers = require("../../services/handlers");
|
||||
|
||||
const LABEL = 'label';
|
||||
const RELATION = 'relation';
|
||||
@ -1143,6 +1142,10 @@ class Note extends AbstractEntity {
|
||||
taskContext = new TaskContext('no-progress-reporting');
|
||||
}
|
||||
|
||||
// needs to be run before branches and attributes are deleted and thus attached relations disappear
|
||||
handlers.runAttachedRelations(this, 'runOnNoteDeletion', this);
|
||||
taskContext.noteDeletionHandlerTriggered = true;
|
||||
|
||||
for (const branch of this.getParentBranches()) {
|
||||
branch.deleteBranch(deleteId, taskContext);
|
||||
}
|
||||
|
@ -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);
|
||||
@ -47,9 +47,9 @@ async function createNote(parentNotePath, options = {}) {
|
||||
templateNoteId: options.templateNoteId
|
||||
});
|
||||
|
||||
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,
|
||||
|
@ -233,6 +233,9 @@ const ATTR_HELP = {
|
||||
"runOnNoteCreation": "executes when note is created on backend",
|
||||
"runOnNoteTitleChange": "executes when note title is changed (includes note creation as well)",
|
||||
"runOnNoteChange": "executes when note is changed (includes note creation as well)",
|
||||
"runOnNoteDeletion": "executes when note is being deleted",
|
||||
"runOnBranchCreation": "executes when a branch is created. Branch is a link between parent note and child note and is created e.g. when cloning or moving note.",
|
||||
"runOnBranchDeletion": "executes when a branch is deleted. Branch is a link between parent note and child note and is deleted e.g. when moving note (old branch/link is deleted).",
|
||||
"runOnChildNoteCreation": "executes when new note is created under this note",
|
||||
"runOnAttributeCreation": "executes when new attribute is created under this note",
|
||||
"runOnAttributeChange": "executes when attribute is changed under this note",
|
||||
|
@ -330,7 +330,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()
|
||||
});
|
||||
}
|
||||
|
||||
@ -344,4 +345,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());
|
||||
}
|
||||
}
|
||||
|
@ -363,7 +363,9 @@ pre:not(.CodeMirror-line) {
|
||||
|
||||
.go-to-selected-note-button.disabled, .go-to-selected-note-button.disabled:hover {
|
||||
cursor: inherit;
|
||||
color: var(--button-disabled-background-color) !important;
|
||||
color: var(--button-disabled-text-color) !important;
|
||||
background-color: var(--button-disabled-background-color) !important;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.note-autocomplete-input {
|
||||
|
@ -21,10 +21,11 @@
|
||||
--more-accented-background-color: #777;
|
||||
|
||||
--button-background-color: transparent;
|
||||
--button-disabled-background-color: #222;
|
||||
--button-border-color: #ccc;
|
||||
--button-text-color: currentColor;
|
||||
--button-border-radius: 5px;
|
||||
--button-disabled-background-color: transparent;
|
||||
--button-disabled-text-color: #999;
|
||||
|
||||
--primary-button-background-color: #888;
|
||||
--primary-button-text-color: white;
|
||||
|
@ -25,10 +25,11 @@ html {
|
||||
--more-accented-background-color: #ddd;
|
||||
|
||||
--button-background-color: transparent;
|
||||
--button-disabled-background-color: #ddd;
|
||||
--button-border-color: #ddd;
|
||||
--button-text-color: black;
|
||||
--button-border-radius: 5px;
|
||||
--button-disabled-background-color: #ddd;
|
||||
--button-disabled-text-color: black;
|
||||
|
||||
--primary-button-background-color: #6c757d;
|
||||
--primary-button-text-color: white;
|
||||
|
@ -1 +1 @@
|
||||
module.exports = { buildDate:"2022-05-27T22:13:24+02:00", buildRevision: "388dcadef3e23c25ee256c63cd627d18691a687a" };
|
||||
module.exports = { buildDate:"2022-06-05T15:00:25+02:00", buildRevision: "f587e0dfd9177462faef8ad7c39a855c25d03c91" };
|
||||
|
@ -61,6 +61,9 @@ module.exports = [
|
||||
{ type: 'relation', name: 'runOnNoteCreation', isDangerous: true },
|
||||
{ type: 'relation', name: 'runOnNoteTitleChange', isDangerous: true },
|
||||
{ type: 'relation', name: 'runOnNoteChange', isDangerous: true },
|
||||
{ type: 'relation', name: 'runOnNoteDeletion', isDangerous: true },
|
||||
{ type: 'relation', name: 'runOnBranchCreation', isDangerous: true },
|
||||
{ type: 'relation', name: 'runOnBranchDeletion', isDangerous: true },
|
||||
{ type: 'relation', name: 'runOnChildNoteCreation', isDangerous: true },
|
||||
{ type: 'relation', name: 'runOnAttributeCreation', isDangerous: true },
|
||||
{ type: 'relation', name: 'runOnAttributeChange', isDangerous: true },
|
||||
|
@ -49,6 +49,7 @@ eventService.subscribe([ eventService.ENTITY_CHANGED, eventService.ENTITY_DELETE
|
||||
}
|
||||
}
|
||||
else if (entityName === 'notes') {
|
||||
// ENTITY_DELETED won't trigger anything since all branches/attributes are already deleted at this point
|
||||
runAttachedRelations(entity, 'runOnNoteChange', entity);
|
||||
}
|
||||
});
|
||||
@ -94,6 +95,9 @@ eventService.subscribe(eventService.ENTITY_CREATED, ({ entityName, entity }) =>
|
||||
handleSortedAttribute(entity);
|
||||
}
|
||||
}
|
||||
else if (entityName === 'branches') {
|
||||
runAttachedRelations(entity.getNote(), 'runOnBranchCreation', entity);
|
||||
}
|
||||
else if (entityName === 'notes') {
|
||||
runAttachedRelations(entity, 'runOnNoteCreation', entity);
|
||||
}
|
||||
@ -167,4 +171,12 @@ eventService.subscribe(eventService.ENTITY_DELETED, ({ entityName, entity }) =>
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (entityName === 'branches') {
|
||||
runAttachedRelations(entity.getNote(), 'runOnBranchDeletion', entity);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
runAttachedRelations
|
||||
};
|
||||
|
@ -10,6 +10,7 @@ class TaskContext {
|
||||
this.taskId = taskId;
|
||||
this.taskType = taskType;
|
||||
this.data = data;
|
||||
this.noteDeletionHandlerTriggered = false;
|
||||
|
||||
// progressCount is meant to represent just some progress - to indicate the task is not stuck
|
||||
this.progressCount = -1; // we're incrementing immediatelly
|
||||
|
Loading…
x
Reference in New Issue
Block a user