@iquji-community/web-editor 0.0.0-stage → 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Iquji contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,30 @@
1
- # Temporary Holding Version
1
+ # @iquji-community/web-editor
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [简体中文](README.zh-CN.md)
4
+
5
+ Rich text and code editors for React. The text editor supports Markdown, JSON, YAML, TOML, Shell and plain text.
6
+
7
+ ```sh
8
+ npm install react@19.2.4 react-dom@19.2.4 @iquji-community/web-editor @iquji-community/web-theme @iquji-community/web-component
9
+ ```
10
+
11
+ ```tsx
12
+ import "@iquji-community/web-theme/tokens.css";
13
+ import "@iquji-community/web-component/styles.css";
14
+ import "@iquji-community/web-editor/styles.css";
15
+ import { IqujiTextEditor } from "@iquji-community/web-editor/text";
16
+ import { useState } from "react";
17
+
18
+ export function Editor() {
19
+ const [value, setValue] = useState("{}");
20
+ return (
21
+ <IqujiTextEditor
22
+ preset="json"
23
+ ariaLabel="JSON document"
24
+ labels={{ edit: "Edit", preview: "Preview", format: "Format", invalid: "Invalid JSON" }}
25
+ value={value}
26
+ onChange={setValue}
27
+ />
28
+ );
29
+ }
30
+ ```
@@ -0,0 +1,30 @@
1
+ # @iquji-community/web-editor
2
+
3
+ [English](README.md)
4
+
5
+ 适用于 React 的富文本和代码编辑器。代码编辑器支持 Markdown、JSON、YAML、TOML、Shell 和纯文本。
6
+
7
+ ```sh
8
+ npm install react@19.2.4 react-dom@19.2.4 @iquji-community/web-editor @iquji-community/web-theme @iquji-community/web-component
9
+ ```
10
+
11
+ ```tsx
12
+ import "@iquji-community/web-theme/tokens.css";
13
+ import "@iquji-community/web-component/styles.css";
14
+ import "@iquji-community/web-editor/styles.css";
15
+ import { IqujiTextEditor } from "@iquji-community/web-editor/text";
16
+ import { useState } from "react";
17
+
18
+ export function Editor() {
19
+ const [value, setValue] = useState("{}");
20
+ return (
21
+ <IqujiTextEditor
22
+ preset="json"
23
+ ariaLabel="JSON 文档"
24
+ labels={{ edit: "编辑", preview: "预览", format: "格式化", invalid: "格式有误" }}
25
+ value={value}
26
+ onChange={setValue}
27
+ />
28
+ );
29
+ }
30
+ ```
@@ -0,0 +1,9 @@
1
+ export declare const EDITOR_HIGHLIGHT_COLORS: readonly ["yellow", "green", "blue", "purple", "pink"];
2
+ export type EditorHighlightPreset = (typeof EDITOR_HIGHLIGHT_COLORS)[number];
3
+ export type EditorColor = `#${string}`;
4
+ export type EditorHighlightColor = EditorHighlightPreset | EditorColor;
5
+ export declare const EDITOR_HIGHLIGHT_PALETTE: Record<EditorHighlightPreset, EditorColor>;
6
+ export declare const EDITOR_TEXT_PALETTE: readonly ["#171717", "#525252", "#b91c1c", "#c2410c", "#a16207", "#15803d", "#0e7490", "#1d4ed8", "#7e22ce", "#be185d"];
7
+ export declare const isEditorColor: (value: unknown) => value is EditorColor;
8
+ export declare const isEditorHighlightColor: (value: unknown) => value is EditorHighlightColor;
9
+ export declare const editorHighlightCss: (value: EditorHighlightColor) => string;
@@ -0,0 +1,13 @@
1
+ import { type IqujiColorPickerProps } from "@iquji-community/web-component";
2
+ import type { Editor } from "@tiptap/core";
3
+ import { type ReactElement } from "react";
4
+ export interface IqujiEditorColorControlProps {
5
+ editor: Editor | null;
6
+ kind: "highlight" | "textColor";
7
+ disabled?: boolean | undefined;
8
+ selectionOnly?: boolean | undefined;
9
+ trigger?: ReactElement | undefined;
10
+ labels: Pick<IqujiColorPickerProps, "label" | "defaultLabel" | "customLabel" | "hexLabel" | "applyLabel" | "cancelLabel">;
11
+ colorLabel(value: string): string;
12
+ }
13
+ export declare function IqujiEditorColorControl({ editor, kind, disabled, selectionOnly, trigger, labels, colorLabel, }: IqujiEditorColorControlProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ export type EditorAlignment = "left" | "center" | "right" | "justify";
2
+ export type EditorFormatIconName = EditorAlignment | "bold" | "italic" | "underline" | "strike" | "code" | "highlight" | "image" | "link" | "divider" | "table" | "blockquote" | "bulletList" | "orderedList" | "taskList" | "formatBrush" | "find" | "attachment" | "indent" | "outdent" | "clearFormatting" | "undo" | "redo" | "minus" | "plus" | "chevron-down";
3
+ export declare function EditorFormatIcon({ name }: {
4
+ name: EditorFormatIconName;
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import type { HTMLAttributes, ReactNode } from "react";
2
+ export interface IqujiEditorLayoutProps extends HTMLAttributes<HTMLDivElement> {
3
+ toolbar?: ReactNode;
4
+ footer?: ReactNode;
5
+ children: ReactNode;
6
+ }
7
+ /** 按工具栏、正文和页脚顺序排列内容。 */
8
+ export declare function IqujiEditorLayout({ toolbar, footer, children, className, ...props }: IqujiEditorLayoutProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import type { HTMLAttributes, ReactNode, Ref } from "react";
2
+ export interface IqujiEditorViewportProps extends HTMLAttributes<HTMLDivElement> {
3
+ toolbar?: ReactNode;
4
+ overlay?: ReactNode;
5
+ footer?: ReactNode;
6
+ zoom?: number;
7
+ scrollRef?: Ref<HTMLDivElement>;
8
+ onBodyInteract?(target: EventTarget): void;
9
+ classes?: Partial<Record<"workspace" | "viewport" | "scroll" | "page" | "footer", string>>;
10
+ }
11
+ /** 在可滚动视口内缩放页面,并渲染独立的工具栏和浮层。 */
12
+ export declare function IqujiEditorViewport({ toolbar, overlay, footer, zoom, scrollRef, onBodyInteract, classes, children, className, ...props }: IqujiEditorViewportProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ export * from "./colors.js";
2
+ export * from "./editor-color-control.js";
3
+ export * from "./editor-layout.js";
4
+ export * from "./editor-viewport.js";
5
+ export * from "./markdown.js";
6
+ export * from "./presets.js";
7
+ export * from "./rich-text-colors.js";
8
+ export * from "./rich-text-content.js";
9
+ export * from "./rich-text-editor.js";
10
+ export * from "./rich-text-preset.js";
11
+ export * from "./rich-text-toolbar.js";
12
+ export * from "./text-editor.js";