@accordproject/markdown-editor
Version:
A rich text editor that can read and write markdown text. Based on Slate.js.
64 lines (49 loc) • 1.53 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.identifyBlock = exports.capitalizeWord = exports.MOD = void 0;
/**
*************** INTERNAL METHODS ***************
*/
/**
* Methods for conversion to strings and further manipulation.
*/
const capitalizeFirst = word => word.toString().charAt(0).toUpperCase();
const sliceWord = word => word.toString().slice(1);
const firstTwoLetters = word => word.toString().slice(0, 2);
/**
* Function to determine OS and MOD command of user
*/
function OS() {
const platform = window.navigator.platform;
const macosPlatforms = {
Macintosh: true,
MacIntel: true,
MacPPC: true,
Mac68K: true
};
if (macosPlatforms[platform]) return '⌘';
return 'Ctrl';
}
const MOD = OS();
/**
*************** EXTERNAL METHODS ***************
*/
/**
* Converts an input into a string, capitalizes the first letter, and returns string
*/
exports.MOD = MOD;
const capitalizeWord = word => capitalizeFirst(word) + sliceWord(word);
/**
* Checks the beginning of a block type to determine the string to return
*/
exports.capitalizeWord = capitalizeWord;
const identifyBlock = block => {
const typeBeginning = firstTwoLetters(block);
if (typeBeginning === 'bl') return "Quote (".concat(MOD, "+\u21E7+. )");
if (typeBeginning === 'ul') return "Bulleted List (".concat(MOD, "+\u21E7+8)");
if (typeBeginning === 'ol') return "Numbered List (".concat(MOD, "+\u21E7+7)");
return null;
};
exports.identifyBlock = identifyBlock;