Skip to content

Commit

Permalink
Feat: add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
coddingyun committed Oct 13, 2023
1 parent b44a21a commit df6a8a1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/common/annotation-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class AnnotationManager {
this.render();
}

//
// 추가 시 post api 호출
addAnnotation(annotation) {
console.log(annotation)
if (this._readOnly) {
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/view/selection-popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ function SelectionPopup(props) {
props.onAddAnnotation({ ...props.params.annotation, color });
}

// Push to Chat 버튼 클릭시 드래그한 텍스트 전송
function handleAddToNote() {
// props.onAddToNote([props.params.annotation]);
// console.log("check!!!", props.params.annotation.text)
window.parent.postMessage({selectedText: props.params.annotation.text}, '*')
}

Expand Down
2 changes: 2 additions & 0 deletions src/common/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,14 @@ class Reader {
}
}

// 추가: 연두 서비스에서 답변 내용 export 시 조테로 뷰어에 노트 업데이트
updateSettings(annotation) {
if (typeof annotation !== 'undefined') {
this._annotationManager.addAnnotation(annotation)
}
}

// 추가: 탭 변경시
changePaper(annotation) {
this._annotationManager._annotations = annotation
this._annotationManager.render()
Expand Down
2 changes: 1 addition & 1 deletion src/en-us.strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default {
'pdfReader.draw': 'Draw',
'pdfReader.erase': 'Erase',
'pdfReader.pickColor': 'Pick a Color',
'pdfReader.addToNote': 'Chat with AI',
'pdfReader.addToNote': 'Push to Chat',
'pdfReader.zoomIn': 'Zoom In',
'pdfReader.zoomOut': 'Zoom Out',
'pdfReader.zoomReset': 'Reset Zoom',
Expand Down
16 changes: 8 additions & 8 deletions src/index.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { putApi, deleteApi } from './custom/utils/apiFetch';

window.dev = true;

// 추가: api 연결
let api = '';
if (process.env.NODE_ENV === 'development'){
api = 'https://be.yeondoo.net'
Expand All @@ -21,6 +22,7 @@ let reader

let chatNoteList = []

// 추가: iframe 연동
const receiveBasicInfo = async(e) => {
if (e.data.workspaceId) {
sessionStorage.setItem('workspaceId', e.data.workspaceId)
Expand Down Expand Up @@ -70,17 +72,13 @@ const receiveBasicInfo = async(e) => {

//createReader(paperId, [...paperItemsWithTag, e.data.chatNote])
}
// if (e.data.needPaperIndex) {
// reader.
// window.parent.postMessage({pageIndex: 0}, '*')
// }
}

window.addEventListener("message", receiveBasicInfo);

window.parent.postMessage({isPdfRender: true}, '*')


// 변경: createReader 파라미터 추가
async function createReader(paperId, paperItems) {
if (window._reader) {
throw new Error('Reader is already initialized');
Expand All @@ -98,10 +96,9 @@ async function createReader(paperId, paperItems) {
else if (type === 'snapshot') {
demo = snapshot;
}
// 변경: pdf 주소 받기
let res = await fetch(`https://browse.arxiv.org/pdf/${paperId}.pdf`);
// console.log("hihi",Number(sessionStorage.getItem('workspaceId')))
// console.log("location!!",window.location)
// console.log(window.location)

reader = new Reader({
type,
localizedStrings: strings,
Expand All @@ -126,6 +123,7 @@ async function createReader(paperId, paperItems) {
onAddToNote() {
alert('Add annotations to the current note');
},
// 추가: save시 put api 호출
onSaveAnnotations: function (annotations) {
const payload = {...annotations[0]}
delete payload.tags
Expand All @@ -151,13 +149,15 @@ async function createReader(paperId, paperItems) {
})
console.log('Save annotations', annotations);
},
// 추가: 삭제 시 delete api 호출
onDeleteAnnotations: function (ids) {
const paperId = sessionStorage.getItem('paperId')
const workspaceId = sessionStorage.getItem('workspaceId')

deleteApi(api, `/api/paper/item?paperId=${paperId}&workspaceId=${workspaceId}&itemId=${ids}`)
console.log('Delete annotations', JSON.stringify(ids));
},
// 추가: view가 업데이트 될 때마다 pageIndex 보내주기
onChangeViewState: function (state, primary) {
if (state){
window.parent.postMessage({pageIndex: state.pageIndex}, '*')
Expand Down

0 comments on commit df6a8a1

Please sign in to comment.