Skip to content

Commit 41a727d

Browse files
committed
Merge remote-tracking branch 'origin/master' into roam-js
2 parents 3a01e1a + 7456f3d commit 41a727d

File tree

11 files changed

+16856
-1019
lines changed

11 files changed

+16856
-1019
lines changed

README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
Browser extension designed to improve your experience of using Roam Research
88

9+
---
10+
The development is supported by <a href="https://roam.garden/"> <img src="https://roam.garden/static/logo-2740b191a74245dc48ee30c68d5192aa.svg" height="50" /></a> - a service that allows you to publish your Roam notes as a beautiful static website (digital garden)
11+
12+
---
13+
914
## WalkThrough
1015

1116
[![Watch the video](https://img.youtube.com/vi/llP-3AqFGL8/maxresdefault.jpg)](https://youtu.be/llP-3AqFGL8)
@@ -23,9 +28,9 @@ You can create dates using [**natural language**](https://github.com/wanasit/chr
2328

2429
![](./media/fuzzy_date.gif)
2530

26-
Replace mode:
31+
Replace mode:
2732

28-
![](.media/fuzzy_date_replace.gif)
33+
![](./media/fuzzy_date_replace.gif)
2934

3035
You can also **increment or decrement dates**:
3136

package-lock.json

+16,772-1,000
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"cytoscape-cola": "^2.4.0",
2424
"dateformat": "^3.0.3",
2525
"immutable": "^4.0.0-rc.12",
26-
"lodash": "^4.17.19",
26+
"lodash": "^4.17.21",
2727
"react": "^16.12.0",
2828
"react-dom": "^16.12.0",
2929
"react-hotkeys": "^2.0.0",

src/manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "Roam Toolkit",
33
"author": "roam-unofficial",
4-
"version": "0.5.0",
4+
"version": "0.5.4",
55
"description": "Roam force multiplier",
66
"icons": {
77
"128": "assets/icon-128.png"
88
},
99
"content_security_policy": "script-src 'self'; object-src 'self'",
10-
"permissions": ["activeTab", "storage", "tabs", "clipboardRead", "clipboardWrite", "*://roamresearch.com/*"],
10+
"permissions": ["activeTab", "storage", "clipboardRead", "clipboardWrite", "*://roamresearch.com/*"],
1111
"manifest_version": 2,
1212
"background": {
1313
"scripts": ["background.js"],

src/ts/components/containers/Settings/Home.tsx

+26-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {Feature} from '../../../core/settings'
88
import {Checkbox} from '../../Checkbox'
99
import {WarningIcon} from '../../WarningIcon'
1010

11-
type HomeProps = { features: Feature[] }
11+
type HomeProps = {features: Feature[]}
1212
export const Home = ({features}: HomeProps) => {
1313
const dispatch = useDispatch()
1414

@@ -42,6 +42,13 @@ export const Home = ({features}: HomeProps) => {
4242
<HomeContainer>
4343
<Header>
4444
<img src={`../../../assets/logo-${theme}.png`} />
45+
<SupportedByContainer>
46+
{' '}
47+
Publish your Roam notes with
48+
<a href={'https://roam.garden'} target={'_blank'}>
49+
<InlineLogo src={`../../../assets/roam-garden.svg`} />
50+
</a>
51+
</SupportedByContainer>
4552
</Header>
4653
<FeaturesList>
4754
{features.map((feature: Feature) => (
@@ -59,8 +66,23 @@ export const Home = ({features}: HomeProps) => {
5966

6067
const HomeContainer = styled('div')``
6168

69+
const InlineLogo = styled.img`
70+
display: inline;
71+
height: 30px;
72+
margin-left: 0.5em;
73+
`
74+
75+
const SupportedByContainer = styled.div`
76+
display: flex;
77+
align-items: center;
78+
justify-content: center;
79+
`
80+
6281
const Header = styled('div')`
63-
padding: 20px 0 20px 24px;
82+
padding-top: 20px;
83+
padding-right: 0;
84+
padding-left: 24px;
85+
padding-bottom: 10px;
6486
border-bottom: 1px solid #989898;
6587
`
6688

@@ -96,6 +118,7 @@ const FeatureListElement = styled('li')`
96118
color: #828282;
97119
transform: translateY(-50%);
98120
}
121+
99122
&:hover {
100123
&::after {
101124
color: #111111;
@@ -121,6 +144,7 @@ const FeatureNameContainer = styled('div')`
121144
122145
&:hover {
123146
cursor: pointer;
147+
124148
${FeatureName} {
125149
text-decoration: underline;
126150
}

src/ts/core/features/spatial-mode/spatial-container.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const getCytoscapeContainer = () => {
5656
pointer-events: none;
5757
}
5858
/* But make the actual content itself clickable */
59-
${Selectors.leftPanel}, .roam-topbar, ${PANEL_SELECTOR} {
59+
${Selectors.leftPanel}, ${Selectors.topBar}, ${PANEL_SELECTOR} {
6060
pointer-events: auto;
6161
}
6262

src/ts/core/features/vim-mode/commands/insert-commands.ts

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const insertBlockBefore = async () => {
2727
export const InsertCommands = [
2828
nmap('i', 'Click Selection', editBlock),
2929
nmap('a', 'Click Selection and Go-to End of Line', editBlockFromEnd),
30+
nmap('shift+a', 'Click Selection and Go-to End of Line', editBlockFromEnd),
3031
nmap('shift+o', 'Insert Block Before', insertBlockBefore),
3132
nmap('o', 'Insert Block After', insertBlockAfter),
3233
]

src/ts/core/features/vim-mode/hint-view.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,16 @@ Promise.all(HINT_IDS.map(hintCss)).then(cssClasses => {
5050

5151
export const updateVimHints = (block: HTMLElement) => {
5252
// button is for reference counts
53-
const links = block.querySelectorAll(
54-
`${Selectors.link}, ${Selectors.externalLink}, ${Selectors.checkbox}, ${Selectors.button}, ${Selectors.blockReference}`
55-
)
53+
const clickableSelectors = [
54+
Selectors.link,
55+
Selectors.externalLink,
56+
Selectors.checkbox,
57+
Selectors.button,
58+
Selectors.blockReference,
59+
Selectors.hiddenSection,
60+
]
61+
const links = block.querySelectorAll(clickableSelectors.join(', '))
62+
5663
links.forEach((link, i) => {
5764
link.classList.add(HINT_CSS_CLASS, hintCssClass(i))
5865
})

src/ts/core/features/vim-mode/vim-view.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ const SELECTED_BLOCK_CSS_CLASS = 'roam-toolkit-block-mode--highlight'
1616
injectStyle(
1717
`
1818
.${SELECTED_BLOCK_CSS_CLASS} {
19-
background-color: wheat;
19+
border-radius: 5px;
20+
background-color: #FFF3E2;
2021
}
2122
`,
2223
'roam-toolkit-block-mode'

src/ts/core/roam/references.ts

+29-6
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,38 @@ import {Selectors} from './selectors'
22
import {Mouse} from '../common/mouse'
33
import {BlockElement, RoamBlock} from '../features/vim-mode/roam/roam-block'
44

5+
function expandReference(
6+
wrapperSelector: string,
7+
breadcrumbSelector: string,
8+
getClickElement: (parent: HTMLElement) => HTMLElement | null
9+
) {
10+
const referenceItem = RoamBlock.selected().element?.closest(wrapperSelector + ',' + Selectors.inlineReference)
11+
const breadcrumbs = referenceItem?.querySelector(breadcrumbSelector + ',' + Selectors.zoomPath)
12+
13+
const clickElement = getClickElement(breadcrumbs as HTMLElement)
14+
if (!clickElement) return false
15+
16+
Mouse.leftClick(clickElement)
17+
return true
18+
}
19+
520
export const expandLastBreadcrumb = () => {
6-
const referenceItem = RoamBlock.selected().element?.closest(Selectors.referenceItem)
7-
const breadcrumbs = referenceItem?.querySelector(Selectors.breadcrumbsContainer)
21+
expandReference(
22+
Selectors.referenceItem,
23+
Selectors.breadcrumbsContainer,
24+
breadcrumbs => breadcrumbs.lastElementChild as HTMLElement
25+
)
826

9-
if (breadcrumbs?.lastElementChild) Mouse.leftClick(breadcrumbs.lastElementChild as HTMLElement)
27+
expandReference(Selectors.inlineReference, Selectors.zoomPath, breadcrumbs => {
28+
const nodes = breadcrumbs.querySelectorAll(Selectors.zoomItemContent)
29+
return nodes[nodes.length - 1] as HTMLElement
30+
})
1031
}
1132

1233
export const closePageReferenceView = () => {
13-
const referenceItem = RoamBlock.selected().element?.closest(Selectors.pageReferenceItem)
34+
const referenceItem = RoamBlock.selected().element?.closest(
35+
Selectors.pageReferenceItem + ',' + Selectors.inlineReference
36+
)
1437
const foldButton = referenceItem?.querySelector(Selectors.foldButton)
1538

1639
if (foldButton) Mouse.leftClick(foldButton as HTMLElement)
@@ -36,7 +59,7 @@ export const openParentPage = (shiftKey: boolean = false) => {
3659
return
3760
}
3861

39-
Mouse.leftClick(parentLink, { shiftKey })
62+
Mouse.leftClick(parentLink, {shiftKey})
4063
}
4164

4265
const getMentionsButton = (blockElement: BlockElement | null): HTMLElement | null => {
@@ -54,6 +77,6 @@ const getMentionsButton = (blockElement: BlockElement | null): HTMLElement | nul
5477
export const openMentions = (shiftKey: boolean = false) => {
5578
const mentionsButton = getMentionsButton(RoamBlock.selected().element)
5679
if (mentionsButton) {
57-
Mouse.leftClick(mentionsButton, { shiftKey })
80+
Mouse.leftClick(mentionsButton, {shiftKey})
5881
}
5982
}

src/ts/core/roam/selectors.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const Selectors = {
22
link: '.rm-page-ref',
3+
hiddenSection: '.rm-block__part--equals',
34
block: '.roam-block',
45
blockInput: '.rm-block-input',
56
blockContainer: '.roam-block-container',
@@ -18,7 +19,7 @@ export const Selectors = {
1819

1920
leftPanel: '.roam-sidebar-container',
2021

21-
topBar: '.roam-topbar',
22+
topBar: '.rm-topbar',
2223

2324
foldButton: '.rm-caret',
2425
highlight: '.block-highlight-blue',
@@ -29,6 +30,9 @@ export const Selectors = {
2930
checkbox: '.check-container',
3031
externalLink: 'a',
3132
referenceItem: '.rm-reference-item',
33+
inlineReference: '.rm-inline-reference',
34+
zoomPath: '.rm-zoom-path',
35+
zoomItemContent: '.rm-zoom-item-content',
3236
breadcrumbsContainer: '.zoom-mentions-view',
3337
pageReferenceItem: '.rm-ref-page-view',
3438
pageReferenceLink: '.rm-ref-page-view-title a span',

0 commit comments

Comments
 (0)