aboutsummaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lua/null-browser/api.lua17
-rw-r--r--lua/null-browser/extras/tabline.lua2
2 files changed, 17 insertions, 2 deletions
diff --git a/lua/null-browser/api.lua b/lua/null-browser/api.lua
index 07b7072..5475beb 100644
--- a/lua/null-browser/api.lua
+++ b/lua/null-browser/api.lua
@@ -129,6 +129,21 @@ function web.view.set_url(url, view_id) return __internals.view_set_url(url, vie
--- ```
function web.view.set_html(html, opts) return __internals.view_set_html(html, (opts or {}).view) end
+--- @class RunJSOpts
+--- @field view? number View id
+
+--- Set html in a given view
+---
+--- @param js string HTML string
+--- @param opts? RunJSOpts Options
+---
+--- @example
+--- ```lua
+--- web.view.run_js('console.log(42)')
+--- web.view.run_js('console.log(42)', 3) -- Set html for view with id 3
+--- ```
+function web.view.run_js(js, opts) return __internals.view_run_js(js, (opts or {}).view) end
+
--- @class ExposeOpts
--- @field view? number View id
@@ -146,7 +161,7 @@ function web.view.set_html(html, opts) return __internals.view_set_html(html, (o
--- ```
--- then in js
--- ```js
---- __nullbrowser.tab_select({ view: 5 })
+--- _nullbrowser.rpc.tab_select({ view: 5 })
--- ```
function web.view.expose(name, action, opts) return __internals.view_expose(name, action, (opts or {}).view) end
diff --git a/lua/null-browser/extras/tabline.lua b/lua/null-browser/extras/tabline.lua
index b9156f5..e265940 100644
--- a/lua/null-browser/extras/tabline.lua
+++ b/lua/null-browser/extras/tabline.lua
@@ -47,7 +47,7 @@ function tabline.tabs_html()
for index, view in ipairs(web.view.list()) do
local tab = html.button({
class = 'tab' .. (web.view.current() == view.id and ' current' or ''),
- onclick = '__nullbrowser.tab_select({ view: ' .. view.id .. ' })',
+ onclick = '_nullbrowser.rpc.tab_select({ view: ' .. view.id .. ' })',
}, {
index .. ': ' .. view.title .. ' (' .. view.url .. ')',
})