Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import Handsontable from 'handsontable';
import { getDisplayValue } from '../common';
const { getCaretPosition, getSelectionEndPosition, setCaretPosition } = Handsontable.dom;
class KeyValueEditor extends Handsontable.editors.AutocompleteEditor {
prepare(row, col, prop, td, originalValue, cellProperties, ...args) {
super.prepare(row, col, prop, td, originalValue, cellProperties, ...args);
this.cellProperties.strict = true; // Force strict mode (key-value context)
}
getValue() {
const selection = this.htEditor.getSelectedLast();
if (selection) {
return this.htEditor.getSourceDataAtRow(selection[0])[this.cellProperties.keyProperty];
}
}
setValue(value) {
renderer(instance, td, row, col, prop, value) {
if (instance.isEmptyRow(row)) {
td.innerHTML = null;
return td;
}
const { members } = instance.getSettings();
if (!members) {
td.innerHTML = null;
return td;
}
const assingedUser = members[members.findIndex(member => member.uid === value)];
td.className = 'htCenter htMiddle';
td.style.paddingTop = '5px';
Handsontable.dom.empty(td);
const img = document.createElement('IMG');
img.style.width = '25px';
img.style.height = '25px';
img.style.borderRadius = '50%';
if (assingedUser) {
img.src = assingedUser.photoURL || person;
} else {
img.src = value ? unknown : logoMini; // unknownは削除されたユーザー
img.title = value ? '@unknown' : '@every';
}
if (td.parentNode.style.backgroundColor === constants.cellColor.RUNNING) {
img.style.animation = `busy 3s ${row % 3}s infinite`;
} else if (td.parentNode.style.backgroundColor === constants.cellColor.OUT) {
img.style.animation = 'help 1s infinite';
}
td.appendChild(img);
onToggleMenuClick(event) {
if (typeof event.stopPropagation === 'function') {
event.stopPropagation();
} else {
event.cancelBubble = true;
}
if (Handsontable.dom.hasClass(event.target, MENU_BUTTON_CLASS_NAME) ) {
let rect = event.target.getBoundingClientRect();
this.menu(this,event,rect);
}
}
function make_url_cell(td, text, href) {
Handsontable.dom.empty(td);
var url = make_url(text, href);
$(td).addClass('htCenter').addClass('htMiddle').append(url);
}