Skip to content

Commit 4475a57

Browse files
author
Katochimoto
committed
https://github.com/Katochimoto/x-bubbles/issues/11
1 parent 89a00bf commit 4475a57

15 files changed

+268
-33
lines changed

dist/x-bubbles-compact.js

+80-3
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,20 @@ var XBubbles =
4747

4848
'use strict';
4949

50+
/**
51+
* XBubbles custom element.
52+
* @module x-bubbles
53+
*/
54+
5055
var context = __webpack_require__(1);
5156
var editor = __webpack_require__(2);
5257
var utils = __webpack_require__(6);
5358
var options = __webpack_require__(36);
5459

60+
/**
61+
* Prototype of XBubbles.
62+
* @type {Object}
63+
*/
5564
var XBubbles = Object.create(HTMLDivElement.prototype, {
5665
createdCallback: {
5766
value: function value() {
@@ -79,48 +88,109 @@ var XBubbles =
7988
}
8089
},
8190

91+
/**
92+
* The receiving and recording settings.
93+
* @memberof XBubbles
94+
* @function
95+
* @param {string} name
96+
* @param {*} value
97+
* @returns {*}
98+
* @public
99+
*/
82100
options: {
83101
value: function value(name, _value) {
84102
return options(this, name, _value);
85103
}
86104
},
87105

106+
/**
107+
* List bablow.
108+
* @memberof XBubbles
109+
* @type {array}
110+
* @public
111+
*/
88112
items: {
89113
get: function get() {
90114
return this.editor.getItems();
91115
}
92116
},
93117

118+
/**
119+
* The value entered.
120+
* @memberof XBubbles
121+
* @type {string}
122+
* @public
123+
*/
94124
inputValue: {
95125
get: function get() {
96126
return this.editor.inputValue();
97127
}
98128
},
99129

130+
/**
131+
* Set contents of the set.
132+
* @function
133+
* @memberof XBubbles
134+
* @param {string} data
135+
* @returns {boolean}
136+
* @public
137+
*/
100138
setContent: {
101139
value: function value(data) {
102140
return this.editor.setContent(data);
103141
}
104142
},
105143

144+
/**
145+
* Add bubble.
146+
* @function
147+
* @memberof XBubbles
148+
* @param {string} bubbleText
149+
* @param {Object} [data]
150+
* @returns {boolean}
151+
* @public
152+
*/
106153
addBubble: {
107154
value: function value(bubbleText, data) {
108155
return this.editor.addBubble(bubbleText, data);
109156
}
110157
},
111158

159+
/**
160+
* Remove bubble.
161+
* @function
162+
* @memberof XBubbles
163+
* @param {HTMLElement} nodeBubble
164+
* @returns {boolean}
165+
* @public
166+
*/
112167
removeBubble: {
113168
value: function value(nodeBubble) {
114169
return this.editor.removeBubble(nodeBubble);
115170
}
116171
},
117172

173+
/**
174+
* Edit bubble.
175+
* @function
176+
* @memberof XBubbles
177+
* @param {HTMLElement} nodeBubble
178+
* @returns {boolean}
179+
* @public
180+
*/
118181
editBubble: {
119182
value: function value(nodeBubble) {
120183
return this.editor.editBubble(nodeBubble);
121184
}
122185
},
123186

187+
/**
188+
* Starting formation bablow.
189+
* @function
190+
* @memberof XBubbles
191+
* @returns {boolean}
192+
* @public
193+
*/
124194
bubbling: {
125195
value: function value() {
126196
return this.editor.bubbling();
@@ -283,6 +353,8 @@ var XBubbles =
283353
this.appendChild(this.ownerDocument.createTextNode(data));
284354
bubble.bubbling(this);
285355
cursor.restore(this);
356+
357+
return true;
286358
}
287359

288360
function addBubble(bubbleText, dataAttributes) {
@@ -3009,9 +3081,13 @@ var XBubbles =
30093081
} else {
30103082
var separator = nodeEditor.options('separator');
30113083
if (separator && separator.test(String.fromCharCode(code))) {
3012-
event.preventDefault();
3013-
bubble.bubbling(nodeEditor);
3014-
cursor.restore(nodeEditor);
3084+
var separatorCond = nodeEditor.options('separatorCond');
3085+
3086+
if (!separatorCond || separatorCond(nodeEditor.inputValue)) {
3087+
event.preventDefault();
3088+
bubble.bubbling(nodeEditor);
3089+
cursor.restore(nodeEditor);
3090+
}
30153091
}
30163092
}
30173093
};
@@ -3562,6 +3638,7 @@ var XBubbles =
35623638
ending: ['reg', null, 'ending'], // /\@ya\.ru/g
35633639
selection: ['bool', true, 'selection'],
35643640
separator: ['reg', /[,;]/, 'separator'],
3641+
separatorCond: ['func', null, 'separator-cond'],
35653642
tokenizer: ['func', null, 'tokenizer']
35663643
};
35673644

dist/x-bubbles-compact.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/x-bubbles-compact.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/x-bubbles.js

+80-3
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,20 @@ var XBubbles =
4747

4848
'use strict';
4949

50+
/**
51+
* XBubbles custom element.
52+
* @module x-bubbles
53+
*/
54+
5055
var context = __webpack_require__(1);
5156
var editor = __webpack_require__(2);
5257
var utils = __webpack_require__(6);
5358
var options = __webpack_require__(36);
5459

60+
/**
61+
* Prototype of XBubbles.
62+
* @type {Object}
63+
*/
5564
var XBubbles = Object.create(HTMLDivElement.prototype, {
5665
createdCallback: {
5766
value: function value() {
@@ -79,48 +88,109 @@ var XBubbles =
7988
}
8089
},
8190

91+
/**
92+
* The receiving and recording settings.
93+
* @memberof XBubbles
94+
* @function
95+
* @param {string} name
96+
* @param {*} value
97+
* @returns {*}
98+
* @public
99+
*/
82100
options: {
83101
value: function value(name, _value) {
84102
return options(this, name, _value);
85103
}
86104
},
87105

106+
/**
107+
* List bablow.
108+
* @memberof XBubbles
109+
* @type {array}
110+
* @public
111+
*/
88112
items: {
89113
get: function get() {
90114
return this.editor.getItems();
91115
}
92116
},
93117

118+
/**
119+
* The value entered.
120+
* @memberof XBubbles
121+
* @type {string}
122+
* @public
123+
*/
94124
inputValue: {
95125
get: function get() {
96126
return this.editor.inputValue();
97127
}
98128
},
99129

130+
/**
131+
* Set contents of the set.
132+
* @function
133+
* @memberof XBubbles
134+
* @param {string} data
135+
* @returns {boolean}
136+
* @public
137+
*/
100138
setContent: {
101139
value: function value(data) {
102140
return this.editor.setContent(data);
103141
}
104142
},
105143

144+
/**
145+
* Add bubble.
146+
* @function
147+
* @memberof XBubbles
148+
* @param {string} bubbleText
149+
* @param {Object} [data]
150+
* @returns {boolean}
151+
* @public
152+
*/
106153
addBubble: {
107154
value: function value(bubbleText, data) {
108155
return this.editor.addBubble(bubbleText, data);
109156
}
110157
},
111158

159+
/**
160+
* Remove bubble.
161+
* @function
162+
* @memberof XBubbles
163+
* @param {HTMLElement} nodeBubble
164+
* @returns {boolean}
165+
* @public
166+
*/
112167
removeBubble: {
113168
value: function value(nodeBubble) {
114169
return this.editor.removeBubble(nodeBubble);
115170
}
116171
},
117172

173+
/**
174+
* Edit bubble.
175+
* @function
176+
* @memberof XBubbles
177+
* @param {HTMLElement} nodeBubble
178+
* @returns {boolean}
179+
* @public
180+
*/
118181
editBubble: {
119182
value: function value(nodeBubble) {
120183
return this.editor.editBubble(nodeBubble);
121184
}
122185
},
123186

187+
/**
188+
* Starting formation bablow.
189+
* @function
190+
* @memberof XBubbles
191+
* @returns {boolean}
192+
* @public
193+
*/
124194
bubbling: {
125195
value: function value() {
126196
return this.editor.bubbling();
@@ -283,6 +353,8 @@ var XBubbles =
283353
this.appendChild(this.ownerDocument.createTextNode(data));
284354
bubble.bubbling(this);
285355
cursor.restore(this);
356+
357+
return true;
286358
}
287359

288360
function addBubble(bubbleText, dataAttributes) {
@@ -3891,9 +3963,13 @@ var XBubbles =
38913963
} else {
38923964
var separator = nodeEditor.options('separator');
38933965
if (separator && separator.test(String.fromCharCode(code))) {
3894-
event.preventDefault();
3895-
bubble.bubbling(nodeEditor);
3896-
cursor.restore(nodeEditor);
3966+
var separatorCond = nodeEditor.options('separatorCond');
3967+
3968+
if (!separatorCond || separatorCond(nodeEditor.inputValue)) {
3969+
event.preventDefault();
3970+
bubble.bubbling(nodeEditor);
3971+
cursor.restore(nodeEditor);
3972+
}
38973973
}
38983974
}
38993975
};
@@ -4444,6 +4520,7 @@ var XBubbles =
44444520
ending: ['reg', null, 'ending'], // /\@ya\.ru/g
44454521
selection: ['bool', true, 'selection'],
44464522
separator: ['reg', /[,;]/, 'separator'],
4523+
separatorCond: ['func', null, 'separator-cond'],
44474524
tokenizer: ['func', null, 'tokenizer']
44484525
};
44494526

dist/x-bubbles.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/x-bubbles.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)