Skip to content

Commit 7b482a5

Browse files
committed
refactor, switch to tabs
1 parent b477a76 commit 7b482a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+4271
-3993
lines changed

.editorconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ root = true
99
[*]
1010
charset = utf-8
1111
end_of_line = lf
12-
indent_style = space
12+
indent_style = tab
1313
indent_size = 2
1414
trim_trailing_whitespace = true
1515

1616
[*.php]
17-
indent_style = tab
1817
indent_size = 4
1918
insert_final_newline = true
2019

src/components/BlockFormats.js

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,50 @@
11
export default class InlineFormats {
2-
constructor(defs) {
3-
4-
this.defs = defs.reduce((result, def) => {
5-
result[def.token] = result[def.token]
6-
? Object.assign(result[def.token], def)
7-
: def;
8-
return result;
9-
}, {});
10-
11-
this.markTokens = defs.reduce((result, def) => {
12-
if (result.includes(def.markToken)) return result;
13-
return [...result, def.markToken];
14-
}, []);
15-
16-
this.blockTypes = Object.keys(this.defs);
17-
}
18-
19-
get(type) {
20-
return this.defs[type];
21-
}
22-
23-
exists(type) {
24-
return typeof this.defs[type] !== "undefined";
25-
}
26-
27-
hasMark(type) {
28-
if (!this.exists(type)) return false;
29-
return typeof this.get(type).mark !== "undefined";
30-
}
31-
32-
mark(type) {
33-
if (!this.exists(type)) return null;
34-
return this.get(type).mark;
35-
}
36-
37-
markTokenExists(token) {
38-
return this.markTokens.includes(token);
39-
}
40-
41-
get types() {
42-
return this.blockTypes;
43-
}
44-
45-
render(type, n) {
46-
const format = this.get(type);
47-
return typeof format.render === "function" ? format.render(n) : format.render;
48-
}
2+
constructor(defs) {
3+
this.defs = defs.reduce((result, def) => {
4+
result[def.token] = result[def.token]
5+
? Object.assign(result[def.token], def)
6+
: def;
7+
return result;
8+
}, {});
9+
10+
this.markTokens = defs.reduce((result, def) => {
11+
if (result.includes(def.markToken)) return result;
12+
return [...result, def.markToken];
13+
}, []);
14+
15+
this.blockTypes = Object.keys(this.defs);
16+
}
17+
18+
get(type) {
19+
return this.defs[type];
20+
}
21+
22+
exists(type) {
23+
return typeof this.defs[type] !== "undefined";
24+
}
25+
26+
hasMark(type) {
27+
if (!this.exists(type)) return false;
28+
return typeof this.get(type).mark !== "undefined";
29+
}
30+
31+
mark(type) {
32+
if (!this.exists(type)) return null;
33+
return this.get(type).mark;
34+
}
35+
36+
markTokenExists(token) {
37+
return this.markTokens.includes(token);
38+
}
39+
40+
get types() {
41+
return this.blockTypes;
42+
}
43+
44+
render(type, n) {
45+
const format = this.get(type);
46+
return typeof format.render === "function"
47+
? format.render(n)
48+
: format.render;
49+
}
4950
}
Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
11
import Button from "./Button.js";
22

