Heading 1
\n\t\t// MLA9 Heading 1:Heading 1
\n\t\t// Turabian9 Heading 1:Heading 1
\n\t\tswitch(_referenceFormatTypeId){\n\t\t\tcase config.enums.Format.APA7:\n\t\t\tcase config.enums.Format.Turabian9:\n\t\t\t\tcontentToClipBoard += '' + store.state.paperEdit.meta.Title + '
';\n\t\t\t\tbreak;\n\t\t\tcase config.enums.Format.MLA9:\n\t\t\t\tcontentToClipBoard += '' + store.state.paperEdit.meta.Title + '
';\n\t\t\t\tbreak;\n\t\t}\n\n\t\t// discution post content\n\t\tif(CKEDITOR.instances.ckPaperBody){\n\t\t\t// there is a ck instance use it's data\n\t\t\tcontentToClipBoard += CKEDITOR.instances.ckPaperBody.getData();\n\n\t\t} else {\n\t\t\tif(window.$vm.$route.name === 'PaperTabExport'){\n\t\t\t\tcontentToClipBoard += store.state.paperEdit.paperDataBody;\n\t\t\t} else {\n\t\t\t\treturn reject();\t// should handle this better - but i don't have a ck instnace and not on the Export tab so this is worst case\n\t\t\t}\n\t\t}\n\n\t\t// discution post reference section > title\n\t\tif(_referenceFormatTypeId === config.enums.Format.MLA9){\n\t\t\t// check for single or multiple references\n\t\t\tif(store.state.paperEdit.referencesInPaper.length === 1){\n\t\t\t\tcontentToClipBoard += 'Work Cited
';\n\t\t\t} else {\n\t\t\t\tcontentToClipBoard += 'Works Cited
';\n\t\t\t}\n\t\t} else {\n\t\t\tcontentToClipBoard += 'References
';\n\t\t}\n\n\t\t// discution post reference section > references\n\t\tstore.state.paperEdit.referencesInPaper.forEach((referenceObject)=>{\n\t\t\tcontentToClipBoard += '' + referenceObject.displayValue + '
'\n\t\t});\n\t\t\n\t\t// replace any PERRLA Headings with code that fits better on something like Blackboard\n\t\tlet parsedHtml = new DOMParser().parseFromString(contentToClipBoard, 'text/html');\n\t\t\n\t\t// APA7 Heading 1:Heading 1
\n\t\t// MLA9 Heading 1:Heading 1
\n\t\t// Turabian9 Heading 1:Heading 1
\n\t\tlet h1Elements = parsedHtml.getElementsByTagName(\"h1\");\n\t\t_forEachRight(h1Elements, (h1Element)=>{\n\t\t\tlet newElement = document.createElement('p');\n\t\t\tif(_referenceFormatTypeId === config.enums.Format.APA7 || _referenceFormatTypeId === config.enums.Format.Turabian9){\n\t\t\t\tnewElement.style['text-align'] = 'center';\n\t\t\t}\n\t\t\tnewElement.innerHTML = '' + h1Element.innerText + '';\n\t\t\th1Element.replaceWith(newElement);\n\t\t});//e:forEach\n\n\t\t// APA7 Heading 2:Heading 2
\n\t\t// MLA9 Heading 2:Heading 2
\n\t\t// Turabian9 Heading 2:Heading 2
\n\t\tlet h2Elements = parsedHtml.getElementsByTagName(\"h2\");\n\t\t_forEachRight(h2Elements, (h2Element)=>{\n\t\t\tlet newElement = document.createElement('p');\n\t\t\tif(_referenceFormatTypeId === config.enums.Format.APA7){\n\t\t\t\tnewElement.innerHTML = '' + h2Element.innerText + '';\n\t\t\t} else if(_referenceFormatTypeId === config.enums.Format.MLA9){\n\t\t\t\tnewElement.innerHTML = '' + h2Element.innerText + '';\n\t\t\t} else if(_referenceFormatTypeId === config.enums.Format.Turabian9){\n\t\t\t\tnewElement.style['text-align'] = 'center';\n\t\t\t\tnewElement.innerHTML = h2Element.innerText;\n\t\t\t}\n\t\t\t\n\t\t\th2Element.replaceWith(newElement);\n\t\t});//e:forEach\n\n\t\t// APA7 Heading 3:Heading 3
\n\t\t// MLA9 Heading 3:Heading 3
\n\t\t// Turabian9 Heading 3:Heading 3
\n\t\tlet h3Elements = parsedHtml.getElementsByTagName(\"h3\");\n\t\t_forEachRight(h3Elements, (h3Element)=>{\n\t\t\tlet newElement = document.createElement('p');\n\t\t\tif(_referenceFormatTypeId === config.enums.Format.APA7){\n\t\t\t\tnewElement.innerHTML = '' + h3Element.innerText + '';\n\t\t\t} else if(_referenceFormatTypeId === config.enums.Format.MLA9){\n\t\t\t\tnewElement.innerHTML = h3Element.innerText;\n\t\t\t} else if(_referenceFormatTypeId === config.enums.Format.Turabian9){\n\t\t\t\tnewElement.innerHTML = '' + h3Element.innerText + '';\n\t\t\t}\n\t\t\th3Element.replaceWith(newElement);\n\t\t});//e:forEach\n\n\t\t// MLA9 Heading 4:Heading 4.
\n\t\t// Turabian9 Heading 4:Heading 4.
\n\t\tlet h4Elements = parsedHtml.getElementsByTagName(\"h4\");\n\t\t_forEachRight(h4Elements, (h4Element)=>{\n\t\t\tlet newElement = document.createElement('p');\n\t\t\tif(_referenceFormatTypeId === config.enums.Format.MLA9){\n\t\t\t\tnewElement.innerHTML = '' + h4Element.innerText + '';\n\t\t\t} else if(_referenceFormatTypeId === config.enums.Format.Turabian9){\n\t\t\t\tnewElement.innerHTML = h4Element.innerText;\n\t\t\t}\n\t\t\th4Element.replaceWith(newElement);\n\t\t});//e:forEach\n\n\t\t// MLA9 Heading 5:Heading 5.
\n\t\tlet h5Elements = parsedHtml.getElementsByTagName(\"h5\");\n\t\t_forEachRight(h5Elements, (h5Element)=>{\n\t\t\tlet newElement = document.createElement('p');\n\t\t\tif(_referenceFormatTypeId === config.enums.Format.MLA9){\n\t\t\t\tnewElement.innerHTML = '' + h5Element.innerText + '';\n\t\t\t// } else if(_referenceFormatTypeId === config.enums.Format.Turabian9){\n\t\t\t// \tnewElement.innerHTML = h4Element.innerText;\n\t\t\t}\n\t\t\th5Element.replaceWith(newElement);\n\t\t});//e:forEach\n\n\t\t// APA7 inline headings that render in the editor as SPAN tags\n\t\tlet spanElements = parsedHtml.getElementsByTagName(\"span\");\n\t\t_forEachRight(spanElements, (spanElement)=>{\n\t\t\tif(spanElement.classList.contains('h4')){\n\t\t\t\t// APA7 Heading 4:Heading 4. Sentence
\n\t\t\t\tlet newElement = document.createElement('strong');\n\t\t\t\tnewElement.innerHTML = spanElement.innerText;\n\t\t\t\tspanElement.replaceWith(newElement);\t\n\t\t\t} else if(spanElement.classList.contains('h5')){\n\t\t\t\tif(_referenceFormatTypeId === config.enums.Format.APA7){\n\t\t\t\t\t// APA7 Heading 5:Heading 5. Sentence
\n\t\t\t\t\tlet newElement = document.createElement('em');\n\t\t\t\t\tnewElement.innerHTML = '' + spanElement.innerText + '';\n\t\t\t\t\tspanElement.replaceWith(newElement);\t\n\t\t\t\t} else if(_referenceFormatTypeId === config.enums.Format.Turabian9){\n\t\t\t\t\t// Turabian9 Heading 5:Heading 5. Sentence.
\n\t\t\t\t\tlet newElement = document.createElement('strong');\n\t\t\t\t\t\tnewElement.innerHTML = spanElement.innerText;\n\t\t\t\t\t\tspanElement.replaceWith(newElement);\t\n\t\t\t\t}\n\t\t\t}\n\t\t});//e:forEach\n\n\t\n\t\tlet bodyInnerHtml = parsedHtml.getElementsByTagName(\"body\")[0].innerHTML\n\n\t\t// Create container for the HTML\n\t\tlet container = document.createElement('div');\n\t\tcontainer.innerHTML = bodyInnerHtml;\n\n\t\t// Hide element\n\t\tcontainer.style.position = 'fixed';\n\t\tcontainer.style.pointerEvents = 'none';\n\t\tcontainer.style.opacity = 0;\n\n\t\t// Detect all style sheets of the page\n\t\t// var activeSheets = Array.prototype.slice.call(document.styleSheets).filter(function (sheet) {\n\t\t// \treturn !sheet.disabled\n\t\t// });\n\n\t\t// Mount the container to the DOM to make `contentWindow` available\n\t\tdocument.body.appendChild(container);\n\n\t\t// Copy to clipboard\n\t\twindow.getSelection().removeAllRanges();\n\n\t\tlet range = document.createRange();\n\t\trange.selectNode(container);\n\t\twindow.getSelection().addRange(range);\n\n\t\tdocument.execCommand('copy');\n\n\t\t// for (var i = 0; i < activeSheets.length; i++) activeSheets[i].disabled = true\n\n\t\t// document.execCommand('copy');\n\n\t\t// for (var i = 0; i < activeSheets.length; i++) activeSheets[i].disabled = false;\n\n\t\t// Remove the container\n\t\tdocument.body.removeChild(container);\n\n\t\twindow.$vm.emitter.emit('globalToasterOpen',{\n\t\t\ttextContent: 'Copied to clipboard',\n\t\t});\n\t\t\n\t\treturn resolve();\n\n\t});//e:Promise\n\t\n}","// PS_BuildHtml\n// paper edit level - converts all paper parts into complete html \n\nimport _cloneDeep from 'lodash/cloneDeep';\nimport _forEach from 'lodash/forEach';\nimport _has from 'lodash/has';\nimport _isEmpty from 'lodash/isEmpty';\nimport _sortBy from 'lodash/sortBy';\nimport _uniqBy from 'lodash/uniqBy';\nimport config from '@/config';\nimport PCKS_NumberFigureCaptions from '@/services/paper/ck/numberFigureCaptions'\nimport PCKS_NumberTableCaptions from '@/services/paper/ck/numberTableCaptions'\nimport router from '@/router';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve, reject) => {\n\t\tconst errorSourceName = 'PS_BuildHtml';\n\t\t// console.log(errorSourceName);\n\n\t\t// set defaults\n\t\tconst _$opts = $opts || {};\n\t\tconst _updateMetaTags = _has(_$opts, 'updateMetaTags') ? _$opts.updateMetaTags : null;\n\t\t\n\t\tlet returnHtml = '';\n\t\tlet paperId = 0;\n\n\t\t// meta\n\t\t_forEach(config.metaDataKeys, (metaDataKey)=>{\n\t\t\t// if(metaDataKey !== 'UseNewCitationMode'){\n\t\t\t\tlet isMetaChange = false;\n\t\t\t\tif(_updateMetaTags){\n\t\t\t\t\t_forEach(_updateMetaTags, (updatedTagValue)=>{\n\t\t\t\t\t\tif(updatedTagValue[metaDataKey]){\n\t\t\t\t\t\t\tisMetaChange = true;\n\t\t\t\t\t\t\treturnHtml += '';\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif(metaDataKey === 'PaperID'){\n\t\t\t\t\tpaperId = store.state.paperEdit.meta[metaDataKey] || 0;\n\t\t\t\t}\n\t\t\t\tif(!isMetaChange){\n\t\t\t\t\treturnHtml += '';\n\t\t\t\t}\n\n\t\t\t// }\n\t\t});\n\n\t\treturnHtml += '\\r\\r';\n\t\t\n\t\t// review\n\t\t_forEach(store.state.paperEdit.review, (value, key)=>{\n\t\t\treturnHtml += 'ORCID iD's
\n\t\t\t\t\tChanges of Affiliation
\n\t\t\t\t\tDisclosures & Acknowledgements
\n\t\t\t\t\tContact Information
\n\t\t\t\t`;\n\t\t\t}\n\t\t\treturnHtml += '';\n\t\t\t\t\t\t\t\t\tlet postContent = '
';\n\n\t\t\t\t\t\t\t\t\tif(foundCitation.content !== '@@@
'){\n\t\t\t\t\t\t\t\t\t\t// there are pre and post content we need to extract\n\n\t\t\t\t\t\t\t\t\t\tlet splitAtCitationPlaceholderArray = foundCitation.content.split('@@@');\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t// if theres any variation here, figure out the use case and add code to check them\n\t\t\t\t\t\t\t\t\t\tif(splitAtCitationPlaceholderArray.length === 2){\n\t\t\t\t\t\t\t\t\t\t\t// replace html tags in the pre content\n\t\t\t\t\t\t\t\t\t\t\tpreContent = splitAtCitationPlaceholderArray[0]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(//gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(/<\\/strong>/gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(//gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(/<\\/u>/gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(//gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(/<\\/em>/gi, '');\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t// replace html tags in the post content\n\t\t\t\t\t\t\t\t\t\t\tpostContent = splitAtCitationPlaceholderArray[1]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(//gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(/<\\/strong>/gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(//gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(/<\\/u>/gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(//gi, '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(/<\\/em>/gi, '');\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tfootnoteExportArray.push({\n\t\t\t\t\t\t\t\t\t\tcitationDisplayValue: citationObject.displayValue,\n\t\t\t\t\t\t\t\t\t\tpre: preContent,\n\t\t\t\t\t\t\t\t\t\tpost: postContent,\n\t\t\t\t\t\t\t\t\t\tfindById: foundCitation.findById.toUpperCase()\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\t\t}//e:if:foundCitation\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t});//e:forEach\n\t\t\t\t\t\t}\n\n\t\t\t\t\t});//e:forEach\n\t\t\t\t\t\n\t\t\t\t\t// since group citations will list here twice, just remove any duplicated ids\n\t\t\t\t\tfootnoteExportArray = _uniqBy(footnoteExportArray, 'findById');\n\t\t\t\t\t\n\t\t\t\t\t/*\n\t\t\t\t\t// using this to check what's happening with Footnoes in Discusion posts\n\t\t\t\t\tlet exportTextToCheck = `JTVCJTdCJTIyY2l0YXRpb25EaXNwbGF5VmFsdWUlMjIlM0ElMjJTdGFubGV5JTIwRS4lMjBQb3J0ZXIlMkMlMjAlM0NlbSUzRVRoZSUyMEFwb3N0bGUlMjBQYXVsJTNBJTIwSGlzJTIwTGlmZSUyQyUyMFRob3VnaHQlMkMlMjBhbmQlMjBMZXR0ZXJzJTNDJTJGZW0lM0UlMjAoR3JhbmQlMjBSYXBpZHMlMkMlMjBNSSUzQSUyMFdpbGxpYW0lMjBCLiUyMEVlcmRtYW5zJTJDJTIwMjAxNikuJTIyJTJDJTIycHJlJTIyJTNBJTIyJTNDcCUzRSUyMiUyQyUyMnBvc3QlMjIlM0ElMjIlM0MlMkZwJTNFJTIyJTJDJTIyZmluZEJ5SWQlMjIlM0ElMjI3ODZDMDY3Ri04ODEyLTQzN0QtQjU4QS1ENjhBODU4NDhDQjQlMjIlN0QlMkMlN0IlMjJjaXRhdGlvbkRpc3BsYXlWYWx1ZSUyMiUzQSUyMlBvcnRlciUyQyUyMCUzQ2VtJTNFVGhlJTIwQXBvc3RsZSUyMFBhdWwlM0MlMkZlbSUzRSUyQyUyMDMwNC4lMjIlMkMlMjJwcmUlMjIlM0ElMjIlM0NwJTNFJTIyJTJDJTIycG9zdCUyMiUzQSUyMiUzQyUyRnAlM0UlMjIlMkMlMjJmaW5kQnlJZCUyMiUzQSUyMkIxNTg2NjFELUMzMEQtNDBBRi05OEUwLTcyNkU2RDhCNTlGOSUyMiU3RCUyQyU3QiUyMmNpdGF0aW9uRGlzcGxheVZhbHVlJTIyJTNBJTIyUG9ydGVyJTJDJTIwJTNDZW0lM0VUaGUlMjBBcG9zdGxlJTIwUGF1bCUzQyUyRmVtJTNFLiUyMiUyQyUyMnByZSUyMiUzQSUyMiUzQ3AlM0UlMjIlMkMlMjJwb3N0JTIyJTNBJTIyJTNDJTJGcCUzRSUyMiUyQyUyMmZpbmRCeUlkJTIyJTNBJTIyMUVCNURDQzktQzYxQS00MTY5LTkwM0EtODEwMDdGNEIzMjJDJTIyJTdEJTJDJTdCJTIyY2l0YXRpb25EaXNwbGF5VmFsdWUlMjIlM0ElMjJQb3J0ZXIlMkMlMjAlM0NlbSUzRVRoZSUyMEFwb3N0bGUlMjBQYXVsJTNDJTJGZW0lM0UuJTIyJTJDJTIycHJlJTIyJTNBJTIyJTNDcCUzRSUyMiUyQyUyMnBvc3QlMjIlM0ElMjIlM0MlMkZwJTNFJTIyJTJDJTIyZmluZEJ5SWQlMjIlM0ElMjJBOUZEMTIwOS03RjdGLTQ3NkYtODRGMy05QzQyMTIyOTA2MDAlMjIlN0QlNUQ`;\n\t\t\t\t\tlet decodedTextToCheck = decodeURIComponent(window.atob(exportTextToCheck));\n\t\t\t\t\tlet jsonPaseExportTextToCheck = JSON.parse(decodedTextToCheck);\n\n\t\t\t\t\tconsole.log('jsonPaseExportTextToCheck');\n\t\t\t\t\tconsole.log(jsonPaseExportTextToCheck);\n\t\t\t\t\t\n\t\t\t\t\t// jsonPaseExportTextToCheck = \n\t\t\t\t\t[\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"citationDisplayValue\": \"Stanley E. Porter, The Apostle Paul: His Life, Thought, and Letters (Grand Rapids, MI: William B. Eerdmans, 2016).\",\n\t\t\t\t\t\t\t\"pre\": \"\",\n\t\t\t\t\t\t\t\"post\": \"
\",\n\t\t\t\t\t\t\t\"findById\": \"786C067F-8812-437D-B58A-D68A85848CB4\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"citationDisplayValue\": \"Porter, The Apostle Paul, 304.\",\n\t\t\t\t\t\t\t\"pre\": \"\",\n\t\t\t\t\t\t\t\"post\": \"
\",\n\t\t\t\t\t\t\t\"findById\": \"B158661D-C30D-40AF-98E0-726E6D8B59F9\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"citationDisplayValue\": \"Porter, The Apostle Paul.\",\n\t\t\t\t\t\t\t\"pre\": \"\",\n\t\t\t\t\t\t\t\"post\": \"
\",\n\t\t\t\t\t\t\t\"findById\": \"1EB5DCC9-C61A-4169-903A-81007F4B322C\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"citationDisplayValue\": \"Porter, The Apostle Paul.\",\n\t\t\t\t\t\t\t\"pre\": \"\",\n\t\t\t\t\t\t\t\"post\": \"
\",\n\t\t\t\t\t\t\t\"findById\": \"A9FD1209-7F7F-476F-84F3-9C4212290600\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t\t*/\n\n\t\t\t\t\treturnHtml += '', '');\n\t\t\t\t// outlineHtml = outlineHtml.replaceAll('
', '');\n\n\t\t\t\tstore.commit('paperEdit/outline/FULL_HTML', outlineHtml);\n\n\t\t\t\tPS_SaveDocument({\n\t\t\t\t\tisStealthSave: true,\n\t\t\t\t\tmessage: 'Saved Organize tab',\n\t\t\t\t}).then(()=>{\n\t\t\t\t\tstore.commit('paperEdit/outline/SET_IS_UNSAVED', false);\n\t\t\t\t\t\n\t\t\t\t\twindow.$vm.emitter.emit('globalToasterOpen',{\n\t\t\t\t\t\ttextContent: 'Outline changes saved',\n\t\t\t\t\t});\n\t\t\t\t\tstore.commit('loaders/REMOVE_ID', 'App');\n\t\t\t\t\treturn resolve();\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\t\n\t\t\t});//e:PS_BuildReferencesInPaper\n\t\t} else {\n\t\t\treturn resolve();\n\t\t}\n\t});//e:Promise\n}","// PCKS_OnChange\n\nimport store from '@/store';\n\nexport default ($opts) => {\n\t// console.log('PCKS_OnChange');\n\n\treturn new Promise((resolve) => {\n\t\tif(store.state.paperEdit.isPaperFooterOn) {\n\t\t\t// set a stop type timer with every change event\n\t\t\tstore.commit('paperEdit/ck/USER_TYPE_FOOTER_TIMER_START', $opts.editorName);\n\t\t}\n\t\tstore.commit('paperEdit/localVersion/USER_TYPE_LOCAL_TIMER_START');\n\t\tstore.commit('paperEdit/localVersion/SET_IS_LOCAL_STORAGE_FRESH', false);\n\t\tstore.commit('paperEdit/SET_IS_DOCUMENT_SAVED', false);\n\n\t\tstore.dispatch('paperEdit/inactivityAlert/startTimer');\n\t\t\n\t\treturn resolve();\n\t});//e:Promise\t\t\t\n\n}\n","// PCKS_NumberTableCaptions\n\nimport _forEach from 'lodash/forEach';\nimport config from '@/config';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('PCKS_NumberTableCaptions');\n\t\t\n\t\tif($opts.ckEditor === 'all'){\n\t\t\t// check all instances - this is probably from a document save\n\t\t\t_forEach(CKEDITOR.instances, (ckInstance)=>{\n\t\t\t\tnumberTablesForSingleInstance(ckInstance);\n\t\t\t});\n\t\t\t\n\t\t} else {\n\t\t\t// single instance\n\t\t\tnumberTablesForSingleInstance($opts.ckEditor);\n\n\t\t}//e:if\n\t\t\n\t\treturn resolve();\n\n\t});//e:Promise\n\n\tfunction numberTablesForSingleInstance(ckEditor){\n\t\tlet tableCount = 0;\n\n\t\tif(ckEditor.$ckEditorType === config.enums.CkEditorType.ABSTRACT){\n\t\t\t// abstract - start the table count at 0\n\t\t\ttableCount = 0;\n\t\t\t\n\t\t} else if(ckEditor.$ckEditorType === config.enums.CkEditorType.BODY){\n\t\t\t// body - i need to know how many tables were in the abstract\n\t\t\tif(CKEDITOR.instances['ckPaperAbstract'] && CKEDITOR.instances['ckPaperAbstract'].document){\n\t\t\t\tlet tablesInAbstract = CKEDITOR.instances['ckPaperAbstract'].document.find('table');\n\t\t\t\ttableCount = tablesInAbstract.toArray().length;\n\t\t\t}\n\n\t\t}\n\n\t\t// find all table elements in this instance\n\t\tif(ckEditor.document){\n\t\t\tlet tablesInInstance = ckEditor.document.find('table');\n\n\t\t\t// loop through the elements found\n\t\t\t_forEach(tablesInInstance.toArray(), (tableElement)=>{\n\t\t\t\ttableElement.$.style.width = \"100%\";\n\t\t\t\ttableCount++;\n\n\t\t\t\t// find theType your appendix content here...
';\n\t\t}\n\n\t\tstore.commit('paperEdit/appendices/ADD_TO_PAPER', {\n\t\t\tcontent: appendixTitleDefaultContent,\t// this is the Title the user can change, don't confuse it with the Label like \"Appendix A\"\n\t\t\tuid: newUUID, \n\t\t});\n\n\t\t// after adding just reclean them (to sync sort and title)\n\t\tPApS_CleanUp().then((cleanedAppendicesInPaper)=>{\n\t\t\tstore.commit('paperEdit/appendices/IN_PAPER', cleanedAppendicesInPaper);\n\t\t\t\n\t\t\tstore.dispatch('paperEdit/toc/generateContent').then(()=>{\n\t\t\t\twindow.$vm.emitter.emit('globalToasterOpen',{\n\t\t\t\t\ttextContent: 'Appendix added',\n\t\t\t\t});\n\n\t\t\t\tresolve(newUUID);\n\t\t\t});//e:dispatch:paperEdit/toc/generateContent\n\t\t\t\n\t\t});\n\t});//e:Promise\n}","// PAnS_AddUpdate\n// Adds an empty annotation instnace\n// Updates exisiting annotation content\n\nimport store from '@/store';\n\nexport default ($opts) => {\n\t// console.log('PAnS_AddUpdate');\n\n\treturn new Promise((resolve) => {\n\t\tstore.commit('paperEdit/annotations/IS_INCLUDE', true);\n\t\t\t\t\n\t\tlet thisAnnotationFindIndex = store.state.paperEdit.annotations.inPaper.findIndex((annotationData)=>{\n\t\t\treturn annotationData.referenceUniqueId.toUpperCase() === $opts.referenceUniqueId.toUpperCase();\n\t\t});\n\t\tif(thisAnnotationFindIndex > -1){\n\t\t\tstore.commit('paperEdit/annotations/UPDATE_AT_INDEX', {\n\t\t\t\tcontent: $opts.content,\n\t\t\t\tindex: thisAnnotationFindIndex,\n\t\t\t});\n\t\t} else {\n\t\t\t// Add\n\t\t\tstore.commit('paperEdit/annotations/ADD_TO_PAPER', $opts);\n\t\t}\n\n\t\treturn resolve();\n\t});//e:Promise\t\t\t\n\n}\n","/*\n- PCS_InsertCitation\n-- Inserts a single citation\n-- Renders a citation (APA7 / MLA9) or a Footnote (Turabian)\n-- Fires from CitationAdd or the CitationRow to Insert an Orphan Citation\n*/\n\nimport _has from 'lodash/has';\nimport config from '@/config';\nimport PCKS_WrapCitation from '@/services/paper/ck/wrapCitation';\nimport router from '@/router';\nimport store from '@/store';\nimport Swal from 'sweetalert2';\nimport { v4 as uuidv4 } from 'uuid';\nimport Vue from 'vue';\n\nexport default ($opts) => {\n\treturn new Promise((resolve, reject) => {\n\t\t// console.log('PCS_InsertCitation');\n\n\t\tif(!CKEDITOR.instances[store.state.paperEdit.ck.editorLastFocused]){\n\t\t\treturn reject();\n\t\t}\n\n\t\tlet $findFocusedCitation; \n\n\t\tif(store.state.paperEdit.footnotes.contextMenuSelectedOnFindById === ''){\n\t\t\t// user was already on a citation element in the paper\n\t\t\t$findFocusedCitation = CKEDITOR.instances[store.state.paperEdit.ck.editorLastFocused].document.findOne('span.cke_widget_wrapper_perrla_citation.cke_widget_selected');\n\n\t\t} else {\n\t\t\t// user had a Footnote Citation selected, find it's matching citation in the paper\n\t\t\t\t\t\t\n\t\t\t// start by looking for the group uid\n\t\t\t$findFocusedCitation = CKEDITOR.instances[store.state.paperEdit.ck.editorLastFocused].document.findOne('span[data-group-unique-id=\"' + store.state.paperEdit.footnotes.contextMenuSelectedOnFindById + '\"]');\n\n\t\t\tif(!$findFocusedCitation){\n\t\t\t\t// not found, try to find a single\n\t\t\t\t$findFocusedCitation = CKEDITOR.instances[store.state.paperEdit.ck.editorLastFocused].document.findOne('span[data-citation-unique-id=\"' + store.state.paperEdit.footnotes.contextMenuSelectedOnFindById + '\"]');\n\t\t\t}\n\n\t\t\tif($findFocusedCitation){\n\t\t\t\t$findFocusedCitation = $findFocusedCitation.getParent();\n\t\t\t}\n\t\t}//e:if:else\n\n\n\n\t\tif($findFocusedCitation) {\n\t\t\t// Focus was inside a citation widget while inserting one - combine them\n\n\t\t\t// %Rh Temp Fix - Group Citations are not wired up in the Outline, stop them from being added for now so you can come back and fix them properly soon\n\t\t\tif(router.currentRoute.meta.tab === config.enums.Tab.OUTLINE){\n\t\t\t\tSwal.fire({\n\t\t\t\t\tallowOutsideClick: false,\n\t\t\t\t\tbuttonsStyling: false,\n\t\t\t\t\ttext: 'There was a problem adding this citation to your outline',\n\t\t\t\t\ticon: 'error',\n\t\t\t\t\tconfirmButtonText: 'Ok',\n\t\t\t\t\tshowCloseButton: false,\n\t\t\t\t\tshowConfirmButton: true,\n\t\t\t\t\tcustomClass:{\n\t\t\t\t\t\tconfirmButton: 'btn btn-danger',\n\t\t\t\t\t},\n\t\t\t\t}).then((result) => {\n\t\t\t\t\tif (result.value) {\n\t\t\t\t\t\treturn reject();\n\t\t\t\t\t}\n\t\t\t\t});//e:Swal\n\n\t\t\t} else if(router.currentRoute.meta.tab === config.enums.Tab.EDITOR){\n\n\t\t\t\t// this is the actual ckElement that is focused\n\t\t\t\tlet $findCitationNode = $findFocusedCitation.findOne('span.perrla_citation');\n\t\t\t\t\n\t\t\t\t// console.log('$findCitationNode1');\n\t\t\t\t// console.log($findCitationNode);\n\n\t\t\t\t// https://app.raygun.com/crashreporting/mb3tr7/errors/82499371374\n\t\t\t\tif(!$findCitationNode) {\n\t\t\t\t\treturn reject();\n\t\t\t\t}\n\n\t\t\t\tlet currentCitationNodeUid = $findCitationNode.getAttribute('data-citation-unique-id');\n\t\t\t\t// console.log('currentCitationNodeUid');\n\t\t\t\t// console.log(currentCitationNodeUid);\n\n\t\t\t\t// is this citation already part of a group?\n\t\t\t\tlet isGroupCitation = $findCitationNode.hasAttribute('data-group-unique-id');\n\t\t\t\t\n\t\t\t\tlet newGroupUniqueID = '';\n\t\t\t\t\n\t\t\t\tlet createOrder = 0;\n\n\t\t\t\tif(isGroupCitation) {\n\t\t\t\t\t// Already a group citation - add to it\n\t\t\t\t\tnewGroupUniqueID = $findCitationNode.getAttribute('data-group-unique-id')\n\t\t\t\t\t\n\t\t\t\t\tlet citationsWithThisGroupUid = [];\n\n\t\t\t\t\t// loop through current citations in paper\n\t\t\t\t\tstore.state.paperEdit.citations.inPaper.forEach((citationObject)=>{\n\t\t\t\t\t\tif(_has(citationObject, 'groupUniqueID') && citationObject.groupUniqueID.toUpperCase() === newGroupUniqueID.toUpperCase()){\n\t\t\t\t\t\t\tcitationsWithThisGroupUid.push(citationObject);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\t// console.log('citationsWithThisGroupUid');\n\t\t\t\t\t// console.log(citationsWithThisGroupUid);\n\n\t\t\t\t\tcreateOrder += citationsWithThisGroupUid.length;\n\n\t\t\t\t} else {\n\t\t\t\t\t// Single citation, create a group\n\t\t\t\t\tcreateOrder++;\n\n\t\t\t\t\t// generate a group uid to link these two inPaper\n\t\t\t\t\tnewGroupUniqueID = uuidv4().toUpperCase();\n\t\t\t\t\t\n\t\t\t\t\t// console.log('newGroupUniqueID');\n\t\t\t\t\t// console.log(newGroupUniqueID);\n\t\t\t\t\t\n\t\t\t\t\t$findCitationNode.setAttribute('data-group-unique-id', newGroupUniqueID);\n\t\t\t\t\t$findCitationNode.removeAttribute('data-citation-unique-id');\n\n\t\t\t\t\t// console.log('$findCitationNode2');\n\t\t\t\t\t// console.log($findCitationNode);\n\n\t\t\t\t\t// add the currently focused citation to the group\n\t\t\t\t\tlet findCitationIndex = store.state.paperEdit.citations.inPaper.findIndex((citation)=>{\n\t\t\t\t\t\treturn citation.citationData.citationUniqueID.toUpperCase() === currentCitationNodeUid.toUpperCase();\n\t\t\t\t\t});\n\t\t\t\t\tif(findCitationIndex !== -1){\n\t\t\t\t\t\tstore.commit('paperEdit/citations/ADD_GROUP_UID_AT_INDEX', {\n\t\t\t\t\t\t\tcreateOrder: createOrder,\n\t\t\t\t\t\t\tfindIndex: findCitationIndex,\n\t\t\t\t\t\t\tgroupUniqueID: newGroupUniqueID,\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\tif(store.state.paperEdit.config.renderCitationsAsFootnotes){\n\t\t\t\t\t\t\tstore.commit('paperEdit/footnotes/REMOVE_AT_CITATION_UID', currentCitationNodeUid.toUpperCase());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}//e:if:else:isGroupCitation\n\n\t\t\t\t// add the citation that was just created (or trying to insert as orphan) also to the group\n\t\t\t\tlet findCitationIndex = store.state.paperEdit.citations.inPaper.findIndex((citation)=>{\n\t\t\t\t\treturn citation.citationData.citationUniqueID.toUpperCase() === $opts.citationUniqueID.toUpperCase();\n\t\t\t\t});\n\t\t\t\tif(findCitationIndex !== -1){\n\t\t\t\t\tcreateOrder++;\n\t\t\t\t\tstore.commit('paperEdit/citations/ADD_GROUP_UID_AT_INDEX', {\n\t\t\t\t\t\tcreateOrder: createOrder,\n\t\t\t\t\t\tfindIndex: findCitationIndex,\n\t\t\t\t\t\tgroupUniqueID: newGroupUniqueID,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// add a group unique id\n\t\t\t\t$opts.groupUniqueID = newGroupUniqueID;\n\t\t\t\n\t\t\t\tVue.nextTick(()=>{\n\t\t\t\t\tPCKS_WrapCitation($opts).then(()=>{\n\t\t\t\t\t\treturn resolve(newGroupUniqueID);\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t}//e:if:else:Tab.EDITOR\n\n\t\t} else {\n\t\t\t// Focus was in a normal document, insert as usual\n\t\t\tif(router.currentRoute.meta.tab === config.enums.Tab.EDITOR){\n\t\t\t\tCKEDITOR.instances[store.state.paperEdit.ck.editorLastFocused].execCommand('perrlaReferences', {\n\t\t\t\t\tstartupData: $opts\n\t\t\t\t});\n\n\t\t\t\tVue.nextTick(()=>{\n\t\t\t\t\tPCKS_WrapCitation($opts).then(()=>{\n\t\t\t\t\t\t// if it's a footnote, force space after it so the cursor can grab something \n\t\t\t\t\t\tif(store.state.paperEdit.config.renderCitationsAsFootnotes){\n\t\t\t\t\t\t\tlet $citationNode = CKEDITOR.instances.ckPaperBody.document.findOne('span[data-citation-unique-id=\"' + $opts.citationUniqueID.toUpperCase() + '\"]');\n\t\t\t\t\t\t\tif($citationNode && $citationNode.getParent()){\n\t\t\t\t\t\t\t\tlet textItem = new CKEDITOR.dom.text(' ');\n\t\t\t\t\t\t\t\ttextItem.insertAfter( $citationNode.getParent() );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\twindow.$vm.emitter.emit('calculateFootnoteDisplay');\n\t\t\t\t\t\treturn resolve($opts.citationUniqueID.toUpperCase());\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t} else if(router.currentRoute.meta.tab === config.enums.Tab.OUTLINE){\n\t\t\t\t// console.log('$opts');\n\t\t\t\t// console.log($opts);\n\t\t\t\n\t\t\t\tCKEDITOR.instances[store.state.paperEdit.ck.editorLastFocused].execCommand('outlineCitation', {\n\t\t\t\t\tstartupData: $opts\n\t\t\t\t});\n\n\t\t\t\tVue.nextTick(()=>{\n\t\t\t\t\tstore.commit('paperEdit/outline/ADD_CITATION_OBJECT', {\n\t\t\t\t\t\tcitationUniqueId: $opts.citationUniqueID,\n\t\t\t\t\t\tdataBase64: $opts.citationDataBase64,\n\t\t\t\t\t});\n\n\t\t\t\t\tPCKS_WrapCitation($opts).then(()=>{\n\t\t\t\t\t\t// if it's a footnote, force space after it so the cursor can grab something \n\t\t\t\t\t\tif(store.state.paperEdit.config.renderCitationsAsFootnotes){\n\t\t\t\t\t\t\tlet $citationNode = CKEDITOR.instances.ckPaperOutline.document.findOne('span[data-citation-unique-id=\"' + $opts.citationUniqueID.toUpperCase() + '\"]');\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif($citationNode && $citationNode.getParent()){\n\t\t\t\t\t\t\t\tlet bracketElement = new CKEDITOR.dom.element('span');\n\t\t\t\t\t\t\t\tbracketElement.setHtml(' ');\n\t\t\t\t\t\t\t\tbracketElement.insertAfter( $citationNode.getParent() );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn resolve();\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});//e:Promise\n}","/*\n- PS_DownloadDocumentVersion\n-- 2023.03.14\n*/\n\nimport _has from 'lodash/has';\nimport _isEmpty from 'lodash/isEmpty';\nimport ApiS_MakeCall from '@/services/app/api/makeCall';\nimport config from '@/config';\nimport dateToLongString from '@/helpers/date-to-long-string';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('PS_DownloadDocumentVersionV4');\n\n\t\t// set opt defaults\n\t\tconst _$opts = $opts || {};\n\t\tconst _versionId = (_has(_$opts, 'versionId')) ? _$opts.versionId : '';\n\t\tconst _isOpenAfter = (_has(_$opts, 'isOpenAfter')) ? _$opts.isOpenAfter : false;\n\t\tconst _isPrint = (_has(_$opts, 'isPrint')) ? _$opts.isPrint : false;\n\t\tconst _isStealth = (_has(_$opts, 'isStealth')) ? _$opts.isStealth : false;\n\t\t\n\t\tconst _paperId = (_has(_$opts, 'paperId')) ? _$opts.paperId : store.state.paperEdit.meta.PaperID;\n\t\tconst _paperTitle = (_has(_$opts, 'paperId')) ? _$opts.paperTitle : store.state.paperEdit.meta.Title;\n\t\tlet _versionDateOuput = (_has(_$opts, 'versionDateOuput')) ? _$opts.versionDateOuput : null;\n\n\t\tif(!_versionDateOuput){\n\t\t\t_versionDateOuput = dateToLongString({\n\t\t\t\tdateValue: new Date(),\n\t\t\t\tshowTime: true,\n\t\t\t});\n\t\t}\n\t\t\n\t\tlet paramPass = {\n\t\t\tpaperId: _paperId,\n\t\t\tplatform: $opts.platform,\n\t\t\tcontentType: $opts.contentType\n\t\t};\n\t\tif(_versionId != '') {\n\t\t\tparamPass.versionId = _versionId;\n\t\t}\n\t\t\n\t\tif(!_isStealth){\n\t\t\tstore.commit('loaders/ADD_ID', 'App');\n\t\t}\n\n\t\tApiS_MakeCall({\n\t\t\tmethod: 'GET',\n\t\t\tparams: paramPass,\n\t\t\tresponseType: 'arraybuffer',\n\t\t\turl: 'v4/Paper',\n\t\t}).then((responseData)=>{\n\t\t\tlet paperTitle = '';\n\n\t\t\tif(config.platformId === config.enums.Platform.CHROME_EXT){\n\t\t\t\tif(_isEmpty(store.state.users.papers.openData)){\n\t\t\t\t\tpaperTitle = _paperTitle || 'Document';\n\t\t\t\t} else {\n\t\t\t\t\tpaperTitle = store.state.users.papers.openData.name || 'Document';\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tpaperTitle = _paperTitle || 'Document';\n\t\t\t}\n\n\t\t\tpaperTitle = paperTitle.replace(/[/\\\\?%*:|\"<>]/g, '-');\n\t\t\t\n\t\t\tlet fileBlobType = '';\n\t\t\tlet fileSaveExtension = '';\n\n\t\t\tswitch($opts.contentType){\n\t\t\t\tcase config.enums.DownloadPaperContentType.COMPRESSED:\n\t\t\t\t\tfileBlobType = 'text/plain';\n\t\t\t\t\tbreak;\n\t\t\t\tcase config.enums.DownloadPaperContentType.PDF:\n\t\t\t\t\tfileBlobType = 'application/pdf';\n\t\t\t\t\tfileSaveExtension = 'pdf';\n\t\t\t\t\tbreak;\n\t\t\t\tcase config.enums.DownloadPaperContentType.HTML:\n\t\t\t\t\tfileBlobType = 'text/html';\n\t\t\t\t\tfileSaveExtension = 'html';\n\t\t\t\t\tbreak;\n\t\t\t\tcase config.enums.DownloadPaperContentType.WORD:\n\t\t\t\tcase config.enums.DownloadPaperContentType.WORD_SIMPLE:\n\t\t\t\t\tfileBlobType = 'application/msword';\n\t\t\t\t\tfileSaveExtension = 'docx';\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tlet file = new Blob([responseData], {\n\t\t\t\ttype: fileBlobType\n\t\t\t});\n\n\t\t\tif (window.navigator && window.navigator.msSaveOrOpenBlob) {\n\t\t\t\twindow.navigator.msSaveOrOpenBlob(file, paperTitle + ' - ' + _versionDateOuput + '.' + fileSaveExtension);\n\t\t\t} else {\n\t\t\t\tlet fileURL = window.URL.createObjectURL(file);\n\n\t\t\t\tlet fileLink = document.createElement('a');\n\t\t\t\tfileLink.href = fileURL;\n\n\t\t\t\tif(_isOpenAfter){\n\t\t\t\t\tfileLink.target = '_blank';\n\t\t\t\t\twindow.open(fileLink);\n\n\t\t\t\t} else if(_isPrint){\n\t\t\t\t\tconst iframe = document.createElement('iframe');\n\t\t\t\t\tdocument.body.appendChild(iframe);\n\n\t\t\t\t\tiframe.style.display = 'none';\n\t\t\t\t\tiframe.src = fileURL;\n\t\t\t\t\tiframe.onload = ()=>{\n\t\t\t\t\t\tsetTimeout(()=>{\n\t\t\t\t\t\t\tiframe.focus();\n\t\t\t\t\t\t\tiframe.contentWindow.print();\n\t\t\t\t\t\t}, 33);\n\t\t\t\t\t};\n\t\t\t\t\t\n\t\t\t\t} else {\n\t\t\t\t\tif($opts.contentType === config.enums.DownloadPaperContentType.COMPRESSED){\n\t\t\t\t\t\tfileLink.download = 'PaperContent.txt';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfileLink.download = paperTitle + ' - ' + _versionDateOuput + '.' + fileSaveExtension;\n\t\t\t\t\t}\n\t\t\t\t\tdocument.body.appendChild(fileLink);\n\t\t\t\t\tfileLink.click();\n\n\t\t\t\t\tsetTimeout(()=>{\n\t\t\t\t\t\t// For Firefox it is necessary to delay revoking the ObjectURL\n\t\t\t\t\t\twindow.URL.revokeObjectURL(fileURL);\n\t\t\t\t\t}, 100);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\n\t\t\tstore.commit('loaders/REMOVE_ID', 'App');\n\n\t\t\tresolve();\n\n\t\t});//e:ApiS_MakeCall\n\t});//e:Promise\n}","// PS_InjectContent\nimport config from '@/config';\nimport LzString from 'lz-string';\nimport PS_ParseHiddenTags from '@/services/paper/parseHiddenTags';\nimport RS_UpdateAfterSync from '@/services/reference/updateAfterSync';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('PS_InjectContent');\n\n\t\tstore.commit('paperEdit/SET_ENCRYPTED_PAPER_LZ_STRING', $opts.compressedPaperData);\n\n\t\tlet decompressedPaperData = LzString.decompressFromUTF16($opts.compressedPaperData);\n\n\t\tPS_ParseHiddenTags(decompressedPaperData).then(()=>{\n\t\t\tswitch(store.state.paperEdit.meta.DocumentType){\n\t\t\t\tcase config.enums.DocumentType.ANNOTATED_BIBLIOGRAPHY:\n\t\t\t\tcase config.enums.DocumentType.REFERENCE_LIST:\n\t\t\t\t\t// no ckEditor Body\n\t\t\t\t\tRS_UpdateAfterSync().then(()=>{\n\t\t\t\t\t\twindow.$vm.emitter.emit('loadCkReferencePage');\n\t\t\t\t\t\tstore.commit('loaders/REMOVE_ID', 'App');\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase config.enums.DocumentType.DISCUSSION_POST:\n\t\t\t\t\t// no Title Page\n\t\t\t\t\twindow.$vm.emitter.emit('loadCkBody');\n\t\t\t\t\tbreak;\n\t\t\t\tcase config.enums.DocumentType.RESEARCH_PAPER:\n\t\t\t\t\twindow.$vm.emitter.emit('loadCkTitlePage');\n\t\t\t\t\twindow.$vm.emitter.emit('loadTitlePageDrawer');\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tstore.commit('paperEdit/ck/SET_IS_EDITOR_LOADED_ONCE');\n\n\t\t\tresolve();\n\n\t\t});//e:paperEdit/parseHiddenTags\n\n\t});//e:Promise\n\n}","// PS_LoadByRoute\nimport _isEmpty from 'lodash/isEmpty';\nimport AS_SyncData from '@/services/app/syncData';\nimport store from '@/store';\n\nexport default () =>{\n\treturn new Promise((resolve, reject) => {\n\t\t// console.log('PS_LoadByRoute');\n\n\t\tif(_isEmpty(store.state.openObject)){\n\t\t\t// console.log('need to look this paper up');\n\n\t\t\tAS_SyncData().then(()=>{\n\t\t\t\t// look paper up by the encryptedId param\n\t\t\t\tlet findPaper = store.state.paperList.list.find((paperData)=>{\n\t\t\t\t\treturn paperData.encryptedID === window.$vm.$route.params.encryptedId\n\t\t\t\t});\n\n\t\t\t\tif(findPaper){\n\t\t\t\t\tstore.commit('paperEdit/SET_OPEN_OBJECT', findPaper)\n\t\t\t\t\tresolve();\n\t\t\t\t} else {\n\t\t\t\t\treject('Could not find paper');\n\t\t\t\t}\n\t\t\t});//e:syncData\n\n\t\t} else {\n\t\t\tstore.commit('loaders/REMOVE_ID', 'App');\n\t\t\t\n\t\t\tresolve();\n\t\t}\n\n\t});//e:Promise\n\n}","// PS_SaveDocument\nimport _forEach from 'lodash/forEach';\nimport _has from 'lodash/has';\nimport ApiS_MakeCall from '@/services/app/api/makeCall';\nimport config from '@/config';\nimport ErrS_GenericAlert from '@/services/app/error/generic-alert.js';\nimport LzString from 'lz-string';\nimport PS_BuildHtml from '@/services/paper/buildHtml';\nimport router from '@/router';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\t// console.log('PS_SaveDocument');\n\t\n\t\t// set defaults\n\t\tconst _$opts = $opts || {};\n\t\tconst _isAutoSave = (_has(_$opts, 'isAutoSave')) ? _$opts.isAutoSave : false;\n\t\tconst _isMetaDataChanges = (_has(_$opts, 'isMetaDataChanges')) ? _$opts.isMetaDataChanges : false;\n\n\t\t// 2024.09.23 Updated to remove the blue spinner - Document Saves will be processed without any problems\n\t\t// let _isStealthSave = (_has(_$opts, 'isStealthSave')) ? _$opts.isStealthSave : false;\n\t\tlet _isStealthSave = true;\n\t\t\n\t\tlet verifyLogId;\n\n\t\tconst _updateMetaTags = (_has(_$opts, 'updateMetaTags')) ? _$opts.updateMetaTags : [];\n\t\tconst _message = (_has(_$opts, 'message')) ? _$opts.message : '';\n\n\t\t// write the initial request local logs\n\t\tstore.dispatch('logs/write', {\n\t\t\tmessage: _message,\n\t\t}).then((newLogId)=>{\n\t\t\tverifyLogId = newLogId;\n\t\t});\n\n\t\t// stop the inactivy timer\n\t\tstore.dispatch('paperEdit/inactivityAlert/endTimer');\n\n\t\t// cancel the local version check in\n\t\tstore.commit('paperEdit/localVersion/USER_TYPE_LOCAL_TIMER_CANCEL');\n\n\t\tif(!_isAutoSave && !_isStealthSave){\n\t\t\t// show loading if not Auto or Stealth\n\t\t\tstore.commit('loaders/ADD_ID', 'App');\n\t\t}\n\n\t\t// prepare the document and try to save it\n\t\tPS_BuildHtml({\n\t\t\tupdateMetaTags: _updateMetaTags,\n\t\t}).then((buildHtmlResponseObj)=>{\n\t\t\t// console.log('buildHtmlResponseObj.returnHtml');\n\t\t\t// console.log(buildHtmlResponseObj.returnHtml);\n\n\t\t\tlet compressedPaperContent = LzString.compressToUTF16(buildHtmlResponseObj.returnHtml)\n\t\t\tlet encryptedPaper = encodeURIComponent(compressedPaperContent);\n\n\t\t\tlet params = {};\n\t\t\t\n\t\t\tif(_isMetaDataChanges){\n\t\t\t\tparams['metaDataChanges'] = true;\n\t\t\t}\n\n\t\t\t// MESSAGES API - https://trello.com/c/3A5FYXAY/305-action-descriptions-for-paper-saves-in-online-add-in\n\t\t\tif(_message != ''){\n\t\t\t\tparams['message'] = _message;\n\t\t\t}\n\n\t\t\t// start the inactivityAlert timer back up (but not in Outline)\n\t\t\tif(router.currentRoute.meta.tab === config.enums.Tab.EDITOR){\n\t\t\t\tstore.dispatch('paperEdit/inactivityAlert/startTimer');\n\t\t\t}\n\n\t\t\tif(!_isAutoSave && !_isStealthSave){\n\t\t\t\tstore.commit('loaders/ADD_ID', 'App');\n\t\t\t}\n\n\t\t\t/*\n\t\t\tto simulate vairious error responses replace one of these with one of the parameters in the api call:\n\t\t\t\t?\t\t\t\t\t\t400\n\t\t\t\turl: 'v3/PaperX',\t\t404\n\t\t\t\turl: 'v3/Paper/%',\t\t?\n\t\t\t\tbody: 'content=XXX',\t?\n\t\t\t*/\n\t\t\t\n\t\t\tApiS_MakeCall({\n\t\t\t\tcontentType: 'application/x-www-form-urlencoded',\n\t\t\t\tbody: 'content=' + encryptedPaper,\n\t\t\t\tmethod: 'PUT',\n\t\t\t\tparams,\n\t\t\t\tresponseType: 'json',\n\t\t\t\turl: 'v3/Paper',\n\t\t\t}).then((responseData)=>{\n\t\t\t\t// console.log('responseData');\n\t\t\t\t// console.log(responseData);\n\t\t\t\n\t\t\t\tstore.commit('paperEdit/SET_IS_DOCUMENT_SAVED', true);\n\n\t\t\t\tstore.dispatch('paperEdit/toc/generateContent').then(()=>{\n\n\t\t\t\t\t// reset all ck instances so they are clean\n\t\t\t\t\t_forEach(CKEDITOR.instances, (ckInstance)=>{\n\t\t\t\t\t\tckInstance.resetDirty();\n\t\t\t\t\t});\n\t\t\t\t\t\n\t\t\t\t\t// if(!_isAutoSave && !_isStealthSave){\n\t\t\t\t\t\t// hide loading if not Auto or Stealth\n\t\t\t\t\t\tstore.commit('loaders/REMOVE_ID', 'App');\n\t\t\t\t\t// }\n\n\t\t\t\t\tif(responseData && _has(responseData, 's3VersionID')){\n\t\t\t\t\t\t// save was successful at this point, i can update the proper indexedDb item\n\t\t\t\t\t\tconst openRequest = indexedDB.open('po_papers', 2);\n\n\t\t\t\t\t\topenRequest.onupgradeneeded = () => {\n\t\t\t\t\t\t\t// console.log('indb:onupgradeneeded po_papers 2');\n\n\t\t\t\t\t\t\tlet db = openRequest.result;\n\n\t\t\t\t\t\t\tif(!db.objectStoreNames.contains('papers')){\n\t\t\t\t\t\t\t\tdb.createObjectStore('papers', {\n\t\t\t\t\t\t\t\t\tautoIncrement: true,\t// people online says this will fix an error i'm seeing in rollbar - i can't replicate to error to verify, changing this doesn't seem to matter locally\n\t\t\t\t\t\t\t\t\tkeyPath: 'paperId',\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};//e:onupgradeneeded\n\n\t\t\t\t\t\topenRequest.onsuccess = () => {\n\t\t\t\t\t\t\tlet db = openRequest.result;\n\n\t\t\t\t\t\t\tif(db.objectStoreNames.contains('papers')){\n\n\t\t\t\t\t\t\t\tconst txn = db.transaction([\"papers\"], 'readwrite');\n\t\t\t\t\t\t\t\tconst store = txn.objectStore('papers');\n\n\t\t\t\t\t\t\t\tlet request = store.openCursor(buildHtmlResponseObj.paperId);\n\n\t\t\t\t\t\t\t\trequest.onsuccess = () => {\n\t\t\t\t\t\t\t\t\tlet requestResult = request.result;\n\t\t\t\t\t\t\t\t\tif (requestResult) {\n\t\t\t\t\t\t\t\t\t\t// this item should now be fresh since the save went through\n\t\t\t\t\t\t\t\t\t\tlet item = requestResult.value;\n\t\t\t\t\t\t\t\t\t\titem.content = compressedPaperContent;\n\t\t\t\t\t\t\t\t\t\titem.isFresh = true;\n\t\t\t\t\t\t\t\t\t\tstore.put(item);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t};//e:onsuccess\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\ttxn.oncomplete = () => {\n\t\t\t\t\t\t\t\t\tdb.close();\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t};//e:onsuccess\n\t\t\t\t\t\t\n\t\t\t\t\t\t// verify the last request in the log, it was successfull\n\t\t\t\t\t\tstore.dispatch('logs/verify', {\n\t\t\t\t\t\t\ts3Link: responseData.s3VersionID,\n\t\t\t\t\t\t\tverifyLogId: verifyLogId\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\twindow.$vm.emitter.emit('referencesInPaperReady');\t// emit to ReferenceCitation.vue (if that drawer isn't open then nothing will happen)\n\n\t\t\t\t\t\tstore.commit('paperEdit/localVersion/SET_IS_FORCE_SAVE_AFTER_LOADING', false);\t// resets to false, only should be true if the user is restoring from local storage\n\n\t\t\t\t\t\treturn resolve({\n\t\t\t\t\t\t\t'contentUrl': (_has(responseData, 'contentUrl')) ? responseData.contentUrl : '',\n\t\t\t\t\t\t\t'pageCount': (_has(responseData, 'pageCount')) ? responseData.pageCount : '',\n\t\t\t\t\t\t});\n\n\t\t\t\t\t}//e:if:responseData\n\n\t\t\t\t});//e:dispatch:paperEdit/toc/generateContent\n\n\t\t\t});//e:ApiS_MakeCall\n\t\t\t\n\t\t}).catch((errorObj)=>{\n\t\t\tErrS_GenericAlert({\n\t\t\t\tenum: errorObj.enum,\n\t\t\t\tsrc: errorObj.src\n\t\t\t});\n\t\t});//e:PS_BuildHtml\n\t\t\n\t});//e:Promise\n}","// PS_AddReferenceToPaper\n// happens when adding a reference from the library, or when creating a new reference in a paper\n\nimport PAnS_AddUpdate from '@/services/paper/annotations/addUpdate';\nimport PS_UpdateReferenceObject from '@/services/paper/updateReferenceObject';\nimport RS_GetValueOutput from '@/services/reference/getValueOutput';\nimport store from '@/store';\n\nexport default ($opts) => {\n\treturn new Promise((resolve) => {\n\t\tstore.commit('paperEdit/REFERENCE_ADD_TO_PAPER', $opts.reference.referenceUniqueID.toUpperCase());\n\t\t\t\t\t\t\n\t\t// craft a message that will eventually make it's way to saveDocument\n\t\tlet referenceDisplayValue = RS_GetValueOutput({\n\t\t\tdisplayFormatVersionId: store.state.customer.preferredFormatVersionID,\n\t\t\treferenceData: $opts.reference,\n\t\t});\n\n\t\tPS_UpdateReferenceObject({\n\t\t\tsaveMessage: 'Added reference from library - ' + referenceDisplayValue,\n\t\t}).then(()=>{\n\t\t\tif($opts.isDrawer){\n\t\t\t\tif(store.state.paperEdit.annotations.isInclude){\n\t\t\t\t\tPAnS_AddUpdate({\n\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\treferenceUniqueId: $opts.reference.referenceUniqueID.toUpperCase(),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// add reference to list of all customer papers\n\t\t\tlet findPaperIndex = store.state.paperList.list.findIndex((paper) =>{\n\t\t\t\treturn paper.paperID === $opts.paperID;\n\t\t\t});\n\t\t\tif(findPaperIndex != -1){\n\t\t\t\t// paper found, is this reference already in the list (assume APA7 / Genesis)\n\t\t\t\tif(!store.state.paperList.list[findPaperIndex].genesisReferences.includes($opts.referenceID)){\n\t\t\t\t\tstore.commit('paperList/ADD_REFERENCE_ID_TO_PAPER', {\n\t\t\t\t\t\tpaperIndex: findPaperIndex,\n\t\t\t\t\t\treferenceID: $opts.referenceID\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn resolve();\n\t\t\t\n\t\t});//e:PS_UpdateReferenceObject\n\n\t});//e:Promise\n}\n"],"names":["$opts","Promise","resolve","store","commit","PS_SaveDocument","isMetaDataChanges","message","then","Vue","$newInstnaceWrp","document","getElementById","scrollIntoView","config","useWProofreader","WEBSPELLCHECKER","getInstances","forEach","wscInstance","destroy","content","parsedHtml","DOMParser","parseFromString","metaElements","getElementsByTagName","hasUseNewCitationModeTag","_forEach","element","attrName","getAttribute","attrContent","decodeURIComponent","error","console","log","state","paperEdit","meta","PaperType","enums","APA7_AnnotatedBibliography","MLA9_AnnotatedBibliography","Turabian9_AnnotatedBibliography","DocumentType","ANNOTATED_BIBLIOGRAPHY","APA_DiscussionPost","APA7_DiscussionPost","MLA_DiscussionPost","MLA9_DiscussionPost","Turabian9_DiscussionPost","DISCUSSION_POST","APA7_ReferenceList","MLA9_ReferenceList","Turabian9_ReferenceList","REFERENCE_LIST","APA_ResearchPaper","APA7_ProfessionalPaper","APA7_StudentPaper","MLA_ResearchPaper","MLA9_ResearchPaper","Turabian9_ResearchPaper","RESEARCH_PAPER","Swal","allowOutsideClick","buttonsStyling","text","icon","confirmButtonText","showCloseButton","showConfirmButton","customClass","confirmButton","dispatch","IncludeAuthorNote","authorNoteInPaperElement","IncludeAbstract","abstractInPaperElement","_appendicesInPaper","appendicesInPaperElements","appendix","appendixContent","appendixContentDecoded","h1sInAppendix","length","isAppendixTitleFound","h1","classList","contains","push","uid","_orderBy","PApS_CleanUp","arrayOfAppendices","cleanedAppendicesInPaper","_referencesInPaper","_citationsInPaper","referenceElementsInPaper","referenceElemenent","referenceData","JSON","parse","_has","citations","citationObject","orderByValue","referenceUniqueID","toUpperCase","hasAttribute","PAnS_AddUpdate","referenceUniqueId","_sortBy","_referenceUniqueIdsInPaper","sortedReference","_uniq","useOultineInPaperElement","outlineInPaperElement","outlineElement","outlineDataRaw","window","atob","outlineDataEncoded","isOutlineDecoded","startContent","outline","allCitationsElement","allCitationsObject","openReferenceUID","referenceUniqueIdsInPaper","setOpenReferenceId","citationData","renderCitationsAsFootnotes","footnotesElement","footnotesContent","findById","citationUniqueID","groupUniqueID","footnoteData","reviewElements","key","value","toBoolean","sortByScore","parsedLocationValue","sortByEnum","ResearchNotesSortBy","CITATION_FIRST_TO_LAST","type","parseInt","isNaN","CITATION_LAST_TO_FIRST","ordA","charCodeAt","ordAordZlen","_$opts","_arrayOfAppendices","_cloneDeep","appendices","inPaper","_uniqBy","sort","label","indexCounter","_indexCounter","labelAppend","String","fromCharCode","Math","floor","reject","_referenceFormatTypeId","HelperGetReferenceFormatId","contentToClipBoard","Format","APA7","Turabian9","Title","MLA9","CKEDITOR","instances","ckPaperBody","getData","$vm","$route","name","paperDataBody","referencesInPaper","referenceObject","displayValue","h1Elements","_forEachRight","h1Element","newElement","createElement","style","innerHTML","innerText","replaceWith","h2Elements","h2Element","h3Elements","h3Element","h4Elements","h4Element","h5Elements","h5Element","spanElements","spanElement","bodyInnerHtml","container","position","pointerEvents","opacity","body","appendChild","getSelection","removeAllRanges","range","createRange","selectNode","addRange","execCommand","removeChild","emitter","emit","textContent","errorSourceName","_updateMetaTags","updateMetaTags","returnHtml","paperId","metaDataKeys","metaDataKey","isMetaChange","updatedTagValue","encodeURIComponent","review","authorsNoteContent","ckPaperAuthorNote","authorsNote","abstractContent","ckPaperAbstract","abstract","abstractKeywords","$elmTxtPaperAbstractKeywords","keywords","PCKS_NumberTableCaptions","ckEditor","PCKS_NumberFigureCaptions","stringify","annotations","isInclude","_isEmpty","fullHtml","btoa","appendixData","citationHtmlToCheckIn","arrayOfCitationsInThisDocument","router","currentRoute","tab","Tab","EDITOR","_thisCitation","ckInstance","$citationNode","findOne","removeAttribute","setAttribute","weightForEditor","$ckEditorType","CkEditorType","ABSTRACT","BODY","APPENDIX","documentPosition","round","getDocumentPosition","y","x","enum","Error","PAPER_SAVE","src","footnotesInDocument","OUTLINE","footnotes","arrayToMakeFootnotes","_citationObject","find","findFootnote","isLive","alert","footnoteExportArray","foundCitation","footnoteObject","preContent","postContent","splitAtCitationPlaceholderArray","split","replace","citationDisplayValue","pre","post","saveMessage","isGroupCitation","citationElementInPaper","remainingCitationObject","groupUniqueId","filter","referenceIdRemoved","findCitationIndex","findIndex","citation","getParent","getHtml","setHtml","apa7","first","citationUniqueId","PaperFormatVersionID","$elToInsert","dom","setText","UseNewCitationMode","_reference","reference","referenceID","findPaperIndex","paperList","list","paper","paperID","genesisReferences","includes","paperIndex","hasActiveCitations","isDrawer","$citationNodeList","toArray","PCS_RemoveById","referenceDisplayValue","RS_GetValueOutput","displayFormatVersionId","customer","preferredFormatVersionID","PS_UpdateReferenceObject","_paperId","_versionId","versionId","ApiS_MakeCall","url","params","method","responseType","init","getFrame","$","editorName","isPaperFooterOn","numberFiguresForSingleInstance","figureCount","figuresInAbstract","figuresInInstance","figureElement","thisCaptionEl","thisCaptionText","getText","trim","$figureTitleEl","figureTitle","slice","_saveMessage","PS_BuildReferencesInPaper","isMatchFound","module","Module","PAPER_EDIT","isSaveAfter","RESEARCH","$ckPaperOutline","outlineHtml","isStealthSave","numberTablesForSingleInstance","tableCount","tablesInAbstract","tablesInInstance","tableElement","width","$tableTitleEl","tableTitle","tFootElements","remove","citationPrevious","beforeText","citationParent","getPrevious","NODE_TEXT","charAt","insertBefore","citationNext","getNext","afterText","insertAfter","EngineAfterSpecialRules","referenceUID","thisReference","referenceLibraryGenesis","_citationsForThisReference","thisReferenceModified","citationAutoInsert","RS_CalcCitationDisplayValueFromReferenceData","primaryTitle","RS_ExtractPrimaryTitleFromReferenceData","data","Engine","footnoteCounter","citationElementsInThisInstance","citationElement","citationElementParent","bracketElement","citationsWithDocumentPosition","citationsInThisOutline","citationsNodeList","index","citationDataObject","footnoteIndex","_citationsInThisOutline","citationDataChild","citationsForThisReference","ref","modeLevel","isDev","isTest","citationEngineResult","referenceTypeID","setValue","subsequent","mla9","turabian9","newUUID","uuidv1","appendixTitleDefaultContent","thisAnnotationFindIndex","annotationData","ck","editorLastFocused","$findFocusedCitation","contextMenuSelectedOnFindById","result","$findCitationNode","currentCitationNodeUid","newGroupUniqueID","createOrder","citationsWithThisGroupUid","uuidv4","PCKS_WrapCitation","startupData","dataBase64","citationDataBase64","ckPaperOutline","_isOpenAfter","isOpenAfter","_isPrint","isPrint","_isStealth","isStealth","PaperID","_paperTitle","paperTitle","_versionDateOuput","versionDateOuput","dateToLongString","dateValue","Date","showTime","paramPass","platform","contentType","responseData","platformId","Platform","CHROME_EXT","users","papers","openData","fileBlobType","fileSaveExtension","DownloadPaperContentType","COMPRESSED","PDF","HTML","WORD","WORD_SIMPLE","file","Blob","navigator","msSaveOrOpenBlob","fileURL","URL","createObjectURL","fileLink","href","target","open","iframe","display","onload","setTimeout","focus","contentWindow","print","download","click","revokeObjectURL","compressedPaperData","decompressedPaperData","LzString","PS_ParseHiddenTags","RS_UpdateAfterSync","openObject","AS_SyncData","findPaper","paperData","encryptedID","encryptedId","_isMetaDataChanges","isAutoSave","verifyLogId","_message","newLogId","PS_BuildHtml","buildHtmlResponseObj","compressedPaperContent","encryptedPaper","resetDirty","openRequest","indexedDB","onupgradeneeded","db","objectStoreNames","createObjectStore","autoIncrement","keyPath","onsuccess","txn","transaction","objectStore","request","openCursor","requestResult","item","isFresh","put","oncomplete","close","s3Link","s3VersionID","contentUrl","pageCount","catch","errorObj","ErrS_GenericAlert"],"sourceRoot":""}