polar: add highlight colors

This commit is contained in:
Dima Gerasimov 2020-05-15 12:52:22 +01:00
parent 3d8002c8c9
commit 8277b33c18

View file

@ -65,6 +65,7 @@ class Highlight(NamedTuple):
selection: str selection: str
comments: Sequence[Comment] comments: Sequence[Comment]
tags: Sequence[str] tags: Sequence[str]
color: Optional[str] = None
Uid = str Uid = str
@ -106,10 +107,12 @@ class Loader:
notes = meta['notes'].zoom() notes = meta['notes'].zoom()
else: else:
notes = [] # TODO FIXME dict? notes = [] # TODO FIXME dict?
comments = meta['comments'].zoom() comments = list(meta['comments'].zoom().values()) if 'comments' in meta else []
meta['questions'].zoom() meta['questions'].zoom()
meta['flashcards'].zoom() meta['flashcards'].zoom()
highlights = meta['textHighlights'].zoom() highlights = meta['textHighlights'].zoom()
# TODO could be useful to at least add a meta bout area highlights/screens
meta['areaHighlights'].zoom() meta['areaHighlights'].zoom()
meta['screenshots'].zoom() meta['screenshots'].zoom()
meta['thumbnails'].zoom() meta['thumbnails'].zoom()
@ -122,7 +125,7 @@ class Loader:
# TODO how to make it nicer? # TODO how to make it nicer?
cmap: Dict[Hid, List[Comment]] = {} cmap: Dict[Hid, List[Comment]] = {}
vals = list(comments.values()) vals = list(comments)
for v in vals: for v in vals:
cid = v['id'].zoom() cid = v['id'].zoom()
v['guid'].zoom() v['guid'].zoom()
@ -168,7 +171,7 @@ class Loader:
h['notes'].consume() h['notes'].consume()
h['questions'].consume() h['questions'].consume()
h['flashcards'].consume() h['flashcards'].consume()
h['color'].consume() color = h['color'].zoom().value
h['images'].ignore() h['images'].ignore()
# TODO eh, quite excessive \ns... # TODO eh, quite excessive \ns...
text = h['text'].zoom()['TEXT'].zoom().value text = h['text'].zoom()['TEXT'].zoom().value
@ -179,6 +182,7 @@ class Loader:
selection=text, selection=text,
comments=tuple(comments), comments=tuple(comments),
tags=tuple(htags), tags=tuple(htags),
color=color,
) )
h.consume() h.consume()