2
0
mirror of https://github.com/koreader/koreader synced 2024-11-13 19:11:25 +00:00
koreader/frontend/ui/plugin/insert_menu.lua
Hzj_jie 1a08f2cb69
Plugins: adds PluginMenuInserter helper (#7419)
Allows user-plugins to register themselves
into "More tools" menu.
2021-05-10 12:46:55 +02:00

22 lines
859 B
Lua

local reader_order = require("ui/elements/reader_menu_order")
local filemanager_order = require("ui/elements/filemanager_menu_order")
-- A "hacky" way to update plugin menu items on-the-fly.
-- Use: require("plugins/insert_menu").add("my_plugin_menu_name")
-- This piece of logic / table is singleton in the KOReader process.
-- It provides a way to add a plugin into the "More Plugins" and is useful to
-- work with contrib/plugins which are not in the core logic of KOReader.
-- To avoid duplicating the menu item, caller is expected to call the add once
-- in the KOReader process, usually it's achieveable to rely on the "require"
-- function in lua.
local PluginMenuInserter = {}
function PluginMenuInserter.add(name)
table.insert(reader_order.more_tools, name)
table.insert(filemanager_order.more_tools, name)
end
return PluginMenuInserter