Skip to content

Commit

Permalink
Highlight occurance in search results
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustem Mussabekov committed Apr 9, 2024
1 parent d68ad9a commit 76f14be
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 15 deletions.
7 changes: 5 additions & 2 deletions src/co/bookmarks/item/info/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import React from 'react'
import t from '~t'

import { ShortDate } from '~modules/format/date'
import SafeHtml from '~co/common/safeHtml'
import { Link } from 'react-router-dom'
import Icon, { Avatar } from '~co/common/icon'
import Path from './path'

export default function BookmarkItemInfo(props) {
const { className='', creatorRef, domain, type, link, created, reparse, collectionId, spaceId, important, broken, duplicate, cache } = props
const { className='', creatorRef, domain, type, link, created, reparse, collectionId, spaceId, important, broken, duplicate, cache, highlight } = props

return (
<div className={s.info+' '+className}>
Expand Down Expand Up @@ -58,7 +59,9 @@ export default function BookmarkItemInfo(props) {
<section data-inline><Icon name={type} size='micro' /></section>
) : null}

<section>{domain}</section>
{highlight.link ? (
<SafeHtml tagName='section' html={highlight.link} />
) : <section>{domain}</section>}

<section><ShortDate date={created}/></section>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/co/bookmarks/item/info/index.module.styl
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
}

&:not(:last-child):not([data-inline]) {
padding-right: var(--padding-large)
padding-right: var(--padding-medium)

&:after {
position: absolute
right: 0
top: 0
content: '·'
width: var(--padding-large)
width: var(--padding-medium)
text-align: center
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/co/bookmarks/item/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ export default function BookmarkItemView(props) {

<div className={s.description}>
{note ? (
<SafeMarkdown className={s.note} markdown={note} />
) : null}
{excerpt ? (
<SafeHtml className={s.excerpt} html={highlight.excerpt || excerpt} />
<SafeMarkdown className={s.note} markdown={highlight.note || note} />
) : null}
{highlight.body || highlight.excerpt ? (
<SafeHtml className={s.body} html={highlight.body || highlight.excerpt} />
) : (
excerpt ? (
<SafeHtml className={s.excerpt} html={excerpt} />
) : null
)}
<Reminder reminder={reminder} />
<Highlights className={s.highlights} highlights={highlights} />
<Tags tags={tags} spaceId={spaceId} />
Expand Down
11 changes: 8 additions & 3 deletions src/co/bookmarks/item/view.module.styl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
align-content: flex-start
grid-gap: calc(var(--padding-mini) / 2)

em {
font-weight: bold
font-style: normal
}

.title {
font-weight: 500
font-size: var(--title-font-size)
Expand Down Expand Up @@ -104,7 +109,7 @@
}
}

.title, .excerpt, .note {
.title, .excerpt, .note, .body {
display: -webkit-box
line-clamp: 5
-webkit-line-clamp: 5
Expand All @@ -113,7 +118,7 @@
overflow: clip
}

.title, .excerpt {
.title, .excerpt, .body {
white-space: pre
white-space: pre-wrap
}
Expand Down Expand Up @@ -211,7 +216,7 @@
padding: calc(var(--padding-medium) - var(--padding-mini))
}

.title, .excerpt {
.title, .excerpt, .body {
line-clamp: 3;
-webkit-line-clamp: 3;
}
Expand Down
4 changes: 2 additions & 2 deletions src/co/common/header/index.module.styl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.header {
app-region: drag
-webkit-app-region: drag
//app-region: drag
//-webkit-app-region: drag
display: flex
flex-direction: row
align-items: center
Expand Down
2 changes: 1 addition & 1 deletion src/data/helpers/bookmarks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const normalizeBookmarks = (items=[], options)=>{
meta[item._id] = normalizeMeta(item)

if (item.highlight)
highlight[item._id] = _.pick(item.highlight, 'title', 'excerpt', 'note', 'body')
highlight[item._id] = _.pick(item.highlight, 'title', 'excerpt', 'note', 'body', 'link')

ids.push(item._id)
})
Expand Down
2 changes: 1 addition & 1 deletion src/data/modules/persistConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (RAINDROP_ENVIRONMENT == 'browser')
else
storage = require('@react-native-async-storage/async-storage').default

const version = 36
const version = 37

export default {
key: 'primary',
Expand Down

0 comments on commit 76f14be

Please sign in to comment.