Implement Unicode text formatter plugin
- Add unicode-maps.ts with BOLD_MAP, ITALIC_MAP, BOLD_ITALIC_MAP from Unicode Sans-Serif ranges - Add formatter.ts with transformText(text, style) using the maps - Add commands.ts registering three editorCallback commands (bold, italic, bold-italic) - Replace sample plugin boilerplate in main.ts with UnicodeFormatterPlugin wired to registerCommands - Update manifest.json with correct id, name, and description - Delete unused settings.ts boilerplate Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { BOLD_MAP, ITALIC_MAP, BOLD_ITALIC_MAP } from "./unicode-maps";
|
||||
|
||||
export type FormatStyle = "bold" | "italic" | "bold-italic";
|
||||
|
||||
const STYLE_MAPS: Record<FormatStyle, Record<string, string>> = {
|
||||
"bold": BOLD_MAP,
|
||||
"italic": ITALIC_MAP,
|
||||
"bold-italic": BOLD_ITALIC_MAP,
|
||||
};
|
||||
|
||||
export function transformText(text: string, style: FormatStyle): string {
|
||||
const map = STYLE_MAPS[style];
|
||||
return [...text].map(ch => map[ch] ?? ch).join("");
|
||||
}
|
||||
Reference in New Issue
Block a user