@xlxz/markdown-editor 2.0.0 → 2.1.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/dist/index.cjs +40 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +40 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1254,7 +1254,7 @@ function createTableTheme(EditorView) {
|
|
|
1254
1254
|
fontWeight: "600"
|
|
1255
1255
|
},
|
|
1256
1256
|
".cm-table-separator": {
|
|
1257
|
-
backgroundColor: "
|
|
1257
|
+
backgroundColor: "transparent",
|
|
1258
1258
|
color: "var(--text-faint)"
|
|
1259
1259
|
},
|
|
1260
1260
|
".cm-table-active.cm-table-separator": {
|
|
@@ -1262,19 +1262,19 @@ function createTableTheme(EditorView) {
|
|
|
1262
1262
|
color: "var(--text-muted)"
|
|
1263
1263
|
},
|
|
1264
1264
|
".cm-table-row-even": {
|
|
1265
|
-
backgroundColor: "
|
|
1265
|
+
backgroundColor: "transparent"
|
|
1266
1266
|
},
|
|
1267
1267
|
".cm-table-row-odd": {
|
|
1268
|
-
backgroundColor: "var(--table-row-odd-bg, rgba(80, 140, 220, 0.
|
|
1268
|
+
backgroundColor: "var(--table-row-odd-bg, rgba(80, 140, 220, 0.08))"
|
|
1269
1269
|
},
|
|
1270
1270
|
".cm-table-active.cm-table-header": {
|
|
1271
1271
|
backgroundColor: "rgba(80, 120, 200, 0.10)"
|
|
1272
1272
|
},
|
|
1273
1273
|
".cm-table-active.cm-table-row-even": {
|
|
1274
|
-
backgroundColor: "
|
|
1274
|
+
backgroundColor: "transparent"
|
|
1275
1275
|
},
|
|
1276
1276
|
".cm-table-active.cm-table-row-odd": {
|
|
1277
|
-
backgroundColor: "rgba(80, 140, 220, 0.
|
|
1277
|
+
backgroundColor: "rgba(80, 140, 220, 0.05)"
|
|
1278
1278
|
},
|
|
1279
1279
|
".cm-table-copy-btn": {
|
|
1280
1280
|
position: "absolute",
|
|
@@ -1687,6 +1687,7 @@ function createEditor(container, options = {}, backend = {}) {
|
|
|
1687
1687
|
const activePlugins = new Map;
|
|
1688
1688
|
pluginStates.set("__mockEditor", mockEditor);
|
|
1689
1689
|
pluginStates.set("__mockOwner", mockOwner);
|
|
1690
|
+
let currentMode = "ir";
|
|
1690
1691
|
function makeContext() {
|
|
1691
1692
|
return {
|
|
1692
1693
|
view,
|
|
@@ -1800,7 +1801,40 @@ function createEditor(container, options = {}, backend = {}) {
|
|
|
1800
1801
|
},
|
|
1801
1802
|
use,
|
|
1802
1803
|
unuse,
|
|
1803
|
-
registerSuggest
|
|
1804
|
+
registerSuggest,
|
|
1805
|
+
setTheme(theme) {
|
|
1806
|
+
if (theme === "light") {
|
|
1807
|
+
container.classList.add("theme-light");
|
|
1808
|
+
container.classList.remove("theme-dark");
|
|
1809
|
+
} else {
|
|
1810
|
+
container.classList.add("theme-dark");
|
|
1811
|
+
container.classList.remove("theme-light");
|
|
1812
|
+
}
|
|
1813
|
+
document.body.classList.toggle("theme-dark", theme === "dark");
|
|
1814
|
+
document.body.classList.toggle("theme-light", theme === "light");
|
|
1815
|
+
},
|
|
1816
|
+
setMode(mode) {
|
|
1817
|
+
if (mode === currentMode)
|
|
1818
|
+
return;
|
|
1819
|
+
currentMode = mode;
|
|
1820
|
+
const { EditorView: EV, Compartment } = window.__cm6;
|
|
1821
|
+
if (mode === "ir" || mode === "view") {
|
|
1822
|
+
container.classList.add("is-live-preview");
|
|
1823
|
+
container.classList.remove("is-source-mode");
|
|
1824
|
+
} else {
|
|
1825
|
+
container.classList.remove("is-live-preview");
|
|
1826
|
+
container.classList.add("is-source-mode");
|
|
1827
|
+
}
|
|
1828
|
+
view.dispatch({
|
|
1829
|
+
effects: window.__cm6.StateEffect.appendConfig.of(EV.editable.of(mode !== "view"))
|
|
1830
|
+
});
|
|
1831
|
+
view.dispatch({
|
|
1832
|
+
effects: window.__cm6.StateEffect.appendConfig.of([])
|
|
1833
|
+
});
|
|
1834
|
+
},
|
|
1835
|
+
getMode() {
|
|
1836
|
+
return currentMode;
|
|
1837
|
+
}
|
|
1804
1838
|
};
|
|
1805
1839
|
return instance;
|
|
1806
1840
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,6 @@
|
|
|
18
18
|
* });
|
|
19
19
|
*/
|
|
20
20
|
export { createEditor, autoLoad } from './kernel.js';
|
|
21
|
-
export type { EditorBackend, EditorOptions, EditorInstance, EditorPlugin, PluginContext, LinkTarget, SuggestConfig, SuggestItem, I18nProvider, AssetLoader, AutoLoadOptions, } from './types.js';
|
|
21
|
+
export type { EditorBackend, EditorOptions, EditorInstance, EditorMode, EditorPlugin, PluginContext, LinkTarget, SuggestConfig, SuggestItem, I18nProvider, AssetLoader, AutoLoadOptions, } from './types.js';
|
|
22
22
|
export { livePreviewPlugin, markdownLanguagePlugin, hangingIndentPlugin, listContinuationPlugin, closeBracketsPlugin, expandTextPlugin, foldPlugin, lineNumbersPlugin, indentGuidePlugin, suggestPlugin, linkHandlerPlugin, attachmentPlugin, tablePlugin, tableContinuationPlugin, themePlugin, baseExtensionsPlugin, keymapPlugin, onChangePlugin, } from './plugins/index.js';
|
|
23
23
|
export type { CompletionProvider } from './plugins/types.js';
|
package/dist/index.js
CHANGED
|
@@ -1200,7 +1200,7 @@ function createTableTheme(EditorView) {
|
|
|
1200
1200
|
fontWeight: "600"
|
|
1201
1201
|
},
|
|
1202
1202
|
".cm-table-separator": {
|
|
1203
|
-
backgroundColor: "
|
|
1203
|
+
backgroundColor: "transparent",
|
|
1204
1204
|
color: "var(--text-faint)"
|
|
1205
1205
|
},
|
|
1206
1206
|
".cm-table-active.cm-table-separator": {
|
|
@@ -1208,19 +1208,19 @@ function createTableTheme(EditorView) {
|
|
|
1208
1208
|
color: "var(--text-muted)"
|
|
1209
1209
|
},
|
|
1210
1210
|
".cm-table-row-even": {
|
|
1211
|
-
backgroundColor: "
|
|
1211
|
+
backgroundColor: "transparent"
|
|
1212
1212
|
},
|
|
1213
1213
|
".cm-table-row-odd": {
|
|
1214
|
-
backgroundColor: "var(--table-row-odd-bg, rgba(80, 140, 220, 0.
|
|
1214
|
+
backgroundColor: "var(--table-row-odd-bg, rgba(80, 140, 220, 0.08))"
|
|
1215
1215
|
},
|
|
1216
1216
|
".cm-table-active.cm-table-header": {
|
|
1217
1217
|
backgroundColor: "rgba(80, 120, 200, 0.10)"
|
|
1218
1218
|
},
|
|
1219
1219
|
".cm-table-active.cm-table-row-even": {
|
|
1220
|
-
backgroundColor: "
|
|
1220
|
+
backgroundColor: "transparent"
|
|
1221
1221
|
},
|
|
1222
1222
|
".cm-table-active.cm-table-row-odd": {
|
|
1223
|
-
backgroundColor: "rgba(80, 140, 220, 0.
|
|
1223
|
+
backgroundColor: "rgba(80, 140, 220, 0.05)"
|
|
1224
1224
|
},
|
|
1225
1225
|
".cm-table-copy-btn": {
|
|
1226
1226
|
position: "absolute",
|
|
@@ -1633,6 +1633,7 @@ function createEditor(container, options = {}, backend = {}) {
|
|
|
1633
1633
|
const activePlugins = new Map;
|
|
1634
1634
|
pluginStates.set("__mockEditor", mockEditor);
|
|
1635
1635
|
pluginStates.set("__mockOwner", mockOwner);
|
|
1636
|
+
let currentMode = "ir";
|
|
1636
1637
|
function makeContext() {
|
|
1637
1638
|
return {
|
|
1638
1639
|
view,
|
|
@@ -1746,7 +1747,40 @@ function createEditor(container, options = {}, backend = {}) {
|
|
|
1746
1747
|
},
|
|
1747
1748
|
use,
|
|
1748
1749
|
unuse,
|
|
1749
|
-
registerSuggest
|
|
1750
|
+
registerSuggest,
|
|
1751
|
+
setTheme(theme) {
|
|
1752
|
+
if (theme === "light") {
|
|
1753
|
+
container.classList.add("theme-light");
|
|
1754
|
+
container.classList.remove("theme-dark");
|
|
1755
|
+
} else {
|
|
1756
|
+
container.classList.add("theme-dark");
|
|
1757
|
+
container.classList.remove("theme-light");
|
|
1758
|
+
}
|
|
1759
|
+
document.body.classList.toggle("theme-dark", theme === "dark");
|
|
1760
|
+
document.body.classList.toggle("theme-light", theme === "light");
|
|
1761
|
+
},
|
|
1762
|
+
setMode(mode) {
|
|
1763
|
+
if (mode === currentMode)
|
|
1764
|
+
return;
|
|
1765
|
+
currentMode = mode;
|
|
1766
|
+
const { EditorView: EV, Compartment } = window.__cm6;
|
|
1767
|
+
if (mode === "ir" || mode === "view") {
|
|
1768
|
+
container.classList.add("is-live-preview");
|
|
1769
|
+
container.classList.remove("is-source-mode");
|
|
1770
|
+
} else {
|
|
1771
|
+
container.classList.remove("is-live-preview");
|
|
1772
|
+
container.classList.add("is-source-mode");
|
|
1773
|
+
}
|
|
1774
|
+
view.dispatch({
|
|
1775
|
+
effects: window.__cm6.StateEffect.appendConfig.of(EV.editable.of(mode !== "view"))
|
|
1776
|
+
});
|
|
1777
|
+
view.dispatch({
|
|
1778
|
+
effects: window.__cm6.StateEffect.appendConfig.of([])
|
|
1779
|
+
});
|
|
1780
|
+
},
|
|
1781
|
+
getMode() {
|
|
1782
|
+
return currentMode;
|
|
1783
|
+
}
|
|
1750
1784
|
};
|
|
1751
1785
|
return instance;
|
|
1752
1786
|
}
|
package/package.json
CHANGED