@kerebron/legacy-compat 0.8.8 → 0.8.9
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/dist/kerebron.cjs +2 -2
- package/dist/kerebron.cjs.map +1 -1
- package/dist/kerebron.js +140 -94
- package/dist/kerebron.js.map +1 -1
- package/package.json +1 -1
package/dist/kerebron.js
CHANGED
|
@@ -8539,7 +8539,12 @@ var CoreEditor = class e extends EventTarget {
|
|
|
8539
8539
|
}, this.schema, n);
|
|
8540
8540
|
n.created(r, this.schema);
|
|
8541
8541
|
let a = this.getJSON(), o = this.state.selection;
|
|
8542
|
-
|
|
8542
|
+
r.createView(a, o), r.setupPlugins();
|
|
8543
|
+
{
|
|
8544
|
+
let e = this.state, t = r.state.tr.setMeta("cloned", e);
|
|
8545
|
+
r.dispatchTransaction(t);
|
|
8546
|
+
}
|
|
8547
|
+
return r;
|
|
8543
8548
|
}
|
|
8544
8549
|
getExtension(e) {
|
|
8545
8550
|
return this.ci.resolve(e);
|
|
@@ -8664,15 +8669,19 @@ var CoreEditor = class e extends EventTarget {
|
|
|
8664
8669
|
doc: n,
|
|
8665
8670
|
plugins: this.state.plugins,
|
|
8666
8671
|
storedMarks: this.state.storedMarks
|
|
8667
|
-
})
|
|
8668
|
-
runInputRulesTexts()(r, (e) => {
|
|
8672
|
+
}), a = (e) => {
|
|
8669
8673
|
r = r.apply(e);
|
|
8670
|
-
}
|
|
8671
|
-
|
|
8674
|
+
};
|
|
8675
|
+
{
|
|
8676
|
+
let e = this.state;
|
|
8677
|
+
a(r.tr.setMeta("cloned", e));
|
|
8678
|
+
}
|
|
8679
|
+
runInputRulesTexts()(r, a), this.state = r, this.view && (this.view.updateState(this.state), this.view.dispatch(this.view.state.tr));
|
|
8680
|
+
let o = new CustomEvent("doc:loaded", { detail: {
|
|
8672
8681
|
editor: this,
|
|
8673
8682
|
doc: this.state.doc
|
|
8674
8683
|
} });
|
|
8675
|
-
this.dispatchEvent(
|
|
8684
|
+
this.dispatchEvent(o);
|
|
8676
8685
|
}
|
|
8677
8686
|
async saveDocument(e) {
|
|
8678
8687
|
let t = this.getConverter(e), n = this.state.doc.toJSON(), r = Node$3.fromJSON(this.state.schema, n);
|
|
@@ -9734,12 +9743,17 @@ var PasteState = class {
|
|
|
9734
9743
|
key: PastePluginKey,
|
|
9735
9744
|
state: {
|
|
9736
9745
|
init() {
|
|
9737
|
-
return
|
|
9746
|
+
return new PasteState(e);
|
|
9738
9747
|
},
|
|
9739
9748
|
apply(e, t, n, r) {
|
|
9740
9749
|
if (e.isGeneric) return t;
|
|
9741
|
-
let a = e.getMeta(
|
|
9742
|
-
|
|
9750
|
+
let a = e.getMeta("cloned");
|
|
9751
|
+
if (a) {
|
|
9752
|
+
let e = PastePluginKey.getState(a);
|
|
9753
|
+
if (e) return e;
|
|
9754
|
+
}
|
|
9755
|
+
let o = e.getMeta(PastePluginKey);
|
|
9756
|
+
return t.handleCommands(o, e), t;
|
|
9743
9757
|
}
|
|
9744
9758
|
},
|
|
9745
9759
|
props: {
|
|
@@ -16627,8 +16641,61 @@ async function mdToPmConverterText(e, t, n) {
|
|
|
16627
16641
|
return o.doc;
|
|
16628
16642
|
}
|
|
16629
16643
|
//#endregion
|
|
16630
|
-
//#region ../extension-markdown/src/
|
|
16631
|
-
var
|
|
16644
|
+
//#region ../extension-markdown/src/MarkdownContentMapper.ts
|
|
16645
|
+
var MarkdownContentMapper = class e {
|
|
16646
|
+
result;
|
|
16647
|
+
rawTextArr;
|
|
16648
|
+
constructor(e, t) {
|
|
16649
|
+
this.result = t, this.rawTextArr = [];
|
|
16650
|
+
for (let e of t.rawTextMap) e.nodeIdx >= 0 && this.rawTextArr.push({
|
|
16651
|
+
nodeIdx: e.nodeIdx,
|
|
16652
|
+
maxNodeIdx: e.nodeIdx,
|
|
16653
|
+
targetPos: e.targetPos,
|
|
16654
|
+
targetRow: e.targetRow,
|
|
16655
|
+
targetCol: e.targetCol
|
|
16656
|
+
});
|
|
16657
|
+
this.rawTextArr.sort((e, t) => e.nodeIdx - t.nodeIdx);
|
|
16658
|
+
for (let t = 0; t < this.rawTextArr.length; t++) {
|
|
16659
|
+
let n = t + 1;
|
|
16660
|
+
n < this.rawTextArr.length ? this.rawTextArr[t].maxNodeIdx = this.rawTextArr[n].nodeIdx - 1 : this.rawTextArr[t].maxNodeIdx = e;
|
|
16661
|
+
}
|
|
16662
|
+
}
|
|
16663
|
+
getTextContent() {
|
|
16664
|
+
return this.result.content;
|
|
16665
|
+
}
|
|
16666
|
+
toRawTextPos(e) {
|
|
16667
|
+
for (let t = 0; t < this.rawTextArr.length; t++) {
|
|
16668
|
+
let n = this.rawTextArr[t];
|
|
16669
|
+
if (e >= n.nodeIdx && e <= n.maxNodeIdx) return n.targetPos + e - n.nodeIdx;
|
|
16670
|
+
}
|
|
16671
|
+
return -1;
|
|
16672
|
+
}
|
|
16673
|
+
toRawTextLineCol(e) {
|
|
16674
|
+
for (let t = 0; t < this.rawTextArr.length; t++) {
|
|
16675
|
+
let n = this.rawTextArr[t];
|
|
16676
|
+
if (e >= n.nodeIdx && e <= n.maxNodeIdx) return [n.targetRow, n.targetCol + e - n.nodeIdx];
|
|
16677
|
+
}
|
|
16678
|
+
return [0, 0];
|
|
16679
|
+
}
|
|
16680
|
+
fromLineChar(e, t) {
|
|
16681
|
+
for (let n = 0; n < this.rawTextArr.length; n++) {
|
|
16682
|
+
let r = this.rawTextArr[n], a = r.maxNodeIdx - r.nodeIdx + 1;
|
|
16683
|
+
if (r.targetRow === e) {
|
|
16684
|
+
if (t >= r.targetCol && t < r.targetCol + a) {
|
|
16685
|
+
let e = t - r.targetCol;
|
|
16686
|
+
return r.nodeIdx + e;
|
|
16687
|
+
}
|
|
16688
|
+
let e = this.rawTextArr[n + 1];
|
|
16689
|
+
if ((!e || e.targetRow > r.targetRow) && t >= r.targetCol + a) return r.maxNodeIdx;
|
|
16690
|
+
}
|
|
16691
|
+
}
|
|
16692
|
+
return -1;
|
|
16693
|
+
}
|
|
16694
|
+
static async create(t, n) {
|
|
16695
|
+
let r = await extPmToMdConverter(t.doc, n, t.schema, new EventTarget());
|
|
16696
|
+
return new e(t.doc.nodeSize, r);
|
|
16697
|
+
}
|
|
16698
|
+
}, addEmptyLines = (e, t) => {
|
|
16632
16699
|
let n = e.doc, r = e.tr, a = e.schema.nodes.br, o = e.schema.nodes.softbreak;
|
|
16633
16700
|
function s(e, t, n = 0, c = 0) {
|
|
16634
16701
|
let l = 0, u = !1;
|
|
@@ -16862,65 +16929,15 @@ function getDefaultsPreProcessFilters(e) {
|
|
|
16862
16929
|
];
|
|
16863
16930
|
}
|
|
16864
16931
|
//#endregion
|
|
16865
|
-
//#region ../extension-markdown/src/
|
|
16866
|
-
var
|
|
16867
|
-
result;
|
|
16868
|
-
rawTextArr;
|
|
16869
|
-
constructor(e, t) {
|
|
16870
|
-
this.result = t, this.rawTextArr = [];
|
|
16871
|
-
for (let e of t.rawTextMap) e.nodeIdx >= 0 && this.rawTextArr.push({
|
|
16872
|
-
nodeIdx: e.nodeIdx,
|
|
16873
|
-
maxNodeIdx: e.nodeIdx,
|
|
16874
|
-
targetPos: e.targetPos,
|
|
16875
|
-
targetRow: e.targetRow,
|
|
16876
|
-
targetCol: e.targetCol
|
|
16877
|
-
});
|
|
16878
|
-
this.rawTextArr.sort((e, t) => e.nodeIdx - t.nodeIdx);
|
|
16879
|
-
for (let t = 0; t < this.rawTextArr.length; t++) {
|
|
16880
|
-
let n = t + 1;
|
|
16881
|
-
n < this.rawTextArr.length ? this.rawTextArr[t].maxNodeIdx = this.rawTextArr[n].nodeIdx - 1 : this.rawTextArr[t].maxNodeIdx = e;
|
|
16882
|
-
}
|
|
16883
|
-
}
|
|
16884
|
-
getTextContent() {
|
|
16885
|
-
return this.result.content;
|
|
16886
|
-
}
|
|
16887
|
-
toRawTextPos(e) {
|
|
16888
|
-
for (let t = 0; t < this.rawTextArr.length; t++) {
|
|
16889
|
-
let n = this.rawTextArr[t];
|
|
16890
|
-
if (e >= n.nodeIdx && e <= n.maxNodeIdx) return n.targetPos + e - n.nodeIdx;
|
|
16891
|
-
}
|
|
16892
|
-
return -1;
|
|
16893
|
-
}
|
|
16894
|
-
toRawTextLineCol(e) {
|
|
16895
|
-
for (let t = 0; t < this.rawTextArr.length; t++) {
|
|
16896
|
-
let n = this.rawTextArr[t];
|
|
16897
|
-
if (e >= n.nodeIdx && e <= n.maxNodeIdx) return [n.targetRow, n.targetCol + e - n.nodeIdx];
|
|
16898
|
-
}
|
|
16899
|
-
return [0, 0];
|
|
16900
|
-
}
|
|
16901
|
-
fromLineChar(e, t) {
|
|
16902
|
-
for (let n = 0; n < this.rawTextArr.length; n++) {
|
|
16903
|
-
let r = this.rawTextArr[n], a = r.maxNodeIdx - r.nodeIdx + 1;
|
|
16904
|
-
if (r.targetRow === e) {
|
|
16905
|
-
if (t >= r.targetCol && t < r.targetCol + a) {
|
|
16906
|
-
let e = t - r.targetCol;
|
|
16907
|
-
return r.nodeIdx + e;
|
|
16908
|
-
}
|
|
16909
|
-
let e = this.rawTextArr[n + 1];
|
|
16910
|
-
if ((!e || e.targetRow > r.targetRow) && t >= r.targetCol + a) return r.maxNodeIdx;
|
|
16911
|
-
}
|
|
16912
|
-
}
|
|
16913
|
-
return -1;
|
|
16914
|
-
}
|
|
16915
|
-
static async create(t, n) {
|
|
16916
|
-
let r = await extPmToMdConverter(t.doc, n, t.schema, new EventTarget());
|
|
16917
|
-
return new e(t.doc.nodeSize, r);
|
|
16918
|
-
}
|
|
16919
|
-
}, MarkdownPluginState = class {
|
|
16932
|
+
//#region ../extension-markdown/src/createMarkdownPlugin.ts
|
|
16933
|
+
var MarkdownPluginState = class {
|
|
16920
16934
|
editor;
|
|
16921
16935
|
extensionMarkdown;
|
|
16922
16936
|
capturing = !0;
|
|
16923
16937
|
workspace;
|
|
16938
|
+
hooks = {};
|
|
16939
|
+
urlFromRewriter;
|
|
16940
|
+
urlToRewriter;
|
|
16924
16941
|
constructor(e, t) {
|
|
16925
16942
|
this.editor = e, this.extensionMarkdown = t, this.workspace = e.ci.resolve("workspace"), this.performSnapshot = debounce(this.performSnapshot.bind(this), 800);
|
|
16926
16943
|
}
|
|
@@ -16947,15 +16964,38 @@ var MarkdownContentMapper = class e {
|
|
|
16947
16964
|
getContentMapper: r
|
|
16948
16965
|
});
|
|
16949
16966
|
}
|
|
16950
|
-
|
|
16967
|
+
handleCommands(e, t) {
|
|
16968
|
+
if (!e) return !1;
|
|
16969
|
+
if (e.setMarkdownHooks) {
|
|
16970
|
+
let { type: t, hooks: n } = e.setMarkdownHooks;
|
|
16971
|
+
return this.hooks[t] = n, !0;
|
|
16972
|
+
}
|
|
16973
|
+
if (e.setFromMarkdownUrlRewriter) {
|
|
16974
|
+
let { urlRewriter: t } = e.setFromMarkdownUrlRewriter;
|
|
16975
|
+
return this.urlFromRewriter = t, !0;
|
|
16976
|
+
}
|
|
16977
|
+
if (e.setToMarkdownUrlRewriter) {
|
|
16978
|
+
let { urlRewriter: t } = e.setToMarkdownUrlRewriter;
|
|
16979
|
+
return this.urlToRewriter = t, !0;
|
|
16980
|
+
}
|
|
16981
|
+
}
|
|
16982
|
+
}, MarkdownPluginKey = new PluginKey("markdown");
|
|
16951
16983
|
function createMarkdownPlugin(e, t) {
|
|
16952
16984
|
return new Plugin({
|
|
16985
|
+
key: MarkdownPluginKey,
|
|
16953
16986
|
state: {
|
|
16954
|
-
init() {
|
|
16955
|
-
|
|
16987
|
+
init(n, r) {
|
|
16988
|
+
let a = new MarkdownPluginState(t, e);
|
|
16989
|
+
return r.schema.topNodeType.name === "doc" ? a.hooks["pm2md.pre"] = getDefaultsPreProcessFilters({ getUrlRewriter: () => a.urlToRewriter }) : a.hooks["pm2md.pre"] = [], a.hooks["md2pm.post"] = [rewriteUrls(() => a.urlFromRewriter)], a;
|
|
16956
16990
|
},
|
|
16957
16991
|
apply(e, t, n, r) {
|
|
16958
|
-
|
|
16992
|
+
let a = e.getMeta("cloned");
|
|
16993
|
+
if (a) {
|
|
16994
|
+
let e = MarkdownPluginKey.getState(a);
|
|
16995
|
+
if (e) return e;
|
|
16996
|
+
}
|
|
16997
|
+
let o = e.getMeta(MarkdownPluginKey);
|
|
16998
|
+
return t.handleCommands(o, e) || e.docChanged && t.capturing && t.performSnapshot(), t;
|
|
16959
16999
|
}
|
|
16960
17000
|
},
|
|
16961
17001
|
view() {
|
|
@@ -16971,28 +17011,31 @@ function createMarkdownPlugin(e, t) {
|
|
|
16971
17011
|
var ExtensionMarkdown = class extends Extension {
|
|
16972
17012
|
config;
|
|
16973
17013
|
name = "markdown";
|
|
16974
|
-
hooks = {};
|
|
16975
|
-
urlFromRewriter;
|
|
16976
|
-
urlToRewriter;
|
|
16977
17014
|
constructor(e = {}) {
|
|
16978
17015
|
super(e), this.config = e;
|
|
16979
17016
|
}
|
|
16980
17017
|
getConverters(e, t) {
|
|
16981
17018
|
let n = { "text/x-markdown": {
|
|
16982
|
-
fromDoc: (n) =>
|
|
16983
|
-
|
|
16984
|
-
|
|
16985
|
-
|
|
16986
|
-
|
|
16987
|
-
|
|
16988
|
-
|
|
16989
|
-
|
|
16990
|
-
|
|
16991
|
-
|
|
16992
|
-
|
|
16993
|
-
|
|
16994
|
-
|
|
16995
|
-
|
|
17019
|
+
fromDoc: (n) => {
|
|
17020
|
+
let r = MarkdownPluginKey.getState(e.state);
|
|
17021
|
+
return pmToMdConverter(n, {
|
|
17022
|
+
assetLoad: this.editor.config.assetLoad,
|
|
17023
|
+
...this.config,
|
|
17024
|
+
urlRewriter: r.urlToRewriter,
|
|
17025
|
+
hooks: r.hooks["pm2md.pre"],
|
|
17026
|
+
frontmatter: e.ci.resolve("frontmatter")
|
|
17027
|
+
}, t, e);
|
|
17028
|
+
},
|
|
17029
|
+
toDoc: (n) => {
|
|
17030
|
+
let r = MarkdownPluginKey.getState(e.state);
|
|
17031
|
+
return mdToPmConverter(n, {
|
|
17032
|
+
assetLoad: this.editor.config.assetLoad,
|
|
17033
|
+
...this.config,
|
|
17034
|
+
urlRewriter: r.urlFromRewriter,
|
|
17035
|
+
hooks: r.hooks["md2pm.post"],
|
|
17036
|
+
frontmatter: e.ci.resolve("frontmatter")
|
|
17037
|
+
}, t);
|
|
17038
|
+
}
|
|
16996
17039
|
} };
|
|
16997
17040
|
return n["text/markdown"] = n["text/x-markdown"], n;
|
|
16998
17041
|
}
|
|
@@ -17013,15 +17056,18 @@ var ExtensionMarkdown = class extends Extension {
|
|
|
17013
17056
|
}
|
|
17014
17057
|
return new Slice(t, 0, 0);
|
|
17015
17058
|
}
|
|
17016
|
-
created() {
|
|
17017
|
-
this.editor.schema.topNodeType.name === "doc" ? this.hooks["pm2md.pre"] = getDefaultsPreProcessFilters({ getUrlRewriter: () => this.urlToRewriter }) : this.hooks["pm2md.pre"] = [], this.hooks["md2pm.post"] = [rewriteUrls(() => this.urlFromRewriter)];
|
|
17018
|
-
}
|
|
17019
17059
|
getCommandFactories() {
|
|
17020
17060
|
return {
|
|
17021
|
-
getMarkdownHooks: (e, t) => () =>
|
|
17022
|
-
|
|
17023
|
-
|
|
17024
|
-
|
|
17061
|
+
getMarkdownHooks: (e, t) => (n, r) => {
|
|
17062
|
+
let a = MarkdownPluginKey.getState(n);
|
|
17063
|
+
return t(a ? a.hooks[e] : []), !0;
|
|
17064
|
+
},
|
|
17065
|
+
setMarkdownHooks: (e, t) => (n, r) => (r && r(n.tr.setMeta(MarkdownPluginKey, { setMarkdownHooks: {
|
|
17066
|
+
type: e,
|
|
17067
|
+
hooks: t
|
|
17068
|
+
} })), !0),
|
|
17069
|
+
setFromMarkdownUrlRewriter: (e) => (t, n) => (n && n(t.tr.setMeta(MarkdownPluginKey, { setFromMarkdownUrlRewriter: { urlRewriter: e } })), !0),
|
|
17070
|
+
setToMarkdownUrlRewriter: (e) => (t, n) => (n && n(t.tr.setMeta(MarkdownPluginKey, { setToMarkdownUrlRewriter: { urlRewriter: e } })), !0)
|
|
17025
17071
|
};
|
|
17026
17072
|
}
|
|
17027
17073
|
getProseMirrorPlugins() {
|