mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-20 02:05:21 -04:00
Remove PDF embedding (#1000)
* Remove PDF embedding * Add pdf deprecation to CHANGELOG.md Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
parent
c862ca341f
commit
add741a677
10 changed files with 50 additions and 118 deletions
|
@ -1,9 +0,0 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
.pdf-frame {
|
||||
width: 100%;
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import React, { useState } from 'react'
|
||||
import { ExternalLink } from '../../../common/links/external-link'
|
||||
import { OneClickEmbedding } from '../one-click-frame/one-click-embedding'
|
||||
import './pdf-frame.scss'
|
||||
|
||||
export interface PdfFrameProps {
|
||||
url: string
|
||||
}
|
||||
|
||||
export const PdfFrame: React.FC<PdfFrameProps> = ({ url }) => {
|
||||
const [activated, setActivated] = useState(false)
|
||||
|
||||
return (
|
||||
<OneClickEmbedding containerClassName={`embed-responsive embed-responsive-${activated ? '4by3' : '16by9'}`}
|
||||
previewContainerClassName={'embed-responsive-item bg-danger'}
|
||||
hoverIcon={'file-pdf-o'}
|
||||
hoverTextI18nKey={'editor.embeddings.clickToLoad'}
|
||||
onActivate={() => setActivated(true)}>
|
||||
<object type={'application/pdf'} data={url} className={'pdf-frame'}>
|
||||
<ExternalLink text={url} href={url}/>
|
||||
</object>
|
||||
</OneClickEmbedding>
|
||||
)
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { DomElement } from 'domhandler'
|
||||
import MarkdownIt from 'markdown-it'
|
||||
import markdownItRegex from 'markdown-it-regex'
|
||||
import React from 'react'
|
||||
import { ComponentReplacer } from '../ComponentReplacer'
|
||||
import { getAttributesFromHedgeDocTag } from '../utils'
|
||||
import { PdfFrame } from './pdf-frame'
|
||||
import { replacePdfShortCode } from './replace-pdf-short-code'
|
||||
|
||||
export class PdfReplacer extends ComponentReplacer {
|
||||
private counterMap: Map<string, number> = new Map<string, number>()
|
||||
|
||||
public getReplacement (node: DomElement): React.ReactElement | undefined {
|
||||
const attributes = getAttributesFromHedgeDocTag(node, 'pdf')
|
||||
if (attributes && attributes.url) {
|
||||
const pdfUrl = attributes.url
|
||||
const count = (this.counterMap.get(pdfUrl) || 0) + 1
|
||||
this.counterMap.set(pdfUrl, count)
|
||||
return <PdfFrame url={pdfUrl}/>
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly markdownItPlugin: MarkdownIt.PluginSimple = (markdownIt) => {
|
||||
markdownItRegex(markdownIt, replacePdfShortCode)
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { RegexOptions } from '../../../../external-types/markdown-it-regex/interface'
|
||||
|
||||
export const replacePdfShortCode: RegexOptions = {
|
||||
name: 'pdf-short-code',
|
||||
regex: /^{%pdf (.*) ?%}$/,
|
||||
replace: (match) => {
|
||||
// ESLint wants to collapse this tag, but then the tag won't be valid html anymore.
|
||||
// noinspection CheckTagEmptyBody
|
||||
return `<app-pdf url="${match}"></app-pdf>`
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue