@enso-ui/wysiwyg 3.1.1 → 3.2.2
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/CHANGELOG.md +10 -0
- package/LICENSE +1 -5
- package/README.md +64 -10
- package/package.json +28 -27
- package/src/bulma/TrixEditor.vue +53 -0
- package/src/bulma/Wysiwyg.vue +78 -7
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 3.2.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- added optional Trix editor support through the `editor` prop
|
|
8
|
+
- kept TinyMCE as the default editor for backward compatibility
|
|
9
|
+
- added Trix styling aligned with the Bulma theme tokens used by the existing WYSIWYG field
|
|
10
|
+
|
package/LICENSE
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 laravel-enso
|
|
4
|
-
|
|
2
|
+
Copyright (c) 2026 Laravel Enso
|
|
5
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
4
|
of this software and associated documentation files (the "Software"), to deal
|
|
7
5
|
in the Software without restriction, including without limitation the rights
|
|
8
6
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
7
|
copies of the Software, and to permit persons to whom the Software is
|
|
10
8
|
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
9
|
The above copyright notice and this permission notice shall be included in all
|
|
13
10
|
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
11
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
12
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
13
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
package/README.md
CHANGED
|
@@ -1,20 +1,74 @@
|
|
|
1
1
|
# WYSIWYG
|
|
2
|
+
[](https://github.com/enso-ui/wysiwyg/blob/master/LICENSE)
|
|
3
|
+
[](https://www.npmjs.com/package/@enso-ui/wysiwyg)
|
|
4
|
+
[](https://www.npmjs.com/package/@enso-ui/wysiwyg)
|
|
5
|
+
[](https://vuejs.org/)
|
|
6
|
+
[](https://developer.mozilla.org/docs/Web/JavaScript)
|
|
7
|
+
[](https://sass-lang.com/)
|
|
8
|
+
[](https://www.npmjs.com/package/@enso-ui/wysiwyg)
|
|
9
|
+
[](https://github.com/enso-ui/wysiwyg/issues)
|
|
10
|
+
[](https://github.com/enso-ui/wysiwyg/pulls)
|
|
11
|
+
## Description
|
|
12
|
+
WYSIWYG field for Enso UI, with TinyMCE as the default editor and optional Trix support.
|
|
13
|
+
## Installation
|
|
14
|
+
Install the package:
|
|
2
15
|
|
|
3
|
-
|
|
16
|
+
```bash
|
|
17
|
+
yarn add @enso-ui/wysiwyg
|
|
18
|
+
```
|
|
19
|
+
## Features
|
|
20
|
+
- exports `Wysiwyg` as its public surface
|
|
21
|
+
- supports `tinymce` and `trix` editor engines
|
|
22
|
+
- keeps TinyMCE as the default editor for backward compatibility
|
|
23
|
+
- keeps the Bulma presentation layer separate from the renderless/stateful layer where applicable
|
|
24
|
+
## Usage
|
|
25
|
+
```vue
|
|
26
|
+
<script setup>
|
|
27
|
+
import Wysiwyg from '@enso-ui/wysiwyg/bulma';
|
|
28
|
+
</script>
|
|
4
29
|
|
|
5
|
-
|
|
30
|
+
<Wysiwyg v-model="content"
|
|
31
|
+
:has-error="false"/>
|
|
6
32
|
|
|
7
|
-
|
|
8
|
-
|
|
33
|
+
<Wysiwyg v-model="content"
|
|
34
|
+
editor="trix"
|
|
35
|
+
:has-error="false"/>
|
|
36
|
+
```
|
|
37
|
+
## API
|
|
38
|
+
### `Wysiwyg`
|
|
9
39
|
|
|
10
|
-
|
|
40
|
+
Public export available from `src/bulma/Wysiwyg.vue`.
|
|
11
41
|
|
|
12
|
-
|
|
42
|
+
Props:
|
|
43
|
+
- `hasError`
|
|
44
|
+
- `editor`
|
|
45
|
+
- `menubar`
|
|
46
|
+
- `plugins`
|
|
47
|
+
- `toolbar`
|
|
13
48
|
|
|
14
|
-
|
|
49
|
+
`editor` defaults to `tinymce`. Set it to `trix` to use the Trix editor.
|
|
15
50
|
|
|
16
|
-
|
|
51
|
+
### Trix
|
|
52
|
+
|
|
53
|
+
Trix uses the same `v-model` contract as TinyMCE:
|
|
54
|
+
|
|
55
|
+
```vue
|
|
56
|
+
<Wysiwyg v-model="content"
|
|
57
|
+
editor="trix"
|
|
58
|
+
:has-error="false"/>
|
|
59
|
+
```
|
|
17
60
|
|
|
18
|
-
|
|
61
|
+
Form renderers may pass this through backend metadata as `meta.editor: 'trix'`.
|
|
19
62
|
|
|
20
|
-
|
|
63
|
+
## Changelog
|
|
64
|
+
|
|
65
|
+
See [CHANGELOG.md](CHANGELOG.md).
|
|
66
|
+
|
|
67
|
+
## Depends On
|
|
68
|
+
- No additional Enso UI package dependencies.
|
|
69
|
+
- [`trix`](https://github.com/basecamp/trix)
|
|
70
|
+
## Contributions
|
|
71
|
+
are welcome. Pull requests are great, but issues are good too.
|
|
72
|
+
Thank you to all the people who already contributed to Enso!
|
|
73
|
+
## License
|
|
74
|
+
[MIT](https://github.com/enso-ui/wysiwyg/blob/master/LICENSE)
|
package/package.json
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
2
|
+
"name": "@enso-ui/wysiwyg",
|
|
3
|
+
"version": "3.2.2",
|
|
4
|
+
"description": "TinyMCE-based WYSIWYG field for Enso UI.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/enso-ui/wysiwyg.git"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"wysiwyg",
|
|
12
|
+
"vue"
|
|
13
|
+
],
|
|
14
|
+
"author": "Adrian Ocneanu <aocneanu@gmail.com>",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/enso-ui/wysiwyg/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/enso-ui/wysiwyg#readme",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@tinymce/tinymce-vue": "^4.0.0",
|
|
22
|
+
"trix": "^2.1.19"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"vue": "^3.5.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"vue": "^3.5.0"
|
|
29
|
+
}
|
|
29
30
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
|
|
3
|
+
import 'trix/dist/trix.css';
|
|
4
|
+
import 'trix';
|
|
5
|
+
import {
|
|
6
|
+
computed, h, nextTick, ref, watch,
|
|
7
|
+
} from 'vue';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
name: 'EnsoTrixEditor',
|
|
11
|
+
|
|
12
|
+
inheritAttrs: false,
|
|
13
|
+
|
|
14
|
+
props: {
|
|
15
|
+
modelValue: {
|
|
16
|
+
type: [String, null],
|
|
17
|
+
default: '',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
emits: ['update:modelValue'],
|
|
22
|
+
|
|
23
|
+
setup(props, { emit }) {
|
|
24
|
+
const inputId = `trix-${Math.random().toString(36).slice(2)}`;
|
|
25
|
+
const trix = ref(null);
|
|
26
|
+
const normalizedValue = computed(() => props.modelValue ?? '');
|
|
27
|
+
|
|
28
|
+
const update = event => emit('update:modelValue', event.target.value);
|
|
29
|
+
|
|
30
|
+
watch(() => props.modelValue, value => nextTick(() => {
|
|
31
|
+
const html = value ?? '';
|
|
32
|
+
|
|
33
|
+
if (trix.value && trix.value.value !== html) {
|
|
34
|
+
trix.value.editor.loadHTML(html);
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
return () => [
|
|
39
|
+
h('input', {
|
|
40
|
+
id: inputId,
|
|
41
|
+
type: 'hidden',
|
|
42
|
+
value: normalizedValue.value,
|
|
43
|
+
}),
|
|
44
|
+
h('trix-editor', {
|
|
45
|
+
input: inputId,
|
|
46
|
+
ref: trix,
|
|
47
|
+
onTrixChange: update,
|
|
48
|
+
}),
|
|
49
|
+
];
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
</script>
|
package/src/bulma/Wysiwyg.vue
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :class="['wysiwyg-wrapper', {'has-error': hasError}, $attrs.class]">
|
|
3
|
-
<
|
|
4
|
-
:key="
|
|
5
|
-
|
|
6
|
-
:plugins="plugins"
|
|
7
|
-
:init="editorInit"/>
|
|
3
|
+
<component :is="editorComponent"
|
|
4
|
+
:key="componentKey"
|
|
5
|
+
v-bind="editorBindings"/>
|
|
8
6
|
</div>
|
|
9
7
|
</template>
|
|
10
8
|
|
|
11
9
|
<script>
|
|
10
|
+
import { defineAsyncComponent } from 'vue';
|
|
12
11
|
import Editor from '@tinymce/tinymce-vue';
|
|
13
12
|
|
|
14
13
|
export default {
|
|
15
14
|
name: 'Wysiwyg',
|
|
16
15
|
|
|
17
|
-
components: { Editor },
|
|
18
|
-
|
|
19
16
|
inheritAttrs: false,
|
|
20
17
|
|
|
21
18
|
data: () => ({
|
|
@@ -30,6 +27,11 @@ export default {
|
|
|
30
27
|
type: Boolean,
|
|
31
28
|
required: true,
|
|
32
29
|
},
|
|
30
|
+
editor: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: 'tinymce',
|
|
33
|
+
validator: value => ['tinymce', 'trix'].includes(value),
|
|
34
|
+
},
|
|
33
35
|
menubar: {
|
|
34
36
|
type: [String, Boolean],
|
|
35
37
|
default: false,
|
|
@@ -45,6 +47,29 @@ export default {
|
|
|
45
47
|
},
|
|
46
48
|
|
|
47
49
|
computed: {
|
|
50
|
+
editorComponent() {
|
|
51
|
+
return this.editor === 'trix'
|
|
52
|
+
? defineAsyncComponent(() => import('./TrixEditor.vue'))
|
|
53
|
+
: Editor;
|
|
54
|
+
},
|
|
55
|
+
componentKey() {
|
|
56
|
+
return this.editor === 'tinymce'
|
|
57
|
+
? this.editorKey
|
|
58
|
+
: this.editor;
|
|
59
|
+
},
|
|
60
|
+
editorBindings() {
|
|
61
|
+
if (this.editor === 'trix') {
|
|
62
|
+
return Object.fromEntries(Object.entries(this.$attrs)
|
|
63
|
+
.filter(([key]) => key !== 'apiKey'));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
...this.$attrs,
|
|
68
|
+
toolbar: this.toolbar,
|
|
69
|
+
plugins: this.plugins,
|
|
70
|
+
init: this.editorInit,
|
|
71
|
+
};
|
|
72
|
+
},
|
|
48
73
|
isDarkTheme() {
|
|
49
74
|
return this.theme === 'dark';
|
|
50
75
|
},
|
|
@@ -217,4 +242,50 @@ export default {
|
|
|
217
242
|
.wysiwyg-wrapper.has-error {
|
|
218
243
|
border: 1px solid var(--bulma-danger);
|
|
219
244
|
}
|
|
245
|
+
|
|
246
|
+
.wysiwyg-wrapper {
|
|
247
|
+
trix-toolbar {
|
|
248
|
+
.trix-button-row {
|
|
249
|
+
flex-wrap: wrap;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.trix-button-group {
|
|
253
|
+
background-color: var(--bulma-scheme-main-ter);
|
|
254
|
+
border-color: var(--bulma-border);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.trix-button {
|
|
258
|
+
border-color: var(--bulma-border);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.trix-button:not(:disabled) {
|
|
262
|
+
color: var(--bulma-text);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.trix-button.trix-active {
|
|
266
|
+
background-color: var(--bulma-scheme-main-bis);
|
|
267
|
+
color: var(--bulma-text-strong);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
trix-editor {
|
|
272
|
+
background-color: var(--bulma-scheme-main);
|
|
273
|
+
border-color: var(--bulma-border);
|
|
274
|
+
border-radius: var(--bulma-radius);
|
|
275
|
+
color: var(--bulma-text);
|
|
276
|
+
min-height: 10rem;
|
|
277
|
+
|
|
278
|
+
&:focus {
|
|
279
|
+
border-color: var(--bulma-input-focus-border-color);
|
|
280
|
+
box-shadow: var(--bulma-input-focus-box-shadow-size)
|
|
281
|
+
var(--bulma-input-focus-box-shadow-color);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
&.has-error {
|
|
286
|
+
trix-editor {
|
|
287
|
+
border-color: var(--bulma-danger);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
220
291
|
</style>
|