Anyone with a login to Giant will be able to view, add, move, remove and rename files within it.
8 |Only you will be able to rename, delete or share the workspace itself.
9 |You can change this setting at any time by clicking Share Workspace.
10 |');
7 | html = html.replace('`', '
');
8 | count = (html.match(/`/g) || []).length;
9 | }
10 | return html;
11 | }
12 |
--------------------------------------------------------------------------------
/frontend/src/js/util/markdownToHtml.spec.js:
--------------------------------------------------------------------------------
1 | import markdownToHtml from './markdownToHtml';
2 |
3 | test('correctly convert with no backticks', () => {
4 | expect(markdownToHtml('test text no backticks')).toBe('test text no backticks');
5 | });
6 |
7 | test('correctly convert with one backtick', () => {
8 | expect(markdownToHtml('test `text one backtick')).toBe('test `text one backtick');
9 | });
10 |
11 | test('correctly convert with two backticks', () => {
12 | expect(markdownToHtml('test `text` two backticks')).toBe('test text
two backticks');
13 | });
14 |
15 | test('correctly convert with three backticks', () => {
16 | expect(markdownToHtml('test `text` three `backticks')).toBe('test text
three `backticks');
17 | });
18 |
--------------------------------------------------------------------------------
/frontend/src/js/util/readableFileSize.js:
--------------------------------------------------------------------------------
1 | export function readableFileSize(bytes, fractionalDigits = 1) {
2 | const threshold = 1024;
3 | const units = ['B', 'KiB', 'MiB', 'GiB', 'TiB'];
4 |
5 | if (bytes < 0 || bytes > Math.pow(threshold, units.length)) {
6 | throw new Error(`Cannot convert to human readable bytes, value is out of range (${bytes}).`);
7 | }
8 |
9 | let unitIdx = 0;
10 |
11 | while (bytes >= threshold) {
12 | bytes /= threshold;
13 | unitIdx += 1;
14 | }
15 |
16 | return bytes.toFixed(fractionalDigits) + ' ' + units[unitIdx];
17 | }
18 |
--------------------------------------------------------------------------------
/frontend/src/js/util/regexEscape.js:
--------------------------------------------------------------------------------
1 | export default function(s) {
2 | return s.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
3 | }
4 |
--------------------------------------------------------------------------------
/frontend/src/js/util/stringUtils.spec.ts:
--------------------------------------------------------------------------------
1 | import { getLastPart } from './stringUtils';
2 |
3 | test('getLastPart', () => {
4 | expect(getLastPart('blah/blurgh/hey', '/')).toBe('hey');
5 | expect(getLastPart('ha', '/')).toBe('ha');
6 | expect(getLastPart('hey.blurgh/hey', '.')).toBe('blurgh/hey');
7 | });
8 |
--------------------------------------------------------------------------------
/frontend/src/js/util/stringUtils.ts:
--------------------------------------------------------------------------------
1 | export function getLastPart(input: string, separator: string) {
2 | return input.split(separator).slice(-1)[0];
3 | }
4 |
5 | export function removeLastUnmatchedQuote(input: string) {
6 | const quoteCount = [...input.matchAll(/"/g)].length;
7 | if ((quoteCount % 2) !== 0) {
8 | return input.replace(/(.*)(")(.*)$/, '$1$3');
9 | }
10 | return input;
11 | }
12 |
--------------------------------------------------------------------------------
/frontend/src/js/util/styleLocalization.js:
--------------------------------------------------------------------------------
1 | import i18n from '../i18n';
2 |
3 | export default function directionalStyle(baseClass) {
4 | if (i18n.dir(i18n.language) == 'rtl') {
5 | return baseClass + '--rtl';
6 | }
7 | return baseClass;
8 | }
9 |
--------------------------------------------------------------------------------
/frontend/src/js/util/stylesheets/EUIStyles.tsx:
--------------------------------------------------------------------------------
1 | import '@elastic/eui/dist/eui_theme_light.css';
2 | import '../../../stylesheets/eui-main.scss';
3 |
4 | const EUIStyles: React.FC = () => null;
5 | export default EUIStyles;
--------------------------------------------------------------------------------
/frontend/src/js/util/stylesheets/OriginalGiantStyles.tsx:
--------------------------------------------------------------------------------
1 | import 'semantic-ui-css/semantic.min.css';
2 | import '../../../stylesheets/main.scss';
3 |
4 | const OriginalGiantStyles: React.FC = () => null;
5 | export default OriginalGiantStyles;
--------------------------------------------------------------------------------
/frontend/src/js/util/stylesheets/StylesheetLoader.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | const OriginalGiantStyles = React.lazy(() => import('./OriginalGiantStyles'));
4 | const EUIStyles = React.lazy(() => import('./EUIStyles'));
5 |
6 | // This is a trick to conditionally load CSS at runtime without ejecting from Create React App
7 | // https://stackoverflow.com/questions/46835825/conditional-css-in-create-react-app
8 | export function StylesheetLoader({ eui, children }: { eui: boolean, children: React.ReactElement[] }) {
9 | return