@shzlx/ui-default 4.58.2
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/README.md +5 -0
- package/api.ts +61 -0
- package/backendlib/builder.ts +182 -0
- package/backendlib/markdown-it-imsize.ts +235 -0
- package/backendlib/markdown-it-katex.ts +139 -0
- package/backendlib/markdown-it-media.ts +163 -0
- package/backendlib/markdown-it-xss.ts +200 -0
- package/backendlib/markdown.js +64 -0
- package/backendlib/misc.ts +54 -0
- package/backendlib/template.ts +279 -0
- package/breakpoints.json +5 -0
- package/components/DOMAttachedObject.ts +128 -0
- package/components/autocomplete/AssignSelectAutoComplete.tsx +22 -0
- package/components/autocomplete/CustomSelectAutoComplete.tsx +23 -0
- package/components/autocomplete/DomainSelectAutoComplete.tsx +18 -0
- package/components/autocomplete/FileSelectAutoComplete.tsx +26 -0
- package/components/autocomplete/LanguageSelectAutoComplete.tsx +24 -0
- package/components/autocomplete/ProblemSelectAutoComplete.tsx +18 -0
- package/components/autocomplete/UserSelectAutoComplete.tsx +23 -0
- package/components/autocomplete/components/AssignSelectAutoComplete.tsx +118 -0
- package/components/autocomplete/components/DomainSelectAutoComplete.tsx +53 -0
- package/components/autocomplete/components/FileSelectAutoComplete.tsx +50 -0
- package/components/autocomplete/components/LanguageSelectAutoComplete.tsx +48 -0
- package/components/autocomplete/components/ProblemSelectAutoComplete.tsx +54 -0
- package/components/autocomplete/components/UserSelectAutoComplete.tsx +54 -0
- package/components/autocomplete/domainselectautocomplete.page.styl +6 -0
- package/components/autocomplete/index.tsx +110 -0
- package/components/autocomplete/problemselectautocomplete.page.styl +6 -0
- package/components/autocomplete/userselectautocomplete.page.styl +6 -0
- package/components/browser-update.page.ts +27 -0
- package/components/calendar/calendar.page.styl +129 -0
- package/components/calendar/index.js +367 -0
- package/components/clipboard.page.ts +23 -0
- package/components/contest/contest.page.styl +119 -0
- package/components/contest/contest.page.ts +23 -0
- package/components/contest/contest_sidebar.page.styl +21 -0
- package/components/contest/problem-contest-bg.png +0 -0
- package/components/contest/problem-contest-bg@2x.png +0 -0
- package/components/customFont.page.tsx +90 -0
- package/components/datepicker/datepicker.page.tsx +94 -0
- package/components/dialog/DomDialog.ts +145 -0
- package/components/dialog/dialog.page.styl +40 -0
- package/components/dialog/index.tsx +285 -0
- package/components/discussion/CommentBox.js +103 -0
- package/components/discussion/collapsible.page.styl +40 -0
- package/components/discussion/collapsible.page.tsx +62 -0
- package/components/discussion/comments.page.styl +142 -0
- package/components/discussion/comments.page.tsx +192 -0
- package/components/discussion/discussion.page.styl +17 -0
- package/components/discussion/history.page.tsx +81 -0
- package/components/discussion/reaction.page.styl +30 -0
- package/components/discussion/reaction.page.tsx +103 -0
- package/components/drop/drop.page.styl +40 -0
- package/components/dropdown/Dropdown.js +50 -0
- package/components/dropdown/dropdown.page.styl +33 -0
- package/components/dropdown/dropdown.page.ts +8 -0
- package/components/editor/cmeditor.page.ts +23 -0
- package/components/editor/cmeditor.styl +10 -0
- package/components/editor/index.tsx +293 -0
- package/components/editor/mdeditor.ts +60 -0
- package/components/editor/textareaHandler.ts +29 -0
- package/components/footer/footer.page.styl +94 -0
- package/components/footer/footer.page.ts +26 -0
- package/components/form/button.page.default.styl +59 -0
- package/components/form/button.page.styl +36 -0
- package/components/form/checkbox.page.styl +89 -0
- package/components/form/form.page.styl +200 -0
- package/components/form/form.page.ts +20 -0
- package/components/form/multiSelectCheckbox.page.js +46 -0
- package/components/form/radiobox.page.styl +62 -0
- package/components/form/select.page.styl +29 -0
- package/components/form/textbox.page.styl +79 -0
- package/components/form/textbox.page.ts +21 -0
- package/components/form/var.inc.styl +14 -0
- package/components/header/header.page.styl +79 -0
- package/components/highlighter/code-example.js +111 -0
- package/components/highlighter/highlighter.page.styl +99 -0
- package/components/highlighter/highlighter.page.ts +72 -0
- package/components/highlighter/meta.js +15 -0
- package/components/highlighter/prismjs.js +122 -0
- package/components/hint.page.styl +9 -0
- package/components/hint.ts +19 -0
- package/components/hitokoto/index.page.js +21 -0
- package/components/hotkey/hotkey.page.js +83 -0
- package/components/katex/katex.page.js +26 -0
- package/components/katex/katex.page.styl +2 -0
- package/components/languageselect.tsx +94 -0
- package/components/loader/loader.page.styl +40 -0
- package/components/mantine.page.tsx +39 -0
- package/components/marker/Marker.js +192 -0
- package/components/marker/MarkerReactive.js +55 -0
- package/components/marker/marker.page.js +8 -0
- package/components/marker/marker.page.styl +57 -0
- package/components/media/media.page.js +46 -0
- package/components/menu/menu-heading.page.js +28 -0
- package/components/menu/menu.page.js +18 -0
- package/components/menu/menu.page.styl +68 -0
- package/components/message/index.page.ts +166 -0
- package/components/message/worker.ts +110 -0
- package/components/messagepad/DialogueListItem.page.styl +28 -0
- package/components/messagepad/DialogueListItemComponent.jsx +39 -0
- package/components/messagepad/Message.page.styl +64 -0
- package/components/messagepad/MessageComponent.jsx +33 -0
- package/components/messagepad/MessagePad.page.styl +99 -0
- package/components/messagepad/MessagePadDialogueContentContainer.jsx +104 -0
- package/components/messagepad/MessagePadDialogueListContainer.jsx +49 -0
- package/components/messagepad/MessagePadInputContainer.jsx +100 -0
- package/components/messagepad/index.jsx +49 -0
- package/components/messagepad/reducers/activeId.ts +36 -0
- package/components/messagepad/reducers/dialogues.js +53 -0
- package/components/messagepad/reducers/index.ts +14 -0
- package/components/messagepad/reducers/inputs.js +43 -0
- package/components/messagepad/reducers/isPosting.ts +49 -0
- package/components/monaco/index.ts +178 -0
- package/components/monaco/languages/markdown.ts +97 -0
- package/components/monaco/languages/typescript.ts +45 -0
- package/components/monaco/languages/yaml.ts +22 -0
- package/components/monaco/loader.ts +96 -0
- package/components/monaco/monaco.styl +30 -0
- package/components/monaco/nls.js +31 -0
- package/components/monaco/schema/problemconfig.ts +123 -0
- package/components/navigation/hamburgers.page.styl +87 -0
- package/components/navigation/nav-logo-small_dark.png +0 -0
- package/components/navigation/navigation.page.js +203 -0
- package/components/navigation/navigation.page.styl +211 -0
- package/components/notification/index.ts +105 -0
- package/components/notification/notification.page.js +14 -0
- package/components/notification/notification.page.styl +84 -0
- package/components/nprogress.page.styl +50 -0
- package/components/omnisearch/index.page.tsx +124 -0
- package/components/omnisearch/omnibar.page.styl +138 -0
- package/components/pager/pager.page.styl +57 -0
- package/components/preview/preview.page.ts +187 -0
- package/components/problem/create.page.js +12 -0
- package/components/problem/list.page.js +9 -0
- package/components/problem/rp.page.styl +4 -0
- package/components/problem/tag.page.styl +84 -0
- package/components/problemconfig/BasicForm.tsx +92 -0
- package/components/problemconfig/ProblemConfigEditor.tsx +170 -0
- package/components/problemconfig/ProblemConfigForm.tsx +140 -0
- package/components/problemconfig/ProblemConfigTree.tsx +163 -0
- package/components/problemconfig/ProblemType.tsx +165 -0
- package/components/problemconfig/index.tsx +91 -0
- package/components/problemconfig/reducer/config.ts +173 -0
- package/components/problemconfig/reducer/index.ts +11 -0
- package/components/problemconfig/reducer/testdata.ts +16 -0
- package/components/problemconfig/tree/AddTestcase.tsx +137 -0
- package/components/problemconfig/tree/SelectionManager.tsx +140 -0
- package/components/problemconfig/tree/SubtaskSettings.tsx +180 -0
- package/components/problemconfig/tree/Testcase.tsx +98 -0
- package/components/profile/backgrounds/1.jpg +0 -0
- package/components/profile/backgrounds/10.jpg +0 -0
- package/components/profile/backgrounds/11.jpg +0 -0
- package/components/profile/backgrounds/12.jpg +0 -0
- package/components/profile/backgrounds/13.jpg +0 -0
- package/components/profile/backgrounds/14.jpg +0 -0
- package/components/profile/backgrounds/15.jpg +0 -0
- package/components/profile/backgrounds/16.jpg +0 -0
- package/components/profile/backgrounds/17.jpg +0 -0
- package/components/profile/backgrounds/18.jpg +0 -0
- package/components/profile/backgrounds/19.jpg +0 -0
- package/components/profile/backgrounds/2.jpg +0 -0
- package/components/profile/backgrounds/20.jpg +0 -0
- package/components/profile/backgrounds/21.jpg +0 -0
- package/components/profile/backgrounds/3.jpg +0 -0
- package/components/profile/backgrounds/4.jpg +0 -0
- package/components/profile/backgrounds/5.jpg +0 -0
- package/components/profile/backgrounds/6.jpg +0 -0
- package/components/profile/backgrounds/7.jpg +0 -0
- package/components/profile/backgrounds/8.jpg +0 -0
- package/components/profile/backgrounds/9.jpg +0 -0
- package/components/profile/backgrounds/gen_thumbnails.sh +7 -0
- package/components/profile/backgrounds/thumbnail/1.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/10.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/11.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/12.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/13.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/14.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/15.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/16.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/17.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/18.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/19.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/2.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/20.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/21.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/3.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/4.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/5.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/6.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/7.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/8.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/9.jpg +0 -0
- package/components/profile/profile.page.styl +23 -0
- package/components/react/DomComponent.tsx +14 -0
- package/components/react/IconComponent.tsx +20 -0
- package/components/record/record.page.styl +26 -0
- package/components/rotator/index.js +75 -0
- package/components/rotator/rotator.page.styl +20 -0
- package/components/scratchpad/DataInput.page.styl +17 -0
- package/components/scratchpad/DataInputComponent.jsx +45 -0
- package/components/scratchpad/Editor.page.styl +13 -0
- package/components/scratchpad/Panel.page.styl +18 -0
- package/components/scratchpad/PanelButton.page.styl +15 -0
- package/components/scratchpad/PanelButtonComponent.jsx +19 -0
- package/components/scratchpad/PanelComponent.jsx +25 -0
- package/components/scratchpad/ScratchpadEditorContainer.tsx +137 -0
- package/components/scratchpad/ScratchpadPretestContainer.jsx +57 -0
- package/components/scratchpad/ScratchpadRecordsContainer.jsx +45 -0
- package/components/scratchpad/ScratchpadRecordsRowContainer.jsx +83 -0
- package/components/scratchpad/ScratchpadSettings.tsx +48 -0
- package/components/scratchpad/ScratchpadToolbarContainer.jsx +190 -0
- package/components/scratchpad/Tab.page.styl +24 -0
- package/components/scratchpad/Toolbar.page.styl +53 -0
- package/components/scratchpad/ToolbarComponent.jsx +85 -0
- package/components/scratchpad/index.tsx +132 -0
- package/components/scratchpad/reducers/editor.ts +24 -0
- package/components/scratchpad/reducers/index.ts +17 -0
- package/components/scratchpad/reducers/pretest.ts +34 -0
- package/components/scratchpad/reducers/records.ts +40 -0
- package/components/scratchpad/reducers/state.ts +10 -0
- package/components/scratchpad/reducers/ui.ts +152 -0
- package/components/scratchpad/scratchpad.page.styl +55 -0
- package/components/scratchpad/var.inc.styl +2 -0
- package/components/selectUser.tsx +16 -0
- package/components/signin/signInDialog.page.js +84 -0
- package/components/signin/signin_dialog.page.styl +57 -0
- package/components/smoothscroll/smoothscroll.page.js +44 -0
- package/components/socket/index.ts +68 -0
- package/components/star/star.page.styl +20 -0
- package/components/star/star.page.ts +58 -0
- package/components/sticky/sticky.page.js +66 -0
- package/components/tab/Tab.js +168 -0
- package/components/tab/tab.page.js +9 -0
- package/components/tab/tab.page.styl +105 -0
- package/components/tab/var.inc.styl +3 -0
- package/components/table/StyledTable.js +51 -0
- package/components/table/styledTable.page.js +8 -0
- package/components/table/table.page.styl +73 -0
- package/components/time/time.page.js +47 -0
- package/components/tooltip/Tooltip.js +49 -0
- package/components/tooltip/tooltip.page.js +29 -0
- package/components/tooltip/tooltip.page.styl +69 -0
- package/components/training/training.page.styl +25 -0
- package/components/upload.tsx +103 -0
- package/components/vote/vote.page.js +43 -0
- package/components/zipDownloader/index.ts +157 -0
- package/constant/domain.js +21 -0
- package/constant/message.js +5 -0
- package/constant/record.js +52 -0
- package/context.ts +11 -0
- package/entry.js +72 -0
- package/hydro.ts +112 -0
- package/index.ts +226 -0
- package/lazyload.ts +69 -0
- package/locales/en.yaml +71 -0
- package/locales/ko.yaml +823 -0
- package/locales/zh.yaml +1137 -0
- package/locales/zh_TW.yaml +1133 -0
- package/misc/Page.ts +49 -0
- package/misc/PageLoader.js +31 -0
- package/misc/float.styl +14 -0
- package/misc/grid.styl +1048 -0
- package/misc/immersive-background.jpg +0 -0
- package/misc/immersive-background@2x.jpg +0 -0
- package/misc/immersive.styl +23 -0
- package/misc/nothing.styl +13 -0
- package/misc/puzzled_twd2.svg +1 -0
- package/misc/section.styl +105 -0
- package/misc/slideout.styl +46 -0
- package/misc/structure.styl +158 -0
- package/misc/textalign.styl +11 -0
- package/misc/typography.styl +485 -0
- package/package.json +148 -0
- package/polyfill.ts +90 -0
- package/postcss.config.js +15 -0
- package/sentry.ts +26 -0
- package/service-worker.ts +265 -0
- package/setting.yaml +98 -0
- package/templates/about.html +14 -0
- package/templates/bsod.html +35 -0
- package/templates/components/comments_discussion.html +165 -0
- package/templates/components/comments_solution.html +171 -0
- package/templates/components/contest.html +12 -0
- package/templates/components/form.html +214 -0
- package/templates/components/home.html +20 -0
- package/templates/components/homework.html +8 -0
- package/templates/components/md_hint.html +39 -0
- package/templates/components/noscript_note.html +15 -0
- package/templates/components/nothing.html +6 -0
- package/templates/components/paginator.html +25 -0
- package/templates/components/problem.html +33 -0
- package/templates/components/record.html +21 -0
- package/templates/components/sidemenu.html +11 -0
- package/templates/components/user.html +49 -0
- package/templates/contest_balloon.html +48 -0
- package/templates/contest_clarification.html +103 -0
- package/templates/contest_detail.html +56 -0
- package/templates/contest_edit.html +259 -0
- package/templates/contest_main.html +146 -0
- package/templates/contest_manage.html +80 -0
- package/templates/contest_print.html +27 -0
- package/templates/contest_problemlist.html +231 -0
- package/templates/contest_scoreboard.html +46 -0
- package/templates/contest_scoreboard_download_html.html +71 -0
- package/templates/contest_user.html +47 -0
- package/templates/discussion_create.html +28 -0
- package/templates/discussion_detail.html +149 -0
- package/templates/discussion_edit.html +30 -0
- package/templates/discussion_main_or_node.html +47 -0
- package/templates/domain_base.html +26 -0
- package/templates/domain_create.html +55 -0
- package/templates/domain_dashboard.html +45 -0
- package/templates/domain_edit.html +6 -0
- package/templates/domain_group.html +51 -0
- package/templates/domain_join.html +47 -0
- package/templates/domain_join_applications.html +67 -0
- package/templates/domain_permission.html +66 -0
- package/templates/domain_role.html +71 -0
- package/templates/domain_user.html +86 -0
- package/templates/domain_user_raw.html +5 -0
- package/templates/error.html +25 -0
- package/templates/home_domain.html +64 -0
- package/templates/home_files.html +16 -0
- package/templates/home_messages.html +9 -0
- package/templates/home_security.html +224 -0
- package/templates/home_settings.html +21 -0
- package/templates/homework_detail.html +82 -0
- package/templates/homework_edit.html +138 -0
- package/templates/homework_files.html +24 -0
- package/templates/homework_main.html +76 -0
- package/templates/layout/basic.html +27 -0
- package/templates/layout/home_base.html +13 -0
- package/templates/layout/html5.html +74 -0
- package/templates/layout/immersive.html +22 -0
- package/templates/layout/mail.html +31 -0
- package/templates/layout/simple.html +4 -0
- package/templates/layout/wiki_base.html +16 -0
- package/templates/main.html +22 -0
- package/templates/manage_base.html +24 -0
- package/templates/manage_config.html +6 -0
- package/templates/manage_dashboard.html +27 -0
- package/templates/manage_script.html +56 -0
- package/templates/manage_setting.html +6 -0
- package/templates/manage_user_import.html +23 -0
- package/templates/manage_user_priv.html +76 -0
- package/templates/partials/category.html +19 -0
- package/templates/partials/contest.html +3 -0
- package/templates/partials/contest_balloon.html +37 -0
- package/templates/partials/contest_sidebar.html +150 -0
- package/templates/partials/contest_sidebar_management.html +56 -0
- package/templates/partials/contest_user.html +19 -0
- package/templates/partials/discussion_edit_form.html +45 -0
- package/templates/partials/discussion_list.html +50 -0
- package/templates/partials/discussion_nodes_widget.html +17 -0
- package/templates/partials/files.html +49 -0
- package/templates/partials/footer.html +108 -0
- package/templates/partials/hamburger.html +7 -0
- package/templates/partials/header_mobile.html +12 -0
- package/templates/partials/homepage/bulletin.html +7 -0
- package/templates/partials/homepage/contest.html +48 -0
- package/templates/partials/homepage/discussion.html +13 -0
- package/templates/partials/homepage/discussion_nodes.html +4 -0
- package/templates/partials/homepage/error.html +5 -0
- package/templates/partials/homepage/hitokoto.html +6 -0
- package/templates/partials/homepage/homework.html +45 -0
- package/templates/partials/homepage/problem_search.html +13 -0
- package/templates/partials/homepage/ranking.html +39 -0
- package/templates/partials/homepage/recent_problems.html +17 -0
- package/templates/partials/homepage/starred_problems.html +15 -0
- package/templates/partials/homepage/suggestion.html +34 -0
- package/templates/partials/homepage/training.html +50 -0
- package/templates/partials/homework.html +3 -0
- package/templates/partials/homework_default_penalty_rules.yaml +6 -0
- package/templates/partials/homework_sidebar.html +93 -0
- package/templates/partials/login_dialog.html +56 -0
- package/templates/partials/manage_user_priv.html +78 -0
- package/templates/partials/nav.html +138 -0
- package/templates/partials/problem-sidebar-information.html +25 -0
- package/templates/partials/problem.html +2 -0
- package/templates/partials/problem_category_dialog.html +43 -0
- package/templates/partials/problem_default.md +26 -0
- package/templates/partials/problem_description.html +33 -0
- package/templates/partials/problem_files.html +63 -0
- package/templates/partials/problem_list.html +68 -0
- package/templates/partials/problem_lucky.html +10 -0
- package/templates/partials/problem_sidebar.html +14 -0
- package/templates/partials/problem_sidebar_contest.html +43 -0
- package/templates/partials/problem_sidebar_homework.html +42 -0
- package/templates/partials/problem_sidebar_normal.html +152 -0
- package/templates/partials/problem_stat.html +3 -0
- package/templates/partials/scoreboard.html +79 -0
- package/templates/partials/setting.html +92 -0
- package/templates/partials/training_default.json +14 -0
- package/templates/partials/training_detail.html +153 -0
- package/templates/partials/user.html +2 -0
- package/templates/partials/user_detail/activity.html +18 -0
- package/templates/partials/user_detail/solution.html +29 -0
- package/templates/problem_config.html +39 -0
- package/templates/problem_detail.html +150 -0
- package/templates/problem_edit.html +111 -0
- package/templates/problem_files.html +91 -0
- package/templates/problem_hack.html +41 -0
- package/templates/problem_import.html +58 -0
- package/templates/problem_main.html +100 -0
- package/templates/problem_solution.html +55 -0
- package/templates/problem_statistics.html +96 -0
- package/templates/problem_submit.html +40 -0
- package/templates/ranking.html +81 -0
- package/templates/record_detail.html +134 -0
- package/templates/record_detail_status.html +93 -0
- package/templates/record_detail_summary.html +19 -0
- package/templates/record_main.html +142 -0
- package/templates/record_main_tr.html +35 -0
- package/templates/status.html +75 -0
- package/templates/training_detail.html +120 -0
- package/templates/training_edit.html +68 -0
- package/templates/training_files.html +64 -0
- package/templates/training_main.html +107 -0
- package/templates/user_changemail_mail.html +6 -0
- package/templates/user_changemail_mail_sent.html +9 -0
- package/templates/user_delete_pending.html +10 -0
- package/templates/user_detail.html +181 -0
- package/templates/user_login.html +46 -0
- package/templates/user_logout.html +13 -0
- package/templates/user_lostpass.html +27 -0
- package/templates/user_lostpass_mail.html +6 -0
- package/templates/user_lostpass_mail_sent.html +9 -0
- package/templates/user_lostpass_with_code.html +29 -0
- package/templates/user_register.html +22 -0
- package/templates/user_register_mail.html +6 -0
- package/templates/user_register_mail_sent.html +9 -0
- package/templates/user_register_with_code.html +35 -0
- package/templates/user_sudo.html +54 -0
- package/templates/user_sudo_redirect.html +18 -0
- package/templates/wiki_help.html +189 -0
- package/theme/bp6-compat.css +48 -0
- package/theme/dark.styl +397 -0
- package/theme/default.js +33 -0
- package/typed.d.ts +20 -0
- package/utils/base.ts +209 -0
- package/utils/base64.js +104 -0
- package/utils/db.ts +32 -0
- package/utils/index.ts +73 -0
- package/utils/loadReactRedux.ts +32 -0
- package/utils/mediaQuery.ts +13 -0
- package/utils/pjax.js +148 -0
- package/utils/slide.ts +57 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import 'jquery.easing';
|
|
2
|
+
|
|
3
|
+
import $ from 'jquery';
|
|
4
|
+
import { AutoloadPage } from 'vj/misc/Page';
|
|
5
|
+
import { i18n } from 'vj/utils';
|
|
6
|
+
|
|
7
|
+
function initCollapsibleContent() {
|
|
8
|
+
$('.collapsible-content').each(function () {
|
|
9
|
+
const $content = $(this);
|
|
10
|
+
let $inner = $content.find('.collapsible-content__inner');
|
|
11
|
+
if ($inner.length) return;
|
|
12
|
+
const $children = $content.contents().detach();
|
|
13
|
+
$inner = $('<div class="collapsible-content__inner"></div>');
|
|
14
|
+
$inner.append($children);
|
|
15
|
+
$content.append($inner);
|
|
16
|
+
$content.find('.collapsible-toggle').remove();
|
|
17
|
+
const scrollHeight = $inner[0].scrollHeight;
|
|
18
|
+
const clientHeight = $inner[0].clientHeight;
|
|
19
|
+
if (scrollHeight > clientHeight + 10) {
|
|
20
|
+
const $toggle = $(`<div class="collapsible-toggle">
|
|
21
|
+
<a href="javascript:;" class="collapsible-toggle__link">${i18n('Show more')}</a>
|
|
22
|
+
</div>`);
|
|
23
|
+
$content.append($toggle);
|
|
24
|
+
const $toggleLink = $toggle.find('.collapsible-toggle__link');
|
|
25
|
+
requestAnimationFrame(() => {
|
|
26
|
+
$toggle.addClass('visible');
|
|
27
|
+
});
|
|
28
|
+
$toggleLink.on('click', (e) => {
|
|
29
|
+
e.preventDefault();
|
|
30
|
+
if ($content.hasClass('expanded')) {
|
|
31
|
+
const currentHeight = $inner[0].scrollHeight;
|
|
32
|
+
$inner.css('max-height', `${currentHeight}px`);
|
|
33
|
+
requestAnimationFrame(() => {
|
|
34
|
+
$content.removeClass('expanded');
|
|
35
|
+
$inner.css('max-height', '');
|
|
36
|
+
$toggleLink.text(i18n('Show more'));
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
// Expand: get full height by temporarily removing max-height, then animate to it
|
|
40
|
+
const currentMaxHeight = $inner.css('max-height');
|
|
41
|
+
$inner.css('max-height', 'none');
|
|
42
|
+
const fullHeight = $inner[0].scrollHeight;
|
|
43
|
+
$inner.css('max-height', currentMaxHeight);
|
|
44
|
+
requestAnimationFrame(() => {
|
|
45
|
+
$inner.css('max-height', `${fullHeight}px`);
|
|
46
|
+
$content.addClass('expanded');
|
|
47
|
+
$toggleLink.text(i18n('Show less'));
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
} else $content.addClass('expanded');
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const commentsPage = new AutoloadPage('commentsPage', () => {
|
|
56
|
+
initCollapsibleContent();
|
|
57
|
+
$(document).on('vjContentNew', () => {
|
|
58
|
+
initCollapsibleContent();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export default commentsPage;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
$upvote-color = green
|
|
2
|
+
$downvote-color = red
|
|
3
|
+
|
|
4
|
+
.dczcomments__item .is-editing
|
|
5
|
+
[name="dczcomments__dummy-box"]
|
|
6
|
+
display: none
|
|
7
|
+
> .typo
|
|
8
|
+
display: none
|
|
9
|
+
|
|
10
|
+
.dczcomments__box .textbox
|
|
11
|
+
min-height: rem(180px)
|
|
12
|
+
resize: vertical
|
|
13
|
+
|
|
14
|
+
.textbox[name="dczcomments__dummy-box"]
|
|
15
|
+
min-height: rem(60px)
|
|
16
|
+
resize: none
|
|
17
|
+
font-size: rem($font-size-title)
|
|
18
|
+
color: $comment-placeholder-color
|
|
19
|
+
padding: rem(10px)
|
|
20
|
+
|
|
21
|
+
.dczcomments__item,
|
|
22
|
+
.dczcomments__reply
|
|
23
|
+
border-top: 1px solid $table-border-color
|
|
24
|
+
|
|
25
|
+
>.media
|
|
26
|
+
padding: rem(20px 0)
|
|
27
|
+
|
|
28
|
+
&:first-child
|
|
29
|
+
border-top: 0
|
|
30
|
+
|
|
31
|
+
.dczcomments__reply
|
|
32
|
+
>.media
|
|
33
|
+
// FIXME doesn't work on IE 11
|
|
34
|
+
display: flex
|
|
35
|
+
|
|
36
|
+
&:last-child
|
|
37
|
+
>.media
|
|
38
|
+
padding-bottom: 0
|
|
39
|
+
|
|
40
|
+
.dczcomments__item > .media
|
|
41
|
+
display: flex
|
|
42
|
+
>.media__body
|
|
43
|
+
max-width: calc(100% - 6.5em)
|
|
44
|
+
+mobile()
|
|
45
|
+
max-width: 100%
|
|
46
|
+
|
|
47
|
+
.dczcomments__supplementary
|
|
48
|
+
float: left
|
|
49
|
+
margin-bottom: rem(5px)
|
|
50
|
+
|
|
51
|
+
.history
|
|
52
|
+
float: right
|
|
53
|
+
margin-left: rem(5px)
|
|
54
|
+
|
|
55
|
+
.dczcomments__operations
|
|
56
|
+
font-size: rem($font-size)
|
|
57
|
+
float: right
|
|
58
|
+
vertical-align: top
|
|
59
|
+
color: $comment-op-color
|
|
60
|
+
|
|
61
|
+
a, a:visited
|
|
62
|
+
color: $comment-op-link-color
|
|
63
|
+
margin-left: rem(3px)
|
|
64
|
+
a:hover
|
|
65
|
+
color: $primary-color
|
|
66
|
+
text-decoration: none
|
|
67
|
+
|
|
68
|
+
.view--solution .dczcomments__replies
|
|
69
|
+
margin-left: rem(50px)
|
|
70
|
+
|
|
71
|
+
.dczcomments__item
|
|
72
|
+
.vote-number
|
|
73
|
+
width: rem(82px)
|
|
74
|
+
text-align: center
|
|
75
|
+
font-size: rem(25px)
|
|
76
|
+
font-weight: 300
|
|
77
|
+
margin-bottom: rem(10px)
|
|
78
|
+
|
|
79
|
+
.vote-op
|
|
80
|
+
position: relative
|
|
81
|
+
border: 1px solid transparent
|
|
82
|
+
border-radius: rem(14px)
|
|
83
|
+
transition: border-color .2s linear, opacity .2s linear
|
|
84
|
+
opacity: 0.5
|
|
85
|
+
|
|
86
|
+
&>button
|
|
87
|
+
width: rem(40px)
|
|
88
|
+
float: left
|
|
89
|
+
position: relative
|
|
90
|
+
|
|
91
|
+
&:hover .vote-op
|
|
92
|
+
opacity: 1
|
|
93
|
+
border-color: $supplementary-border-color
|
|
94
|
+
|
|
95
|
+
.vote-button
|
|
96
|
+
appearance: none
|
|
97
|
+
border: 0
|
|
98
|
+
background: none
|
|
99
|
+
width: 100%
|
|
100
|
+
outline: 0
|
|
101
|
+
font-size: rem($font-size-icon)
|
|
102
|
+
line-height: rem(26px)
|
|
103
|
+
color: #AAA
|
|
104
|
+
transition: color .2s linear, background-color .2s linear, box-shadow .2s linear
|
|
105
|
+
|
|
106
|
+
&.upvote
|
|
107
|
+
border-radius: rem(13px 0 0 13px)
|
|
108
|
+
padding-left: rem(7px)
|
|
109
|
+
|
|
110
|
+
&:hover
|
|
111
|
+
background: $upvote-color
|
|
112
|
+
color: #FFF
|
|
113
|
+
box-shadow: 0 2px 10px rgba($upvote-color, 0.4)
|
|
114
|
+
|
|
115
|
+
&.active
|
|
116
|
+
color: $upvote-color
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
&.downvote
|
|
120
|
+
border-radius: rem(0 13px 13px 0)
|
|
121
|
+
padding-right: rem(7px)
|
|
122
|
+
|
|
123
|
+
&:hover
|
|
124
|
+
background: $downvote-color
|
|
125
|
+
color: #FFF
|
|
126
|
+
box-shadow: 0 2px 10px rgba($downvote-color, 0.4)
|
|
127
|
+
|
|
128
|
+
&.active
|
|
129
|
+
color: $downvote-color
|
|
130
|
+
|
|
131
|
+
&.active
|
|
132
|
+
background: transparent !important
|
|
133
|
+
box-shadow: none !important
|
|
134
|
+
cursor: default
|
|
135
|
+
|
|
136
|
+
.dczcomments__replies .collapsible-content__inner
|
|
137
|
+
max-height: rem(200px)
|
|
138
|
+
|
|
139
|
+
+mobile()
|
|
140
|
+
.dczcomments__item
|
|
141
|
+
.media__left
|
|
142
|
+
display: none
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import 'jquery.easing';
|
|
2
|
+
|
|
3
|
+
import $ from 'jquery';
|
|
4
|
+
import { confirm } from 'vj/components/dialog';
|
|
5
|
+
import CommentBox from 'vj/components/discussion/CommentBox';
|
|
6
|
+
import { AutoloadPage } from 'vj/misc/Page';
|
|
7
|
+
import {
|
|
8
|
+
delay, i18n, request, slideDown, slideUp,
|
|
9
|
+
} from 'vj/utils';
|
|
10
|
+
|
|
11
|
+
const $replyTemplate = $('.commentbox-container').eq(0).clone();
|
|
12
|
+
|
|
13
|
+
function createReplyContainer($parent) {
|
|
14
|
+
const $container = $replyTemplate
|
|
15
|
+
.clone()
|
|
16
|
+
.hide()
|
|
17
|
+
.prependTo($parent.find('.commentbox-reply-target').eq(0))
|
|
18
|
+
.trigger('vjContentNew');
|
|
19
|
+
return $container.find('.commentbox-placeholder');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function showReplyContainer($parent) {
|
|
23
|
+
const $container = $parent.find('.commentbox-container');
|
|
24
|
+
// TODO: fix ugly hack. cannot get $container rect because it is invisible
|
|
25
|
+
const rect = $container.parent()[0].getBoundingClientRect();
|
|
26
|
+
const rectBody = document.body.getBoundingClientRect();
|
|
27
|
+
if (rect.top < 100 || rect.top + 100 > window.innerHeight) {
|
|
28
|
+
const targetScrollTop = rect.top - rectBody.top - window.innerHeight * 0.382;
|
|
29
|
+
$('html, body').stop().animate({ scrollTop: targetScrollTop }, 400, 'easeOutCubic');
|
|
30
|
+
await delay(300);
|
|
31
|
+
// delay duration is set smaller than animation duration intentionally
|
|
32
|
+
}
|
|
33
|
+
$container.css('opacity', 0);
|
|
34
|
+
await slideDown($container, 300);
|
|
35
|
+
await $container.transition({ opacity: 1 }, { duration: 200 }).promise();
|
|
36
|
+
$container.removeAttr('style');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function destroyReplyContainer($parent) {
|
|
40
|
+
const $container = $parent.find('.commentbox-container');
|
|
41
|
+
$container.css('opacity', 1);
|
|
42
|
+
await $container.transition({ opacity: 0 }, { duration: 200 }).promise();
|
|
43
|
+
await slideUp($container, 300);
|
|
44
|
+
$container.remove();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function onClickDummyBox(ev) {
|
|
48
|
+
const $evTarget = $(ev.currentTarget);
|
|
49
|
+
|
|
50
|
+
if (CommentBox.get($evTarget)) {
|
|
51
|
+
CommentBox.get($evTarget).focus();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const $mediaBody = $evTarget.closest('.media__body');
|
|
56
|
+
|
|
57
|
+
const opt = {
|
|
58
|
+
form: JSON.parse($evTarget.attr('data-form')),
|
|
59
|
+
mode: 'comment',
|
|
60
|
+
onCancel: () => {
|
|
61
|
+
$mediaBody.removeClass('is-editing');
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
$mediaBody.addClass('is-editing');
|
|
66
|
+
|
|
67
|
+
CommentBox
|
|
68
|
+
.getOrConstruct($evTarget, opt)
|
|
69
|
+
.appendTo($mediaBody.find('.commentbox-placeholder').eq(0))
|
|
70
|
+
.focus();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function onCommentClickReplyComment(ev, options: any = {}) {
|
|
74
|
+
const $evTarget = $(ev.currentTarget);
|
|
75
|
+
|
|
76
|
+
if (CommentBox.get($evTarget)) {
|
|
77
|
+
// If comment box is already expanded,
|
|
78
|
+
// we should insert "initialText"
|
|
79
|
+
CommentBox
|
|
80
|
+
.get($evTarget)
|
|
81
|
+
.insertText(options.initialText || '')
|
|
82
|
+
.focus();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const $mediaBody = $evTarget.closest('.media__body');
|
|
87
|
+
|
|
88
|
+
const opt = {
|
|
89
|
+
initialText: '',
|
|
90
|
+
mode: 'reply',
|
|
91
|
+
...options,
|
|
92
|
+
onCancel: async () => {
|
|
93
|
+
await destroyReplyContainer($mediaBody);
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const cbox = CommentBox
|
|
98
|
+
.getOrConstruct($evTarget, {
|
|
99
|
+
form: JSON.parse($evTarget.attr('data-form')),
|
|
100
|
+
...opt,
|
|
101
|
+
})
|
|
102
|
+
.appendTo(createReplyContainer($mediaBody));
|
|
103
|
+
await showReplyContainer($mediaBody);
|
|
104
|
+
cbox.focus();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function onCommentClickReplyReply(ev) {
|
|
108
|
+
const $evTarget = $(ev.currentTarget);
|
|
109
|
+
const $mediaBody = $evTarget.closest('.media__body');
|
|
110
|
+
const uid = $mediaBody
|
|
111
|
+
.find('.user-profile-name')
|
|
112
|
+
.attr('href').split('/user/')[1];
|
|
113
|
+
|
|
114
|
+
$evTarget
|
|
115
|
+
.closest('.dczcomments__item')
|
|
116
|
+
.find('[data-op="reply"][data-type="comment"]').eq(0)
|
|
117
|
+
.trigger('click', { initialText: `@[](/user/${uid.trim()}) ` });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function onCommentClickEdit(mode, ev) {
|
|
121
|
+
const $evTarget = $(ev.currentTarget);
|
|
122
|
+
|
|
123
|
+
if (CommentBox.get($evTarget)) {
|
|
124
|
+
CommentBox.get($evTarget).focus();
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const $mediaBody = $evTarget.closest('.media__body');
|
|
129
|
+
|
|
130
|
+
const raw = await request.get(
|
|
131
|
+
$mediaBody.find('.typo').eq(0).attr('data-raw-url'),
|
|
132
|
+
{},
|
|
133
|
+
{ dataType: 'text' },
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const opt = {
|
|
137
|
+
initialText: raw,
|
|
138
|
+
form: JSON.parse($evTarget.attr('data-form')),
|
|
139
|
+
mode,
|
|
140
|
+
onCancel: () => {
|
|
141
|
+
$mediaBody.removeClass('is-editing');
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
$mediaBody.addClass('is-editing');
|
|
146
|
+
|
|
147
|
+
CommentBox
|
|
148
|
+
.getOrConstruct($evTarget, opt)
|
|
149
|
+
.appendTo($mediaBody.find('.commentbox-edit-target').eq(0))
|
|
150
|
+
.focus();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function onCommentClickEditComment(ev) {
|
|
154
|
+
return onCommentClickEdit('comment-update', ev);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function onCommentClickEditReply(ev) {
|
|
158
|
+
return onCommentClickEdit('reply-update', ev);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async function onCommentClickDelete(type, ev) {
|
|
162
|
+
const message = (type === 'comment')
|
|
163
|
+
? 'Confirm deleting this comment? Its replies will be deleted as well.'
|
|
164
|
+
: 'Confirm deleting this reply?';
|
|
165
|
+
if (!await confirm(i18n(message))) return;
|
|
166
|
+
|
|
167
|
+
const $evTarget = $(ev.currentTarget);
|
|
168
|
+
const form = JSON.parse($evTarget.attr('data-form'));
|
|
169
|
+
|
|
170
|
+
await request.post('', form);
|
|
171
|
+
window.location.reload();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function onCommentClickDeleteComment(ev) {
|
|
175
|
+
onCommentClickDelete('comment', ev);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function onCommentClickDeleteReply(ev) {
|
|
179
|
+
onCommentClickDelete('reply', ev);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const commentsPage = new AutoloadPage('commentsPage', () => {
|
|
183
|
+
$(document).on('click', '[name="dczcomments__dummy-box"]', onClickDummyBox);
|
|
184
|
+
$(document).on('click', '[data-op="reply"][data-type="comment"]', onCommentClickReplyComment);
|
|
185
|
+
$(document).on('click', '[data-op="reply"][data-type="reply"]', onCommentClickReplyReply);
|
|
186
|
+
$(document).on('click', '[data-op="edit"][data-type="comment"]', onCommentClickEditComment);
|
|
187
|
+
$(document).on('click', '[data-op="edit"][data-type="reply"]', onCommentClickEditReply);
|
|
188
|
+
$(document).on('click', '[data-op="delete"][data-type="comment"]', onCommentClickDeleteComment);
|
|
189
|
+
$(document).on('click', '[data-op="delete"][data-type="reply"]', onCommentClickDeleteReply);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
export default commentsPage;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.discussion-node-tag
|
|
2
|
+
font-size: rem($font-size-small)
|
|
3
|
+
display: inline-block
|
|
4
|
+
line-height: rem(22px)
|
|
5
|
+
padding: rem(0 10px)
|
|
6
|
+
vertical-align: middle
|
|
7
|
+
border-radius: rem(12px)
|
|
8
|
+
border: 1px solid $supplementary-border-color
|
|
9
|
+
|
|
10
|
+
&:hover
|
|
11
|
+
background: $primary-color
|
|
12
|
+
color: #FFF !important
|
|
13
|
+
text-decoration: none
|
|
14
|
+
border-color: $primary-color
|
|
15
|
+
|
|
16
|
+
.icon
|
|
17
|
+
margin-right: rem(5px)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/* eslint-disable react-refresh/only-export-components */
|
|
2
|
+
import { MantineProvider, Popover } from '@mantine/core';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import ReactDOM from 'react-dom/client';
|
|
5
|
+
import TimeAgo from 'timeago-react';
|
|
6
|
+
import { InfoDialog } from 'vj/components/dialog';
|
|
7
|
+
import { AutoloadPage } from 'vj/misc/Page';
|
|
8
|
+
import { i18n, request, tpl } from 'vj/utils';
|
|
9
|
+
|
|
10
|
+
async function historyDialog(payload, time, uid) {
|
|
11
|
+
const ts = new Date(time).getTime();
|
|
12
|
+
const rawHtml = await fetch(`${payload}?time=${ts}&render=1`).then((res) => res.text());
|
|
13
|
+
new InfoDialog({
|
|
14
|
+
$body: tpl`
|
|
15
|
+
<div class="typo richmedia">
|
|
16
|
+
<p><div data-user>${uid}</div> ${i18n('Edited at')} <span class="time relative" data-timestamp="${ts / 1000}">${time}</span></p>
|
|
17
|
+
<div style="scroll-behavior: smooth; max-height: 60vh; overflow: auto;">
|
|
18
|
+
${{ templateRaw: true, html: rawHtml }}
|
|
19
|
+
</div>
|
|
20
|
+
</div>`,
|
|
21
|
+
}).open();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function History({ payload }) {
|
|
25
|
+
const [load, setLoad] = React.useState(false);
|
|
26
|
+
const [data, setData] = React.useState([]);
|
|
27
|
+
const [isLoading, setLoading] = React.useState(true);
|
|
28
|
+
const [error, setError] = React.useState('');
|
|
29
|
+
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
if (!load) return;
|
|
32
|
+
setLoading(true);
|
|
33
|
+
request.get(`${payload}?all=1`).then(({ history }) => {
|
|
34
|
+
setData(history);
|
|
35
|
+
}).catch((e) => {
|
|
36
|
+
setError(e.message);
|
|
37
|
+
}).finally(() => {
|
|
38
|
+
setLoading(false);
|
|
39
|
+
});
|
|
40
|
+
}, [load]);
|
|
41
|
+
|
|
42
|
+
return <Popover onOpen={() => setLoad(true)}>
|
|
43
|
+
<Popover.Target>
|
|
44
|
+
<span>{i18n('Edited')} <span className="icon icon-expand_more"></span></span>
|
|
45
|
+
</Popover.Target>
|
|
46
|
+
<Popover.Dropdown>
|
|
47
|
+
<ol className="menu">
|
|
48
|
+
{(isLoading || error) && (
|
|
49
|
+
<li className="menu__item">
|
|
50
|
+
<a className="menu__link">
|
|
51
|
+
{isLoading ? i18n('Loading...') : i18n('Loading failed.')}
|
|
52
|
+
</a>
|
|
53
|
+
</li>
|
|
54
|
+
)}
|
|
55
|
+
{data?.map((item) => (
|
|
56
|
+
<li className="menu__item" key={item.time}>
|
|
57
|
+
<a className="menu__link" onClick={() => historyDialog(payload, item.time, item.uid)}>
|
|
58
|
+
{i18n('Edited at')}
|
|
59
|
+
{' '}
|
|
60
|
+
<TimeAgo datetime={item.time} locale={i18n('timeago_locale')} />
|
|
61
|
+
</a>
|
|
62
|
+
</li>
|
|
63
|
+
))}
|
|
64
|
+
</ol>
|
|
65
|
+
</Popover.Dropdown>
|
|
66
|
+
</Popover>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const page = new AutoloadPage('discussionHistoryPage', () => {
|
|
70
|
+
$('[data-discussion-history]').each((i, e) => {
|
|
71
|
+
const url = $(e).data('raw-url');
|
|
72
|
+
if (!url) return;
|
|
73
|
+
ReactDOM.createRoot(e).render(
|
|
74
|
+
<MantineProvider>
|
|
75
|
+
<History payload={url} />
|
|
76
|
+
</MantineProvider>,
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export default page;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.reactions
|
|
2
|
+
display: inline
|
|
3
|
+
|
|
4
|
+
.reaction
|
|
5
|
+
white-space: nowrap
|
|
6
|
+
width: auto
|
|
7
|
+
border-radius: 1.75rem
|
|
8
|
+
overflow: visible
|
|
9
|
+
font-size: rem($font-size-small)
|
|
10
|
+
display: inline-block
|
|
11
|
+
line-height: rem(22px)
|
|
12
|
+
padding: rem(0 10px)
|
|
13
|
+
vertical-align: middle
|
|
14
|
+
border-radius: rem(12px)
|
|
15
|
+
border: 1px solid $supplementary-border-color
|
|
16
|
+
cursor: pointer
|
|
17
|
+
&.active, &:hover
|
|
18
|
+
text-decoration: none
|
|
19
|
+
border-color: $primary-color
|
|
20
|
+
color: #FFF !important
|
|
21
|
+
&.active
|
|
22
|
+
background-color: lighten($primary-color, 10%) !important
|
|
23
|
+
&:hover
|
|
24
|
+
background-color: lighten($primary-color, 30%) !important
|
|
25
|
+
.emoji
|
|
26
|
+
margin-right: rem(5px)
|
|
27
|
+
|
|
28
|
+
.popover-reaction-item
|
|
29
|
+
&:hover
|
|
30
|
+
background-color: $toolbar-bg-hover
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/* eslint-disable react-refresh/only-export-components */
|
|
2
|
+
import 'jquery.easing';
|
|
3
|
+
|
|
4
|
+
import { MantineProvider, Popover } from '@mantine/core';
|
|
5
|
+
import $ from 'jquery';
|
|
6
|
+
import { chunk } from 'lodash';
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import ReactDOM from 'react-dom/client';
|
|
9
|
+
import { AutoloadPage } from 'vj/misc/Page';
|
|
10
|
+
import { request } from 'vj/utils';
|
|
11
|
+
|
|
12
|
+
function renderReactions(reactions = {}, self = {}, rootEle) {
|
|
13
|
+
let html = '';
|
|
14
|
+
for (const [k, v] of Object.entries(reactions).sort(([, v1], [, v2]) => +v2 - +v1)) {
|
|
15
|
+
if (!v) continue;
|
|
16
|
+
html += `<div class="reaction${self[k] ? ' active' : ''}""><span class="emoji">${k}</span> ${v}</div>\n`;
|
|
17
|
+
}
|
|
18
|
+
rootEle.html(html);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function handleEmojiClick(payload, emoji, ele) {
|
|
22
|
+
const res = await request.post('', { ...payload, emoji });
|
|
23
|
+
if (!res.sdoc) return;
|
|
24
|
+
renderReactions(res.doc?.react, res.sdoc.react, ele);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getRow(count) {
|
|
28
|
+
if (count <= 2) return 2;
|
|
29
|
+
if (count <= 3) return 3;
|
|
30
|
+
if (count <= 4) return 4;
|
|
31
|
+
if (count <= 6) return 6;
|
|
32
|
+
return 12;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function Reaction({ payload, ele }) {
|
|
36
|
+
const emojiList: string[] = (UiContext.emojiList || '👍 👎 😄 😕 ❤️ 🤔 🤣 🌿 🍋 🕊️ 👀 🤡').split(' ');
|
|
37
|
+
const elesPerRow = getRow(Math.sqrt(emojiList.length));
|
|
38
|
+
const [focus, updateFocus] = React.useState(false);
|
|
39
|
+
const [open, updateOpen] = React.useState(false);
|
|
40
|
+
const [trigger, updateTrigger] = React.useState(false);
|
|
41
|
+
return (
|
|
42
|
+
<Popover opened={trigger || open || focus}>
|
|
43
|
+
<Popover.Target>
|
|
44
|
+
<span
|
|
45
|
+
className="icon icon-emoji"
|
|
46
|
+
onMouseEnter={() => updateTrigger(true)}
|
|
47
|
+
onMouseLeave={() => {
|
|
48
|
+
setTimeout(() => updateTrigger(false), 300);
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
</Popover.Target>
|
|
52
|
+
<Popover.Dropdown onMouseEnter={() => updateOpen(true)} onMouseLeave={() => updateOpen(false)}>
|
|
53
|
+
{chunk(emojiList, elesPerRow).map((line, i) => (
|
|
54
|
+
<div className="row" key={+i} style={{ paddingBottom: 4, paddingTop: 4 }}>
|
|
55
|
+
{line.map((emoji) => (
|
|
56
|
+
<div
|
|
57
|
+
key={emoji}
|
|
58
|
+
className={`medium-${12 / elesPerRow} small-${12 / elesPerRow} columns popover-reaction-item`}
|
|
59
|
+
onClick={() => handleEmojiClick(payload, emoji, ele).then(() => {
|
|
60
|
+
updateOpen(false);
|
|
61
|
+
updateTrigger(false);
|
|
62
|
+
})}
|
|
63
|
+
>
|
|
64
|
+
{emoji}
|
|
65
|
+
</div>
|
|
66
|
+
))}
|
|
67
|
+
</div>
|
|
68
|
+
))}
|
|
69
|
+
<div className="row" style={{ paddingTop: 7, paddingBottom: 4 }}>
|
|
70
|
+
<div className="medium-12 columns">
|
|
71
|
+
<input name="emojiSuggest" onFocus={() => updateFocus(true)} onBlur={() => updateFocus(false)}></input>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</Popover.Dropdown>
|
|
75
|
+
</Popover>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const reactionPage = new AutoloadPage('reactionPage', () => {
|
|
80
|
+
const canUseReaction = $('[data-op="react"]').length > 0;
|
|
81
|
+
$('[data-op="react"]').each((i, e) => {
|
|
82
|
+
ReactDOM.createRoot(e).render(<MantineProvider>
|
|
83
|
+
<Reaction payload={$(e).data('form')} ele={$(`.reactions[data-${$(e).data('form').nodeType}='${$(e).data('form').id}']`)} />
|
|
84
|
+
</MantineProvider>);
|
|
85
|
+
});
|
|
86
|
+
$(document).on('click', '.reaction', async (e) => {
|
|
87
|
+
if (!canUseReaction) {
|
|
88
|
+
(window as any).showSignInDialog();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const target = $(e.currentTarget);
|
|
92
|
+
const res = await request.post('', {
|
|
93
|
+
operation: 'reaction',
|
|
94
|
+
nodeType: target.parent().data('type'),
|
|
95
|
+
id: target.parent().data(target.parent().data('type')),
|
|
96
|
+
emoji: target.text().trim().split(' ')[0],
|
|
97
|
+
reverse: target.hasClass('active'),
|
|
98
|
+
});
|
|
99
|
+
renderReactions(res.doc?.react, res.sdoc?.react, target.parent());
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export default reactionPage;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
.drop-element,
|
|
2
|
+
.drop-element:after,
|
|
3
|
+
.drop-element:before,
|
|
4
|
+
.drop-element *,
|
|
5
|
+
.drop-element *:after,
|
|
6
|
+
.drop-element *:before
|
|
7
|
+
box-sizing: border-box
|
|
8
|
+
|
|
9
|
+
.drop-element
|
|
10
|
+
position: absolute
|
|
11
|
+
display: none
|
|
12
|
+
opacity: 0
|
|
13
|
+
transition: opacity .1s ease-in-out
|
|
14
|
+
z-index: 1000 // managed
|
|
15
|
+
|
|
16
|
+
&.drop-open
|
|
17
|
+
display: block
|
|
18
|
+
|
|
19
|
+
&.drop-open-transitionend
|
|
20
|
+
display: block
|
|
21
|
+
|
|
22
|
+
&.drop-after-open
|
|
23
|
+
opacity: 1
|
|
24
|
+
|
|
25
|
+
.drop-target-attached-top.drop-target-attached-left .drop-content
|
|
26
|
+
transform-origin: -10% 110%
|
|
27
|
+
.drop-target-attached-top.drop-target-attached-center .drop-content
|
|
28
|
+
transform-origin: 50% 110%
|
|
29
|
+
.drop-target-attached-top.drop-target-attached-right .drop-content
|
|
30
|
+
transform-origin: 110% 110%
|
|
31
|
+
.drop-target-attached-bottom.drop-target-attached-left .drop-content
|
|
32
|
+
transform-origin: -10% -10%
|
|
33
|
+
.drop-target-attached-bottom.drop-target-attached-center .drop-content
|
|
34
|
+
transform-origin: 50% -10%
|
|
35
|
+
.drop-target-attached-bottom.drop-target-attached-right .drop-content
|
|
36
|
+
transform-origin: 110% -10%
|
|
37
|
+
.drop-target-attached-center.drop-target-attached-right .drop-content
|
|
38
|
+
transform-origin: -10% 50%
|
|
39
|
+
.drop-target-attached-center.drop-target-attached-left .drop-content
|
|
40
|
+
transform-origin: 110% 50%
|