-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Components] roamresearch - Added new components
- Loading branch information
Showing
15 changed files
with
599 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
components/roamresearch/actions/append-block/append-block.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import utils from "../../common/utils.mjs"; | ||
import app from "../../roamresearch.app.mjs"; | ||
|
||
export default { | ||
key: "roamresearch-append-block", | ||
name: "Append Block", | ||
description: "Generic append block for Roam Research pages. [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/jzuu4ODbF).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
string: { | ||
type: "string", | ||
label: "Content", | ||
description: "The string to append.", | ||
}, | ||
children: { | ||
type: "string[]", | ||
label: "Children", | ||
description: "The children to append. This is an array of possibly further nested child blocks.", | ||
optional: true, | ||
}, | ||
heading: { | ||
type: "string", | ||
label: "Heading", | ||
description: "The heading to append.", | ||
optional: true, | ||
}, | ||
open: { | ||
type: "boolean", | ||
label: "Open", | ||
description: "Whether the block should be collapsed or expanded. Defaults to `true`.", | ||
optional: true, | ||
}, | ||
childrenViewType: { | ||
type: "string", | ||
label: "Children View Type", | ||
description: "Block view type of children blocks.", | ||
optional: true, | ||
options: [ | ||
"bullet", | ||
"document", | ||
"numbered", | ||
], | ||
}, | ||
uid: { | ||
type: "string", | ||
label: "UID", | ||
description: "The UID of the block to append.", | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
app, | ||
string, | ||
children, | ||
heading, | ||
open, | ||
childrenViewType, | ||
uid, | ||
} = this; | ||
|
||
const response = await app.appendBlocks({ | ||
$, | ||
data: { | ||
"append-data": { | ||
string, | ||
children: utils.parseArray(children), | ||
heading, | ||
open, | ||
["children-view-type"]: childrenViewType, | ||
uid, | ||
}, | ||
}, | ||
}); | ||
|
||
$.export("$summary", "Succesfully ran append block."); | ||
return response; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import app from "../../roamresearch.app.mjs"; | ||
|
||
export default { | ||
key: "roamresearch-pull-many", | ||
name: "Pull Many", | ||
description: "Generic pull many for Roam Research pages. [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/mdnjFsqoA).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
eids: { | ||
type: "string", | ||
label: "Entity IDs", | ||
description: "The entity ID to pull. Eg. `[[:block/uid \"08-30-2022\"] [:block/uid \"08-31-2022\"]]`.", | ||
}, | ||
selector: { | ||
type: "string", | ||
label: "Selector", | ||
description: "The selector to pull. Eg. `[:block/uid :node/title :block/string {:block/children [:block/uid :block/string]} {:block/refs [:node/title :block/string :block/uid]}]`.", | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
app, | ||
eids, | ||
selector, | ||
} = this; | ||
|
||
const response = await app.pullMany({ | ||
$, | ||
data: { | ||
eids, | ||
selector, | ||
}, | ||
}); | ||
|
||
if (!response.result) { | ||
$.export("$summary", `Failed to pull many data for entity IDs: \`${eids}\`.`); | ||
return response; | ||
} | ||
|
||
$.export("$summary", "Succesfully ran pull many."); | ||
return response; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import app from "../../roamresearch.app.mjs"; | ||
|
||
export default { | ||
key: "roamresearch-pull", | ||
name: "Pull", | ||
description: "Generic pull for Roam Research pages. [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/mdnjFsqoA).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
eid: { | ||
type: "string", | ||
label: "Entity ID", | ||
description: "The entity ID to pull. Eg. `[:block/uid \"08-30-2022\"]`.", | ||
}, | ||
selector: { | ||
type: "string", | ||
label: "Selector", | ||
description: "The selector to pull. Eg. `[:block/uid :node/title :block/string {:block/children [:block/uid :block/string]} {:block/refs [:node/title :block/string :block/uid]}]`.", | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
app, | ||
eid, | ||
selector, | ||
} = this; | ||
|
||
const response = await app.pull({ | ||
$, | ||
data: { | ||
eid, | ||
selector, | ||
}, | ||
}); | ||
|
||
if (!response.result) { | ||
$.export("$summary", `Failed to pull data for entity ID: \`${eid}\`.`); | ||
return response; | ||
} | ||
|
||
$.export("$summary", "Succesfully ran pull."); | ||
return response; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import app from "../../roamresearch.app.mjs"; | ||
|
||
export default { | ||
key: "roamresearch-query", | ||
name: "Query", | ||
description: "Generic query for Roam Research pages. [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/mdnjFsqoA).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
query: { | ||
type: "string", | ||
label: "Query", | ||
description: "The query to run in Datalog language. Eg. `[:find ?block-uid ?block-str :in $ ?search-string :where [?b :block/uid ?block-uid] [?b :block/string ?block-str] [(clojure.string/includes? ?block-str ?search-string)]]`.", | ||
}, | ||
args: { | ||
type: "string[]", | ||
label: "Arguments", | ||
description: "The arguments to pass to the query. Eg. `apple` as the firs argument.", | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
app, | ||
query, | ||
args, | ||
} = this; | ||
|
||
const response = await app.query({ | ||
$, | ||
data: { | ||
query, | ||
args, | ||
}, | ||
}); | ||
|
||
$.export("$summary", "Succesfully ran query."); | ||
return response; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.