@@ -3,17 +3,22 @@ import { App, MarkdownView, Plugin, MarkdownPostProcessorContext, PluginSettingT
33import { Coder } from "./Coder" ;
44import { Base64Encoder , Base64Decoder } from "./Base64" ;
55import { Rot13Encoder , Rot13Decoder } from "./Rot13" ;
6+ import { AtbashEncoder , AtbashDecoder } from "./Atbash" ;
67
78export default class CoderPlugin extends Plugin {
89
910 // List of coders
10- coders : Coder [ ] = [ new Base64Encoder ( ) , new Base64Decoder ( ) , new Rot13Encoder ( ) , new Rot13Decoder ( ) ] ;
11+ coders : Coder [ ] = [ new Base64Encoder ( ) , new Base64Decoder ( ) , new Rot13Encoder ( ) , new Rot13Decoder ( ) , new AtbashEncoder ( ) , new AtbashDecoder ( ) ] ;
1112
1213 async onload ( ) {
1314 this . registerMarkdownCodeBlockProcessor ( 'transform-text-base64' , this . processTextToBase64 ) ;
1415 this . registerMarkdownCodeBlockProcessor ( 'transform-base64-text' , this . processBase64ToText ) ;
1516 this . registerMarkdownCodeBlockProcessor ( 'transform-text-rot13' , this . processTextToRot13 ) ;
1617 this . registerMarkdownCodeBlockProcessor ( 'transform-rot13-text' , this . processRot13ToText ) ;
18+ this . registerMarkdownCodeBlockProcessor ( 'transform-text-atbash' , this . processTextToAtbash ) ;
19+ this . registerMarkdownCodeBlockProcessor ( 'transform-atbash-text' , this . processAtbashToText ) ;
20+
21+
1722 }
1823
1924 // function to get a coder by from and to types
@@ -50,6 +55,16 @@ export default class CoderPlugin extends Plugin {
5055 this . processText ( content , el , coder ) ;
5156 }
5257
58+ processTextToAtbash = async ( content : string , el : HTMLElement , ctx : MarkdownPostProcessorContext ) => {
59+ let coder = this . getCoder ( "text" , "atbash" ) ;
60+ this . processText ( content , el , coder ) ;
61+ }
62+
63+ processAtbashToText = async ( content : string , el : HTMLElement , ctx : MarkdownPostProcessorContext ) => {
64+ let coder = this . getCoder ( "atbash" , "text" ) ;
65+ this . processText ( content , el , coder ) ;
66+ }
67+
5368 processText ( content : string , el : HTMLElement , coder : Coder | null ) {
5469 var destination ;
5570
0 commit comments