smart-editor-v3 1.16.2 → 1.16.3

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.
@@ -53974,6 +53974,7 @@ const GU = { class: "smart-button-content" }, jU = { class: "smart-button-text"
53974
53974
  }, 8, ["class", "data-smart-id"]));
53975
53975
  }
53976
53976
  }, hV = /* @__PURE__ */ rt(fV, [["__scopeId", "data-v-c9d475ce"]]), { options: pV } = ve(), mV = Uk(Mk), gV = rz.extend({
53977
+ isInitialized: !1,
53977
53978
  isolating: !0,
53978
53979
  addAttributes() {
53979
53980
  var t;
@@ -54008,36 +54009,25 @@ const GU = { class: "smart-button-content" }, jU = { class: "smart-button-text"
54008
54009
  var t;
54009
54010
  return kn((t = pV.value.render.codeBlock) != null && t.view ? hV : dV);
54010
54011
  },
54012
+ addKeyboardShortcuts() {
54013
+ var t;
54014
+ return {
54015
+ ...(t = this.parent) == null ? void 0 : t.call(this),
54016
+ Backspace: () => {
54017
+ const { empty: e, $anchor: n } = this.editor.state.selection, r = n.pos === 1;
54018
+ return !e || n.parent.type.name !== this.name ? !1 : !!(r || !n.parent.textContent.length);
54019
+ }
54020
+ };
54021
+ },
54011
54022
  addProseMirrorPlugins() {
54012
54023
  var t;
54013
54024
  return [
54014
54025
  ...(t = this.parent) == null ? void 0 : t.call(this),
54015
54026
  new mt({
54016
54027
  key: new _t("codeBlockInit"),
54017
- // view(editorView) {
54018
- // const { state, dispatch } = editorView
54019
- // state.doc.descendants((node, pos) => {
54020
- // console.log('初始化 codeBlock', node, pos);
54021
- // if (node.type.name === 'codeBlock' && node.attrs.code && node.content.size === 0) {
54022
- // console.log('进入 codeBlock', node, pos);
54023
- // const textNode = node.type.schema.text(node.attrs.code)
54024
- // const fragment = Fragment.from(textNode)
54025
- // const tr = state.tr.replaceRangeWith(
54026
- // pos + 1,
54027
- // pos + node.nodeSize - 1,
54028
- // fragment,
54029
- // )
54030
- // // 清空 attrs.code 避免重复
54031
- // tr.setNodeMarkup(pos, undefined, {
54032
- // ...node.attrs,
54033
- // code: '',
54034
- // })
54035
- // dispatch(tr)
54036
- // }
54037
- // })
54038
- // return {}
54039
- // },
54040
54028
  appendTransaction: (e, n, r) => {
54029
+ if (this.isInitialized)
54030
+ return null;
54041
54031
  const i = [];
54042
54032
  if (r.doc.descendants((s, a) => {
54043
54033
  if (s.type.name === "codeBlock" && s.attrs.code && s.content.size === 0) {
@@ -54050,6 +54040,7 @@ const GU = { class: "smart-button-content" }, jU = { class: "smart-button-text"
54050
54040
  }
54051
54041
  }), i.length === 0)
54052
54042
  return null;
54043
+ this.isInitialized = !0;
54053
54044
  const o = r.tr;
54054
54045
  return i.sort((s, a) => a.pos - s.pos), i.forEach((s) => {
54055
54046
  o.insert(s.pos, s.content);
@@ -54064,7 +54055,10 @@ const GU = { class: "smart-button-content" }, jU = { class: "smart-button-text"
54064
54055
  return r.doc.descendants((s, a) => {
54065
54056
  if (s.type.name !== "codeBlock")
54066
54057
  return;
54067
- const l = s.textContent, c = {
54058
+ const l = s.textContent;
54059
+ if (s.attrs.code === l)
54060
+ return;
54061
+ const c = {
54068
54062
  ...s.attrs,
54069
54063
  code: l
54070
54064
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "smart-editor-v3",
3
3
  "type": "module",
4
- "version": "1.16.2",
4
+ "version": "1.16.3",
5
5
  "exports": {
6
6
  ".": {
7
7
  "import": "./dist/smart-editor-package.js"