From c16a7b6d41e82a674f1abbf5dfd8454bf8526106 Mon Sep 17 00:00:00 2001 From: Derek Sifford Date: Tue, 15 Nov 2016 21:09:11 -0500 Subject: [PATCH] 4.7.2 (#234) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: convert to ts-loader due to breaking api changes in the other * fix: use https pubmed url rather than http to avoid redirects Closes #230 * fix: Prevent images just prior to bib/footnotes from being deleted Closes #226 * fix: vastly improve citation insertion performance. This commit fixes several issues: - Fix problem causing citations to not be able to be inserted in image caption boxes. - Fix issue causing the carat to be moved to the end of the paragraph upon inserting a citation. Closes #224 * chore: update type defs + adjust webpack configs * chore: update webpack config * fix: prevent footnotes from being inserted with an empty list * test: fix failed tests * chore: update styles Styles Added: - Bulletin de la Société Entomologique de France - Herpetologica - Presses Universitaires de Rennes - Archéologie et Culture (French) * chore: update citeproc * chore: build version 4.7.2 --- ISSUE_TEMPLATE.md | 2 +- package.json | 5 +- src/academic-bloggers-toolkit.php | 4 +- src/academic-bloggers-toolkit.pot | 6 +- .../components/ReferenceList.tsx | 3 +- .../components/pubmed-window/ResultList.tsx | 2 +- src/lib/js/utils/HelperFunctions.ts | 8 +- src/lib/js/utils/TinymceFunctions.ts | 150 ++++++++---------- .../utils/__tests__/HelperFunctions-test.ts | 48 +++--- src/readme.txt | 6 +- src/vendor/citationstyles.php | 2 +- src/vendor/citeproc.js | 8 +- types/tinymce.d.ts | 4 +- webpack.config.js | 6 +- 14 files changed, 120 insertions(+), 134 deletions(-) diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index 16d232fc..e8bf83bf 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -4,7 +4,7 @@ Please use this template for all bug reports. Before submitting an issue, please try disabling all other plugins to ensure issue is isolated within ABT --> -**ABT Version:** 4.7.1 +**ABT Version:** 4.7.2 **PHP Version:** 5.6 diff --git a/package.json b/package.json index 5a24a904..d3107933 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "academic-bloggers-toolkit", - "version": "4.7.1", + "version": "4.7.2", "description": "A plugin extending the functionality of WordPress for Academic Blogging.", "main": "index.js", "scripts": { @@ -32,7 +32,6 @@ "autoprefixer": "^6.5.1", "awesome-typescript-loader": "^2.2.4", "babel-core": "^6.17.0", - "babel-loader": "^6.2.5", "babel-polyfill": "^6.16.0", "babel-preset-es2015": "^6.16.0", "babel-preset-react": "^6.16.0", @@ -44,7 +43,7 @@ "eslint": "^3.8.1", "eslint-config-airbnb-base": "^9.0.0", "eslint-plugin-import": "^2.0.1", - "gulp": "github:gulpjs/gulp#4.0", + "gulp": "gulpjs/gulp#4.0", "gulp-replace": "^0.5.4", "gulp-sort": "^2.0.0", "gulp-sourcemaps": "^2.1.1", diff --git a/src/academic-bloggers-toolkit.php b/src/academic-bloggers-toolkit.php index e60ee946..0278f39d 100644 --- a/src/academic-bloggers-toolkit.php +++ b/src/academic-bloggers-toolkit.php @@ -4,14 +4,14 @@ * Plugin Name: Academic Blogger's Toolkit * Plugin URI: https://wordpress.org/plugins/academic-bloggers-toolkit/ * Description: A plugin extending the functionality of Wordpress for academic blogging - * Version: 4.7.1 + * Version: 4.7.2 * Author: Derek P Sifford * Author URI: https://github.com/dsifford * License: GPL3 or later * Text Domain: academic-bloggers-toolkit */ -define('ABT_VERSION', '4.7.1'); +define('ABT_VERSION', '4.7.2'); /** * Load plugin translations diff --git a/src/academic-bloggers-toolkit.pot b/src/academic-bloggers-toolkit.pot index f7144f19..4df58588 100644 --- a/src/academic-bloggers-toolkit.pot +++ b/src/academic-bloggers-toolkit.pot @@ -1,8 +1,8 @@ -# Copyright (C) 2016 Academic Blogger's Toolkit 4.7.1 -# This file is distributed under the same license as the Academic Blogger's Toolkit 4.7.1 package. +# Copyright (C) 2016 Academic Blogger's Toolkit 4.7.2 +# This file is distributed under the same license as the Academic Blogger's Toolkit 4.7.2 package. msgid "" msgstr "" -"Project-Id-Version: Academic Blogger's Toolkit 4.7.1\n" +"Project-Id-Version: Academic Blogger's Toolkit 4.7.2\n" "Report-Msgid-Bugs-To: https://github.com/dsifford/academic-bloggers-toolkit/issues\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" diff --git a/src/lib/js/reference-list/components/ReferenceList.tsx b/src/lib/js/reference-list/components/ReferenceList.tsx index 2c1da2af..528fc488 100644 --- a/src/lib/js/reference-list/components/ReferenceList.tsx +++ b/src/lib/js/reference-list/components/ReferenceList.tsx @@ -238,7 +238,7 @@ export class ReferenceList extends React.Component<{store: Store}, {}> { * from it and push it to data. */ const selection = this.editor.selection.getContent({ format: 'html' }); - if (//.test(selection)) { const re = /"(\w+?)"/g; let m: RegExpExecArray; while ((m = re.exec(selection)) !== null) { // tslint:disable-line:no-conditional-assignment @@ -317,6 +317,7 @@ export class ReferenceList extends React.Component<{store: Store}, {}> { preprocess.then((data) => { + if (data.length === 0) return; this.props.store.citations.addItems(data); data = data.reduce((prev, curr) => { diff --git a/src/lib/js/tinymce/components/pubmed-window/ResultList.tsx b/src/lib/js/tinymce/components/pubmed-window/ResultList.tsx index 6f567756..618c3fca 100644 --- a/src/lib/js/tinymce/components/pubmed-window/ResultList.tsx +++ b/src/lib/js/tinymce/components/pubmed-window/ResultList.tsx @@ -45,7 +45,7 @@ export class ResultList extends React.PureComponent {
el.name).join(', ') /* tslint:disable-line */} />
` + - `[PubMed]` + + `[PubMed]` + ``; } case 'DOI': { @@ -338,7 +338,7 @@ export function parseReferenceURL( case 'PMCID': { return linkedHtml + ` ` + // tslint:disable-next-line - `[PMC]` + + `[PMC]` + ``; } case 'URL': @@ -353,13 +353,13 @@ export function parseReferenceURL( case 'always-full-surround': { switch (id.kind) { case 'PMID': { - return `${html}`; + return `${html}`; } case 'DOI': { return `${html}`; } case 'PMCID': { - return `${html}`; + return `${html}`; // tslint:disable-line } case 'URL': default: { diff --git a/src/lib/js/utils/TinymceFunctions.ts b/src/lib/js/utils/TinymceFunctions.ts index 5048308e..82890d5b 100644 --- a/src/lib/js/utils/TinymceFunctions.ts +++ b/src/lib/js/utils/TinymceFunctions.ts @@ -61,13 +61,13 @@ interface CitationPositions { * @return Parsed citation data. */ export function getRelativeCitationPositions(editor: TinyMCE.Editor, validIds: string[]): CitationPositions { - const doc: Document = editor.dom.doc; + const doc = editor.getDoc(); const currentSelection = editor.selection.getContent({ format: 'html' }); const re = /` ); } @@ -132,20 +132,22 @@ function parseFootnoteCitations( citationByIndex: Citeproc.CitationByIndex, ): Promise { return new Promise(resolve => { - const doc = editor.dom.doc; - const exisingNote = doc.getElementById('abt-footnote'); + const doc = editor.getDoc(); + const existingNote = doc.getElementById('abt-footnote'); + const existingBib = doc.querySelector('#abt-bibliography, #abt-smart-bib'); - if (exisingNote) exisingNote.parentElement.removeChild(exisingNote); + if (existingNote) existingNote.parentElement.removeChild(existingNote); + if (existingBib) existingBib.parentElement.removeChild(existingBib); if (clusters.length === 0) return resolve(true); for (const [index, footnote, elementID] of clusters) { const inlineText = `[${index + 1}]`; - const citation: HTMLSpanElement = editor.dom.doc.getElementById(elementID); + const citation: HTMLSpanElement = doc.getElementById(elementID); const sortedItems: Citeproc.SortedItems = citationByIndex[index].sortedItems; const idList: string = JSON.stringify(sortedItems.map(c => c[1].id)); if (!citation) { - editor.insertContent( + editor.selection.setContent( `('div', { + class: 'abt-footnote noselect mceNonEditable', + id: 'abt-footnote', + }); + const heading = editor.dom.create('div', { + class: 'abt-footnote__heading', + }, top.ABT_i18n.misc.footnotes); - const heading = doc.createElement('div'); - heading.className = 'abt-footnote__heading'; - heading.innerText = top.ABT_i18n.misc.footnotes; note.appendChild(heading); const citations = >doc.querySelectorAll('.abt-citation, .abt_cite'); - [...citations].forEach((c, i) => { c.innerText = `[${i + 1}]`; - - /** - * Iterate and set a new footnote box using stored html on the inline notes. - * "Isn't this really inefficient?". Yes. It's citeproc-js's fault. - */ - const div = doc.createElement('div'); - div.className = 'abt-footnote__item'; - div.innerHTML = + const noteItem = editor.dom.create('div', { + class: 'abt-footnote__item', + }, `[${i + 1}]` + - `${c.dataset['footnote']}`; - note.appendChild(div); + `${c.dataset['footnote']}` + ); + note.appendChild(noteItem); }); + editor.getBody().appendChild(note); - const bib = doc.querySelector('#abt-bibliography, #abt-smart-bib'); - - // Save a reference to the current cursor location - const selection = editor.selection; - const cursor = editor.dom.create('span', { class: 'abt-citation', id: 'CURSOR' }); - selection.getNode().appendChild(cursor); - - // Do work - if (bib) bib.parentNode.removeChild(bib); - - editor.setContent(editor.getContent() + note.outerHTML); - - // Move cursor back to where it was & delete reference - const el = doc.getElementById('CURSOR'); - if (el) { - editor.selection.select(el, true); - editor.selection.collapse(true); - el.parentElement.removeChild(el); - } - - // Remove unnecessary   from editor - const p = editor.dom.doc.getElementById('abt-footnote').previousElementSibling; - if (p.tagName === 'P' && p.textContent.trim() === '') { + while ( + note.previousElementSibling + && note.previousElementSibling.childNodes.length === 1 + && note.previousElementSibling.childNodes[0].nodeName === 'BR') { + const p = note.previousElementSibling; p.parentNode.removeChild(p); } - resolve(true); + editor.setContent(editor.getBody().innerHTML); + editor.selection.moveToBookmark(bm); + + return resolve(true); }); } @@ -224,8 +210,8 @@ function parseInTextCitations( ): Promise { return new Promise(resolve => { const doc = editor.dom.doc; - const exisingNote = doc.getElementById('abt-footnote'); - if (exisingNote) exisingNote.parentElement.removeChild(exisingNote); + const existingNote = doc.getElementById('abt-footnote'); + if (existingNote) existingNote.parentElement.removeChild(existingNote); for (const [index, inlineText, elementID] of clusters) { const citation: HTMLSpanElement = editor.dom.doc.getElementById(elementID); @@ -233,7 +219,7 @@ function parseInTextCitations( const idList: string = JSON.stringify(sortedItems.map(c => c[1].id)); if (!citation) { - editor.insertContent( + editor.selection.setContent( `('div', { + class: 'abt-bibliography noselect mceNonEditable', + id: 'abt-bibliography', + }); - const container = doc.createElement('div'); - container.id = container.className = 'abt-bibliography__container'; + const container = editor.dom.create('div', { + class: 'abt-bibliography__container', + id: 'abt-bibliography__container', + }); if (options.heading) { - const heading = doc.createElement('h3'); + const heading = editor.dom.create('h3', { + class: 'abt-bibliography__heading', + }); heading.innerText = options.heading; - heading.classList.add('abt-bibliography__heading'); if (options.style === 'toggle') heading.classList.add('abt-bibliography__heading_toggle'); bib.appendChild(heading); } @@ -289,36 +279,26 @@ export function setBibliography( bib.appendChild(container); for (const meta of bibliography) { - const item = doc.createElement('div'); - item.id = meta.id; - item.innerHTML = meta.html; + const item = editor.dom.create('div', { + id: meta.id, + }, meta.html); container.appendChild(item); } - if (existingBib) existingBib.parentElement.removeChild(existingBib); - if (container.children.length === 0) return; - - // Save a reference to the current cursor location - const selection = editor.selection; - const cursor = editor.dom.create('span', { class: 'abt-citation', id: 'CURSOR' }); - selection.getNode().appendChild(cursor); - - // Do work - editor.setContent(editor.getContent() + bib.outerHTML); - - // Move cursor back to where it was & delete reference - const el = editor.dom.doc.getElementById('CURSOR'); - if (el) { - editor.selection.select(el, true); - editor.selection.collapse(true); - el.parentElement.removeChild(el); + if (container.children.length > 0) { + editor.getBody().appendChild(bib); } // Remove unnecessary   from editor - const p = editor.dom.doc.getElementById('abt-bibliography').previousElementSibling; - if (p.tagName === 'P' && p.textContent.trim() === '') { + while ( + bib.previousElementSibling + && bib.previousElementSibling.childNodes.length === 1 + && bib.previousElementSibling.childNodes[0].nodeName === 'BR') { + const p = bib.previousElementSibling; p.parentNode.removeChild(p); } + editor.setContent(editor.getBody().innerHTML); + editor.selection.moveToBookmark(bm); } export function reset(doc: HTMLDocument) { diff --git a/src/lib/js/utils/__tests__/HelperFunctions-test.ts b/src/lib/js/utils/__tests__/HelperFunctions-test.ts index 8ccc2a65..dc0cdfd3 100644 --- a/src/lib/js/utils/__tests__/HelperFunctions-test.ts +++ b/src/lib/js/utils/__tests__/HelperFunctions-test.ts @@ -332,22 +332,22 @@ describe('HelperFunctions', () => { it('should handle PMIDs', () => { expect(parseReferenceURL( testRefs[0], 'always', { kind: 'PMID', value: PMID } - )).toBe('Body R. The ProMISe Study: EGDT RIP? St. Emlyn’s website. http://stemlynsblog.org/the-promise-study-egdt-rip/; http://blogs.nejm.org/now/index.php/the-final-nail-in-early-goal-directed-therapys-coffin/2015/03/24/. Published 2015. [PubMed]') + )).toBe('Body R. The ProMISe Study: EGDT RIP? St. Emlyn’s website. http://stemlynsblog.org/the-promise-study-egdt-rip/; http://blogs.nejm.org/now/index.php/the-final-nail-in-early-goal-directed-therapys-coffin/2015/03/24/. Published 2015. [PubMed]') expect(parseReferenceURL( testRefs[1], 'always', { kind: 'PMID', value: PMID } - )).toBe('Chan T, Helman A, Davis T, Purdy E. MEdIC Series | The Case the FOAM Faux Pas – Expert Review and Curated Commentary. Academic Life in Emergency Medicine. http://aliem.com/MEdIC-Series-The-Case-the-FOAM-Faux-Pas-Expert-Review-and-Curated-Commentary. Published 2015. [PubMed]'); + )).toBe('Chan T, Helman A, Davis T, Purdy E. MEdIC Series | The Case the FOAM Faux Pas – Expert Review and Curated Commentary. Academic Life in Emergency Medicine. http://aliem.com/MEdIC-Series-The-Case-the-FOAM-Faux-Pas-Expert-Review-and-Curated-Commentary. Published 2015. [PubMed]'); expect(parseReferenceURL( testRefs[2], 'always', { kind: 'PMID', value: PMID } - )).toBe('Colmers IN, Paterson QS, Lin M, Thoma B, Chan TM. The quality checklists for medical education blogs and podcasts. The Winnower. 2015. doi: 10.15200/winn.144720.08769 [PubMed]'); + )).toBe('Colmers IN, Paterson QS, Lin M, Thoma B, Chan TM. The quality checklists for medical education blogs and podcasts. The Winnower. 2015. doi: 10.15200/winn.144720.08769 [PubMed]'); expect(parseReferenceURL( testRefs[3], 'always', { kind: 'PMID', value: PMID } - )).toBe('Mathieu S. Trial of Early, Goal-Directed Resuscitation for Septic Shock. The Bottom Line. http://www.wessexics.com/The_Bottom_Line/Review/index.php?id=3665078336903245716. Published 2015. [PubMed]') + )).toBe('Mathieu S. Trial of Early, Goal-Directed Resuscitation for Septic Shock. The Bottom Line. http://www.wessexics.com/The_Bottom_Line/Review/index.php?id=3665078336903245716. Published 2015. [PubMed]') expect(parseReferenceURL( testRefs[4], 'always', { kind: 'PMID', value: PMID } - )).toBe('Cameron P. Pundit-Based Medicine. Emergency Physicians International. [PubMed]') + )).toBe('Cameron P. Pundit-Based Medicine. Emergency Physicians International. [PubMed]') expect(parseReferenceURL( testRefs[5], 'always', { kind: 'PMID', value: PMID } - )).toBe(`Dunning J. Unskilled and unaware of it. Journal of Personality and Social Psychology. 1999;77(6):1121-1134. http://psych.colorado.edu/~vanboven/teaching/p7536_heurbias/p7536_readings/kruger_dunning.pdf. [PubMed]`) + )).toBe(`Dunning J. Unskilled and unaware of it. Journal of Personality and Social Psychology. 1999;77(6):1121-1134. http://psych.colorado.edu/~vanboven/teaching/p7536_heurbias/p7536_readings/kruger_dunning.pdf. [PubMed]`) }); it('should handle DOIs', () => { expect(parseReferenceURL( @@ -372,22 +372,22 @@ describe('HelperFunctions', () => { it('should handle PMCIDs', () => { expect(parseReferenceURL( testRefs[0], 'always', { kind: 'PMCID', value: PMCID } - )).toBe('Body R. The ProMISe Study: EGDT RIP? St. Emlyn’s website. http://stemlynsblog.org/the-promise-study-egdt-rip/; http://blogs.nejm.org/now/index.php/the-final-nail-in-early-goal-directed-therapys-coffin/2015/03/24/. Published 2015. [PMC]') + )).toBe('Body R. The ProMISe Study: EGDT RIP? St. Emlyn’s website. http://stemlynsblog.org/the-promise-study-egdt-rip/; http://blogs.nejm.org/now/index.php/the-final-nail-in-early-goal-directed-therapys-coffin/2015/03/24/. Published 2015. [PMC]') expect(parseReferenceURL( testRefs[1], 'always', { kind: 'PMCID', value: PMCID } - )).toBe('Chan T, Helman A, Davis T, Purdy E. MEdIC Series | The Case the FOAM Faux Pas – Expert Review and Curated Commentary. Academic Life in Emergency Medicine. http://aliem.com/MEdIC-Series-The-Case-the-FOAM-Faux-Pas-Expert-Review-and-Curated-Commentary. Published 2015. [PMC]'); + )).toBe('Chan T, Helman A, Davis T, Purdy E. MEdIC Series | The Case the FOAM Faux Pas – Expert Review and Curated Commentary. Academic Life in Emergency Medicine. http://aliem.com/MEdIC-Series-The-Case-the-FOAM-Faux-Pas-Expert-Review-and-Curated-Commentary. Published 2015. [PMC]'); expect(parseReferenceURL( testRefs[2], 'always', { kind: 'PMCID', value: PMCID } - )).toBe('Colmers IN, Paterson QS, Lin M, Thoma B, Chan TM. The quality checklists for medical education blogs and podcasts. The Winnower. 2015. doi: 10.15200/winn.144720.08769 [PMC]'); + )).toBe('Colmers IN, Paterson QS, Lin M, Thoma B, Chan TM. The quality checklists for medical education blogs and podcasts. The Winnower. 2015. doi: 10.15200/winn.144720.08769 [PMC]'); expect(parseReferenceURL( testRefs[3], 'always', { kind: 'PMCID', value: PMCID } - )).toBe('Mathieu S. Trial of Early, Goal-Directed Resuscitation for Septic Shock. The Bottom Line. http://www.wessexics.com/The_Bottom_Line/Review/index.php?id=3665078336903245716. Published 2015. [PMC]') + )).toBe('Mathieu S. Trial of Early, Goal-Directed Resuscitation for Septic Shock. The Bottom Line. http://www.wessexics.com/The_Bottom_Line/Review/index.php?id=3665078336903245716. Published 2015. [PMC]') expect(parseReferenceURL( testRefs[4], 'always', { kind: 'PMCID', value: PMCID } - )).toBe('Cameron P. Pundit-Based Medicine. Emergency Physicians International. [PMC]') + )).toBe('Cameron P. Pundit-Based Medicine. Emergency Physicians International. [PMC]') expect(parseReferenceURL( testRefs[5], 'always', { kind: 'PMCID', value: PMCID } - )).toBe(`Dunning J. Unskilled and unaware of it. Journal of Personality and Social Psychology. 1999;77(6):1121-1134. http://psych.colorado.edu/~vanboven/teaching/p7536_heurbias/p7536_readings/kruger_dunning.pdf. [PMC]`) + )).toBe(`Dunning J. Unskilled and unaware of it. Journal of Personality and Social Psychology. 1999;77(6):1121-1134. http://psych.colorado.edu/~vanboven/teaching/p7536_heurbias/p7536_readings/kruger_dunning.pdf. [PMC]`) }); it('should handle URLs', () => { expect(parseReferenceURL( @@ -434,22 +434,22 @@ describe('HelperFunctions', () => { it('should handle PMIDs', () => { expect(parseReferenceURL( testRefs[0], 'always-full-surround', { kind: 'PMID', value: PMID } - )).toBe('Body R. The ProMISe Study: EGDT RIP? St. Emlyn’s website. http://stemlynsblog.org/the-promise-study-egdt-rip/; http://blogs.nejm.org/now/index.php/the-final-nail-in-early-goal-directed-therapys-coffin/2015/03/24/. Published 2015.') + )).toBe('Body R. The ProMISe Study: EGDT RIP? St. Emlyn’s website. http://stemlynsblog.org/the-promise-study-egdt-rip/; http://blogs.nejm.org/now/index.php/the-final-nail-in-early-goal-directed-therapys-coffin/2015/03/24/. Published 2015.') expect(parseReferenceURL( testRefs[1], 'always-full-surround', { kind: 'PMID', value: PMID } - )).toBe('Chan T, Helman A, Davis T, Purdy E. MEdIC Series | The Case the FOAM Faux Pas – Expert Review and Curated Commentary. Academic Life in Emergency Medicine. www.aliem.com/MEdIC-Series-The-Case-the-FOAM-Faux-Pas-Expert-Review-and-Curated-Commentary. Published 2015.'); + )).toBe('Chan T, Helman A, Davis T, Purdy E. MEdIC Series | The Case the FOAM Faux Pas – Expert Review and Curated Commentary. Academic Life in Emergency Medicine. www.aliem.com/MEdIC-Series-The-Case-the-FOAM-Faux-Pas-Expert-Review-and-Curated-Commentary. Published 2015.'); expect(parseReferenceURL( testRefs[2], 'always-full-surround', { kind: 'PMID', value: PMID } - )).toBe('Colmers IN, Paterson QS, Lin M, Thoma B, Chan TM. The quality checklists for medical education blogs and podcasts. The Winnower. 2015. doi:10.15200/winn.144720.08769.'); + )).toBe('Colmers IN, Paterson QS, Lin M, Thoma B, Chan TM. The quality checklists for medical education blogs and podcasts. The Winnower. 2015. doi:10.15200/winn.144720.08769.'); expect(parseReferenceURL( testRefs[3], 'always-full-surround', { kind: 'PMID', value: PMID } - )).toBe('Mathieu S. Trial of Early, Goal-Directed Resuscitation for Septic Shock. The Bottom Line. http://www.wessexics.com/The_Bottom_Line/Review/index.php?id=3665078336903245716. Published 2015.') + )).toBe('Mathieu S. Trial of Early, Goal-Directed Resuscitation for Septic Shock. The Bottom Line. http://www.wessexics.com/The_Bottom_Line/Review/index.php?id=3665078336903245716. Published 2015.') expect(parseReferenceURL( testRefs[4], 'always-full-surround', { kind: 'PMID', value: PMID } - )).toBe('Cameron P. Pundit-Based Medicine. Emergency Physicians International.') + )).toBe('Cameron P. Pundit-Based Medicine. Emergency Physicians International.') expect(parseReferenceURL( testRefs[5], 'always-full-surround', { kind: 'PMID', value: PMID } - )).toBe(`Dunning J. Unskilled and unaware of it. Journal of Personality and Social Psychology. 1999;77(6):1121-1134. http://psych.colorado.edu/~vanboven/teaching/p7536_heurbias/p7536_readings/kruger_dunning.pdf.`) + )).toBe(`Dunning J. Unskilled and unaware of it. Journal of Personality and Social Psychology. 1999;77(6):1121-1134. http://psych.colorado.edu/~vanboven/teaching/p7536_heurbias/p7536_readings/kruger_dunning.pdf.`) }); it('should handle DOIs', () => { expect(parseReferenceURL( @@ -474,22 +474,22 @@ describe('HelperFunctions', () => { it('should handle PMCIDs', () => { expect(parseReferenceURL( testRefs[0], 'always-full-surround', { kind: 'PMCID', value: PMCID } - )).toBe('Body R. The ProMISe Study: EGDT RIP? St. Emlyn’s website. http://stemlynsblog.org/the-promise-study-egdt-rip/; http://blogs.nejm.org/now/index.php/the-final-nail-in-early-goal-directed-therapys-coffin/2015/03/24/. Published 2015.') + )).toBe('Body R. The ProMISe Study: EGDT RIP? St. Emlyn’s website. http://stemlynsblog.org/the-promise-study-egdt-rip/; http://blogs.nejm.org/now/index.php/the-final-nail-in-early-goal-directed-therapys-coffin/2015/03/24/. Published 2015.') expect(parseReferenceURL( testRefs[1], 'always-full-surround', { kind: 'PMCID', value: PMCID } - )).toBe('Chan T, Helman A, Davis T, Purdy E. MEdIC Series | The Case the FOAM Faux Pas – Expert Review and Curated Commentary. Academic Life in Emergency Medicine. www.aliem.com/MEdIC-Series-The-Case-the-FOAM-Faux-Pas-Expert-Review-and-Curated-Commentary. Published 2015.'); + )).toBe('Chan T, Helman A, Davis T, Purdy E. MEdIC Series | The Case the FOAM Faux Pas – Expert Review and Curated Commentary. Academic Life in Emergency Medicine. www.aliem.com/MEdIC-Series-The-Case-the-FOAM-Faux-Pas-Expert-Review-and-Curated-Commentary. Published 2015.'); expect(parseReferenceURL( testRefs[2], 'always-full-surround', { kind: 'PMCID', value: PMCID } - )).toBe('Colmers IN, Paterson QS, Lin M, Thoma B, Chan TM. The quality checklists for medical education blogs and podcasts. The Winnower. 2015. doi:10.15200/winn.144720.08769.'); + )).toBe('Colmers IN, Paterson QS, Lin M, Thoma B, Chan TM. The quality checklists for medical education blogs and podcasts. The Winnower. 2015. doi:10.15200/winn.144720.08769.'); expect(parseReferenceURL( testRefs[3], 'always-full-surround', { kind: 'PMCID', value: PMCID } - )).toBe('Mathieu S. Trial of Early, Goal-Directed Resuscitation for Septic Shock. The Bottom Line. http://www.wessexics.com/The_Bottom_Line/Review/index.php?id=3665078336903245716. Published 2015.') + )).toBe('Mathieu S. Trial of Early, Goal-Directed Resuscitation for Septic Shock. The Bottom Line. http://www.wessexics.com/The_Bottom_Line/Review/index.php?id=3665078336903245716. Published 2015.') expect(parseReferenceURL( testRefs[4], 'always-full-surround', { kind: 'PMCID', value: PMCID } - )).toBe('Cameron P. Pundit-Based Medicine. Emergency Physicians International.') + )).toBe('Cameron P. Pundit-Based Medicine. Emergency Physicians International.') expect(parseReferenceURL( testRefs[5], 'always-full-surround', { kind: 'PMCID', value: PMCID } - )).toBe(`Dunning J. Unskilled and unaware of it. Journal of Personality and Social Psychology. 1999;77(6):1121-1134. http://psych.colorado.edu/~vanboven/teaching/p7536_heurbias/p7536_readings/kruger_dunning.pdf.`) + )).toBe(`Dunning J. Unskilled and unaware of it. Journal of Personality and Social Psychology. 1999;77(6):1121-1134. http://psych.colorado.edu/~vanboven/teaching/p7536_heurbias/p7536_readings/kruger_dunning.pdf.`) }); it('should handle URLs', () => { expect(parseReferenceURL( diff --git a/src/readme.txt b/src/readme.txt index 85d9fb04..0ccfaf92 100644 --- a/src/readme.txt +++ b/src/readme.txt @@ -4,7 +4,7 @@ Donate link: https://donorbox.org/academic-bloggers-toolkit Tags: academia, academic, bibliographies, bibliography, citation, citations, cite, citing, CSL, curriculum vitae, cv, doi, endnote, footnote, footnotes, journal, mendeley, papers, pmid, publications, publish, pubmed, reference, reference list, reference manager, references, referencing, ris, scholar, scholarly, zotero Requires at least: 4.2.2 Tested up to: 4.6 -Stable tag: 4.7.1 +Stable tag: 4.7.2 License: GPL3 or later License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -57,6 +57,10 @@ Yikes! I'm sorry about that. Please report all issues on the Academic Blogger's == Changelog == += 4.7.2 = + +[Click here](https://headwayapp.co/academic-bloggers-toolkit-changelog) to view changes. + = 4.7.1 = [Click here](https://headwayapp.co/academic-bloggers-toolkit-changelog) to view changes. diff --git a/src/vendor/citationstyles.php b/src/vendor/citationstyles.php index 964276b2..4086649c 100644 --- a/src/vendor/citationstyles.php +++ b/src/vendor/citationstyles.php @@ -1,3 +1,3 @@ \ No newline at end of file diff --git a/src/vendor/citeproc.js b/src/vendor/citeproc.js index 5c6b7b13..8aad0897 100644 --- a/src/vendor/citeproc.js +++ b/src/vendor/citeproc.js @@ -23,7 +23,7 @@ * respectively. */ var CSL = { - PROCESSOR_VERSION: "1.1.139", + PROCESSOR_VERSION: "1.1.140", CONDITION_LEVEL_TOP: 1, CONDITION_LEVEL_BOTTOM: 2, PLAIN_HYPHEN_REGEX: /(?:[^\\]-|\u2013)/, @@ -8829,7 +8829,9 @@ CSL.NameOutput.prototype._renderInstitutionName = function (v, name, slot, j) { institution = [this._composeOneInstitutionPart([n.l.pri, n.l.sec, n.l.ter], slot, long_style, v)]; break; } - return this._join(institution, " "); + var blob = this._join(institution, " "); + this.state.tmp.name_node.children.push(blob); + return blob; }; CSL.NameOutput.prototype._composeOneInstitutionPart = function (names, slot, style, v) { var primary = false, secondary = false, tertiary = false, primary_tok, secondary_tok, tertiary_tok; @@ -13327,7 +13329,7 @@ CSL.Util.substituteEnd = function (state, target) { } else if ("complete-each" === subrule) { var rendered_name = state.tmp.rendered_name.join(","); if (rendered_name) { - if (!rendered_name.localeCompare(state.tmp.last_rendered_name)) { + if (state.tmp.last_rendered_name && !rendered_name.localeCompare(state.tmp.last_rendered_name)) { for (i = 0, ilen = state.tmp.name_node.children.length; i < ilen; i += 1) { str = new CSL.Blob(state[state.tmp.area].opt["subsequent-author-substitute"]); state.tmp.name_node.children[i].blobs = [str]; diff --git a/types/tinymce.d.ts b/types/tinymce.d.ts index c9d56009..9f89ccee 100644 --- a/types/tinymce.d.ts +++ b/types/tinymce.d.ts @@ -24,7 +24,7 @@ declare namespace TinyMCE { contentWindow: Window; controlManager: Object; dom: { - create(tag: string, attrs: { [attr: string]: string}, children?: string): HTMLElement; + create(tag: string, attrs: { [attr: string]: string}, children?: string): T; doc: Document; getStyle(element: HTMLElement, name: string, computed: boolean): string; }; @@ -37,6 +37,7 @@ declare namespace TinyMCE { getBookmark(type?: number, normalized?: boolean): Object; // tslint:disable-line getNode(): Node; getContent(args: { format: 'html'|'text' }): string; + setContent(content: string, args?: { format: string }): string moveToBookmark(bookmark: Object): boolean; select(el: HTMLElement, content: boolean); setCursorLocation(a): void; @@ -50,6 +51,7 @@ declare namespace TinyMCE { addButton(buttonID: string, buttonObj: Object): void; addShortcut(keys: string, title: string, func: Function): void; getBody(): HTMLBodyElement; + getDoc(): HTMLDocument; getContent(): string; setContent(content: string, args?: Object): string; insertContent(content: string): void; diff --git a/webpack.config.js b/webpack.config.js index 56788cc9..20ab02fa 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,5 @@ const path = require('path'); const webpack = require('webpack'); -const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin; const isProduction = process.env.NODE_ENV === 'production'; @@ -10,7 +9,6 @@ const sharedPlugins = [ debug: false, }), new webpack.NoErrorsPlugin(), - new ForkCheckerPlugin(), new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', minChunks: Infinity, @@ -69,11 +67,11 @@ module.exports = { { test: /\.tsx?$/, include: path.resolve(__dirname, 'src'), - loaders: ['awesome-typescript'], + loaders: ['awesome-typescript-loader'], }, { test: /\.css$/, - loaders: ['style', 'css'], + loaders: ['style-loader', 'css-loader'], }, ], },