@exmg/exm-wysiwyg-editor 1.1.16
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.
- package/LICENSE +21 -0
- package/README.md +25 -0
- package/dist/actions/anchor/action.d.ts +9 -0
- package/dist/actions/anchor/action.js +108 -0
- package/dist/actions/anchor/dialog/exm-wysiwyg-toolbar-dialog-css.d.ts +1 -0
- package/dist/actions/anchor/dialog/exm-wysiwyg-toolbar-dialog-css.js +53 -0
- package/dist/actions/anchor/dialog/exm-wysiwyg-toolbar-link-dialog.d.ts +21 -0
- package/dist/actions/anchor/dialog/exm-wysiwyg-toolbar-link-dialog.js +124 -0
- package/dist/actions/anchor/options.d.ts +9 -0
- package/dist/actions/anchor/options.js +30 -0
- package/dist/actions/anchor/types.d.ts +13 -0
- package/dist/actions/anchor/types.js +2 -0
- package/dist/actions/block.d.ts +19 -0
- package/dist/actions/block.js +25 -0
- package/dist/actions/fullScreen.d.ts +8 -0
- package/dist/actions/fullScreen.js +21 -0
- package/dist/actions/heading.d.ts +19 -0
- package/dist/actions/heading.js +25 -0
- package/dist/actions/lists.d.ts +13 -0
- package/dist/actions/lists.js +17 -0
- package/dist/actions/text.d.ts +25 -0
- package/dist/actions/text.js +33 -0
- package/dist/exm-wysiwyg-editor-base.d.ts +38 -0
- package/dist/exm-wysiwyg-editor-base.js +199 -0
- package/dist/exm-wysiwyg-editor-toolbar-base.d.ts +18 -0
- package/dist/exm-wysiwyg-editor-toolbar-base.js +75 -0
- package/dist/exm-wysiwyg-editor-toolbar.d.ts +9 -0
- package/dist/exm-wysiwyg-editor-toolbar.js +12 -0
- package/dist/exm-wysiwyg-editor.d.ts +18 -0
- package/dist/exm-wysiwyg-editor.js +21 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/styles/exm-wysiwyg-editor-css.d.ts +1 -0
- package/dist/styles/exm-wysiwyg-editor-css.js +142 -0
- package/dist/styles/exm-wysiwyg-editor-toolbar-css.d.ts +1 -0
- package/dist/styles/exm-wysiwyg-editor-toolbar-css.js +43 -0
- package/dist/toolbarActions.d.ts +4 -0
- package/dist/toolbarActions.js +39 -0
- package/dist/types.d.ts +44 -0
- package/dist/types.js +17 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +2 -0
- package/package.json +67 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/core';
|
|
2
|
+
import { ExmgElement } from '@exmg/lit-base';
|
|
3
|
+
import { EditorActions } from './types.js';
|
|
4
|
+
import './exm-wysiwyg-editor-toolbar.js';
|
|
5
|
+
import { WysiwygEditorToolbar } from './exm-wysiwyg-editor-toolbar.js';
|
|
6
|
+
/**
|
|
7
|
+
* # Events:
|
|
8
|
+
* - change - where detail is current html value
|
|
9
|
+
* - blur - on editor blur
|
|
10
|
+
* - focus - on editor focus
|
|
11
|
+
*
|
|
12
|
+
* @customElement
|
|
13
|
+
* @element exm-markdown-editor
|
|
14
|
+
* @memberof Exmg
|
|
15
|
+
* @extends ExmgElement
|
|
16
|
+
* @summary Markdown editor element
|
|
17
|
+
*/
|
|
18
|
+
export declare class WysiwygEditorElementBase extends ExmgElement {
|
|
19
|
+
value: string;
|
|
20
|
+
label: string;
|
|
21
|
+
upload: boolean;
|
|
22
|
+
editorActions: EditorActions[];
|
|
23
|
+
required: boolean;
|
|
24
|
+
disabled: boolean;
|
|
25
|
+
supportingText: string;
|
|
26
|
+
editorElement?: HTMLDivElement;
|
|
27
|
+
toolbar?: WysiwygEditorToolbar;
|
|
28
|
+
editor?: Editor;
|
|
29
|
+
reset(): void;
|
|
30
|
+
protected firstUpdated(): void;
|
|
31
|
+
private createExtensionList;
|
|
32
|
+
editorSetup(): void;
|
|
33
|
+
private handleEditorUpdate;
|
|
34
|
+
private handleEditorTransaction;
|
|
35
|
+
private handleBlur;
|
|
36
|
+
private handleFocus;
|
|
37
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, nothing } from 'lit';
|
|
3
|
+
import { Editor } from '@tiptap/core';
|
|
4
|
+
import Document from '@tiptap/extension-document';
|
|
5
|
+
import Paragraph from '@tiptap/extension-paragraph';
|
|
6
|
+
import Text from '@tiptap/extension-text';
|
|
7
|
+
import Bold from '@tiptap/extension-bold';
|
|
8
|
+
import Italic from '@tiptap/extension-italic';
|
|
9
|
+
import Heading from '@tiptap/extension-heading';
|
|
10
|
+
import OrderedList from '@tiptap/extension-ordered-list';
|
|
11
|
+
import UnOrderedList from '@tiptap/extension-bullet-list';
|
|
12
|
+
import ListItem from '@tiptap/extension-list-item';
|
|
13
|
+
import Strike from '@tiptap/extension-strike';
|
|
14
|
+
import Underline from '@tiptap/extension-underline';
|
|
15
|
+
import Blockquote from '@tiptap/extension-blockquote';
|
|
16
|
+
import Link from '@tiptap/extension-link';
|
|
17
|
+
import { query, property, state } from 'lit/decorators.js';
|
|
18
|
+
import { ExmgElement } from '@exmg/lit-base';
|
|
19
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
20
|
+
import { EditorActions } from './types.js';
|
|
21
|
+
import './exm-wysiwyg-editor-toolbar.js';
|
|
22
|
+
import { linkOptions } from './actions/anchor/options.js';
|
|
23
|
+
import { defaultActionList } from './toolbarActions.js';
|
|
24
|
+
/**
|
|
25
|
+
* # Events:
|
|
26
|
+
* - change - where detail is current html value
|
|
27
|
+
* - blur - on editor blur
|
|
28
|
+
* - focus - on editor focus
|
|
29
|
+
*
|
|
30
|
+
* @customElement
|
|
31
|
+
* @element exm-markdown-editor
|
|
32
|
+
* @memberof Exmg
|
|
33
|
+
* @extends ExmgElement
|
|
34
|
+
* @summary Markdown editor element
|
|
35
|
+
*/
|
|
36
|
+
export class WysiwygEditorElementBase extends ExmgElement {
|
|
37
|
+
constructor() {
|
|
38
|
+
super(...arguments);
|
|
39
|
+
this.value = '';
|
|
40
|
+
this.label = '';
|
|
41
|
+
this.upload = false;
|
|
42
|
+
this.editorActions = defaultActionList;
|
|
43
|
+
this.required = false;
|
|
44
|
+
this.disabled = false;
|
|
45
|
+
this.supportingText = '';
|
|
46
|
+
}
|
|
47
|
+
reset() {
|
|
48
|
+
var _a;
|
|
49
|
+
this.value = (_a = this.getAttribute('value')) !== null && _a !== void 0 ? _a : '';
|
|
50
|
+
}
|
|
51
|
+
firstUpdated() {
|
|
52
|
+
if (!this.disabled) {
|
|
53
|
+
this.editorSetup();
|
|
54
|
+
}
|
|
55
|
+
if (this.label && this.required) {
|
|
56
|
+
this.setAttribute('aria-required', 'true');
|
|
57
|
+
this.label += ' *';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
createExtensionList() {
|
|
61
|
+
const headingList = [];
|
|
62
|
+
let hasList = false;
|
|
63
|
+
const extensions = [];
|
|
64
|
+
for (const action of this.editorActions) {
|
|
65
|
+
switch (action) {
|
|
66
|
+
case EditorActions.Anchor:
|
|
67
|
+
extensions.push(Link.configure(linkOptions));
|
|
68
|
+
break;
|
|
69
|
+
case EditorActions.Bold:
|
|
70
|
+
extensions.push(Bold);
|
|
71
|
+
break;
|
|
72
|
+
case EditorActions.Italic:
|
|
73
|
+
extensions.push(Italic);
|
|
74
|
+
break;
|
|
75
|
+
case EditorActions.Blockquote:
|
|
76
|
+
extensions.push(Blockquote);
|
|
77
|
+
break;
|
|
78
|
+
case EditorActions.Strike:
|
|
79
|
+
extensions.push(Strike);
|
|
80
|
+
break;
|
|
81
|
+
case EditorActions.Underline:
|
|
82
|
+
extensions.push(Underline);
|
|
83
|
+
break;
|
|
84
|
+
case EditorActions.OrderedList:
|
|
85
|
+
extensions.push(OrderedList);
|
|
86
|
+
hasList = true;
|
|
87
|
+
break;
|
|
88
|
+
case EditorActions.UnOrderedList:
|
|
89
|
+
extensions.push(UnOrderedList);
|
|
90
|
+
hasList = true;
|
|
91
|
+
break;
|
|
92
|
+
case EditorActions.Heading_1:
|
|
93
|
+
headingList.push(1);
|
|
94
|
+
break;
|
|
95
|
+
case EditorActions.Heading_2:
|
|
96
|
+
headingList.push(2);
|
|
97
|
+
break;
|
|
98
|
+
case EditorActions.Heading_3:
|
|
99
|
+
headingList.push(3);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (hasList) {
|
|
104
|
+
extensions.push(ListItem);
|
|
105
|
+
}
|
|
106
|
+
if (headingList.length > 0) {
|
|
107
|
+
extensions.push(Heading.configure({
|
|
108
|
+
levels: headingList,
|
|
109
|
+
HTMLAttributes: {},
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
return extensions;
|
|
113
|
+
}
|
|
114
|
+
editorSetup() {
|
|
115
|
+
if (!this.editorElement) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
this.editor = new Editor({
|
|
119
|
+
element: this.editorElement,
|
|
120
|
+
extensions: [Document, Paragraph, Text, ...this.createExtensionList()],
|
|
121
|
+
content: this.value,
|
|
122
|
+
autofocus: true,
|
|
123
|
+
editable: !this.disabled,
|
|
124
|
+
injectCSS: false,
|
|
125
|
+
onUpdate: this.handleEditorUpdate.bind(this),
|
|
126
|
+
onTransaction: this.handleEditorTransaction.bind(this),
|
|
127
|
+
onBlur: this.handleBlur.bind(this),
|
|
128
|
+
onFocus: this.handleFocus.bind(this),
|
|
129
|
+
});
|
|
130
|
+
this.editor;
|
|
131
|
+
}
|
|
132
|
+
handleEditorUpdate({ editor }) {
|
|
133
|
+
this.value = editor.getHTML();
|
|
134
|
+
this.fire('change', this.value);
|
|
135
|
+
}
|
|
136
|
+
handleEditorTransaction() {
|
|
137
|
+
var _a;
|
|
138
|
+
(_a = this.toolbar) === null || _a === void 0 ? void 0 : _a.requestUpdate();
|
|
139
|
+
}
|
|
140
|
+
handleBlur() {
|
|
141
|
+
this.fire('blur');
|
|
142
|
+
}
|
|
143
|
+
handleFocus() {
|
|
144
|
+
this.fire('focus');
|
|
145
|
+
}
|
|
146
|
+
render() {
|
|
147
|
+
const containerClasses = {
|
|
148
|
+
'has-label': !!this.label,
|
|
149
|
+
'has-editor': !!this.editor,
|
|
150
|
+
};
|
|
151
|
+
const labelClasses = { 'not-empty': !!this.value };
|
|
152
|
+
return html `
|
|
153
|
+
<div id="wysiwygEditorContainer" class="container ${classMap(containerClasses)}">
|
|
154
|
+
<div class="background"></div>
|
|
155
|
+
<div class="state-layer"></div>
|
|
156
|
+
${this.label
|
|
157
|
+
? html `<label class="${classMap(labelClasses)}" for="wysiwygEditorContainer">${this.label}</label>`
|
|
158
|
+
: nothing}
|
|
159
|
+
<exm-wysiwyg-editor-toolbar
|
|
160
|
+
.editor=${this.editor}
|
|
161
|
+
.editorActions=${this.editorActions}
|
|
162
|
+
></exm-wysiwyg-editor-toolbar>
|
|
163
|
+
<div class="editor" id="editor"></div>
|
|
164
|
+
${this.supportingText ? html `<div class="supporting-text">${this.supportingText}</div>` : nothing}
|
|
165
|
+
</div>
|
|
166
|
+
`;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
__decorate([
|
|
170
|
+
property({ type: String })
|
|
171
|
+
], WysiwygEditorElementBase.prototype, "value", void 0);
|
|
172
|
+
__decorate([
|
|
173
|
+
property({ type: String })
|
|
174
|
+
], WysiwygEditorElementBase.prototype, "label", void 0);
|
|
175
|
+
__decorate([
|
|
176
|
+
property({ type: Boolean })
|
|
177
|
+
], WysiwygEditorElementBase.prototype, "upload", void 0);
|
|
178
|
+
__decorate([
|
|
179
|
+
property({ type: Array })
|
|
180
|
+
], WysiwygEditorElementBase.prototype, "editorActions", void 0);
|
|
181
|
+
__decorate([
|
|
182
|
+
property({ type: Boolean, reflect: true })
|
|
183
|
+
], WysiwygEditorElementBase.prototype, "required", void 0);
|
|
184
|
+
__decorate([
|
|
185
|
+
property({ type: Boolean, reflect: true })
|
|
186
|
+
], WysiwygEditorElementBase.prototype, "disabled", void 0);
|
|
187
|
+
__decorate([
|
|
188
|
+
property({ type: String, attribute: 'supporting-text' })
|
|
189
|
+
], WysiwygEditorElementBase.prototype, "supportingText", void 0);
|
|
190
|
+
__decorate([
|
|
191
|
+
query('#editor')
|
|
192
|
+
], WysiwygEditorElementBase.prototype, "editorElement", void 0);
|
|
193
|
+
__decorate([
|
|
194
|
+
query('exm-wysiwyg-editor-toolbar')
|
|
195
|
+
], WysiwygEditorElementBase.prototype, "toolbar", void 0);
|
|
196
|
+
__decorate([
|
|
197
|
+
state()
|
|
198
|
+
], WysiwygEditorElementBase.prototype, "editor", void 0);
|
|
199
|
+
//# sourceMappingURL=exm-wysiwyg-editor-base.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { nothing } from 'lit';
|
|
2
|
+
import { ExmgElement } from '@exmg/lit-base/index.js';
|
|
3
|
+
import '@material/web/iconbutton/icon-button.js';
|
|
4
|
+
import '@material/web/icon/icon.js';
|
|
5
|
+
import { EditorActionList } from './toolbarActions.js';
|
|
6
|
+
import { Editor } from '@tiptap/core';
|
|
7
|
+
import { EditorButtonActions, EditorSeparator } from './types.js';
|
|
8
|
+
export declare class WysiwygEditorToolbarBase extends ExmgElement {
|
|
9
|
+
upload: boolean;
|
|
10
|
+
editor?: Editor;
|
|
11
|
+
actions: EditorActionList;
|
|
12
|
+
editorActions: (EditorButtonActions | EditorSeparator)[];
|
|
13
|
+
private handleSelectionUpdate;
|
|
14
|
+
protected firstUpdated(): void;
|
|
15
|
+
disconnectedCallback(): void;
|
|
16
|
+
renderActionButtons(): typeof nothing | import("lit-html").TemplateResult<1>[];
|
|
17
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, nothing } from 'lit';
|
|
3
|
+
import { ExmgElement } from '@exmg/lit-base/index.js';
|
|
4
|
+
import { property } from 'lit/decorators.js';
|
|
5
|
+
import '@material/web/iconbutton/icon-button.js';
|
|
6
|
+
import '@material/web/icon/icon.js';
|
|
7
|
+
import { toolbarActions } from './toolbarActions.js';
|
|
8
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
9
|
+
import { EditorActions } from './types.js';
|
|
10
|
+
export class WysiwygEditorToolbarBase extends ExmgElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.upload = false;
|
|
14
|
+
this.actions = toolbarActions;
|
|
15
|
+
this.editorActions = [];
|
|
16
|
+
}
|
|
17
|
+
handleSelectionUpdate() {
|
|
18
|
+
this.requestUpdate();
|
|
19
|
+
}
|
|
20
|
+
firstUpdated() {
|
|
21
|
+
var _a;
|
|
22
|
+
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.on('selectionUpdate', this.handleSelectionUpdate);
|
|
23
|
+
document.addEventListener('fullscreenchange', () => this.requestUpdate());
|
|
24
|
+
}
|
|
25
|
+
disconnectedCallback() {
|
|
26
|
+
var _a;
|
|
27
|
+
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.off('selectionUpdate', this.handleSelectionUpdate);
|
|
28
|
+
document.removeEventListener('fullscreenchange', () => this.requestUpdate());
|
|
29
|
+
super.disconnectedCallback();
|
|
30
|
+
}
|
|
31
|
+
renderActionButtons() {
|
|
32
|
+
if (!this.editor) {
|
|
33
|
+
return nothing;
|
|
34
|
+
}
|
|
35
|
+
const buttons = this.editorActions.map((action) => {
|
|
36
|
+
if (action === EditorActions.Separator) {
|
|
37
|
+
return html `<span class="separator"></span>`;
|
|
38
|
+
}
|
|
39
|
+
const editorAction = this.actions[action];
|
|
40
|
+
const classNames = { 'is-active': editorAction.isActive(this.editor) };
|
|
41
|
+
const icon = !Array.isArray(editorAction.icon)
|
|
42
|
+
? editorAction.icon
|
|
43
|
+
: editorAction.isActive(this.editor)
|
|
44
|
+
? editorAction.icon[1]
|
|
45
|
+
: editorAction.icon[0];
|
|
46
|
+
return html ` <md-icon-button
|
|
47
|
+
aria-label=${editorAction.title}
|
|
48
|
+
title=${editorAction.title}
|
|
49
|
+
@click=${(event) => editorAction.action(this.editor, {
|
|
50
|
+
event,
|
|
51
|
+
})}
|
|
52
|
+
class="${classMap(classNames)}"
|
|
53
|
+
>
|
|
54
|
+
<md-icon>${icon}</md-icon>
|
|
55
|
+
</md-icon-button>`;
|
|
56
|
+
});
|
|
57
|
+
return buttons;
|
|
58
|
+
}
|
|
59
|
+
render() {
|
|
60
|
+
return html `<section class="toolbar-container">${this.renderActionButtons()}</section>`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
__decorate([
|
|
64
|
+
property({ type: Boolean })
|
|
65
|
+
], WysiwygEditorToolbarBase.prototype, "upload", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
property({ type: Object })
|
|
68
|
+
], WysiwygEditorToolbarBase.prototype, "editor", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
property({ type: Object })
|
|
71
|
+
], WysiwygEditorToolbarBase.prototype, "actions", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
property({ type: Array })
|
|
74
|
+
], WysiwygEditorToolbarBase.prototype, "editorActions", void 0);
|
|
75
|
+
//# sourceMappingURL=exm-wysiwyg-editor-toolbar-base.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WysiwygEditorToolbarBase } from './exm-wysiwyg-editor-toolbar-base.js';
|
|
2
|
+
export declare class WysiwygEditorToolbar extends WysiwygEditorToolbarBase {
|
|
3
|
+
static styles: import("lit").CSSResult[];
|
|
4
|
+
}
|
|
5
|
+
declare global {
|
|
6
|
+
interface HTMLElementTagNameMap {
|
|
7
|
+
'exm-wysiwyg-editor-toolbar': WysiwygEditorToolbar;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { customElement } from 'lit/decorators.js';
|
|
3
|
+
import { WysiwygEditorToolbarBase } from './exm-wysiwyg-editor-toolbar-base.js';
|
|
4
|
+
import { style as toolbarStyles } from './styles/exm-wysiwyg-editor-toolbar-css.js';
|
|
5
|
+
let WysiwygEditorToolbar = class WysiwygEditorToolbar extends WysiwygEditorToolbarBase {
|
|
6
|
+
};
|
|
7
|
+
WysiwygEditorToolbar.styles = [toolbarStyles];
|
|
8
|
+
WysiwygEditorToolbar = __decorate([
|
|
9
|
+
customElement('exm-wysiwyg-editor-toolbar')
|
|
10
|
+
], WysiwygEditorToolbar);
|
|
11
|
+
export { WysiwygEditorToolbar };
|
|
12
|
+
//# sourceMappingURL=exm-wysiwyg-editor-toolbar.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { WysiwygEditorElementBase } from './exm-wysiwyg-editor-base.js';
|
|
2
|
+
/**
|
|
3
|
+
* @customElement
|
|
4
|
+
* @group Exmg Core Elements
|
|
5
|
+
* @element exm-wysiwyg-editor
|
|
6
|
+
* @demo demo/index.html
|
|
7
|
+
* @memberof Exmg
|
|
8
|
+
* @extends ExmgElement
|
|
9
|
+
* @summary Wysiwyg editor element
|
|
10
|
+
*/
|
|
11
|
+
export declare class WysiwygEditorElement extends WysiwygEditorElementBase {
|
|
12
|
+
static styles: import("lit").CSSResult[];
|
|
13
|
+
}
|
|
14
|
+
declare global {
|
|
15
|
+
interface HTMLElementTagNameMap {
|
|
16
|
+
'exm-wysiwyg-editor': WysiwygEditorElement;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { customElement } from 'lit/decorators.js';
|
|
3
|
+
import { WysiwygEditorElementBase } from './exm-wysiwyg-editor-base.js';
|
|
4
|
+
import { style as wysiwygEditorStyles } from './styles/exm-wysiwyg-editor-css.js';
|
|
5
|
+
/**
|
|
6
|
+
* @customElement
|
|
7
|
+
* @group Exmg Core Elements
|
|
8
|
+
* @element exm-wysiwyg-editor
|
|
9
|
+
* @demo demo/index.html
|
|
10
|
+
* @memberof Exmg
|
|
11
|
+
* @extends ExmgElement
|
|
12
|
+
* @summary Wysiwyg editor element
|
|
13
|
+
*/
|
|
14
|
+
let WysiwygEditorElement = class WysiwygEditorElement extends WysiwygEditorElementBase {
|
|
15
|
+
};
|
|
16
|
+
WysiwygEditorElement.styles = [wysiwygEditorStyles];
|
|
17
|
+
WysiwygEditorElement = __decorate([
|
|
18
|
+
customElement('exm-wysiwyg-editor')
|
|
19
|
+
], WysiwygEditorElement);
|
|
20
|
+
export { WysiwygEditorElement };
|
|
21
|
+
//# sourceMappingURL=exm-wysiwyg-editor.js.map
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const style: import("lit").CSSResult;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const style = css `
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
--editor-border-color: var(--exm-markdown-editor-border-color, var(--md-sys-color-on-surface-variant));
|
|
7
|
+
--editor-border-color-focus: var(--exm-markdown-editor-border-color-focus, var(--md-sys-color-primary));
|
|
8
|
+
--editor-background-color: var(
|
|
9
|
+
--exm-markdown-editor-background-color,
|
|
10
|
+
var(--md-sys-color-surface-container-highest)
|
|
11
|
+
);
|
|
12
|
+
--editor-code-background-color: var(
|
|
13
|
+
--exm-markdown-editor-code-background-color,
|
|
14
|
+
var(--md-sys-color-surface-container-highest)
|
|
15
|
+
);
|
|
16
|
+
--editor-background-focus-color: var(--exm-markdown-editor-background-focus-color, var(--md-sys-color-on-surface));
|
|
17
|
+
--editor-code-background-focus-color: var(
|
|
18
|
+
--exm-markdown-editor-code-background-focus-color,
|
|
19
|
+
var(--md-sys-color-on-surface)
|
|
20
|
+
);
|
|
21
|
+
--editor-label-focus-color: var(--exm-markdown-editor-label-focus-color, var(--md-sys-color-primary));
|
|
22
|
+
--editor-label-color: var(--exm-markdown-editor-label-color, var(--md-sys-color-on-surface));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.container {
|
|
26
|
+
--label-height: 0px;
|
|
27
|
+
|
|
28
|
+
display: grid;
|
|
29
|
+
position: relative;
|
|
30
|
+
grid-template-columns: 100%;
|
|
31
|
+
grid-template-rows: var(--label-height) auto 1fr auto;
|
|
32
|
+
transition: grid-template-rows 0.2s ease;
|
|
33
|
+
border-top-right-radius: 4px;
|
|
34
|
+
border-top-left-radius: 4px;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
height: 100%;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.container.has-label {
|
|
40
|
+
--label-height: 2rem;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.container.preview-mode exm-markdown-editor-toolbar {
|
|
44
|
+
display: none;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.editor {
|
|
48
|
+
grid-area: 3/1/4/2;
|
|
49
|
+
position: relative;
|
|
50
|
+
overflow: scroll;
|
|
51
|
+
padding-inline: 1rem;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.editor > div {
|
|
55
|
+
outline: none;
|
|
56
|
+
min-height: 100%;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.editor a {
|
|
60
|
+
color: var(--md-sys-color-primary);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
exm-wysiwyg-editor-toolbar {
|
|
64
|
+
grid-area: 2/1/3/2;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.background,
|
|
68
|
+
.state-layer {
|
|
69
|
+
grid-area: 1/1/4/3;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.background {
|
|
73
|
+
background-color: var(--editor-code-background-color, var(--md-sys-color-surface-container-highest));
|
|
74
|
+
border-bottom: 1px solid var(--editor-border-color-focus, var(--md-sys-color-primary));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.container:hover .state-layer {
|
|
78
|
+
background-color: var(--editor-code-background-focus-color, var(--md-sys-color-on-surface-variant));
|
|
79
|
+
opacity: 0.08;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.background::after {
|
|
83
|
+
content: ' ';
|
|
84
|
+
display: block;
|
|
85
|
+
position: absolute;
|
|
86
|
+
bottom: 0;
|
|
87
|
+
width: 100%;
|
|
88
|
+
height: 3px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* The form label style */
|
|
92
|
+
label {
|
|
93
|
+
grid-area: 1/1/2/3;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
label[for='wysiwygEditorContainer'],
|
|
97
|
+
label[for='wysiwygEditorContainer'].not-empty.preview-mode {
|
|
98
|
+
padding: 0.5rem 0 0 1rem;
|
|
99
|
+
font-size: 0.7rem;
|
|
100
|
+
color: var(--editor-label-focus-color, var(--md-sys-color-primary));
|
|
101
|
+
transition: all 200ms ease;
|
|
102
|
+
transform: scale(1) translateY(0px);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
label[for='wysiwygEditorContainer'].not-empty.preview-mode {
|
|
106
|
+
color: var(--editor-label-color, var(--md-sys-color-on-surface));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
label[for='wysiwygEditorContainer'].preview-mode {
|
|
110
|
+
color: var(--editor-label-color, var(--md-sys-color-on-surface));
|
|
111
|
+
padding-bottom: 1rem;
|
|
112
|
+
transform: translateY(8px);
|
|
113
|
+
font-size: 1rem;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* Supporting text, also know as Description */
|
|
117
|
+
.supporting-text {
|
|
118
|
+
grid-area: 4/1/5/3;
|
|
119
|
+
|
|
120
|
+
color: var(--md-filled-field-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));
|
|
121
|
+
display: flex;
|
|
122
|
+
font-family: var(
|
|
123
|
+
--md-filled-field-supporting-text-font,
|
|
124
|
+
var(--md-sys-typescale-body-small-font, var(--md-ref-typeface-plain, Roboto))
|
|
125
|
+
);
|
|
126
|
+
font-size: var(--md-filled-field-supporting-text-size, var(--md-sys-typescale-body-small-size, 0.75rem));
|
|
127
|
+
line-height: var(
|
|
128
|
+
--md-filled-field-supporting-text-line-height,
|
|
129
|
+
var(--md-sys-typescale-body-small-line-height, 1rem)
|
|
130
|
+
);
|
|
131
|
+
font-weight: var(
|
|
132
|
+
--md-filled-field-supporting-text-weight,
|
|
133
|
+
var(--md-sys-typescale-body-small-weight, var(--md-ref-typeface-weight-regular, 400))
|
|
134
|
+
);
|
|
135
|
+
gap: 16px;
|
|
136
|
+
justify-content: space-between;
|
|
137
|
+
padding-inline-start: var(--md-filled-field-supporting-text-leading-space, 16px);
|
|
138
|
+
padding-inline-end: var(--md-filled-field-supporting-text-trailing-space, 16px);
|
|
139
|
+
padding-top: var(--md-filled-field-supporting-text-top-space, 4px);
|
|
140
|
+
}
|
|
141
|
+
`;
|
|
142
|
+
//# sourceMappingURL=exm-wysiwyg-editor-css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const style: import("lit").CSSResult;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const style = css `
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
border-bottom: 1px solid var(--md-sys-color-surface-variant);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.toolbar-container {
|
|
9
|
+
padding: 0.5rem 1rem;
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-wrap: wrap;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.separator {
|
|
15
|
+
display: inline-block;
|
|
16
|
+
width: 1px;
|
|
17
|
+
margin-inline: 0.5rem;
|
|
18
|
+
background-color: var(--md-sys-color-surface-variant);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
md-icon-button {
|
|
22
|
+
--md-icon-button-state-layer-shape: 0.25rem;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
md-icon-button.is-active {
|
|
26
|
+
--md-icon-button-icon-color: var(--md-sys-color-on-primary);
|
|
27
|
+
--md-icon-button-hover-icon-color: var(--md-sys-color-on-primary);
|
|
28
|
+
--md-icon-button-active-icon-color: var(--md-sys-color-on-primary);
|
|
29
|
+
--md-icon-button-focus-icon-color: var(--md-sys-color-on-primary);
|
|
30
|
+
|
|
31
|
+
border-radius: var(--md-icon-button-state-layer-shape);
|
|
32
|
+
background-color: var(--md-sys-color-primary);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
md-icon-button:not(:first) {
|
|
36
|
+
margin: 0 0.3rem;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
md-icon-button:first {
|
|
40
|
+
margin: 0 0;
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
//# sourceMappingURL=exm-wysiwyg-editor-toolbar-css.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { heading1, heading2, heading3 } from './actions/heading.js';
|
|
2
|
+
import { bold, italic, strike, underline } from './actions/text.js';
|
|
3
|
+
import { anchor } from './actions/anchor/action.js';
|
|
4
|
+
import { EditorActions } from './types.js';
|
|
5
|
+
import { blockquote, orderedList, unorderedList } from './actions/block.js';
|
|
6
|
+
import { fullscreen } from './actions/fullScreen.js';
|
|
7
|
+
export const toolbarActions = {
|
|
8
|
+
heading1,
|
|
9
|
+
heading2,
|
|
10
|
+
heading3,
|
|
11
|
+
bold,
|
|
12
|
+
italic,
|
|
13
|
+
strike,
|
|
14
|
+
underline,
|
|
15
|
+
anchor,
|
|
16
|
+
blockquote,
|
|
17
|
+
ordered_list: orderedList,
|
|
18
|
+
unordered_list: unorderedList,
|
|
19
|
+
fullscreen,
|
|
20
|
+
};
|
|
21
|
+
export const defaultActionList = [
|
|
22
|
+
EditorActions.Heading_1,
|
|
23
|
+
EditorActions.Heading_2,
|
|
24
|
+
EditorActions.Heading_3,
|
|
25
|
+
EditorActions.Separator,
|
|
26
|
+
EditorActions.Bold,
|
|
27
|
+
EditorActions.Italic,
|
|
28
|
+
EditorActions.Strike,
|
|
29
|
+
EditorActions.Underline,
|
|
30
|
+
EditorActions.Separator,
|
|
31
|
+
EditorActions.Anchor,
|
|
32
|
+
EditorActions.Separator,
|
|
33
|
+
EditorActions.Blockquote,
|
|
34
|
+
EditorActions.OrderedList,
|
|
35
|
+
EditorActions.UnOrderedList,
|
|
36
|
+
EditorActions.Separator,
|
|
37
|
+
EditorActions.FullScreen,
|
|
38
|
+
];
|
|
39
|
+
//# sourceMappingURL=toolbarActions.js.map
|