Open Achuan-2 opened 1 month ago
I know, that is a feature I want as well 😄
ref: https://github.com/TransMux/SiYuan-Attributes-Panel/blob/48ece4f7268620e49bb2254794e662c099d4d74c/src/components/DbRow.vue#L139 API: "/api/av/setAttributeViewBlockAttr"
// number
let res = await request("/api/av/setAttributeViewBlockAttr", {
avID: '20241017094451-2urncs9',
keyID: '20241017095436-2wlgb7o',
rowID: '20241017094453-65uzx7e',
cellID: '20241017100212-eqifwx8',
value: {
"number": {
"content": 3
}
},
});
res
// type: select
let res = await request("/api/av/setAttributeViewBlockAttr", {
avID: '20241017094451-2urncs9',
keyID: '20241017094451-fu1pv7s',
rowID: '20241017094453-65uzx7e',
cellID: '20241017094455-9mj9255',
value: {
"mSelect":
[{"content":"Fiction3","color":"2"}]
},
});
res
// type: mSelect
let res = await request("/api/av/setAttributeViewBlockAttr", {
avID: '20241017094451-2urncs9',
keyID: '20241017101851-kekovwz',
rowID: '20241017094453-65uzx7e',
cellID: '20241017102149-2jimfjh',
value: {
"mSelect": [{"content":"Fiction3"}]
},
});
res
The main challenge with this is the amount of code required for the different fields to correctly mimic the original functionality. I don't want this to become a maintenance nightmare.
in siyuan v3.1.11, /api/av/setAttributeViewBlockAttr
will do not need cellID
(see https://github.com/siyuan-note/siyuan/issues/12996)
commit https://github.com/siyuan-note/siyuan/commit/777a7c9f51da20a2ed868cbde3f32f87659ffe18
and rowID is docID, for a doc added to the database. It would be easier to change the value of attributes
// type: text
let res = await fetchSyncPost("/api/av/setAttributeViewBlockAttr", {
avID: '20241017094451-2urncs9',
keyID: '20241102151935-gypad0k',
rowID: '20211116001448-ny4lvyw', // docID
value: {
"text": {
"content": 'hh\nhhh'
}
},
});
// number
let res = await fetchSyncPost("/api/av/setAttributeViewBlockAttr", {
avID: '20241017094451-2urncs9',
keyID: '20241017095436-2wlgb7o',
rowID: '20241017094453-65uzx7e', // docID
value: {
"number": {
"content": 3
}
},
});
res
// type: single select
let res = await fetchSyncPost("/api/av/setAttributeViewBlockAttr", {
avID: '20241017094451-2urncs9',
keyID: '20241017094451-fu1pv7s',
rowID: '20241017094453-65uzx7e', // docID
value: {
"mSelect":
[{"content":"Fiction3","color":"2"}]
},
});
res
// type: multiple Select
let res = await fetchSyncPost("/api/av/setAttributeViewBlockAttr", {
avID: '20241017094451-2urncs9',
keyID: '20241017101851-kekovwz',
rowID: '20241017094453-65uzx7e', // docID
value: {
"mSelect": [{"content":"Fiction3"}]
},
});
res
Saving the data is the smallest problem, the main challenge is how to render the complex fields like Select or Relation.
Saving the data is the smallest problem; the main challenge is how to render complex fields like Select or Relation.
I'm sorry, I'm not particularly knowledgeable about rendering. Can't the functionality of the property panel be reused?
Sadly siyuan doesn't expose these components, so they can't be imported into plugins.
It either needs to be copied into the code, or implemented completely - both choices are terrible.
If you encounter difficulties, you can submit issue in the repo of SiYuan. The developer should be willing to provide help.
Yes, it would make sense to make a proposal for this. But this is not an "issue" or bug. Instead it would be a new feature for Siyuan - and then the discussions will take place if this actually makes sense or not.
it would be nice if this plugin can support editing the attributes directly in Database Properties Panel