chore(prettier): fix all files

This commit is contained in:
Elian Doran
2025-01-09 18:07:02 +02:00
parent 19ee861699
commit 4cbb529fd4
571 changed files with 23226 additions and 23940 deletions

View File

@@ -4,7 +4,7 @@ import froca from "../../services/froca.js";
import linkService from "../../services/link.js";
import attributeAutocompleteService from "../../services/attribute_autocomplete.js";
import noteAutocompleteService from "../../services/note_autocomplete.js";
import promotedAttributeDefinitionParser from '../../services/promoted_attribute_definition_parser.js';
import promotedAttributeDefinitionParser from "../../services/promoted_attribute_definition_parser.js";
import NoteContextAwareWidget from "../note_context_aware_widget.js";
import SpacedUpdate from "../../services/spaced_update.js";
import utils from "../../services/utils.js";
@@ -72,25 +72,25 @@ const TPL = `
</style>
<div style="display: flex; justify-content: space-between; margin-bottom: 8px;">
<h5 class="attr-detail-title">${t('attribute_detail.attr_detail_title')}</h5>
<h5 class="attr-detail-title">${t("attribute_detail.attr_detail_title")}</h5>
<span class="bx bx-x close-attr-detail-button" title="${t('attribute_detail.close_button_title')}"></span>
<span class="bx bx-x close-attr-detail-button" title="${t("attribute_detail.close_button_title")}"></span>
</div>
<div class="attr-is-owned-by">${t('attribute_detail.attr_is_owned_by')}</div>
<div class="attr-is-owned-by">${t("attribute_detail.attr_is_owned_by")}</div>
<table class="attr-edit-table">
<tr title="${t('attribute_detail.attr_name_title')}">
<th>${t('attribute_detail.name')}</th>
<tr title="${t("attribute_detail.attr_name_title")}">
<th>${t("attribute_detail.name")}</th>
<td><input type="text" class="attr-input-name form-control" /></td>
</tr>
<tr class="attr-help"></tr>
<tr class="attr-row-value">
<th>${t('attribute_detail.value')}</th>
<th>${t("attribute_detail.value")}</th>
<td><input type="text" class="attr-input-value form-control" /></td>
</tr>
<tr class="attr-row-target-note">
<th title="${t('attribute_detail.target_note_title')}">${t('attribute_detail.target_note')}</th>
<th title="${t("attribute_detail.target_note_title")}">${t("attribute_detail.target_note")}</th>
<td>
<div class="input-group">
<input type="text" class="attr-input-target-note form-control" />
@@ -98,12 +98,12 @@ const TPL = `
</td>
</tr>
<tr class="attr-row-promoted"
title="${t('attribute_detail.promoted_title')}">
<th>${t('attribute_detail.promoted')}</th>
title="${t("attribute_detail.promoted_title")}">
<th>${t("attribute_detail.promoted")}</th>
<td><input type="checkbox" class="attr-input-promoted form-check" /></td>
</tr>
<tr class="attr-row-promoted-alias">
<th title="${t('attribute_detail.promoted_alias_title')}">${t('attribute_detail.promoted_alias')}</th>
<th title="${t("attribute_detail.promoted_alias_title")}">${t("attribute_detail.promoted_alias")}</th>
<td>
<div class="input-group">
<input type="text" class="attr-input-promoted-alias form-control" />
@@ -111,47 +111,47 @@ const TPL = `
</td>
</tr>
<tr class="attr-row-multiplicity">
<th title="${t('attribute_detail.multiplicity_title')}">${t('attribute_detail.multiplicity')}</th>
<th title="${t("attribute_detail.multiplicity_title")}">${t("attribute_detail.multiplicity")}</th>
<td>
<select class="attr-input-multiplicity form-control">
<option value="single">${t('attribute_detail.single_value')}</option>
<option value="multi">${t('attribute_detail.multi_value')}</option>
<option value="single">${t("attribute_detail.single_value")}</option>
<option value="multi">${t("attribute_detail.multi_value")}</option>
</select>
</td>
</tr>
<tr class="attr-row-label-type">
<th title="${t('attribute_detail.label_type_title')}">${t('attribute_detail.label_type')}</th>
<th title="${t("attribute_detail.label_type_title")}">${t("attribute_detail.label_type")}</th>
<td>
<select class="attr-input-label-type form-control">
<option value="text">${t('attribute_detail.text')}</option>
<option value="number">${t('attribute_detail.number')}</option>
<option value="boolean">${t('attribute_detail.boolean')}</option>
<option value="date">${t('attribute_detail.date')}</option>
<option value="datetime">${t('attribute_detail.date_time')}</option>
<option value="time">${t('attribute_detail.time')}</option>
<option value="url">${t('attribute_detail.url')}</option>
<option value="text">${t("attribute_detail.text")}</option>
<option value="number">${t("attribute_detail.number")}</option>
<option value="boolean">${t("attribute_detail.boolean")}</option>
<option value="date">${t("attribute_detail.date")}</option>
<option value="datetime">${t("attribute_detail.date_time")}</option>
<option value="time">${t("attribute_detail.time")}</option>
<option value="url">${t("attribute_detail.url")}</option>
</select>
</td>
</tr>
<tr class="attr-row-number-precision">
<th title="${t('attribute_detail.precision_title')}">${t('attribute_detail.precision')}</th>
<th title="${t("attribute_detail.precision_title")}">${t("attribute_detail.precision")}</th>
<td>
<div class="input-group">
<input type="number" class="form-control attr-input-number-precision" style="text-align: right">
<span class="input-group-text">${t('attribute_detail.digits')}</span>
<span class="input-group-text">${t("attribute_detail.digits")}</span>
</div>
</td>
</tr>
<tr class="attr-row-inverse-relation">
<th title="${t('attribute_detail.inverse_relation_title')}">${t('attribute_detail.inverse_relation')}</th>
<th title="${t("attribute_detail.inverse_relation_title")}">${t("attribute_detail.inverse_relation")}</th>
<td>
<div class="input-group">
<input type="text" class="attr-input-inverse-relation form-control" />
</div>
</td>
</tr>
<tr title="${t('attribute_detail.inheritable_title')}">
<th>${t('attribute_detail.inheritable')}</th>
<tr title="${t("attribute_detail.inheritable_title")}">
<th>${t("attribute_detail.inheritable")}</th>
<td><input type="checkbox" class="attr-input-inheritable form-check" /></td>
</tr>
</table>
@@ -159,113 +159,113 @@ const TPL = `
<div class="attr-save-delete-button-container">
<button class="btn btn-primary btn-sm attr-save-changes-and-close-button"
style="flex-grow: 1; margin-right: 20px">
${t('attribute_detail.save_and_close')}</button>
${t("attribute_detail.save_and_close")}</button>
<button class="btn btn-secondary btn-sm attr-delete-button">
${t('attribute_detail.delete')}</button>
${t("attribute_detail.delete")}</button>
</div>
<div class="related-notes-container">
<br/>
<h5 class="related-notes-tile">${t('attribute_detail.related_notes_title')}</h5>
<h5 class="related-notes-tile">${t("attribute_detail.related_notes_title")}</h5>
<ul class="related-notes-list"></ul>
<div class="related-notes-more-notes">${t('attribute_detail.more_notes')}</div>
<div class="related-notes-more-notes">${t("attribute_detail.more_notes")}</div>
</div>
</div>`;
const DISPLAYED_NOTES = 10;
const ATTR_TITLES: Record<string, string> = {
"label": t('attribute_detail.label'),
"label-definition": t('attribute_detail.label_definition'),
"relation": t('attribute_detail.relation'),
"relation-definition": t('attribute_detail.relation_definition')
label: t("attribute_detail.label"),
"label-definition": t("attribute_detail.label_definition"),
relation: t("attribute_detail.relation"),
"relation-definition": t("attribute_detail.relation_definition")
};
const ATTR_HELP: Record<string, Record<string, string>> = {
"label": {
"disableVersioning": t('attribute_detail.disable_versioning'),
"calendarRoot": t('attribute_detail.calendar_root'),
"archived": t('attribute_detail.archived'),
"excludeFromExport": t('attribute_detail.exclude_from_export'),
"run": t('attribute_detail.run'),
"runOnInstance": t('attribute_detail.run_on_instance'),
"runAtHour": t('attribute_detail.run_at_hour'),
"disableInclusion": t('attribute_detail.disable_inclusion'),
"sorted": t('attribute_detail.sorted'),
"sortDirection": t('attribute_detail.sort_direction'),
"sortFoldersFirst": t('attribute_detail.sort_folders_first'),
"top": t('attribute_detail.top'),
"hidePromotedAttributes": t('attribute_detail.hide_promoted_attributes'),
"readOnly": t('attribute_detail.read_only'),
"autoReadOnlyDisabled": t('attribute_detail.auto_read_only_disabled'),
"appCss": t('attribute_detail.app_css'),
"appTheme": t('attribute_detail.app_theme'),
"appThemeBase": t('attribute_detail.app_theme_base'),
"cssClass": t('attribute_detail.css_class'),
"iconClass": t('attribute_detail.icon_class'),
"pageSize": t('attribute_detail.page_size'),
"customRequestHandler": t('attribute_detail.custom_request_handler'),
"customResourceProvider": t('attribute_detail.custom_resource_provider'),
"widget": t('attribute_detail.widget'),
"workspace": t('attribute_detail.workspace'),
"workspaceIconClass": t('attribute_detail.workspace_icon_class'),
"workspaceTabBackgroundColor": t('attribute_detail.workspace_tab_background_color'),
"workspaceCalendarRoot": t('attribute_detail.workspace_calendar_root'),
"workspaceTemplate": t('attribute_detail.workspace_template'),
"searchHome": t('attribute_detail.search_home'),
"workspaceSearchHome": t('attribute_detail.workspace_search_home'),
"inbox": t('attribute_detail.inbox'),
"workspaceInbox": t('attribute_detail.workspace_inbox'),
"sqlConsoleHome": t('attribute_detail.sql_console_home'),
"bookmarkFolder": t('attribute_detail.bookmark_folder'),
"shareHiddenFromTree": t('attribute_detail.share_hidden_from_tree'),
"shareExternalLink": t('attribute_detail.share_external_link'),
"shareAlias": t('attribute_detail.share_alias'),
"shareOmitDefaultCss": t('attribute_detail.share_omit_default_css'),
"shareRoot": t('attribute_detail.share_root'),
"shareDescription": t('attribute_detail.share_description'),
"shareRaw": t('attribute_detail.share_raw'),
"shareDisallowRobotIndexing": t('attribute_detail.share_disallow_robot_indexing'),
"shareCredentials": t('attribute_detail.share_credentials'),
"shareIndex": t('attribute_detail.share_index'),
"displayRelations": t('attribute_detail.display_relations'),
"hideRelations": t('attribute_detail.hide_relations'),
"titleTemplate": t('attribute_detail.title_template'),
"template": t('attribute_detail.template'),
"toc": t('attribute_detail.toc'),
"color": t('attribute_detail.color'),
"keyboardShortcut": t('attribute_detail.keyboard_shortcut'),
"keepCurrentHoisting": t('attribute_detail.keep_current_hoisting'),
"executeButton": t('attribute_detail.execute_button'),
"executeDescription": t('attribute_detail.execute_description'),
"excludeFromNoteMap": t('attribute_detail.exclude_from_note_map'),
"newNotesOnTop": t('attribute_detail.new_notes_on_top'),
"hideHighlightWidget": t('attribute_detail.hide_highlight_widget')
label: {
disableVersioning: t("attribute_detail.disable_versioning"),
calendarRoot: t("attribute_detail.calendar_root"),
archived: t("attribute_detail.archived"),
excludeFromExport: t("attribute_detail.exclude_from_export"),
run: t("attribute_detail.run"),
runOnInstance: t("attribute_detail.run_on_instance"),
runAtHour: t("attribute_detail.run_at_hour"),
disableInclusion: t("attribute_detail.disable_inclusion"),
sorted: t("attribute_detail.sorted"),
sortDirection: t("attribute_detail.sort_direction"),
sortFoldersFirst: t("attribute_detail.sort_folders_first"),
top: t("attribute_detail.top"),
hidePromotedAttributes: t("attribute_detail.hide_promoted_attributes"),
readOnly: t("attribute_detail.read_only"),
autoReadOnlyDisabled: t("attribute_detail.auto_read_only_disabled"),
appCss: t("attribute_detail.app_css"),
appTheme: t("attribute_detail.app_theme"),
appThemeBase: t("attribute_detail.app_theme_base"),
cssClass: t("attribute_detail.css_class"),
iconClass: t("attribute_detail.icon_class"),
pageSize: t("attribute_detail.page_size"),
customRequestHandler: t("attribute_detail.custom_request_handler"),
customResourceProvider: t("attribute_detail.custom_resource_provider"),
widget: t("attribute_detail.widget"),
workspace: t("attribute_detail.workspace"),
workspaceIconClass: t("attribute_detail.workspace_icon_class"),
workspaceTabBackgroundColor: t("attribute_detail.workspace_tab_background_color"),
workspaceCalendarRoot: t("attribute_detail.workspace_calendar_root"),
workspaceTemplate: t("attribute_detail.workspace_template"),
searchHome: t("attribute_detail.search_home"),
workspaceSearchHome: t("attribute_detail.workspace_search_home"),
inbox: t("attribute_detail.inbox"),
workspaceInbox: t("attribute_detail.workspace_inbox"),
sqlConsoleHome: t("attribute_detail.sql_console_home"),
bookmarkFolder: t("attribute_detail.bookmark_folder"),
shareHiddenFromTree: t("attribute_detail.share_hidden_from_tree"),
shareExternalLink: t("attribute_detail.share_external_link"),
shareAlias: t("attribute_detail.share_alias"),
shareOmitDefaultCss: t("attribute_detail.share_omit_default_css"),
shareRoot: t("attribute_detail.share_root"),
shareDescription: t("attribute_detail.share_description"),
shareRaw: t("attribute_detail.share_raw"),
shareDisallowRobotIndexing: t("attribute_detail.share_disallow_robot_indexing"),
shareCredentials: t("attribute_detail.share_credentials"),
shareIndex: t("attribute_detail.share_index"),
displayRelations: t("attribute_detail.display_relations"),
hideRelations: t("attribute_detail.hide_relations"),
titleTemplate: t("attribute_detail.title_template"),
template: t("attribute_detail.template"),
toc: t("attribute_detail.toc"),
color: t("attribute_detail.color"),
keyboardShortcut: t("attribute_detail.keyboard_shortcut"),
keepCurrentHoisting: t("attribute_detail.keep_current_hoisting"),
executeButton: t("attribute_detail.execute_button"),
executeDescription: t("attribute_detail.execute_description"),
excludeFromNoteMap: t("attribute_detail.exclude_from_note_map"),
newNotesOnTop: t("attribute_detail.new_notes_on_top"),
hideHighlightWidget: t("attribute_detail.hide_highlight_widget")
},
"relation": {
"runOnNoteCreation": t('attribute_detail.run_on_note_creation'),
"runOnChildNoteCreation": t('attribute_detail.run_on_child_note_creation'),
"runOnNoteTitleChange": t('attribute_detail.run_on_note_title_change'),
"runOnNoteContentChange": t('attribute_detail.run_on_note_content_change'),
"runOnNoteChange": t('attribute_detail.run_on_note_change'),
"runOnNoteDeletion": t('attribute_detail.run_on_note_deletion'),
"runOnBranchCreation": t('attribute_detail.run_on_branch_creation'),
"runOnBranchChange": t('attribute_detail.run_on_branch_change'),
"runOnBranchDeletion": t('attribute_detail.run_on_branch_deletion'),
"runOnAttributeCreation": t('attribute_detail.run_on_attribute_creation'),
"runOnAttributeChange": t('attribute_detail.run_on_attribute_change'),
"template": t('attribute_detail.relation_template'),
"inherit": t('attribute_detail.inherit'),
"renderNote": t('attribute_detail.render_note'),
"widget": t('attribute_detail.widget_relation'),
"shareCss": t('attribute_detail.share_css'),
"shareJs": t('attribute_detail.share_js'),
"shareTemplate": t('attribute_detail.share_template'),
"shareFavicon": t('attribute_detail.share_favicon')
relation: {
runOnNoteCreation: t("attribute_detail.run_on_note_creation"),
runOnChildNoteCreation: t("attribute_detail.run_on_child_note_creation"),
runOnNoteTitleChange: t("attribute_detail.run_on_note_title_change"),
runOnNoteContentChange: t("attribute_detail.run_on_note_content_change"),
runOnNoteChange: t("attribute_detail.run_on_note_change"),
runOnNoteDeletion: t("attribute_detail.run_on_note_deletion"),
runOnBranchCreation: t("attribute_detail.run_on_branch_creation"),
runOnBranchChange: t("attribute_detail.run_on_branch_change"),
runOnBranchDeletion: t("attribute_detail.run_on_branch_deletion"),
runOnAttributeCreation: t("attribute_detail.run_on_attribute_creation"),
runOnAttributeChange: t("attribute_detail.run_on_attribute_change"),
template: t("attribute_detail.relation_template"),
inherit: t("attribute_detail.inherit"),
renderNote: t("attribute_detail.render_note"),
widget: t("attribute_detail.widget_relation"),
shareCss: t("attribute_detail.share_css"),
shareJs: t("attribute_detail.share_js"),
shareTemplate: t("attribute_detail.share_template"),
shareFavicon: t("attribute_detail.share_favicon")
}
};
@@ -288,7 +288,6 @@ interface SearchRelatedResponse {
}
export default class AttributeDetailWidget extends NoteContextAwareWidget {
private $title!: JQuery<HTMLElement>;
private $inputName!: JQuery<HTMLElement>;
private $inputValue!: JQuery<HTMLElement>;
@@ -335,39 +334,40 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
this.$widget = $(TPL);
shortcutService.bindElShortcut(this.$widget, 'ctrl+return', () => this.saveAndClose());
shortcutService.bindElShortcut(this.$widget, 'esc', () => this.cancelAndClose());
shortcutService.bindElShortcut(this.$widget, "ctrl+return", () => this.saveAndClose());
shortcutService.bindElShortcut(this.$widget, "esc", () => this.cancelAndClose());
this.$title = this.$widget.find(".attr-detail-title");
this.$title = this.$widget.find('.attr-detail-title');
this.$inputName = this.$widget.find('.attr-input-name');
this.$inputName.on('input', ev => {
if (!(ev.originalEvent as KeyboardEvent)?.isComposing) { // https://github.com/zadam/trilium/pull/3812
this.$inputName = this.$widget.find(".attr-input-name");
this.$inputName.on("input", (ev) => {
if (!(ev.originalEvent as KeyboardEvent)?.isComposing) {
// https://github.com/zadam/trilium/pull/3812
this.userEditedAttribute();
}
});
this.$inputName.on('change', () => this.userEditedAttribute());
this.$inputName.on('autocomplete:closed', () => this.userEditedAttribute());
this.$inputName.on("change", () => this.userEditedAttribute());
this.$inputName.on("autocomplete:closed", () => this.userEditedAttribute());
this.$inputName.on('focus', () => {
this.$inputName.on("focus", () => {
attributeAutocompleteService.initAttributeNameAutocomplete({
$el: this.$inputName,
attributeType: () => ['relation', 'relation-definition'].includes(this.attrType || "") ? 'relation' : 'label',
attributeType: () => (["relation", "relation-definition"].includes(this.attrType || "") ? "relation" : "label"),
open: true
});
});
this.$rowValue = this.$widget.find('.attr-row-value');
this.$inputValue = this.$widget.find('.attr-input-value');
this.$inputValue.on('input', ev => {
if (!(ev.originalEvent as KeyboardEvent)?.isComposing) { // https://github.com/zadam/trilium/pull/3812
this.$rowValue = this.$widget.find(".attr-row-value");
this.$inputValue = this.$widget.find(".attr-input-value");
this.$inputValue.on("input", (ev) => {
if (!(ev.originalEvent as KeyboardEvent)?.isComposing) {
// https://github.com/zadam/trilium/pull/3812
this.userEditedAttribute();
}
});
this.$inputValue.on('change', () => this.userEditedAttribute());
this.$inputValue.on('autocomplete:closed', () => this.userEditedAttribute());
this.$inputValue.on('focus', () => {
this.$inputValue.on("change", () => this.userEditedAttribute());
this.$inputValue.on("autocomplete:closed", () => this.userEditedAttribute());
this.$inputValue.on("focus", () => {
attributeAutocompleteService.initLabelValueAutocomplete({
$el: this.$inputValue,
open: true,
@@ -375,86 +375,84 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
});
});
this.$rowPromoted = this.$widget.find('.attr-row-promoted');
this.$inputPromoted = this.$widget.find('.attr-input-promoted');
this.$inputPromoted.on('change', () => this.userEditedAttribute());
this.$rowPromoted = this.$widget.find(".attr-row-promoted");
this.$inputPromoted = this.$widget.find(".attr-input-promoted");
this.$inputPromoted.on("change", () => this.userEditedAttribute());
this.$rowPromotedAlias = this.$widget.find('.attr-row-promoted-alias');
this.$inputPromotedAlias = this.$widget.find('.attr-input-promoted-alias');
this.$inputPromotedAlias.on('change', () => this.userEditedAttribute());
this.$rowPromotedAlias = this.$widget.find(".attr-row-promoted-alias");
this.$inputPromotedAlias = this.$widget.find(".attr-input-promoted-alias");
this.$inputPromotedAlias.on("change", () => this.userEditedAttribute());
this.$rowMultiplicity = this.$widget.find('.attr-row-multiplicity');
this.$inputMultiplicity = this.$widget.find('.attr-input-multiplicity');
this.$inputMultiplicity.on('change', () => this.userEditedAttribute());
this.$rowMultiplicity = this.$widget.find(".attr-row-multiplicity");
this.$inputMultiplicity = this.$widget.find(".attr-input-multiplicity");
this.$inputMultiplicity.on("change", () => this.userEditedAttribute());
this.$rowLabelType = this.$widget.find('.attr-row-label-type');
this.$inputLabelType = this.$widget.find('.attr-input-label-type');
this.$inputLabelType.on('change', () => this.userEditedAttribute());
this.$rowLabelType = this.$widget.find(".attr-row-label-type");
this.$inputLabelType = this.$widget.find(".attr-input-label-type");
this.$inputLabelType.on("change", () => this.userEditedAttribute());
this.$rowNumberPrecision = this.$widget.find('.attr-row-number-precision');
this.$inputNumberPrecision = this.$widget.find('.attr-input-number-precision');
this.$inputNumberPrecision.on('change', () => this.userEditedAttribute());
this.$rowNumberPrecision = this.$widget.find(".attr-row-number-precision");
this.$inputNumberPrecision = this.$widget.find(".attr-input-number-precision");
this.$inputNumberPrecision.on("change", () => this.userEditedAttribute());
this.$rowInverseRelation = this.$widget.find('.attr-row-inverse-relation');
this.$inputInverseRelation = this.$widget.find('.attr-input-inverse-relation');
this.$inputInverseRelation.on('input', ev => {
if (!(ev.originalEvent as KeyboardEvent)?.isComposing) { // https://github.com/zadam/trilium/pull/3812
this.$rowInverseRelation = this.$widget.find(".attr-row-inverse-relation");
this.$inputInverseRelation = this.$widget.find(".attr-input-inverse-relation");
this.$inputInverseRelation.on("input", (ev) => {
if (!(ev.originalEvent as KeyboardEvent)?.isComposing) {
// https://github.com/zadam/trilium/pull/3812
this.userEditedAttribute();
}
});
this.$rowTargetNote = this.$widget.find('.attr-row-target-note');
this.$inputTargetNote = this.$widget.find('.attr-input-target-note');
this.$rowTargetNote = this.$widget.find(".attr-row-target-note");
this.$inputTargetNote = this.$widget.find(".attr-input-target-note");
noteAutocompleteService.initNoteAutocomplete(this.$inputTargetNote, { allowCreatingNotes: true })
.on('autocomplete:noteselected', (event, suggestion, dataset) => {
if (!suggestion.notePath) {
return false;
}
noteAutocompleteService.initNoteAutocomplete(this.$inputTargetNote, { allowCreatingNotes: true }).on("autocomplete:noteselected", (event, suggestion, dataset) => {
if (!suggestion.notePath) {
return false;
}
const pathChunks = suggestion.notePath.split('/');
const pathChunks = suggestion.notePath.split("/");
this.attribute.value = pathChunks[pathChunks.length - 1]; // noteId
this.attribute.value = pathChunks[pathChunks.length - 1]; // noteId
this.triggerCommand('updateAttributeList', { attributes: this.allAttributes });
this.updateRelatedNotes();
this.triggerCommand("updateAttributeList", { attributes: this.allAttributes });
this.updateRelatedNotes();
});
this.$inputInheritable = this.$widget.find(".attr-input-inheritable");
this.$inputInheritable.on("change", () => this.userEditedAttribute());
this.$closeAttrDetailButton = this.$widget.find(".close-attr-detail-button");
this.$closeAttrDetailButton.on("click", () => this.cancelAndClose());
this.$attrIsOwnedBy = this.$widget.find(".attr-is-owned-by");
this.$attrSaveDeleteButtonContainer = this.$widget.find(".attr-save-delete-button-container");
this.$saveAndCloseButton = this.$widget.find(".attr-save-changes-and-close-button");
this.$saveAndCloseButton.on("click", () => this.saveAndClose());
this.$deleteButton = this.$widget.find(".attr-delete-button");
this.$deleteButton.on("click", async () => {
await this.triggerCommand("updateAttributeList", {
attributes: this.allAttributes.filter((attr) => attr !== this.attribute)
});
this.$inputInheritable = this.$widget.find('.attr-input-inheritable');
this.$inputInheritable.on('change', () => this.userEditedAttribute());
this.$closeAttrDetailButton = this.$widget.find('.close-attr-detail-button');
this.$closeAttrDetailButton.on('click', () => this.cancelAndClose());
this.$attrIsOwnedBy = this.$widget.find('.attr-is-owned-by');
this.$attrSaveDeleteButtonContainer = this.$widget.find('.attr-save-delete-button-container');
this.$saveAndCloseButton = this.$widget.find('.attr-save-changes-and-close-button');
this.$saveAndCloseButton.on('click', () => this.saveAndClose());
this.$deleteButton = this.$widget.find('.attr-delete-button');
this.$deleteButton.on('click', async () => {
await this.triggerCommand('updateAttributeList', {
attributes: this.allAttributes.filter(attr => attr !== this.attribute)
});
await this.triggerCommand('saveAttributes');
await this.triggerCommand("saveAttributes");
this.hide();
});
this.$attrHelp = this.$widget.find('.attr-help');
this.$attrHelp = this.$widget.find(".attr-help");
this.$relatedNotesContainer = this.$widget.find('.related-notes-container');
this.$relatedNotesTitle = this.$relatedNotesContainer.find('.related-notes-tile');
this.$relatedNotesList = this.$relatedNotesContainer.find('.related-notes-list');
this.$relatedNotesMoreNotes = this.$relatedNotesContainer.find('.related-notes-more-notes');
this.$relatedNotesContainer = this.$widget.find(".related-notes-container");
this.$relatedNotesTitle = this.$relatedNotesContainer.find(".related-notes-tile");
this.$relatedNotesList = this.$relatedNotesContainer.find(".related-notes-list");
this.$relatedNotesMoreNotes = this.$relatedNotesContainer.find(".related-notes-more-notes");
$(window).on('mousedown', e => {
if (!$(e.target).closest(this.$widget[0]).length
&& !$(e.target).closest(".algolia-autocomplete").length
&& !$(e.target).closest("#context-menu-container").length) {
$(window).on("mousedown", (e) => {
if (!$(e.target).closest(this.$widget[0]).length && !$(e.target).closest(".algolia-autocomplete").length && !$(e.target).closest("#context-menu-container").length) {
this.hide();
}
});
@@ -471,13 +469,9 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
this.attrType = this.getAttrType(attribute);
const attrName =
this.attrType === 'label-definition' ? attribute.name.substr(6)
: (this.attrType === 'relation-definition' ? attribute.name.substr(9) : attribute.name);
const attrName = this.attrType === "label-definition" ? attribute.name.substr(6) : this.attrType === "relation-definition" ? attribute.name.substr(9) : attribute.name;
const definition = this.attrType?.endsWith('-definition')
? promotedAttributeDefinitionParser.parse(attribute.value || "")
: {};
const definition = this.attrType?.endsWith("-definition") ? promotedAttributeDefinitionParser.parse(attribute.value || "") : {};
if (this.attrType) {
this.$title.text(ATTR_TITLES[this.attrType]);
@@ -497,75 +491,51 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
this.$attrIsOwnedBy
.show()
.empty()
.append(attribute.type === 'label' ? 'Label' : 'Relation')
.append(attribute.type === "label" ? "Label" : "Relation")
.append(` ${t("attribute_detail.is_owned_by_note")} `)
.append(await linkService.createLink(attribute.noteId))
.append(await linkService.createLink(attribute.noteId));
}
const disabledFn = (() => !isOwned ? "true" : undefined);
const disabledFn = () => (!isOwned ? "true" : undefined);
this.$inputName
.val(attrName)
.attr('readonly', disabledFn);
this.$inputName.val(attrName).attr("readonly", disabledFn);
this.$rowValue.toggle(this.attrType === 'label');
this.$rowTargetNote.toggle(this.attrType === 'relation');
this.$rowValue.toggle(this.attrType === "label");
this.$rowTargetNote.toggle(this.attrType === "relation");
this.$rowPromoted.toggle(['label-definition', 'relation-definition'].includes(this.attrType || ""));
this.$inputPromoted
.prop("checked", !!definition.isPromoted)
.attr('disabled', disabledFn);
this.$rowPromoted.toggle(["label-definition", "relation-definition"].includes(this.attrType || ""));
this.$inputPromoted.prop("checked", !!definition.isPromoted).attr("disabled", disabledFn);
this.$rowPromotedAlias.toggle(!!definition.isPromoted);
this.$inputPromotedAlias
.val(definition.promotedAlias || "")
.attr('disabled', disabledFn);
this.$inputPromotedAlias.val(definition.promotedAlias || "").attr("disabled", disabledFn);
this.$rowMultiplicity.toggle(['label-definition', 'relation-definition'].includes(this.attrType || ""));
this.$inputMultiplicity
.val(definition.multiplicity || "")
.attr('disabled', disabledFn);
this.$rowMultiplicity.toggle(["label-definition", "relation-definition"].includes(this.attrType || ""));
this.$inputMultiplicity.val(definition.multiplicity || "").attr("disabled", disabledFn);
this.$rowLabelType.toggle(this.attrType === 'label-definition');
this.$inputLabelType
.val(definition.labelType || "")
.attr('disabled', disabledFn);
this.$rowLabelType.toggle(this.attrType === "label-definition");
this.$inputLabelType.val(definition.labelType || "").attr("disabled", disabledFn);
this.$rowNumberPrecision.toggle(this.attrType === 'label-definition' && definition.labelType === 'number');
this.$inputNumberPrecision
.val(definition.numberPrecision || "")
.attr('disabled', disabledFn);
this.$rowNumberPrecision.toggle(this.attrType === "label-definition" && definition.labelType === "number");
this.$inputNumberPrecision.val(definition.numberPrecision || "").attr("disabled", disabledFn);
this.$rowInverseRelation.toggle(this.attrType === 'relation-definition');
this.$inputInverseRelation
.val(definition.inverseRelation || "")
.attr('disabled', disabledFn);
this.$rowInverseRelation.toggle(this.attrType === "relation-definition");
this.$inputInverseRelation.val(definition.inverseRelation || "").attr("disabled", disabledFn);
if (attribute.type === 'label') {
this.$inputValue
.val(attribute.value || "")
.attr('readonly', disabledFn);
}
else if (attribute.type === 'relation') {
this.$inputTargetNote
.attr('readonly', disabledFn)
.val("")
.setSelectedNotePath("");
if (attribute.type === "label") {
this.$inputValue.val(attribute.value || "").attr("readonly", disabledFn);
} else if (attribute.type === "relation") {
this.$inputTargetNote.attr("readonly", disabledFn).val("").setSelectedNotePath("");
if (attribute.value) {
const targetNote = await froca.getNote(attribute.value);
if (targetNote) {
this.$inputTargetNote
.val(targetNote ? targetNote.title : "")
.setSelectedNotePath(attribute.value);
this.$inputTargetNote.val(targetNote ? targetNote.title : "").setSelectedNotePath(attribute.value);
}
}
}
this.$inputInheritable
.prop("checked", !!attribute.isInheritable)
.attr('disabled', disabledFn);
this.$inputInheritable.prop("checked", !!attribute.isInheritable).attr("disabled", disabledFn);
this.updateHelp();
@@ -581,16 +551,11 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
.css("left", detPosition.left)
.css("right", detPosition.right)
.css("top", y - offset.top + 70)
.css("max-height",
outerHeight + y > height - 50
? height - y - 50
: 10000);
.css("max-height", outerHeight + y > height - 50 ? height - y - 50 : 10000);
}
if (focus === 'name') {
this.$inputName
.trigger('focus')
.trigger('select');
if (focus === "name") {
this.$inputName.trigger("focus").trigger("select");
}
}
@@ -618,7 +583,7 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
}
async saveAndClose() {
await this.triggerCommand('saveAttributes');
await this.triggerCommand("saveAttributes");
this.hide();
@@ -626,7 +591,7 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
}
async cancelAndClose() {
await this.triggerCommand('reloadAttributes');
await this.triggerCommand("reloadAttributes");
this.hide();
@@ -642,24 +607,18 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
updateHelp() {
const attrName = String(this.$inputName.val());
if (this.attrType && this.attrType in ATTR_HELP &&
attrName && attrName in ATTR_HELP[this.attrType]) {
if (this.attrType && this.attrType in ATTR_HELP && attrName && attrName in ATTR_HELP[this.attrType]) {
this.$attrHelp
.empty()
.append($("<td colspan=2>")
.append($("<strong>").text(attrName))
.append(" - ")
.append(ATTR_HELP[this.attrType][attrName])
)
.append($("<td colspan=2>").append($("<strong>").text(attrName)).append(" - ").append(ATTR_HELP[this.attrType][attrName]))
.show();
}
else {
} else {
this.$attrHelp.empty().hide();
}
}
async updateRelatedNotes() {
let { results, count } = await server.post<SearchRelatedResponse>('search-related', this.attribute);
let { results, count } = await server.post<SearchRelatedResponse>("search-related", this.attribute);
for (const res of results) {
res.noteId = res.notePathArray[res.notePathArray.length - 1];
@@ -676,16 +635,14 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
this.$relatedNotesList.empty();
const displayedResults = results.length <= DISPLAYED_NOTES ? results : results.slice(0, DISPLAYED_NOTES);
const displayedNotes = await froca.getNotes(displayedResults.map(res => res.noteId));
const displayedNotes = await froca.getNotes(displayedResults.map((res) => res.noteId));
const hoistedNoteId = appContext.tabManager.getActiveContext()?.hoistedNoteId;
for (const note of displayedNotes) {
const notePath = note.getBestNotePathString(hoistedNoteId);
const $noteLink = await linkService.createLink(notePath, { showNotePath: true });
this.$relatedNotesList.append(
$("<li>").append($noteLink)
);
this.$relatedNotesList.append($("<li>").append($noteLink));
}
if (results.length > DISPLAYED_NOTES) {
@@ -697,20 +654,18 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
}
getAttrType(attribute: Attribute) {
if (attribute.type === 'label') {
if (attribute.name.startsWith('label:')) {
if (attribute.type === "label") {
if (attribute.name.startsWith("label:")) {
return "label-definition";
} else if (attribute.name.startsWith('relation:')) {
} else if (attribute.name.startsWith("relation:")) {
return "relation-definition";
} else {
return "label";
}
}
else if (attribute.type === 'relation') {
} else if (attribute.type === "relation") {
return "relation";
}
else {
this.$title.text('');
} else {
this.$title.text("");
}
}
@@ -724,26 +679,24 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
this.$inputName.val(attrName);
}
if (this.attrType === 'label-definition') {
if (this.attrType === "label-definition") {
attrName = `label:${attrName}`;
} else if (this.attrType === 'relation-definition') {
} else if (this.attrType === "relation-definition") {
attrName = `relation:${attrName}`;
}
this.attribute.name = attrName;
this.attribute.isInheritable = this.$inputInheritable.is(":checked");
if (this.attrType?.endsWith('-definition')) {
if (this.attrType?.endsWith("-definition")) {
this.attribute.value = this.buildDefinitionValue();
}
else if (this.attrType === 'relation') {
} else if (this.attrType === "relation") {
this.attribute.value = this.$inputTargetNote.getSelectedNoteId() || "";
}
else {
} else {
this.attribute.value = String(this.$inputValue.val());
}
this.triggerCommand('updateAttributeList', { attributes: this.allAttributes });
this.triggerCommand("updateAttributeList", { attributes: this.allAttributes });
}
buildDefinitionValue() {
@@ -752,28 +705,26 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
if (this.$inputPromoted.is(":checked")) {
props.push("promoted");
if (this.$inputPromotedAlias.val() !== '') {
if (this.$inputPromotedAlias.val() !== "") {
props.push(`alias=${this.$inputPromotedAlias.val()}`);
}
}
props.push(this.$inputMultiplicity.val());
if (this.attrType === 'label-definition') {
if (this.attrType === "label-definition") {
props.push(this.$inputLabelType.val());
if (this.$inputLabelType.val() === 'number' && this.$inputNumberPrecision.val() !== '') {
if (this.$inputLabelType.val() === "number" && this.$inputNumberPrecision.val() !== "") {
props.push(`precision=${this.$inputNumberPrecision.val()}`);
}
} else if (this.attrType === 'relation-definition' && String(this.$inputInverseRelation.val())?.trim().length > 0) {
} else if (this.attrType === "relation-definition" && String(this.$inputInverseRelation.val())?.trim().length > 0) {
const inverseRelationName = this.$inputInverseRelation.val();
props.push(`inverse=${utils.filterAttributeName(String(inverseRelationName))}`);
}
this.$rowNumberPrecision.toggle(
this.attrType === 'label-definition'
&& this.$inputLabelType.val() === 'number');
this.$rowNumberPrecision.toggle(this.attrType === "label-definition" && this.$inputLabelType.val() === "number");
this.$rowPromotedAlias.toggle(this.$inputPromoted.is(":checked"));
@@ -787,7 +738,7 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
createLink(noteId: string) {
return $("<a>", {
href: `#root/${noteId}`,
class: 'reference-link'
class: "reference-link"
});
}

