Skip to content

Commit ebe2ca7

Browse files
committed
Lexical: Added about button/view
Re-used existing route and moved tinymce help to its own different route. Added test to cover. Added new external-content block to support in editor UI.
1 parent f4005a1 commit ebe2ca7

File tree

14 files changed

+388
-170
lines changed

14 files changed

+388
-170
lines changed

lang/en/editor.php

+2
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@
163163
'about' => 'About the editor',
164164
'about_title' => 'About the WYSIWYG Editor',
165165
'editor_license' => 'Editor License & Copyright',
166+
'editor_lexical_license' => 'This editor is built as a fork of :lexicalLink which is distributed under the MIT license.',
167+
'editor_lexical_license_link' => 'Full license details can be found here.',
166168
'editor_tiny_license' => 'This editor is built using :tinyLink which is provided under the MIT license.',
167169
'editor_tiny_license_link' => 'The copyright and license details of TinyMCE can be found here.',
168170
'save_continue' => 'Save Page & Continue',
File renamed without changes.

resources/js/wysiwyg-tinymce/plugins-about.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
function register(editor) {
55
const aboutDialog = {
66
title: 'About the WYSIWYG Editor',
7-
url: window.baseUrl('/help/wysiwyg'),
7+
url: window.baseUrl('/help/tinymce'),
88
};
99

1010
editor.ui.registry.addButton('about', {

resources/js/wysiwyg/ui/defaults/buttons/controls.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import {
1111
} from "lexical";
1212
import redoIcon from "@icons/editor/redo.svg";
1313
import sourceIcon from "@icons/editor/source-view.svg";
14-
import {getEditorContentAsHtml} from "../../../utils/actions";
1514
import fullscreenIcon from "@icons/editor/fullscreen.svg";
15+
import aboutIcon from "@icons/editor/about.svg";
16+
import {getEditorContentAsHtml} from "../../../utils/actions";
1617

1718
export const undo: EditorButtonDefinition = {
1819
label: 'Undo',
@@ -80,4 +81,16 @@ export const fullscreen: EditorButtonDefinition = {
8081
isActive(selection, context: EditorUiContext) {
8182
return context.containerDOM.classList.contains('fullscreen');
8283
}
84+
};
85+
86+
export const about: EditorButtonDefinition = {
87+
label: 'About the editor',
88+
icon: aboutIcon,
89+
async action(context: EditorUiContext, button: EditorButton) {
90+
const modal = context.manager.createModal('about');
91+
modal.show({});
92+
},
93+
isActive(selection, context: EditorUiContext) {
94+
return false;
95+
}
8396
};

resources/js/wysiwyg/ui/defaults/forms/controls.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {EditorFormDefinition} from "../../framework/forms";
2-
import {EditorUiContext} from "../../framework/core";
2+
import {EditorUiContext, EditorUiElement} from "../../framework/core";
33
import {setEditorContentFromHtml} from "../../../utils/actions";
4+
import {ExternalContent} from "../../framework/blocks/external-content";
45

56
export const source: EditorFormDefinition = {
67
submitText: 'Save',
@@ -15,4 +16,18 @@ export const source: EditorFormDefinition = {
1516
type: 'textarea',
1617
},
1718
],
19+
};
20+
21+
export const about: EditorFormDefinition = {
22+
submitText: 'Close',
23+
async action() {
24+
return true;
25+
},
26+
fields: [
27+
{
28+
build(): EditorUiElement {
29+
return new ExternalContent('/help/wysiwyg');
30+
}
31+
}
32+
],
1833
};

resources/js/wysiwyg/ui/defaults/modals.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {EditorFormModalDefinition} from "../framework/modals";
22
import {details, image, link, media} from "./forms/objects";
3-
import {source} from "./forms/controls";
3+
import {about, source} from "./forms/controls";
44
import {cellProperties, rowProperties, tableProperties} from "./forms/tables";
55

66
export const modals: Record<string, EditorFormModalDefinition> = {
@@ -35,5 +35,9 @@ export const modals: Record<string, EditorFormModalDefinition> = {
3535
details: {
3636
title: 'Edit collapsible block',
3737
form: details,
38+
},
39+
about: {
40+
title: 'About the WYSIWYG Editor',
41+
form: about,
3842
}
3943
};

resources/js/wysiwyg/ui/toolbars.ts renamed to resources/js/wysiwyg/ui/defaults/toolbars.ts

+20-19
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import {EditorButton} from "./framework/buttons";
2-
import {EditorContainerUiElement, EditorSimpleClassContainer, EditorUiContext, EditorUiElement} from "./framework/core";
3-
import {EditorFormatMenu} from "./framework/blocks/format-menu";
4-
import {FormatPreviewButton} from "./framework/blocks/format-preview-button";
5-
import {EditorDropdownButton} from "./framework/blocks/dropdown-button";
6-
import {EditorColorPicker} from "./framework/blocks/color-picker";
7-
import {EditorTableCreator} from "./framework/blocks/table-creator";
8-
import {EditorColorButton} from "./framework/blocks/color-button";
9-
import {EditorOverflowContainer} from "./framework/blocks/overflow-container";
1+
import {EditorButton} from "../framework/buttons";
2+
import {EditorContainerUiElement, EditorSimpleClassContainer, EditorUiContext, EditorUiElement} from "../framework/core";
3+
import {EditorFormatMenu} from "../framework/blocks/format-menu";
4+
import {FormatPreviewButton} from "../framework/blocks/format-preview-button";
5+
import {EditorDropdownButton} from "../framework/blocks/dropdown-button";
6+
import {EditorColorPicker} from "../framework/blocks/color-picker";
7+
import {EditorTableCreator} from "../framework/blocks/table-creator";
8+
import {EditorColorButton} from "../framework/blocks/color-button";
9+
import {EditorOverflowContainer} from "../framework/blocks/overflow-container";
1010
import {
1111
cellProperties, clearTableFormatting,
1212
copyColumn,
@@ -29,8 +29,8 @@ import {
2929
rowProperties,
3030
splitCell,
3131
table, tableProperties
32-
} from "./defaults/buttons/tables";
33-
import {fullscreen, redo, source, undo} from "./defaults/buttons/controls";
32+
} from "./buttons/tables";
33+
import {about, fullscreen, redo, source, undo} from "./buttons/controls";
3434
import {
3535
blockquote, dangerCallout,
3636
h2,
@@ -41,7 +41,7 @@ import {
4141
paragraph,
4242
successCallout,
4343
warningCallout
44-
} from "./defaults/buttons/block-formats";
44+
} from "./buttons/block-formats";
4545
import {
4646
bold, clearFormating, code,
4747
highlightColor,
@@ -50,22 +50,22 @@ import {
5050
superscript,
5151
textColor,
5252
underline
53-
} from "./defaults/buttons/inline-formats";
53+
} from "./buttons/inline-formats";
5454
import {
5555
alignCenter,
5656
alignJustify,
5757
alignLeft,
5858
alignRight,
5959
directionLTR,
6060
directionRTL
61-
} from "./defaults/buttons/alignments";
61+
} from "./buttons/alignments";
6262
import {
6363
bulletList,
6464
indentDecrease,
6565
indentIncrease,
6666
numberList,
6767
taskList
68-
} from "./defaults/buttons/lists";
68+
} from "./buttons/lists";
6969
import {
7070
codeBlock,
7171
details, detailsEditLabel, detailsToggle, detailsUnwrap,
@@ -75,10 +75,10 @@ import {
7575
image,
7676
link, media,
7777
unlink
78-
} from "./defaults/buttons/objects";
79-
import {el} from "../utils/dom";
80-
import {EditorButtonWithMenu} from "./framework/blocks/button-with-menu";
81-
import {EditorSeparator} from "./framework/blocks/separator";
78+
} from "./buttons/objects";
79+
import {el} from "../../utils/dom";
80+
import {EditorButtonWithMenu} from "../framework/blocks/button-with-menu";
81+
import {EditorSeparator} from "../framework/blocks/separator";
8282

8383
export function getMainEditorFullToolbar(context: EditorUiContext): EditorContainerUiElement {
8484

@@ -201,6 +201,7 @@ export function getMainEditorFullToolbar(context: EditorUiContext): EditorContai
201201
// Meta elements
202202
new EditorOverflowContainer(3, [
203203
new EditorButton(source),
204+
new EditorButton(about),
204205
new EditorButton(fullscreen),
205206

206207
// Test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {EditorUiElement} from "../core";
2+
import {el} from "../../../utils/dom";
3+
4+
export class ExternalContent extends EditorUiElement {
5+
6+
/**
7+
* The URL for HTML to be loaded from.
8+
*/
9+
protected url: string = '';
10+
11+
constructor(url: string) {
12+
super();
13+
this.url = url;
14+
}
15+
16+
buildDOM(): HTMLElement {
17+
const wrapper = el('div', {
18+
class: 'editor-external-content',
19+
});
20+
21+
window.$http.get(this.url).then(resp => {
22+
if (typeof resp.data === 'string') {
23+
wrapper.innerHTML = resp.data;
24+
}
25+
});
26+
27+
return wrapper;
28+
}
29+
}

resources/js/wysiwyg/ui/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
getImageToolbarContent,
55
getLinkToolbarContent,
66
getMainEditorFullToolbar, getTableToolbarContent
7-
} from "./toolbars";
7+
} from "./defaults/toolbars";
88
import {EditorUIManager} from "./framework/manager";
99
import {EditorUiContext} from "./framework/core";
1010
import {CodeBlockDecorator} from "./decorators/code-block";

resources/sass/_editor.scss

+7
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,13 @@ body.editor-is-fullscreen {
350350
text-align: center;
351351
padding: 0.2em;
352352
}
353+
.editor-external-content {
354+
min-width: 500px;
355+
min-height: 500px;
356+
h4:first-child {
357+
margin-top: 0;
358+
}
359+
}
353360

354361
// In-editor elements
355362
.editor-image-wrap {
+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
@extends('layouts.plain')
2+
@section('document-class', 'bg-white ' . (setting()->getForCurrentUser('dark-mode-enabled') ? 'dark-mode ' : ''))
3+
4+
@section('content')
5+
<div class="p-m">
6+
7+
<h4 class="mt-s">{{ trans('editor.editor_license') }}</h4>
8+
<p>
9+
{!! trans('editor.editor_tiny_license', ['tinyLink' => '<a href="https://www.tiny.cloud/" target="_blank" rel="noopener noreferrer">TinyMCE</a>']) !!}
10+
<br>
11+
<a href="{{ url('/libs/tinymce/license.txt') }}" target="_blank">{{ trans('editor.editor_tiny_license_link') }}</a>
12+
</p>
13+
14+
<h4>{{ trans('editor.shortcuts') }}</h4>
15+
16+
<p>{{ trans('editor.shortcuts_intro') }}</p>
17+
<table>
18+
<thead>
19+
<tr>
20+
<th>{{ trans('editor.shortcut') }} {{ trans('editor.windows_linux') }}</th>
21+
<th>{{ trans('editor.shortcut') }} {{ trans('editor.mac') }}</th>
22+
<th>{{ trans('editor.description') }}</th>
23+
</tr>
24+
</thead>
25+
<tbody>
26+
<tr>
27+
<td><code>Ctrl</code>+<code>S</code></td>
28+
<td><code>Cmd</code>+<code>S</code></td>
29+
<td>{{ trans('entities.pages_edit_save_draft') }}</td>
30+
</tr>
31+
<tr>
32+
<td><code>Ctrl</code>+<code>Enter</code></td>
33+
<td><code>Cmd</code>+<code>Enter</code></td>
34+
<td>{{ trans('editor.save_continue') }}</td>
35+
</tr>
36+
<tr>
37+
<td><code>Ctrl</code>+<code>B</code></td>
38+
<td><code>Cmd</code>+<code>B</code></td>
39+
<td>{{ trans('editor.bold') }}</td>
40+
</tr>
41+
<tr>
42+
<td><code>Ctrl</code>+<code>I</code></td>
43+
<td><code>Cmd</code>+<code>I</code></td>
44+
<td>{{ trans('editor.italic') }}</td>
45+
</tr>
46+
<tr>
47+
<td>
48+
<code>Ctrl</code>+<code>1</code><br>
49+
<code>Ctrl</code>+<code>2</code><br>
50+
<code>Ctrl</code>+<code>3</code><br>
51+
<code>Ctrl</code>+<code>4</code>
52+
</td>
53+
<td>
54+
<code>Cmd</code>+<code>1</code><br>
55+
<code>Cmd</code>+<code>2</code><br>
56+
<code>Cmd</code>+<code>3</code><br>
57+
<code>Cmd</code>+<code>4</code>
58+
</td>
59+
<td>
60+
{{ trans('editor.header_large') }} <br>
61+
{{ trans('editor.header_medium') }} <br>
62+
{{ trans('editor.header_small') }} <br>
63+
{{ trans('editor.header_tiny') }}
64+
</td>
65+
</tr>
66+
<tr>
67+
<td>
68+
<code>Ctrl</code>+<code>5</code><br>
69+
<code>Ctrl</code>+<code>D</code>
70+
</td>
71+
<td>
72+
<code>Cmd</code>+<code>5</code><br>
73+
<code>Cmd</code>+<code>D</code>
74+
</td>
75+
<td>{{ trans('editor.paragraph') }}</td>
76+
</tr>
77+
<tr>
78+
<td>
79+
<code>Ctrl</code>+<code>6</code><br>
80+
<code>Ctrl</code>+<code>Q</code>
81+
</td>
82+
<td>
83+
<code>Cmd</code>+<code>6</code><br>
84+
<code>Cmd</code>+<code>Q</code>
85+
</td>
86+
<td>{{ trans('editor.blockquote') }}</td>
87+
</tr>
88+
<tr>
89+
<td>
90+
<code>Ctrl</code>+<code>7</code><br>
91+
<code>Ctrl</code>+<code>E</code>
92+
</td>
93+
<td>
94+
<code>Cmd</code>+<code>7</code><br>
95+
<code>Cmd</code>+<code>E</code>
96+
</td>
97+
<td>{{ trans('editor.insert_code_block') }}</td>
98+
</tr>
99+
<tr>
100+
<td>
101+
<code>Ctrl</code>+<code>8</code><br>
102+
<code>Ctrl</code>+<code>Shift</code>+<code>E</code>
103+
</td>
104+
<td>
105+
<code>Cmd</code>+<code>8</code><br>
106+
<code>Cmd</code>+<code>Shift</code>+<code>E</code>
107+
</td>
108+
<td>{{ trans('editor.inline_code') }}</td>
109+
</tr>
110+
<tr>
111+
<td><code>Ctrl</code>+<code>9</code></td>
112+
<td><code>Cmd</code>+<code>9</code></td>
113+
<td>
114+
{{ trans('editor.callouts') }} <br>
115+
<small>{{ trans('editor.callouts_cycle') }}</small>
116+
</td>
117+
</tr>
118+
<tr>
119+
<td>
120+
<code>Ctrl</code>+<code>O</code> <br>
121+
<code>Ctrl</code>+<code>P</code>
122+
</td>
123+
<td>
124+
<code>Cmd</code>+<code>O</code> <br>
125+
<code>Cmd</code>+<code>P</code>
126+
</td>
127+
<td>
128+
{{ trans('editor.list_numbered') }} <br>
129+
{{ trans('editor.list_bullet') }}
130+
</td>
131+
</tr>
132+
<tr>
133+
<td>
134+
<code>Ctrl</code>+<code>Shift</code>+<code>K</code>
135+
</td>
136+
<td>
137+
<code>Cmd</code>+<code>Shift</code>+<code>K</code>
138+
</td>
139+
<td>{{ trans('editor.link_selector') }}</td>
140+
</tr>
141+
</tbody>
142+
</table>
143+
144+
</div>
145+
@endsection
146+

0 commit comments

Comments
 (0)