jedison 1.18.0 → 1.19.0
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.
- package/CHANGELOG.md +5 -0
- package/dist/cjs/jedison.cjs +1 -1
- package/dist/cjs/jedison.cjs.map +1 -1
- package/dist/esm/jedison.js +74 -0
- package/dist/esm/jedison.js.map +1 -1
- package/dist/umd/jedison.umd.js +1 -1
- package/dist/umd/jedison.umd.js.map +1 -1
- package/package.json +7 -3
package/dist/esm/jedison.js
CHANGED
|
@@ -6049,6 +6049,79 @@ class EditorStringSimpleMDE extends EditorString {
|
|
|
6049
6049
|
super.destroy();
|
|
6050
6050
|
}
|
|
6051
6051
|
}
|
|
6052
|
+
class EditorStringMilkdown extends EditorString {
|
|
6053
|
+
static resolves(schema) {
|
|
6054
|
+
const format2 = getSchemaXOption(schema, "format");
|
|
6055
|
+
return isSet(format2) && format2 === "milkdown" && window.Milkdown && window.Milkdown.Crepe && getSchemaType(schema) === "string";
|
|
6056
|
+
}
|
|
6057
|
+
build() {
|
|
6058
|
+
this.control = this.theme.getPlaceholderControl({
|
|
6059
|
+
title: this.getTitle(),
|
|
6060
|
+
description: this.getDescription(),
|
|
6061
|
+
id: this.getIdFromPath(this.instance.path),
|
|
6062
|
+
titleIconClass: getSchemaXOption(this.instance.schema, "titleIconClass"),
|
|
6063
|
+
titleHidden: getSchemaXOption(this.instance.schema, "titleHidden"),
|
|
6064
|
+
info: this.getInfo()
|
|
6065
|
+
});
|
|
6066
|
+
this.mounted = false;
|
|
6067
|
+
try {
|
|
6068
|
+
const milkdownOptions = getSchemaXOption(this.instance.schema, "milkdown") ?? {};
|
|
6069
|
+
const { Crepe } = window.Milkdown;
|
|
6070
|
+
this.crepe = new Crepe({
|
|
6071
|
+
...milkdownOptions,
|
|
6072
|
+
root: this.control.placeholder,
|
|
6073
|
+
defaultValue: this.instance.getValue() ?? ""
|
|
6074
|
+
});
|
|
6075
|
+
this.crepe.on((api) => {
|
|
6076
|
+
api.markdownUpdated((ctx, markdown) => {
|
|
6077
|
+
if (markdown !== this.instance.getValue()) {
|
|
6078
|
+
this.syncingFromEditor = true;
|
|
6079
|
+
this.instance.setValue(markdown, true, "user");
|
|
6080
|
+
this.syncingFromEditor = false;
|
|
6081
|
+
}
|
|
6082
|
+
});
|
|
6083
|
+
});
|
|
6084
|
+
this.crepe.create().then(() => {
|
|
6085
|
+
this.mounted = true;
|
|
6086
|
+
this.refreshDisabledState();
|
|
6087
|
+
}).catch((e) => console.error("Milkdown failed to mount.", e));
|
|
6088
|
+
} catch (e) {
|
|
6089
|
+
console.error("Milkdown is not available or not loaded correctly.", e);
|
|
6090
|
+
}
|
|
6091
|
+
}
|
|
6092
|
+
adaptForHorizontal(labelCol, inputCol) {
|
|
6093
|
+
this.theme.adaptForHorizontalInputControl(this.control, labelCol, inputCol);
|
|
6094
|
+
}
|
|
6095
|
+
addEventListeners() {
|
|
6096
|
+
}
|
|
6097
|
+
refreshDisabledState() {
|
|
6098
|
+
if (this.crepe && this.mounted) {
|
|
6099
|
+
this.crepe.setReadonly(this.disabled || this.readOnly);
|
|
6100
|
+
}
|
|
6101
|
+
}
|
|
6102
|
+
refreshUI() {
|
|
6103
|
+
super.refreshUI();
|
|
6104
|
+
if (!this.crepe || !this.mounted || this.syncingFromEditor) {
|
|
6105
|
+
return;
|
|
6106
|
+
}
|
|
6107
|
+
const value = this.instance.getValue() ?? "";
|
|
6108
|
+
if (value !== this.crepe.getMarkdown()) {
|
|
6109
|
+
try {
|
|
6110
|
+
const { replaceAll: replaceAll2 } = window.Milkdown;
|
|
6111
|
+
this.crepe.editor.action(replaceAll2(value));
|
|
6112
|
+
} catch (e) {
|
|
6113
|
+
console.error("Milkdown could not apply the updated value.", e);
|
|
6114
|
+
}
|
|
6115
|
+
}
|
|
6116
|
+
}
|
|
6117
|
+
destroy() {
|
|
6118
|
+
if (this.crepe) {
|
|
6119
|
+
this.crepe.destroy().catch(() => {
|
|
6120
|
+
});
|
|
6121
|
+
}
|
|
6122
|
+
super.destroy();
|
|
6123
|
+
}
|
|
6124
|
+
}
|
|
6052
6125
|
class EditorStringQuill extends EditorString {
|
|
6053
6126
|
static resolves(schema) {
|
|
6054
6127
|
const format2 = getSchemaXOption(schema, "format");
|
|
@@ -6877,6 +6950,7 @@ class UiResolver {
|
|
|
6877
6950
|
EditorStringAwesomplete,
|
|
6878
6951
|
EditorStringEmojiButton,
|
|
6879
6952
|
EditorStringSimpleMDE,
|
|
6953
|
+
EditorStringMilkdown,
|
|
6880
6954
|
EditorStringQuill,
|
|
6881
6955
|
EditorStringJodit,
|
|
6882
6956
|
EditorStringPickr,
|