Skip to content

Commit

Permalink
chore(TS): extract const reNonWord from HEADER (#8197)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrea Bogazzi <andreabogazzi79@gmail.com>
  • Loading branch information
ShaMan123 and asturur authored Aug 28, 2022
1 parent cd69a80 commit 5ead2d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 0 additions & 4 deletions HEADER.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ fabric.SHARED_ATTRIBUTES = [
/* _FROM_SVG_END_ */


fabric.reNonWord = /[ \n\.,;!\?\-]/;



/**
* @todo move to config when window is exported
*/
Expand Down
7 changes: 4 additions & 3 deletions src/mixins/itext_behavior.mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import { Point } from '../point.class';
import { removeFromArray } from '../util/internals';

// extend this regex to support non english languages
const reNonWord = /[ \n\.,;!\?\-]/;

(function(global) {
var fabric = global.fabric;
fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.prototype */ {
Expand Down Expand Up @@ -288,9 +291,7 @@ import { removeFromArray } from '../util/internals';
searchWordBoundary: function(selectionStart, direction) {
var text = this._text,
index = this._reSpace.test(text[selectionStart]) ? selectionStart - 1 : selectionStart,
_char = text[index],
// wrong
reNonWord = fabric.reNonWord;
_char = text[index];

while (!reNonWord.test(_char) && index > 0 && index < text.length) {
index += direction;
Expand Down

0 comments on commit 5ead2d6

Please sign in to comment.