punkweb-bb 0.2.3__py3-none-any.whl → 0.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- punkweb_bb/__pycache__/admin.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/admin_forms.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/bbcode.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/forms.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/middleware.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/mixins.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/models.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/pagination.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/parsers.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/response.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/settings.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/signals.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/tags.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/tests.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/urls.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/utils.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/views.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/widgets.cpython-311.pyc +0 -0
- punkweb_bb/admin.py +0 -5
- punkweb_bb/admin_forms.py +6 -5
- punkweb_bb/bbcode.py +155 -0
- punkweb_bb/forms.py +13 -5
- punkweb_bb/migrations/0005_alter_thread_options.py +24 -0
- punkweb_bb/migrations/0006_remove_boardprofile__signature_rendered_and_more.py +60 -0
- punkweb_bb/migrations/__pycache__/0005_alter_thread_options.cpython-311.pyc +0 -0
- punkweb_bb/migrations/__pycache__/0006_remove_boardprofile__signature_rendered_and_more.cpython-311.pyc +0 -0
- punkweb_bb/models.py +6 -6
- punkweb_bb/settings.py +1 -0
- punkweb_bb/static/punkweb_bb/css/defaults.css +2 -2
- punkweb_bb/static/punkweb_bb/css/punkweb-modal.css +2 -0
- punkweb_bb/static/punkweb_bb/css/punkweb.css +2 -2
- punkweb_bb/static/punkweb_bb/css/subcategory.css +4 -0
- punkweb_bb/static/punkweb_bb/css/thread.css +24 -0
- punkweb_bb/static/punkweb_bb/editor/bbcode-editor-content.css +4 -5
- punkweb_bb/static/punkweb_bb/editor/bbcode-editor.js +0 -5
- punkweb_bb/static/punkweb_bb/editor/markdown-editor.js +49 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/.eslintrc.json +15 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/.gitignore +108 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/.prettierrc.json +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/LICENSE +21 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/README.md +240 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/babel.config.json +14 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/blank.html +18 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/demo.html +126 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.css +231 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.js +3086 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.min.css +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.min.js +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.tiny.js +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/docs/_config.yml +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/docs/_layouts/default.html +50 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/docs/index.md +174 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/globals.d.ts +172 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/gulpfile.mjs +226 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/block.test.js +696 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/commandbar.test.js +84 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/inline.test.js +486 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/interaction.test.js +31 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/setup.test.js +164 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/util/config.js +2 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/util/server.js +9 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/util/setup.js +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/util/test-helpers.js +98 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest-puppeteer.config.js +8 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest.config.js +13 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/package-lock.json +16295 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/package.json +72 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/TinyMDE.js +1926 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/TinyMDECommandBar.js +256 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/css/commandbar.css +72 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/css/editor.css +157 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/css/index.css +3 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/grammar.js +300 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/html/blank.html +18 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/html/demo.html +126 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/index.js +4 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/blockquote.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/bold.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/clear_formatting.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/code.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/h1.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/h2.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/hr.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/image.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/italic.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/link.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/ol.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/strikethrough.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/svg.js +17 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/ul.svg +1 -0
- punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/tiny.js +3 -0
- punkweb_bb/templates/punkweb_bb/base_delete_modal.html +13 -0
- punkweb_bb/templates/punkweb_bb/bbcode.html +2 -3
- punkweb_bb/templates/punkweb_bb/index.html +2 -2
- punkweb_bb/templates/punkweb_bb/partials/category_delete.html +4 -8
- punkweb_bb/templates/punkweb_bb/partials/post_delete.html +4 -8
- punkweb_bb/templates/punkweb_bb/partials/shout_delete.html +4 -8
- punkweb_bb/templates/punkweb_bb/partials/subcategory_delete.html +4 -8
- punkweb_bb/templates/punkweb_bb/partials/thread_delete.html +4 -8
- punkweb_bb/templates/punkweb_bb/partials/thread_move.html +24 -0
- punkweb_bb/templates/punkweb_bb/profile.html +2 -2
- punkweb_bb/templates/punkweb_bb/shoutbox/shout_list.html +2 -2
- punkweb_bb/templates/punkweb_bb/subcategory.html +1 -1
- punkweb_bb/templates/punkweb_bb/thread.html +24 -14
- punkweb_bb/templates/punkweb_bb/widgets/markdown-editor.html +4 -0
- punkweb_bb/templatetags/__pycache__/markdown.cpython-311.pyc +0 -0
- punkweb_bb/templatetags/__pycache__/render.cpython-311.pyc +0 -0
- punkweb_bb/templatetags/__pycache__/shoutbox_bbcode.cpython-311.pyc +0 -0
- punkweb_bb/templatetags/__pycache__/shoutbox_render.cpython-311.pyc +0 -0
- punkweb_bb/templatetags/render.py +35 -0
- punkweb_bb/tests.py +3 -3
- punkweb_bb/urls.py +1 -0
- punkweb_bb/utils.py +24 -10
- punkweb_bb/views.py +45 -23
- punkweb_bb/widgets.py +20 -0
- {punkweb_bb-0.2.3.dist-info → punkweb_bb-0.4.0.dist-info}/METADATA +58 -51
- {punkweb_bb-0.2.3.dist-info → punkweb_bb-0.4.0.dist-info}/RECORD +120 -53
- punkweb_bb/bbcode_tags.py +0 -167
- punkweb_bb/parsers.py +0 -70
- punkweb_bb/templatetags/shoutbox_bbcode.py +0 -14
- {punkweb_bb-0.2.3.dist-info → punkweb_bb-0.4.0.dist-info}/LICENSE +0 -0
- {punkweb_bb-0.2.3.dist-info → punkweb_bb-0.4.0.dist-info}/WHEEL +0 -0
- {punkweb_bb-0.2.3.dist-info → punkweb_bb-0.4.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import svg from './svg/svg';
|
|
2
|
+
|
|
3
|
+
const isMacLike = /(Mac|iPhone|iPod|iPad)/i.test(typeof navigator !== "undefined" ? navigator.platform : "");
|
|
4
|
+
|
|
5
|
+
const DefaultCommands = {
|
|
6
|
+
'bold': {
|
|
7
|
+
name: 'bold',
|
|
8
|
+
action: 'bold',
|
|
9
|
+
innerHTML: svg.bold,
|
|
10
|
+
title: 'Bold',
|
|
11
|
+
hotkey: 'Mod-B',
|
|
12
|
+
},
|
|
13
|
+
'italic': {
|
|
14
|
+
name: 'italic',
|
|
15
|
+
action: 'italic',
|
|
16
|
+
innerHTML: svg.italic,
|
|
17
|
+
title: 'Italic',
|
|
18
|
+
hotkey: 'Mod-I',
|
|
19
|
+
},
|
|
20
|
+
'strikethrough': {
|
|
21
|
+
name: 'strikethrough',
|
|
22
|
+
action: 'strikethrough',
|
|
23
|
+
innerHTML: svg.strikethrough,
|
|
24
|
+
title: 'Strikethrough',
|
|
25
|
+
hotkey: 'Mod2-Shift-5',
|
|
26
|
+
},
|
|
27
|
+
'code': {
|
|
28
|
+
name: 'code',
|
|
29
|
+
action: 'code',
|
|
30
|
+
innerHTML: svg.code,
|
|
31
|
+
title: 'Format as code',
|
|
32
|
+
},
|
|
33
|
+
'h1': {
|
|
34
|
+
name: 'h1',
|
|
35
|
+
action: 'h1',
|
|
36
|
+
innerHTML: svg.h1,
|
|
37
|
+
title: 'Level 1 heading',
|
|
38
|
+
hotkey: 'Mod-Shift-1',
|
|
39
|
+
},
|
|
40
|
+
'h2': {
|
|
41
|
+
name: 'h2',
|
|
42
|
+
action: 'h2',
|
|
43
|
+
innerHTML: svg.h2,
|
|
44
|
+
title: 'Level 2 heading',
|
|
45
|
+
hotkey: 'Mod-Shift-2',
|
|
46
|
+
},
|
|
47
|
+
'ul': {
|
|
48
|
+
name: 'ul',
|
|
49
|
+
action: 'ul',
|
|
50
|
+
innerHTML: svg.ul,
|
|
51
|
+
title: 'Bulleted list',
|
|
52
|
+
},
|
|
53
|
+
'ol': {
|
|
54
|
+
name: 'ol',
|
|
55
|
+
action: 'ol',
|
|
56
|
+
innerHTML: svg.ol,
|
|
57
|
+
title: 'Numbered list',
|
|
58
|
+
},
|
|
59
|
+
'blockquote': {
|
|
60
|
+
name: 'blockquote',
|
|
61
|
+
action: 'blockquote',
|
|
62
|
+
innerHTML: svg.blockquote,
|
|
63
|
+
title: 'Quote',
|
|
64
|
+
hotkey: 'Mod2-Shift-Q',
|
|
65
|
+
},
|
|
66
|
+
'insertLink': {
|
|
67
|
+
name: 'insertLink',
|
|
68
|
+
action: (editor) => {if (editor.isInlineFormattingAllowed()) editor.wrapSelection('[', ']()')},
|
|
69
|
+
enabled: (editor, focus, anchor) => editor.isInlineFormattingAllowed(focus, anchor) ? false : null,
|
|
70
|
+
innerHTML: svg.link,
|
|
71
|
+
title: 'Insert link',
|
|
72
|
+
hotkey: 'Mod-K',
|
|
73
|
+
},
|
|
74
|
+
'insertImage': {
|
|
75
|
+
name: 'insertImage',
|
|
76
|
+
action: (editor) => {if (editor.isInlineFormattingAllowed()) editor.wrapSelection('![', ']()')},
|
|
77
|
+
enabled: (editor, focus, anchor) => editor.isInlineFormattingAllowed(focus, anchor) ? false : null,
|
|
78
|
+
innerHTML: svg.image,
|
|
79
|
+
title: 'Insert image',
|
|
80
|
+
hotkey: 'Mod2-Shift-I',
|
|
81
|
+
},
|
|
82
|
+
'hr': {
|
|
83
|
+
name: 'hr',
|
|
84
|
+
action: (editor) => editor.paste('\n***\n'),
|
|
85
|
+
enabled: () => false,
|
|
86
|
+
innerHTML: svg.hr,
|
|
87
|
+
title: 'Insert horizontal line',
|
|
88
|
+
hotkey: 'Mod2-Shift-L'
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class CommandBar {
|
|
94
|
+
constructor(props) {
|
|
95
|
+
this.e = null;
|
|
96
|
+
this.editor = null;
|
|
97
|
+
this.commands = [];
|
|
98
|
+
this.buttons = {};
|
|
99
|
+
this.state = {};
|
|
100
|
+
this.hotkeys = [];
|
|
101
|
+
|
|
102
|
+
let element = props.element;
|
|
103
|
+
if (element && !element.tagName) {
|
|
104
|
+
element = document.getElementById(props.element);
|
|
105
|
+
}
|
|
106
|
+
if (!element) {
|
|
107
|
+
element = document.body;
|
|
108
|
+
}
|
|
109
|
+
this.createCommandBarElement(element, props.commands || ['bold', 'italic', 'strikethrough', '|', 'code', '|', 'h1', 'h2', '|', 'ul', 'ol', '|', 'blockquote', 'hr', '|', 'insertLink', 'insertImage']);
|
|
110
|
+
document.addEventListener('keydown', (e) => this.handleKeydown(e));
|
|
111
|
+
if (props.editor) this.setEditor(props.editor);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
createCommandBarElement(parentElement, commands) {
|
|
115
|
+
this.e = document.createElement('div');
|
|
116
|
+
this.e.className = 'TMCommandBar';
|
|
117
|
+
|
|
118
|
+
for (let command of commands) {
|
|
119
|
+
if (command == '|') {
|
|
120
|
+
let el = document.createElement('div');
|
|
121
|
+
el.className = 'TMCommandDivider';
|
|
122
|
+
this.e.appendChild(el);
|
|
123
|
+
} else {
|
|
124
|
+
let commandName;
|
|
125
|
+
if (typeof command == "string") {
|
|
126
|
+
// Reference to default command
|
|
127
|
+
|
|
128
|
+
if (DefaultCommands[command]) {
|
|
129
|
+
commandName = command;
|
|
130
|
+
this.commands[commandName] = DefaultCommands[commandName];
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
} else {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
} else if (typeof command == "object" && command.name) {
|
|
138
|
+
commandName = command.name;
|
|
139
|
+
this.commands[commandName] = {};
|
|
140
|
+
if (DefaultCommands[commandName]) Object.assign(this.commands[commandName], DefaultCommands[commandName]);
|
|
141
|
+
Object.assign(this.commands[commandName], command);
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
} else {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
let title = this.commands[commandName].title || commandName;
|
|
149
|
+
|
|
150
|
+
if (this.commands[commandName].hotkey) {
|
|
151
|
+
const keys = this.commands[commandName].hotkey.split('-');
|
|
152
|
+
// construct modifiers
|
|
153
|
+
let modifiers = [];
|
|
154
|
+
let modifierexplanation = [];
|
|
155
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
156
|
+
switch (keys[i]) {
|
|
157
|
+
case 'Ctrl': modifiers.push('ctrlKey'); modifierexplanation.push('Ctrl'); break;
|
|
158
|
+
case 'Cmd': modifiers.push('metaKey'); modifierexplanation.push('⌘'); break;
|
|
159
|
+
case 'Alt': modifiers.push('altKey'); modifierexplanation.push('Alt'); break;
|
|
160
|
+
case 'Option': modifiers.push('altKey'); modifierexplanation.push('⌥'); break;
|
|
161
|
+
case 'Win': modifiers.push('metaKey'); modifierexplanation.push('⊞ Win'); break;
|
|
162
|
+
|
|
163
|
+
case 'Shift': modifiers.push('shiftKey'); modifierexplanation.push('⇧'); break;
|
|
164
|
+
|
|
165
|
+
case 'Mod': // Mod is a convenience mechanism: Ctrl on Windows, Cmd on Mac
|
|
166
|
+
if (isMacLike) {modifiers.push('metaKey'); modifierexplanation.push('⌘');}
|
|
167
|
+
else {modifiers.push('ctrlKey'); modifierexplanation.push('Ctrl');}
|
|
168
|
+
break;
|
|
169
|
+
case 'Mod2':
|
|
170
|
+
modifiers.push('altKey');
|
|
171
|
+
if (isMacLike) modifierexplanation.push('⌥');
|
|
172
|
+
else modifierexplanation.push('Alt');
|
|
173
|
+
break; // Mod2 is a convenience mechanism: Alt on Windows, Option on Mac
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
modifierexplanation.push(keys[keys.length - 1]);
|
|
177
|
+
let hotkey = {
|
|
178
|
+
|
|
179
|
+
modifiers: modifiers,
|
|
180
|
+
command: commandName,
|
|
181
|
+
};
|
|
182
|
+
// TODO Right now this is working only for letters and numbers
|
|
183
|
+
if (keys[keys.length - 1].match(/^[0-9]$/)) {
|
|
184
|
+
hotkey.code = `Digit${keys[keys.length - 1]}`;
|
|
185
|
+
} else {
|
|
186
|
+
hotkey.key = keys[keys.length - 1].toLowerCase();
|
|
187
|
+
}
|
|
188
|
+
this.hotkeys.push(hotkey);
|
|
189
|
+
title = title.concat(` (${modifierexplanation.join('+')})`);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
this.buttons[commandName] = document.createElement('div');
|
|
193
|
+
this.buttons[commandName].className = 'TMCommandButton TMCommandButton_Disabled';
|
|
194
|
+
this.buttons[commandName].title = title;
|
|
195
|
+
this.buttons[commandName].innerHTML = this.commands[commandName].innerHTML;
|
|
196
|
+
|
|
197
|
+
this.buttons[commandName].addEventListener('mousedown', (e) => this.handleClick(commandName, e));
|
|
198
|
+
this.e.appendChild(this.buttons[commandName]);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
parentElement.appendChild(this.e);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
handleClick(commandName, event) {
|
|
205
|
+
if (!this.editor) return;
|
|
206
|
+
event.preventDefault();
|
|
207
|
+
if (typeof this.commands[commandName].action == "string") {
|
|
208
|
+
if (this.state[commandName] === false) this.editor.setCommandState(commandName, true);
|
|
209
|
+
else this.editor.setCommandState(commandName, false);
|
|
210
|
+
} else if (typeof this.commands[commandName].action == "function") {
|
|
211
|
+
this.commands[commandName].action(this.editor);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
setEditor(editor) {
|
|
216
|
+
this.editor = editor;
|
|
217
|
+
editor.addEventListener('selection', (e) => this.handleSelection(e));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
handleSelection(event) {
|
|
221
|
+
if (event.commandState) {
|
|
222
|
+
for (let command in this.commands) {
|
|
223
|
+
if (event.commandState[command] === undefined) {
|
|
224
|
+
if (this.commands[command].enabled) this.state[command] = this.commands[command].enabled(this.editor, event.focus, event.anchor);
|
|
225
|
+
else this.state[command] = event.focus ? false : null;
|
|
226
|
+
} else {
|
|
227
|
+
this.state[command] = event.commandState[command];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (this.state[command] === true) {
|
|
231
|
+
this.buttons[command].className = 'TMCommandButton TMCommandButton_Active';
|
|
232
|
+
} else if (this.state[command] === false) {
|
|
233
|
+
this.buttons[command].className = 'TMCommandButton TMCommandButton_Inactive';
|
|
234
|
+
} else {
|
|
235
|
+
this.buttons[command].className = 'TMCommandButton TMCommandButton_Disabled';
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
handleKeydown(event) {
|
|
242
|
+
outer: for (let hotkey of this.hotkeys) {
|
|
243
|
+
if ((hotkey.key && event.key.toLowerCase() == hotkey.key) || (hotkey.code && event.code == hotkey.code)) {
|
|
244
|
+
// Key matches hotkey. Look for any required modifier that wasn't pressed
|
|
245
|
+
for (let modifier of hotkey.modifiers) {
|
|
246
|
+
if (!event[modifier]) continue outer;
|
|
247
|
+
}
|
|
248
|
+
// Everything matches.
|
|
249
|
+
this.handleClick(hotkey.command, event);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export default CommandBar;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
.TMCommandBar {
|
|
2
|
+
background-color: var(--oc-gray-1);
|
|
3
|
+
border: 1px solid var(--border);
|
|
4
|
+
border-bottom: none;
|
|
5
|
+
border-top-left-radius: 0.25rem;
|
|
6
|
+
border-top-right-radius: 0.25rem;
|
|
7
|
+
/* height: 24px; */
|
|
8
|
+
/* border:4px solid var(--oc-gray-1); */
|
|
9
|
+
/* box-sizing: content-box; */
|
|
10
|
+
display: flex;
|
|
11
|
+
gap: 0.25rem;
|
|
12
|
+
padding: 0.25rem;
|
|
13
|
+
user-select: none;
|
|
14
|
+
overflow-x: scroll;
|
|
15
|
+
overflow-y: hidden;
|
|
16
|
+
scrollbar-width: none;
|
|
17
|
+
-ms-overflow-style: none;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.TMCommandBar::-webkit-scrollbar {
|
|
21
|
+
display: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.TMCommandButton {
|
|
25
|
+
/* box-sizing: border-box; */
|
|
26
|
+
display: inline-block;
|
|
27
|
+
height: 24px;
|
|
28
|
+
width: 24px;
|
|
29
|
+
/* padding:3px; */
|
|
30
|
+
/* margin-right:4px; */
|
|
31
|
+
color: var(--oc-gray-9);
|
|
32
|
+
fill: var(--oc-gray-9);
|
|
33
|
+
text-align: center;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
vertical-align: middle;
|
|
36
|
+
font-size: 20px;
|
|
37
|
+
line-height: 18px;
|
|
38
|
+
font-family: sans-serif;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.TMCommandDivider {
|
|
42
|
+
/* box-sizing: content-box; */
|
|
43
|
+
height: 24px;
|
|
44
|
+
margin: 0 8px;
|
|
45
|
+
width: 0px;
|
|
46
|
+
border-left: 2px solid var(--border);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.TMCommandButton_Active {
|
|
50
|
+
font-weight: bold;
|
|
51
|
+
color: var(--primary-9);
|
|
52
|
+
background-color: var(--primary-2);
|
|
53
|
+
fill: var(--primary-9);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.TMCommandButton_Inactive {
|
|
57
|
+
background-color: var(--oc-gray-1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.TMCommandButton_Disabled {
|
|
61
|
+
color: var(--oc-gray-7);
|
|
62
|
+
fill: var(--oc-gray-7);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@media (hover: hover) {
|
|
66
|
+
.TMCommandButton_Active:hover,
|
|
67
|
+
.TMCommandButton_Disabled:hover,
|
|
68
|
+
.TMCommandButton_Inactive:hover {
|
|
69
|
+
background-color: var(--primary-1);
|
|
70
|
+
fill: var(--oc-gray-9);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
.TinyMDE {
|
|
2
|
+
background-color: #fff;
|
|
3
|
+
border: 1px solid var(--border);
|
|
4
|
+
border-bottom-left-radius: 0.25rem;
|
|
5
|
+
border-bottom-right-radius: 0.25rem;
|
|
6
|
+
color: var(--oc-gray-9);
|
|
7
|
+
font-size: 16px;
|
|
8
|
+
line-height: 1.5;
|
|
9
|
+
outline: none;
|
|
10
|
+
padding: 0.5rem 1rem;
|
|
11
|
+
min-height: 12rem;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.TMBlankLine {
|
|
15
|
+
height: 1.5rem;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.TMH1,
|
|
19
|
+
.TMSetextH1 {
|
|
20
|
+
font-size: 2rem;
|
|
21
|
+
line-height: 32px;
|
|
22
|
+
font-weight: bold;
|
|
23
|
+
margin-bottom: 8px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.TMSetextH1 {
|
|
27
|
+
margin-bottom: 0px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.TMSetextH1Marker {
|
|
31
|
+
margin-bottom: 8px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.TMH2,
|
|
35
|
+
.TMSetextH2 {
|
|
36
|
+
font-size: 20px;
|
|
37
|
+
line-height: 28px;
|
|
38
|
+
font-weight: bold;
|
|
39
|
+
margin-bottom: 4px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.TMMark_TMCode {
|
|
43
|
+
font-family: monospace;
|
|
44
|
+
font-size: 0.9em;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.TMFencedCodeBacktick,
|
|
48
|
+
.TMFencedCodeTilde,
|
|
49
|
+
.TMIndentedCode,
|
|
50
|
+
.TMCode {
|
|
51
|
+
font-family: monospace;
|
|
52
|
+
font-size: 0.9em;
|
|
53
|
+
background-color: #e0e0e0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.TMCodeFenceBacktickOpen,
|
|
57
|
+
.TMCodeFenceTildeOpen {
|
|
58
|
+
border-bottom: 1px solid #c0c0c0;
|
|
59
|
+
font-family: monospace;
|
|
60
|
+
font-size: 0.9em;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.TMCodeFenceBacktickClose,
|
|
64
|
+
.TMCodeFenceTildeClose {
|
|
65
|
+
border-top: 1px solid #c0c0c0;
|
|
66
|
+
font-family: monospace;
|
|
67
|
+
font-size: 0.9em;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.TMInfoString {
|
|
71
|
+
color: #0000ff;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.TMCode {
|
|
75
|
+
border: 1px solid #c0c0c0;
|
|
76
|
+
border-radius: 2px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.TMBlockquote {
|
|
80
|
+
font-style: italic;
|
|
81
|
+
border-left: 2px solid #c0c0c0;
|
|
82
|
+
padding-left: 10px;
|
|
83
|
+
margin-left: 10px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.TMMark {
|
|
87
|
+
color: #a0a0a0;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.TMMark_TMH1,
|
|
91
|
+
.TMMark_TMH2 {
|
|
92
|
+
color: #ff8080;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.TMMark_TMUL,
|
|
96
|
+
.TMMark_TMOL {
|
|
97
|
+
color: #ff8080;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.TMImage {
|
|
101
|
+
text-decoration: underline;
|
|
102
|
+
text-decoration-color: #00ff00;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.TMLink {
|
|
106
|
+
text-decoration: underline;
|
|
107
|
+
text-decoration-color: #0000ff;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.TMLinkLabel {
|
|
111
|
+
text-decoration: underline;
|
|
112
|
+
font-family: monospace;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.TMLinkLabel_Definition,
|
|
116
|
+
.TMLinkLabel_Valid {
|
|
117
|
+
color: #40c040;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.TMLinkLabel_Invalid {
|
|
121
|
+
color: #ff0000;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.TMLinkTitle {
|
|
125
|
+
font-style: italic;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.TMLinkDestination,
|
|
129
|
+
.TMAutolink {
|
|
130
|
+
text-decoration: underline;
|
|
131
|
+
color: #0000ff;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.TMHR {
|
|
135
|
+
position: relative;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.TMHR:before {
|
|
139
|
+
content: "";
|
|
140
|
+
position: absolute;
|
|
141
|
+
bottom: 50%;
|
|
142
|
+
left: 40%;
|
|
143
|
+
border-bottom: 2px solid #808080;
|
|
144
|
+
width: 20%;
|
|
145
|
+
z-index: 0;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.TMHTML,
|
|
149
|
+
.TMHTMLBlock {
|
|
150
|
+
font-family: monospace;
|
|
151
|
+
font-size: 0.9em;
|
|
152
|
+
color: #8000ff;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.TMHTMLBlock {
|
|
156
|
+
color: #6000c0;
|
|
157
|
+
}
|