33
export default class BlockQuote extends Button {
4+
get button() {
5+
return {
6+
icon: "quote",
7+
label:
8+
this.input.$t("markdown.toolbar.button.blockquote") +
9+
this.formatKeyName(this.keys()[0]),
10+
command: this.command
11+
};
12+
}
413

5-
get button() {
6-
return {
7-
icon: "quote",
8-
label: this.input.$t("markdown.toolbar.button.blockquote") + this.formatKeyName(this.keys()[0]),
9-
command: this.command,
10-
};
11-
}
14+
get command() {
15+
return () => this.editor.toggleBlockFormat(this.token);
16+
}
1217

13-
get command() {
14-
return () => this.editor.toggleBlockFormat(this.token);
15-
}
18+
keys() {
19+
return [
20+
{
21+
mac: "Ctrl-Alt-q",
22+
key: "Alt-Shift-q",
23+
run: this.command,
24+
preventDefault: true
25+
}
26+
];
27+
}
1628

17-
keys() {
18-
return [
19-
{
20-
mac: "Ctrl-Alt-q",
21-
key: "Alt-Shift-q",
22-
run: this.command,
23-
preventDefault: true,
24-
}
25-
];
26-
}
29+
get name() {
30+
return "blockquote";
31+
}
2732

28-
get name() {
29-
return "blockquote";
30-
}
33+
get token() {
34+
return "Blockquote";
35+
}
3136

32-
get token() {
33-
return "Blockquote";
34-
}
35-
36-
get tokenType() {
37-
return "block";
38-
}
37+
get tokenType() {
38+
return "block";
39+
}
3940
}
Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
11
import Button from "./Button.js";
22

33
export default class BulletList extends Button {
4+
get button() {
5+
return {
6+
icon: "list-bullet",
7+
label:
8+
this.input.$t("toolbar.button.ul") + this.formatKeyName(this.keys()[0]),
9+
command: this.command
10+
};
11+
}
412

5-
get button() {
6-
return {
7-
icon: "list-bullet",
8-
label: this.input.$t("toolbar.button.ul") + this.formatKeyName(this.keys()[0]),
9-
command: this.command,
10-
};
11-
}
13+
get command() {
14+
return () => this.editor.toggleBlockFormat(this.token);
15+
}
1216

13-
get command() {
14-
return () => this.editor.toggleBlockFormat(this.token);
15-
}
17+
configure(options) {
18+
if (typeof options === "string") {
19+
options = { mark: options };
20+
}
1621

17-
configure(options) {
18-
if (typeof options === "string") {
19-
options = { mark: options };
20-
}
22+
Button.prototype.configure.call(this, options);
2123

22-
Button.prototype.configure.call(this, options);
24+
if (!["-", "*", "+"].includes(this.options.mark)) {
25+
throw "Bullet list mark must be either `-`, `*` or `+`.";
26+
}
27+
}
2328

24-
if (!["-", "*", "+"].includes(this.options.mark)) {
25-
throw "Bullet list mark must be either `-`, `*` or `+`.";
26-
}
27-
}
29+
get defaults() {
30+
return {
31+
mark: "-"
32+
};
33+
}
2834

29-
get defaults() {
30-
return {
31-
mark: "-",
32-
};
33-
}
35+
keys() {
36+
return [
37+
{
38+
mac: "Ctrl-Alt-u",
39+
key: "Alt-Shift-u",
40+
run: this.command,
41+
preventDefault: true
42+
}
43+
];
44+
}
3445

35-
keys() {
36-
return [
37-
{
38-
mac: "Ctrl-Alt-u",
39-
key: "Alt-Shift-u",
40-
run: this.command,
41-
preventDefault: true,
42-
}
43-
];
44-
}
46+
get name() {
47+
return "ul";
48+
}
4549

46-
get name() {
47-
return "ul";
48-
}
50+
get syntax() {
51+
// Override default with configured syntax
52+
return {
53+
token: this.token,
54+
type: this.tokenType,
55+
render: this.options.mark + " "
56+
};
57+
}
4958

50-
get syntax() {
51-
// Override default with configured syntax
52-
return {
53-
token: this.token,
54-
type: this.tokenType,
55-
render: this.options.mark + " ",
56-
};
57-
}
59+
get token() {
60+
return "BulletList";
61+
}
5862

59-
get token() {
60-
return "BulletList";
61-
}
62-
63-
get tokenType() {
64-
return "block";
65-
}
63+
get tokenType() {
64+
return "block";
65+
}
6666
}

0 commit comments

Comments
 (0)