@jvs-milkdown/crepe 1.2.28 → 1.2.30
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/lib/cjs/builder.js +2 -1
- package/lib/cjs/builder.js.map +1 -1
- package/lib/cjs/feature/code-mirror/index.js.map +1 -1
- package/lib/cjs/feature/toolbar/index.js +84 -62
- package/lib/cjs/feature/toolbar/index.js.map +1 -1
- package/lib/cjs/index.js +1121 -988
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/builder.js +2 -1
- package/lib/esm/builder.js.map +1 -1
- package/lib/esm/feature/code-mirror/index.js.map +1 -1
- package/lib/esm/feature/toolbar/index.js +84 -62
- package/lib/esm/feature/toolbar/index.js.map +1 -1
- package/lib/esm/index.js +1143 -1010
- package/lib/esm/index.js.map +1 -1
- package/lib/theme/common/image-block.css +5 -1
- package/lib/theme/common/reset.css +1 -1
- package/lib/theme/common/table.css +5 -0
- package/lib/theme/common/toolbar.css +23 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
- package/lib/types/feature/fixed-toolbar/component.d.ts +2 -2
- package/lib/types/feature/fixed-toolbar/component.d.ts.map +1 -1
- package/lib/types/feature/fixed-toolbar/index.d.ts +2 -0
- package/lib/types/feature/fixed-toolbar/index.d.ts.map +1 -1
- package/lib/types/feature/fixed-toolbar/outline-panel.d.ts.map +1 -1
- package/lib/types/feature/fixed-toolbar/view-menu-state.d.ts +3 -0
- package/lib/types/feature/fixed-toolbar/view-menu-state.d.ts.map +1 -1
- package/lib/types/feature/toolbar/component.d.ts +2 -2
- package/lib/types/feature/toolbar/component.d.ts.map +1 -1
- package/lib/types/feature/toolbar/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/feature/code-mirror/index.ts +51 -46
- package/src/feature/fixed-toolbar/component.tsx +203 -110
- package/src/feature/fixed-toolbar/index.ts +30 -8
- package/src/feature/fixed-toolbar/outline-panel.tsx +1 -2
- package/src/feature/fixed-toolbar/view-menu-state.ts +2 -0
- package/src/feature/toolbar/component.tsx +57 -44
- package/src/feature/toolbar/index.ts +9 -13
- package/src/theme/common/image-block.css +6 -1
- package/src/theme/common/reset.css +1 -1
- package/src/theme/common/table.css +5 -0
- package/src/theme/common/toolbar.css +30 -0
|
@@ -379,6 +379,29 @@ var CrepeFeature = /* @__PURE__ */ ((CrepeFeature2) => {
|
|
|
379
379
|
return CrepeFeature2;
|
|
380
380
|
})(CrepeFeature || {});
|
|
381
381
|
|
|
382
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
383
|
+
let _popupCount = 0;
|
|
384
|
+
function getIsAnyPopupOpen() {
|
|
385
|
+
return _popupCount > 0;
|
|
386
|
+
}
|
|
387
|
+
function addPopupChangeListener(fn) {
|
|
388
|
+
listeners.add(fn);
|
|
389
|
+
return () => listeners.delete(fn);
|
|
390
|
+
}
|
|
391
|
+
function incrementPopupCount() {
|
|
392
|
+
const wasZero = _popupCount === 0;
|
|
393
|
+
_popupCount++;
|
|
394
|
+
if (wasZero) {
|
|
395
|
+
listeners.forEach((fn) => fn());
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
function decrementPopupCount() {
|
|
399
|
+
_popupCount = Math.max(0, _popupCount - 1);
|
|
400
|
+
if (_popupCount === 0) {
|
|
401
|
+
listeners.forEach((fn) => fn());
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
382
405
|
const remarkTextColorPlugin = utils.$remark(
|
|
383
406
|
"remarkTextColor",
|
|
384
407
|
() => function() {
|
|
@@ -1036,29 +1059,6 @@ const formatPainterIcon = `
|
|
|
1036
1059
|
</svg>
|
|
1037
1060
|
`;
|
|
1038
1061
|
|
|
1039
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
1040
|
-
let _popupCount = 0;
|
|
1041
|
-
function getIsAnyPopupOpen() {
|
|
1042
|
-
return _popupCount > 0;
|
|
1043
|
-
}
|
|
1044
|
-
function addPopupChangeListener(fn) {
|
|
1045
|
-
listeners.add(fn);
|
|
1046
|
-
return () => listeners.delete(fn);
|
|
1047
|
-
}
|
|
1048
|
-
function incrementPopupCount() {
|
|
1049
|
-
const wasZero = _popupCount === 0;
|
|
1050
|
-
_popupCount++;
|
|
1051
|
-
if (wasZero) {
|
|
1052
|
-
listeners.forEach((fn) => fn());
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
function decrementPopupCount() {
|
|
1056
|
-
_popupCount = Math.max(0, _popupCount - 1);
|
|
1057
|
-
if (_popupCount === 0) {
|
|
1058
|
-
listeners.forEach((fn) => fn());
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
1062
|
function keepAlive(..._args) {
|
|
1063
1063
|
}
|
|
1064
1064
|
|
|
@@ -4165,7 +4165,7 @@ const Toolbar = vue.defineComponent({
|
|
|
4165
4165
|
ctx: { type: Object, required: true },
|
|
4166
4166
|
hide: { type: Function, required: true },
|
|
4167
4167
|
show: { type: Object, required: true },
|
|
4168
|
-
|
|
4168
|
+
state: { type: Object, required: true },
|
|
4169
4169
|
config: { type: Object, required: false },
|
|
4170
4170
|
isFixed: { type: Boolean, required: false }
|
|
4171
4171
|
},
|
|
@@ -4767,17 +4767,17 @@ const Toolbar = vue.defineComponent({
|
|
|
4767
4767
|
if (ctx) fn(ctx);
|
|
4768
4768
|
};
|
|
4769
4769
|
function checkActive(checker) {
|
|
4770
|
-
var _a;
|
|
4771
|
-
keepAlive(props.
|
|
4772
|
-
const status = (
|
|
4770
|
+
var _a, _b;
|
|
4771
|
+
keepAlive(props.state, (_a = props.state) == null ? void 0 : _a.value);
|
|
4772
|
+
const status = (_b = ctx == null ? void 0 : ctx.get(core.editorCtx)) == null ? void 0 : _b.status;
|
|
4773
4773
|
if (status !== core.EditorStatus.Created) return false;
|
|
4774
4774
|
return checker(ctx);
|
|
4775
4775
|
}
|
|
4776
4776
|
const blockGroups = vue.computed(() => getGroups$1("", void 0, ctx));
|
|
4777
4777
|
const activeBlockItem = vue.computed(() => {
|
|
4778
|
-
var _a;
|
|
4779
|
-
keepAlive(props.
|
|
4780
|
-
const status = (
|
|
4778
|
+
var _a, _b;
|
|
4779
|
+
keepAlive(props.state, (_a = props.state) == null ? void 0 : _a.value);
|
|
4780
|
+
const status = (_b = ctx == null ? void 0 : ctx.get(core.editorCtx)) == null ? void 0 : _b.status;
|
|
4781
4781
|
if (status !== core.EditorStatus.Created) return null;
|
|
4782
4782
|
const view = ctx.get(core.editorViewCtx);
|
|
4783
4783
|
const { $from } = view.state.selection;
|
|
@@ -4815,9 +4815,9 @@ const Toolbar = vue.defineComponent({
|
|
|
4815
4815
|
return targetIcon;
|
|
4816
4816
|
});
|
|
4817
4817
|
const currentAlignIndent = vue.computed(() => {
|
|
4818
|
-
var _a;
|
|
4819
|
-
keepAlive(props.
|
|
4820
|
-
const status = (
|
|
4818
|
+
var _a, _b;
|
|
4819
|
+
keepAlive(props.state, (_a = props.state) == null ? void 0 : _a.value);
|
|
4820
|
+
const status = (_b = ctx == null ? void 0 : ctx.get(core.editorCtx)) == null ? void 0 : _b.status;
|
|
4821
4821
|
if (status !== core.EditorStatus.Created) return { align: "left", indent: 0 };
|
|
4822
4822
|
const view = ctx.get(core.editorViewCtx);
|
|
4823
4823
|
let align = "left";
|
|
@@ -4887,13 +4887,15 @@ const Toolbar = vue.defineComponent({
|
|
|
4887
4887
|
}
|
|
4888
4888
|
};
|
|
4889
4889
|
const canMerge = vue.computed(() => {
|
|
4890
|
-
|
|
4890
|
+
var _a;
|
|
4891
|
+
keepAlive(props.state, (_a = props.state) == null ? void 0 : _a.value);
|
|
4891
4892
|
const view = ctx == null ? void 0 : ctx.get(core.editorViewCtx);
|
|
4892
4893
|
if (!view) return false;
|
|
4893
4894
|
return tables.mergeCells(view.state);
|
|
4894
4895
|
});
|
|
4895
4896
|
const canSplit = vue.computed(() => {
|
|
4896
|
-
|
|
4897
|
+
var _a;
|
|
4898
|
+
keepAlive(props.state, (_a = props.state) == null ? void 0 : _a.value);
|
|
4897
4899
|
const view = ctx == null ? void 0 : ctx.get(core.editorViewCtx);
|
|
4898
4900
|
if (!view) return false;
|
|
4899
4901
|
return tables.splitCell(view.state);
|
|
@@ -4953,16 +4955,16 @@ const Toolbar = vue.defineComponent({
|
|
|
4953
4955
|
showAlignMenu.value = false;
|
|
4954
4956
|
};
|
|
4955
4957
|
const currentColorState = vue.computed(() => {
|
|
4956
|
-
var _a;
|
|
4957
|
-
keepAlive(props.
|
|
4958
|
-
const status = (
|
|
4958
|
+
var _a, _b;
|
|
4959
|
+
keepAlive(props.state, (_a = props.state) == null ? void 0 : _a.value);
|
|
4960
|
+
const status = (_b = ctx == null ? void 0 : ctx.get(core.editorCtx)) == null ? void 0 : _b.status;
|
|
4959
4961
|
if (status !== core.EditorStatus.Created)
|
|
4960
4962
|
return { textColor: null, bgColor: null };
|
|
4961
4963
|
const view = ctx.get(core.editorViewCtx);
|
|
4962
4964
|
const { state } = view;
|
|
4963
4965
|
const schema = ctx.get(core.schemaCtx);
|
|
4964
|
-
const tcHasMark = schema.marks[
|
|
4965
|
-
const bcHasMark = schema.marks[
|
|
4966
|
+
const tcHasMark = schema.marks["textColor"];
|
|
4967
|
+
const bcHasMark = schema.marks["bgColor"];
|
|
4966
4968
|
if (!tcHasMark || !bcHasMark) return { textColor: null, bgColor: null };
|
|
4967
4969
|
const tcType = textColorSchema.type(ctx);
|
|
4968
4970
|
const bcType = bgColorSchema.type(ctx);
|
|
@@ -5009,8 +5011,8 @@ const Toolbar = vue.defineComponent({
|
|
|
5009
5011
|
const { tr } = state;
|
|
5010
5012
|
const { from, to, empty } = state.selection;
|
|
5011
5013
|
const schema = ctx.get(core.schemaCtx);
|
|
5012
|
-
const tcHasMark = schema.marks[
|
|
5013
|
-
const bcHasMark = schema.marks[
|
|
5014
|
+
const tcHasMark = schema.marks["textColor"];
|
|
5015
|
+
const bcHasMark = schema.marks["bgColor"];
|
|
5014
5016
|
if (!tcHasMark || !bcHasMark) return;
|
|
5015
5017
|
const textColorType = textColorSchema.type(ctx);
|
|
5016
5018
|
const bgColorType = bgColorSchema.type(ctx);
|
|
@@ -5026,29 +5028,37 @@ const Toolbar = vue.defineComponent({
|
|
|
5026
5028
|
showColorMenu.value = false;
|
|
5027
5029
|
};
|
|
5028
5030
|
const currentFontState = vue.computed(() => {
|
|
5029
|
-
var _a;
|
|
5030
|
-
keepAlive(props.
|
|
5031
|
-
const status = (
|
|
5031
|
+
var _a, _b;
|
|
5032
|
+
keepAlive(props.state, (_a = props.state) == null ? void 0 : _a.value);
|
|
5033
|
+
const status = (_b = ctx == null ? void 0 : ctx.get(core.editorCtx)) == null ? void 0 : _b.status;
|
|
5032
5034
|
if (status !== core.EditorStatus.Created)
|
|
5033
5035
|
return { fontFamily: null, fontSize: null };
|
|
5034
5036
|
const view = ctx.get(core.editorViewCtx);
|
|
5035
5037
|
const { state } = view;
|
|
5036
5038
|
const schema = ctx.get(core.schemaCtx);
|
|
5037
|
-
const ffHasMark = schema.marks[
|
|
5038
|
-
const fsHasMark = schema.marks[
|
|
5039
|
-
if (!ffHasMark || !fsHasMark)
|
|
5039
|
+
const ffHasMark = schema.marks["fontFamily"];
|
|
5040
|
+
const fsHasMark = schema.marks["fontSize"];
|
|
5041
|
+
if (!ffHasMark || !fsHasMark) {
|
|
5042
|
+
return { fontFamily: null, fontSize: null };
|
|
5043
|
+
}
|
|
5040
5044
|
const ffType = fontFamilySchema.type(ctx);
|
|
5041
5045
|
const fsType = fontSizeSchema.type(ctx);
|
|
5042
5046
|
const { $cursor, ranges } = state.selection;
|
|
5047
|
+
let result = {
|
|
5048
|
+
fontFamily: null,
|
|
5049
|
+
fontSize: null
|
|
5050
|
+
};
|
|
5043
5051
|
if ($cursor) {
|
|
5044
5052
|
let fontFamily = null;
|
|
5045
5053
|
let fontSize = null;
|
|
5046
5054
|
const marks = state.storedMarks || $cursor.marks();
|
|
5047
5055
|
for (const mark of marks) {
|
|
5048
|
-
if (mark.type === ffType)
|
|
5049
|
-
|
|
5056
|
+
if (mark.type === ffType)
|
|
5057
|
+
fontFamily = mark.attrs.fontFamily || null;
|
|
5058
|
+
if (mark.type === fsType)
|
|
5059
|
+
fontSize = mark.attrs.fontSize || null;
|
|
5050
5060
|
}
|
|
5051
|
-
|
|
5061
|
+
result = { fontFamily, fontSize };
|
|
5052
5062
|
} else {
|
|
5053
5063
|
const fontFamilies = /* @__PURE__ */ new Set();
|
|
5054
5064
|
const fontSizes = /* @__PURE__ */ new Set();
|
|
@@ -5058,15 +5068,20 @@ const Toolbar = vue.defineComponent({
|
|
|
5058
5068
|
if (node.isText) {
|
|
5059
5069
|
const ffMark = ffType.isInSet(node.marks);
|
|
5060
5070
|
const fsMark = fsType.isInSet(node.marks);
|
|
5061
|
-
fontFamilies.add(
|
|
5062
|
-
|
|
5071
|
+
fontFamilies.add(
|
|
5072
|
+
ffMark ? ffMark.attrs.fontFamily : null
|
|
5073
|
+
);
|
|
5074
|
+
fontSizes.add(
|
|
5075
|
+
fsMark ? fsMark.attrs.fontSize : null
|
|
5076
|
+
);
|
|
5063
5077
|
}
|
|
5064
5078
|
});
|
|
5065
5079
|
}
|
|
5066
5080
|
const fontFamily = fontFamilies.size === 1 ? Array.from(fontFamilies)[0] : "mixed";
|
|
5067
5081
|
const fontSize = fontSizes.size === 1 ? Array.from(fontSizes)[0] : "mixed";
|
|
5068
|
-
|
|
5082
|
+
result = { fontFamily, fontSize };
|
|
5069
5083
|
}
|
|
5084
|
+
return result;
|
|
5070
5085
|
});
|
|
5071
5086
|
const setFontFamily = (fontFamily) => {
|
|
5072
5087
|
const commands = ctx.get(core.commandsCtx);
|
|
@@ -5297,7 +5312,11 @@ const Toolbar = vue.defineComponent({
|
|
|
5297
5312
|
color: "#363B4C"
|
|
5298
5313
|
}
|
|
5299
5314
|
},
|
|
5300
|
-
|
|
5315
|
+
(() => {
|
|
5316
|
+
const fontState = currentFontState.value;
|
|
5317
|
+
const fontFamily = fontState == null ? void 0 : fontState.fontFamily;
|
|
5318
|
+
return fontFamily && fontFamily !== "mixed" ? fontFamily.split(",")[0].replace(/['"]/g, "") || (ctx ? i18n(ctx, "customMenu.fontDefault") : "\u9ED8\u8BA4") : ctx ? i18n(ctx, "customMenu.fontDefault") : "\u9ED8\u8BA4";
|
|
5319
|
+
})()
|
|
5301
5320
|
),
|
|
5302
5321
|
/* @__PURE__ */ vue.h(
|
|
5303
5322
|
"span",
|
|
@@ -5327,7 +5346,10 @@ const Toolbar = vue.defineComponent({
|
|
|
5327
5346
|
flexShrink: 0
|
|
5328
5347
|
}
|
|
5329
5348
|
},
|
|
5330
|
-
/* @__PURE__ */ vue.h("span", { style: { fontSize: "13px", color: "#363B4C" } },
|
|
5349
|
+
/* @__PURE__ */ vue.h("span", { style: { fontSize: "13px", color: "#363B4C" } }, (() => {
|
|
5350
|
+
const fs = currentFontState.value.fontSize;
|
|
5351
|
+
return fs && fs !== "mixed" ? fs : "16px";
|
|
5352
|
+
})()),
|
|
5331
5353
|
/* @__PURE__ */ vue.h(
|
|
5332
5354
|
"span",
|
|
5333
5355
|
{
|
|
@@ -6431,21 +6453,21 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
|
|
|
6431
6453
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6432
6454
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
6433
6455
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
6434
|
-
var _tooltipProvider, _content, _app,
|
|
6456
|
+
var _tooltipProvider, _content, _app, _state, _show, _mousePressed, _removePopupListener, _onDocumentMouseUp;
|
|
6435
6457
|
const toolbarTooltip = tooltip.tooltipFactory("CREPE_TOOLBAR");
|
|
6436
6458
|
class ToolbarView {
|
|
6437
6459
|
constructor(ctx, view, config) {
|
|
6438
6460
|
__privateAdd(this, _tooltipProvider);
|
|
6439
6461
|
__privateAdd(this, _content);
|
|
6440
6462
|
__privateAdd(this, _app);
|
|
6441
|
-
__privateAdd(this,
|
|
6463
|
+
__privateAdd(this, _state);
|
|
6442
6464
|
__privateAdd(this, _show, vue.ref(false));
|
|
6443
6465
|
__privateAdd(this, _mousePressed, false);
|
|
6444
6466
|
__privateAdd(this, _removePopupListener);
|
|
6445
6467
|
__privateAdd(this, _onDocumentMouseUp);
|
|
6446
6468
|
this.update = (view, prevState) => {
|
|
6447
6469
|
__privateGet(this, _tooltipProvider).update(view, prevState);
|
|
6448
|
-
__privateGet(this,
|
|
6470
|
+
__privateGet(this, _state).value = view.state;
|
|
6449
6471
|
};
|
|
6450
6472
|
this.destroy = () => {
|
|
6451
6473
|
var _a;
|
|
@@ -6462,12 +6484,12 @@ class ToolbarView {
|
|
|
6462
6484
|
};
|
|
6463
6485
|
const content = document.createElement("div");
|
|
6464
6486
|
content.className = "milkdown-toolbar";
|
|
6465
|
-
__privateSet(this,
|
|
6487
|
+
__privateSet(this, _state, vue.shallowRef(view.state));
|
|
6466
6488
|
const app = vue.createApp(Toolbar, {
|
|
6467
6489
|
ctx,
|
|
6468
6490
|
hide: this.hide,
|
|
6469
6491
|
config,
|
|
6470
|
-
|
|
6492
|
+
state: __privateGet(this, _state),
|
|
6471
6493
|
show: __privateGet(this, _show)
|
|
6472
6494
|
});
|
|
6473
6495
|
app.mount(content);
|
|
@@ -6531,7 +6553,7 @@ class ToolbarView {
|
|
|
6531
6553
|
_tooltipProvider = new WeakMap();
|
|
6532
6554
|
_content = new WeakMap();
|
|
6533
6555
|
_app = new WeakMap();
|
|
6534
|
-
|
|
6556
|
+
_state = new WeakMap();
|
|
6535
6557
|
_show = new WeakMap();
|
|
6536
6558
|
_mousePressed = new WeakMap();
|
|
6537
6559
|
_removePopupListener = new WeakMap();
|