Skip to content

Commit

Permalink
fix: fix compatibility issue for obsidian v0.15.0+
Browse files Browse the repository at this point in the history
close #51
  • Loading branch information
aidenlx committed Jun 15, 2022
1 parent b133af5 commit 8b7723d
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 102 deletions.
2 changes: 1 addition & 1 deletion esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ try {
format: "cjs",
mainFields: ["browser", "module", "main"],
banner: { js: banner },
sourcemap: isProd ? false : "inline",
sourcemap: "inline",
minify: isProd,
define: {
"process.env.NODE_ENV": JSON.stringify(process.env.BUILD),
Expand Down
2 changes: 1 addition & 1 deletion manifest-beta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "obsidian-icon-shortcodes",
"name": "Icon Shortcodes",
"version": "0.9.5",
"minAppVersion": "0.13.27",
"minAppVersion": "0.15.0",
"description": "Insert emoji and custom icons with shortcodes",
"author": "AidenLx",
"authorUrl": "https://github.com/aidenlx",
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "obsidian-icon-shortcodes",
"name": "Icon Shortcodes",
"version": "0.9.5",
"minAppVersion": "0.13.27",
"minAppVersion": "0.15.0",
"description": "Insert emoji and custom icons with shortcodes",
"author": "AidenLx",
"authorUrl": "https://github.com/aidenlx",
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@
"@aidenlx/prettier-config": "^0.1.0",
"@aidenlx/release-it-config": "^0.1.11",
"@aidenlx/ts-config": "^0.1.2",
"@codemirror/language": "^0.19.7",
"@codemirror/rangeset": "^0.19.8",
"@codemirror/state": "^0.19.9",
"@codemirror/stream-parser": "github:lishid/stream-parser",
"@codemirror/view": "^0.19.45",
"@codemirror/language": "github:lishid/cm-language",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"@fortawesome/fontawesome-free": "6.0.0",
"@lezer/common": "^0.15.11",
"@release-it/bumper": "^3.0.1",
Expand Down Expand Up @@ -85,7 +83,7 @@
"mini-svg-data-uri": "^1.4.3",
"monkey-around": "^2.3.0",
"node-emoji": "github:rhysd/node-emoji#fix-gh-short-codes",
"obsidian": "^0.13.26",
"obsidian": "latest",
"path-browserify": "^1.0.1",
"preact": "^10.5.15",
"prettier": "^2.4.1",
Expand Down
6 changes: 3 additions & 3 deletions src/icon-in-editor/state.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { syntaxTree } from "@codemirror/language";
import { tokenClassNodeProp } from "@codemirror/language";
import {
Range,
RangeSet,
RangeSetBuilder,
RangeValue,
} from "@codemirror/rangeset";
} from "@codemirror/state";
import { EditorState, StateField } from "@codemirror/state";
import { tokenClassNodeProp } from "@codemirror/stream-parser";
import type { NodeType } from "@lezer/common";

import {
Expand Down Expand Up @@ -82,7 +82,7 @@ const getShortcodePosField = (plugin: IconSC) => {
syntaxTree(state).iterate({
from: from - 1,
to: to + 1,
enter: (type, from, to) => {
enter: ({ type, from, to }) => {
if (type.name === "Document") return;
if (from !== prevTo) saveRange(prevTo, from);
prevTo = to;
Expand Down
15 changes: 12 additions & 3 deletions src/icon-in-editor/view-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { DecorationSet, PluginField, ViewUpdate } from "@codemirror/view";
import { EditorView, ViewPlugin } from "@codemirror/view";
import {
Decoration,
DecorationSet,
EditorView,
ViewPlugin,
ViewUpdate,
} from "@codemirror/view";
import { editorLivePreviewField } from "obsidian";

import type IconSC from "../isc-main";
Expand Down Expand Up @@ -39,7 +44,11 @@ const getIconLivePreviewPlugin = (plugin: IconSC): ViewPlugin<IconPlugin> => {
mousedown: IconClickHandler,
},
decorations: (v) => v.decorations,
provide: PluginField.atomicRanges.from((v) => v.decorations),
provide: (plugin) =>
EditorView.atomicRanges.of((view) => {
let value = view.plugin(plugin);
return value ? value.decorations : Decoration.none;
}),
});
/* eslint-disable prefer-arrow/prefer-arrow-functions */
function IconClickHandler(
Expand Down
144 changes: 57 additions & 87 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ __metadata:
"@aidenlx/prettier-config": ^0.1.0
"@aidenlx/release-it-config": ^0.1.11
"@aidenlx/ts-config": ^0.1.2
"@codemirror/language": ^0.19.7
"@codemirror/rangeset": ^0.19.8
"@codemirror/state": ^0.19.9
"@codemirror/stream-parser": "github:lishid/stream-parser"
"@codemirror/view": ^0.19.45
"@codemirror/language": "github:lishid/cm-language"
"@codemirror/state": ^6.0.0
"@codemirror/view": ^6.0.0
"@fortawesome/fontawesome-free": 6.0.0
"@lezer/common": ^0.15.11
"@release-it/bumper": ^3.0.1
Expand Down Expand Up @@ -94,7 +92,7 @@ __metadata:
mini-svg-data-uri: ^1.4.3
monkey-around: ^2.3.0
node-emoji: "github:rhysd/node-emoji#fix-gh-short-codes"
obsidian: ^0.13.26
obsidian: latest
path-browserify: ^1.0.1
preact: ^10.5.15
prettier: ^2.4.1
Expand Down Expand Up @@ -178,80 +176,35 @@ __metadata:
languageName: node
linkType: hard

"@codemirror/language@npm:^0.19.0, @codemirror/language@npm:^0.19.7":
version: 0.19.7
resolution: "@codemirror/language@npm:0.19.7::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2F%40codemirror%2Flanguage%2F-%2Flanguage-0.19.7.tgz"
dependencies:
"@codemirror/state": ^0.19.0
"@codemirror/text": ^0.19.0
"@codemirror/view": ^0.19.0
"@lezer/common": ^0.15.5
"@lezer/lr": ^0.15.0
checksum: 5dacd9d138eb4fa361ea9927d13badd94b1f64b15c403bb2af4fa178f782df41cc85e18f57f89e11014c1b7333f1d4a4ebe8da5762bfc4e7a49219dedf0d3f7b
languageName: node
linkType: hard

"@codemirror/rangeset@npm:^0.19.5, @codemirror/rangeset@npm:^0.19.8":
version: 0.19.8
resolution: "@codemirror/rangeset@npm:0.19.8::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2F%40codemirror%2Frangeset%2F-%2Frangeset-0.19.8.tgz"
dependencies:
"@codemirror/state": ^0.19.0
checksum: 2cb4fb31878f8f05c4e843fe01570b18c3bcaedb241af3187bbc6416cb6763736c5f103e77b10a935d9c77a13b642d36f7631e791a6ee5ed9c065ff6d1eb068c
languageName: node
linkType: hard

"@codemirror/state@npm:^0.19.0, @codemirror/state@npm:^0.19.3, @codemirror/state@npm:^0.19.6, @codemirror/state@npm:^0.19.9":
version: 0.19.9
resolution: "@codemirror/state@npm:0.19.9::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2F%40codemirror%2Fstate%2F-%2Fstate-0.19.9.tgz"
dependencies:
"@codemirror/text": ^0.19.0
checksum: 5d20c80e51eab6f82be28edadd9e774c864c48e4ba15c23b39277bcb3948f5b716ba07fdefcda556324dbfba19de8f91defa7e338390a714f9deb1e92f5d21bf
languageName: node
linkType: hard

"@codemirror/stream-parser@github:lishid/stream-parser":
version: 0.19.6
resolution: "@codemirror/stream-parser@https://github.com/lishid/stream-parser.git#commit=26c8edae7bdf63dc34d358d1de640bdd12e7b09f"
"@codemirror/language@github:lishid/cm-language":
version: 6.0.0
resolution: "@codemirror/language@https://github.com/lishid/cm-language.git#commit=b32c52b99603deef33dd607600ce32d3cc2f83c1"
dependencies:
"@codemirror/language": ^0.19.0
"@codemirror/state": ^0.19.0
"@codemirror/text": ^0.19.0
"@lezer/common": ^0.15.0
"@lezer/lr": ^0.15.0
checksum: 32eebc69eb1c367332917ba9fe09327bf71e4afc02262b74e0b1fc844eef69c098691acc0ed302dc53a040f08dadfcaebdada15ac1469ec544339ab82a39e3c5
languageName: node
linkType: hard

"@codemirror/text@npm:^0.19.0":
version: 0.19.6
resolution: "@codemirror/text@npm:0.19.6::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2F%40codemirror%2Ftext%2F-%2Ftext-0.19.6.tgz"
checksum: 685e46c1f0114a216081b7a070460e1b0db9c51b0a2b361e9ed90e5ea2ed89d86a7a834b76f7c63b27fd192809d9414e7a15e0d186bd15cdb5d4f85639d434f0
"@codemirror/state": ^6.0.0
"@codemirror/view": ^6.0.0
"@lezer/common": ^1.0.0
"@lezer/highlight": ^1.0.0
"@lezer/lr": ^1.0.0
style-mod: ^4.0.0
checksum: 43699b1e9a3fca3e1c31adc7a03fe025e6b2a8f7c8564189b9ae2ea87e06051d0994b4f4a7aab651765f5b42fe2011662e7db09fa176d82721dc6e4bb534e208
languageName: node
linkType: hard

"@codemirror/view@npm:^0.19.0, @codemirror/view@npm:^0.19.45":
version: 0.19.45
resolution: "@codemirror/view@npm:0.19.45::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2F%40codemirror%2Fview%2F-%2Fview-0.19.45.tgz"
dependencies:
"@codemirror/rangeset": ^0.19.5
"@codemirror/state": ^0.19.3
"@codemirror/text": ^0.19.0
style-mod: ^4.0.0
w3c-keyname: ^2.2.4
checksum: e8a24af04244e5d3ef4d714903914b9def565d1f479e3585eeccca019748a65ff60bc640903194289b6a33613c0c1a0f1c866b4fc3e0a9dfc2afad5ac23e527a
"@codemirror/state@npm:^6.0.0":
version: 6.0.0
resolution: "@codemirror/state@npm:6.0.0::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2F%40codemirror%2Fstate%2F-%2Fstate-6.0.0.tgz"
checksum: 7f6286d8e8b8c5e7018f9ee81943b35324150fd15ccc77ae220b904a73e10fa480ab51a89663d956a9c2fae70b13d754da0bf535092759158cc3707743aa236f
languageName: node
linkType: hard

"@codemirror/view@npm:^0.19.31":
version: 0.19.44
resolution: "@codemirror/view@npm:0.19.44::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2F%40codemirror%2Fview%2F-%2Fview-0.19.44.tgz"
"@codemirror/view@npm:^6.0.0":
version: 6.0.0
resolution: "@codemirror/view@npm:6.0.0::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2F%40codemirror%2Fview%2F-%2Fview-6.0.0.tgz"
dependencies:
"@codemirror/rangeset": ^0.19.5
"@codemirror/state": ^0.19.3
"@codemirror/text": ^0.19.0
"@codemirror/state": ^6.0.0
style-mod: ^4.0.0
w3c-keyname: ^2.2.4
checksum: e8b60f7456677680676018c12965dad357dd097915ea9c2b128e3d385a0ed655020f5c45d30a70ec49644ba844c1ca790ab000d6fb8d7cadcfcbf3f473c5e876
checksum: 1029fbf3d249ca0f2425dfba6a1db517e77ca06274a0b8886903bf88456d6b6f25df1b2029e7824775b71709617a83623daeb8afd329a8ee3f60ca4f704a50fa
languageName: node
linkType: hard

Expand Down Expand Up @@ -397,19 +350,35 @@ __metadata:
languageName: node
linkType: hard

"@lezer/common@npm:^0.15.0, @lezer/common@npm:^0.15.11, @lezer/common@npm:^0.15.5":
"@lezer/common@npm:^0.15.11":
version: 0.15.11
resolution: "@lezer/common@npm:0.15.11::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2F%40lezer%2Fcommon%2F-%2Fcommon-0.15.11.tgz"
checksum: 5cabce5493b9392bb54816d6b921dae20d154b175423479b408e990fdf572fd2ed77a6b2df0ed6ef26d779eeb66ec737d10aa2312e1ffecbcec22e14b19f7be3
languageName: node
linkType: hard

"@lezer/lr@npm:^0.15.0":
version: 0.15.8
resolution: "@lezer/lr@npm:0.15.8::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2F%40lezer%2Flr%2F-%2Flr-0.15.8.tgz"
"@lezer/common@npm:^1.0.0":
version: 1.0.0
resolution: "@lezer/common@npm:1.0.0::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2F%40lezer%2Fcommon%2F-%2Fcommon-1.0.0.tgz"
checksum: 0ba652b39f9ff073a6a8a3376a74279f2c2d2ccdd4d2bb57c7b607341dbdbf64baf9c23a196314f09349d175623bc73a6a0b6a0eeb2cc63f3a1190fd631f7c31
languageName: node
linkType: hard

"@lezer/highlight@npm:^1.0.0":
version: 1.0.0
resolution: "@lezer/highlight@npm:1.0.0::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2F%40lezer%2Fhighlight%2F-%2Fhighlight-1.0.0.tgz"
dependencies:
"@lezer/common": ^1.0.0
checksum: 9ce6c4ea041598e2500f11610e74163eba0361954df8dbf5d12b96dc8b5ab5da8af2defda7ff5728ca460d49f053a7502f2840361bcd8dcf30e8a23f7c30672a
languageName: node
linkType: hard

"@lezer/lr@npm:^1.0.0":
version: 1.0.0
resolution: "@lezer/lr@npm:1.0.0::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2F%40lezer%2Flr%2F-%2Flr-1.0.0.tgz"
dependencies:
"@lezer/common": ^0.15.0
checksum: e741225d6ac9cf08f8016bad49622fbd4a4e0d20c2e8c2b38a0abf0ddca69c58275b0ebdb9d5dde2905cf84f6977bc302f7ed5e5ba42c23afa27e9e65b900f36
"@lezer/common": ^1.0.0
checksum: 1365a2d1fa0a40815a03a635506a0215475b778d8b8907d274b8ee4b0732fcb7266799b50db7c4517254da1d245c153c348fd0d7b1db93b7d66926b9c538ee43
languageName: node
linkType: hard

Expand Down Expand Up @@ -4796,10 +4765,10 @@ __metadata:
languageName: node
linkType: hard

"moment@npm:2.29.1":
version: 2.29.1
resolution: "moment@npm:2.29.1::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2Fmoment%2F-%2Fmoment-2.29.1.tgz"
checksum: 1e14d5f422a2687996be11dd2d50c8de3bd577c4a4ca79ba5d02c397242a933e5b941655de6c8cb90ac18f01cc4127e55b4a12ae3c527a6c0a274e455979345e
"moment@npm:2.29.3":
version: 2.29.3
resolution: "moment@npm:2.29.3::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2Fmoment%2F-%2Fmoment-2.29.3.tgz"
checksum: 2e780e36d9a1823c08a1b6313cbb08bd01ecbb2a9062095820a34f42c878991ccba53abaa6abb103fd5c01e763724f295162a8c50b7e95b4f1c992ef0772d3f0
languageName: node
linkType: hard

Expand Down Expand Up @@ -5027,15 +4996,16 @@ __metadata:
languageName: node
linkType: hard

"obsidian@npm:^0.13.26":
version: 0.13.26
resolution: "obsidian@npm:0.13.26"
"obsidian@npm:latest":
version: 0.15.0
resolution: "obsidian@npm:0.15.0::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2Fobsidian%2F-%2Fobsidian-0.15.0.tgz"
dependencies:
"@codemirror/state": ^0.19.6
"@codemirror/view": ^0.19.31
"@types/codemirror": 0.0.108
moment: 2.29.1
checksum: ddc91063eb72677368a9f3c823df180ec161c158d23688bfe0f96a7aa86cb640202d0e5e3b9f91d02b90673b6d8ea72ad85d080a18c237a73a847e657c79560f
moment: 2.29.3
peerDependencies:
"@codemirror/state": ^6.0.0
"@codemirror/view": ^6.0.0
checksum: c48aef8e9ed4379d34e26d4486f1a4e8840ccbf2cfd0193f402c305b41fd1ceda23a72764843b47817c9b24e9fac2387c49d23315ba26cdcb54ff26d2dca5035
languageName: node
linkType: hard

Expand Down

0 comments on commit 8b7723d

Please sign in to comment.