Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight Entity #284

Merged
merged 29 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d515a07
Add basic highlight API
xypnox Nov 17, 2022
61f2ae7
Add types and highlightStoreConstructor v2
xypnox Nov 17, 2022
9153e2d
Fix store calls for adding, removing highlights
xypnox Nov 17, 2022
2e0ebfc
Use 2 as new version, retain old one for checking usage pattern
xypnox Nov 17, 2022
7e49a4b
Add highlight apis to background script
xypnox Nov 17, 2022
f1537f1
Change highlight structure, use store
xypnox Nov 18, 2022
a79fbff
Add determining which blocks to show highlight on
xypnox Nov 18, 2022
ff2119e
Fix delete highlight call (add workspace headers)
xypnox Nov 18, 2022
26861cf
Use highlightStore2, change flow to new highlights
xypnox Nov 18, 2022
f5672e8
Fix calls for addHighlight, split content
xypnox Nov 19, 2022
c3554e5
Fix highlight of url call from new store
xypnox Nov 19, 2022
7570133
Fix highlight store sync
xypnox Nov 19, 2022
996d667
Fix interfacing with highlighter, check before getting highlightmap
xypnox Nov 21, 2022
145f1d3
Highlight sourceUrl in blocks and serialization fixes
xypnox Nov 21, 2022
329690f
Show notes when edit/navigating to highlight
xypnox Nov 22, 2022
3610d8d
Fix deletion of a highlight and its content from notes
xypnox Nov 23, 2022
e91f27e
Add a link if it doesn't exist on highlight
xypnox Nov 23, 2022
25a8133
Fix styles for note links with highlights
xypnox Nov 23, 2022
0fe9ef4
Simplify saveIt
xypnox Nov 24, 2022
ce13d02
Fix analysis worker crash due to missing lic in captured
xypnox Nov 24, 2022
16c1885
Remove old stores and types
xypnox Nov 25, 2022
e3ad035
Remove old store and types
xypnox Nov 26, 2022
a94c128
Add delete blockid requests
xypnox Nov 26, 2022
167db0f
Convert to API class
xypnox Nov 26, 2022
34228d2
Fix sidebar styling
xypnox Nov 28, 2022
a5546ab
Fix fetching highlights
xypnox Nov 28, 2022
e5a1fc1
Fix drag handle animation of extension sidebar
xypnox Nov 28, 2022
42f6791
Remove old code and comments
xypnox Nov 28, 2022
b85994f
Changeset added
Nov 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove old stores and types
  • Loading branch information
xypnox committed Nov 26, 2022
commit 16c188593d79c90859479906fbf5276227db07f0
2 changes: 1 addition & 1 deletion apps/extension/src/Components/InternalEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useEditorStore } from '../Hooks/useEditorStore'
import { useHighlighter } from '../Hooks/useHighlighter'
import { useSaveChanges } from '../Hooks/useSaveChanges'
import { useSputlitContext, VisualState } from '../Hooks/useSputlitContext'
import { useHighlightStore, useHighlightStore2 } from '../Stores/useHighlightStore'
import { useHighlightStore2 } from '../Stores/useHighlightStore'
import { useSputlitStore } from '../Stores/useSputlitStore'
import { getDibbaText } from '../Utils/getDibbaText'
import { getSelectionHTML } from '../Utils/getSelectionHTML'
Expand Down
15 changes: 4 additions & 11 deletions apps/extension/src/Stores/useHighlightStore.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
import create from 'zustand'
import { persist } from 'zustand/middleware'

import { HighlightStore, HighlightStore2, highlightStoreConstructor, highlightStoreConstructor2 } from '@mexit/core'
import { HighlightStore2, highlightStoreConstructor2 } from '@mexit/core'

import { asyncLocalStorage } from '../Utils/chromeStorageAdapter'

// DEPRECATED
export const useHighlightStore = create<HighlightStore>(
persist(highlightStoreConstructor, {
name: 'highlights-store',
getStorage: () => asyncLocalStorage
})
)

export const useHighlightStore2 = create<HighlightStore2>(
persist(highlightStoreConstructor2, {
name: 'highlights-store-2',
getStorage: () => asyncLocalStorage
name: 'highlights-store',
getStorage: () => asyncLocalStorage,
version: 2
})
)
4 changes: 0 additions & 4 deletions apps/extension/src/Utils/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@ import {
directKeys,
DirectProperties,
directPropertyKeys,
ElementHighlightMetadata,
ElementHighlightMetadata2,
extractMetadata,
generateElementMetadata,
generateTempId,
mappedKeys,
mog,
PartialBy
} from '@mexit/core'

import { useAuthStore } from '../Hooks/useAuth'
Expand Down
12 changes: 3 additions & 9 deletions apps/webapp/src/Stores/useHighlightStore.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import create from 'zustand'
import { persist } from 'zustand/middleware'

import { HighlightStore, HighlightStore2, highlightStoreConstructor, highlightStoreConstructor2 } from '@mexit/core'

// DEPRECATED
export const useHighlightStore = create<HighlightStore>(
persist(highlightStoreConstructor, {
name: 'highlights-store'
})
)
import { HighlightStore2, highlightStoreConstructor2 } from '@mexit/core'

