When `standalone` is set to true, this action button will only appear in "standalone PWA" mode (e.g. home-screen mobile apps, or installed PWA on desktop). Useful to e.g. only show forward and backward buttons. These forward and backward buttons are now also added to the default action button config.
1.4 KiB
1.4 KiB
description, tags
| description | tags |
|---|---|
| APIs to define custom action buttons | meta/api |
APIs to more conveniently define action buttons (alternative to setting them via regular ^Library/Std/Config).
API
actionButton.define(spec)
Keys to define:
icon: feather icon to use for your buttonrun: function to invoke once the button is pusheddescription(optional): description of button (appears on hover)priority(optional): determines priority of button (the higher, the earlier in the list)mobile: when set totruethis button will only appear on mobile devicesstandalone: when set totruethis button will only appear in standalone/PWA mode; whenfalse, only in browser modedropdown(optional): when set tofalse, the button stays visible outside the dropdown menu on mobile (default:true)
Example
-- Defines a new button that forces your UI into read-only mode
actionButton.define {
icon = "eye",
-- Uncomment the following line to only make this button appear
-- ONLY on mobile devices:
-- mobile = true,
run = function()
editor.setUiOption("forcedROMode", true)
editor.rebuildEditorState()
end
}
Implementation
-- priority: 100
actionButton = actionButton or {}
function actionButton.define(spec)
local actionButtonConfig = config.get("actionButtons", {})
table.insert(actionButtonConfig, spec)
end