@@ -24,7 +24,7 @@
diff --git a/src/components/code-editor/style.less b/src/components/code-editor/style.less
new file mode 100644
index 0000000..b9453f4
--- /dev/null
+++ b/src/components/code-editor/style.less
@@ -0,0 +1,202 @@
+.tui-code-editor {
+ width: calc(100% - 2px);
+ min-width: 0;
+ border: 1px solid var(--td-component-stroke, #B8BBC9);
+ display: flex;
+ overflow: hidden;
+ background: transparent;
+ border-radius: var(--td-radius-medium, 0);
+
+ .gutter {
+ flex: none;
+ color: var(--td-text-color-placeholder, #999);
+ overflow: hidden;
+ text-align: right;
+ background: #F2F2F2E6;
+ border-right: 1px solid var(--td-component-stroke, #B8BBC9);
+
+ > span {
+ width: 3.25rem;
+ height: 1.5rem;
+ display: block;
+ font-size: 1rem;
+ font-family: "JetBrains Mono", "Fira Code", Consolas, "Courier New", monospace;
+ line-height: 1.5rem;
+ padding-right: .25rem;
+ }
+ }
+
+ .body {
+ flex: 1;
+ min-width: 0;
+ min-height: 0;
+ position: relative;
+ overflow: hidden;
+ }
+
+ .search-bar {
+ top: .5rem;
+ right: .5rem;
+ gap: .5rem;
+ z-index: 3;
+ display: flex;
+ padding: .5rem;
+ position: absolute;
+ align-items: center;
+ border-radius: var(--td-radius-default, .375rem);
+ background: var(--td-bg-color-container, #fff);
+ border: 1px solid var(--td-component-stroke, #B8BBC9);
+ box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .12);
+ }
+
+ .search-input {
+ width: 10rem;
+ height: 2rem;
+ padding: 0 .5rem;
+ color: var(--td-text-color-primary, #111);
+ border: 1px solid var(--td-component-stroke, #B8BBC9);
+ background: var(--td-bg-color-container, #fff);
+ border-radius: var(--td-radius-default, .375rem);
+ font: inherit;
+ }
+
+ .search-actions {
+ gap: .25rem;
+ display: flex;
+ align-items: center;
+ }
+
+ .search-button {
+ height: 2rem;
+ padding: 0 .625rem;
+ color: var(--td-text-color-primary, #111);
+ border: 1px solid var(--td-component-stroke, #B8BBC9);
+ background: var(--td-bg-color-container, #fff);
+ border-radius: var(--td-radius-default, .375rem);
+ cursor: pointer;
+
+ &:hover {
+ background: var(--td-bg-color-container-hover, #f6f6f6);
+ }
+ }
+
+ .search-status {
+ color: var(--td-text-color-secondary, #666);
+ white-space: nowrap;
+ font-size: .875rem;
+ }
+
+ .preview,
+ .input {
+ inset: 0;
+ width: 100%;
+ height: 100%;
+ margin: 0;
+ tab-size: 4;
+ overflow: auto;
+ max-width: 100%;
+ min-width: 0;
+ line-height: 1.5rem;
+ font-size: 1rem;
+ box-sizing: border-box;
+ font-family: "JetBrains Mono", "Fira Code", Consolas, "Courier New", monospace;
+ }
+
+ .preview {
+ top: 0;
+ left: 0;
+ border: none;
+ position: absolute;
+ word-break: normal;
+ background: transparent;
+ transition: none;
+ white-space: pre;
+ border-radius: 0;
+ pointer-events: none;
+
+ code {
+ padding: 0;
+ display: block;
+ width: max-content;
+ min-width: 100%;
+ min-height: 100%;
+ color: inherit;
+ background: transparent;
+ text-shadow: none;
+ font-size: inherit;
+ line-height: inherit;
+ font-family: inherit;
+ }
+ }
+
+ .input {
+ top: 0;
+ left: 0;
+ color: transparent;
+ resize: none;
+ border: none;
+ outline: none;
+ position: absolute;
+ background: transparent;
+ white-space: pre;
+ word-break: normal;
+ overflow-wrap: normal;
+ caret-color: var(--td-text-color-primary, #111);
+ -webkit-text-fill-color: transparent;
+ }
+
+ .input::placeholder {
+ color: var(--td-text-color-placeholder, #999);
+ -webkit-text-fill-color: var(--td-text-color-placeholder, #999);
+ }
+
+ .input::selection {
+ background: rgb(0 122 255 / 18%);
+ }
+
+ &.disabled {
+ opacity: .65;
+ }
+
+ &.readonly {
+ .preview {
+ pointer-events: auto;
+ }
+ }
+}
+
+@media (prefers-color-scheme: dark) {
+ .tui-code-editor {
+ border-color: var(--td-component-stroke, #434343);
+
+ .gutter {
+ border-right-color: var(--td-component-stroke, #434343);
+ }
+
+ .search-bar {
+ background: var(--td-bg-color-container, #1f1f1f);
+ border-color: var(--td-component-stroke, #434343);
+ box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .28);
+ }
+
+ .search-input,
+ .search-button {
+ color: var(--td-text-color-primary, #F5F5F5);
+ border-color: var(--td-component-stroke, #434343);
+ background: var(--td-bg-color-container, #1f1f1f);
+ }
+
+ .search-button:hover {
+ background: var(--td-bg-color-container-hover, #2b2b2b);
+ }
+
+ .input {
+ caret-color: var(--td-text-color-primary, #F5F5F5);
+ }
+
+ .input::selection {
+ background: rgb(64 153 255 / 28%);
+ }
+ }
+}
+
diff --git a/src/components/comment/form/emits.ts b/src/components/comment/form/emits.ts
deleted file mode 100644
index 8da9836..0000000
--- a/src/components/comment/form/emits.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { Comment } from "timi-web";
-
-/**
- * emits
- */
-export interface Emits {
- (event: "submit"): Promise
;
-}
-
-export const useHandler = (emit: Emits) => {
-
- const onSubmit = async (comment: Comment) => await emit("submit");
-
- return {
- onSubmit,
- };
-};
diff --git a/src/components/comment/form/index.ts b/src/components/comment/form/index.ts
deleted file mode 100644
index ccc25e6..0000000
--- a/src/components/comment/form/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import view from "./index.vue";
-import { Toolkit } from "timi-web";
-
-export const CommentForm = Toolkit.withInstall(view);
-export default CommentForm;
diff --git a/src/components/comment/form/index.vue b/src/components/comment/form/index.vue
deleted file mode 100644
index 8691ee0..0000000
--- a/src/components/comment/form/index.vue
+++ /dev/null
@@ -1,114 +0,0 @@
-
-
-
-
-
-
-
diff --git a/src/components/comment/form/reply/emits.ts b/src/components/comment/form/reply/emits.ts
deleted file mode 100644
index 5f7e70b..0000000
--- a/src/components/comment/form/reply/emits.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { CommentReply } from "timi-web";
-
-/**
- * emits
- */
-export interface Emits {
- (event: "cancel"): Promise;
- (event: "submit", reply: CommentReply): Promise;
-}
-
-export const useHandler = (emit: Emits) => {
-
- const onCancel = async () => await emit("cancel");
- const onSubmit = async (reply: CommentReply) => await emit("submit", reply);
-
- return {
- onCancel,
- onSubmit
- };
-};
diff --git a/src/components/comment/form/reply/index.ts b/src/components/comment/form/reply/index.ts
deleted file mode 100644
index d7ff5c4..0000000
--- a/src/components/comment/form/reply/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import view from "./index.vue";
-import { Toolkit } from "timi-web";
-
-export const CommentReplyForm = Toolkit.withInstall(view);
-export default CommentReplyForm;
diff --git a/src/components/comment/form/reply/index.vue b/src/components/comment/form/reply/index.vue
deleted file mode 100644
index 6e99017..0000000
--- a/src/components/comment/form/reply/index.vue
+++ /dev/null
@@ -1,168 +0,0 @@
-
-
-
-
-
-
-
diff --git a/src/components/comment/index.ts b/src/components/comment/index.ts
deleted file mode 100644
index 3c12858..0000000
--- a/src/components/comment/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import view from "./index.vue";
-import { Toolkit } from "timi-web";
-
-export const Comment = Toolkit.withInstall(view);
-export default Comment;
diff --git a/src/components/comment/index.vue b/src/components/comment/index.vue
deleted file mode 100644
index 0e8659d..0000000
--- a/src/components/comment/index.vue
+++ /dev/null
@@ -1,148 +0,0 @@
-
-
-
-
-
-
-
diff --git a/src/components/comment/list/emits.ts b/src/components/comment/list/emits.ts
deleted file mode 100644
index 8ed4165..0000000
--- a/src/components/comment/list/emits.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
- * emits
- */
-export interface Emits {
-}
-
-export const useHandler = (emit: Emits) => {
-
- return {
- };
-};
diff --git a/src/components/comment/list/index.ts b/src/components/comment/list/index.ts
deleted file mode 100644
index f10d2c2..0000000
--- a/src/components/comment/list/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import view from "./index.vue";
-import { Toolkit } from "timi-web";
-
-export const CommentList = Toolkit.withInstall(view);
-export default CommentList;
diff --git a/src/components/comment/list/index.vue b/src/components/comment/list/index.vue
deleted file mode 100644
index 4512ec5..0000000
--- a/src/components/comment/list/index.vue
+++ /dev/null
@@ -1,240 +0,0 @@
-
-
-
-
-
-
-
diff --git a/src/components/comment/list/reply/emits.ts b/src/components/comment/list/reply/emits.ts
deleted file mode 100644
index 3b31e4d..0000000
--- a/src/components/comment/list/reply/emits.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { Comment, CommentReply } from "timi-web";
-
-/**
- * emits
- */
-export interface Emits {
- (event: "reply", comment: Comment, replyTo?: CommentReply): Promise;
-}
-
-export const useHandler = (emit: Emits) => {
-
- const onReply = async (comment: Comment, replyTo?: CommentReply) => await emit("reply", comment, replyTo);
-
- return {
- onReply,
- };
-};
diff --git a/src/components/comment/list/reply/index.ts b/src/components/comment/list/reply/index.ts
deleted file mode 100644
index 54db3a2..0000000
--- a/src/components/comment/list/reply/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import view from "./index.vue";
-import { Toolkit } from "timi-web";
-
-export const CommentReplyList = Toolkit.withInstall(view);
-export default CommentReplyList;
diff --git a/src/components/comment/list/reply/index.vue b/src/components/comment/list/reply/index.vue
deleted file mode 100644
index 46fb0e7..0000000
--- a/src/components/comment/list/reply/index.vue
+++ /dev/null
@@ -1,179 +0,0 @@
-
-
-
-
-
-
-
diff --git a/src/components/editor-search/index.vue b/src/components/editor-search/index.vue
new file mode 100644
index 0000000..fb71e40
--- /dev/null
+++ b/src/components/editor-search/index.vue
@@ -0,0 +1,271 @@
+
+
+
+
+
+
+
+
+
+ Aa
+
+
+ .*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/index.ts b/src/components/index.ts
index f4a11c8..14d3a79 100644
--- a/src/components/index.ts
+++ b/src/components/index.ts
@@ -1,34 +1,56 @@
/** 导出所有组件 */
import AuthorizeForm from "~/components/authorize-form";
import RootLayout from "~/components/root-layout";
-import Comment from "~/components/comment";
-import CommentForm from "~/components/comment/form";
-import CommentList from "~/components/comment/list";
-import CommentReplyList from "~/components/comment/list/reply";
-import CommentReplyForm from "~/components/comment/form/reply";
import UserProfile from "~/components/user-profile";
import UserProfilePopup from "~/components/user-profile/popup";
+import CodeEditor from "~/components/code-editor";
+import TiptapEditor from "~/components/tiptap-editor";
+import TiptapView from "~/components/tiptap-view";
+import ArticleEditor from "~/components/article-editor";
+import ArticleView from "~/components/article-view";
+import NotifyEditor from "~/components/notify-editor";
+import NotifyView from "~/components/notify-view";
export default [
RootLayout,
AuthorizeForm,
- Comment,
- CommentForm,
- CommentReplyForm,
- CommentList,
- CommentReplyList,
UserProfile,
- UserProfilePopup
+ UserProfilePopup,
+ CodeEditor,
+ TiptapEditor,
+ TiptapView,
+ ArticleEditor,
+ ArticleView,
+ NotifyEditor,
+ NotifyView
];
export {
RootLayout,
AuthorizeForm,
- Comment,
- CommentForm,
- CommentReplyForm,
- CommentList,
- CommentReplyList,
UserProfile,
- UserProfilePopup
+ UserProfilePopup,
+ CodeEditor,
+ TiptapEditor,
+ TiptapView,
+ ArticleEditor,
+ ArticleView,
+ NotifyEditor,
+ NotifyView
};
+
+export type {
+ CodeEditorExpose
+} from "./code-editor";
+
+export type {
+ TiptapEditorExpose
+} from "./tiptap-editor";
+
+export type {
+ ArticleEditorExpose
+} from "./article-editor";
+
+export type {
+ NotifyEditorExpose
+} from "./notify-editor";
diff --git a/src/components/message.ts b/src/components/message.ts
new file mode 100644
index 0000000..77a14bb
--- /dev/null
+++ b/src/components/message.ts
@@ -0,0 +1,7 @@
+import { MessagePlugin } from "tdesign-vue-next";
+
+type MessageType = "info" | "success" | "warning" | "error";
+
+export async function showPlatformMessage(type: MessageType, content: string) {
+ await MessagePlugin[type](content);
+}
diff --git a/src/components/notify-editor/index.ts b/src/components/notify-editor/index.ts
new file mode 100644
index 0000000..2a28533
--- /dev/null
+++ b/src/components/notify-editor/index.ts
@@ -0,0 +1,11 @@
+import view from "./index.vue";
+import { Toolkit } from "timi-web";
+import type { NotifyDetail } from "timi-web/editor";
+
+export type NotifyEditorExpose = {
+ submit: () => Promise;
+ getPendingMediaCount: () => number;
+};
+
+export const NotifyEditor = Toolkit.withInstall(view);
+export default NotifyEditor;
diff --git a/src/components/notify-editor/index.vue b/src/components/notify-editor/index.vue
new file mode 100644
index 0000000..da7d622
--- /dev/null
+++ b/src/components/notify-editor/index.vue
@@ -0,0 +1,76 @@
+
+
+
+
+
diff --git a/src/components/notify-view/index.ts b/src/components/notify-view/index.ts
new file mode 100644
index 0000000..0bd6ef4
--- /dev/null
+++ b/src/components/notify-view/index.ts
@@ -0,0 +1,5 @@
+import view from "./index.vue";
+import { Toolkit } from "timi-web";
+
+export const NotifyView = Toolkit.withInstall(view);
+export default NotifyView;
diff --git a/src/components/notify-view/index.vue b/src/components/notify-view/index.vue
new file mode 100644
index 0000000..674ec41
--- /dev/null
+++ b/src/components/notify-view/index.vue
@@ -0,0 +1,32 @@
+
+
+
+
+
diff --git a/src/components/tiptap-content.less b/src/components/tiptap-content.less
new file mode 100644
index 0000000..73ffa63
--- /dev/null
+++ b/src/components/tiptap-content.less
@@ -0,0 +1,46 @@
+.tp-content-theme() {
+ color: var(--td-text-color-primary);
+ line-height: 1.6;
+
+ p {
+ margin: 0 0 .75rem;
+ }
+
+ p:empty:before {
+ content: "\00a0";
+ }
+
+ ul,
+ ol {
+ margin: 0 0 .75rem;
+ padding-left: 1.25rem;
+ }
+
+ table {
+ width: 100%;
+ margin: .75rem 0;
+ table-layout: fixed;
+ border-collapse: collapse;
+ }
+
+ th,
+ td {
+ border: 1px solid var(--td-component-border);
+ }
+
+ th {
+ background: var(--td-bg-color-secondarycontainer);
+ }
+
+ img,
+ video,
+ iframe {
+ margin: 0 auto;
+ max-width: 100%;
+ }
+}
+
+.tp-content-body {
+ .tp-content-theme();
+}
+
diff --git a/src/components/tiptap-editor/TiptapCodeBlockButton.vue b/src/components/tiptap-editor/TiptapCodeBlockButton.vue
new file mode 100644
index 0000000..10c4bae
--- /dev/null
+++ b/src/components/tiptap-editor/TiptapCodeBlockButton.vue
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/tiptap-editor/TiptapIframeButton.vue b/src/components/tiptap-editor/TiptapIframeButton.vue
new file mode 100644
index 0000000..bcf40ff
--- /dev/null
+++ b/src/components/tiptap-editor/TiptapIframeButton.vue
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/tiptap-editor/TiptapLinkButton.vue b/src/components/tiptap-editor/TiptapLinkButton.vue
new file mode 100644
index 0000000..8af2570
--- /dev/null
+++ b/src/components/tiptap-editor/TiptapLinkButton.vue
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+ 显示文本同步为链接
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/tiptap-editor/TiptapMediaButton.vue b/src/components/tiptap-editor/TiptapMediaButton.vue
new file mode 100644
index 0000000..4a3217d
--- /dev/null
+++ b/src/components/tiptap-editor/TiptapMediaButton.vue
@@ -0,0 +1,182 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/tiptap-editor/TiptapPaddingButton.vue b/src/components/tiptap-editor/TiptapPaddingButton.vue
new file mode 100644
index 0000000..0cc151c
--- /dev/null
+++ b/src/components/tiptap-editor/TiptapPaddingButton.vue
@@ -0,0 +1,99 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/tiptap-editor/TiptapTableButton.vue b/src/components/tiptap-editor/TiptapTableButton.vue
new file mode 100644
index 0000000..47b1b5a
--- /dev/null
+++ b/src/components/tiptap-editor/TiptapTableButton.vue
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/tiptap-editor/TiptapToolbar.vue b/src/components/tiptap-editor/TiptapToolbar.vue
new file mode 100644
index 0000000..961176a
--- /dev/null
+++ b/src/components/tiptap-editor/TiptapToolbar.vue
@@ -0,0 +1,429 @@
+
+
+
+
+
+
+
diff --git a/src/components/tiptap-editor/index.ts b/src/components/tiptap-editor/index.ts
new file mode 100644
index 0000000..5f44f8e
--- /dev/null
+++ b/src/components/tiptap-editor/index.ts
@@ -0,0 +1,19 @@
+import view from "./index.vue";
+import { Toolkit } from "timi-web";
+import type { TiptapEditorInstance } from "timi-web/editor";
+
+export * from "timi-web/editor";
+export type TiptapEditorExpose = {
+ submit: () => Promise;
+ getPendingMediaCount: () => number;
+ openSearch: (showReplace: boolean) => void;
+ closeSearch: () => void;
+ findNext: () => boolean;
+ findPrevious: () => boolean;
+ replaceCurrent: () => boolean;
+ replaceAll: () => number;
+ editor?: TiptapEditorInstance;
+};
+
+export const TiptapEditor = Toolkit.withInstall(view);
+export default TiptapEditor;
diff --git a/src/components/tiptap-editor/index.vue b/src/components/tiptap-editor/index.vue
new file mode 100644
index 0000000..b9f2e5c
--- /dev/null
+++ b/src/components/tiptap-editor/index.vue
@@ -0,0 +1,624 @@
+
+
+
+
+
+
+
diff --git a/src/components/tiptap-view/index.ts b/src/components/tiptap-view/index.ts
new file mode 100644
index 0000000..1c4cd1d
--- /dev/null
+++ b/src/components/tiptap-view/index.ts
@@ -0,0 +1,5 @@
+import view from "./index.vue";
+import { Toolkit } from "timi-web";
+
+export const TiptapView = Toolkit.withInstall(view);
+export default TiptapView;
diff --git a/src/components/tiptap-view/index.vue b/src/components/tiptap-view/index.vue
new file mode 100644
index 0000000..5196979
--- /dev/null
+++ b/src/components/tiptap-view/index.vue
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
diff --git a/src/index.ts b/src/index.ts
index 9fc4165..c0055ec 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,6 +1,9 @@
import "./assets/style/tencent-cloud.less";
import "./assets/style/tencent-cloud-custom.less";
import { popupUserStore } from "./store/popupUser";
+import "./components/tiptap-content.less";
+import "timi-web/style.css";
+import "../../timi-web/src/components/prism-code-block.less";
export * from "./components";
diff --git a/tsconfig.json b/tsconfig.json
index 4ff52e1..2a4c4ca 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -23,6 +23,9 @@
"@/*": [
"./examples/*"
],
+ "timi-web/editor": [
+ "../timi-web/src/editor/index.ts"
+ ],
"timi-tdesign-pc": [
"./src/index.ts"
]
diff --git a/vite.config.ts b/vite.config.ts
index fff1ece..653d21c 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -20,6 +20,10 @@ const alias: Alias[] = [
find: "*",
replacement: resolve("")
},
+ {
+ find: /^timi-web\/editor$/,
+ replacement: resolve(__dirname, "../timi-web/src/editor/index.ts")
+ },
{
find: /^timi-tdesign-pc(\/(es|lib))?$/,
replacement: resolve(__dirname, "./src/index.ts")
评论
-