fix and update ColorView.openPopup()
This commit is contained in:
parent
ce8a0a2d42
commit
352846c8b4
|
@ -397,25 +397,18 @@
|
||||||
this.cm.state.colorpicker = null;
|
this.cm.state.colorpicker = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
openPopup(defaultColor = '#FFFFFF') {
|
openPopup(color) {
|
||||||
const cursor = this.cm.getCursor();
|
let {line, ch} = this.cm.getCursor();
|
||||||
const data = {
|
const lineText = this.cm.getLine(line);
|
||||||
line: cursor.line,
|
ch -= (lineText.lastIndexOf('!important', ch) >= ch - '!important'.length) ? '!important'.length : 0;
|
||||||
ch: cursor.ch,
|
const lineCache = this.cm.state.colorpicker.cache.get(lineText);
|
||||||
color: defaultColor,
|
const data = {line, ch, color, isShortCut: true};
|
||||||
isShortCut: true,
|
for (const [start, {color, colorValue}] of lineCache && lineCache.entries() || []) {
|
||||||
};
|
if (start <= ch && ch <= start + color.length) {
|
||||||
for (const {from, marker} of this.cm.getLineHandle(cursor.line).markedSpans || []) {
|
Object.assign(data, {ch: start, color, colorValue});
|
||||||
if (from <= data.ch && (marker.replacedWith || {}).colorpickerData) {
|
|
||||||
const {color, colorValue} = marker.replacedWith.colorpickerData;
|
|
||||||
if (data.ch <= from + color.length) {
|
|
||||||
data.ch = from;
|
|
||||||
data.color = color;
|
|
||||||
data.colorValue = colorValue;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this.openPopupForToken({colorpickerData: data});
|
this.openPopupForToken({colorpickerData: data});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,8 +419,8 @@
|
||||||
top,
|
top,
|
||||||
left,
|
left,
|
||||||
cm: this.cm,
|
cm: this.cm,
|
||||||
color: data.colorValue || data.color,
|
color: data.colorValue || data.color || '#fff',
|
||||||
prevColor: data.color,
|
prevColor: data.color || '',
|
||||||
isShortCut: false,
|
isShortCut: false,
|
||||||
callback: ColorMarker.popupOnChange,
|
callback: ColorMarker.popupOnChange,
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user