rename "widget" type to "content-widget"

This commit is contained in:
zadam 2022-12-06 16:23:30 +01:00
parent d64b575e60
commit 012fb1f50b
6 changed files with 17 additions and 12 deletions

View File

@ -22,7 +22,8 @@ const NOTE_TYPE_ICONS = {
"canvas": "bx bx-pen",
"web-view": "bx bx-globe-alt",
"launcher": "bx bx-link",
"doc": "bx bxs-file-doc"
"doc": "bx bxs-file-doc",
"content-widget": "bx bxs-widget"
};
/**

View File

@ -26,7 +26,7 @@ import NoneTypeWidget from "./type_widgets/none.js";
import NoteMapTypeWidget from "./type_widgets/note_map.js";
import WebViewTypeWidget from "./type_widgets/web_view.js";
import DocTypeWidget from "./type_widgets/doc.js";
import WidgetTypeWidget from "./type_widgets/widget.js";
import ContentWidgetTypeWidget from "./type_widgets/widget.js";
const TPL = `
<div class="note-detail">
@ -61,7 +61,7 @@ const typeWidgetClasses = {
'note-map': NoteMapTypeWidget,
'web-view': WebViewTypeWidget,
'doc': DocTypeWidget,
'widget': WidgetTypeWidget
'content-widget': ContentWidgetTypeWidget
};
export default class NoteDetailWidget extends NoteContextAwareWidget {
@ -130,6 +130,10 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
if (!(this.type in this.typeWidgets)) {
const clazz = typeWidgetClasses[this.type];
if (!clazz) {
throw new Error(`Cannot find type widget for type '${this.type}'`);
}
const typeWidget = this.typeWidgets[this.type] = new clazz();
typeWidget.spacedUpdate = this.spacedUpdate;
typeWidget.setParent(this);

View File

@ -10,7 +10,7 @@ const NOTE_TYPES = [
{ type: "note-map", mime: '', title: "Note Map", selectable: false },
{ type: "launcher", mime: '', title: "Launcher", selectable: false },
{ type: "doc", mime: '', title: "Doc", selectable: false },
{ type: "widget", mime: '', title: "Widget", selectable: false },
{ type: "content-widget", 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 },

View File

@ -2,8 +2,8 @@ import TypeWidget from "./type_widget.js";
const TPL = `<div class="note-detail-widget note-detail-printable"></div>`;
export default class WidgetTypeWidget extends TypeWidget {
static getType() { return "widget"; }
export default class ContentWidgetTypeWidget extends TypeWidget {
static getType() { return "content-widget"; }
doRender() {
this.$widget = $(TPL);
@ -12,12 +12,12 @@ export default class WidgetTypeWidget extends TypeWidget {
}
async doRefresh(note) {
const widgetName = note.getLabelValue('widget');
const contentWidget = note.getLabelValue('contentWidget');
if (widgetName === 'optionsAppearance') {
if (contentWidget === 'optionsAppearance') {
this.$widget.empty().append("HI!");
} else {
this.$widget.empty().append(`Unknown widget of type "${widgetName}"`);
this.$widget.empty().append(`Unknown widget of type "${contentWidget}"`);
}
}
}

View File

@ -13,5 +13,5 @@ module.exports = [
'web-view',
'launcher',
'doc',
'widget'
'content-widget'
];

View File

@ -593,12 +593,12 @@ function createOptionNotes() {
branchId: OPTIONS_APPEARANCE,
noteId: OPTIONS_APPEARANCE,
title: 'Appearance',
type: 'widget',
type: 'content-widget',
content: '',
parentNoteId: OPTIONS_ROOT
}).note;
note.addLabel('widget', 'optionsAppearance');
note.addLabel('contentWidget', 'optionsAppearance');
}
}