mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-20 10:15:17 -04:00
parent
3a0e35a9f3
commit
0e912d64dd
39 changed files with 87 additions and 84 deletions
|
@ -1,6 +1,6 @@
|
|||
import { DomElement } from 'domhandler'
|
||||
import React from 'react'
|
||||
import { getAttributesFromCodiMdTag } from '../codi-md-tag-utils'
|
||||
import { getAttributesFromHedgeDocTag } from '../utils'
|
||||
import { ComponentReplacer } from '../ComponentReplacer'
|
||||
import { AsciinemaFrame } from './asciinema-frame'
|
||||
|
||||
|
@ -8,7 +8,7 @@ export class AsciinemaReplacer extends ComponentReplacer {
|
|||
private counterMap: Map<string, number> = new Map<string, number>()
|
||||
|
||||
public getReplacement (node: DomElement, index: number): React.ReactElement | undefined {
|
||||
const attributes = getAttributesFromCodiMdTag(node, 'asciinema')
|
||||
const attributes = getAttributesFromHedgeDocTag(node, 'asciinema')
|
||||
if (attributes && attributes.id) {
|
||||
const asciinemaId = attributes.id
|
||||
const count = (this.counterMap.get(asciinemaId) || 0) + 1
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
import { DomElement } from 'domhandler'
|
||||
|
||||
export const getAttributesFromCodiMdTag = (node: DomElement, tagName: string): ({ [s: string]: string; }|undefined) => {
|
||||
if (node.name !== `codimd-${tagName}` || !node.attribs) {
|
||||
return
|
||||
}
|
||||
return node.attribs
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import { DomElement } from 'domhandler'
|
||||
import React from 'react'
|
||||
import { getAttributesFromCodiMdTag } from '../codi-md-tag-utils'
|
||||
import { getAttributesFromHedgeDocTag } from '../utils'
|
||||
import { ComponentReplacer } from '../ComponentReplacer'
|
||||
import { OneClickEmbedding } from '../one-click-frame/one-click-embedding'
|
||||
import { GistFrame } from './gist-frame'
|
||||
|
@ -10,7 +10,7 @@ export class GistReplacer extends ComponentReplacer {
|
|||
private counterMap: Map<string, number> = new Map<string, number>()
|
||||
|
||||
public getReplacement (node: DomElement, index: number): React.ReactElement | undefined {
|
||||
const attributes = getAttributesFromCodiMdTag(node, 'gist')
|
||||
const attributes = getAttributesFromHedgeDocTag(node, 'gist')
|
||||
if (attributes && attributes.id) {
|
||||
const gistId = attributes.id
|
||||
const count = (this.counterMap.get(gistId) || 0) + 1
|
||||
|
|
|
@ -9,12 +9,12 @@ const getNodeIfKatexBlock = (node: DomElement): (DomElement|undefined) => {
|
|||
return
|
||||
}
|
||||
return node.children.find((subnode) => {
|
||||
return (subnode.name === 'codimd-katex' && subnode.attribs?.inline === undefined)
|
||||
return (subnode.name === 'app-katex' && subnode.attribs?.inline === undefined)
|
||||
})
|
||||
}
|
||||
|
||||
const getNodeIfInlineKatex = (node: DomElement): (DomElement|undefined) => {
|
||||
return (node.name === 'codimd-katex' && node.attribs?.inline !== undefined) ? node : undefined
|
||||
return (node.name === 'app-katex' && node.attribs?.inline !== undefined) ? node : undefined
|
||||
}
|
||||
|
||||
export class KatexReplacer extends ComponentReplacer {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { DomElement } from 'domhandler'
|
||||
import { ComponentReplacer } from '../ComponentReplacer'
|
||||
|
||||
export class CodimdLinemarkerReplacer extends ComponentReplacer {
|
||||
export class LinemarkerReplacer extends ComponentReplacer {
|
||||
public getReplacement (codeNode: DomElement, index: number): null | undefined {
|
||||
return codeNode.name === 'codimd-linemarker' ? null : undefined
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import { DomElement } from 'domhandler'
|
||||
import React from 'react'
|
||||
import { getAttributesFromCodiMdTag } from '../codi-md-tag-utils'
|
||||
import { getAttributesFromHedgeDocTag } from '../utils'
|
||||
import { ComponentReplacer } from '../ComponentReplacer'
|
||||
import { PdfFrame } from './pdf-frame'
|
||||
|
||||
|
@ -8,7 +8,7 @@ export class PdfReplacer extends ComponentReplacer {
|
|||
private counterMap: Map<string, number> = new Map<string, number>()
|
||||
|
||||
public getReplacement (node: DomElement, index: number): React.ReactElement | undefined {
|
||||
const attributes = getAttributesFromCodiMdTag(node, 'pdf')
|
||||
const attributes = getAttributesFromHedgeDocTag(node, 'pdf')
|
||||
if (attributes && attributes.url) {
|
||||
const pdfUrl = attributes.url
|
||||
const count = (this.counterMap.get(pdfUrl) || 0) + 1
|
||||
|
|
|
@ -2,7 +2,7 @@ import { DomElement } from 'domhandler'
|
|||
import { ComponentReplacer, NativeRenderer, SubNodeTransform } from '../ComponentReplacer'
|
||||
import './possible-wider-replacer.scss'
|
||||
|
||||
const enabledTags = ['img', 'codimd-youtube', 'codimd-vimeo', 'codimd-asciinema', 'codimd-pdf']
|
||||
const enabledTags = ['img', 'app-youtube', 'app-vimeo', 'app-asciinema', 'app-pdf']
|
||||
|
||||
/**
|
||||
* This replacer doesn't actually replace something.
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
import { DomElement } from 'domhandler'
|
||||
|
||||
export const getAttributesFromHedgeDocTag = (node: DomElement, tagName: string): ({ [s: string]: string; }|undefined) => {
|
||||
if (node.name !== `app-${tagName}` || !node.attribs) {
|
||||
return
|
||||
}
|
||||
return node.attribs
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import { DomElement } from 'domhandler'
|
||||
import React from 'react'
|
||||
import { getAttributesFromCodiMdTag } from '../codi-md-tag-utils'
|
||||
import { getAttributesFromHedgeDocTag } from '../utils'
|
||||
import { ComponentReplacer } from '../ComponentReplacer'
|
||||
import { VimeoFrame } from './vimeo-frame'
|
||||
|
||||
|
@ -8,7 +8,7 @@ export class VimeoReplacer extends ComponentReplacer {
|
|||
private counterMap: Map<string, number> = new Map<string, number>()
|
||||
|
||||
public getReplacement (node: DomElement, index: number): React.ReactElement | undefined {
|
||||
const attributes = getAttributesFromCodiMdTag(node, 'vimeo')
|
||||
const attributes = getAttributesFromHedgeDocTag(node, 'vimeo')
|
||||
if (attributes && attributes.id) {
|
||||
const videoId = attributes.id
|
||||
const count = (this.counterMap.get(videoId) || 0) + 1
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { DomElement } from 'domhandler'
|
||||
import React from 'react'
|
||||
import { getAttributesFromCodiMdTag } from '../codi-md-tag-utils'
|
||||
import { getAttributesFromHedgeDocTag } from '../utils'
|
||||
import { ComponentReplacer } from '../ComponentReplacer'
|
||||
import { YouTubeFrame } from './youtube-frame'
|
||||
|
||||
|
@ -8,7 +8,7 @@ export class YoutubeReplacer extends ComponentReplacer {
|
|||
private counterMap: Map<string, number> = new Map<string, number>()
|
||||
|
||||
public getReplacement (node: DomElement, index: number): React.ReactElement | undefined {
|
||||
const attributes = getAttributesFromCodiMdTag(node, 'youtube')
|
||||
const attributes = getAttributesFromHedgeDocTag(node, 'youtube')
|
||||
if (attributes && attributes.id) {
|
||||
const videoId = attributes.id
|
||||
const count = (this.counterMap.get(videoId) || 0) + 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue