owl-tiptap 1.0.0 → 1.0.1
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/es/components/tag-input/TagInput.css +33 -11
- package/es/components/tag-input/TagInput.d.ts +2 -0
- package/es/components/tag-input/TagInput.js +12 -3
- package/es/components/tag-input/TagNode.js +5 -3
- package/es/index.d.ts +0 -1
- package/es/index.js +0 -1
- package/package.json +1 -1
- package/es/index.css +0 -6
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
.ott-tag-input {
|
|
2
|
+
--ott-primary-color: rgb(22, 119, 255);
|
|
3
|
+
--ott-border-color: rgb(204, 204, 204);
|
|
4
|
+
--ott-placeholder-color: rgb(173, 181, 189);
|
|
5
|
+
--ott-text-color-secondary: rgb(136, 136, 136);
|
|
6
|
+
--ott-primary-color-08: rgba(22, 119, 255, 0.8);
|
|
7
|
+
--ott-primary-color-02: rgba(22, 119, 255, 0.2);
|
|
8
|
+
--ott-primary-color-04: rgba(22, 119, 255, 0.4);
|
|
9
|
+
--ott-primary-color-01: rgba(22, 119, 255, 0.1);
|
|
2
10
|
position: relative;
|
|
3
11
|
background-color: white;
|
|
4
12
|
}
|
|
13
|
+
.ott-tag-input.disabled {
|
|
14
|
+
cursor: not-allowed;
|
|
15
|
+
background-color: #f5f5f5;
|
|
16
|
+
opacity: 0.7;
|
|
17
|
+
}
|
|
18
|
+
.ott-tag-input.disabled .ProseMirror {
|
|
19
|
+
background-color: #f5f5f5;
|
|
20
|
+
border-color: #e0e0e0;
|
|
21
|
+
color: #999;
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
}
|
|
24
|
+
.ott-tag-input.disabled .tag-wrapper .tag {
|
|
25
|
+
pointer-events: none;
|
|
26
|
+
}
|
|
5
27
|
.ott-tag-input .ProseMirror {
|
|
6
28
|
padding: 8px;
|
|
7
|
-
border: 1px solid
|
|
29
|
+
border: 1px solid var(--ott-border-color);
|
|
8
30
|
border-radius: 4px;
|
|
9
31
|
}
|
|
10
32
|
.ott-tag-input .ProseMirror:focus {
|
|
11
33
|
outline: none;
|
|
12
|
-
border-color:
|
|
13
|
-
box-shadow: 0 0 0 2px
|
|
34
|
+
border-color: var(--ott-primary-color-08);
|
|
35
|
+
box-shadow: 0 0 0 2px var(--ott-primary-color-02);
|
|
14
36
|
}
|
|
15
37
|
.ott-tag-input .ProseMirror p {
|
|
16
38
|
margin: 0;
|
|
@@ -18,7 +40,7 @@
|
|
|
18
40
|
.ott-tag-input .ProseMirror p.is-editor-empty:first-child::before {
|
|
19
41
|
content: attr(data-placeholder);
|
|
20
42
|
float: left;
|
|
21
|
-
color:
|
|
43
|
+
color: var(--ott-placeholder-color);
|
|
22
44
|
pointer-events: none;
|
|
23
45
|
height: 0;
|
|
24
46
|
}
|
|
@@ -31,7 +53,7 @@
|
|
|
31
53
|
min-height: 20px;
|
|
32
54
|
display: inline-flex;
|
|
33
55
|
align-items: center;
|
|
34
|
-
background-color:
|
|
56
|
+
background-color: var(--ott-primary-color);
|
|
35
57
|
border: none;
|
|
36
58
|
border-radius: 3px;
|
|
37
59
|
padding: 2px 8px;
|
|
@@ -73,7 +95,7 @@
|
|
|
73
95
|
.ott-tag-input .ott-suggestion-list {
|
|
74
96
|
background: white;
|
|
75
97
|
max-height: 200px;
|
|
76
|
-
border: 1px solid
|
|
98
|
+
border: 1px solid var(--ott-primary-color-04);
|
|
77
99
|
border-radius: 4px;
|
|
78
100
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
|
79
101
|
overflow: auto;
|
|
@@ -84,18 +106,18 @@
|
|
|
84
106
|
cursor: pointer;
|
|
85
107
|
}
|
|
86
108
|
.ott-tag-input .ott-suggestion-list div.is-selected, .ott-tag-input .ott-suggestion-list div:hover {
|
|
87
|
-
background-color:
|
|
88
|
-
color:
|
|
109
|
+
background-color: var(--ott-primary-color-01);
|
|
110
|
+
color: var(--ott-primary-color);
|
|
89
111
|
}
|
|
90
112
|
.ott-tag-input .ott-suggestion-list div.is-empty {
|
|
91
|
-
color:
|
|
113
|
+
color: var(--ott-text-color-secondary);
|
|
92
114
|
cursor: default;
|
|
93
115
|
}
|
|
94
116
|
.ott-tag-input .ott-suggestion-list div.is-disabled {
|
|
95
|
-
color:
|
|
117
|
+
color: var(--ott-text-color-secondary);
|
|
96
118
|
cursor: not-allowed;
|
|
97
119
|
}
|
|
98
120
|
.ott-tag-input .ott-suggestion-list div.is-disabled.is-selected, .ott-tag-input .ott-suggestion-list div.is-disabled:hover {
|
|
99
121
|
background-color: transparent;
|
|
100
|
-
color:
|
|
122
|
+
color: var(--ott-text-color-secondary);
|
|
101
123
|
}
|
|
@@ -26,6 +26,7 @@ interface TagInputState {
|
|
|
26
26
|
suggestion: SuggestionState;
|
|
27
27
|
}
|
|
28
28
|
interface TagInputProps {
|
|
29
|
+
className?: string;
|
|
29
30
|
ref?: (component: TagInput) => void;
|
|
30
31
|
placeholder?: string;
|
|
31
32
|
slots?: {
|
|
@@ -104,6 +105,7 @@ export declare class TagInput extends Component<TagInputProps> {
|
|
|
104
105
|
el: HTMLElement;
|
|
105
106
|
};
|
|
106
107
|
state: TagInputState;
|
|
108
|
+
get className(): string;
|
|
107
109
|
onSuggestionSelect(event: MouseEvent, item: SuggestionItem): void;
|
|
108
110
|
updateSuggestion(props: any, options?: Partial<SuggestionState>): void;
|
|
109
111
|
/**
|
|
@@ -27,6 +27,10 @@ export class TagInput extends Component {
|
|
|
27
27
|
},
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
+
get className() {
|
|
31
|
+
const disabledClass = this.props.readonly ? 'disabled' : '';
|
|
32
|
+
return classNames('&tag-input', this.props.className, disabledClass);
|
|
33
|
+
}
|
|
30
34
|
onSuggestionSelect(event, item) {
|
|
31
35
|
this.props.onSuggestionSelect?.(event, item);
|
|
32
36
|
if (!event.cancelBubble) {
|
|
@@ -57,7 +61,12 @@ export class TagInput extends Component {
|
|
|
57
61
|
* @returns {object} The content as a JSON object.
|
|
58
62
|
*/
|
|
59
63
|
getContent() {
|
|
60
|
-
|
|
64
|
+
const json = this.state.editor.getJSON();
|
|
65
|
+
const { content } = json;
|
|
66
|
+
if (content.length === 1 && content[0].type === 'paragraph' && !content[0].content) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return json;
|
|
61
70
|
}
|
|
62
71
|
/**
|
|
63
72
|
* Deserializes content into the editor.
|
|
@@ -185,7 +194,7 @@ export class TagInput extends Component {
|
|
|
185
194
|
},
|
|
186
195
|
onUpdate: ({ editor, transaction }) => {
|
|
187
196
|
if (transaction.docChanged) {
|
|
188
|
-
this.props.onChange?.(
|
|
197
|
+
this.props.onChange?.(this.getContent());
|
|
189
198
|
}
|
|
190
199
|
},
|
|
191
200
|
}));
|
|
@@ -228,7 +237,7 @@ TagInput.props = {
|
|
|
228
237
|
char: { type: String, optional: true },
|
|
229
238
|
};
|
|
230
239
|
TagInput.template = xml `
|
|
231
|
-
<div
|
|
240
|
+
<div t-att-class="className">
|
|
232
241
|
<div t-ref="editor"/>
|
|
233
242
|
<div t-if="state.suggestion.visible" t-att-style="state.suggestion.style" class="ott-suggestion-list-wrapper">
|
|
234
243
|
<SuggestionList
|
|
@@ -48,9 +48,11 @@ export const TagNode = Node.create({
|
|
|
48
48
|
});
|
|
49
49
|
dom.setAttribute('data-type', 'tag');
|
|
50
50
|
dom.classList.add('tag'); // Add a class for styling
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
if (!readonly) {
|
|
52
|
+
dom.addEventListener('click', () => {
|
|
53
|
+
this.options.onTagClick(node.attrs, getPos());
|
|
54
|
+
});
|
|
55
|
+
}
|
|
54
56
|
const labelSpan = document.createElement('span');
|
|
55
57
|
labelSpan.textContent = label; // Set the visible text
|
|
56
58
|
dom.appendChild(labelSpan);
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/package.json
CHANGED