<commit_before>
import CONST from '../canvas-const.js';

var editorHeight = 30;
var editor, canvas;

class TextTool {
    constructor(canvasWrapper, eventAggregator) {
        canvas = canvasWrapper.canvas;
        eventAggregator.subscribeTo(CONST.TOOL.TEXT, 'TextTool', textTool);
        eventAggregator.subscribeTo('keydown', 'TextTool', function(topic, sender, keyCode) {
            if (keyCode === 27) {
                abort();
            }
        });
    
        function notify(message) {
            eventAggregator.notify('TOOL_USAGE', CONST.TOOL.TEXT, message);
        }
        
        function abort() {
            if (editor) {
                canvas.remove(editor);
                editor = undefined;
                notify('inactive');
            }
        }
        function textTool(topic, sender, payload) {
            console.log('TEXT', payload);
            if (payload!=='toolbar-click') {
                abort();
                return;
            }
            notify('active');
            editor = new fabric.IText('Click to leave a comment', {
                fontFamily: 'arial black',
                fontSize: 18,
                left: 100,
                top: -40,<commit_msg>WIP with scope isolation of the tools<commit_after>import CONST from '../canvas-const.js';

var editorHeight = 30;

class TextTool {
    constructor(canvasWrapper, eventAggregator) {
        var canvas = canvasWrapper.canvas;
        var editor;
        eventAggregator.subscribeTo(CONST.TOOL.TEXT, 'TextTool', textTool);
        eventAggregator.subscribeTo('keydown', 'TextTool', function(topic, sender, keyCode) {
            if (keyCode === 27) {
                abort();
            }
        });
    
        function notify(message) {
            eventAggregator.notify('TOOL_USAGE', CONST.TOOL.TEXT, message);
        }
        
        function abort() {
            if (editor) {
                canvas.remove(editor);
                editor = undefined;
                notify('inactive');
            }
        }
        function textTool(topic, sender, payload) {
            console.log('TEXT', payload);
            if (payload!=='toolbar-click') {
                abort();
                return;
            }
            notify('active');
            editor = new fabric.IText('Click to leave a comment', {
                fontFamily: 'arial black',
                fontSize: 18,
                left: 100,
                top: -40,
{'fraction_non_alphanumeric': 0.11371914204775395, 'fraction_numerical': 0.008903278025091057, 'mean_word_length': 1.5432098765432098, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7619202', 'n_tokens_mistral': 665, 'n_tokens_neox': 626, 'n_words': 142}