Browse Source

Open inline links in new tab, remove referrer header, fix service worker path, fix bug in updating user's default sort type

main
GreatBearShark 2 years ago
parent
commit
a42c6d7cfb
  1. 1
      package.json
  2. 3
      src/components/user.tsx
  3. 2
      src/service-worker.ts
  4. 6
      src/utils.ts
  5. 5
      yarn.lock

1
package.json

@ -39,6 +39,7 @@
"markdown-it": "^10.0.0",
"markdown-it-container": "^2.0.0",
"markdown-it-emoji": "^1.4.0",
"markdown-it-for-inline": "^0.1.1",
"moment": "^2.24.0",
"node-fetch": "^2.6.0",
"parse-domain": "^3.0.2",

3
src/components/user.tsx

@ -947,7 +947,8 @@ export class User extends Component<any, UserState> {
}
handleUserSettingsSortTypeChange(val: SortType) {
this.state.userSettingsForm.default_sort_type = val;
// @ts-ignore
this.state.userSettingsForm.default_sort_type = parseInt(val, 10);
this.setState(this.state);
}

2
src/service-worker.ts

@ -1,7 +1,7 @@
import { register } from 'register-service-worker';
register('/service-worker.js', {
registrationOptions: { scope: './' },
registrationOptions: { scope: '/' },
ready(registration) {
console.log('Service worker is active.');
},

6
src/utils.ts

@ -53,6 +53,7 @@ import Tribute from 'tributejs/src/Tribute.js';
import markdown_it from 'markdown-it';
import markdownitEmoji from 'markdown-it-emoji/light';
import markdown_it_container from 'markdown-it-container';
import iterator from 'markdown-it-for-inline';
import emojiShortName from 'emoji-short-name';
import Toastify from 'toastify-js';
import tippy from 'tippy.js';
@ -182,6 +183,11 @@ export const md = new markdown_it({
.use(markdownitEmoji, {
defs: objectFlip(emojiShortName),
})
.use(iterator, 'url_new_win', 'link_open', function (tokens, idx) {
// make sure all inline links open in a new window and don't include the referrer
tokens[idx].attrPush(['target', '_blank']);
tokens[idx].attrPush(['rel', 'noreferrer']);
})
.disable('image');
export function hotRankComment(comment: Comment): number {

5
yarn.lock

@ -4864,6 +4864,11 @@ [email protected]^1.4.0:
resolved "https://registry.yarnpkg.com/markdown-it-emoji/-/markdown-it-emoji-1.4.0.tgz#9bee0e9a990a963ba96df6980c4fddb05dfb4dcc"
integrity sha1-m+4OmpkKljupbfaYDE/dsF37Tcw=
[email protected]^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/markdown-it-for-inline/-/markdown-it-for-inline-0.1.1.tgz#435f2316f5b5e68e1450cfa2242f2b8d59adc75f"
integrity sha1-Q18jFvW15o4UUM+iJC8rjVmtx18=
[email protected]^10.0.0:
version "10.0.0"
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-10.0.0.tgz#abfc64f141b1722d663402044e43927f1f50a8dc"

Loading…
Cancel
Save