mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
update highlight entity
This commit is contained in:
parent
06000264d2
commit
5f0e1af285
8 changed files with 100 additions and 24 deletions
|
|
@ -3,12 +3,21 @@ import {
|
|||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
ManyToMany,
|
||||
OneToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm'
|
||||
import { User } from './user'
|
||||
import { Label } from './label'
|
||||
import { Page } from './page'
|
||||
import { User } from './user'
|
||||
|
||||
export enum HighlightType {
|
||||
Highlight = 'HIGHLIGHT',
|
||||
Redaction = 'REDACTION', // allowing people to remove text from the page
|
||||
Note = 'NOTE', // allowing people to add a note at the document level
|
||||
}
|
||||
|
||||
@Entity({ name: 'highlight' })
|
||||
export class Highlight {
|
||||
|
|
@ -52,4 +61,30 @@ export class Highlight {
|
|||
|
||||
@Column('timestamp')
|
||||
sharedAt?: Date
|
||||
|
||||
@Column('real')
|
||||
highlightPositionPercent!: number
|
||||
|
||||
@Column('integer')
|
||||
highlightPositionAnchorIndex!: number
|
||||
|
||||
@Column('enum', {
|
||||
enum: HighlightType,
|
||||
default: HighlightType.Highlight,
|
||||
})
|
||||
highlightType!: HighlightType
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
html?: string | null
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
color?: string | null
|
||||
|
||||
@ManyToMany(() => Label, { eager: true })
|
||||
@JoinTable({
|
||||
name: 'entity_labels',
|
||||
joinColumn: { name: 'highlight_id' },
|
||||
inverseJoinColumn: { name: 'label_id' },
|
||||
})
|
||||
labels?: Label[]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,7 +165,11 @@ export class LibraryItem {
|
|||
subscription?: Subscription
|
||||
|
||||
@ManyToMany(() => Label, { eager: true })
|
||||
@JoinTable()
|
||||
@JoinTable({
|
||||
name: 'entity_labels',
|
||||
joinColumn: { name: 'library_item_id' },
|
||||
inverseJoinColumn: { name: 'label_id' },
|
||||
})
|
||||
labels?: Label[]
|
||||
|
||||
@Column('enum', { enum: DirectionalityType, default: DirectionalityType.LTR })
|
||||
|
|
|
|||
14
packages/db/migrations/0119.do.entity_labels.sql
Executable file
14
packages/db/migrations/0119.do.entity_labels.sql
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
-- Type: DO
|
||||
-- Name: entity_labels
|
||||
-- Description: Create table entity_labels
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE omnivore.entity_labels (
|
||||
library_item_id uuid REFERENCES omnivore.library_item(id) ON DELETE CASCADE,
|
||||
highlight_id uuid REFERENCES omnivore.highlight(id) ON DELETE CASCADE,
|
||||
label_id uuid NOT NULL REFERENCES omnivore.labels(id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (library_item_id, highlight_id, label_id)
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
-- Type: DO
|
||||
-- Name: library_item_labels
|
||||
-- Description: Create table library_item_labels
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE omnivore.library_item_labels (
|
||||
library_item_id uuid NOT NULL REFERENCES omnivore.library_item(id) ON DELETE CASCADE,
|
||||
label_id uuid NOT NULL REFERENCES omnivore.labels(id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (library_item_id, label_id)
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
9
packages/db/migrations/0119.undo.entity_labels.sql
Executable file
9
packages/db/migrations/0119.undo.entity_labels.sql
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
-- Type: UNDO
|
||||
-- Name: entity_labels
|
||||
-- Description: Create table entity_labels
|
||||
|
||||
BEGIN;
|
||||
|
||||
DROP TABLE omnivore.entity_labels;
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
-- Type: UNDO
|
||||
-- Name: library_item_labels
|
||||
-- Description: Create table library_item_labels
|
||||
|
||||
BEGIN;
|
||||
|
||||
DROP TABLE omnivore.library_item_labels;
|
||||
|
||||
COMMIT;
|
||||
20
packages/db/migrations/0121.do.update_highlight.sql
Executable file
20
packages/db/migrations/0121.do.update_highlight.sql
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
-- Type: DO
|
||||
-- Name: update_highlight
|
||||
-- Description: Add fields to highlight table
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TYPE highlight_type AS ENUM (
|
||||
'HIGHLIGHT',
|
||||
'REDACTION',
|
||||
'NOTE'
|
||||
);
|
||||
|
||||
ALTER TABLE omnivore.highlight
|
||||
ADD COLUMN highlight_position_percent real NOT NULL DEFAULT 0,
|
||||
ADD COLUMN highlight_position_anchor_index integer NOT NULL DEFAULT 0,
|
||||
ADD COLUMN highlight_type highlight_type NOT NULL DEFAULT 'HIGHLIGHT',
|
||||
ADD COLUMN color text,
|
||||
ADD COLUMN html text;
|
||||
|
||||
COMMIT;
|
||||
16
packages/db/migrations/0121.undo.update_highlight.sql
Executable file
16
packages/db/migrations/0121.undo.update_highlight.sql
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
-- Type: UNDO
|
||||
-- Name: update_highlight
|
||||
-- Description: Add fields to highlight table
|
||||
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE omnivore.highlight
|
||||
DROP COLUMN html,
|
||||
DROP COLUMN color,
|
||||
DROP COLUMN highlight_type,
|
||||
DROP COLUMN highlight_position_anchor_index,
|
||||
DROP COLUMN highlight_position_percent;
|
||||
|
||||
DROP TYPE highlight_type;
|
||||
|
||||
COMMIT;
|
||||
Loading…
Reference in a new issue