rename note types to camelCase

This commit is contained in:
zadam 2022-12-06 23:01:42 +01:00
parent f336435adb
commit b9632a7814
32 changed files with 95 additions and 77 deletions

View File

@ -0,0 +1,3 @@
UPDATE notes SET type = 'relationMap' WHERE type = 'relation-map';
UPDATE notes SET type = 'noteMap' WHERE type = 'note-map';
UPDATE notes SET type = 'webView' WHERE type = 'web-view';

View File

@ -0,0 +1,15 @@
UPDATE notes SET noteId = 'globalNoteMap' WHERE noteId = 'globalnotemap';
UPDATE notes SET noteId = 'bulkAction' WHERE noteId = 'bulkaction';
UPDATE notes SET noteId = 'sqlConsole' WHERE noteId = 'sqlconsole';
UPDATE branches SET branchId = 'globalNoteMap' WHERE branchId = 'globalnotemap';
UPDATE branches SET branchId = 'bulkAction' WHERE branchId = 'bulkaction';
UPDATE branches SET branchId = 'sqlConsole' WHERE branchId = 'sqlconsole';
UPDATE branches SET parentNoteId = 'globalNoteMap' WHERE parentNoteId = 'globalnotemap';
UPDATE branches SET parentNoteId = 'bulkAction' WHERE parentNoteId = 'bulkaction';
UPDATE branches SET parentNoteId = 'sqlConsole' WHERE parentNoteId = 'sqlconsole';
UPDATE attributes SET noteId = 'globalNoteMap' WHERE noteId = 'globalnotemap';
UPDATE attributes SET noteId = 'bulkAction' WHERE noteId = 'bulkaction';
UPDATE attributes SET noteId = 'sqlConsole' WHERE noteId = 'sqlconsole';

View File

@ -709,7 +709,7 @@ components:
- image
- search
- book
- relation-map
- relationMap
- render
mime:
type: string
@ -747,7 +747,7 @@ components:
type: string
type:
type: string
enum: [text, code, render, file, image, search, relation-map, book, note-map, mermaid, web-view, shortcut]
enum: [text, code, render, file, image, search, relationMap, book, noteMap, mermaid, webView, shortcut]
mime:
type: string
isProtected:

View File

