roamjs-components 0.79.9 → 0.79.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ const Filter = ({ data, initialValue, onChange, renderButtonText = (s) => s ? s.
9
9
  const closeFilter = (0, react_1.useCallback)(() => {
10
10
  setIsFilterOpen(false);
11
11
  }, [setIsFilterOpen]);
12
- const filtersRef = (0, react_1.useRef)({
12
+ const initialFiltersValue = (0, react_1.useMemo)(() => ({
13
13
  includes: Object.fromEntries(Object.keys(data).map((k) => [
14
14
  k,
15
15
  new Set(data[k].filter((d) => initialValue && initialValue.includes[k].has(d))),
@@ -18,7 +18,8 @@ const Filter = ({ data, initialValue, onChange, renderButtonText = (s) => s ? s.
18
18
  k,
19
19
  new Set(data[k].filter((d) => initialValue && initialValue.excludes[k].has(d))),
20
20
  ])),
21
- });
21
+ }), [initialValue, data]);
22
+ const filtersRef = (0, react_1.useRef)(initialFiltersValue);
22
23
  const [filters, setFilters] = (0, react_1.useState)(filtersRef.current);
23
24
  const [filterSearch, setFilterSearch] = (0, react_1.useState)("");
24
25
  const active = Object.keys(filters.includes).some((k) => filters.includes[k].size > 0) ||
@@ -1 +1 @@
1
- {"version":3,"file":"Filter.js","sourceRoot":"","sources":["../../src/components/Filter.tsx"],"names":[],"mappings":";;;AAAA,4CAA6E;AAC7E,uDAA6D;AAC7D,0DAA0B;AAO1B,MAAM,MAAM,GAAG,CAAC,EACd,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,gBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE,CACvB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,qCAAG,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,cAAa,EAC5D,kBAAkB,GAAG,2BAA2B,EAChD,kBAAkB,GAAG,sBAAsB,EAC3C,KAAK,GASN,EAAE,EAAE;IACH,MAAM,CAAC,YAAY,EA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AC,CAAC;oCACpB,CAAC,IAEA,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAChB,CACL,CACF,CACP,CAAC,CACA;wBACL,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,CACrB,uCACE,SAAS,EAAC,SAAS,EACnB,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,GACxC,CACH,CACc,CAClB,CAAC,CACE,CACF,CACF,EAER,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,YAAY,GACpB,CACM,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC","sourcesContent":["import { Tooltip, Position, Popover, Button, Icon } from \"@blueprintjs/core\";\nimport React, { useCallback, useRef, useState } from \"react\";\nimport fuzzy from \"fuzzy\";\n\nexport type Filters = {\n includes: Record<string, Set<string>>;\n excludes: Record<string, Set<string>>;\n};\n\nconst Filter = ({\n data,\n initialValue,\n onChange,\n renderButtonText = (s) =>\n s ? s.toString() : <i style={{ opacity: 0.5 }}>(Empty)</i>,\n includeHelpMessage = \"Only include these values\",\n excludeHelpMessage = \"Exclude these values\",\n small,\n}: {\n initialValue?: Filters;\n data: Record<string, string[]>;\n onChange: (filters: Filters) => void;\n renderButtonText?: (s: string, key: string) => React.ReactNode;\n includeHelpMessage?: string;\n excludeHelpMessage?: string;\n small?: boolean;\n}) => {\n const [isFilterOpen, setIsFilterOpen] = useState(false);\n const closeFilter = useCallback(() => {\n setIsFilterOpen(false);\n }, [setIsFilterOpen]);\n const filtersRef = useRef({\n includes: Object.fromEntries(\n Object.keys(data).map((k) => [\n k,\n new Set<string>(\n data[k].filter((d) => initialValue && initialValue.includes[k].has(d))\n ),\n ])\n ),\n excludes: Object.fromEntries(\n Object.keys(data).map((k) => [\n k,\n new Set<string>(\n data[k].filter((d) => initialValue && initialValue.excludes[k].has(d))\n ),\n ])\n ),\n });\n const [filters, setFilters] = useState(filtersRef.current);\n const [filterSearch, setFilterSearch] = useState(\"\");\n const active =\n Object.keys(filters.includes).some((k) => filters.includes[k].size > 0) ||\n Object.keys(filters.excludes).some((k) => filters.excludes[k].size > 0);\n return (\n <Tooltip content={\"Filters\"} position={Position.BOTTOM}>\n <Popover\n target={\n <Button\n icon={\n <Icon icon={\"filter\"} color={active ? \"#a82a2a\" : \"#5c7080\"} />\n }\n onClick={(e) => {\n e.stopPropagation();\n setIsFilterOpen(!isFilterOpen);\n }}\n className={`roamjs-filter ${active ? \"roamjs-filter-active\" : \"\"}`}\n minimal\n small={small}\n />\n }\n content={\n <div\n style={{ maxWidth: 600, maxHeight: 245, overflowY: \"scroll\" }}\n onClick={(e) => e.stopPropagation()}\n >\n <div\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n width: 500,\n maxWidth: \"90vw\",\n transition: \"all 300ms ease-in 0s\",\n padding: 8,\n }}\n >\n <div className=\"flex-h-box\">\n <div\n style={{\n flex: \"1 1 100%\",\n paddingTop: 4,\n paddingBottom: 4,\n paddingLeft: 4,\n }}\n >\n <div>\n <strong>Includes</strong>\n <span style={{ marginLeft: 4, fontSize: 12 }}>\n Click to Add\n </span>\n <div\n style={{\n padding: \"8px 0px\",\n fontSize: \"0.8em\",\n color: \"rgb(167, 182, 194)\",\n }}\n >\n {Object.values(filters.includes).every(\n (v) => v.size === 0\n )\n ? includeHelpMessage\n : Object.entries(filters.includes).flatMap(\n ([key, col]) =>\n Array.from(col).map((n, i) => (\n <div\n style={{\n position: \"relative\",\n display: \"inline-block\",\n }}\n key={`${n.toString()}-${i}`}\n >\n <div>\n <button\n className=\"bp3-button\"\n style={{\n margin: 4,\n paddingRight: 4,\n cursor: \"pointer\",\n borderBottomColor: \"rgb(92, 112, 128)\",\n }}\n onClick={() => {\n filtersRef.current.includes[key].delete(\n n\n );\n const filters = {\n ...filtersRef.current,\n };\n setFilters(filters);\n onChange(filters);\n }}\n >\n {renderButtonText(n, key)}\n </button>\n </div>\n </div>\n ))\n )}\n </div>\n </div>\n <div style={{ paddingTop: 8 }} />\n </div>\n <div\n className=\"rm-line\"\n style={{ marginTop: 8, marginBottom: 8 }}\n />\n <div\n style={{\n flex: \"1 1 100%\",\n paddingTop: 4,\n paddingBottom: 4,\n paddingLeft: 8,\n }}\n >\n <div>\n <strong>Removes</strong>\n <span style={{ marginLeft: 4, fontSize: 12 }}>\n Shift-Click to Add\n </span>\n <div\n style={{\n padding: \"8px 0px\",\n fontSize: \"0.8em\",\n color: \"rgb(167, 182, 194)\",\n }}\n >\n {Object.values(filters.excludes).every(\n (v) => v.size === 0\n )\n ? excludeHelpMessage\n : Object.entries(filters.excludes).flatMap(\n ([key, col]) =>\n Array.from(col).map((n, i) => (\n <div\n style={{\n position: \"relative\",\n display: \"inline-block\",\n }}\n key={`${n.toString()}-${i}`}\n >\n <div>\n <button\n className=\"bp3-button\"\n style={{\n margin: 4,\n paddingRight: 4,\n cursor: \"pointer\",\n borderBottomColor: \"rgb(92, 112, 128)\",\n }}\n onClick={() => {\n filtersRef.current.excludes[key].delete(\n n\n );\n const filters = {\n ...filtersRef.current,\n };\n setFilters(filters);\n onChange(filters);\n }}\n >\n {renderButtonText(n, key)}\n </button>\n </div>\n </div>\n ))\n )}\n </div>\n </div>\n <div style={{ paddingTop: 8 }} />\n </div>\n </div>\n <div\n className=\"rm-line\"\n style={{ marginTop: 4, borderColor: \"rgb(41, 55, 66)\" }}\n />\n <input\n placeholder=\"Search References\"\n className=\"bp3-input bp3-minimal search-input\"\n style={{ margin: 8 }}\n value={filterSearch}\n onChange={(e) => setFilterSearch(e.target.value)}\n />\n <div className=\"flex-h-box\">\n {Object.keys(data).map((k, i, all) => (\n <React.Fragment key={k}>\n <div\n style={{\n flex: \"1 1 100%\",\n paddingTop: 4,\n paddingBottom: 4,\n paddingLeft: 4,\n }}\n >\n {(filterSearch\n ? fuzzy\n .filter(filterSearch, data[k])\n .map((s) => s.string)\n : data[k]\n )\n .filter(\n (n) =>\n !filters.includes[k].has(n) &&\n !filters.excludes[k].has(n)\n )\n .map((n, i) => (\n <div\n style={{\n position: \"relative\",\n display: \"inline-block\",\n }}\n key={`${n.toString()}-${i}`}\n >\n <div>\n <button\n className=\"bp3-button\"\n style={{\n margin: 4,\n paddingRight: 4,\n cursor: \"pointer\",\n borderBottomColor: \"rgb(92, 112, 128)\",\n }}\n onClick={(e) => {\n if (e.shiftKey)\n filtersRef.current.excludes[k].add(n);\n else filtersRef.current.includes[k].add(n);\n const filters = { ...filtersRef.current };\n setFilters(filters);\n onChange(filters);\n }}\n >\n {renderButtonText(n, k)}\n </button>\n </div>\n </div>\n ))}\n </div>\n {i < all.length - 1 && (\n <div\n className=\"rm-line\"\n style={{ marginTop: 8, marginBottom: 8 }}\n />\n )}\n </React.Fragment>\n ))}\n </div>\n </div>\n </div>\n }\n onClose={closeFilter}\n isOpen={isFilterOpen}\n />\n </Tooltip>\n );\n};\n\nexport default Filter;\n"]}
1
+ {"version":3,"file":"Filter.js","sourceRoot":"","sources":["../../src/components/Filter.tsx"],"names":[],"mappings":";;;AAAA,4CAA6E;AAC7E,uDAAsE;AACtE,0DAA0B;AAO1B,MAAM,MAAM,GAAG,CAAC,EACd,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,gBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE,CACvB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,qCAAG,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,cAAa,EAC5D,kBAAkB,GAAG,2BAA2B,EAChD,kBAAkB,GAAG,sBAAsB,EAC3C,KAAK,GASN,EAAE,EAAE;IACH,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IACxD,MAAM,WAAW,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QACnC,eAAe,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;IAC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ACL,CACF,CACP,CAAC,CACA;wBACL,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,CACrB,uCACE,SAAS,EAAC,SAAS,EACnB,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,GACxC,CACH,CACc,CAClB,CAAC,CACE,CACF,CACF,EAER,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,YAAY,GACpB,CACM,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC","sourcesContent":["import { Tooltip, Position, Popover, Button, Icon } from \"@blueprintjs/core\";\nimport React, { useCallback, useRef, useState, useMemo } from \"react\";\nimport fuzzy from \"fuzzy\";\n\nexport type Filters = {\n includes: Record<string, Set<string>>;\n excludes: Record<string, Set<string>>;\n};\n\nconst Filter = ({\n data,\n initialValue,\n onChange,\n renderButtonText = (s) =>\n s ? s.toString() : <i style={{ opacity: 0.5 }}>(Empty)</i>,\n includeHelpMessage = \"Only include these values\",\n excludeHelpMessage = \"Exclude these values\",\n small,\n}: {\n initialValue?: Filters;\n data: Record<string, string[]>;\n onChange: (filters: Filters) => void;\n renderButtonText?: (s: string, key: string) => React.ReactNode;\n includeHelpMessage?: string;\n excludeHelpMessage?: string;\n small?: boolean;\n}) => {\n const [isFilterOpen, setIsFilterOpen] = useState(false);\n const closeFilter = useCallback(() => {\n setIsFilterOpen(false);\n }, [setIsFilterOpen]);\n const initialFiltersValue = useMemo(\n () => ({\n includes: Object.fromEntries(\n Object.keys(data).map((k) => [\n k,\n new Set<string>(\n data[k].filter(\n (d) => initialValue && initialValue.includes[k].has(d)\n )\n ),\n ])\n ),\n excludes: Object.fromEntries(\n Object.keys(data).map((k) => [\n k,\n new Set<string>(\n data[k].filter(\n (d) => initialValue && initialValue.excludes[k].has(d)\n )\n ),\n ])\n ),\n }),\n [initialValue, data]\n );\n const filtersRef = useRef(initialFiltersValue);\n const [filters, setFilters] = useState(filtersRef.current);\n const [filterSearch, setFilterSearch] = useState(\"\");\n const active =\n Object.keys(filters.includes).some((k) => filters.includes[k].size > 0) ||\n Object.keys(filters.excludes).some((k) => filters.excludes[k].size > 0);\n return (\n <Tooltip content={\"Filters\"} position={Position.BOTTOM}>\n <Popover\n target={\n <Button\n icon={\n <Icon icon={\"filter\"} color={active ? \"#a82a2a\" : \"#5c7080\"} />\n }\n onClick={(e) => {\n e.stopPropagation();\n setIsFilterOpen(!isFilterOpen);\n }}\n className={`roamjs-filter ${active ? \"roamjs-filter-active\" : \"\"}`}\n minimal\n small={small}\n />\n }\n content={\n <div\n style={{ maxWidth: 600, maxHeight: 245, overflowY: \"scroll\" }}\n onClick={(e) => e.stopPropagation()}\n >\n <div\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n width: 500,\n maxWidth: \"90vw\",\n transition: \"all 300ms ease-in 0s\",\n padding: 8,\n }}\n >\n <div className=\"flex-h-box\">\n <div\n style={{\n flex: \"1 1 100%\",\n paddingTop: 4,\n paddingBottom: 4,\n paddingLeft: 4,\n }}\n >\n <div>\n <strong>Includes</strong>\n <span style={{ marginLeft: 4, fontSize: 12 }}>\n Click to Add\n </span>\n <div\n style={{\n padding: \"8px 0px\",\n fontSize: \"0.8em\",\n color: \"rgb(167, 182, 194)\",\n }}\n >\n {Object.values(filters.includes).every(\n (v) => v.size === 0\n )\n ? includeHelpMessage\n : Object.entries(filters.includes).flatMap(\n ([key, col]) =>\n Array.from(col).map((n, i) => (\n <div\n style={{\n position: \"relative\",\n display: \"inline-block\",\n }}\n key={`${n.toString()}-${i}`}\n >\n <div>\n <button\n className=\"bp3-button\"\n style={{\n margin: 4,\n paddingRight: 4,\n cursor: \"pointer\",\n borderBottomColor: \"rgb(92, 112, 128)\",\n }}\n onClick={() => {\n filtersRef.current.includes[key].delete(\n n\n );\n const filters = {\n ...filtersRef.current,\n };\n setFilters(filters);\n onChange(filters);\n }}\n >\n {renderButtonText(n, key)}\n </button>\n </div>\n </div>\n ))\n )}\n </div>\n </div>\n <div style={{ paddingTop: 8 }} />\n </div>\n <div\n className=\"rm-line\"\n style={{ marginTop: 8, marginBottom: 8 }}\n />\n <div\n style={{\n flex: \"1 1 100%\",\n paddingTop: 4,\n paddingBottom: 4,\n paddingLeft: 8,\n }}\n >\n <div>\n <strong>Removes</strong>\n <span style={{ marginLeft: 4, fontSize: 12 }}>\n Shift-Click to Add\n </span>\n <div\n style={{\n padding: \"8px 0px\",\n fontSize: \"0.8em\",\n color: \"rgb(167, 182, 194)\",\n }}\n >\n {Object.values(filters.excludes).every(\n (v) => v.size === 0\n )\n ? excludeHelpMessage\n : Object.entries(filters.excludes).flatMap(\n ([key, col]) =>\n Array.from(col).map((n, i) => (\n <div\n style={{\n position: \"relative\",\n display: \"inline-block\",\n }}\n key={`${n.toString()}-${i}`}\n >\n <div>\n <button\n className=\"bp3-button\"\n style={{\n margin: 4,\n paddingRight: 4,\n cursor: \"pointer\",\n borderBottomColor: \"rgb(92, 112, 128)\",\n }}\n onClick={() => {\n filtersRef.current.excludes[key].delete(\n n\n );\n const filters = {\n ...filtersRef.current,\n };\n setFilters(filters);\n onChange(filters);\n }}\n >\n {renderButtonText(n, key)}\n </button>\n </div>\n </div>\n ))\n )}\n </div>\n </div>\n <div style={{ paddingTop: 8 }} />\n </div>\n </div>\n <div\n className=\"rm-line\"\n style={{ marginTop: 4, borderColor: \"rgb(41, 55, 66)\" }}\n />\n <input\n placeholder=\"Search References\"\n className=\"bp3-input bp3-minimal search-input\"\n style={{ margin: 8 }}\n value={filterSearch}\n onChange={(e) => setFilterSearch(e.target.value)}\n />\n <div className=\"flex-h-box\">\n {Object.keys(data).map((k, i, all) => (\n <React.Fragment key={k}>\n <div\n style={{\n flex: \"1 1 100%\",\n paddingTop: 4,\n paddingBottom: 4,\n paddingLeft: 4,\n }}\n >\n {(filterSearch\n ? fuzzy\n .filter(filterSearch, data[k])\n .map((s) => s.string)\n : data[k]\n )\n .filter(\n (n) =>\n !filters.includes[k].has(n) &&\n !filters.excludes[k].has(n)\n )\n .map((n, i) => (\n <div\n style={{\n position: \"relative\",\n display: \"inline-block\",\n }}\n key={`${n.toString()}-${i}`}\n >\n <div>\n <button\n className=\"bp3-button\"\n style={{\n margin: 4,\n paddingRight: 4,\n cursor: \"pointer\",\n borderBottomColor: \"rgb(92, 112, 128)\",\n }}\n onClick={(e) => {\n if (e.shiftKey)\n filtersRef.current.excludes[k].add(n);\n else filtersRef.current.includes[k].add(n);\n const filters = { ...filtersRef.current };\n setFilters(filters);\n onChange(filters);\n }}\n >\n {renderButtonText(n, k)}\n </button>\n </div>\n </div>\n ))}\n </div>\n {i < all.length - 1 && (\n <div\n className=\"rm-line\"\n style={{ marginTop: 8, marginBottom: 8 }}\n />\n )}\n </React.Fragment>\n ))}\n </div>\n </div>\n </div>\n }\n onClose={closeFilter}\n isOpen={isFilterOpen}\n />\n </Tooltip>\n );\n};\n\nexport default Filter;\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "roamjs-components",
3
3
  "description": "Expansive toolset, utilities, & components for developing RoamJS extensions.",
4
- "version": "0.79.9",
4
+ "version": "0.79.11",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {
@@ -1,7 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const formatRoamNode = (n, v) => {
4
- const viewType = (typeof n[":children/view-type"] === "string" ? n[":children/view-type"] : v).replace(/^:/, "");
3
+ const formatRoamNode = (n) => {
4
+ var _a, _b, _c;
5
+ if (!n)
6
+ return {
7
+ text: "",
8
+ open: true,
9
+ order: 0,
10
+ uid: "",
11
+ children: [],
12
+ parents: [],
13
+ heading: 0,
14
+ viewType: "bullet",
15
+ editTime: new Date(0),
16
+ props: { imageResize: {}, iframe: {} },
17
+ textAlign: "left",
18
+ };
19
+ const viewType = ((_c = (_b = (_a = (n[":block/parents"] || [])
20
+ .find((a) => typeof a[":children/view-type"] === "string")) === null || _a === void 0 ? void 0 : _a[":children/view-type"]) === null || _b === void 0 ? void 0 : _b.replace) === null || _c === void 0 ? void 0 : _c.call(_b, /^:/, "")) || "bullet";
5
21
  return {
6
22
  text: n[":block/string"] || n[":node/title"] || "",
7
23
  open: typeof n[":block/open"] === "undefined" ? true : n[":block/open"],
@@ -14,13 +30,11 @@ const formatRoamNode = (n, v) => {
14
30
  textAlign: n[":block/text-align"] || "left",
15
31
  children: (n[":block/children"] || [])
16
32
  .sort((a, b) => (a[":block/order"] || 0) - (b[":block/order"] || 0))
17
- .map((r) => formatRoamNode(r, viewType)),
33
+ .map(formatRoamNode),
18
34
  parents: (n[":block/parents"] || []).map((n) => (n === null || n === void 0 ? void 0 : n[":db/id"]) || 0),
19
35
  };
20
36
  };
21
- const getFullTreeByParentUid = (uid) => {
22
- var _a, _b, _c, _d;
23
- return formatRoamNode((((_b = (_a = window.roamAlphaAPI.data.fast.q(`[:find (pull ?b [
37
+ const getFullTreeByParentUid = (uid) => formatRoamNode(window.roamAlphaAPI.pull(`[
24
38
  :block/string
25
39
  :node/title
26
40
  :block/uid
@@ -31,15 +45,8 @@ const getFullTreeByParentUid = (uid) => {
31
45
  :block/text-align
32
46
  :edit/time
33
47
  :block/props
34
- :block/parents
48
+ {:block/parents [:children/view-type]}
35
49
  {:block/children ...}
36
- ]) :where [?b :block/uid "${uid}"]]`)) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b[0]) || {}), ((_d = (_c = window.roamAlphaAPI.data.fast.q(`[:find
37
- (pull ?p [:children/view-type]) :where
38
- [?c :block/uid "${uid}"] [?c :block/parents ?p]]`)
39
- .reverse()
40
- .map((a) => a[0])
41
- .map((a) => a && a[":children/view-type"])
42
- .find((a) => !!a)) === null || _c === void 0 ? void 0 : _c.replace) === null || _d === void 0 ? void 0 : _d.call(_c, /^:/, "")) || "bullet");
43
- };
50
+ ]`, [`:block/uid`, uid]));
44
51
  exports.default = getFullTreeByParentUid;
45
52
  //# sourceMappingURL=getFullTreeByPar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G,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;QAC1C,OAAO,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAG,QAAQ,CAAC,KAAI,CAAC,CAAC;KACpE,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,GAAW,EAAY,EAAE;;IACvD,OAAA,cAAc,CACZ,CAAC,CAAA,MAAA,MAAA,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAC9B;;;;;;;;;;;;;gCAa0B,GAAG,KAAK,CACnC,0CAAG,CAAC,CAAC,0CAAG,CAAC,CAAC,KAAI,EAAE,CAAc,EAC/B,CAAC,MAAA,MACC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAC7B;;wBAEgB,GAAG,4BAA4B,CAElD;SACE,OAAO,EAAE;SACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAChB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,qBAAqB,CAAC,CAAC;SACzC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,0CACf,OAAO,mDAAG,IAAI,EAAE,EAAE,CAAc,KAAI,QAAQ,CACjD,CAAA;CAAA,CAAC;AAEJ,kBAAe,sBAAsB,CAAC","sourcesContent":["import type { PullBlock, TreeNode, ViewType } from \"../types\";\n\nconst formatRoamNode = (n: PullBlock, v: ViewType): TreeNode => {\n const viewType = (\n typeof n[\":children/view-type\"] === \"string\" ? n[\":children/view-type\"] : v\n ).replace(/^:/, \"\") as ViewType;\n return {\n text: n[\":block/string\"] || n[\":node/title\"] || \"\",\n open: typeof n[\":block/open\"] === \"undefined\" ? true : n[\":block/open\"],\n order: n[\":block/order\"] || 0,\n uid: n[\":block/uid\"] || \"\",\n heading: n[\":block/heading\"] || 0,\n viewType,\n editTime: new Date(n[\":edit/time\"] || 0),\n props: { imageResize: {}, iframe: {} },\n textAlign: n[\":block/text-align\"] || \"left\",\n children: (n[\":block/children\"] || [])\n .sort(\n (a: PullBlock, b: PullBlock) =>\n (a[\":block/order\"] || 0) - (b[\":block/order\"] || 0)\n )\n .map((r) => formatRoamNode(r, viewType)),\n parents: (n[\":block/parents\"] || []).map((n) => n?.[\":db/id\"] || 0),\n };\n};\n\nconst getFullTreeByParentUid = (uid: string): TreeNode =>\n formatRoamNode(\n (window.roamAlphaAPI.data.fast.q(\n `[:find (pull ?b [\n :block/string \n :node/title \n :block/uid \n :block/order \n :block/heading \n :block/open \n :children/view-type\n :block/text-align\n :edit/time \n :block/props\n :block/parents\n {:block/children ...}\n ]) :where [?b :block/uid \"${uid}\"]]`\n )?.[0]?.[0] || {}) as PullBlock,\n ((\n window.roamAlphaAPI.data.fast.q(\n `[:find\n (pull ?p [:children/view-type]) :where\n [?c :block/uid \"${uid}\"] [?c :block/parents ?p]]`\n ) as [PullBlock][]\n )\n .reverse()\n .map((a) => a[0])\n .map((a) => a && a[\":children/view-type\"])\n .find((a) => !!a)\n ?.replace?.(/^:/, \"\") as ViewType) || \"bullet\"\n );\n\nexport default getFullTreeByParentUid;\n"]}
1
+ {"version":3,"file":"getFullTreeByParentUid.js","sourceRoot":"","sources":["../../src/queries/getFullTreeByParentUid.ts"],"names":[],"mappings":";;AAEA,MAAM,cAAc,GAAG,CAAC,CAAmB,EAAY,EAAE;;IACvD,IAAI,CAAC,CAAC;QACJ,OAAO;YACL,IAAI,EAAE,EAAE;YACR,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,CAAC;YACR,GAAG,EAAE,EAAE;YACP,QAAQ,EAAE,EAAE;YACZ,OAAO,E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AAE,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;aACnE,GAAG,CAAC,cAAc,CAAC;QACtB,OAAO,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAG,QAAQ,CAAC,KAAI,CAAC,CAAC;KACpE,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,GAAW,EAAY,EAAE,CACvD,cAAc,CACZ,MAAM,CAAC,YAAY,CAAC,IAAI,CACtB;;;;;;;;;;;;;MAaA,EACA,CAAC,YAAY,EAAE,GAAG,CAAC,CACpB,CACF,CAAC;AAEJ,kBAAe,sBAAsB,CAAC","sourcesContent":["import type { PullBlock, TreeNode, ViewType } from \"../types\";\n\nconst formatRoamNode = (n: PullBlock | null): TreeNode => {\n if (!n)\n return {\n text: \"\",\n open: true,\n order: 0,\n uid: \"\",\n children: [],\n parents: [],\n heading: 0,\n viewType: \"bullet\",\n editTime: new Date(0),\n props: { imageResize: {}, iframe: {} },\n textAlign: \"left\",\n };\n const viewType =\n ((n[\":block/parents\"] || [])\n .find((a) => typeof a[\":children/view-type\"] === \"string\")\n ?.[\":children/view-type\"]?.replace?.(/^:/, \"\") as ViewType) || \"bullet\";\n return {\n text: n[\":block/string\"] || n[\":node/title\"] || \"\",\n open: typeof n[\":block/open\"] === \"undefined\" ? true : n[\":block/open\"],\n order: n[\":block/order\"] || 0,\n uid: n[\":block/uid\"] || \"\",\n heading: n[\":block/heading\"] || 0,\n viewType,\n editTime: new Date(n[\":edit/time\"] || 0),\n props: { imageResize: {}, iframe: {} },\n textAlign: n[\":block/text-align\"] || \"left\",\n children: (n[\":block/children\"] || [])\n .sort((a, b) => (a[\":block/order\"] || 0) - (b[\":block/order\"] || 0))\n .map(formatRoamNode),\n parents: (n[\":block/parents\"] || []).map((n) => n?.[\":db/id\"] || 0),\n };\n};\n\nconst getFullTreeByParentUid = (uid: string): TreeNode =>\n formatRoamNode(\n window.roamAlphaAPI.pull(\n `[\n :block/string \n :node/title \n :block/uid \n :block/order \n :block/heading \n :block/open \n :children/view-type\n :block/text-align\n :edit/time \n :block/props\n {:block/parents [:children/view-type]}\n {:block/children ...}\n ]`,\n [`:block/uid`, uid]\n )\n );\n\nexport default getFullTreeByParentUid;\n"]}
package/types/native.d.ts CHANGED
@@ -119,9 +119,7 @@ export declare type RoamPull = {
119
119
  "node/title"?: string;
120
120
  } & RoamNode;
121
121
  export declare type PullBlock = {
122
- ":attrs/lookup"?: ({
123
- ":db/id": number;
124
- } | PullBlock)[];
122
+ ":attrs/lookup"?: PullBlock[];
125
123
  ":entity/attrs"?: [
126
124
  {
127
125
  ":source": [":block/uid", string];
@@ -1 +1 @@
1
- {"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/types/native.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,4EAA4E","sourcesContent":["// emulating Datalog Grammar\n// https://docs.datomic.com/cloud/query/query-data-reference.html#or-clauses\n\nimport { ChangeEvent } from \"react\";\n\nexport type DatalogSrcVar = {\n type: \"src-var\";\n value: string;\n};\n\nexport type DatalogVariable = {\n type: \"variable\";\n value: string;\n};\n\nexport type DatalogAndClause = {\n type: \"and-clause\";\n clauses: DatalogClause[];\n};\n\nexport type DatalogExpressionClause =\n | DatalogDataPattern\n | DatalogPredExpr\n | DatalogFnExpr\n | DatalogRuleExpr;\n\nexport type DatalogRuleExpr = {\n type: \"rule-expr\";\n srcVar?: DatalogSrcVar;\n ruleName: DatalogRuleName;\n arguments: DatalogArgument[];\n};\n\nexport type DatalogNotClause = {\n type: \"not-clause\";\n srcVar?: DatalogSrcVar;\n clauses: DatalogClause[];\n};\n\nexport type DatalogNotJoinClause = {\n type: \"not-join-clause\";\n srcVar?: DatalogSrcVar;\n variables: DatalogVariable[];\n clauses: DatalogClause[];\n};\n\nexport type DatalogOrClause = {\n type: \"or-clause\";\n srcVar?: DatalogSrcVar;\n clauses: DatalogClause[];\n};\n\nexport type DatalogOrJoinClause = {\n type: \"or-join-clause\";\n srcVar?: DatalogSrcVar;\n variables: DatalogVariable[];\n clauses: DatalogClause[];\n};\n\nexport type DatalogClause =\n | DatalogNotClause\n | DatalogOrJoinClause\n | DatalogExpressionClause\n | DatalogOrClause\n | DatalogNotJoinClause\n | DatalogAndClause;\n\nexport type DatalogDataPattern = {\n type: \"data-pattern\";\n srcVar?: DatalogSrcVar;\n arguments: DatalogArgument[];\n};\n\nexport type DatalogArgument =\n | DatalogSrcVar\n | DatalogVariable\n | DatalogConstant\n | DatalogUnderscore;\n\nexport type DatalogConstant = {\n type: \"constant\";\n value: string;\n};\n\nexport type DatalogPredExpr = {\n type: \"pred-expr\";\n pred:\n | \"<\"\n | \">\"\n | \"re-matches\"\n | \"re-find\"\n | \"clojure.string/includes?\"\n | \"clojure.string/ends-with?\"\n | \"clojure.string/starts-with?\";\n arguments: DatalogArgument[];\n};\n\nexport type DatalogFnExpr = {\n type: \"fn-expr\";\n fn: \"re-pattern\" | \"get\";\n arguments: DatalogArgument[];\n binding: DatalogBinding;\n};\n\nexport type DatalogBinding =\n | DatalogBindScalar\n | DatalogBindTuple\n | DatalogBindColl\n | DatalogBindRel;\n\nexport type DatalogBindScalar = {\n type: \"bind-scalar\";\n variable: DatalogVariable;\n};\nexport type DatalogBindTuple = {\n type: \"bind-tuple\";\n args: (DatalogVariable | DatalogUnderscore)[];\n};\nexport type DatalogBindColl = {\n type: \"bind-col\";\n variable: DatalogVariable;\n};\n\nexport type DatalogBindRel = {\n type: \"bind-rel\";\n args: (DatalogVariable | DatalogUnderscore)[];\n};\n\nexport type DatalogUnderscore = {\n type: \"underscore\";\n value: \"_\";\n};\n\nexport type DatalogRuleName = {\n type: \"rulename\";\n value: string;\n};\n\nexport type RoamBasicBlock = {\n string: string;\n uid: string;\n};\n\nexport type RoamBasicPage = { title: string; uid: string };\n\nexport type RoamBasicNode = {\n text: string;\n uid: string;\n children: RoamBasicNode[];\n};\n\nexport type RoamPull = {\n \"block/children\"?: RoamNode[];\n \"block/heading\"?: number;\n \"block/open\"?: boolean;\n \"block/order\"?: number;\n \"block/page\"?: RoamNode;\n \"block/parents\"?: RoamNode[];\n \"block/refs\"?: RoamNode[];\n \"block/string\"?: string;\n \"block/uid\"?: string;\n \"children/view-type\"?: `:${ViewType}`;\n \"create/time\"?: number;\n \"create/user\"?: RoamNode;\n \"edit/time\"?: number;\n \"edit/user\"?: RoamNode;\n \"log/id\"?: number;\n \"node/title\"?: string;\n} & RoamNode;\n\nexport type PullBlock = {\n \":attrs/lookup\"?: ({ \":db/id\": number } | PullBlock)[];\n \":entity/attrs\"?: [\n { \":source\": [\":block/uid\", string]; \":value\": [\":block/uid\", string] },\n { \":source\": [\":block/uid\", string]; \":value\": [\":block/uid\", string] },\n {\n \":source\": [\":block/uid\", string];\n \":value\": string | [\":block/uid\", string];\n }\n ][];\n \":block/children\"?: PullBlock[];\n \":block/heading\"?: number;\n \":block/open\"?: boolean;\n \":block/order\"?: number;\n \":block/page\"?: { \":db/id\": number };\n \":block/parents\"?: PullBlock[];\n \":block/props\"?: {\n \":image-size\"?: {\n [p: string]: {\n \":height\": number;\n \":width\": number;\n };\n };\n \":iframe\"?: {\n [p: string]: {\n \":size\": {\n \":height\": number;\n \":width\": number;\n };\n };\n };\n [k: `:roamjs-${string}`]: Record<string, unknown>;\n };\n \":block/refs\"?: { \":db/id\": number }[];\n \":block/string\"?: string;\n \":block/view-type\"?: `:${BlockViewType}`;\n \":block/text-align\"?: TextAlignment;\n \":block/uid\"?: string;\n \":children/view-type\"?: `:${ViewType}`;\n \":create/time\"?: number;\n \":create/user\"?: { \":db/id\": number };\n \":edit/time\"?: number;\n \":edit/user\"?: { \":db/id\": number };\n \":db/id\"?: number;\n \":log/id\"?: number;\n \":node/title\"?: string;\n \":user/display-name\"?: string;\n \":user/display-page\"?: { \":db/id\": number };\n \":user/settings\"?: {\n \":namespace-options\": [\":none\", \":partial\", \":full\"];\n \":link-brackets?\": boolean;\n \":showing-inline-references?\": boolean;\n \":right-sidebar-pinned\": {\n [uuid: string]: SidebarWindow;\n };\n \":showing-own-icons?\": boolean;\n \":showing-user-icons?\": boolean;\n \":first-day-of-week\"?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n };\n \":user/uid\"?: string;\n \":user/email\"?: string;\n};\n\nexport type RoamPullResult = RoamPull | null;\n\nexport type ViewType = \"document\" | \"bullet\" | \"numbered\";\n\nexport type BlockViewType =\n | \"tabs\"\n | \"outline\"\n | \"horizontal\"\n | \"popout\"\n | \"comment\"\n | \"side\"\n | \"vertical\";\n\nexport type TextAlignment = \"left\" | \"center\" | \"right\" | \"justify\";\n\nexport type RoamBlock = {\n attrs?: { source: string[] }[][];\n children?: { id: number }[];\n id?: number;\n string?: string;\n title?: string;\n time?: number;\n uid?: string;\n order?: number;\n \"view-type\"?: ViewType;\n};\n\nexport type RoamError = {\n raw: string;\n \"status-code\": number;\n};\n\nexport type TreeNode = {\n text: string;\n order: number;\n children: TreeNode[];\n parents: number[];\n uid: string;\n heading: number;\n open: boolean;\n viewType: ViewType;\n editTime: Date;\n textAlign: TextAlignment;\n props: {\n imageResize: {\n [link: string]: {\n height: number;\n width: number;\n };\n };\n iframe: {\n [link: string]: {\n height: number;\n width: number;\n };\n };\n };\n};\n\nexport type TextNode = {\n text: string;\n children: TextNode[];\n};\n\nexport type InputTextNode = {\n text: string;\n children?: InputTextNode[];\n uid?: string;\n heading?: number;\n textAlign?: TextAlignment;\n viewType?: ViewType;\n open?: boolean;\n props?: Record<string, unknown>;\n};\n\ntype PlusType = [number, string];\n\nexport type RoamNode = { \"db/id\": number };\n\nexport type RoamQuery = RoamPull & {\n \"block/graph\"?: RoamNode;\n \"node/graph+title\"?: PlusType;\n \"block/graph+uid\"?: PlusType;\n \"node/graph\"?: RoamNode;\n \"edit/email\"?: string;\n \"entity/graph\"?: RoamNode;\n};\n\nexport type RoamQueryResult = number & RoamQuery;\n\nexport type ClientParams = {\n action:\n | \"pull\"\n | \"q\"\n | \"create-block\"\n | \"update-block\"\n | \"create-page\"\n | \"move-block\"\n | \"delete-block\"\n | \"delete-page\"\n | \"update-page\";\n selector?: string;\n uid?: string;\n query?: string;\n inputs?: string[];\n} & ActionParams;\n\nexport type ActionParams = {\n location?: {\n \"parent-uid\": string;\n order: number;\n };\n block?: {\n string?: string;\n uid?: string;\n open?: boolean;\n heading?: number;\n \"text-align\"?: TextAlignment;\n \"children-view-type\"?: ViewType;\n props?: Record<string, unknown>;\n };\n page?: {\n title?: string;\n uid?: string;\n };\n};\n\nexport type WriteAction = (a: ActionParams) => Promise<void>;\n\nexport type UserSettings = {\n \"global-filters\": {\n includes: string[];\n removes: string[];\n };\n};\n\ntype SidebarWindowType =\n | SidebarBlockWindow\n | SidebarMentionsWindow\n | SidebarGraphWindow\n | SidebarOutlineWindow;\n\nexport type SidebarWindowInput = {\n \"block-uid\": string;\n type: SidebarWindowType[\"type\"];\n};\n\ntype SidebarBlockWindow = {\n type: \"block\";\n \"block-uid\": string;\n};\n\ntype SidebarOutlineWindow = {\n type: \"outline\";\n \"page-uid\": string;\n};\n\ntype SidebarMentionsWindow = {\n type: \"mentions\";\n \"mentions-uid\": string;\n};\n\ntype SidebarGraphWindow = {\n type: \"graph\";\n // \"page-uid\": string; Currently not working despite documentation\n \"block-uid\": string;\n};\n\nexport type SidebarAction = (action: {\n window: SidebarWindowInput;\n}) => Promise<void>;\n\nexport type SidebarWindow = {\n \"collapsed?\": boolean;\n order: number;\n \"pinned?\": boolean;\n \"window-id\": string;\n} & SidebarWindowType;\n\nexport type AddPullWatch = (\n pullPattern: string,\n entityId: string,\n callback: (before: PullBlock | null, after: PullBlock | null) => void\n) => boolean;\n\ntype ButtonAction = {\n type: \"button\";\n onClick?: (e: MouseEvent) => void;\n content: string;\n};\n\ntype SwitchAction = {\n type: \"switch\";\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n};\n\ntype InputAction = {\n type: \"input\";\n placeholder: string;\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n};\n\ntype SelectAction = {\n type: \"select\";\n items: string[];\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n};\n\ntype CustomAction = {\n type: \"reactComponent\";\n component: React.FC;\n};\n\nexport type Action =\n | ButtonAction\n | SwitchAction\n | InputAction\n | SelectAction\n | CustomAction;\n\ntype PanelConfig = {\n tabTitle: string;\n settings: {\n id: string;\n name: string;\n description: string;\n action: Action;\n }[];\n};\n\nexport type AddCommandOptions = {\n label: string;\n callback: () => void;\n disableHotkey?: boolean;\n defaultHotkey?: string | string[];\n};\n\ntype RemoveCommandOptions = {\n label: string;\n};\n\nexport type OnloadArgs = {\n extensionAPI: {\n settings: {\n get: (k: string) => unknown;\n getAll: () => Record<string, unknown>;\n panel: {\n create: (c: PanelConfig) => void;\n };\n set: (k: string, v: unknown) => Promise<void>;\n };\n ui: {\n commandPalette: {\n addCommand: (c: AddCommandOptions) => Promise<void>;\n removeCommand: (c: RemoveCommandOptions) => Promise<void>;\n };\n };\n };\n extension: {\n version: string;\n };\n};\n"]}
1
+ {"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/types/native.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,4EAA4E","sourcesContent":["// emulating Datalog Grammar\n// https://docs.datomic.com/cloud/query/query-data-reference.html#or-clauses\n\nimport { ChangeEvent } from \"react\";\n\nexport type DatalogSrcVar = {\n type: \"src-var\";\n value: string;\n};\n\nexport type DatalogVariable = {\n type: \"variable\";\n value: string;\n};\n\nexport type DatalogAndClause = {\n type: \"and-clause\";\n clauses: DatalogClause[];\n};\n\nexport type DatalogExpressionClause =\n | DatalogDataPattern\n | DatalogPredExpr\n | DatalogFnExpr\n | DatalogRuleExpr;\n\nexport type DatalogRuleExpr = {\n type: \"rule-expr\";\n srcVar?: DatalogSrcVar;\n ruleName: DatalogRuleName;\n arguments: DatalogArgument[];\n};\n\nexport type DatalogNotClause = {\n type: \"not-clause\";\n srcVar?: DatalogSrcVar;\n clauses: DatalogClause[];\n};\n\nexport type DatalogNotJoinClause = {\n type: \"not-join-clause\";\n srcVar?: DatalogSrcVar;\n variables: DatalogVariable[];\n clauses: DatalogClause[];\n};\n\nexport type DatalogOrClause = {\n type: \"or-clause\";\n srcVar?: DatalogSrcVar;\n clauses: DatalogClause[];\n};\n\nexport type DatalogOrJoinClause = {\n type: \"or-join-clause\";\n srcVar?: DatalogSrcVar;\n variables: DatalogVariable[];\n clauses: DatalogClause[];\n};\n\nexport type DatalogClause =\n | DatalogNotClause\n | DatalogOrJoinClause\n | DatalogExpressionClause\n | DatalogOrClause\n | DatalogNotJoinClause\n | DatalogAndClause;\n\nexport type DatalogDataPattern = {\n type: \"data-pattern\";\n srcVar?: DatalogSrcVar;\n arguments: DatalogArgument[];\n};\n\nexport type DatalogArgument =\n | DatalogSrcVar\n | DatalogVariable\n | DatalogConstant\n | DatalogUnderscore;\n\nexport type DatalogConstant = {\n type: \"constant\";\n value: string;\n};\n\nexport type DatalogPredExpr = {\n type: \"pred-expr\";\n pred:\n | \"<\"\n | \">\"\n | \"re-matches\"\n | \"re-find\"\n | \"clojure.string/includes?\"\n | \"clojure.string/ends-with?\"\n | \"clojure.string/starts-with?\";\n arguments: DatalogArgument[];\n};\n\nexport type DatalogFnExpr = {\n type: \"fn-expr\";\n fn: \"re-pattern\" | \"get\";\n arguments: DatalogArgument[];\n binding: DatalogBinding;\n};\n\nexport type DatalogBinding =\n | DatalogBindScalar\n | DatalogBindTuple\n | DatalogBindColl\n | DatalogBindRel;\n\nexport type DatalogBindScalar = {\n type: \"bind-scalar\";\n variable: DatalogVariable;\n};\nexport type DatalogBindTuple = {\n type: \"bind-tuple\";\n args: (DatalogVariable | DatalogUnderscore)[];\n};\nexport type DatalogBindColl = {\n type: \"bind-col\";\n variable: DatalogVariable;\n};\n\nexport type DatalogBindRel = {\n type: \"bind-rel\";\n args: (DatalogVariable | DatalogUnderscore)[];\n};\n\nexport type DatalogUnderscore = {\n type: \"underscore\";\n value: \"_\";\n};\n\nexport type DatalogRuleName = {\n type: \"rulename\";\n value: string;\n};\n\nexport type RoamBasicBlock = {\n string: string;\n uid: string;\n};\n\nexport type RoamBasicPage = { title: string; uid: string };\n\nexport type RoamBasicNode = {\n text: string;\n uid: string;\n children: RoamBasicNode[];\n};\n\nexport type RoamPull = {\n \"block/children\"?: RoamNode[];\n \"block/heading\"?: number;\n \"block/open\"?: boolean;\n \"block/order\"?: number;\n \"block/page\"?: RoamNode;\n \"block/parents\"?: RoamNode[];\n \"block/refs\"?: RoamNode[];\n \"block/string\"?: string;\n \"block/uid\"?: string;\n \"children/view-type\"?: `:${ViewType}`;\n \"create/time\"?: number;\n \"create/user\"?: RoamNode;\n \"edit/time\"?: number;\n \"edit/user\"?: RoamNode;\n \"log/id\"?: number;\n \"node/title\"?: string;\n} & RoamNode;\n\nexport type PullBlock = {\n \":attrs/lookup\"?: PullBlock[];\n \":entity/attrs\"?: [\n { \":source\": [\":block/uid\", string]; \":value\": [\":block/uid\", string] },\n { \":source\": [\":block/uid\", string]; \":value\": [\":block/uid\", string] },\n {\n \":source\": [\":block/uid\", string];\n \":value\": string | [\":block/uid\", string];\n }\n ][];\n \":block/children\"?: PullBlock[];\n \":block/heading\"?: number;\n \":block/open\"?: boolean;\n \":block/order\"?: number;\n \":block/page\"?: { \":db/id\": number };\n \":block/parents\"?: PullBlock[];\n \":block/props\"?: {\n \":image-size\"?: {\n [p: string]: {\n \":height\": number;\n \":width\": number;\n };\n };\n \":iframe\"?: {\n [p: string]: {\n \":size\": {\n \":height\": number;\n \":width\": number;\n };\n };\n };\n [k: `:roamjs-${string}`]: Record<string, unknown>;\n };\n \":block/refs\"?: { \":db/id\": number }[];\n \":block/string\"?: string;\n \":block/view-type\"?: `:${BlockViewType}`;\n \":block/text-align\"?: TextAlignment;\n \":block/uid\"?: string;\n \":children/view-type\"?: `:${ViewType}`;\n \":create/time\"?: number;\n \":create/user\"?: { \":db/id\": number };\n \":edit/time\"?: number;\n \":edit/user\"?: { \":db/id\": number };\n \":db/id\"?: number;\n \":log/id\"?: number;\n \":node/title\"?: string;\n \":user/display-name\"?: string;\n \":user/display-page\"?: { \":db/id\": number };\n \":user/settings\"?: {\n \":namespace-options\": [\":none\", \":partial\", \":full\"];\n \":link-brackets?\": boolean;\n \":showing-inline-references?\": boolean;\n \":right-sidebar-pinned\": {\n [uuid: string]: SidebarWindow;\n };\n \":showing-own-icons?\": boolean;\n \":showing-user-icons?\": boolean;\n \":first-day-of-week\"?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n };\n \":user/uid\"?: string;\n \":user/email\"?: string;\n};\n\nexport type RoamPullResult = RoamPull | null;\n\nexport type ViewType = \"document\" | \"bullet\" | \"numbered\";\n\nexport type BlockViewType =\n | \"tabs\"\n | \"outline\"\n | \"horizontal\"\n | \"popout\"\n | \"comment\"\n | \"side\"\n | \"vertical\";\n\nexport type TextAlignment = \"left\" | \"center\" | \"right\" | \"justify\";\n\nexport type RoamBlock = {\n attrs?: { source: string[] }[][];\n children?: { id: number }[];\n id?: number;\n string?: string;\n title?: string;\n time?: number;\n uid?: string;\n order?: number;\n \"view-type\"?: ViewType;\n};\n\nexport type RoamError = {\n raw: string;\n \"status-code\": number;\n};\n\nexport type TreeNode = {\n text: string;\n order: number;\n children: TreeNode[];\n parents: number[];\n uid: string;\n heading: number;\n open: boolean;\n viewType: ViewType;\n editTime: Date;\n textAlign: TextAlignment;\n props: {\n imageResize: {\n [link: string]: {\n height: number;\n width: number;\n };\n };\n iframe: {\n [link: string]: {\n height: number;\n width: number;\n };\n };\n };\n};\n\nexport type TextNode = {\n text: string;\n children: TextNode[];\n};\n\nexport type InputTextNode = {\n text: string;\n children?: InputTextNode[];\n uid?: string;\n heading?: number;\n textAlign?: TextAlignment;\n viewType?: ViewType;\n open?: boolean;\n props?: Record<string, unknown>;\n};\n\ntype PlusType = [number, string];\n\nexport type RoamNode = { \"db/id\": number };\n\nexport type RoamQuery = RoamPull & {\n \"block/graph\"?: RoamNode;\n \"node/graph+title\"?: PlusType;\n \"block/graph+uid\"?: PlusType;\n \"node/graph\"?: RoamNode;\n \"edit/email\"?: string;\n \"entity/graph\"?: RoamNode;\n};\n\nexport type RoamQueryResult = number & RoamQuery;\n\nexport type ClientParams = {\n action:\n | \"pull\"\n | \"q\"\n | \"create-block\"\n | \"update-block\"\n | \"create-page\"\n | \"move-block\"\n | \"delete-block\"\n | \"delete-page\"\n | \"update-page\";\n selector?: string;\n uid?: string;\n query?: string;\n inputs?: string[];\n} & ActionParams;\n\nexport type ActionParams = {\n location?: {\n \"parent-uid\": string;\n order: number;\n };\n block?: {\n string?: string;\n uid?: string;\n open?: boolean;\n heading?: number;\n \"text-align\"?: TextAlignment;\n \"children-view-type\"?: ViewType;\n props?: Record<string, unknown>;\n };\n page?: {\n title?: string;\n uid?: string;\n };\n};\n\nexport type WriteAction = (a: ActionParams) => Promise<void>;\n\nexport type UserSettings = {\n \"global-filters\": {\n includes: string[];\n removes: string[];\n };\n};\n\ntype SidebarWindowType =\n | SidebarBlockWindow\n | SidebarMentionsWindow\n | SidebarGraphWindow\n | SidebarOutlineWindow;\n\nexport type SidebarWindowInput = {\n \"block-uid\": string;\n type: SidebarWindowType[\"type\"];\n};\n\ntype SidebarBlockWindow = {\n type: \"block\";\n \"block-uid\": string;\n};\n\ntype SidebarOutlineWindow = {\n type: \"outline\";\n \"page-uid\": string;\n};\n\ntype SidebarMentionsWindow = {\n type: \"mentions\";\n \"mentions-uid\": string;\n};\n\ntype SidebarGraphWindow = {\n type: \"graph\";\n // \"page-uid\": string; Currently not working despite documentation\n \"block-uid\": string;\n};\n\nexport type SidebarAction = (action: {\n window: SidebarWindowInput;\n}) => Promise<void>;\n\nexport type SidebarWindow = {\n \"collapsed?\": boolean;\n order: number;\n \"pinned?\": boolean;\n \"window-id\": string;\n} & SidebarWindowType;\n\nexport type AddPullWatch = (\n pullPattern: string,\n entityId: string,\n callback: (before: PullBlock | null, after: PullBlock | null) => void\n) => boolean;\n\ntype ButtonAction = {\n type: \"button\";\n onClick?: (e: MouseEvent) => void;\n content: string;\n};\n\ntype SwitchAction = {\n type: \"switch\";\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n};\n\ntype InputAction = {\n type: \"input\";\n placeholder: string;\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n};\n\ntype SelectAction = {\n type: \"select\";\n items: string[];\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n};\n\ntype CustomAction = {\n type: \"reactComponent\";\n component: React.FC;\n};\n\nexport type Action =\n | ButtonAction\n | SwitchAction\n | InputAction\n | SelectAction\n | CustomAction;\n\ntype PanelConfig = {\n tabTitle: string;\n settings: {\n id: string;\n name: string;\n description: string;\n action: Action;\n }[];\n};\n\nexport type AddCommandOptions = {\n label: string;\n callback: () => void;\n disableHotkey?: boolean;\n defaultHotkey?: string | string[];\n};\n\ntype RemoveCommandOptions = {\n label: string;\n};\n\nexport type OnloadArgs = {\n extensionAPI: {\n settings: {\n get: (k: string) => unknown;\n getAll: () => Record<string, unknown>;\n panel: {\n create: (c: PanelConfig) => void;\n };\n set: (k: string, v: unknown) => Promise<void>;\n };\n ui: {\n commandPalette: {\n addCommand: (c: AddCommandOptions) => Promise<void>;\n removeCommand: (c: RemoveCommandOptions) => Promise<void>;\n };\n };\n };\n extension: {\n version: string;\n };\n};\n"]}
@@ -1,2 +1,2 @@
1
- declare const extractRef: (ref: string) => string;
1
+ declare const extractRef: (ref?: string) => string;
2
2
  export default extractRef;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const constants_1 = require("../dom/constants");
4
- const extractRef = (ref) => {
4
+ const extractRef = (ref = "") => {
5
5
  var _a;
6
6
  return ((_a = new RegExp(`(?:\\(\\()?${constants_1.BLOCK_REF_REGEX.source.slice(4, -4)}(?:\\)\\))?`).exec(ref)) === null || _a === void 0 ? void 0 : _a[1]) || ref;
7
7
  };
@@ -1 +1 @@
1
- {"version":3,"file":"extractRef.js","sourceRoot":"","sources":["../../src/util/extractRef.ts"],"names":[],"mappings":";;AAAA,gDAAmD;AAEnD,MAAM,UAAU,GAAG,CAAC,GAAW,EAAU,EAAE;;IACzC,OAAA,CAAA,MAAA,IAAI,MAAM,CACR,cAAc,2BAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,CAC/D,CAAC,IAAI,CAAC,GAAG,CAAC,0CAAG,CAAC,CAAC,KAAI,GAAG,CAAA;CAAA,CAAC;AAE1B,kBAAe,UAAU,CAAC","sourcesContent":["import { BLOCK_REF_REGEX } from \"../dom/constants\";\n\nconst extractRef = (ref: string): string =>\n new RegExp(\n `(?:\\\\(\\\\()?${BLOCK_REF_REGEX.source.slice(4, -4)}(?:\\\\)\\\\))?`\n ).exec(ref)?.[1] || ref;\n\nexport default extractRef;\n"]}
1
+ {"version":3,"file":"extractRef.js","sourceRoot":"","sources":["../../src/util/extractRef.ts"],"names":[],"mappings":";;AAAA,gDAAmD;AAEnD,MAAM,UAAU,GAAG,CAAC,GAAG,GAAG,EAAE,EAAU,EAAE;;IACtC,OAAA,CAAA,MAAA,IAAI,MAAM,CACR,cAAc,2BAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,CAC/D,CAAC,IAAI,CAAC,GAAG,CAAC,0CAAG,CAAC,CAAC,KAAI,GAAG,CAAA;CAAA,CAAC;AAE1B,kBAAe,UAAU,CAAC","sourcesContent":["import { BLOCK_REF_REGEX } from \"../dom/constants\";\n\nconst extractRef = (ref = \"\"): string =>\n new RegExp(\n `(?:\\\\(\\\\()?${BLOCK_REF_REGEX.source.slice(4, -4)}(?:\\\\)\\\\))?`\n ).exec(ref)?.[1] || ref;\n\nexport default extractRef;\n"]}