Skip to content

Commit b8be100

Browse files
committed
Make react-mde zero dependencies
1 parent dce34b7 commit b8be100

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

src/components/MdeToolbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import {Command, CommandGroup, GetIcon} from "../types";
33
import { MdeToolbarButtonGroup } from "./MdeToolbarButtonGroup";
44
import { MdeToolbarDropdown } from "./MdeToolbarDropdown";
55
import { MdeToolbarButton } from "./MdeToolbarButton";
6-
import * as classNames from "classnames";
76
import { Tab } from "../types/Tab";
87
import { L18n } from "..";
8+
import {classNames} from "../util/ClassNames";
99

1010
export interface MdeToolbarProps {
1111
getIconFromProvider: GetIcon;

src/components/ReactMde.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ import {
55
} from "../types";
66
import {getDefaultCommands} from "../commands";
77
import {TextArea, MdePreview, MdeToolbar, MdeFontAwesomeIcon} from ".";
8-
import * as classNames from "classnames";
98
import {extractCommandMap} from "../util/CommandUtils";
109
import {Tab} from "../types/Tab";
1110
import {L18n} from "..";
1211
import {enL18n} from "../l18n/react-mde.en";
1312
import {CommandOrchestrator, TextAreaCommandOrchestrator} from "../commandOrchestrator";
14-
import {SvgIcon} from "../icons/SvgIcon";
13+
import {classNames} from "../util/ClassNames";
1514

1615
export interface ReactMdeProps {
1716
value: string;

src/util/ClassNames.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*!
2+
Copyright (c) 2018 Jed Watson.
3+
Licensed under the MIT License (MIT), see
4+
http://jedwatson.github.io/classnames
5+
*/
6+
7+
export function classNames(...args: any[]) {
8+
const classes = [];
9+
10+
for (let i = 0; i < arguments.length; i++) {
11+
const arg = arguments[i];
12+
if (!arg) continue;
13+
14+
const argType = typeof arg;
15+
16+
if (argType === "string" || argType === "number") {
17+
classes.push(arg);
18+
} else if (Array.isArray(arg) && arg.length) {
19+
var inner = classNames.apply(null, arg);
20+
if (inner) {
21+
classes.push(inner);
22+
}
23+
} else if (argType === "object") {
24+
for (let key in arg) {
25+
if (arg.hasOwnProperty(key) && arg[key]) {
26+
classes.push(key);
27+
}
28+
}
29+
}
30+
}
31+
32+
return classes.join(" ");
33+
}

src/util/InsertText.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*!
2+
* The MIT License
3+
Copyright (c) 2018 Dmitriy Kubyshkin
4+
Copied from https://github.com/grassator/insert-text-at-cursor
5+
*/
6+
17
/**
28
* @param {HTMLElement} input
39
* @return {boolean}

0 commit comments

Comments
 (0)