Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
refactor(FormattingToolbar): consolidate code - I270
Browse files Browse the repository at this point in the history
Signed-off-by: irmerk <[email protected]>
  • Loading branch information
jolanglinais committed Mar 9, 2020
1 parent 565c652 commit eb55ae3
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/FormattingToolbar/toolbarTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,17 @@ const firstTwoLetters = word => word.toString().slice(0, 2);
/**
* Function to determine OS and MOD command of user
*/

function OS () {
const {platform} = window.navigator;
function OS() {
const { platform } = window.navigator;

const macosPlatforms = {
os: {
"Macintosh": true,
"MacIntel": true,
"MacPPC": true,
"Mac68K": true
},
MOD: "⌘"
Macintosh: true,
MacIntel: true,
MacPPC: true,
Mac68K: true
};

if (macosPlatforms.os[platform]) return macosPlatforms.MOD;
if (macosPlatforms[platform]) return '⌘';
return 'Ctrl';
}

Expand All @@ -52,8 +48,8 @@ export const capitalizeWord = word => capitalizeFirst(word) + sliceWord(word);

export const identifyBlock = (block) => {
const typeBeginning = firstTwoLetters(block);
if(typeBeginning === 'bl') return `Quote (${MOD}+Q)`;
if(typeBeginning === 'ul') return `Bulleted List (${MOD}+Shift+8)`;
if(typeBeginning === 'ol') return `Numbered List (${MOD}+Shift+7)`;
if (typeBeginning === 'bl') return `Quote (${MOD}+Q)`;
if (typeBeginning === 'ul') return `Bulleted List (${MOD}+Shift+8)`;
if (typeBeginning === 'ol') return `Numbered List (${MOD}+Shift+7)`;
return null;
};

0 comments on commit eb55ae3

Please sign in to comment.