Repository URL to install this package:
|
Version:
3.1.7 ▾
|
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.runtime = exports.declaration = void 0;
const CommandService_1 = require("@joplin/lib/services/CommandService");
const bridge_1 = require("../services/bridge");
const dom_1 = require("@joplin/lib/dom");
exports.declaration = {
name: 'replaceMisspelling',
};
const runtime = () => {
return {
execute: (context, suggestion) => __awaiter(void 0, void 0, void 0, function* () {
const state = context.state;
const modalDialogVisible = !!Object.keys(state.visibleDialogs).length;
// If we're inside one of the editors, we need to use their own
// replaceSelection command to set the suggested word. Outside of
// it, we can use the Chrome built-in replaceMisspelling function,
// which will work in any standard text input.
const activeElement = document.activeElement;
if (!modalDialogVisible && ((0, dom_1.isInsideContainer)(activeElement, 'codeMirrorEditor') || (0, dom_1.isInsideContainer)(activeElement, 'tox-edit-area__iframe'))) {
yield CommandService_1.default.instance().execute('replaceSelection', suggestion);
}
else {
(0, bridge_1.default)().window().webContents.replaceMisspelling(suggestion);
}
}),
};
};
exports.runtime = runtime;
//# sourceMappingURL=replaceMisspelling.js.map