diff --git a/src/common/annotation-manager.js b/src/common/annotation-manager.js index 183d9210..66d9e75b 100644 --- a/src/common/annotation-manager.js +++ b/src/common/annotation-manager.js @@ -81,7 +81,7 @@ class AnnotationManager { this.render(); } - // + // 추가 시 post api 호출 addAnnotation(annotation) { console.log(annotation) if (this._readOnly) { diff --git a/src/common/components/view/selection-popup.js b/src/common/components/view/selection-popup.js index 7d8d8775..73a2953e 100644 --- a/src/common/components/view/selection-popup.js +++ b/src/common/components/view/selection-popup.js @@ -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}, '*') } diff --git a/src/common/reader.js b/src/common/reader.js index d3425e0a..c1803d6d 100644 --- a/src/common/reader.js +++ b/src/common/reader.js @@ -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() diff --git a/src/en-us.strings.js b/src/en-us.strings.js index b5ed7b39..85030925 100644 --- a/src/en-us.strings.js +++ b/src/en-us.strings.js @@ -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', diff --git a/src/index.dev.js b/src/index.dev.js index a1480268..0af76d6c 100644 --- a/src/index.dev.js +++ b/src/index.dev.js @@ -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' @@ -21,6 +22,7 @@ let reader let chatNoteList = [] +// 추가: iframe 연동 const receiveBasicInfo = async(e) => { if (e.data.workspaceId) { sessionStorage.setItem('workspaceId', e.data.workspaceId) @@ -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'); @@ -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, @@ -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 @@ -151,6 +149,7 @@ 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') @@ -158,6 +157,7 @@ async function createReader(paperId, paperItems) { 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}, '*')