Compare commits

...

19 Commits

Author SHA1 Message Date
inhji 1c2b1e9dea Merge pull request 'devel' (#14) from devel into main
Reviewed-on: #14
2023-06-11 17:18:17 +02:00
inhji 431c0add43 Merge branch 'main' into devel 2023-06-11 17:18:10 +02:00
Inhji 9f63a40eca version 2.1.0 2023-06-11 17:17:30 +02:00
Inhji c14c231d34 add support for writing back url into frontmatter after publish 2023-06-11 17:16:06 +02:00
inhji 808c190a77 Merge pull request 'Update dependency @types/node to v18' (#12) from renovate/node-18.x into devel
Reviewed-on: #12
2023-06-10 10:00:09 +02:00
inhji a1c809c12f Merge branch 'devel' into renovate/node-18.x 2023-06-10 10:00:02 +02:00
inhji d8cbfaaec9 Merge pull request 'Update dependency tslib to v2.5.3' (#9) from renovate/tslib-2.x into devel
Reviewed-on: #9
2023-06-10 09:59:35 +02:00
Daft Bot 972f8d9671 Update dependency @types/node to v18 2023-06-10 09:57:38 +02:00
Daft Bot f3ce3e409d Update dependency tslib to v2.5.3 2023-06-10 09:57:34 +02:00
inhji 85e52fd489 Merge pull request 'Update dependency @types/node to v16.18.35' (#6) from renovate/node-16.x-lockfile into devel
Reviewed-on: #6
2023-06-10 09:53:13 +02:00
inhji 04e9fbdb8c Merge branch 'devel' into renovate/node-16.x-lockfile 2023-06-10 09:53:07 +02:00
inhji 8c11064ed4 Merge pull request 'Update typescript-eslint monorepo to v5.59.9' (#11) from renovate/typescript-eslint-monorepo into devel
Reviewed-on: #11
2023-06-10 09:52:57 +02:00
inhji 72be75afd0 Merge branch 'devel' into renovate/typescript-eslint-monorepo 2023-06-10 09:52:42 +02:00
inhji 1011535d7a Merge pull request 'Update dependency typescript to v5' (#13) from renovate/typescript-5.x into devel
Reviewed-on: #13
2023-06-10 09:52:25 +02:00
Daft Bot 56f7597313 Update dependency typescript to v5 2023-06-10 09:39:56 +02:00
Daft Bot dc9ae84c6f Update typescript-eslint monorepo to v5.59.9 2023-06-10 09:39:42 +02:00
Inhji c880bda827 Update dependency @types/node to v16.18.35 2023-06-10 09:25:22 +02:00
inhji d12ef24bfc Merge pull request 'Configure Renovate' (#5) from renovate/configure into devel
Reviewed-on: #5
2023-06-10 09:24:25 +02:00
Inhji 5306c0c2fa Add renovate.json 2023-06-10 09:23:23 +02:00
10 changed files with 466 additions and 155 deletions

331
package-lock.json generated
View File

@ -1,22 +1,22 @@
{
"name": "microblog-publish-plugin",
"version": "1.6.0",
"version": "2.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "microblog-publish-plugin",
"version": "1.6.0",
"version": "2.0.0",
"license": "MIT",
"devDependencies": {
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "5.29.0",
"@typescript-eslint/parser": "5.29.0",
"@types/node": "^18.0.0",
"@typescript-eslint/eslint-plugin": "5.59.9",
"@typescript-eslint/parser": "5.59.9",
"builtin-modules": "3.3.0",
"esbuild": "0.14.47",
"obsidian": "latest",
"tslib": "2.4.0",
"typescript": "4.7.4"
"tslib": "2.5.3",
"typescript": "5.1.3"
}
},
"node_modules/@codemirror/state": {
@ -38,6 +38,30 @@
"w3c-keyname": "^2.2.4"
}
},
"node_modules/@eslint-community/eslint-utils": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz",
"integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==",
"dev": true,
"dependencies": {
"eslint-visitor-keys": "^3.3.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"peerDependencies": {
"eslint": "^6.0.0 || ^7.0.0 || >=8.0.0"
}
},
"node_modules/@eslint-community/regexpp": {
"version": "4.5.1",
"resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.1.tgz",
"integrity": "sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==",
"dev": true,
"engines": {
"node": "^12.0.0 || ^14.0.0 || >=16.0.0"
}
},
"node_modules/@eslint/eslintrc": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.2.tgz",
@ -160,15 +184,21 @@
"dev": true
},
"node_modules/@types/json-schema": {
"version": "7.0.11",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
"version": "7.0.12",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz",
"integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==",
"dev": true
},
"node_modules/@types/node": {
"version": "16.11.59",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.59.tgz",
"integrity": "sha512-6u+36Dj3aDzhfBVUf/mfmc92OEdzQ2kx2jcXGdigfl70E/neV21ZHE6UCz4MDzTRcVqGAM27fk+DLXvyDsn3Jw==",
"version": "18.16.17",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.17.tgz",
"integrity": "sha512-QAkjjRA1N7gPJeAP4WLXZtYv6+eMXFNviqktCDt4GLcmCugMr5BcRHfkOjCQzvCsnMp+L79a54zBkbw356xv9Q==",
"dev": true
},
"node_modules/@types/semver": {
"version": "7.5.0",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz",
"integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==",
"dev": true
},
"node_modules/@types/tern": {
@ -181,18 +211,19 @@
}
},
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.29.0.tgz",
"integrity": "sha512-kgTsISt9pM53yRFQmLZ4npj99yGl3x3Pl7z4eA66OuTzAGC4bQB5H5fuLwPnqTKU3yyrrg4MIhjF17UYnL4c0w==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.9.tgz",
"integrity": "sha512-4uQIBq1ffXd2YvF7MAvehWKW3zVv/w+mSfRAu+8cKbfj3nwzyqJLNcZJpQ/WZ1HLbJDiowwmQ6NO+63nCA+fqA==",
"dev": true,
"dependencies": {
"@typescript-eslint/scope-manager": "5.29.0",
"@typescript-eslint/type-utils": "5.29.0",
"@typescript-eslint/utils": "5.29.0",
"@eslint-community/regexpp": "^4.4.0",
"@typescript-eslint/scope-manager": "5.59.9",
"@typescript-eslint/type-utils": "5.59.9",
"@typescript-eslint/utils": "5.59.9",
"debug": "^4.3.4",
"functional-red-black-tree": "^1.0.1",
"grapheme-splitter": "^1.0.4",
"ignore": "^5.2.0",
"regexpp": "^3.2.0",
"natural-compare-lite": "^1.4.0",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
},
@ -214,14 +245,14 @@
}
},
"node_modules/@typescript-eslint/parser": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.29.0.tgz",
"integrity": "sha512-ruKWTv+x0OOxbzIw9nW5oWlUopvP/IQDjB5ZqmTglLIoDTctLlAJpAQFpNPJP/ZI7hTT9sARBosEfaKbcFuECw==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.9.tgz",
"integrity": "sha512-FsPkRvBtcLQ/eVK1ivDiNYBjn3TGJdXy2fhXX+rc7czWl4ARwnpArwbihSOHI2Peg9WbtGHrbThfBUkZZGTtvQ==",
"dev": true,
"dependencies": {
"@typescript-eslint/scope-manager": "5.29.0",
"@typescript-eslint/types": "5.29.0",
"@typescript-eslint/typescript-estree": "5.29.0",
"@typescript-eslint/scope-manager": "5.59.9",
"@typescript-eslint/types": "5.59.9",
"@typescript-eslint/typescript-estree": "5.59.9",
"debug": "^4.3.4"
},
"engines": {
@ -241,13 +272,13 @@
}
},
"node_modules/@typescript-eslint/scope-manager": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.29.0.tgz",
"integrity": "sha512-etbXUT0FygFi2ihcxDZjz21LtC+Eps9V2xVx09zFoN44RRHPrkMflidGMI+2dUs821zR1tDS6Oc9IXxIjOUZwA==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.9.tgz",
"integrity": "sha512-8RA+E+w78z1+2dzvK/tGZ2cpGigBZ58VMEHDZtpE1v+LLjzrYGc8mMaTONSxKyEkz3IuXFM0IqYiGHlCsmlZxQ==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.29.0",
"@typescript-eslint/visitor-keys": "5.29.0"
"@typescript-eslint/types": "5.59.9",
"@typescript-eslint/visitor-keys": "5.59.9"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -258,12 +289,13 @@
}
},
"node_modules/@typescript-eslint/type-utils": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.29.0.tgz",
"integrity": "sha512-JK6bAaaiJozbox3K220VRfCzLa9n0ib/J+FHIwnaV3Enw/TO267qe0pM1b1QrrEuy6xun374XEAsRlA86JJnyg==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.59.9.tgz",
"integrity": "sha512-ksEsT0/mEHg9e3qZu98AlSrONAQtrSTljL3ow9CGej8eRo7pe+yaC/mvTjptp23Xo/xIf2mLZKC6KPv4Sji26Q==",
"dev": true,
"dependencies": {
"@typescript-eslint/utils": "5.29.0",
"@typescript-eslint/typescript-estree": "5.59.9",
"@typescript-eslint/utils": "5.59.9",
"debug": "^4.3.4",
"tsutils": "^3.21.0"
},
@ -284,9 +316,9 @@
}
},
"node_modules/@typescript-eslint/types": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.29.0.tgz",
"integrity": "sha512-X99VbqvAXOMdVyfFmksMy3u8p8yoRGITgU1joBJPzeYa0rhdf5ok9S56/itRoUSh99fiDoMtarSIJXo7H/SnOg==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.9.tgz",
"integrity": "sha512-uW8H5NRgTVneSVTfiCVffBb8AbwWSKg7qcA4Ot3JI3MPCJGsB4Db4BhvAODIIYE5mNj7Q+VJkK7JxmRhk2Lyjw==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -297,13 +329,13 @@
}
},
"node_modules/@typescript-eslint/typescript-estree": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.29.0.tgz",
"integrity": "sha512-mQvSUJ/JjGBdvo+1LwC+GY2XmSYjK1nAaVw2emp/E61wEVYEyibRHCqm1I1vEKbXCpUKuW4G7u9ZCaZhJbLoNQ==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.9.tgz",
"integrity": "sha512-pmM0/VQ7kUhd1QyIxgS+aRvMgw+ZljB3eDb+jYyp6d2bC0mQWLzUDF+DLwCTkQ3tlNyVsvZRXjFyV0LkU/aXjA==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.29.0",
"@typescript-eslint/visitor-keys": "5.29.0",
"@typescript-eslint/types": "5.59.9",
"@typescript-eslint/visitor-keys": "5.59.9",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
@ -324,17 +356,19 @@
}
},
"node_modules/@typescript-eslint/utils": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.29.0.tgz",
"integrity": "sha512-3Eos6uP1nyLOBayc/VUdKZikV90HahXE5Dx9L5YlSd/7ylQPXhLk1BYb29SDgnBnTp+jmSZUU0QxUiyHgW4p7A==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.9.tgz",
"integrity": "sha512-1PuMYsju/38I5Ggblaeb98TOoUvjhRvLpLa1DoTOFaLWqaXl/1iQ1eGurTXgBY58NUdtfTXKP5xBq7q9NDaLKg==",
"dev": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@types/json-schema": "^7.0.9",
"@typescript-eslint/scope-manager": "5.29.0",
"@typescript-eslint/types": "5.29.0",
"@typescript-eslint/typescript-estree": "5.29.0",
"@types/semver": "^7.3.12",
"@typescript-eslint/scope-manager": "5.59.9",
"@typescript-eslint/types": "5.59.9",
"@typescript-eslint/typescript-estree": "5.59.9",
"eslint-scope": "^5.1.1",
"eslint-utils": "^3.0.0"
"semver": "^7.3.7"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -348,12 +382,12 @@
}
},
"node_modules/@typescript-eslint/visitor-keys": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.29.0.tgz",
"integrity": "sha512-Hpb/mCWsjILvikMQoZIE3voc9wtQcS0A9FUw3h8bhr9UxBdtI/tw1ZDZUOXHXLOVMedKCH5NxyzATwnU78bWCQ==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.9.tgz",
"integrity": "sha512-bT7s0td97KMaLwpEBckbzj/YohnvXtqbe2XgqNvTl6RJVakY5mvENOTPvw5u66nljfZxthESpDozs86U+oLY8Q==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.29.0",
"@typescript-eslint/types": "5.59.9",
"eslint-visitor-keys": "^3.3.0"
},
"engines": {
@ -745,6 +779,7 @@
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz",
"integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==",
"dev": true,
"peer": true,
"dependencies": {
"eslint-visitor-keys": "^2.0.0"
},
@ -763,6 +798,7 @@
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz",
"integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==",
"dev": true,
"peer": true,
"engines": {
"node": ">=10"
}
@ -1009,12 +1045,6 @@
"dev": true,
"peer": true
},
"node_modules/functional-red-black-tree": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz",
"integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==",
"dev": true
},
"node_modules/glob": {
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
@ -1089,8 +1119,7 @@
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz",
"integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==",
"dev": true,
"peer": true
"dev": true
},
"node_modules/has-flag": {
"version": "4.0.0",
@ -1333,6 +1362,12 @@
"dev": true,
"peer": true
},
"node_modules/natural-compare-lite": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz",
"integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==",
"dev": true
},
"node_modules/obsidian": {
"version": "0.16.3",
"resolved": "https://registry.npmjs.org/obsidian/-/obsidian-0.16.3.tgz",
@ -1516,6 +1551,7 @@
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz",
"integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==",
"dev": true,
"peer": true,
"engines": {
"node": ">=8"
},
@ -1695,9 +1731,9 @@
}
},
"node_modules/tslib": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz",
"integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==",
"version": "2.5.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.3.tgz",
"integrity": "sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==",
"dev": true
},
"node_modules/tsutils": {
@ -1748,16 +1784,16 @@
}
},
"node_modules/typescript": {
"version": "4.7.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz",
"integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==",
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.3.tgz",
"integrity": "sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
"node": ">=14.17"
}
},
"node_modules/uri-js": {
@ -1850,6 +1886,21 @@
"w3c-keyname": "^2.2.4"
}
},
"@eslint-community/eslint-utils": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz",
"integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==",
"dev": true,
"requires": {
"eslint-visitor-keys": "^3.3.0"
}
},
"@eslint-community/regexpp": {
"version": "4.5.1",
"resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.1.tgz",
"integrity": "sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==",
"dev": true
},
"@eslint/eslintrc": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.2.tgz",
@ -1943,15 +1994,21 @@
"dev": true
},
"@types/json-schema": {
"version": "7.0.11",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
"version": "7.0.12",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz",
"integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==",
"dev": true
},
"@types/node": {
"version": "16.11.59",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.59.tgz",
"integrity": "sha512-6u+36Dj3aDzhfBVUf/mfmc92OEdzQ2kx2jcXGdigfl70E/neV21ZHE6UCz4MDzTRcVqGAM27fk+DLXvyDsn3Jw==",
"version": "18.16.17",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.17.tgz",
"integrity": "sha512-QAkjjRA1N7gPJeAP4WLXZtYv6+eMXFNviqktCDt4GLcmCugMr5BcRHfkOjCQzvCsnMp+L79a54zBkbw356xv9Q==",
"dev": true
},
"@types/semver": {
"version": "7.5.0",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz",
"integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==",
"dev": true
},
"@types/tern": {
@ -1964,69 +2021,71 @@
}
},
"@typescript-eslint/eslint-plugin": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.29.0.tgz",
"integrity": "sha512-kgTsISt9pM53yRFQmLZ4npj99yGl3x3Pl7z4eA66OuTzAGC4bQB5H5fuLwPnqTKU3yyrrg4MIhjF17UYnL4c0w==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.9.tgz",
"integrity": "sha512-4uQIBq1ffXd2YvF7MAvehWKW3zVv/w+mSfRAu+8cKbfj3nwzyqJLNcZJpQ/WZ1HLbJDiowwmQ6NO+63nCA+fqA==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "5.29.0",
"@typescript-eslint/type-utils": "5.29.0",
"@typescript-eslint/utils": "5.29.0",
"@eslint-community/regexpp": "^4.4.0",
"@typescript-eslint/scope-manager": "5.59.9",
"@typescript-eslint/type-utils": "5.59.9",
"@typescript-eslint/utils": "5.59.9",
"debug": "^4.3.4",
"functional-red-black-tree": "^1.0.1",
"grapheme-splitter": "^1.0.4",
"ignore": "^5.2.0",
"regexpp": "^3.2.0",
"natural-compare-lite": "^1.4.0",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
}
},
"@typescript-eslint/parser": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.29.0.tgz",
"integrity": "sha512-ruKWTv+x0OOxbzIw9nW5oWlUopvP/IQDjB5ZqmTglLIoDTctLlAJpAQFpNPJP/ZI7hTT9sARBosEfaKbcFuECw==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.9.tgz",
"integrity": "sha512-FsPkRvBtcLQ/eVK1ivDiNYBjn3TGJdXy2fhXX+rc7czWl4ARwnpArwbihSOHI2Peg9WbtGHrbThfBUkZZGTtvQ==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "5.29.0",
"@typescript-eslint/types": "5.29.0",
"@typescript-eslint/typescript-estree": "5.29.0",
"@typescript-eslint/scope-manager": "5.59.9",
"@typescript-eslint/types": "5.59.9",
"@typescript-eslint/typescript-estree": "5.59.9",
"debug": "^4.3.4"
}
},
"@typescript-eslint/scope-manager": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.29.0.tgz",
"integrity": "sha512-etbXUT0FygFi2ihcxDZjz21LtC+Eps9V2xVx09zFoN44RRHPrkMflidGMI+2dUs821zR1tDS6Oc9IXxIjOUZwA==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.9.tgz",
"integrity": "sha512-8RA+E+w78z1+2dzvK/tGZ2cpGigBZ58VMEHDZtpE1v+LLjzrYGc8mMaTONSxKyEkz3IuXFM0IqYiGHlCsmlZxQ==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.29.0",
"@typescript-eslint/visitor-keys": "5.29.0"
"@typescript-eslint/types": "5.59.9",
"@typescript-eslint/visitor-keys": "5.59.9"
}
},
"@typescript-eslint/type-utils": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.29.0.tgz",
"integrity": "sha512-JK6bAaaiJozbox3K220VRfCzLa9n0ib/J+FHIwnaV3Enw/TO267qe0pM1b1QrrEuy6xun374XEAsRlA86JJnyg==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.59.9.tgz",
"integrity": "sha512-ksEsT0/mEHg9e3qZu98AlSrONAQtrSTljL3ow9CGej8eRo7pe+yaC/mvTjptp23Xo/xIf2mLZKC6KPv4Sji26Q==",
"dev": true,
"requires": {
"@typescript-eslint/utils": "5.29.0",
"@typescript-eslint/typescript-estree": "5.59.9",
"@typescript-eslint/utils": "5.59.9",
"debug": "^4.3.4",
"tsutils": "^3.21.0"
}
},
"@typescript-eslint/types": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.29.0.tgz",
"integrity": "sha512-X99VbqvAXOMdVyfFmksMy3u8p8yoRGITgU1joBJPzeYa0rhdf5ok9S56/itRoUSh99fiDoMtarSIJXo7H/SnOg==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.9.tgz",
"integrity": "sha512-uW8H5NRgTVneSVTfiCVffBb8AbwWSKg7qcA4Ot3JI3MPCJGsB4Db4BhvAODIIYE5mNj7Q+VJkK7JxmRhk2Lyjw==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.29.0.tgz",
"integrity": "sha512-mQvSUJ/JjGBdvo+1LwC+GY2XmSYjK1nAaVw2emp/E61wEVYEyibRHCqm1I1vEKbXCpUKuW4G7u9ZCaZhJbLoNQ==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.9.tgz",
"integrity": "sha512-pmM0/VQ7kUhd1QyIxgS+aRvMgw+ZljB3eDb+jYyp6d2bC0mQWLzUDF+DLwCTkQ3tlNyVsvZRXjFyV0LkU/aXjA==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.29.0",
"@typescript-eslint/visitor-keys": "5.29.0",
"@typescript-eslint/types": "5.59.9",
"@typescript-eslint/visitor-keys": "5.59.9",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
@ -2035,26 +2094,28 @@
}
},
"@typescript-eslint/utils": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.29.0.tgz",
"integrity": "sha512-3Eos6uP1nyLOBayc/VUdKZikV90HahXE5Dx9L5YlSd/7ylQPXhLk1BYb29SDgnBnTp+jmSZUU0QxUiyHgW4p7A==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.9.tgz",
"integrity": "sha512-1PuMYsju/38I5Ggblaeb98TOoUvjhRvLpLa1DoTOFaLWqaXl/1iQ1eGurTXgBY58NUdtfTXKP5xBq7q9NDaLKg==",
"dev": true,
"requires": {
"@eslint-community/eslint-utils": "^4.2.0",
"@types/json-schema": "^7.0.9",
"@typescript-eslint/scope-manager": "5.29.0",
"@typescript-eslint/types": "5.29.0",
"@typescript-eslint/typescript-estree": "5.29.0",
"@types/semver": "^7.3.12",
"@typescript-eslint/scope-manager": "5.59.9",
"@typescript-eslint/types": "5.59.9",
"@typescript-eslint/typescript-estree": "5.59.9",
"eslint-scope": "^5.1.1",
"eslint-utils": "^3.0.0"
"semver": "^7.3.7"
}
},
"@typescript-eslint/visitor-keys": {
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.29.0.tgz",
"integrity": "sha512-Hpb/mCWsjILvikMQoZIE3voc9wtQcS0A9FUw3h8bhr9UxBdtI/tw1ZDZUOXHXLOVMedKCH5NxyzATwnU78bWCQ==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.9.tgz",
"integrity": "sha512-bT7s0td97KMaLwpEBckbzj/YohnvXtqbe2XgqNvTl6RJVakY5mvENOTPvw5u66nljfZxthESpDozs86U+oLY8Q==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.29.0",
"@typescript-eslint/types": "5.59.9",
"eslint-visitor-keys": "^3.3.0"
}
},
@ -2363,6 +2424,7 @@
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz",
"integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==",
"dev": true,
"peer": true,
"requires": {
"eslint-visitor-keys": "^2.0.0"
},
@ -2371,7 +2433,8 @@
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz",
"integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==",
"dev": true
"dev": true,
"peer": true
}
}
},
@ -2551,12 +2614,6 @@
"dev": true,
"peer": true
},
"functional-red-black-tree": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz",
"integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==",
"dev": true
},
"glob": {
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
@ -2610,8 +2667,7 @@
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz",
"integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==",
"dev": true,
"peer": true
"dev": true
},
"has-flag": {
"version": "4.0.0",
@ -2803,6 +2859,12 @@
"dev": true,
"peer": true
},
"natural-compare-lite": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz",
"integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==",
"dev": true
},
"obsidian": {
"version": "0.16.3",
"resolved": "https://registry.npmjs.org/obsidian/-/obsidian-0.16.3.tgz",
@ -2925,7 +2987,8 @@
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz",
"integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==",
"dev": true
"dev": true,
"peer": true
},
"resolve-from": {
"version": "4.0.0",
@ -3042,9 +3105,9 @@
}
},
"tslib": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz",
"integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==",
"version": "2.5.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.3.tgz",
"integrity": "sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==",
"dev": true
},
"tsutils": {
@ -3082,9 +3145,9 @@
"peer": true
},
"typescript": {
"version": "4.7.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz",
"integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==",
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.3.tgz",
"integrity": "sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==",
"dev": true
},
"uri-js": {

View File

@ -1,6 +1,6 @@
{
"name": "microblog-publish-plugin",
"version": "2.0.0",
"version": "2.1.0",
"description": "Publish Note to Micro.blog",
"main": "main.js",
"scripts": {
@ -12,13 +12,13 @@
"author": "",
"license": "MIT",
"devDependencies": {
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "5.29.0",
"@typescript-eslint/parser": "5.29.0",
"@types/node": "^18.0.0",
"@typescript-eslint/eslint-plugin": "5.59.9",
"@typescript-eslint/parser": "5.59.9",
"builtin-modules": "3.3.0",
"esbuild": "0.14.47",
"obsidian": "latest",
"tslib": "2.4.0",
"typescript": "4.7.4"
"tslib": "2.5.3",
"typescript": "5.1.3"
}
}

6
renovate.json Normal file
View File

@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
]
}

View File

@ -1,14 +1,16 @@
import { ErrorView } from '@views/ErrorView'
import { Notice, Plugin } from 'obsidian'
import { Editor, Notice, Plugin } from 'obsidian'
import { MicroPluginContainerInterface, MicroPluginContainer } from '@base/MicroPluginContainer'
import { MicroPluginSettingsView } from '@views/MicroPluginSettingsView'
import { PublishView } from '@views/PublishView'
import { ServiceFactory, ServiceFactoryInterface } from '@factories/ServiceFactory'
import { StoredSettings, defaultSettings } from '@stores/StoredSettings'
import { TagSynchronizationServiceInterface } from '@services/TagSynchronizationService'
import { TagSynchronizationServiceDelegate, TagSynchronizationServiceInterface } from '@services/TagSynchronizationService'
import { ViewModelFactoryInterface, ViewModelFactory } from '@factories/ViewModelFactory'
import { FrontmatterServiceDelegate, FrontmatterServiceInterface } from './services/FrontmatterService'
import { PublishResponse } from './networking/PublishResponse'
export default class MicroPlugin extends Plugin {
export default class MicroPlugin extends Plugin implements TagSynchronizationServiceDelegate {
// Properties
@ -17,15 +19,17 @@ export default class MicroPlugin extends Plugin {
private viewModelFactory: ViewModelFactoryInterface
private serviceFactory: ServiceFactoryInterface
private synchronizationService: TagSynchronizationServiceInterface
private frontmatterService: FrontmatterServiceInterface
// Public
public async onload() {
await this.loadSettings()
await this.loadDependencies()
await this.loadViewModelFactory()
await this.loadServiceFactory()
await this.registerSynchronizationService()
await this.registerFrontmatterService()
await this.loadViewModelFactory()
this.synchronizationService.fetchTags()
@ -41,7 +45,8 @@ export default class MicroPlugin extends Plugin {
new PublishView(
this.viewModelFactory.makePublishViewModel(
markdownView.file.basename,
editor.getValue()
editor.getValue(),
editor
)
).open()
}
@ -88,7 +93,8 @@ export default class MicroPlugin extends Plugin {
private async loadViewModelFactory() {
this.viewModelFactory = new ViewModelFactory(
this.container
this.container,
this.frontmatterService
)
}
@ -105,6 +111,11 @@ export default class MicroPlugin extends Plugin {
)
}
private async registerFrontmatterService() {
this.frontmatterService = this.serviceFactory
.makeFrontmatterService()
}
// TagSynchronizationServiceDelegate
public tagSynchronizationDidSucceed(

View File

@ -17,6 +17,7 @@ export interface MicroPluginContainerInterface {
// The network request factory, used to build the
// requests which will be executed by the network client.
networkRequestFactory: NetworkRequestFactoryInterface
}
export class MicroPluginContainer implements MicroPluginContainerInterface {

View File

@ -1,4 +1,8 @@
import { MicroPluginContainerInterface } from "@base/MicroPluginContainer";
import {
FrontmatterService,
FrontmatterServiceInterface,
FrontmatterServiceDelegate } from "@base/services/FrontmatterService";
import {
TagSynchronizationServiceInterface,
TagSynchronizationService,
@ -13,6 +17,13 @@ export interface ServiceFactoryInterface {
makeTagSynchronizationService(
delegate?: TagSynchronizationServiceDelegate
): TagSynchronizationServiceInterface
// Builds the yaml frontmatter service, used by the client
// to update the frontmatter of the file after publishing
// with publish date, used tags, etc.
makeFrontmatterService(
delegate?: FrontmatterServiceDelegate
): FrontmatterServiceInterface
}
/*
@ -47,4 +58,12 @@ export class ServiceFactory implements ServiceFactoryInterface {
delegate
)
}
public makeFrontmatterService(
delegate?: FrontmatterServiceDelegate
): FrontmatterServiceInterface {
return new FrontmatterService(
delegate
)
}
}

View File

@ -1,8 +1,11 @@
import { MicroPluginSettingsViewModel } from '@views/MicroPluginSettingsViewModel'
import { PublishViewModel } from '@views/PublishViewModel'
import { PublishViewModel, PublishViewModelDelegate } from '@views/PublishViewModel'
import { TagSuggestionViewModel, TagSuggestionDelegate } from '@views/TagSuggestionViewModel'
import { ErrorViewModel } from '@views/ErrorViewModel'
import { MicroPluginContainerInterface } from '@base/MicroPluginContainer'
import { Editor } from 'obsidian'
import { ServiceFactoryInterface } from './ServiceFactory'
import { FrontmatterServiceInterface } from '@base/services/FrontmatterService'
export interface ViewModelFactoryInterface {
@ -10,7 +13,9 @@ export interface ViewModelFactoryInterface {
// to Micro.blog via the Commands Palette.
makePublishViewModel(
title: string,
content: string
content: string,
editor: Editor,
delegate?: PublishViewModelDelegate
): PublishViewModel
// Builds the Plugin Settings View Model, used by the plugin
@ -37,22 +42,26 @@ export class ViewModelFactory implements ViewModelFactoryInterface {
// Properties
private container: MicroPluginContainerInterface
private frontmatterService: FrontmatterServiceInterface
// Life cycle
constructor(
container: MicroPluginContainerInterface
container: MicroPluginContainerInterface,
frontmatterService: FrontmatterServiceInterface
) {
this.container = container
this.frontmatterService = frontmatterService
}
// Public
public makePublishViewModel(
title: string,
content: string
content: string,
editor: Editor
): PublishViewModel {
return new PublishViewModel(
const viewModel = new PublishViewModel(
title,
content,
this.container.settings.defaultTags,
@ -61,8 +70,12 @@ export class ViewModelFactory implements ViewModelFactoryInterface {
this.container.settings.selectedBlogID,
this.container.networkClient,
this.container.networkRequestFactory,
this
this,
this.frontmatterService,
editor
)
return viewModel
}
public makeMicroPluginSettingsViewModel(): MicroPluginSettingsViewModel {

View File

@ -1,4 +1,5 @@
import { NetworkRequest } from '@networking/NetworkRequest'
import { log } from 'console'
export interface NetworkRequestFactoryInterface {
@ -78,8 +79,9 @@ export class NetworkRequestFactory implements NetworkRequestFactoryInterface {
return {
url: this.endpointUrl(),
parameters: parameters,
method: 'POST'
parameters: new URLSearchParams(),
method: 'POST',
body: parameters.toString()
}
}

View File

@ -0,0 +1,185 @@
import { PublishResponse } from "@base/networking/PublishResponse";
import { Editor, EditorPosition, parseYaml, stringifyYaml } from "obsidian";
export const YAML_REGEX = /^---\n(?:((?:.|\n)*?)\n)?---(?=\n|$)/;
type CommonUpdateParam = {
editor: Editor;
key: string;
value: string;
action: 'replace' | 'insert' | 'remove';
}
type BulkUpdateParam = {
editor: Editor;
updateDatas: Record<string, unknown>;
removeDatas: string[];
action: 'bulk'
}
export interface FrontmatterServiceInterface {
updateFrontmatter(response: PublishResponse, editor: Editor): void
}
export interface FrontmatterServiceDelegate {
frontmatterUpdateDidSucceed(): void
frontmatterUpdateDidFail(error: Error): void
}
export class FrontmatterService implements FrontmatterServiceInterface {
// Properties
private delegate?: FrontmatterServiceDelegate
// Life cycle
constructor(delegate?: FrontmatterServiceDelegate) {
this.delegate = delegate
}
// Public
public async updateFrontmatter(response: PublishResponse, editor: Editor) {
const yaml = this.getObjectYaml(editor)
this.upsert("url", response.url, false, editor)
this.delegate?.frontmatterUpdateDidSucceed()
}
// Get objectify yaml of current file
getObjectYaml(editor: Editor) {
const stringYaml = this.getYaml(editor);
return stringYaml? parseYaml(stringYaml.slice(4, -4)): {}
}
// Exchange item position in array
itemMove<T>(arr: T[], itemIdx1: number, itemIdx2: number): void {
[arr[itemIdx1], arr[itemIdx2]] = [arr[itemIdx2], arr[itemIdx1]];
}
// Add item in specific position
itemAdd<T>(arr: T[], itemIdx: number, item: T): void {
arr.splice(itemIdx, 0, item)
}
// Delete specific item in array
itemDelete<T>(arr: T[], itemIndex: number): void {
arr.splice(itemIndex, 1);
}
// Get yaml section
getYaml(editor: Editor): string {
const matchResult = editor.getValue().match(YAML_REGEX);
return matchResult?.[0] ?? '';
}
generateActionKeyword(data: CommonUpdateParam | BulkUpdateParam) {
const {editor, action} = data;
const yamlSection = this.getYaml(editor);
const yaml = yamlSection.slice(4, -3);
const objectYaml = this.getObjectYaml(editor);
const objectSnippet: Record<string, unknown> = {};
if (action === 'replace') objectSnippet[data.key] = data.value;
if (action === 'insert') {
if (objectYaml[data.key] instanceof Array) {
console.log('inserting into array')
objectSnippet[data.key] = [...objectYaml[data.key], data.value];
} else {
console.log('inserting')
//objectSnippet[data.key] = [data.value];
objectSnippet[data.key] = data.value;
}
}
if (action === 'remove') {
if (objectYaml[data.key] instanceof Array) {
const newValue = objectYaml[data.key].filter((val: string) => val !== data.value);
objectSnippet[data.key] = newValue.length? newValue: null;
} else {
objectSnippet[data.key] = null;
}
}
if (action === 'bulk') {
Object.entries(data.updateDatas).forEach(([key, value]) => objectSnippet[key] = value );
data.removeDatas.forEach((key) => objectSnippet[key] = null)
}
let replacement = `---\n${this.generateReplacement(yaml, objectSnippet)}---`;
const startPosition: EditorPosition = {line: 0, ch: 0};
const endPosition: EditorPosition = editor.offsetToPos(yamlSection.length);
// Make sure there is at least one newline character
// after the end of the frontmatter
const charAfterYaml = editor.getRange(endPosition, {ch: endPosition.ch + 1, line: endPosition.line})
replacement = charAfterYaml == "\n" ? replacement : replacement + "\n"
return {replacement, startPosition, endPosition}
}
generateReplacement(yaml: string, snippet: Record<string, unknown>) {
return Object.entries(snippet).reduce((temp, [key, value]) => {
const YAML_FIELD_REGEX = new RegExp(`(${key} *:).+?\\n(?=\\S|$)`, 'gs');
const replacement = (value === null)? '': stringifyYaml({[key]: value});
return temp.match(YAML_FIELD_REGEX)? temp.replace(YAML_FIELD_REGEX, replacement): `${temp}${replacement}`;
}, yaml)
}
flatYamlFields(yaml: string, flatFields: string[]): string {
const objectYaml = parseYaml(yaml.slice(4, -4));
return flatFields.reduce((temp, key) => {
const YAML_FIELD_REGEX = new RegExp(`(${key}:).+?(?=\\n\\S|$)`, 'gs');
return temp.match(YAML_FIELD_REGEX)? temp.replace(YAML_FIELD_REGEX, `$1 [${objectYaml[key].join(', ')}]`): temp;
}, yaml)
}
replace(key: string, value: string, editor: Editor): void {
const {replacement, startPosition, endPosition} = this.generateActionKeyword({key, value, editor, action: 'replace'});
editor.replaceRange(replacement, startPosition, endPosition)
}
insert(key: string, value: string, flat: boolean, editor: Editor): void {
const {replacement, startPosition, endPosition} = this.generateActionKeyword({key, value, editor, action: 'insert'});
const postProcessedReplacement = flat? this.flatYamlFields(replacement, [key]): replacement;
editor.replaceRange(postProcessedReplacement, startPosition, endPosition)
}
upsert(key: string, value: string, flat: boolean, editor: Editor): void {
const yaml = this.getObjectYaml(editor)
if (yaml[key]) {
this.replace(key, value, editor)
} else {
this.insert(key, value, flat, editor)
}
}
remove(key: string, value: string, flat: boolean, editor: Editor): void {
const {replacement, startPosition, endPosition} = this.generateActionKeyword({key, value, editor, action: 'remove'});
const postProcessedReplacement = flat? this.flatYamlFields(replacement, [key]): replacement;
editor.replaceRange(postProcessedReplacement, startPosition, endPosition)
}
bulkUpdate(updateDatas: Record<string, unknown>, removeDatas: string[], flatFields: string[], editor: Editor): void {
const {replacement, startPosition, endPosition} = this.generateActionKeyword({updateDatas, removeDatas, editor, action: 'bulk'});
const flattedReplacement = this.flatYamlFields(replacement, flatFields);
editor.replaceRange(flattedReplacement, startPosition, endPosition);
}
}

View File

@ -3,6 +3,9 @@ import { NetworkClientInterface } from '@networking/NetworkClient'
import { PublishResponse } from '@networking/PublishResponse'
import { TagSuggestionDelegate, TagSuggestionViewModel } from '@views/TagSuggestionViewModel'
import { ViewModelFactoryInterface } from '@factories/ViewModelFactory'
import { Editor } from 'obsidian'
import { ServiceFactoryInterface } from '@base/factories/ServiceFactory'
import { FrontmatterService, FrontmatterServiceInterface } from '@base/services/FrontmatterService'
/*
* Publish View Delegate Interface, implemented by
@ -53,6 +56,8 @@ export class PublishViewModel implements TagSuggestionDelegate {
private networkClient: NetworkClientInterface
private networkRequestFactory: NetworkRequestFactoryInterface
private viewModelFactory: ViewModelFactoryInterface
private frontmatterService: FrontmatterServiceInterface
private editor: Editor
readonly blogs: Record<string, string>
// Life cycle
@ -66,7 +71,9 @@ export class PublishViewModel implements TagSuggestionDelegate {
selectedBlogID: string,
networkClient: NetworkClientInterface,
networkRequestFactory: NetworkRequestFactoryInterface,
viewModelFactory: ViewModelFactoryInterface
viewModelFactory: ViewModelFactoryInterface,
frontmatterService: FrontmatterServiceInterface,
editor: Editor
) {
this.titleWrappedValue = title
this.content = content
@ -80,6 +87,8 @@ export class PublishViewModel implements TagSuggestionDelegate {
this.networkClient = networkClient
this.networkRequestFactory = networkRequestFactory
this.viewModelFactory = viewModelFactory
this.frontmatterService = frontmatterService
this.editor = editor
}
// Public
@ -162,6 +171,8 @@ export class PublishViewModel implements TagSuggestionDelegate {
request
)
this.frontmatterService.updateFrontmatter(response, this.editor)
this.delegate?.publishDidSucceed(response)
} catch (error) {
this.delegate?.publishDidFail(error)