@enso-ui/wysiwyg 3.1.0 → 3.2.0

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 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,56 @@
1
1
  # WYSIWYG
2
-
3
- WYSIWYG editor component.
4
-
5
- ### Features
6
-
7
- - TinyMCE-based editing
8
- - theme-aware styling
9
-
10
- ### Configuration & Usage
11
-
12
- Use the component where rich text editing is needed inside the Enso ecosystem.
13
-
14
- ### Contributions
15
-
2
+ [![License](https://img.shields.io/badge/license-MIT-10b981.svg)](https://github.com/enso-ui/wysiwyg/blob/master/LICENSE)
3
+ [![Stable](https://img.shields.io/badge/stable-3.1.1-2563eb.svg)](https://www.npmjs.com/package/@enso-ui/wysiwyg)
4
+ [![Downloads](https://img.shields.io/npm/dm/@enso-ui/wysiwyg.svg)](https://www.npmjs.com/package/@enso-ui/wysiwyg)
5
+ [![Vue](https://img.shields.io/badge/vue-3.x-42b883.svg)](https://vuejs.org/)
6
+ [![JavaScript](https://img.shields.io/badge/javascript-ES2020-f7df1e.svg)](https://developer.mozilla.org/docs/Web/JavaScript)
7
+ [![SCSS](https://img.shields.io/badge/scss-supported-c6538c.svg)](https://sass-lang.com/)
8
+ [![npm](https://img.shields.io/badge/npm-package-cb3837.svg)](https://www.npmjs.com/package/@enso-ui/wysiwyg)
9
+ [![Issues](https://img.shields.io/github/issues/enso-ui/wysiwyg.svg)](https://github.com/enso-ui/wysiwyg/issues)
10
+ [![Merge Requests](https://img.shields.io/github/issues-pr/enso-ui/wysiwyg.svg)](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:
15
+
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 the Bulma presentation layer separate from the renderless/stateful layer where applicable
23
+ ## Usage
24
+ ```vue
25
+ <script setup>
26
+ import Wysiwyg from '@enso-ui/wysiwyg/bulma';
27
+ </script>
28
+
29
+ <Wysiwyg v-model="content"
30
+ :has-error="false"/>
31
+
32
+ <Wysiwyg v-model="content"
33
+ editor="trix"
34
+ :has-error="false"/>
35
+ ```
36
+ ## API
37
+ ### `Wysiwyg`
38
+
39
+ Public export available from `src/bulma/Wysiwyg.vue`.
40
+
41
+ Props:
42
+ - `hasError`
43
+ - `editor`
44
+ - `menubar`
45
+ - `plugins`
46
+ - `toolbar`
47
+
48
+ `editor` defaults to `tinymce`. Set it to `trix` to use the Trix editor.
49
+ ## Depends On
50
+ - No additional Enso UI package dependencies.
51
+ - [`trix`](https://github.com/basecamp/trix)
52
+ ## Contributions
16
53
  are welcome. Pull requests are great, but issues are good too.
17
-
18
- ### License
19
-
20
- This package is released under the MIT license.
54
+ Thank you to all the people who already contributed to Enso!
55
+ ## License
56
+ [MIT](https://github.com/enso-ui/wysiwyg/blob/master/LICENSE)
package/package.json CHANGED
@@ -1,24 +1,30 @@
1
1
  {
2
- "name": "@enso-ui/wysiwyg",
3
- "version": "3.1.0",
4
- "description": "WYSIWYG",
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
- "vue": "^3.0"
23
- }
2
+ "name": "@enso-ui/wysiwyg",
3
+ "version": "3.2.0",
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
+ }
24
30
  }
@@ -0,0 +1,42 @@
1
+ <template>
2
+ <input :id="inputId"
3
+ type="hidden"
4
+ :value="normalizedValue">
5
+ <trix-editor :input="inputId"
6
+ ref="trix"
7
+ @trix-change="update"/>
8
+ </template>
9
+
10
+ <script setup>
11
+
12
+ import 'trix/dist/trix.css';
13
+ import 'trix';
14
+ import { computed, nextTick, ref, watch } from 'vue';
15
+
16
+ defineOptions({
17
+ inheritAttrs: false,
18
+ });
19
+
20
+ const props = defineProps({
21
+ modelValue: {
22
+ type: [String, null],
23
+ default: '',
24
+ },
25
+ });
26
+
27
+ const emit = defineEmits(['update:modelValue']);
28
+ const inputId = `trix-${Math.random().toString(36).slice(2)}`;
29
+ const trix = ref(null);
30
+ const normalizedValue = computed(() => props.modelValue ?? '');
31
+
32
+ const update = event => emit('update:modelValue', event.target.value);
33
+
34
+ watch(() => props.modelValue, value => nextTick(() => {
35
+ const html = value ?? '';
36
+
37
+ if (trix.value && trix.value.value !== html) {
38
+ trix.value.editor.loadHTML(html);
39
+ }
40
+ }));
41
+
42
+ </script>
@@ -1,21 +1,18 @@
1
1
  <template>
2
2
  <div :class="['wysiwyg-wrapper', {'has-error': hasError}, $attrs.class]">
3
- <editor v-bind="$attrs"
4
- :key="editorKey"
5
- :toolbar="toolbar"
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>