@ -15,15 +15,15 @@ const NOTE_TYPE_ICONS = {
"code": "bx bx-code",
"render": "bx bx-extension",
"search": "bx bx-file-find",
"relation-map": "bx bx-map-alt",
"relationMap": "bx bx-map-alt",
"book": "bx bx-book",
"note-map": "bx bx-map-alt",
"noteMap": "bx bx-map-alt",
"mermaid": "bx bx-selection",
"canvas": "bx bx-pen",
"web-view": "bx bx-globe-alt",
"webView": "bx bx-globe-alt",
"launcher": "bx bx-link",
"doc": "bx bxs-file-doc",
"content-widget": "bx bxs-widget"
"contentWidget": "bx bxs-widget"
};
/**

View File

@ -148,7 +148,7 @@ async function getRenderedContent(note, options = {}) {
else if (type === 'book') {
// nothing, book doesn't have its own content
}
else if (!options.tooltip && type === 'protected-session') {
else if (!options.tooltip && type === 'protectedSession') {
const $button = $(`<button class="btn btn-sm"><span class="bx bx-log-in"></span> Enter protected session</button>`)
.on('click', protectedSessionService.enterProtectedSession);
@ -219,7 +219,7 @@ function getRenderingType(note) {
protectedSessionHolder.touchProtectedSession();
}
else {
type = 'protected-session';
type = 'protectedSession';
}
}

View File

@ -92,7 +92,7 @@ const TPL = `
border: 1px solid var(--main-border-color);
}
.note-book-content.type-image, .note-book-content.type-file, .note-book-content.type-protected-session {
.note-book-content.type-image, .note-book-content.type-file, .note-book-content.type-protectedSession {
display: flex;
align-items: center;
justify-content: center;

View File

@ -6,13 +6,13 @@ async function getNoteTypeItems(command) {
{ title: "Text", command: command, type: "text", uiIcon: "bx bx-note" },
{ title: "Code", command: command, type: "code", uiIcon: "bx bx-code" },
{ title: "Saved Search", command: command, type: "search", uiIcon: "bx bx-file-find" },
{ title: "Relation Map", command: command, type: "relation-map", uiIcon: "bx bx-map-alt" },
{ title: "Note Map", command: command, type: "note-map", uiIcon: "bx bx-map-alt" },
{ title: "Relation Map", command: command, type: "relationMap", uiIcon: "bx bx-map-alt" },
{ title: "Note Map", command: command, type: "noteMap", uiIcon: "bx bx-map-alt" },
{ title: "Render Note", command: command, type: "render", uiIcon: "bx bx-extension" },
{ title: "Book", command: command, type: "book", uiIcon: "bx bx-book" },
{ title: "Mermaid Diagram", command: command, type: "mermaid", uiIcon: "bx bx-selection" },
{ title: "Canvas", command: command, type: "canvas", uiIcon: "bx bx-pen" },
{ title: "Web View", command: command, type: "web-view", uiIcon: "bx bx-globe-alt" },
{ title: "Web View", command: command, type: "webView", uiIcon: "bx bx-globe-alt" },
];
const templateNoteIds = await server.get("search-templates");

View File

@ -81,7 +81,7 @@ export default class NoteActionsWidget extends NoteContextAwareWidget {
refreshWithNote(note) {
this.toggleDisabled(this.$findInTextButton, ['text', 'code', 'book', 'search'].includes(note.type));
this.toggleDisabled(this.$showSourceButton, ['text', 'relation-map', 'search', 'code'].includes(note.type));
this.toggleDisabled(this.$showSourceButton, ['text', 'relationMap', 'search', 'code'].includes(note.type));
this.toggleDisabled(this.$printActiveNoteButton, ['text', 'code'].includes(note.type));

View File

@ -83,7 +83,7 @@ export default class BulkActionsDialog extends BasicWidget {
this.$widget.on('click', '[data-action-add]', async event => {
const actionName = $(event.target).attr('data-action-add');
await bulkActionService.addAction('bulkaction', actionName);
await bulkActionService.addAction('bulkAction', actionName);
await this.refresh();
});
@ -111,7 +111,7 @@ export default class BulkActionsDialog extends BasicWidget {
this.$affectedNoteCount.text(affectedNoteCount);
const bulkActionNote = await froca.getNote('bulkaction');
const bulkActionNote = await froca.getNote('bulkAction');
const actions = bulkActionService.parseActions(bulkActionNote);
@ -150,7 +150,7 @@ export default class BulkActionsDialog extends BasicWidget {
if (loadResults.getAttributes().find(attr =>
attr.type === 'label'
&& attr.name === 'action'
&& attr.noteId === 'bulkaction'
&& attr.noteId === 'bulkAction'
&& attr.isDeleted)) {
// this may be triggered from e.g. sync without open widget, then no need to refresh the widget

View File

@ -23,7 +23,7 @@ const TPL = `
export default class RelationMapButtons extends NoteContextAwareWidget {
isEnabled() {
return super.isEnabled() && this.note?.type === 'relation-map';
return super.isEnabled() && this.note?.type === 'relationMap';
}
doRender() {

View File

@ -46,22 +46,22 @@ const TPL = `
const typeWidgetClasses = {
'empty': EmptyTypeWidget,
'deleted': DeletedTypeWidget,
'editable-text': EditableTextTypeWidget,
'read-only-text': ReadOnlyTextTypeWidget,
'editable-code': EditableCodeTypeWidget,
'read-only-code': ReadOnlyCodeTypeWidget,
'editableText': EditableTextTypeWidget,
'readOnlyText': ReadOnlyTextTypeWidget,
'editableCode': EditableCodeTypeWidget,
'readOnlyCode': ReadOnlyCodeTypeWidget,
'file': FileTypeWidget,
'image': ImageTypeWidget,
'search': NoneTypeWidget,
'render': RenderTypeWidget,
'relation-map': RelationMapTypeWidget,
'relationMap': RelationMapTypeWidget,
'canvas': CanvasTypeWidget,
'protected-session': ProtectedSessionTypeWidget,
'protectedSession': ProtectedSessionTypeWidget,
'book': BookTypeWidget,
'note-map': NoteMapTypeWidget,
'web-view': WebViewTypeWidget,
'webView': WebViewTypeWidget,
'doc': DocTypeWidget,
'content-widget': ContentWidgetTypeWidget
'contentWidget': ContentWidgetTypeWidget
};
export default class NoteDetailWidget extends NoteContextAwareWidget {
@ -164,7 +164,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
// https://github.com/zadam/trilium/issues/2522
this.$widget.toggleClass("full-height",
!this.noteContext.hasNoteList()
&& ['editable-text', 'editable-code', 'canvas', 'web-view', 'note-map'].includes(this.type)
&& ['editableText', 'editableCode', 'canvas', 'webView', 'noteMap'].includes(this.type)
&& this.mime !== 'text/x-sqlite;schema=trilium');
}
@ -188,19 +188,19 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
let type = note.type;
if (type === 'text' && await this.noteContext.isReadOnly()) {
type = 'read-only-text';
type = 'readOnlyText';
}
if ((type === 'code' || type === 'mermaid') && await this.noteContext.isReadOnly()) {
type = 'read-only-code';
type = 'readOnlyCode';
}
if (type === 'text') {
type = 'editable-text';
type = 'editableText';
}
if (type === 'code' || type === 'mermaid') {
type = 'editable-code';
type = 'editableCode';
}
if (type === 'launcher') {
@ -208,7 +208,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
}
if (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) {
type = 'protected-session';
type = 'protectedSession';
}
return type;

View File

@ -7,18 +7,18 @@ const NOTE_TYPES = [
{ type: "file", title: "File", selectable: false },
{ type: "image", title: "Image", selectable: false },
{ type: "search", title: "Saved Search", selectable: false },
{ type: "note-map", mime: '', title: "Note Map", selectable: false },
{ type: "noteMap", mime: '', title: "Note Map", selectable: false },
{ type: "launcher", mime: '', title: "Launcher", selectable: false },
{ type: "doc", mime: '', title: "Doc", selectable: false },
{ type: "content-widget", mime: '', title: "Widget", selectable: false },
{ type: "contentWidget", mime: '', title: "Widget", selectable: false },
{ type: "text", mime: "text/html", title: "Text", selectable: true },
{ type: "relation-map", mime: "application/json", title: "Relation Map", selectable: true },
{ type: "relationMap", mime: "application/json", title: "Relation Map", selectable: true },
{ type: "render", mime: '', title: "Render Note", selectable: true },
{ type: "canvas", mime: 'application/json', title: "Canvas", selectable: true },
{ type: "mermaid", mime: 'text/mermaid', title: "Mermaid Diagram", selectable: true },
{ type: "book", mime: '', title: "Book", selectable: true },
{ type: "web-view", mime: '', title: "Web View", selectable: true },
{ type: "webView", mime: '', title: "Web View", selectable: true },
{ type: "code", mime: 'text/plain', title: "Code", selectable: true }
];

View File

@ -43,7 +43,7 @@ export default class NoteWrapperWidget extends FlexContainer {
}
this.$widget.toggleClass("full-content-width",
['image', 'mermaid', 'book', 'render', 'canvas', 'web-view'].includes(note.type)
['image', 'mermaid', 'book', 'render', 'canvas', 'webView'].includes(note.type)
|| !!note?.hasLabel('fullContentWidth')
);

View File

@ -26,7 +26,7 @@ const CONTENT_WIDGETS = {
};
export default class ContentWidgetTypeWidget extends TypeWidget {
static getType() { return "content-widget"; }
static getType() { return "contentWidget"; }
doRender() {
this.$widget = $(TPL);

View File

@ -21,7 +21,7 @@ const TPL = `
</div>`;
export default class EditableCodeTypeWidget extends TypeWidget {
static getType() { return "editable-code"; }
static getType() { return "editableCode"; }
doRender() {
this.$widget = $(TPL);

View File

@ -83,7 +83,7 @@ const TPL = `
`;
export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
static getType() { return "editable-text"; }
static getType() { return "editableText"; }
doRender() {
this.$widget = $(TPL);

View File

@ -4,7 +4,7 @@ import NoteMapWidget from "../note_map.js";
const TPL = `<div class="note-detail-note-map note-detail-printable"></div>`;
export default class NoteMapTypeWidget extends TypeWidget {
static getType() { return "note-map"; }
static getType() { return "noteMap"; }
constructor() {
super();

View File

@ -21,7 +21,7 @@ const TPL = `
</div>`;
export default class ProtectedSessionTypeWidget extends TypeWidget {
static getType() { return "protected-session"; }
static getType() { return "protectedSession"; }
doRender() {
this.$widget = $(TPL);

View File

@ -17,7 +17,7 @@ const TPL = `
</div>`;
export default class ReadOnlyCodeTypeWidget extends TypeWidget {
static getType() { return "read-only-code"; }
static getType() { return "readOnlyCode"; }
doRender() {
this.$widget = $(TPL);

View File

@ -67,7 +67,7 @@ const TPL = `
`;
export default class ReadOnlyTextTypeWidget extends AbstractTextTypeWidget {
static getType() { return "read-only-text"; }
static getType() { return "readOnlyText"; }
doRender() {
this.$widget = $(TPL);

View File

@ -74,7 +74,7 @@ const TPL = `
let containerCounter = 1;
export default class RelationMapTypeWidget extends TypeWidget {
static getType() { return "relation-map"; }
static getType() { return "relationMap"; }
doRender() {
this.$widget = $(TPL);

View File

@ -19,7 +19,7 @@ const TPL = `
</div>`;
export default class WebViewTypeWidget extends TypeWidget {
static getType() { return "web-view"; }
static getType() { return "webView"; }
doRender() {
this.$widget = $(TPL);

View File

@ -1,4 +1,4 @@
.type-relation-map .note-detail {
.type-relationMap .note-detail {
height: 100%;
}

View File

@ -6,7 +6,7 @@ function execute(req) {
const affectedNoteIds = getAffectedNoteIds(noteIds, includeDescendants);
const bulkActionNote = becca.getNote('bulkaction');
const bulkActionNote = becca.getNote('bulkAction');
bulkActionService.executeActions(bulkActionNote, affectedNoteIds);
}

View File

@ -4,8 +4,8 @@ const build = require('./build');
const packageJson = require('../../package');
const {TRILIUM_DATA_DIR} = require('./data_dir');
const APP_DB_VERSION = 204;
const SYNC_VERSION = 27;
const APP_DB_VERSION = 206;
const SYNC_VERSION = 28;
const CLIPPER_PROTOCOL_VERSION = "1.0";
module.exports = {

View File

@ -212,7 +212,7 @@ function BackendScriptApi(currentNote, apiParams) {
* @property {string} parentNoteId - MANDATORY
* @property {string} title - MANDATORY
* @property {string|buffer} content - MANDATORY
* @property {string} type - text, code, file, image, search, book, relation-map, canvas - MANDATORY
* @property {string} type - text, code, file, image, search, book, relationMap, canvas - MANDATORY
* @property {string} mime - value is derived from default mimes for type
* @property {boolean} isProtected - default is false
* @property {boolean} isExpanded - default is false

View File

@ -41,7 +41,7 @@ function exportSingleNote(taskContext, branch, format, res) {
extension = mimeTypes.extension(note.mime) || 'code';
mime = note.mime;
}
else if (note.type === 'relation-map' || note.type === 'canvas' || note.type === 'search') {
else if (note.type === 'relationMap' || note.type === 'canvas' || note.type === 'search') {
payload = content;
extension = 'json';
mime = 'application/json';

View File

@ -344,7 +344,7 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
}
}
if (type === 'relation-map' && noteMeta) {
if (type === 'relationMap' && noteMeta) {
const relationMapLinks = (noteMeta.attributes || [])
.filter(attr => attr.type === 'relation' && attr.name === 'relationMapLink');

View File

@ -5,13 +5,13 @@ module.exports = [
'file',
'image',
'search',
'relation-map',
'relationMap',
'book',
'note-map',
'noteMap',
'mermaid',
'canvas',
'web-view',
'webView',
'launcher',
'doc',
'content-widget'
'contentWidget'
];

View File

@ -50,9 +50,9 @@ function deriveMime(type, mime) {
mime = 'text/html';
} else if (type === 'code' || type === 'mermaid') {
mime = 'text/plain';
} else if (['relation-map', 'search', 'canvas'].includes(type)) {
} else if (['relationMap', 'search', 'canvas'].includes(type)) {
mime = 'application/json';
} else if (['render', 'book', 'web-view'].includes(type)) {
} else if (['render', 'book', 'webView'].includes(type)) {
mime = '';
} else {
mime = 'application/octet-stream';
@ -130,7 +130,7 @@ function getAndValidateParent(params) {
* - {string} parentNoteId
* - {string} title
* - {*} content
* - {string} type - text, code, file, image, search, book, relation-map, canvas, render
* - {string} type - text, code, file, image, search, book, relationMap, canvas, render
*
* Following are optional (have defaults)
* - {string} mime - value is derived from default mimes for type
@ -495,7 +495,7 @@ function downloadImages(noteId, content) {
}
function saveLinks(note, content) {
if (note.type !== 'text' && note.type !== 'relation-map') {
if (note.type !== 'text' && note.type !== 'relationMap') {
return content;
}
@ -512,7 +512,7 @@ function saveLinks(note, content) {
content = findInternalLinks(content, foundLinks);
content = findIncludeNoteLinks(content, foundLinks);
}
else if (note.type === 'relation-map') {
else if (note.type === 'relationMap') {
findRelationMapLinks(content, foundLinks);
}
else {
@ -683,7 +683,7 @@ function getUndeletedParentBranchIds(noteId, deleteId) {
}
function scanForLinks(note) {
if (!note || !['text', 'relation-map'].includes(note.type)) {
if (!note || !['text', 'relationMap'].includes(note.type)) {
return;
}
@ -873,7 +873,7 @@ function duplicateSubtreeInner(origNote, origBranch, newParentNoteId, noteIdMapp
let content = origNote.getContent();
if (['text', 'relation-map', 'search'].includes(origNote.type)) {
if (['text', 'relationMap', 'search'].includes(origNote.type)) {
// fix links in the content
content = replaceByMap(content, noteIdMapping);
}

View File

@ -89,14 +89,14 @@ function getSearchRoot() {
}
function getGlobalNoteMap() {
let globalNoteMap = becca.getNote('globalnotemap');
let globalNoteMap = becca.getNote('globalNoteMap');
if (!globalNoteMap) {
globalNoteMap = noteService.createNewNote({
branchId: 'globalnotemap',
noteId: 'globalnotemap',
branchId: 'globalNoteMap',
noteId: 'globalNoteMap',
title: 'Global Note Map',
type: 'note-map',
type: 'noteMap',
content: '',
parentNoteId: getHiddenRoot().noteId
}).note;
@ -108,12 +108,12 @@ function getGlobalNoteMap() {
}
function getSqlConsoleRoot() {
let sqlConsoleRoot = becca.getNote('sqlconsole');
let sqlConsoleRoot = becca.getNote('sqlConsole');
if (!sqlConsoleRoot) {
sqlConsoleRoot = noteService.createNewNote({
branchId: 'sqlconsole',
noteId: 'sqlconsole',
branchId: 'sqlConsole',
noteId: 'sqlConsole',
title: 'SQL Console',
type: 'doc',
content: '',
@ -236,12 +236,12 @@ function getShareRoot() {
}
function getBulkActionNote() {
let bulkActionNote = becca.getNote('bulkaction');
let bulkActionNote = becca.getNote('bulkAction');
if (!bulkActionNote) {
bulkActionNote = noteService.createNewNote({
branchId: 'bulkaction',
noteId: 'bulkaction',
branchId: 'bulkAction',
noteId: 'bulkAction',
title: 'Bulk action',
type: 'text',
content: '',
@ -331,7 +331,7 @@ const launchers = [
{ id: 'lb_newnote', command: 'createNoteIntoInbox', title: 'New note', icon: 'bx bx-file-blank', isVisible: true },
{ id: 'lb_search', command: 'searchNotes', title: 'Search notes', icon: 'bx bx-search', isVisible: true },
{ id: 'lb_jumpto', command: 'jumpToNote', title: 'Jump to note', icon: 'bx bx-send', isVisible: true },
{ id: 'lb_notemap', targetNoteId: 'globalnotemap', title: 'Note map', icon: 'bx bx-map-alt', isVisible: true },
{ id: 'lb_notemap', targetNoteId: 'globalNotemap', title: 'Note map', icon: 'bx bx-map-alt', isVisible: true },
{ id: 'lb_calendar', builtinWidget: 'calendar', title: 'Calendar', icon: 'bx bx-calendar', isVisible: true },
{ id: 'lb_spacer1', builtinWidget: 'spacer', title: 'Spacer', isVisible: true, baseSize: "50", growthFactor: "0" },
{ id: 'lb_bookmarks', builtinWidget: 'bookmarks', title: 'Bookmarks', icon: 'bx bx-bookmark', isVisible: true },
@ -604,7 +604,7 @@ function createOptionNotes() {
branchId: OPTIONS_APPEARANCE,
noteId: OPTIONS_APPEARANCE,
title: 'Appearance',
type: 'content-widget',
type: 'contentWidget',
content: '',
parentNoteId: OPTIONS_ROOT
}).note;

View File

@ -168,7 +168,7 @@ const STRING_MIME_TYPES = [
function isStringNote(type, mime) {
// render and book are string note in the sense that they are expected to contain empty string
return ["text", "code", "relation-map", "search", "render", "book", "mermaid", "canvas"].includes(type)
return ["text", "code", "relationMap", "search", "render", "book", "mermaid", "canvas"].includes(type)
|| mime.startsWith('text/')
|| STRING_MIME_TYPES.includes(mime);
}
@ -192,7 +192,7 @@ function formatDownloadTitle(filename, type, mime) {
if (type === 'text') {
return filename + '.html';
} else if (['relation-map', 'canvas', 'search'].includes(type)) {
} else if (['relationMap', 'canvas', 'search'].includes(type)) {
return filename + '.json';
} else {
if (!mime) {