@sps-woodland/rich-text-editor 7.0.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/README.md +3 -0
- package/global.d.ts +4 -0
- package/lib/RTELinkModal.d.ts +12 -0
- package/lib/RichTextEditor.css.d.ts +14 -0
- package/lib/RichTextEditor.d.ts +7 -0
- package/lib/RichTextEditorExamples.d.ts +2 -0
- package/lib/hooks/useHtmlToMd.d.ts +1 -0
- package/lib/hooks/useMdToHtml.d.ts +1 -0
- package/lib/hooks/useRTEContent.d.ts +13 -0
- package/lib/hooks/useRTEObserver.d.ts +5 -0
- package/lib/hooks/useRTESelectionListener.d.ts +6 -0
- package/lib/hooks/useRTEToolbarButtons.d.ts +14 -0
- package/lib/icons/index.d.ts +11 -0
- package/lib/index.cjs.js +157 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.es.js +12482 -0
- package/lib/manifest.d.ts +2 -0
- package/lib/style.css +1 -0
- package/lib/toolbar-button/RTEToolbarButton.css.d.ts +15 -0
- package/lib/toolbar-button/RTEToolbarButton.d.ts +10 -0
- package/lib/utils/utils.d.ts +2 -0
- package/package.json +52 -0
- package/vite.config.js +21 -0
package/README.md
ADDED
package/global.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ComponentProps } from "@sps-woodland/core";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import type { SelectionDOMContextFind } from "./hooks/useRTESelectionListener";
|
|
4
|
+
export interface LinkConfig {
|
|
5
|
+
text: string;
|
|
6
|
+
link: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function RTELinkModal({ onClose, selectionDOMContextFind, selectionRange, }: ComponentProps<{
|
|
9
|
+
onClose: (range?: Range, config?: LinkConfig) => void;
|
|
10
|
+
selectionDOMContextFind: SelectionDOMContextFind;
|
|
11
|
+
selectionRange?: Range;
|
|
12
|
+
}>): React.ReactElement;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const richTextEditor: import("@vanilla-extract/recipes/dist/declarations/src/types").RuntimeFn<{
|
|
2
|
+
disabled: {
|
|
3
|
+
true: {
|
|
4
|
+
borderColor: string;
|
|
5
|
+
};
|
|
6
|
+
false: {
|
|
7
|
+
borderColor: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}>;
|
|
11
|
+
export declare type RichTextEditorVariants = Required<Parameters<typeof richTextEditor>>[0];
|
|
12
|
+
export declare const rteEditableDiv: typeof richTextEditor;
|
|
13
|
+
export declare const rteToolbar: string;
|
|
14
|
+
export declare const vr: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ComponentProps } from "@sps-woodland/core";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import type { RichTextEditorAggregateValue } from "./hooks/useRTEContent";
|
|
4
|
+
import type { RichTextEditorVariants } from "./RichTextEditor.css";
|
|
5
|
+
export declare function RichTextEditor({ className, md: mdProp, html: htmlProp, disabled, onChange, ...rest }: ComponentProps<RichTextEditorVariants & Partial<RichTextEditorAggregateValue> & {
|
|
6
|
+
onChange?: (newValue: RichTextEditorAggregateValue) => void;
|
|
7
|
+
}, HTMLDivElement>): React.ReactElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useHtmlToMd(): (html: string) => Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useMdToHtml(): (md: string) => Promise<string>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
export interface RichTextEditorAggregateValue {
|
|
3
|
+
md: string;
|
|
4
|
+
html: string;
|
|
5
|
+
}
|
|
6
|
+
export declare type RTEStateUpdateFromDiv = <T extends HTMLElement>(ref: RefObject<T>) => void;
|
|
7
|
+
export declare function useRTEContent(initMd?: string, initHtml?: string): {
|
|
8
|
+
aggValue?: RichTextEditorAggregateValue;
|
|
9
|
+
editableDivInnerHtml: {
|
|
10
|
+
html: string;
|
|
11
|
+
};
|
|
12
|
+
updateStateFromDiv: RTEStateUpdateFromDiv;
|
|
13
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
import type { RTEStateUpdateFromDiv } from "./useRTEContent";
|
|
3
|
+
export declare function moveCaretAfter(node: Node): void;
|
|
4
|
+
export declare function moveCaretBefore(node: Node): void;
|
|
5
|
+
export declare function useRTEObserver(updateStateFromDiv: RTEStateUpdateFromDiv): RefObject<HTMLDivElement>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare type ElementTest = (element: HTMLElement) => boolean;
|
|
2
|
+
export declare type SelectionDOMContextFind = (test?: ElementTest) => HTMLElement | null;
|
|
3
|
+
export declare function useRTESelectionListener(editableDivRef: any): {
|
|
4
|
+
selectionRange: Range | undefined;
|
|
5
|
+
selectionDOMContextFind: SelectionDOMContextFind;
|
|
6
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
import type { RTEToolbarButton } from "../toolbar-button/RTEToolbarButton";
|
|
3
|
+
import type { LinkConfig } from "../RTELinkModal";
|
|
4
|
+
import type { SelectionDOMContextFind } from "./useRTESelectionListener";
|
|
5
|
+
declare type ToolbarButtonProps = Parameters<typeof RTEToolbarButton>[0] & {
|
|
6
|
+
key: string;
|
|
7
|
+
};
|
|
8
|
+
declare type ToolbarButtonPartialProps = Omit<ToolbarButtonProps, "selectionDOMContextFind">;
|
|
9
|
+
export declare function useRTEToolbarButtons(selectionDOMContextFind: SelectionDOMContextFind, editableDivRef: RefObject<HTMLDivElement>): {
|
|
10
|
+
toolbarButtons: (ToolbarButtonPartialProps | "vr")[];
|
|
11
|
+
showLinkModal: boolean;
|
|
12
|
+
handleLinkModalClose: (range: Range, config?: LinkConfig) => void;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import bold from "./BOLD.svg";
|
|
2
|
+
import indent from "./INDENT.svg";
|
|
3
|
+
import italics from "./ITALICS.svg";
|
|
4
|
+
import link from "./LINK.svg";
|
|
5
|
+
import orderedList from "./ORDERED_LIST.svg";
|
|
6
|
+
import outdent from "./OUTDENT.svg";
|
|
7
|
+
import redo from "./REDO.svg";
|
|
8
|
+
import undo from "./UNDO.svg";
|
|
9
|
+
import unlink from "./UNLINK.svg";
|
|
10
|
+
import unorderedList from "./UNORDERED_LIST.svg";
|
|
11
|
+
export { bold, indent, italics, link, orderedList, outdent, redo, undo, unlink, unorderedList, };
|