First of all, thanks for devs. Now I can have a dream to escape from all the heavy and commercial note services… But there are many questions because I’m not good at English and programming.
My current issue is: Is there a flag or something to set the individual page readonly? Quick edit is cool feature and I love it. And it will be great if I can protect the system pages from unexpected edit.
The following block will let you make a page read-only if it has the tag “uneditable” (you can change that if you want)
EDIT: This approach has some massive flaws
It takes a second for the changes to take effect though… sadly I couldn’t find a page load event to listen to.
event.listen {
name = "cron:secondPassed",
run = function(e)
meta = editor.getCurrentPageMeta()
isReadOnly = editor.getUiOption("forcedROMode")
if not isReadOnly and table.includes(meta.tags, "uneditable") then
editor.setUiOption("forcedROMode", true)
editor.rebuildEditorState()
elseif isReadOnly and not table.includes(meta.tags, "uneditable") then
editor.setUiOption("forcedROMode", false)
editor.rebuildEditorState()
end
end
}
function setPerm()
pageName = editor.getCurrentPage()
if not pageName then return end
local permission = query [[from index.tag "page" where name == editor.getCurrentPage() select perm]]
editor.flashNotification(permission)
if unpack(permission) == "rw" then
editor.flashNotification("ok")
local objects = {perm = "ro"}
else
editor.flashNotification("not")
local objects = {perm = "rw"}
end
index.indexObjects(pageName, objects)
return
end
(info : editor.flashNotification just for control)
Result → Error: can’t access property Symbol.iterator, t is null.
After much research, it seems impossible to change the “perm” attribute.
For what ?
So it looks like we need a new page attribute to block any changes on individual page during a silverbullet session. This also could be a partial solution to the problem identified when viewing on mobile.