View File

@@ -86,10 +86,10 @@ const TPL = `
const mentionSetup: MentionConfig = {
feeds: [
{
marker: '@',
feed: queryText => noteAutocompleteService.autocompleteSourceForCKEditor(queryText),
itemRenderer: item => {
const itemElement = document.createElement('button');
marker: "@",
feed: (queryText) => noteAutocompleteService.autocompleteSourceForCKEditor(queryText),
itemRenderer: (item) => {
const itemElement = document.createElement("button");
itemElement.innerHTML = `${item.highlightedNotePathTitle} `;
@@ -98,29 +98,29 @@ const mentionSetup: MentionConfig = {
minimumCharacters: 0
},
{
marker: '#',
feed: async queryText => {
marker: "#",
feed: async (queryText) => {
const names = await server.get<string[]>(`attribute-names/?type=label&query=${encodeURIComponent(queryText)}`);
return names.map(name => {
return names.map((name) => {
return {
id: `#${name}`,
name: name
}
};
});
},
minimumCharacters: 0
},
{
marker: '~',
feed: async queryText => {
marker: "~",
feed: async (queryText) => {
const names = await server.get<string[]>(`attribute-names/?type=relation&query=${encodeURIComponent(queryText)}`);
return names.map(name => {
return names.map((name) => {
return {
id: `~${name}`,
name: name
}
};
});
},
minimumCharacters: 0
@@ -130,53 +130,53 @@ const mentionSetup: MentionConfig = {
const editorConfig = {
removePlugins: [
'Heading',
'Link',
'Autoformat',
'Bold',
'Italic',
'Underline',
'Strikethrough',
'Code',
'Superscript',
'Subscript',
'BlockQuote',
'Image',
'ImageCaption',
'ImageStyle',
'ImageToolbar',
'ImageUpload',
'ImageResize',
'List',
'TodoList',
'PasteFromOffice',
'Table',
'TableToolbar',
'TableProperties',
'TableCellProperties',
'Indent',
'IndentBlock',
'BlockToolbar',
'ParagraphButtonUI',
'HeadingButtonsUI',
'UploadimagePlugin',
'InternalLinkPlugin',
'MarkdownImportPlugin',
'CuttonotePlugin',
'TextTransformation',
'Font',
'FontColor',
'FontBackgroundColor',
'CodeBlock',
'SelectAll',
'IncludeNote',
'CutToNote',
'Mathematics',
'AutoformatMath',
'indentBlockShortcutPlugin',
'removeFormatLinksPlugin',
'Footnotes',
'Mermaid'
"Heading",
"Link",
"Autoformat",
"Bold",
"Italic",
"Underline",
"Strikethrough",
"Code",
"Superscript",
"Subscript",
"BlockQuote",
"Image",
"ImageCaption",
"ImageStyle",
"ImageToolbar",
"ImageUpload",
"ImageResize",
"List",
"TodoList",
"PasteFromOffice",
"Table",
"TableToolbar",
"TableProperties",
"TableCellProperties",
"Indent",
"IndentBlock",
"BlockToolbar",
"ParagraphButtonUI",
"HeadingButtonsUI",
"UploadimagePlugin",
"InternalLinkPlugin",
"MarkdownImportPlugin",
"CuttonotePlugin",
"TextTransformation",
"Font",
"FontColor",
"FontBackgroundColor",
"CodeBlock",
"SelectAll",
"IncludeNote",
"CutToNote",
"Mathematics",
"AutoformatMath",
"indentBlockShortcutPlugin",
"removeFormatLinksPlugin",
"Footnotes",
"Mermaid"
],
toolbar: {
items: []
@@ -187,11 +187,7 @@ const editorConfig = {
type AttributeCommandNames = FilteredCommandNames<CommandData>;
export default class AttributeEditorWidget extends NoteContextAwareWidget implements
EventListener<"entitiesReloaded">,
EventListener<"addNewLabel">,
EventListener<"addNewRelation"> {
export default class AttributeEditorWidget extends NoteContextAwareWidget implements EventListener<"entitiesReloaded">, EventListener<"addNewLabel">, EventListener<"addNewRelation"> {
private attributeDetailWidget: AttributeDetailWidget;
private $editor!: JQuery<HTMLElement>;
private $addNewAttributeButton!: JQuery<HTMLElement>;
@@ -210,11 +206,11 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
doRender() {
this.$widget = $(TPL);
this.$editor = this.$widget.find('.attribute-list-editor');
this.$editor = this.$widget.find(".attribute-list-editor");
this.initialized = this.initEditor();
this.$editor.on('keydown', async e => {
this.$editor.on("keydown", async (e) => {
if (e.which === 13) {
// allow autocomplete to fill the result textarea
setTimeout(() => this.save(), 100);
@@ -223,48 +219,48 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
this.attributeDetailWidget.hide();
});
this.$editor.on('blur', () => setTimeout(() => this.save(), 100)); // Timeout to fix https://github.com/zadam/trilium/issues/4160
this.$editor.on("blur", () => setTimeout(() => this.save(), 100)); // Timeout to fix https://github.com/zadam/trilium/issues/4160
this.$addNewAttributeButton = this.$widget.find('.add-new-attribute-button');
this.$addNewAttributeButton.on('click', e => this.addNewAttribute(e));
this.$addNewAttributeButton = this.$widget.find(".add-new-attribute-button");
this.$addNewAttributeButton.on("click", (e) => this.addNewAttribute(e));
this.$saveAttributesButton = this.$widget.find('.save-attributes-button');
this.$saveAttributesButton.on('click', () => this.save());
this.$saveAttributesButton = this.$widget.find(".save-attributes-button");
this.$saveAttributesButton.on("click", () => this.save());
this.$errors = this.$widget.find('.attribute-errors');
this.$errors = this.$widget.find(".attribute-errors");
}
addNewAttribute(e: JQuery.ClickEvent) {
contextMenuService.show<AttributeCommandNames>({
x: e.pageX,
y: e.pageY,
orientation: 'left',
orientation: "left",
items: [
{ title: t("attribute_editor.add_new_label"), command: "addNewLabel", uiIcon: "bx bx-hash" },
{ title: t("attribute_editor.add_new_relation"), command: "addNewRelation", uiIcon: "bx bx-transfer" },
{ title: "----" },
{ title: t("attribute_editor.add_new_label_definition"), command: "addNewLabelDefinition", uiIcon: "bx bx-empty" },
{ title: t("attribute_editor.add_new_relation_definition"), command: "addNewRelationDefinition", uiIcon: "bx bx-empty" },
{ title: t("attribute_editor.add_new_relation_definition"), command: "addNewRelationDefinition", uiIcon: "bx bx-empty" }
],
selectMenuItemHandler: ({ command }) => this.handleAddNewAttributeCommand(command)
});
}
// triggered from keyboard shortcut
async addNewLabelEvent({ntxId}: EventData<"addNewLabel">) {
async addNewLabelEvent({ ntxId }: EventData<"addNewLabel">) {
if (this.isNoteContext(ntxId)) {
await this.refresh();
this.handleAddNewAttributeCommand('addNewLabel');
this.handleAddNewAttributeCommand("addNewLabel");
}
}
// triggered from keyboard shortcut
async addNewRelationEvent({ntxId}: EventData<"addNewRelation">) {
async addNewRelationEvent({ ntxId }: EventData<"addNewRelation">) {
if (this.isNoteContext(ntxId)) {
await this.refresh();
this.handleAddNewAttributeCommand('addNewRelation');
this.handleAddNewAttributeCommand("addNewRelation");
}
}
@@ -280,22 +276,22 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
let name;
let value;
if (command === 'addNewLabel') {
type = 'label';
name = 'myLabel';
value = '';
} else if (command === 'addNewRelation') {
type = 'relation';
name = 'myRelation';
value = '';
} else if (command === 'addNewLabelDefinition') {
type = 'label';
name = 'label:myLabel';
value = 'promoted,single,text';
} else if (command === 'addNewRelationDefinition') {
type = 'label';
name = 'relation:myRelation';
value = 'promoted,single';
if (command === "addNewLabel") {
type = "label";
name = "myLabel";
value = "";
} else if (command === "addNewRelation") {
type = "relation";
name = "myRelation";
value = "";
} else if (command === "addNewLabelDefinition") {
type = "label";
name = "label:myLabel";
value = "promoted,single,text";
} else if (command === "addNewRelationDefinition") {
type = "label";
name = "relation:myRelation";
value = "promoted,single";
} else {
return;
}
@@ -323,7 +319,7 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
isOwned: true,
x: (rect.left + rect.right) / 2,
y: rect.bottom,
focus: 'name'
focus: "name"
});
}, 100);
}
@@ -343,10 +339,10 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
this.$saveAttributesButton.fadeOut();
// blink the attribute text to give a visual hint that save has been executed
this.$editor.css('opacity', 0);
this.$editor.css("opacity", 0);
// revert back
setTimeout(() => this.$editor.css('opacity', 1), 100);
setTimeout(() => this.$editor.css("opacity", 1), 100);
}
}
@@ -359,7 +355,8 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
}
getPreprocessedData() {
const str = this.textEditor.getData()
const str = this.textEditor
.getData()
.replace(/<a[^>]+href="(#[A-Za-z0-9_/]*)"[^>]*>[^<]*<\/a>/g, "$1")
.replace(/&nbsp;/g, " "); // otherwise .text() below outputs non-breaking space in unicode
@@ -371,18 +368,22 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
this.$widget.show();
this.$editor.on("click", e => this.handleEditorClick(e));
this.$editor.on("click", (e) => this.handleEditorClick(e));
this.textEditor = await CKEditor.BalloonEditor.create(this.$editor[0], editorConfig);
this.textEditor.model.document.on('change:data', () => this.dataChanged());
this.textEditor.editing.view.document.on('enter', (event, data) => {
// disable entering new line - see https://github.com/ckeditor/ckeditor5/issues/9422
data.preventDefault();
event.stop();
}, {priority: 'high'});
this.textEditor.model.document.on("change:data", () => this.dataChanged());
this.textEditor.editing.view.document.on(
"enter",
(event, data) => {
// disable entering new line - see https://github.com/ckeditor/ckeditor5/issues/9422
data.preventDefault();
event.stop();
},
{ priority: "high" }
);
// disable spellcheck for attribute editor
this.textEditor.editing.view.change(writer => writer.setAttribute('spellcheck', 'false', this.textEditor.editing.view.document.getRoot()));
this.textEditor.editing.view.change((writer) => writer.setAttribute("spellcheck", "false", this.textEditor.editing.view.document.getRoot()));
}
dataChanged() {
@@ -390,8 +391,7 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
if (this.lastSavedContent === this.textEditor.getData()) {
this.$saveAttributesButton.fadeOut();
}
else {
} else {
this.$saveAttributesButton.fadeIn();
}
@@ -412,8 +412,7 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
try {
parsedAttrs = attributeParser.lexAndParse(this.getPreprocessedData(), true);
}
catch (e) {
} catch (e) {
// the input is incorrect because the user messed up with it and now needs to fix it manually
return null;
}
@@ -421,8 +420,7 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
let matchedAttr = null;
for (const attr of parsedAttrs) {
if (attr.startIndex && clickIndex > attr.startIndex &&
attr.endIndex && clickIndex <= attr.endIndex) {
if (attr.startIndex && clickIndex > attr.startIndex && attr.endIndex && clickIndex <= attr.endIndex) {
matchedAttr = attr;
break;
}
@@ -430,7 +428,7 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
setTimeout(() => {
if (matchedAttr) {
this.$editor.tooltip('hide');
this.$editor.tooltip("hide");
this.attributeDetailWidget.showAttributeDetail({
allAttributes: parsedAttrs,
@@ -439,13 +437,11 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
x: e.pageX,
y: e.pageY
});
}
else {
} else {
this.showHelpTooltip();
}
}, 100);
}
else {
} else {
this.showHelpTooltip();
}
}
@@ -454,14 +450,14 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
this.attributeDetailWidget.hide();
this.$editor.tooltip({
trigger: 'focus',
trigger: "focus",
html: true,
title: HELP_TEXT,
placement: 'bottom',
placement: "bottom",
offset: "0,30"
});
this.$editor.tooltip('show');
this.$editor.tooltip("show");
}
getClickIndex(pos: TextPosition) {
@@ -472,8 +468,8 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
while (curNode.previousSibling) {
curNode = curNode.previousSibling;
if (curNode.name === 'reference') {
clickIndex += curNode._attrs.get('notePath').length + 1;
if (curNode.name === "reference") {
clickIndex += curNode._attrs.get("notePath").length + 1;
} else {
clickIndex += curNode.data.length;
}
@@ -483,9 +479,9 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
}
async loadReferenceLinkTitle($el: JQuery<HTMLElement>, href: string) {
const {noteId} = linkService.parseNavigationStateFromUrl(href);
const { noteId } = linkService.parseNavigationStateFromUrl(href);
const note = noteId ? await froca.getNote(noteId, true) : null;
const title = note ? note.title : '[missing]';
const title = note ? note.title : "[missing]";
$el.text(title);
}
@@ -530,19 +526,18 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
}
focus() {
this.$editor.trigger('focus');
this.$editor.trigger("focus");
this.textEditor.model.change( writer => {
const positionAt = writer.createPositionAt(this.textEditor.model.document.getRoot(), 'end');
this.textEditor.model.change((writer) => {
const positionAt = writer.createPositionAt(this.textEditor.model.document.getRoot(), "end");
writer.setSelection(positionAt);
} );
});
}
entitiesReloadedEvent({loadResults}: EventData<"entitiesReloaded">) {
if (loadResults.getAttributeRows(this.componentId).find(attr => attributeService.isAffecting(attr, this.note))) {
entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
if (loadResults.getAttributeRows(this.componentId).find((attr) => attributeService.isAffecting(attr, this.note))) {
this.refresh();
}
}
}