-
Notifications
You must be signed in to change notification settings - Fork 142
Migrate remaining markdown it (re) #2835
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
Merged
gerteck
merged 5 commits into
MarkBind:master
from
MoshiMoshiMochi:migrate-remaining-markdown-it
Feb 14, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1f12a44
Add path of .js files to gitignore & eslintignore
MoshiMoshiMochi 48eb8d2
Rename files in markdown-it/plugins to TypeScript
MoshiMoshiMochi 0e7af0a
Adapt files in markdown-it/plugins to TypeScript
MoshiMoshiMochi f18bbc1
Adapt markdown-it/index to TypeScript
MoshiMoshiMochi fb4fdd7
Adapt core/test/unit/lib/markdown-it/plugins to TypeScript
MoshiMoshiMochi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 0 additions & 56 deletions
56
packages/core/src/lib/markdown-it/plugins/markdown-it-block-embed/PluginEnvironment.js
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
packages/core/src/lib/markdown-it/plugins/markdown-it-block-embed/PluginEnvironment.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // Copyright (c) Rotorz Limited and portions by original markdown-it-video authors | ||
| // Licensed under the MIT license. See LICENSE file in the project root. | ||
|
|
||
| import MarkdownIt from 'markdown-it'; | ||
| import { EmbedServiceMap } from './tokenizer'; | ||
| import { BlockEmbedOptions } from './index'; | ||
|
|
||
| import YouTubeService from './services/YouTubeService'; | ||
| import VimeoService from './services/VimeoService'; | ||
| import VineService from './services/VineService'; | ||
| import PreziService from './services/PreziService'; | ||
| import SlideShareService from './services/SlideShareService'; | ||
| import PowerPointOnlineService from './services/PowerPointOnlineService'; | ||
|
|
||
| export default class PluginEnvironment { | ||
| public md: MarkdownIt; | ||
| public options: BlockEmbedOptions; | ||
| public services: EmbedServiceMap = {}; | ||
|
|
||
| constructor(md: MarkdownIt, options: BlockEmbedOptions) { | ||
| this.md = md; | ||
| this.options = Object.assign(this.getDefaultOptions(), options); | ||
|
|
||
| this._initServices(); | ||
| } | ||
|
|
||
| _initServices(): void { | ||
| const defaultServiceBindings: Record<string, any> = { | ||
| 'youtube': YouTubeService, | ||
| 'vimeo': VimeoService, | ||
| 'vine': VineService, | ||
| 'prezi': PreziService, | ||
| 'slideshare': SlideShareService, | ||
| 'powerpoint': PowerPointOnlineService, | ||
| }; | ||
|
|
||
| let serviceBindings = Object.assign({}, defaultServiceBindings, this.options.services); | ||
| let services: EmbedServiceMap = {}; | ||
| for (let serviceName of Object.keys(serviceBindings)) { | ||
| let _serviceClass = serviceBindings[serviceName]; | ||
| const ActualConstructor = _serviceClass.default || _serviceClass; | ||
|
|
||
| if (typeof ActualConstructor === 'function') { | ||
| services[serviceName] = new ActualConstructor(serviceName, this.options[serviceName], this); | ||
| } else { | ||
| console.error(`BlockEmbed Error: Service "${serviceName}" is not a valid constructor.`); | ||
| } | ||
| } | ||
|
|
||
| this.services = services; | ||
| } | ||
|
|
||
| public getDefaultOptions(): BlockEmbedOptions { | ||
| return { | ||
| containerClassName: 'block-embed', | ||
| serviceClassPrefix: 'block-embed-service-', | ||
| outputPlayerSize: true, | ||
| allowFullScreen: true, | ||
| filterUrl: null | ||
| }; | ||
| } | ||
|
|
||
| } |
21 changes: 0 additions & 21 deletions
21
packages/core/src/lib/markdown-it/plugins/markdown-it-block-embed/index.js
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
packages/core/src/lib/markdown-it/plugins/markdown-it-block-embed/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright (c) Rotorz Limited and portions by original markdown-it-video authors | ||
| // Licensed under the MIT license. See LICENSE file in the project root. | ||
|
|
||
| import MarkdownIt from 'markdown-it'; | ||
|
|
||
| import PluginEnvironment from './PluginEnvironment'; | ||
| import renderer from './renderer'; | ||
| import { createTokenizer } from './tokenizer'; | ||
|
|
||
| export type UrlFilterDelegate = ( | ||
| url: string, | ||
| serviceName: string, | ||
| videoID: string, | ||
| options: BlockEmbedOptions | ||
| ) => string; | ||
|
|
||
| export interface BlockEmbedOptions { | ||
| containerClassName?: string; | ||
| serviceClassPrefix?: string; | ||
| outputPlayerSize?: boolean; | ||
| allowFullScreen?: boolean; | ||
| filterUrl?: UrlFilterDelegate | null; | ||
| services?: Record<string, any>; | ||
| [serviceConfig: string]: any; | ||
| } | ||
|
|
||
| export default function setup(md: MarkdownIt, options?: BlockEmbedOptions) { | ||
| const normalizedOptions: BlockEmbedOptions = options ?? {}; | ||
| let env = new PluginEnvironment(md, normalizedOptions); | ||
|
|
||
| md.block.ruler.before("fence", "video", createTokenizer(env.services), { | ||
| alt: [ "paragraph", "reference", "blockquote", "list" ] | ||
| }); | ||
| md.renderer.rules["video"] = renderer.bind(env); | ||
| } | ||
17 changes: 0 additions & 17 deletions
17
packages/core/src/lib/markdown-it/plugins/markdown-it-block-embed/renderer.js
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
packages/core/src/lib/markdown-it/plugins/markdown-it-block-embed/renderer.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // Copyright (c) Rotorz Limited and portions by original markdown-it-video authors | ||
| // Licensed under the MIT license. See LICENSE file in the project root. | ||
|
|
||
| import Token from 'markdown-it/lib/token'; | ||
|
|
||
| export default function renderer(tokens: Token[], idx: number, _options: any, _env: any): string { | ||
| let videoToken = tokens[idx]; | ||
|
|
||
| let service = (videoToken as any).info.service; | ||
| let videoID = (videoToken as any).info.videoID; | ||
|
|
||
| return service.getEmbedCode(videoID); | ||
| } |
20 changes: 0 additions & 20 deletions
20
...e/src/lib/markdown-it/plugins/markdown-it-block-embed/services/PowerPointOnlineService.js
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
...e/src/lib/markdown-it/plugins/markdown-it-block-embed/services/PowerPointOnlineService.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import VideoServiceBase, { VideoServiceOptions } from './VideoServiceBase'; | ||
|
|
||
| export interface PowerPointOnlineOptions extends VideoServiceOptions { | ||
| width?: number; | ||
| height?: number; | ||
| } | ||
|
|
||
| export default class PowerPointOnlineService extends VideoServiceBase { | ||
|
|
||
| getDefaultOptions(): PowerPointOnlineOptions { | ||
| return { width: 610, height: 481, ignoreStyle: true }; | ||
| } | ||
|
|
||
| extractVideoID(reference: string): string { | ||
| return reference; | ||
| } | ||
|
|
||
| getVideoUrl(serviceUrl: string): string { | ||
| return `${serviceUrl}&action=embedview&wdAr=1.3333333333333333`; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
...es/core/src/lib/markdown-it/plugins/markdown-it-block-embed/services/SlideShareService.js
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
...es/core/src/lib/markdown-it/plugins/markdown-it-block-embed/services/SlideShareService.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import VideoServiceBase, { VideoServiceOptions } from './VideoServiceBase'; | ||
|
|
||
| export interface SlideShareOptions extends VideoServiceOptions { | ||
| width?: number; | ||
| height?: number; | ||
| } | ||
|
|
||
| export default class SlideShareService extends VideoServiceBase { | ||
|
|
||
| getDefaultOptions(): SlideShareOptions { | ||
| return {width: 599, height: 487}; | ||
| } | ||
|
|
||
| extractVideoID(reference: string): string { | ||
| return reference; | ||
| } | ||
|
|
||
| getVideoUrl(videoID: string): string { | ||
| let escapedVideoID = this.env.md.utils.escapeHtml(videoID); | ||
| return `//www.slideshare.net/slideshow/embed_code/key/${escapedVideoID}`; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
factory function of tokenizer is used here 👍