locize
Version:
This package adds the incontext editor to your i18next setup.
23 lines (21 loc) • 977 B
JavaScript
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
import { api } from './postMessage.js';
import { store } from '../store.js';
import { uninstrumentedStore } from '../uninstrumentedStore.js';
import { extractNodeMeta } from '../parser.js';
function handler(payload) {
if (!payload.length) return;
payload.forEach(function (item) {
var uni = uninstrumentedStore.get(item.eleUniqueID);
store.save(item.eleUniqueID, undefined, item.textType, extractNodeMeta(item.eleUniqueID, item.textType, _defineProperty({}, "".concat(item.textType), {
ns: item.ns,
key: item.key
}), item.value), uni === null || uni === void 0 ? void 0 : uni.node);
if (uni && uni.keys) delete uni.keys["".concat(item.textType)];
if (uni && uni.keys && !Object.keys(uni.keys).length) {
uninstrumentedStore.remove(item.eleUniqueID, uni.node);
}
});
api.sendCurrentParsedContent();
}
api.addHandler('sendMatchedUninstrumented', handler);