Releases: chrisgurney/obsidian-note-toolbar
v1.17.3
Don't miss all the new features in 1.17.0.
API Beta
Fixes
- Set keyboard focus in
modal()
content area. Thanks @FelipeRearden
Full Changelog: 1.17.2...1.17.3
v1.17.2
Don't miss all the new features in 1.17.0.
Improvements π
- Allow DV + JS scripts to execute even if a file/note is not currently open.
API Beta
Improvements π
- Add focus effect for links in
modal()
when tabbing between them.
Fixes
Set keyboard focus inFixed inmodal()
content area. Thanks @FelipeRearden1.17.3
Full Changelog: 1.17.1...1.17.2
v1.17.1
Don't miss all the new features in 1.17.0.
API Beta: New Feature π
Modal component
Adds ntb.modal()
which displays a modal with the provided string content, or file contents. Thanks @FelipeRearden for the suggestion!
// shows a modal with the provided string
await ntb.modal("_Hello_ world!");
// shows a modal with the content of a file
const filename = "Welcome.md";
const file = app.vault.getAbstractFileByPath(filename);
if (file) {
await ntb.modal(file, {
title: `**${file.basename}**`
});
}
else {
new Notice(`File not found: ${filename}`);
}
See the documentation and examples folder (NtbModal.js
), or learn more about the Note Toolbar API.
Full Changelog: 1.17.0...1.17.1
v1.17.0
What's new in Note Toolbar v1.17?
New Features π
Bottom toolbar position
By popular demand, there is now a Bottom toolbar position, which floats the toolbar at the bottom of your note.
Change to this position using right-click β Set position β Bottom, or via the toolbar's settings.
Styling notes:
- If the
border
style is enabled, the border surrounds the toolbar. - Adjust distance from the bottom, left/right padding, and border radius using Style Settings.
Limitations / Known issues:
- Toolbars with breaks have a gap on the right side (equivalent to the size of the wrapped items).
- Bottom toolbars + Floating buttons: On mobile, the built-in toolbar disappearing makes it hard to use certain toolbar items (e.g., select text β bold).
- As a bit of a workaround, consider adding the new
Note Toolbar: Open Quick Tools (for current toolbar)
to the editor toolbar: Settings β Toolbar β scroll to the bottom of Manage toolbar options β Add global command
- As a bit of a workaround, consider adding the new
π¬ Let me know how well it works for you in the discussion thread, or use the Google feedback form β.
Quickly access styles from the toolbar's context menu
Get to the Style section of settings for the active toolbar by right-clicking on it (or long-press on mobile) and select Style...
New command: Access Quick Tools for the current toolbar
Use the new Note Toolbar: Open Quick Tools (for current toolbar)
command to open a Quick Tools window that shows the items in the toolbar associated with the current note.
π‘ Tip: On mobile, consider adding this command to the editor toolbar: Settings β Toolbar β scroll to the bottom of Manage toolbar options β Add global command
Improvements π
- New plugin setting: Show toolbar for the linked note in the File menu, under Note Toolbar Settings β Other, which is defaulted to off. Allows you to selectively enable this feature, which was introduced in
1.13
. Thanks @Moyf and @FelipeRearden - Floating buttons: Support for the
autohide
andborder
styles.- The border color defaults to the button's icon color, but can be overridden with Style Settings.
- Additional Style Settings:
- Override the
autohide
style opacity for toolbars and buttons separately. - Inactive opacity settings for mobile and desktop are now separate.
- Override the
Fixes
- Toolbars in split views are now updated on leaf change, if its config was updated.
Changes
- Updated Ukranian tranlations thanks to @laktiv
API Beta: Updates
Thanks @FelipeRearden for feedback and testing!
New Features π
- Added
ntb.modal()
. See1.17.1
Improvements π
- Prompt: All options are now passed via an optional
options
object parameter, with defaults for each:let result = await ntb.prompt(options?: { default?: string, // Optional default value for text field; if not provided, no default value is set label?: string, // Optional text shown above the text field, rendered as markdown; default none large?: boolean, // Set true if text box should be larger; if not provided, defaults to false placeholder?: string, // Optional text inside text field; defaults to preset message });
- Suggester: Made function easier to use with optional
keys
(if not provided, returned value is the selected option), also via an optionaloptions
parameter:let result = await ntb.suggester( values: string[] | ((value: T) => string), // Array of strings representing the text that will be displayed for each item in the suggester prompt. This can also be a function that maps an item to its text representation. Rendered as markdown. keys?: T[], // Optional array containing the keys of each item in the correct order. If not provided, values are returned on selection. options?: { placeholder?: string, // shown in the input field; defaults to message limit?: number // Optional limit of the number of items rendered at once (useful to improve performance when displaying large lists). Defaults to no limit. });
- Suggester values and Prompt label (
options.label
) are now rendered as markdown, so they can include markdown and things like Iconize icons. - Prompt: Reduced size of modal when using the simple prompt, including on mobile.
- Prompt: When using the
large
option, a modifier key (e.g.,cmd
) andenter
now submits.
Changes
- The API class name has been shortened from
NoteToolbar
tontb
. - CSS: Updated all class names from
note-toolbar-comp-*
tonote-toolbar-ui-*
; add-ui
class for Suggester. Thanks @FelipeRearden - Examples of the above in the repo have been updated:
- For Dataview:
NtbPrompt.js
andNtbSuggester.js
- For JS Engine:
NtbPrompt.js
andNtbSuggester.js
- For Dataview:
See the updated documentation in the User Guide to learn more.
v1.17-beta-18
Fixes
- On mobile, in What's New, a single code line was not wrapping, pushing out the overall width.
Beta API Improvements π
- The API class name has now been shortened from
NoteToolbar
tontb
. - Fix: Suggester: The bottom border radius was missing on mobile.
Full Changelog: 1.17-beta-17...1.17-beta-18
v1.17-beta-17
Changes
- Moved bottom toolbar position up slightly on mobile (was overlapping the touch bar on iPad).
Beta API Improvements π
- Prompt: Large text field submits on
enter
+ a modifier key (e.g.,cmd
). Thanks @FelipeRearden - Prompt: Made height smaller on mobile.
Full Changelog: 1.17-beta-16...1.17-beta-17
v1.17-beta-16
Beta API Improvements π
(To test) API UIWorking inprompt()
large text field now submits on enter + modifier.beta-17
- Shortened API
prompt()
option parameter names:
let result = await prompt(options?: {
default?: string, // default value for text field; default none
label?: string, // shown above the text field, rendered as markdown; default none
large?: boolean, // set true if text box should be larger; default false
placeholder?: string, // text inside text field; defaults to message
});
Full Changelog: 1.17-beta-15...1.17-beta-16
v1.17-beta-15
Improvements π
API UI components updates
Prompt: All options are now passed via an optional options
object parameter, with defaults for each:
prompt(options?: {
label?: string, // shown above the text field, rendered as markdown; default none
large?: boolean, // set true if text box should be larger; default false
placeholder?: string, // text inside text field; defaults to message
default?: string // default value for text field; default none
})
Suggester: Made function easier to use with optional keys
(if not provided, returned value is the selected option), also via an optional options
parameter:
suggester(
values: string[] | ((value: T) => string), // renamed from text_items; rendered as markdown
keys?: T[], // renamed from items; if not provided, values are returned on selection
options?: {
placeholder?: string, // shown in the input field; defaults to message
limit?: number // how many options to show; defaults to no limit
})
Also:
- Prompt text (
options.prompt_text
) is now also rendered as markdown. Thanks @FelipeRearden - Examples folder in repo have been updated to use the updated functions.
- For Dataview:
NtbPrompt.js
andNtbSuggester.js
- For JS Engine:
NtbPrompt.js
andNtbSuggester.js
- For Dataview:
Other improvements
- Code examples in What's New are now horizontally scrollable.
Fixes
- Using the Create new note link was creating a note but with duplicate toolbars. (This may have been a 1.8.x issue, with the metadata event firing on note creation.)
Full Changelog: 1.17-beta-14...1.17-beta-15
v1.17-beta-14
Changes
Beta API UI components: Suggester:
- Fix: Returns value from
text_items
array ifitems
parameter is provided. Thanks @FelipeRearden - Makes keys (
items
parameter) optional. If not provided, value from thetext_items
array is returned.
const keys = ["key1", "key2"];
// mix in Obsidian and plugin markdown (e.g., Iconize) to have it rendered in the suggester
const values = [":LiHome: value1", ":LiActivity: value2"];
// all of these work:
const selected1 = await NoteToolbar.suggester(values); // returns value of selection
const selected2 = await NoteToolbar.suggester(values, keys); // returns key corresponding to selection
const selected3 = await NoteToolbar.suggester(values, keys, "Placeholder"); // sets placeholder text
const selected4 = await NoteToolbar.suggester(values, null, "Placeholder"); // sets placeholder text without keys
Full Changelog: 1.17-beta-13...1.17-beta-14
v1.17-beta-13
Improvements π
- New plugin setting: Show toolbar for the linked note in the File menu, under Note Toolbar Settings β Other, which is defaulted to off. Allows you to selectively enable this feature, which was introduced in
v1.13
. Thanks @Moyf and @FelipeRearden - Bottom toolbars: Style Settings: Adjust the Y position separately on desktop and mobile.
- Beta API UI components:
- Suggester: Options are now rendered as markdown, so they can include markdown and things like Iconize icons. Thanks @FelipeRearden
- Prompt: Now accepts an optional input placeholder text parameter: Thanks @FelipeRearden
suggester(text_items: string[] | ((item: T) => string), items: T[], placeholder?: string, limit?: number)
- Prompt: Made function easier to use with optional params and more sensible defaults:
prompt(prompt_text: string, multiline?: boolean, placeholder?: string, default_value?: string)
- Examples folder in repo has been updated to use the updated functions.
Full Changelog: 1.17-beta-11...1.17-beta-13