mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-24 05:03:44 +00:00
bringing over fixes from application textbox
This commit is contained in:
parent
deecc9df4c
commit
5824a48268
3 changed files with 2 additions and 35 deletions
1
build.js
1
build.js
|
|
@ -247,7 +247,6 @@ var filesToInclude = [
|
|||
ifSpecifiedInclude('textbox', 'src/shapes/textbox.class.js'),
|
||||
ifSpecifiedInclude('textbox', 'src/mixins/textbox_behavior.mixin.js'),
|
||||
ifSpecifiedInclude('textbox', 'src/mixins/textbox_click_behavior.mixin.js'),
|
||||
ifSpecifiedInclude('textbox', 'src/mixins/textbox_key_behavior.mixin.js'),
|
||||
|
||||
ifSpecifiedInclude('node', 'src/node.js'),
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
fabric.util.object.extend(fabric.Textbox.prototype, /** @lends fabric.Textbox.prototype */ {
|
||||
/**
|
||||
* Overrides superclass function and adjusts cursor offset value because
|
||||
* lines do not necessarily end with a newline in Textbox.
|
||||
*
|
||||
* @param {Event} e
|
||||
* @param {Boolean} isRight
|
||||
* @returns {Number}
|
||||
*/
|
||||
getDownCursorOffset: function (e, isRight) {
|
||||
var current = this.selectionStart,
|
||||
offset = fabric.IText.prototype.getDownCursorOffset.apply(this, [e, isRight]),
|
||||
nextNewline = this.text.indexOf('\n', current);
|
||||
|
||||
return nextNewline >= current && nextNewline <= current + offset ? offset : offset - 1;
|
||||
},
|
||||
/**
|
||||
* Overrides superclass function and adjusts cursor offset value because
|
||||
* lines do not necessarily end with a newline in Textbox.
|
||||
*
|
||||
* @param {Event} e
|
||||
* @param {Boolean} isRight
|
||||
* @returns {Number}
|
||||
*/
|
||||
getUpCursorOffset: function (e, isRight) {
|
||||
var current = this.selectionStart,
|
||||
offset = fabric.IText.prototype.getUpCursorOffset.apply(this, [e, isRight]),
|
||||
previousNewLine = this.text.indexOf('\n', current - offset);
|
||||
|
||||
return previousNewLine >= current - offset && previousNewLine <= current ? offset : offset - 1;
|
||||
}
|
||||
});
|
||||
|
|
@ -284,7 +284,7 @@
|
|||
lineWidth = line === '' ? wordWidth : this._measureText(ctx, line + words[0], lineIndex, offset);
|
||||
|
||||
if (Math.ceil(lineWidth) < maxWidth || (line === '' && Math.ceil(wordWidth) >= maxWidth)) {
|
||||
line += words.shift() + ' ';
|
||||
line += (line === '' ? '' : ' ') + words.shift();
|
||||
}
|
||||
else {
|
||||
offset += line.length;
|
||||
|
|
@ -293,7 +293,7 @@
|
|||
}
|
||||
|
||||
if (words.length === 0) {
|
||||
lines.push(line.substring(0, line.length - 1));
|
||||
lines.push(line);
|
||||
}
|
||||
|
||||
// keep track of largest word
|
||||
|
|
|
|||
Loading…
Reference in a new issue