@ones-editor/editor 2.2.14-beta.7 → 2.2.14-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -20,7 +20,7 @@ export declare class TextColorItem extends TypedEmitter<ColorPaletteEvents> impl
|
|
|
20
20
|
latestColors: Colors;
|
|
21
21
|
private currentTextColors;
|
|
22
22
|
constructor(editor: OnesEditor, storageName?: string);
|
|
23
|
-
|
|
23
|
+
updateLatestColorFromCache(): Colors;
|
|
24
24
|
destroy(): void;
|
|
25
25
|
handlePaletteClick: (type: ColorAction, value: number) => void;
|
|
26
26
|
handleButtonClick: (event: MouseEvent) => void;
|
package/dist/index.js
CHANGED
|
@@ -41846,6 +41846,7 @@ ${codeText}
|
|
|
41846
41846
|
}
|
|
41847
41847
|
const textColorItem = "";
|
|
41848
41848
|
const DEFAULT_BG_COLOR = 2;
|
|
41849
|
+
const NULLABLE_COLOR = -1;
|
|
41849
41850
|
class TextColorItem extends tinyTypedEmitter.TypedEmitter {
|
|
41850
41851
|
constructor(editor, storageName = "color-item") {
|
|
41851
41852
|
super();
|
|
@@ -41903,16 +41904,15 @@ ${codeText}
|
|
|
41903
41904
|
this.latestColors[0] = null;
|
|
41904
41905
|
} else if (value === ColorClearActions.clearBackground) {
|
|
41905
41906
|
this.latestColors[1] = null;
|
|
41906
|
-
}
|
|
41907
|
-
|
|
41908
|
-
if (value === ColorClearActions.clearColor || value === ColorClearActions.clearBackground) {
|
|
41909
|
-
if (this.latestColors.every((color) => color === null)) {
|
|
41910
|
-
this.latestColors[1] = DEFAULT_BG_COLOR;
|
|
41907
|
+
} else {
|
|
41908
|
+
this.latestColors = [null, null];
|
|
41911
41909
|
}
|
|
41912
41910
|
}
|
|
41913
41911
|
this.setCurrentButtonColor(this.latestColors);
|
|
41914
|
-
|
|
41915
|
-
|
|
41912
|
+
const colorIdx = (_a = this.latestColors[0]) != null ? _a : NULLABLE_COLOR;
|
|
41913
|
+
const bgColorIdx = (_b = this.latestColors[1]) != null ? _b : NULLABLE_COLOR;
|
|
41914
|
+
this.editor.settingsProvider.setItem(`${this.storageName}-color`, `${colorIdx}`);
|
|
41915
|
+
this.editor.settingsProvider.setItem(`${this.storageName}-backgroundColor`, `${bgColorIdx}`);
|
|
41916
41916
|
});
|
|
41917
41917
|
__publicField(this, "beforePopup", () => {
|
|
41918
41918
|
this.updatePaletteColor();
|
|
@@ -41925,24 +41925,24 @@ ${codeText}
|
|
|
41925
41925
|
this.children.push(this.colorPaletteItem);
|
|
41926
41926
|
this.element = createColorButton();
|
|
41927
41927
|
this.element.addEventListener("click", this.handleButtonClick);
|
|
41928
|
-
const existColors = this.getColorsFromLocalStorage();
|
|
41929
|
-
this.latestColors = existColors;
|
|
41930
|
-
this.setCurrentButtonColor(this.latestColors);
|
|
41931
41928
|
this.element.setAttribute(`data-editor-tooltip-${editor.clientId}`, this.name);
|
|
41932
41929
|
}
|
|
41933
|
-
|
|
41934
|
-
const colors = [null, null];
|
|
41930
|
+
updateLatestColorFromCache() {
|
|
41935
41931
|
const color = Number.parseInt(this.editor.settingsProvider.getItem(`${this.storageName}-color`) || "", 10);
|
|
41936
41932
|
const backgroundColor = Number.parseInt(this.editor.settingsProvider.getItem(`${this.storageName}-backgroundColor`) || "", 10);
|
|
41933
|
+
if ([color, backgroundColor].every(Number.isNaN)) {
|
|
41934
|
+
const defaultColors = [null, DEFAULT_BG_COLOR];
|
|
41935
|
+
this.latestColors = defaultColors;
|
|
41936
|
+
return defaultColors;
|
|
41937
|
+
}
|
|
41938
|
+
const colors = [null, null];
|
|
41937
41939
|
if (!Number.isNaN(color)) {
|
|
41938
|
-
colors[0] = color;
|
|
41940
|
+
colors[0] = color === NULLABLE_COLOR ? null : color;
|
|
41939
41941
|
}
|
|
41940
41942
|
if (!Number.isNaN(backgroundColor)) {
|
|
41941
|
-
colors[1] = backgroundColor;
|
|
41942
|
-
}
|
|
41943
|
-
if (colors.every((c) => c === null)) {
|
|
41944
|
-
colors[1] = DEFAULT_BG_COLOR;
|
|
41943
|
+
colors[1] = backgroundColor === NULLABLE_COLOR ? null : backgroundColor;
|
|
41945
41944
|
}
|
|
41945
|
+
this.latestColors = colors;
|
|
41946
41946
|
return colors;
|
|
41947
41947
|
}
|
|
41948
41948
|
destroy() {
|
|
@@ -41951,8 +41951,9 @@ ${codeText}
|
|
|
41951
41951
|
this.removeAllListeners();
|
|
41952
41952
|
}
|
|
41953
41953
|
updatePaletteColor() {
|
|
41954
|
-
|
|
41955
|
-
this.colorPaletteItem.palette.setColor("
|
|
41954
|
+
const [color, backgroundColor] = this.latestColors;
|
|
41955
|
+
this.colorPaletteItem.palette.setColor("color", color);
|
|
41956
|
+
this.colorPaletteItem.palette.setColor("backgroundColor", backgroundColor);
|
|
41956
41957
|
}
|
|
41957
41958
|
setCurrentTextColors(colors) {
|
|
41958
41959
|
this.currentTextColors = colors;
|
|
@@ -60588,7 +60589,7 @@ $$${mathData.mathjaxText}$$
|
|
|
60588
60589
|
__publicField(this, "updateButtonColor", (range) => {
|
|
60589
60590
|
const currentTextColor = editorRangeGetColor(this.editor, range, this.getEmptyTextBlockColor);
|
|
60590
60591
|
this.colorItem.setCurrentTextColors(currentTextColor);
|
|
60591
|
-
const lastButtonColor = this.colorItem.
|
|
60592
|
+
const lastButtonColor = this.colorItem.updateLatestColorFromCache();
|
|
60592
60593
|
this.colorItem.setCurrentButtonColor(lastButtonColor);
|
|
60593
60594
|
});
|
|
60594
60595
|
__publicField(this, "setActiveAttribute", (type, value) => {
|
|
@@ -88830,7 +88831,7 @@ ${data2.plantumlText}
|
|
|
88830
88831
|
}
|
|
88831
88832
|
}
|
|
88832
88833
|
});
|
|
88833
|
-
editor.version = "2.2.14-beta.
|
|
88834
|
+
editor.version = "2.2.14-beta.8";
|
|
88834
88835
|
return editor;
|
|
88835
88836
|
}
|
|
88836
88837
|
function isDoc(doc2) {
|
|
@@ -88931,7 +88932,7 @@ ${data2.plantumlText}
|
|
|
88931
88932
|
});
|
|
88932
88933
|
editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
|
|
88933
88934
|
OnesEditorToolbar.register(editor);
|
|
88934
|
-
editor.version = "2.2.14-beta.
|
|
88935
|
+
editor.version = "2.2.14-beta.8";
|
|
88935
88936
|
return editor;
|
|
88936
88937
|
}
|
|
88937
88938
|
async function showDocVersions(editor, options, serverUrl) {
|