export const useHighlightStore2 = create<HighlightStore2>(
persist(highlightStoreConstructor2, {
name: 'highlights-store-2'
name: 'highlights-store',
version: 2
})
)
2 changes: 0 additions & 2 deletions apps/webapp/src/Utils/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import {
directKeys,
DirectProperties,
directPropertyKeys,
ElementHighlightMetadata,
ElementHighlightMetadata2,
extractMetadata,
generateElementMetadata,
generateTempId,
mappedKeys,
PartialBy
Expand Down
10 changes: 5 additions & 5 deletions libs/core/src/Stores/contentStoreConstructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface ContentStoreState {
setSaved: (saved: boolean) => void
removeContent: (nodeid: string) => void
getContent: (nodeid: string) => NodeContent
getContentFromLink: (url: string) => NodeContent[]
// getContentFromLink: (url: string) => NodeContent[]
setContent: (nodeid: string, content: NodeEditorContent, metadata?: NodeMetadata, internalUpdate?: boolean) => void
getAllMetadata: () => Record<string, NodeMetadata>
getMetadata: (nodeid: string) => NodeMetadata
Expand Down Expand Up @@ -75,10 +75,10 @@ export const contentStoreConstructor = (set, get) => ({
getContent: (nodeid) => {
return get().contents[nodeid]
},
getContentFromLink: (url) => {
const contents: Contents = get().contents
return Object.values(contents).filter((item) => item?.metadata?.elementMetadata?.sourceUrl === url)
},
// getContentFromLink: (url) => {
// const contents: Contents = get().contents
// return Object.values(contents).filter((item) => item?.metadata?.elementMetadata?.sourceUrl === url)
// },
removeContent: (nodeid) => {
const oldContent = get().contents
delete oldContent[nodeid]
Expand Down
89 changes: 0 additions & 89 deletions libs/core/src/Stores/highlightStoreConstructor.ts

This file was deleted.

4 changes: 2 additions & 2 deletions libs/core/src/Types/Editor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import HighlightSource from 'web-highlighter/dist/model/source'
import { ElementHighlightMetadata2 } from './Highlight'

import { ElementHighlightMetadata } from '../Utils/serializer'
import { AccessLevel } from './Mentions'

export interface Content {
Expand Down Expand Up @@ -32,7 +32,7 @@ export interface NodeMetadata {
lastEditedBy: string
updatedAt: number

elementMetadata: ElementHighlightMetadata
elementMetadata: ElementHighlightMetadata2
publicAccess?: boolean
iconUrl?: string
// The snippet ID with which all the children nodes should be populated
Expand Down
4 changes: 2 additions & 2 deletions libs/core/src/Types/Highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ IN STORE
"parentIndex": 2,
"textOffset": 355
},
"text": "The species is both terrestrial (ground-living) and arboreal (tree-living); it inhabits savannah, woodland, rocky slopes and in some regions, dense forest. It is diurnal and is known to prey on birds and small mammals. Over suitable surfaces, it can move at speeds up to 16km/h (10mph) for short distances. Adult black mambas have few natural predators.",
"text": "The species is both",
"id": "f0cda665-6660-47bd-99cd-46b48020e253"
},
"sourceUrl": "https://en.wikipedia.org/wiki/Black_mamba"
Expand All @@ -37,7 +37,7 @@ IN STORE
"parentIndex": 56,
"textOffset": 60
},
"text": "Village pump – Forum for discussions about Wikipedia itself, including policies and technical issues.\nSite news – Sources of news about Wikipedia and the broader Wikimedia movement.\nTeahouse – Ask basic questions about using or editing Wikipedia.\nHelp desk – Ask questions about using or editing Wikipedia.\nReference desk – Ask research questions about encyclopedic topics.\nContent portals – A unique way to navigate the encyclopedia.",
"text": "Village pump – Forum for",
"id": "63023772-32e9-4d85-b0e8-933cd429eab3"
},
"sourceUrl": "https://en.wikipedia.org/wiki/Main_Page"
Expand Down
17 changes: 0 additions & 17 deletions libs/core/src/Utils/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,6 @@ export const mappedKeys = {

export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>

export interface HighlightMetaBlock {
parentTagName: string
parentIndex: number
textOffset: number
}

export interface ElementHighlightMetadata {
type: string
saveableRange: {
startMeta: HighlightMetaBlock
endMeta: HighlightMetaBlock
text: string
id: string
}
sourceUrl: string
}

export const generateElementMetadata = (elementMetadata: ElementHighlightMetadata2): ElementHighlightMetadata2 => {
// delete elementMetadata.saveableRange['__isHighlightSource']
return {
Expand Down
1 change: 0 additions & 1 deletion libs/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export * from './Stores/commentStore'
export * from './Stores/contentStoreConstructor'
export * from './Stores/dataStoreConstructor'
export * from './Stores/descriptionStoreConstructor'
export * from './Stores/highlightStoreConstructor'
export * from './Stores/highlightStoreConstructor2'
export * from './Stores/linkStoreConstructor'
export * from './Stores/reactionStore'
Expand Down