@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Ex Machina
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
# Markdown editor element.
|
|
3
|
+
### An out of the box customizable Markdown Editor for Exmachina
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
<exm-markdown-editor markdown="# Header 1"></exm-markdown-editor>
|
|
7
|
+
```
|
|
8
|
+
## Styling
|
|
9
|
+
|
|
10
|
+
Custom property | Description | Default
|
|
11
|
+
----------------|-------------|----------
|
|
12
|
+
`--exm-markdown-editor-code-color` | Editor's text color | --md-sys-color-on-surface
|
|
13
|
+
`--exm-markdown-editor-code-cursor-color` | Editor's cursor color | --md-sys-color-on-surface
|
|
14
|
+
`--exm-markdown-editor-code-header-color` | H1 color in editor | #4a8fc0;
|
|
15
|
+
`--exm-markdown-editor-code-inline-code-color` | Inline code color | #ea881f
|
|
16
|
+
`--exm-markdown-editor-code-list-color` | Lists color | rgb(25, 165, 28)
|
|
17
|
+
`--exm-markdown-editor-selected-code-color` | Selected text color | rgb(140, 140, 140)
|
|
18
|
+
`--exm-markdown-editor-border-color` | Editor's border color | --md-sys-color-primary
|
|
19
|
+
`--exm-markdown-editor-background-color` | Toolbar and default preview background | --md-sys-color-surface-container-high
|
|
20
|
+
`--exm-markdown-editor-code-background-color` | Editor's background color when focused | --md-sys-color-surface-container-high
|
|
21
|
+
|
|
22
|
+
## Events:
|
|
23
|
+
- change - where detail is current markdown value
|
|
24
|
+
- insert-image - if the Editor is set to upload, it will trigger this event when the insert-image is clicked
|
|
25
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/core';
|
|
2
|
+
import './dialog/exm-wysiwyg-toolbar-link-dialog.js';
|
|
3
|
+
export declare const anchor: {
|
|
4
|
+
action: (editor?: Editor) => Promise<void>;
|
|
5
|
+
isActive: (editor?: Editor) => boolean;
|
|
6
|
+
icon: string;
|
|
7
|
+
title: string;
|
|
8
|
+
element: string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import './dialog/exm-wysiwyg-toolbar-link-dialog.js';
|
|
2
|
+
import { sleep } from '../../utils.js';
|
|
3
|
+
/**
|
|
4
|
+
* Open the dialog and wait until the close or submit button has been pressed
|
|
5
|
+
* @param url The initial url for the input
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
const linkDialog = (url) => new Promise((resolve) => {
|
|
9
|
+
/**
|
|
10
|
+
* First we get the dialog, open it and set the initial value for the url
|
|
11
|
+
*/
|
|
12
|
+
const dialog = document.querySelector('exm-wysiwyg-toolbar-link-dialog');
|
|
13
|
+
dialog.open();
|
|
14
|
+
dialog.setValue(url);
|
|
15
|
+
/**
|
|
16
|
+
* Callback function for the cancel button, or escape key
|
|
17
|
+
*/
|
|
18
|
+
function resolveCancel() {
|
|
19
|
+
removeListeners();
|
|
20
|
+
resolve({ success: false });
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Callback function for the submit button (also gets triggered through the dialog with the enter key)
|
|
24
|
+
* @param param Detail contains the url entered in the dialog
|
|
25
|
+
*/
|
|
26
|
+
function resolveSubmit({ detail }) {
|
|
27
|
+
removeListeners();
|
|
28
|
+
resolve({ success: true, value: detail });
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Remove allk previously added event listeners to prevent unwanted artifacts
|
|
32
|
+
*/
|
|
33
|
+
function removeListeners() {
|
|
34
|
+
dialog === null || dialog === void 0 ? void 0 : dialog.removeEventListener('click', resolveCancel);
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
dialog === null || dialog === void 0 ? void 0 : dialog.removeEventListener('click', resolveSubmit);
|
|
37
|
+
window.removeEventListener('keyup', handleKeyUp);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Check if the escape key has been used. If so, treat it as a cancel click
|
|
41
|
+
*/
|
|
42
|
+
function handleKeyUp({ code }) {
|
|
43
|
+
if (code === 'Escape') {
|
|
44
|
+
resolveCancel();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
dialog === null || dialog === void 0 ? void 0 : dialog.addEventListener('wysiwyg-dialog-link-cancel', resolveCancel);
|
|
48
|
+
dialog === null || dialog === void 0 ? void 0 : dialog.addEventListener('wysiwyg-dialog-link-submit', resolveSubmit);
|
|
49
|
+
window.addEventListener('keyup', handleKeyUp);
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Create a dom element, add the dialog and add it to the body
|
|
53
|
+
*/
|
|
54
|
+
const createDialog = () => {
|
|
55
|
+
const dialog = document.createElement('div');
|
|
56
|
+
dialog.id = 'editor-link-dialog-container';
|
|
57
|
+
dialog.innerHTML = '<exm-wysiwyg-toolbar-link-dialog></exm-wysiwyg-toolbar-link-dialog>';
|
|
58
|
+
document.body.appendChild(dialog);
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Remove the dialog from the body
|
|
62
|
+
*/
|
|
63
|
+
const removeDialog = () => {
|
|
64
|
+
const dialogContainer = document.getElementById('editor-link-dialog-container');
|
|
65
|
+
if (dialogContainer) {
|
|
66
|
+
dialogContainer.remove();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Function triggered when clicking the anchor button.
|
|
71
|
+
* @param editor
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
const setLink = async (editor) => {
|
|
75
|
+
if (!editor) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const previousUrl = editor.getAttributes('link').href || '';
|
|
79
|
+
createDialog();
|
|
80
|
+
// Due to some timing issues, this little power-nap is needed
|
|
81
|
+
await sleep(1);
|
|
82
|
+
const urlData = await linkDialog(previousUrl);
|
|
83
|
+
removeDialog();
|
|
84
|
+
// cancelled
|
|
85
|
+
if (!urlData.success) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
// empty
|
|
89
|
+
if (!(urlData === null || urlData === void 0 ? void 0 : urlData.value)) {
|
|
90
|
+
editor.chain().focus().extendMarkRange('link').unsetLink().run();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// update link
|
|
94
|
+
try {
|
|
95
|
+
editor.chain().focus().extendMarkRange('link').setLink({ href: urlData.value }).run();
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
alert(error.message);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
export const anchor = {
|
|
102
|
+
action: setLink,
|
|
103
|
+
isActive: (editor) => !!(editor === null || editor === void 0 ? void 0 : editor.isActive('link')),
|
|
104
|
+
icon: 'insert_link',
|
|
105
|
+
title: 'Toggle format link',
|
|
106
|
+
element: 'anchor-input-dialog',
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const styles = css `
|
|
3
|
+
.link-dialog {
|
|
4
|
+
position: fixed;
|
|
5
|
+
top: 0;
|
|
6
|
+
right: 0;
|
|
7
|
+
left: 0;
|
|
8
|
+
bottom: 0;
|
|
9
|
+
border: none;
|
|
10
|
+
padding: 0;
|
|
11
|
+
background-color: transparent;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.link-dialog[open] {
|
|
17
|
+
display: flex;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
::backdrop {
|
|
21
|
+
background-color: hsla(0deg, 0%, 0%, 0.4);
|
|
22
|
+
backdrop-filter: blur(4px);
|
|
23
|
+
display: block;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.content {
|
|
27
|
+
background-color: var(--md-sys-color-surface-container-high);
|
|
28
|
+
width: 20rem;
|
|
29
|
+
padding: 1rem;
|
|
30
|
+
border-radius: var(--md-dialog-container-shape, var(--md-sys-shape-corner-extra-large, 1rem));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
md-filled-text-field {
|
|
34
|
+
width: 100%;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.row {
|
|
38
|
+
margin-block: 1rem;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
header {
|
|
42
|
+
padding-block: 1rem;
|
|
43
|
+
color: var(--md-list-item-label-text-color, var(--md-sys-color-on-surface, #1d1b20));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
footer {
|
|
47
|
+
display: flex;
|
|
48
|
+
justify-content: flex-end;
|
|
49
|
+
gap: 1rem;
|
|
50
|
+
padding-top: 1rem;
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
//# sourceMappingURL=exm-wysiwyg-toolbar-dialog-css.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import '@material/web/button/filled-button.js';
|
|
2
|
+
import '@material/web/button/outlined-button.js';
|
|
3
|
+
import '@material/web/textfield/filled-text-field.js';
|
|
4
|
+
import { ExmgElement } from '@exmg/lit-base';
|
|
5
|
+
import { MdFilledTextField } from '@material/web/textfield/filled-text-field.js';
|
|
6
|
+
export declare class ExmWysiwygToolbarLinkDialog extends ExmgElement {
|
|
7
|
+
value: string;
|
|
8
|
+
errorMessage: string;
|
|
9
|
+
dialog?: HTMLDialogElement;
|
|
10
|
+
input?: MdFilledTextField;
|
|
11
|
+
static styles: import("lit").CSSResult[];
|
|
12
|
+
open(): void;
|
|
13
|
+
close(): void;
|
|
14
|
+
setValue(url: string): void;
|
|
15
|
+
private handleCancelClick;
|
|
16
|
+
private handleSubmitClick;
|
|
17
|
+
private handleSubmit;
|
|
18
|
+
private validateInput;
|
|
19
|
+
private handleInputChange;
|
|
20
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { customElement } from 'lit/decorators/custom-element.js';
|
|
3
|
+
import { styles } from './exm-wysiwyg-toolbar-dialog-css.js';
|
|
4
|
+
import { html } from 'lit';
|
|
5
|
+
import '@material/web/button/filled-button.js';
|
|
6
|
+
import '@material/web/button/outlined-button.js';
|
|
7
|
+
import '@material/web/textfield/filled-text-field.js';
|
|
8
|
+
import { query, state } from 'lit/decorators.js';
|
|
9
|
+
import { ExmgElement } from '@exmg/lit-base';
|
|
10
|
+
let ExmWysiwygToolbarLinkDialog = class ExmWysiwygToolbarLinkDialog extends ExmgElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.value = '';
|
|
14
|
+
this.errorMessage = '';
|
|
15
|
+
}
|
|
16
|
+
open() {
|
|
17
|
+
if (!this.dialog) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
this.dialog.showModal();
|
|
21
|
+
}
|
|
22
|
+
close() {
|
|
23
|
+
if (!this.dialog) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.dialog.close();
|
|
27
|
+
}
|
|
28
|
+
setValue(url) {
|
|
29
|
+
this.value = url;
|
|
30
|
+
if (!this.input) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this.input.value = url;
|
|
34
|
+
}
|
|
35
|
+
handleCancelClick() {
|
|
36
|
+
this.fire('wysiwyg-dialog-link-cancel');
|
|
37
|
+
}
|
|
38
|
+
handleSubmitClick() {
|
|
39
|
+
var _a;
|
|
40
|
+
if (this.validateInput()) {
|
|
41
|
+
this.fire('wysiwyg-dialog-link-submit', (_a = this.input) === null || _a === void 0 ? void 0 : _a.value);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.errorMessage = 'The entered url is not valid';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
handleSubmit({ code }) {
|
|
48
|
+
if (code === 'Enter') {
|
|
49
|
+
this.handleSubmitClick();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
validateInput() {
|
|
53
|
+
var _a;
|
|
54
|
+
let value = (_a = this.input) === null || _a === void 0 ? void 0 : _a.value;
|
|
55
|
+
if (value === null || value === void 0 ? void 0 : value.startsWith('#')) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
if (!value || !value.includes('.') || !this.input) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
if (!value.startsWith('http')) {
|
|
62
|
+
value = `https://${value}`;
|
|
63
|
+
}
|
|
64
|
+
this.input.value = value;
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
handleInputChange(event) {
|
|
68
|
+
this.errorMessage = '';
|
|
69
|
+
this.value = event.target.value;
|
|
70
|
+
}
|
|
71
|
+
render() {
|
|
72
|
+
return html `
|
|
73
|
+
<dialog class="link-dialog" id="wysiwyg-editor-button-link-dialog">
|
|
74
|
+
<article class="content">
|
|
75
|
+
<header>Enter a valid url</header>
|
|
76
|
+
<form @submit=${this.handleSubmit} @keyup=${this.handleSubmit}>
|
|
77
|
+
<md-filled-text-field
|
|
78
|
+
id="wysiwyg-editor-dialog-input-field"
|
|
79
|
+
type="text"
|
|
80
|
+
label="Url"
|
|
81
|
+
required
|
|
82
|
+
supporting-text="Provide a valid url or anchor like https://test.nl or #chapter-1"
|
|
83
|
+
error-text="${this.errorMessage}"
|
|
84
|
+
?error=${this.errorMessage !== ''}
|
|
85
|
+
@keyup=${this.handleInputChange}
|
|
86
|
+
></md-filled-text-field>
|
|
87
|
+
<input type="submit" hidden />
|
|
88
|
+
</form>
|
|
89
|
+
<footer>
|
|
90
|
+
<md-outlined-button type="button" id="wysiwyg-editor-dialog-button-cancel" @click=${this.handleCancelClick}>
|
|
91
|
+
Cancel
|
|
92
|
+
</md-outlined-button>
|
|
93
|
+
<md-filled-button
|
|
94
|
+
type="submit"
|
|
95
|
+
id="wysiwyg-editor-dialog-button-submit"
|
|
96
|
+
@click=${this.handleSubmitClick}
|
|
97
|
+
?disabled=${!this.value}
|
|
98
|
+
>
|
|
99
|
+
Submit
|
|
100
|
+
</md-filled-button>
|
|
101
|
+
</footer>
|
|
102
|
+
</article>
|
|
103
|
+
</dialog>
|
|
104
|
+
`;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
ExmWysiwygToolbarLinkDialog.styles = [styles];
|
|
108
|
+
__decorate([
|
|
109
|
+
state()
|
|
110
|
+
], ExmWysiwygToolbarLinkDialog.prototype, "value", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
state()
|
|
113
|
+
], ExmWysiwygToolbarLinkDialog.prototype, "errorMessage", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
query('#wysiwyg-editor-button-link-dialog')
|
|
116
|
+
], ExmWysiwygToolbarLinkDialog.prototype, "dialog", void 0);
|
|
117
|
+
__decorate([
|
|
118
|
+
query('#wysiwyg-editor-dialog-input-field')
|
|
119
|
+
], ExmWysiwygToolbarLinkDialog.prototype, "input", void 0);
|
|
120
|
+
ExmWysiwygToolbarLinkDialog = __decorate([
|
|
121
|
+
customElement('exm-wysiwyg-toolbar-link-dialog')
|
|
122
|
+
], ExmWysiwygToolbarLinkDialog);
|
|
123
|
+
export { ExmWysiwygToolbarLinkDialog };
|
|
124
|
+
//# sourceMappingURL=exm-wysiwyg-toolbar-link-dialog.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LinkContext } from './types.js';
|
|
2
|
+
export declare const linkOptions: {
|
|
3
|
+
openOnClick: boolean;
|
|
4
|
+
autolink: boolean;
|
|
5
|
+
defaultProtocol: string;
|
|
6
|
+
protocols: string[];
|
|
7
|
+
shouldAutoLink: (url: string) => boolean;
|
|
8
|
+
isAllowedUri: (url: string, ctx: LinkContext) => boolean;
|
|
9
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const linkOptions = {
|
|
2
|
+
openOnClick: false,
|
|
3
|
+
autolink: true,
|
|
4
|
+
defaultProtocol: 'https',
|
|
5
|
+
protocols: ['https'],
|
|
6
|
+
shouldAutoLink: (url) => url.startsWith('https://'),
|
|
7
|
+
isAllowedUri: (url, ctx) => {
|
|
8
|
+
try {
|
|
9
|
+
// We accept anchor links
|
|
10
|
+
if (url.startsWith('#')) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
const parsedUrl = url.includes(':') ? new URL(url) : new URL(`${ctx.defaultProtocol}://${url}`);
|
|
14
|
+
if (!ctx.defaultValidate(parsedUrl.href)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
// Only accept https:// urls for security reasons
|
|
18
|
+
const disallowedProtocols = ['http', 'ftp', 'file', 'mailto'];
|
|
19
|
+
const protocol = parsedUrl.protocol.replace(':', '');
|
|
20
|
+
if (disallowedProtocols.includes(protocol)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
catch (_a) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LinkProtocolOptions } from '@tiptap/extension-link';
|
|
2
|
+
export type LinkDialogResponse = {
|
|
3
|
+
success: boolean;
|
|
4
|
+
value?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Stole this from : https://github.com/ueberdosis/tiptap/blob/6ceff32242dc815acb121717752467f205d52e42/packages/extension-link/src/link.ts#L99C10-L112C6
|
|
8
|
+
*/
|
|
9
|
+
export type LinkContext = {
|
|
10
|
+
defaultValidate: (url: string) => boolean;
|
|
11
|
+
protocols: Array<LinkProtocolOptions | string>;
|
|
12
|
+
defaultProtocol: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/core';
|
|
2
|
+
export declare const blockquote: {
|
|
3
|
+
action: (editor?: Editor) => void;
|
|
4
|
+
isActive: (editor?: Editor) => boolean;
|
|
5
|
+
icon: string;
|
|
6
|
+
title: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const orderedList: {
|
|
9
|
+
action: (editor?: Editor) => void;
|
|
10
|
+
isActive: (editor?: Editor) => boolean;
|
|
11
|
+
icon: string;
|
|
12
|
+
title: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const unorderedList: {
|
|
15
|
+
action: (editor?: Editor) => void;
|
|
16
|
+
isActive: (editor?: Editor) => boolean;
|
|
17
|
+
icon: string;
|
|
18
|
+
title: string;
|
|
19
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const blockquote = {
|
|
2
|
+
action: (editor) => {
|
|
3
|
+
editor === null || editor === void 0 ? void 0 : editor.chain().focus().toggleBlockquote().run();
|
|
4
|
+
},
|
|
5
|
+
isActive: (editor) => !!(editor === null || editor === void 0 ? void 0 : editor.isActive('blockquote')),
|
|
6
|
+
icon: 'format_quote',
|
|
7
|
+
title: 'Toggle blockquote',
|
|
8
|
+
};
|
|
9
|
+
export const orderedList = {
|
|
10
|
+
action: (editor) => {
|
|
11
|
+
editor === null || editor === void 0 ? void 0 : editor.chain().focus().toggleOrderedList().run();
|
|
12
|
+
},
|
|
13
|
+
isActive: (editor) => !!(editor === null || editor === void 0 ? void 0 : editor.isActive('orderedList')),
|
|
14
|
+
icon: 'format_list_numbered',
|
|
15
|
+
title: 'Toggle ordered list',
|
|
16
|
+
};
|
|
17
|
+
export const unorderedList = {
|
|
18
|
+
action: (editor) => {
|
|
19
|
+
editor === null || editor === void 0 ? void 0 : editor.chain().focus().toggleBulletList().run();
|
|
20
|
+
},
|
|
21
|
+
isActive: (editor) => !!(editor === null || editor === void 0 ? void 0 : editor.isActive('bulletList')),
|
|
22
|
+
icon: 'format_list_bulleted',
|
|
23
|
+
title: 'Toggle unordered list',
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=block.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const toggleFullscreen = (event) => {
|
|
2
|
+
const container = (event === null || event === void 0 ? void 0 : event.target).offsetParent;
|
|
3
|
+
if (!container) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
if (!document.fullscreenElement) {
|
|
7
|
+
container.requestFullscreen();
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
document.exitFullscreen();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export const fullscreen = {
|
|
14
|
+
action: (_, options) => {
|
|
15
|
+
toggleFullscreen(options === null || options === void 0 ? void 0 : options.event);
|
|
16
|
+
},
|
|
17
|
+
isActive: (_) => !!document.fullscreenElement,
|
|
18
|
+
icon: ['fullscreen', 'fullscreen_exit'],
|
|
19
|
+
title: 'Toggle fullscreen mode',
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=fullScreen.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/core';
|
|
2
|
+
export declare const heading1: {
|
|
3
|
+
action: (editor?: Editor) => void;
|
|
4
|
+
isActive: (editor?: Editor) => boolean;
|
|
5
|
+
icon: string;
|
|
6
|
+
title: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const heading2: {
|
|
9
|
+
action: (editor?: Editor) => void;
|
|
10
|
+
isActive: (editor?: Editor) => boolean;
|
|
11
|
+
icon: string;
|
|
12
|
+
title: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const heading3: {
|
|
15
|
+
action: (editor?: Editor) => Promise<void>;
|
|
16
|
+
isActive: (editor?: Editor) => boolean;
|
|
17
|
+
icon: string;
|
|
18
|
+
title: string;
|
|
19
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const heading1 = {
|
|
2
|
+
action: (editor) => {
|
|
3
|
+
editor === null || editor === void 0 ? void 0 : editor.chain().focus().toggleHeading({ level: 1 }).run();
|
|
4
|
+
},
|
|
5
|
+
isActive: (editor) => !!(editor === null || editor === void 0 ? void 0 : editor.isActive('heading', { level: 1 })),
|
|
6
|
+
icon: 'format_h1',
|
|
7
|
+
title: 'Toggle format heading 1',
|
|
8
|
+
};
|
|
9
|
+
export const heading2 = {
|
|
10
|
+
action: (editor) => {
|
|
11
|
+
editor === null || editor === void 0 ? void 0 : editor.chain().focus().toggleHeading({ level: 2 }).run();
|
|
12
|
+
},
|
|
13
|
+
isActive: (editor) => !!(editor === null || editor === void 0 ? void 0 : editor.isActive('heading', { level: 2 })),
|
|
14
|
+
icon: 'format_h2',
|
|
15
|
+
title: 'Toggle format heading 2',
|
|
16
|
+
};
|
|
17
|
+
export const heading3 = {
|
|
18
|
+
action: async (editor) => {
|
|
19
|
+
editor === null || editor === void 0 ? void 0 : editor.chain().focus().toggleHeading({ level: 3 }).run();
|
|
20
|
+
},
|
|
21
|
+
isActive: (editor) => !!(editor === null || editor === void 0 ? void 0 : editor.isActive('heading', { level: 3 })),
|
|
22
|
+
icon: 'format_h3',
|
|
23
|
+
title: 'Toggle format heading 3',
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=heading.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/core';
|
|
2
|
+
export declare const orderedList: {
|
|
3
|
+
action: (editor?: Editor) => void;
|
|
4
|
+
isActive: (editor?: Editor) => boolean;
|
|
5
|
+
icon: string;
|
|
6
|
+
title: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const unorderedList: {
|
|
9
|
+
action: (editor?: Editor) => void;
|
|
10
|
+
isActive: (editor?: Editor) => boolean;
|
|
11
|
+
icon: string;
|
|
12
|
+
title: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const orderedList = {
|
|
2
|
+
action: (editor) => {
|
|
3
|
+
editor === null || editor === void 0 ? void 0 : editor.chain().focus().toggleOrderedList().run();
|
|
4
|
+
},
|
|
5
|
+
isActive: (editor) => !!(editor === null || editor === void 0 ? void 0 : editor.isActive('orderedList')),
|
|
6
|
+
icon: 'format_list_numbered',
|
|
7
|
+
title: 'Toggle ordered list',
|
|
8
|
+
};
|
|
9
|
+
export const unorderedList = {
|
|
10
|
+
action: (editor) => {
|
|
11
|
+
editor === null || editor === void 0 ? void 0 : editor.chain().focus().toggleBulletList().run();
|
|
12
|
+
},
|
|
13
|
+
isActive: (editor) => !!(editor === null || editor === void 0 ? void 0 : editor.isActive('bulletList')),
|
|
14
|
+
icon: 'format_list_bulleted',
|
|
15
|
+
title: 'Toggle unordered list',
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=lists.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/core';
|
|
2
|
+
export declare const bold: {
|
|
3
|
+
action: (editor?: Editor) => void;
|
|
4
|
+
isActive: (editor?: Editor) => boolean;
|
|
5
|
+
icon: string;
|
|
6
|
+
title: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const italic: {
|
|
9
|
+
action: (editor?: Editor) => void;
|
|
10
|
+
isActive: (editor?: Editor) => boolean;
|
|
11
|
+
icon: string;
|
|
12
|
+
title: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const strike: {
|
|
15
|
+
action: (editor?: Editor) => void;
|
|
16
|
+
isActive: (editor?: Editor) => boolean;
|
|
17
|
+
icon: string;
|
|
18
|
+
title: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const underline: {
|
|
21
|
+
action: (editor?: Editor) => void;
|
|
22
|
+
isActive: (editor?: Editor) => boolean;
|
|
23
|
+
icon: string;
|
|
24
|
+
title: string;
|
|
25
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const bold = {
|
|
2
|
+
action: (editor) => {
|
|
3
|
+
editor === null || editor === void 0 ? void 0 : editor.chain().focus().toggleBold().run();
|
|
4
|
+
},
|
|
5
|
+
isActive: (editor) => !!(editor === null || editor === void 0 ? void 0 : editor.isActive('bold')),
|
|
6
|
+
icon: 'format_bold',
|
|
7
|
+
title: 'Toggle format bold',
|
|
8
|
+
};
|
|
9
|
+
export const italic = {
|
|
10
|
+
action: (editor) => {
|
|
11
|
+
editor === null || editor === void 0 ? void 0 : editor.chain().focus().toggleItalic().run();
|
|
12
|
+
},
|
|
13
|
+
isActive: (editor) => !!(editor === null || editor === void 0 ? void 0 : editor.isActive('italic')),
|
|
14
|
+
icon: 'format_italic',
|
|
15
|
+
title: 'Toggle format italic',
|
|
16
|
+
};
|
|
17
|
+
export const strike = {
|
|
18
|
+
action: (editor) => {
|
|
19
|
+
editor === null || editor === void 0 ? void 0 : editor.chain().focus().toggleStrike().run();
|
|
20
|
+
},
|
|
21
|
+
isActive: (editor) => !!(editor === null || editor === void 0 ? void 0 : editor.isActive('strike')),
|
|
22
|
+
icon: 'format_strikethrough',
|
|
23
|
+
title: 'Toggle format strike through',
|
|
24
|
+
};
|
|
25
|
+
export const underline = {
|
|
26
|
+
action: (editor) => {
|
|
27
|
+
editor === null || editor === void 0 ? void 0 : editor.chain().focus().toggleUnderline().run();
|
|
28
|
+
},
|
|
29
|
+
isActive: (editor) => !!(editor === null || editor === void 0 ? void 0 : editor.isActive('underline')),
|
|
30
|
+
icon: 'format_underlined',
|
|
31
|
+
title: 'Toggle format underline',
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=text.js.map
|