Skip to content

Commit d7564a8

Browse files
authored
chore(wordpress): update web-embed-pdf to 1.8.4 and bump plugin to 1.1.3 (#29)
## Background Update the WordPress plugin to use the latest version of `@simplepdf/web-embed-pdf` (1.8.4) and bump the plugin version to 1.1.3. Also updates the "Tested up to" WordPress version to 6.9.4. ## Changes - Update `@simplepdf/web-embed-pdf` dependency from `^1.8.2` to `^1.8.4` - Bump plugin version from 1.1.2 to 1.1.3 - Update `wp_enqueue_script` version parameter to 1.8.4 - Update `Tested up to` from 6.7.1 to 6.9.4 - Copy updated source and build artifacts to SVN trunk - Add changelog entry for 1.1.3
1 parent 77c4c81 commit d7564a8

8 files changed

Lines changed: 66 additions & 18 deletions

File tree

wordpress/package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wordpress/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"package-plugin": "npm install && npm run copy-src && npm run copy-build"
66
},
77
"dependencies": {
8-
"@simplepdf/web-embed-pdf": "^1.8.2"
8+
"@simplepdf/web-embed-pdf": "^1.8.4"
99
}
1010
}

wordpress/svn/assets/blueprints/blueprint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"step": "installPlugin",
1414
"pluginZipFile": {
1515
"resource": "url",
16-
"url": "https://downloads.wordpress.org/plugin/simplepdf-embed.1.1.2.zip"
16+
"url": "https://downloads.wordpress.org/plugin/simplepdf-embed.1.1.3.zip"
1717
},
1818
"options": {
1919
"activate": true

wordpress/svn/trunk/README.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
=== SimplePDF Embed ===
22
Contributors: bendersej
33
Tags: pdf, embed pdf, fill & sign PDF, pdf editor
4-
Tested up to: 6.7.1
5-
Stable tag: 1.1.2
4+
Tested up to: 6.9.4
5+
Stable tag: 1.1.3
66
License: GPLv2 or later
77
License URI: https://www.gnu.org/licenses/gpl-2.0.html
88
Requires at least: 5.8
@@ -90,4 +90,7 @@ Our Github repository contains both the code for the Wordpress plugin as well as
9090
* Move to SimplePDF.com (from SimplePDF.eu)
9191
= 1.1.2 =
9292
* Plugin tested with the latest wordpress version (6.7.1)
93+
= 1.1.3 =
94+
* Update web-embed-pdf to 1.8.4
95+
* Plugin tested with the latest wordpress version (6.9.4)
9396

wordpress/svn/trunk/build/web-embed-pdf.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wordpress/svn/trunk/simplepdf-embed.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Author: SimplePDF
66
Author URI: https://simplepdf.com
77
Description: Your visitors can fill & sign PDFs without leaving your website.
8-
Version: 1.1.2
8+
Version: 1.1.3
99
License: GPL v2 or later
1010
License URI: https://www.gnu.org/licenses/gpl-2.0.html
1111
*/
@@ -64,7 +64,7 @@ function enqueue_simplepdf_script() {
6464
$plugin_url = plugin_dir_url(__FILE__);
6565
$script_src = $plugin_url . 'build/web-embed-pdf.js';
6666

67-
wp_enqueue_script('simplepdf-web-embed-pdf', $script_src, array(), '1.8.2', true);
67+
wp_enqueue_script('simplepdf-web-embed-pdf', $script_src, array(), '1.8.4', true);
6868

6969
$company_identifier = get_option('simplepdf_company_identifier');
7070
$companyIdentifier = empty($company_identifier) ? 'wordpress' : $company_identifier;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { JSDOM } from 'jsdom';
2+
import { describe, it, expect } from 'vitest';
3+
import { getSimplePDFElements } from '../shared';
4+
5+
describe('getSimplePDFElements', () => {
6+
it('detects elements to open with SimplePDF', () => {
7+
const dom = new JSDOM(
8+
`<!doctype html>
9+
<html>
10+
<body>
11+
<!--Should detect below-->
12+
<a href="https://pdfobject.com/pdf/sample-3pp.pdf">PDF link</a>
13+
<a href="https://example.com/some-pdf-without-extension" class="simplepdf">Regular link with class</a>
14+
<button class="simplepdf">Button with class</button>
15+
<a href="https://yourcompany.simplepdf.com/form/d8d57ec7-f3e9-4fc9-8cc5-4a92c02d30d0">SimplePDF form link</a>
16+
<a href="https://yourcompany.simplepdf.com/documents/d8d57ec7-f3e9-4fc9-8cc5-4a92c02d30d0">SimplePDF document link</a>
17+
<!--Should NOT detect below-->
18+
<a href="https://pdfobject.com/pdf/sample-3pp.pdf" class="exclude-simplepdf">PDF link with class exclusion</a>
19+
<a href="https://yourcompany.simplepdf.com/form/d8d57ec7-f3e9-4fc9-8cc5-4a92c02d30d0" class="exclude-simplepdf">SimplePDF form link with exclusion</a>
20+
<a href="https://www.pdfsomething.com/anything">Regular link containing .pdf</a>
21+
<a href="https://www.website.com/some-pdf">Should not be opened with SimplePDF</a>
22+
<a href="https://www.website.com/some-other.pdf.png">Should not be opened with SimplePDF</a>
23+
<a href="https://www.simplepdf.app/s/article/How-to-Manage-PDF-Settings">Should not be opened with SimplePDF</a>
24+
<a href="https://www.app.pdf/some-url">Should not be opened with SimplePDF</a>
25+
</body>
26+
</html>
27+
`,
28+
{ url: 'http://localhost' },
29+
);
30+
const detectedElements = getSimplePDFElements(dom.window.document);
31+
expect(detectedElements).toHaveLength(5);
32+
expect(detectedElements.map(({ innerHTML }) => innerHTML)).toStrictEqual(
33+
expect.arrayContaining([
34+
'Button with class',
35+
'PDF link',
36+
'Regular link with class',
37+
'SimplePDF form link',
38+
'SimplePDF document link',
39+
]),
40+
);
41+
});
42+
});

wordpress/svn/trunk/src/shared.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ const editorContext: EditorContext = {
3232
},
3333
};
3434

35-
const isFormLink = (url: string) => {
36-
const regex = /^https:\/\/[^.]+\.simplepdf\.com\/[^\/]+\/form\/.+/;
35+
const isSimplePDFLink = (url: string) => {
36+
const regex = /^https:\/\/[^.]+\.simplepdf\.com(\/[^\/]+)?\/(form|documents)\/.+/;
3737
return regex.test(url);
3838
};
3939

40+
const isPDFLink = (url: string) => url.endsWith('.pdf');
41+
4042
const getLocale = (): Locale => {
4143
const languageCode = (() => {
4244
try {
@@ -111,7 +113,7 @@ export const setConfig: ConfigSetter = (params) => {
111113
return config;
112114
};
113115

114-
const getSimplePDFElements = (): Element[] => {
116+
export const getSimplePDFElements = (document: Document): Element[] => {
115117
const getAnchors = (): HTMLAnchorElement[] => {
116118
const anchors = Array.from(document.getElementsByTagName('a'));
117119

@@ -120,7 +122,7 @@ const getSimplePDFElements = (): Element[] => {
120122
return false;
121123
}
122124

123-
return anchor.href.includes('.pdf') || anchor.classList.contains('simplepdf') || isFormLink(anchor.href);
125+
return isPDFLink(anchor.href) || anchor.classList.contains('simplepdf') || isSimplePDFLink(anchor.href);
124126
});
125127

126128
return anchorsWithPDF;
@@ -327,8 +329,8 @@ export const openEditor = ({ href, context }: { href: string | null; context?: R
327329
</button>
328330
<div class="simplePDF_iframeContainer">
329331
<iframe id="${IFRAME_ID}" referrerPolicy="no-referrer-when-downgrade" class="simplePDF_iframe" src="${
330-
iframeURL.href
331-
}" onload="${onIframeLoaded()}"/>
332+
iframeURL.href
333+
}" onload="${onIframeLoaded()}"/>
332334
</div>
333335
</div>
334336
</div>
@@ -402,7 +404,7 @@ const enableAutoOpen = () => {
402404
return;
403405
}
404406

405-
const elements = getSimplePDFElements();
407+
const elements = getSimplePDFElements(document);
406408

407409
editorContext.log('Attaching listeners to anchors', {
408410
anchorsCount: elements.length,

0 commit comments

Comments
 (0)