UNPKG

on-codemerge

Version:

A WYSIWYG editor for on-codemerge is a user-friendly interface that allows users to edit and view their code in real time, exactly as it will appear in the final product

2 lines (1 loc) 803 B
"use strict";var a=Object.defineProperty;var c=(r,t,s)=>t in r?a(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s;var h=(r,t,s)=>c(r,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class u{constructor(){h(this,"shortcuts",[])}register(t,s){const e=t.split("+").map(o=>o.trim().toLowerCase());this.shortcuts.push({keys:e,callback:s})}handleKeyDown(t){const s=[];(t.ctrlKey||t.metaKey)&&s.push("ctrl"),t.shiftKey&&s.push("shift"),t.altKey&&s.push("alt"),t.key!=="Control"&&t.key!=="Shift"&&t.key!=="Alt"&&s.push(t.key.toLowerCase());for(const e of this.shortcuts)if(this.matchesShortcut(s,e.keys)){t.preventDefault(),e.callback();break}}matchesShortcut(t,s){return t.length!==s.length?!1:s.every(e=>t.includes(e))}}exports.ShortcutManager=u;