Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: false positive pdf link detection for www.pdf* websites #16

Merged
merged 5 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/react.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Test formatting
- name: Formatting
run: npm run test:format

- name: Test types
- name: Types
run: npm run test:types
43 changes: 43 additions & 0 deletions .github/workflows/web.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Web

on:
push:
branches:
- main
paths:
- web/**
- .github/workflows/web.yaml
pull_request:
branches:
- main
paths:
- web/**
- .github/workflows/web.yaml

jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: web

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"

- name: Install dependencies
run: npm ci

- name: Formatting
run: npm run test:format

- name: Types
run: npm run test:types

- name: Unit tests
run: npm run test:unit
8 changes: 8 additions & 0 deletions web/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dist/

package.json
package-lock.json

.prettierignore
.prettierrc
.DS_Store
7 changes: 6 additions & 1 deletion web/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"jsxBracketSameLine": true,
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
Expand All @@ -26,6 +25,12 @@
"options": {
"parser": "json"
}
},
{
"files": "*.md",
"options": {
"parser": "markdown"
}
}
]
}
19 changes: 11 additions & 8 deletions web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ Add this script in the head of your webpage:

_Replace `companyIdentifier` with your own_

<!-- prettier-ignore-start -->
```html
<script
src="https://unpkg.com/@simplepdf/web-embed-pdf"
companyIdentifier="yourcompany"
defer
></script>
```
<!-- prettier-ignore-end -->

## How does it work?

Expand All @@ -69,9 +71,7 @@ Exclude any anchor tags from opening SimplePDF by adding the class `exclude-simp
Add a class `simplepdf` to any anchor tag to open them with SimplePDF:

```html
<a href="/example_without_pdf_extension" class="simplepdf"
>Open with SimplePDF</a
>
<a href="/example_without_pdf_extension" class="simplepdf">Open with SimplePDF</a>
```

## Advanced usage
Expand All @@ -91,6 +91,7 @@ SimplePDF currently supports the following languages automatically detects the l

**If you wish to override the automatic detection, you can specify the `locale` attribute on the script tag as follows**:

<!-- prettier-ignore-start -->
```html
<script
src="https://unpkg.com/@simplepdf/web-embed-pdf"
Expand All @@ -99,13 +100,14 @@ SimplePDF currently supports the following languages automatically detects the l
defer
></script>
```
<!-- prettier-ignore-end -->

### Opening the editor programmatically

#### Open the editor with a specific PDF

```javascript
window.simplePDF.openEditor({ href: "publicly_available_url_pdf" });
window.simplePDF.openEditor({ href: 'publicly_available_url_pdf' });
```

#### Let your customers pick the PDF on their computer
Expand Down Expand Up @@ -133,17 +135,18 @@ _Do not store sensitive information in the context (!!) as it is available local

```javascript
window.simplePDF.openEditor({
href: "publicly_available_url_pdf",
href: 'publicly_available_url_pdf',
context: {
customer_id: "123",
environment: "prod",
customer_id: '123',
environment: 'prod',
},
});
```

### Updating the configuration programmatically

**Use-cases:**

- Change the locale at run time
- Enabling / Disabling _Auto Open_: automatically opening the editor for anchor tags pointing to PDF files. By default enabled when SimplePDF is added as a script
- Change the company identifier at run time
Expand All @@ -153,4 +156,4 @@ window.simplePDF.setConfig({
locale: 'fr',
autoOpen: false,
});
```
```
Loading
Loading