Skip to content

Commit 8e6a460

Browse files
committed
Fix icon positioning
Editor Updates
1 parent 5c0ae07 commit 8e6a460

File tree

8 files changed

+62
-30
lines changed

8 files changed

+62
-30
lines changed

docs/pages/components/editor.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,27 @@ layout: component
66
---
77

88
```html:preview
9+
910
<zn-editor></zn-editor>
11+
12+
13+
<script>
14+
let cannedResponses = [
15+
{
16+
title: 'Hello',
17+
content: 'Hello, how can I help you?'
18+
command: 'hello'
19+
},
20+
{
21+
title: 'Goodbye',
22+
content: 'Goodbye, have a nice day!'
23+
command: 'goodbye'
24+
}
25+
];
26+
27+
let editor = document.querySelector('zn-editor');
28+
editor.setAttribute('canned-responses', JSON.stringify(cannedResponses));
29+
</script>
1030
```
1131

1232
## Examples

docs/pages/components/item.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ layout: component
4646
</zn-item>
4747
4848
<zn-cols layout="1, 1">
49-
<zn-item inline icon="person">This is the content</zn-item>
49+
<zn-item inline icon="person">
50+
<div>First Name</div>
51+
<div>Second Name</div>
52+
</zn-item>
5053
<zn-item inline icon="person">This is the content</zn-item>
5154
</zn-cols>
5255
```

src/components/editor/editor.component.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { property, query } from 'lit/decorators.js';
2-
import { type CSSResultGroup, html, PropertyValues, unsafeCSS } from 'lit';
3-
import ZincElement, { ZincFormControl } from '../../internal/zinc-element';
1+
import {property, query} from 'lit/decorators.js';
2+
import {type CSSResultGroup, html, PropertyValues, unsafeCSS} from 'lit';
3+
import ZincElement, {ZincFormControl} from '../../internal/zinc-element';
44
import Quill from "quill";
5-
import { FormControlController } from '../../internal/form';
6-
import DropdownModule, { dropdownOpen } from "./modules/dropdown-module";
5+
import {FormControlController} from '../../internal/form';
6+
import DropdownModule, {dropdownOpen} from "./modules/dropdown-module";
77
import AttachmentModule from "./modules/attachment-module";
88
import TimeTrackingModule from "./modules/time-tracking-module";
99
import DragAndDropModule from "./modules/drag-drop-module";
1010
import ImageResizeModule from "./modules/image-resize-module/image-resize-module";
11-
import { normalizeNative } from "./normalize-native";
11+
import {normalizeNative} from "./normalize-native";
1212

1313
import styles from './editor.scss';
1414

@@ -43,15 +43,15 @@ export default class ZnEditor extends ZincElement implements ZincFormControl {
4343
@property() name: string;
4444
@property() value: string;
4545

46-
@property({ attribute: 'interaction-type', type: String })
46+
@property({attribute: 'interaction-type', type: String})
4747
interactionType: 'ticket' | 'chat' = 'chat';
4848

49-
@property({ attribute: 'canned-responses', type: Array })
50-
cannedResponses: Array<any>;
49+
@property({attribute: 'canned-responses', type: Array})
50+
cannedResponses: any[];
5151

52-
@property({ attribute: 'canned-responses-url' }) cannedResponsesUri: string;
52+
@property({attribute: 'canned-responses-url'}) cannedResponsesUri: string;
5353

54-
@property({ attribute: 'attachment-url', type: String })
54+
@property({attribute: 'attachment-url', type: String})
5555
uploadAttachmentUrl: string;
5656

5757
private quillElement: Quill;
@@ -101,7 +101,7 @@ export default class ZnEditor extends ZincElement implements ZincFormControl {
101101
const container = [
102102
['bold', 'italic', 'underline', 'strike'],
103103
['undo', 'redo'],
104-
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
104+
[{'list': 'ordered'}, {'list': 'bullet'}],
105105
];
106106
container.push(this.interactionType === 'ticket' ? ['link', 'image', 'image-attachment'] : ['link', 'image', 'video']);
107107
container.push(['remove-formatting']);
@@ -161,7 +161,7 @@ export default class ZnEditor extends ZincElement implements ZincFormControl {
161161
xhr.onload = () => {
162162
if (xhr.status === 200) {
163163
const response = JSON.parse(xhr.responseText);
164-
resolve({ path: response.uploadPath, url: response.uploadUrl, filename: response.originalFilename });
164+
resolve({path: response.uploadPath, url: response.uploadUrl, filename: response.originalFilename});
165165
}
166166
};
167167
xhr.send(fd);
@@ -195,10 +195,10 @@ export default class ZnEditor extends ZincElement implements ZincFormControl {
195195

196196
this._setupTitleAttributes(quill);
197197

198-
const html = quill.clipboard.convert({ html: this.value });
198+
const html = quill.clipboard.convert({html: this.value});
199199
quill.setContents(html, Quill.sources.SILENT);
200200

201-
this.emit('zn-element-added', { detail: { element: this.editor } });
201+
this.emit('zn-element-added', {detail: {element: this.editor}});
202202

203203
super.firstUpdated(_changedProperties);
204204
}
@@ -234,7 +234,7 @@ export default class ZnEditor extends ZincElement implements ZincFormControl {
234234
const clipboard = context.event.clipboardData;
235235
const text = clipboard.getData('text/plain');
236236
const html = clipboard.getData('text/html');
237-
const delta = this.quillElement.clipboard.convert({ html: html, text: text });
237+
const delta = this.quillElement.clipboard.convert({html: html, text: text});
238238
this.quillElement.setContents(delta, 'silent');
239239
this.quillElement.setSelection(delta.length(), Quill.sources.SILENT);
240240
}
@@ -254,7 +254,7 @@ export default class ZnEditor extends ZincElement implements ZincFormControl {
254254
handler: () => {
255255
const form = this.closest('form');
256256
if (form && !dropdownOpen && this.value && this.value.trim().length > 0 && !empty(this.value)) {
257-
this.emit('zn-submit', { detail: { value: this.value, element: this } });
257+
this.emit('zn-submit', {detail: {value: this.value, element: this}});
258258
form.requestSubmit();
259259
this.quillElement.setText('');
260260
}

src/components/editor/editor.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
height: 100%;
6161
max-height: 100%;
6262
overflow-y: auto;
63+
flex-grow: 1;
6364
color: rgb(var(--zn-text-body));
6465
background-color: rgba(var(--zn-panel), var(--zn-panel-opacity));
6566
font-size: 15px;
@@ -77,6 +78,7 @@
7778
}
7879

7980
#editor {
81+
display: contents;
8082
flex: 1;
8183
height: 0;
8284
padding: 0;

src/components/editor/modules/drag-drop-module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Quill from 'quill';
22

3-
type DragAndDropModuleOptions = {
3+
interface DragAndDropModuleOptions {
44
onDrop: (file: File, options: object) => void;
55
draggableContentTypePattern: string;
66
draggables: [];

src/components/editor/modules/dropdown-module.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import Quill from 'quill';
22

3-
type DropdownModuleOptions = {
3+
interface DropdownModuleOptions {
44
cannedResponses: DropdownModuleCannedResponse[];
55
cannedResponsesUri: string;
66
}
77

8-
type DropdownModuleCannedResponse = {
9-
title: string
8+
interface DropdownModuleCannedResponse {
9+
title: string;
1010
content: string;
1111
command: string;
1212
labels?: string[];
@@ -116,7 +116,7 @@ class DropdownModule {
116116
const char = index === 0 ? text.charAt(0) : text.charAt(index - 1); // Last input char
117117

118118
// if there's no character before the forward slash, we will open the dropdown
119-
if (char === '/' && !dropdownOpen &&
119+
if (char === '#' && !dropdownOpen &&
120120
(text.charAt(index - 2) === ' '
121121
|| text.charAt(index - 2) === '\n'
122122
|| text.charAt(index - 2) === ''

src/components/item/item.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ export default class ZnItem extends ZincElement {
5656
}
5757

5858
render() {
59+
const hasIcon = this.icon && this.icon.length > 0;
60+
5961
return html`
6062
<div class=${classMap({
6163
'description-item': true,
@@ -65,6 +67,7 @@ export default class ZnItem extends ZincElement {
6567
'description-item--small': this.size === 'small',
6668
'description-item--medium': this.size === 'medium',
6769
'description-item--large': this.size === 'large',
70+
'description-item--has-icon': hasIcon,
6871
})}>
6972
7073
${this.icon ? html`

src/components/item/item.scss

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,18 @@
2626
gap: var(--zn-spacing-small);
2727
}
2828

29-
&__icon:not(:empty) {
30-
display: flex;
31-
align-items: center;
32-
justify-content: center;
33-
margin-right: var(--zn-spacing-small);
34-
color: rgb(var(--zn-text-heading));
35-
}
29+
&--has-icon {
30+
align-items: flex-start !important;
3631

32+
.description-item__icon {
33+
position: relative;
34+
line-height: 33px;
35+
display: flex;
36+
justify-content: center;
37+
margin-right: var(--zn-spacing-small);
38+
color: rgb(var(--zn-text-heading));
39+
}
40+
}
3741

3842
&__header {
3943
display: flex;

0 commit comments

Comments
 (0)