@exmg/exm-wysiwyg-editor 1.1.16 → 1.1.18

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/README.md CHANGED
@@ -1,25 +1,13 @@
1
+ # Wysiwyg editor element
1
2
 
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
-
3
+ ### An out of the box customizable Wysiwyg Editor for Exmachina
4
+
5
+ ```html
6
+ <exm-wysiwyg-editor value="<h1>Title</h1>"></exm-wysiwyg-editor>
7
+ ```
8
+
9
+ ## Events
10
+
11
+ - change - where detail is current html value
12
+ - blur - on editor blur
13
+ - focus - on editor focus
@@ -28,6 +28,7 @@ export declare class WysiwygEditorElementBase extends ExmgElement {
28
28
  editor?: Editor;
29
29
  reset(): void;
30
30
  protected firstUpdated(): void;
31
+ attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
31
32
  private createExtensionList;
32
33
  editorSetup(): void;
33
34
  private handleEditorUpdate;
@@ -49,14 +49,25 @@ export class WysiwygEditorElementBase extends ExmgElement {
49
49
  this.value = (_a = this.getAttribute('value')) !== null && _a !== void 0 ? _a : '';
50
50
  }
51
51
  firstUpdated() {
52
- if (!this.disabled) {
53
- this.editorSetup();
54
- }
52
+ this.editorSetup();
55
53
  if (this.label && this.required) {
56
54
  this.setAttribute('aria-required', 'true');
57
55
  this.label += ' *';
58
56
  }
59
57
  }
58
+ attributeChangedCallback(name, _old, value) {
59
+ var _a, _b;
60
+ this[name] = value;
61
+ if (name === 'value') {
62
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.commands.setContent(value);
63
+ }
64
+ if (name === 'disabled') {
65
+ this.disabled = value !== null;
66
+ (_b = this.editor) === null || _b === void 0 ? void 0 : _b.setOptions({
67
+ editable: value === null,
68
+ });
69
+ }
70
+ }
60
71
  createExtensionList() {
61
72
  const headingList = [];
62
73
  let hasList = false;
@@ -127,7 +138,6 @@ export class WysiwygEditorElementBase extends ExmgElement {
127
138
  onBlur: this.handleBlur.bind(this),
128
139
  onFocus: this.handleFocus.bind(this),
129
140
  });
130
- this.editor;
131
141
  }
132
142
  handleEditorUpdate({ editor }) {
133
143
  this.value = editor.getHTML();
@@ -156,10 +166,12 @@ export class WysiwygEditorElementBase extends ExmgElement {
156
166
  ${this.label
157
167
  ? html `<label class="${classMap(labelClasses)}" for="wysiwygEditorContainer">${this.label}</label>`
158
168
  : nothing}
159
- <exm-wysiwyg-editor-toolbar
160
- .editor=${this.editor}
161
- .editorActions=${this.editorActions}
162
- ></exm-wysiwyg-editor-toolbar>
169
+ ${!this.disabled
170
+ ? html `<exm-wysiwyg-editor-toolbar
171
+ .editor=${this.editor}
172
+ .editorActions=${this.editorActions}
173
+ ></exm-wysiwyg-editor-toolbar>`
174
+ : nothing}
163
175
  <div class="editor" id="editor"></div>
164
176
  ${this.supportingText ? html `<div class="supporting-text">${this.supportingText}</div>` : nothing}
165
177
  </div>
@@ -9,6 +9,7 @@ export const style = css `
9
9
  padding: 0.5rem 1rem;
10
10
  display: flex;
11
11
  flex-wrap: wrap;
12
+ gap: 2px;
12
13
  }
13
14
 
14
15
  .separator {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exmg/exm-wysiwyg-editor",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -63,5 +63,5 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "e0ce15fa919af66b23633174437044a47b0b683a"
66
+ "gitHead": "3d6851a4ecf25db65978adfe024851020529e570"
67
67
  }