diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index df8e8ab5e..29b23f7ae 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -30,7 +30,7 @@ assignees: '' - OS: [e.g. iOS 13, Ubuntu 20.04, Windows 10] - Browser with version [e.g. Chrome 81, Safari 13.1] - [Check your Browser Version](https://www.whatismybrowser.com/) - - CodiMD version (Click "Version info" in the footer) + - HedgeDoc version (Click "Version info" in the footer) - server [e.g. 2.0] - client [e.g. 2.0] diff --git a/.idea/dictionaries/codimd.xml b/.idea/dictionaries/hedgedoc.xml similarity index 58% rename from .idea/dictionaries/codimd.xml rename to .idea/dictionaries/hedgedoc.xml index 3c33c8ec6..dfc7a406d 100644 --- a/.idea/dictionaries/codimd.xml +++ b/.idea/dictionaries/hedgedoc.xml @@ -1,8 +1,10 @@ - + CodiMD + HedgeDoc codimd + hedgedoc - + \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index ce6141efd..1f633dfaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## [Unreleased] ### Deprecations -- This version of CodiMD is the last version that supports the following short-code syntaxes for embedding content. Embedding works now instead by putting the plain webpage link to the content into a single line. +- This version of HedgeDoc is the last version that supports the following short-code syntaxes for embedding content. Embedding works now instead by putting the plain webpage link to the content into a single line. - `{%youtube someid %}` -> https://youtube.com/watch?v=someid - `{%vimeo 123456789 %}` -> https://vimeo.com/123456789 - `{%gist user/12345 %}` -> https://gist.github.com/user/12345 @@ -31,7 +31,7 @@ - Highlighted code blocks can now use line wrapping and line numbers at once - Images, videos, and other non-text content is now wider in View Mode - Notes may now be deleted directly from the history page -- CodiMD instances can now be branded either with a '@ ' or '@ ' after the CodiMD logo and text +- HedgeDoc instances can now be branded either with a '@ ' or '@ ' after the HedgeDoc logo and text - Images will be loaded via proxy if an image proxy is configured in the backend - Asciinema videos may now be embedded by pasting the URL of one video into a single line - The Toolbar includes an EmojiPicker diff --git a/README.md b/README.md index 6313ed2b0..306fb3398 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# CodiMD - React Client +# HedgeDoc - React Client ![lint and build](https://github.com/codimd/react-client/workflows/lint%20and%20build/badge.svg) ![e2e](https://github.com/codimd/react-client/workflows/e2e/badge.svg) -This is the new, improved and better looking frontend for CodiMD 2.0. +This is the new, improved and better looking frontend for HedgeDoc 2.0. Our goal is to recreate the current frontend in react and to improve it. ## Preparation @@ -11,8 +11,8 @@ You'll need at least Node 12. We use [yarn](https://yarnpkg.com/) for our depend ## Development mode -1. Clone this repo (e.g. `git clone https://github.com/codimd/react-client.git codimd-react-client`) -2. Go inside the repo (e.g. `cd codimd-react-client`) +1. Clone this repo (e.g. `git clone https://github.com/codimd/react-client.git hedgedoc-react-client`) +2. Go inside the repo (e.g. `cd hedgedoc-react-client`) 3. Run `yarn install` 4. Either run - `yarn start:dev` (expects [a server](https://github.com/codimd/server/tree/develop) running under [http://localhost:3000](http://localhost:3000)) @@ -42,8 +42,8 @@ We use [cypress](https://cypress.io) for e2e tests. ## Production mode -1. Clone this repo (e.g. `git clone https://github.com/codimd/react-client.git codimd-react-client`) -2. Go inside the repo (e.g. `cd codimd-react-client`) +1. Clone this repo (e.g. `git clone https://github.com/codimd/react-client.git hedgedoc-react-client`) +2. Go inside the repo (e.g. `cd hedgedoc-react-client`) 3. Run `yarn install` 4. Run `yarn build` diff --git a/cypress/integration/documentTitle.spec.ts b/cypress/integration/documentTitle.spec.ts index 2494031ff..7d6173b5c 100644 --- a/cypress/integration/documentTitle.spec.ts +++ b/cypress/integration/documentTitle.spec.ts @@ -15,19 +15,19 @@ describe('Document Title', () => { it('just yaml metadata title', () => { cy.get('.CodeMirror textarea') .type(`---\ntitle: ${title}\n---`) - cy.title().should('eq', `${title} - CodiMD @ ${branding.name}`) + cy.title().should('eq', `${title} - HedgeDoc @ ${branding.name}`) }) it('yaml metadata title and opengraph title', () => { cy.get('.CodeMirror textarea') .type(`---\ntitle: ${title}\nopengraph:\n title: False title\n{backspace}{backspace}---`) - cy.title().should('eq', `${title} - CodiMD @ ${branding.name}`) + cy.title().should('eq', `${title} - HedgeDoc @ ${branding.name}`) }) it('yaml metadata title, opengraph title and first heading', () => { cy.get('.CodeMirror textarea') .type(`---\ntitle: ${title}\nopengraph:\n title: False title\n{backspace}{backspace}---\n# a first title`) - cy.title().should('eq', `${title} - CodiMD @ ${branding.name}`) + cy.title().should('eq', `${title} - HedgeDoc @ ${branding.name}`) }) }) @@ -35,13 +35,13 @@ describe('Document Title', () => { it('just opengraph title', () => { cy.get('.CodeMirror textarea') .type(`---\nopengraph:\n title: ${title}\n{backspace}{backspace}---`) - cy.title().should('eq', `${title} - CodiMD @ ${branding.name}`) + cy.title().should('eq', `${title} - HedgeDoc @ ${branding.name}`) }) it('opengraph title and first heading', () => { cy.get('.CodeMirror textarea') .type(`---\nopengraph:\n title: ${title}\n{backspace}{backspace}---\n# a first title`) - cy.title().should('eq', `${title} - CodiMD @ ${branding.name}`) + cy.title().should('eq', `${title} - HedgeDoc @ ${branding.name}`) }) }) @@ -49,19 +49,19 @@ describe('Document Title', () => { it('just first heading', () => { cy.get('.CodeMirror textarea') .type(`# ${title}`) - cy.title().should('eq', `${title} - CodiMD @ ${branding.name}`) + cy.title().should('eq', `${title} - HedgeDoc @ ${branding.name}`) }) it('just first heading with alt-text instead of image', () => { cy.get('.CodeMirror textarea') .type(`# ${title} ![abc](https://dummyimage.com/48)`) - cy.title().should('eq', `${title} abc - CodiMD @ ${branding.name}`) + cy.title().should('eq', `${title} abc - HedgeDoc @ ${branding.name}`) }) it('just first heading without link syntax', () => { cy.get('.CodeMirror textarea') - .type(`# ${title} [link](https://hedgedoc.org)`) - cy.title().should('eq', `${title} link - CodiMD @ ${branding.name}`) + .type(`# ${title} [link](https://codimd.org)`) + cy.title().should('eq', `${title} link - HedgeDoc @ ${branding.name}`) }) }) }) diff --git a/cypress/integration/link.spec.ts b/cypress/integration/link.spec.ts index f36add4d7..d7373dac5 100644 --- a/cypress/integration/link.spec.ts +++ b/cypress/integration/link.spec.ts @@ -108,7 +108,7 @@ describe('Links Intro', () => { }) describe('Powered By Links', () => { - it('CodiMD', () => { + it('HedgeDoc', () => { cy.get('a[href="https://codimd.org"]') .checkExternalLink('https://codimd.org') }) @@ -148,8 +148,8 @@ describe('Links Intro', () => { }) it('Matrix', () => { - cy.get('a[href="https://riot.im/app/#/room/#codimd:matrix.org"]') - .checkExternalLink('https://riot.im/app/#/room/#codimd:matrix.org') + cy.get('a[href="https://riot.im/app/#/room/#hedgedoc:matrix.org"]') + .checkExternalLink('https://riot.im/app/#/room/#hedgedoc:matrix.org') }) it('Mastodon', () => { diff --git a/cypress/integration/toolbar.spec.ts b/cypress/integration/toolbar.spec.ts index c6b09429e..4ce5553cb 100644 --- a/cypress/integration/toolbar.spec.ts +++ b/cypress/integration/toolbar.spec.ts @@ -1,5 +1,5 @@ const testText = 'textText' -const testLink = 'http://hedgedoc.org' +const testLink = 'http://codimd.org' describe('Toolbar', () => { beforeEach(() => { diff --git a/public/api/v2/history b/public/api/v2/history index b1414bcb6..38e501a6e 100644 --- a/public/api/v2/history +++ b/public/api/v2/history @@ -1,10 +1,10 @@ [ { "id": "29QLD0AmT-adevdOPECtqg", - "title": "CodiMD community call 2020-04-26", + "title": "HedgeDoc community call 2020-04-26", "lastVisited": "2020-05-16T22:26:56.547Z", "tags": [ - "CodiMD", + "HedgeDoc", "Community Call" ] }, @@ -20,7 +20,7 @@ }, { "id": "ODakLc2MQkyyFc_Xmb53sg", - "title": "CodiMD V2 API", + "title": "HedgeDoc V2 API", "lastVisited": "2020-05-25T19:48:14.025Z", "tags": [] }, @@ -30,7 +30,7 @@ "lastVisited": "2020-05-24T16:04:36.433Z", "tags": [ "agenda", - "CodiMD community", + "HedgeDoc community", "community call" ] } diff --git a/public/icons/site.webmanifest b/public/icons/site.webmanifest index 5a517004a..234153cc4 100644 --- a/public/icons/site.webmanifest +++ b/public/icons/site.webmanifest @@ -1,6 +1,6 @@ { - "name": "CodiMD", - "short_name": "CodiMD", + "name": "HedgeDoc", + "short_name": "HedgeDoc", "icons": [ { "src": "/icons/android-chrome-192x192.png", diff --git a/public/index.html b/public/index.html index b533f1b81..7bcca202d 100644 --- a/public/index.html +++ b/public/index.html @@ -2,7 +2,7 @@ - CodiMD + HedgeDoc @@ -13,7 +13,7 @@ - + diff --git a/public/locales/en.json b/public/locales/en.json index f1d42db00..d8f12925f 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -16,7 +16,7 @@ "katex": "Works with charts and KaTeX", "slides": "Supports slide mode" }, - "screenShotAltText": "CodiMD Screenshot" + "screenShotAltText": "HedgeDoc Screenshot" }, "history": { "error": { @@ -200,7 +200,7 @@ }, "newVersion": { "title": "New version available!", - "description": "A new version of CodiMD is available", + "description": "A new version of HedgeDoc is available", "linkText": "See releases notes here", "advice": "Refresh to enjoy new features." }, diff --git a/src/api/utils.ts b/src/api/utils.ts index 0377f8482..3e4ed1ff1 100644 --- a/src/api/utils.ts +++ b/src/api/utils.ts @@ -8,7 +8,8 @@ export const defaultFetchConfig: Partial = { 'Content-Type': 'application/json' }, redirect: 'follow', - referrerPolicy: 'no-referrer' + referrerPolicy: 'no-referrer', + method: 'GET' } export const getApiUrl = (): string => { diff --git a/src/components/common/document-title/document-title.tsx b/src/components/common/document-title/document-title.tsx index cc69b4c36..c21591c3b 100644 --- a/src/components/common/document-title/document-title.tsx +++ b/src/components/common/document-title/document-title.tsx @@ -10,7 +10,7 @@ export const DocumentTitle: React.FC = ({ title }) => { const brandingName = useSelector((state: ApplicationState) => state.config.branding.name) useEffect(() => { - document.title = `${title ? title + ' - ' : ''}CodiMD ${brandingName ? ` @ ${brandingName}` : ''}` + document.title = `${title ? title + ' - ' : ''}HedgeDoc ${brandingName ? ` @ ${brandingName}` : ''}` }, [brandingName, title]) return null diff --git a/src/components/editor/app-bar/help-button/links.tsx b/src/components/editor/app-bar/help-button/links.tsx index cc9a49798..24dd12a41 100644 --- a/src/components/editor/app-bar/help-button/links.tsx +++ b/src/components/editor/app-bar/help-button/links.tsx @@ -24,7 +24,7 @@ export const Links: React.FC = () => { diff --git a/src/components/editor/app-bar/navbar-branding.tsx b/src/components/editor/app-bar/navbar-branding.tsx index 4683e61d6..7b56c4b73 100644 --- a/src/components/editor/app-bar/navbar-branding.tsx +++ b/src/components/editor/app-bar/navbar-branding.tsx @@ -9,7 +9,7 @@ export const NavbarBranding: React.FC = () => { - CodiMD + HedgeDoc diff --git a/src/components/editor/editorTestContent.ts b/src/components/editor/editorTestContent.ts index 8047293b0..e52552ccb 100644 --- a/src/components/editor/editorTestContent.ts +++ b/src/components/editor/editorTestContent.ts @@ -2,7 +2,7 @@ export const editorTestContent = `--- title: Features description: Many features, such wow! robots: noindex -tags: codimd, demo, react +tags: hedgedoc, demo, react opengraph: title: Features --- diff --git a/src/components/intro-page/intro-page.tsx b/src/components/intro-page/intro-page.tsx index 52b521389..323cd083f 100644 --- a/src/components/intro-page/intro-page.tsx +++ b/src/components/intro-page/intro-page.tsx @@ -13,7 +13,7 @@ const IntroPage: React.FC = () => {

- CodiMD + HedgeDoc

diff --git a/src/components/landing-layout/footer/powered-by-links.tsx b/src/components/landing-layout/footer/powered-by-links.tsx index c3cc7195d..1672ebf3b 100644 --- a/src/components/landing-layout/footer/powered-by-links.tsx +++ b/src/components/landing-layout/footer/powered-by-links.tsx @@ -15,7 +15,7 @@ export const PoweredByLinks: React.FC = () => { return (

- +  |  diff --git a/src/components/landing-layout/footer/social-links.tsx b/src/components/landing-layout/footer/social-links.tsx index 6d2351b8e..c8bff8f8d 100644 --- a/src/components/landing-layout/footer/social-links.tsx +++ b/src/components/landing-layout/footer/social-links.tsx @@ -9,7 +9,7 @@ const SocialLink: React.FC = () => { , , - , + , , ]}/> diff --git a/src/components/markdown-renderer/markdown-it-plugins/line-number-marker.ts b/src/components/markdown-renderer/markdown-it-plugins/line-number-marker.ts index 68330885a..d636709dd 100644 --- a/src/components/markdown-renderer/markdown-it-plugins/line-number-marker.ts +++ b/src/components/markdown-renderer/markdown-it-plugins/line-number-marker.ts @@ -16,7 +16,7 @@ export interface LineNumberMarkerOptions { */ export const lineNumberMarker: () => MarkdownIt.PluginWithOptions = () => { return (md: MarkdownIt, options) => { - // add codimd_linemarker token before each opening or self-closing level-0 tag + // add app_linemarker token before each opening or self-closing level-0 tag md.core.ruler.push('line_number_marker', (state) => { const lineMarkers: LineMarkers[] = [] tagTokens(state.tokens, lineMarkers) @@ -26,7 +26,7 @@ export const lineNumberMarker: () => MarkdownIt.PluginWithOptions { + md.renderer.rules.app_linemarker = (tokens: Token[], index: number): string => { const startLineNumber = tokens[index].attrGet('data-start-line') const endLineNumber = tokens[index].attrGet('data-end-line') @@ -35,11 +35,11 @@ export const lineNumberMarker: () => MarkdownIt.PluginWithOptions` + return `` } const insertNewLineMarker = (startLineNumber: number, endLineNumber: number, tokenPosition: number, level: number, tokens: Token[]) => { - const startToken = new Token('codimd_linemarker', 'codimd-linemarker', 0) + const startToken = new Token('app_linemarker', 'app-linemarker', 0) startToken.level = level startToken.attrPush(['data-start-line', `${startLineNumber}`]) startToken.attrPush(['data-end-line', `${endLineNumber}`]) diff --git a/src/components/markdown-renderer/markdown-renderer.tsx b/src/components/markdown-renderer/markdown-renderer.tsx index 3e825cb03..bf147821e 100644 --- a/src/components/markdown-renderer/markdown-renderer.tsx +++ b/src/components/markdown-renderer/markdown-renderer.tsx @@ -54,7 +54,7 @@ import { replaceVimeoLink } from './regex-plugins/replace-vimeo-link' import { replaceYouTubeLink } from './regex-plugins/replace-youtube-link' import { buildTransformer, calculateNewLineNumberMapping, LineKeys } from './renderer-utils' import { AsciinemaReplacer } from './replace-components/asciinema/asciinema-replacer' -import { CodimdLinemarkerReplacer } from './replace-components/codimd-linemarker/codimd-linemarker-replacer' +import { LinemarkerReplacer } from './replace-components/linemarker/linemarker-replacer' import { ComponentReplacer } from './replace-components/ComponentReplacer' import { CsvReplacer } from './replace-components/csv/csv-replacer' import { FlowchartReplacer } from './replace-components/flow/flowchart-replacer' @@ -281,12 +281,12 @@ export const MarkdownRenderer: React.FC = ({ permalinkSymbol: '' }) md.use(mathJax({ - beforeMath: '', - afterMath: '', - beforeInlineMath: '', - afterInlineMath: '', - beforeDisplayMath: '', - afterDisplayMath: '' + beforeMath: '', + afterMath: '', + beforeInlineMath: '', + afterInlineMath: '', + beforeDisplayMath: '', + afterDisplayMath: '' })) md.use(markdownItRegex, replaceLegacyYoutubeShortCode) md.use(markdownItRegex, replaceLegacyVimeoShortCode) @@ -339,7 +339,7 @@ export const MarkdownRenderer: React.FC = ({ const markdownReactDom: ReactElement[] = useMemo(() => { const allReplacers: ComponentReplacer[] = [ - new CodimdLinemarkerReplacer(), + new LinemarkerReplacer(), new PossibleWiderReplacer(), new GistReplacer(), new YoutubeReplacer(), diff --git a/src/components/markdown-renderer/regex-plugins/replace-asciinema-link.ts b/src/components/markdown-renderer/regex-plugins/replace-asciinema-link.ts index c334e949f..5a5ea3ba3 100644 --- a/src/components/markdown-renderer/regex-plugins/replace-asciinema-link.ts +++ b/src/components/markdown-renderer/regex-plugins/replace-asciinema-link.ts @@ -13,6 +13,6 @@ export const replaceAsciinemaLink: RegexOptions = { replace: (match) => { // ESLint wants to collapse this tag, but then the tag won't be valid html anymore. // noinspection CheckTagEmptyBody - return `` + return `` } } diff --git a/src/components/markdown-renderer/regex-plugins/replace-gist-link.ts b/src/components/markdown-renderer/regex-plugins/replace-gist-link.ts index 9dba99ed9..0a1a1e552 100644 --- a/src/components/markdown-renderer/regex-plugins/replace-gist-link.ts +++ b/src/components/markdown-renderer/regex-plugins/replace-gist-link.ts @@ -13,6 +13,6 @@ export const replaceGistLink: RegexOptions = { replace: (match) => { // ESLint wants to collapse this tag, but then the tag won't be valid html anymore. // noinspection CheckTagEmptyBody - return `` + return `` } } diff --git a/src/components/markdown-renderer/regex-plugins/replace-legacy-gist-short-code.ts b/src/components/markdown-renderer/regex-plugins/replace-legacy-gist-short-code.ts index 06471d677..c76ec666d 100644 --- a/src/components/markdown-renderer/regex-plugins/replace-legacy-gist-short-code.ts +++ b/src/components/markdown-renderer/regex-plugins/replace-legacy-gist-short-code.ts @@ -8,6 +8,6 @@ export const replaceLegacyGistShortCode: RegexOptions = { replace: (match) => { // ESLint wants to collapse this tag, but then the tag won't be valid html anymore. // noinspection CheckTagEmptyBody - return `` + return `` } } diff --git a/src/components/markdown-renderer/regex-plugins/replace-legacy-vimeo-short-code.ts b/src/components/markdown-renderer/regex-plugins/replace-legacy-vimeo-short-code.ts index ed77b411b..9c069d6b8 100644 --- a/src/components/markdown-renderer/regex-plugins/replace-legacy-vimeo-short-code.ts +++ b/src/components/markdown-renderer/regex-plugins/replace-legacy-vimeo-short-code.ts @@ -6,6 +6,6 @@ export const replaceLegacyVimeoShortCode: RegexOptions = { replace: (match) => { // ESLint wants to collapse this tag, but then the tag won't be valid html anymore. // noinspection CheckTagEmptyBody - return `` + return `` } } diff --git a/src/components/markdown-renderer/regex-plugins/replace-legacy-youtube-short-code.ts b/src/components/markdown-renderer/regex-plugins/replace-legacy-youtube-short-code.ts index 2cbc50417..87aa345b1 100644 --- a/src/components/markdown-renderer/regex-plugins/replace-legacy-youtube-short-code.ts +++ b/src/components/markdown-renderer/regex-plugins/replace-legacy-youtube-short-code.ts @@ -6,6 +6,6 @@ export const replaceLegacyYoutubeShortCode: RegexOptions = { replace: (match) => { // ESLint wants to collapse this tag, but then the tag won't be valid html anymore. // noinspection CheckTagEmptyBody - return `` + return `` } } diff --git a/src/components/markdown-renderer/regex-plugins/replace-pdf-short-code.ts b/src/components/markdown-renderer/regex-plugins/replace-pdf-short-code.ts index be8f3289e..a851feb66 100644 --- a/src/components/markdown-renderer/regex-plugins/replace-pdf-short-code.ts +++ b/src/components/markdown-renderer/regex-plugins/replace-pdf-short-code.ts @@ -6,6 +6,6 @@ export const replacePdfShortCode: RegexOptions = { replace: (match) => { // ESLint wants to collapse this tag, but then the tag won't be valid html anymore. // noinspection CheckTagEmptyBody - return `` + return `` } } diff --git a/src/components/markdown-renderer/regex-plugins/replace-vimeo-link.ts b/src/components/markdown-renderer/regex-plugins/replace-vimeo-link.ts index bf126dc76..db363d294 100644 --- a/src/components/markdown-renderer/regex-plugins/replace-vimeo-link.ts +++ b/src/components/markdown-renderer/regex-plugins/replace-vimeo-link.ts @@ -13,6 +13,6 @@ export const replaceVimeoLink: RegexOptions = { replace: (match) => { // ESLint wants to collapse this tag, but then the tag won't be valid html anymore. // noinspection CheckTagEmptyBody - return `` + return `` } } diff --git a/src/components/markdown-renderer/regex-plugins/replace-youtube-link.ts b/src/components/markdown-renderer/regex-plugins/replace-youtube-link.ts index 6f51fe360..1b509e2da 100644 --- a/src/components/markdown-renderer/regex-plugins/replace-youtube-link.ts +++ b/src/components/markdown-renderer/regex-plugins/replace-youtube-link.ts @@ -14,6 +14,6 @@ export const replaceYouTubeLink: RegexOptions = { replace: (match) => { // ESLint wants to collapse this tag, but then the tag won't be valid html anymore. // noinspection CheckTagEmptyBody - return `` + return `` } } diff --git a/src/components/markdown-renderer/replace-components/asciinema/asciinema-replacer.tsx b/src/components/markdown-renderer/replace-components/asciinema/asciinema-replacer.tsx index 5ceb80bc5..e0baed912 100644 --- a/src/components/markdown-renderer/replace-components/asciinema/asciinema-replacer.tsx +++ b/src/components/markdown-renderer/replace-components/asciinema/asciinema-replacer.tsx @@ -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 = new Map() 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 diff --git a/src/components/markdown-renderer/replace-components/codi-md-tag-utils.ts b/src/components/markdown-renderer/replace-components/codi-md-tag-utils.ts deleted file mode 100644 index 0dcd1cafa..000000000 --- a/src/components/markdown-renderer/replace-components/codi-md-tag-utils.ts +++ /dev/null @@ -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 -} diff --git a/src/components/markdown-renderer/replace-components/gist/gist-replacer.tsx b/src/components/markdown-renderer/replace-components/gist/gist-replacer.tsx index 791e4b807..0039182db 100644 --- a/src/components/markdown-renderer/replace-components/gist/gist-replacer.tsx +++ b/src/components/markdown-renderer/replace-components/gist/gist-replacer.tsx @@ -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 = new Map() 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 diff --git a/src/components/markdown-renderer/replace-components/katex/katex-replacer.tsx b/src/components/markdown-renderer/replace-components/katex/katex-replacer.tsx index 1d0b96c75..210756805 100644 --- a/src/components/markdown-renderer/replace-components/katex/katex-replacer.tsx +++ b/src/components/markdown-renderer/replace-components/katex/katex-replacer.tsx @@ -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 { diff --git a/src/components/markdown-renderer/replace-components/codimd-linemarker/codimd-linemarker-replacer.tsx b/src/components/markdown-renderer/replace-components/linemarker/linemarker-replacer.tsx similarity index 79% rename from src/components/markdown-renderer/replace-components/codimd-linemarker/codimd-linemarker-replacer.tsx rename to src/components/markdown-renderer/replace-components/linemarker/linemarker-replacer.tsx index 43bb63fca..45b67a7b4 100644 --- a/src/components/markdown-renderer/replace-components/codimd-linemarker/codimd-linemarker-replacer.tsx +++ b/src/components/markdown-renderer/replace-components/linemarker/linemarker-replacer.tsx @@ -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 } diff --git a/src/components/markdown-renderer/replace-components/pdf/pdf-replacer.tsx b/src/components/markdown-renderer/replace-components/pdf/pdf-replacer.tsx index 93cf8c39e..0c597d3c1 100644 --- a/src/components/markdown-renderer/replace-components/pdf/pdf-replacer.tsx +++ b/src/components/markdown-renderer/replace-components/pdf/pdf-replacer.tsx @@ -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 = new Map() 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 diff --git a/src/components/markdown-renderer/replace-components/possible-wider/possible-wider-replacer.tsx b/src/components/markdown-renderer/replace-components/possible-wider/possible-wider-replacer.tsx index 8cd02e7c6..eb3b2d898 100644 --- a/src/components/markdown-renderer/replace-components/possible-wider/possible-wider-replacer.tsx +++ b/src/components/markdown-renderer/replace-components/possible-wider/possible-wider-replacer.tsx @@ -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. diff --git a/src/components/markdown-renderer/replace-components/utils.ts b/src/components/markdown-renderer/replace-components/utils.ts new file mode 100644 index 000000000..1c5b16e31 --- /dev/null +++ b/src/components/markdown-renderer/replace-components/utils.ts @@ -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 +} diff --git a/src/components/markdown-renderer/replace-components/vimeo/vimeo-replacer.tsx b/src/components/markdown-renderer/replace-components/vimeo/vimeo-replacer.tsx index 98ddecbea..747824c48 100644 --- a/src/components/markdown-renderer/replace-components/vimeo/vimeo-replacer.tsx +++ b/src/components/markdown-renderer/replace-components/vimeo/vimeo-replacer.tsx @@ -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 = new Map() 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 diff --git a/src/components/markdown-renderer/replace-components/youtube/youtube-replacer.tsx b/src/components/markdown-renderer/replace-components/youtube/youtube-replacer.tsx index 696af7dd1..997ea2986 100644 --- a/src/components/markdown-renderer/replace-components/youtube/youtube-replacer.tsx +++ b/src/components/markdown-renderer/replace-components/youtube/youtube-replacer.tsx @@ -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 = new Map() 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