@linker-design-plus/tiny-peony 1.2.28

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.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/dist/foundation/commandExecutor/commandExecutor.d.ts +9 -0
  3. package/dist/foundation/contentManager/contentManager.d.ts +21 -0
  4. package/dist/foundation/cursorManager/cursorManager.d.ts +14 -0
  5. package/dist/foundation/editorManager/editor.d.ts +39 -0
  6. package/dist/foundation/editorManager/maxLength.d.ts +4 -0
  7. package/dist/foundation/editorManager/paste.d.ts +3 -0
  8. package/dist/foundation/undoManager/undoManager.d.ts +18 -0
  9. package/dist/index.d.ts +367 -0
  10. package/dist/index.js +63 -0
  11. package/dist/index.mjs +4494 -0
  12. package/dist/intersection/components/CommonModal/CommonModal.d.ts +40 -0
  13. package/dist/intersection/components/CommonModal/composables/useModalWrapper.d.ts +47 -0
  14. package/dist/intersection/components/CommonModal/index.d.ts +86 -0
  15. package/dist/intersection/components/CommonModal/syncConfirm.d.ts +2 -0
  16. package/dist/intersection/components/editor/context.d.ts +45 -0
  17. package/dist/intersection/components/editor/editor.d.ts +172 -0
  18. package/dist/intersection/components/editor/iconfont.d.ts +20 -0
  19. package/dist/intersection/components/editor/index.d.ts +365 -0
  20. package/dist/intersection/components/modals/contextMenu.vue.d.ts +22 -0
  21. package/dist/intersection/hooks/use-editor.d.ts +54 -0
  22. package/dist/intersection/hooks/use-highlight.d.ts +7 -0
  23. package/dist/intersection/stores/use-editor-store.d.ts +0 -0
  24. package/dist/plugins/AnchorTagPlugin/constant.d.ts +1 -0
  25. package/dist/plugins/AnchorTagPlugin/index.d.ts +2 -0
  26. package/dist/plugins/AnchorTagPlugin/plugin.d.ts +37 -0
  27. package/dist/plugins/HomophonesTagPlugin/homophoner.vue.d.ts +13 -0
  28. package/dist/plugins/HomophonesTagPlugin/index.d.ts +2 -0
  29. package/dist/plugins/HomophonesTagPlugin/plugin.d.ts +17 -0
  30. package/dist/plugins/PausationTagPlugin/index.d.ts +2 -0
  31. package/dist/plugins/PausationTagPlugin/pausationor.vue.d.ts +9 -0
  32. package/dist/plugins/PausationTagPlugin/plugin.d.ts +28 -0
  33. package/dist/plugins/PronunciationTagPlugin/index.d.ts +2 -0
  34. package/dist/plugins/PronunciationTagPlugin/plugin.d.ts +19 -0
  35. package/dist/plugins/PronunciationTagPlugin/pronunciationor.vue.d.ts +13 -0
  36. package/dist/tiny-peony.css +1 -0
  37. package/dist/typings/actions/i-anchor.d.ts +22 -0
  38. package/dist/typings/actions/i-homophone.d.ts +9 -0
  39. package/dist/typings/actions/i-modal.d.ts +7 -0
  40. package/dist/typings/actions/i-plugin.d.ts +9 -0
  41. package/dist/typings/index.d.ts +9 -0
  42. package/dist/typings/intersection/editor.d.ts +35 -0
  43. package/dist/typings/shared.d.ts +16 -0
  44. package/dist/typings/status/i-command-executor.d.ts +8 -0
  45. package/dist/typings/status/i-content-manager.d.ts +14 -0
  46. package/dist/typings/status/i-cursor-manager.d.ts +10 -0
  47. package/dist/typings/status/i-editor-manager.d.ts +20 -0
  48. package/dist/typings/status/i-undo-manager.d.ts +26 -0
  49. package/dist/utils/dom.d.ts +18 -0
  50. package/dist/utils/index.d.ts +3 -0
  51. package/dist/utils/shared.d.ts +2 -0
  52. package/dist/utils/value-type.d.ts +12 -0
  53. package/package.json +43 -0
@@ -0,0 +1,9 @@
1
+ export interface HomophoneEntity {
2
+ pinyin1: Array<string>;
3
+ pinyin2: Array<string>;
4
+ recommend: string;
5
+ word: string;
6
+ modify: string;
7
+ wordIndex: number;
8
+ paraIndex: number;
9
+ }
@@ -0,0 +1,7 @@
1
+ export interface ModalReturn<T extends Record<string, any> = any> {
2
+ target?: HTMLSpanElement;
3
+ close(): void;
4
+ update(config: {
5
+ visible?: boolean;
6
+ } & T): void;
7
+ }
@@ -0,0 +1,9 @@
1
+ export declare abstract class IPlugin<Options = any, Data extends any = any> {
2
+ abstract name: string;
3
+ abstract prefix: string;
4
+ abstract data: Data;
5
+ abstract add(options: Options): void;
6
+ abstract remove(target: HTMLSpanElement): void;
7
+ abstract setup(): void;
8
+ abstract destroy(): void;
9
+ }
@@ -0,0 +1,9 @@
1
+ export * from './shared';
2
+ export * from './status/i-editor-manager';
3
+ export * from './status/i-content-manager';
4
+ export * from './status/i-cursor-manager';
5
+ export * from './status/i-undo-manager';
6
+ export * from './status/i-command-executor';
7
+ export * from './actions/i-plugin';
8
+ export * from './actions/i-anchor';
9
+ export * from './intersection/editor';
@@ -0,0 +1,35 @@
1
+ import { ListenModeEnum } from '../shared';
2
+ export interface EditorComponentProps {
3
+ /**
4
+ * 预计时长,按文字数量计算
5
+ */
6
+ preTime: string;
7
+ /**
8
+ * 实际时长,按文字数量计算
9
+ */
10
+ realTime: string;
11
+ /**
12
+ * 编辑器已输入文字数量
13
+ */
14
+ textCount: number;
15
+ /**
16
+ * 试听虚拟主播ID
17
+ */
18
+ listenAnchorId: number;
19
+ /**
20
+ * 试听模式:单主播试听 | 整体试听
21
+ */
22
+ listenMode: ListenModeEnum;
23
+ /**
24
+ * 编辑器区域占位文案
25
+ */
26
+ placeholder: string;
27
+ /**
28
+ * simple 简易模式,只显示内容编辑区域
29
+ */
30
+ simple: boolean;
31
+ /**
32
+ * 最大字数
33
+ */
34
+ maxLength: number;
35
+ }
@@ -0,0 +1,16 @@
1
+ export declare enum SelectionType {
2
+ None = "None",
3
+ Caret = "Caret",
4
+ Range = "Range"
5
+ }
6
+ export declare enum PluginFlag {
7
+ pausation = "pausation",
8
+ pronunciation = "pronunciation",
9
+ anchor = "anchor",
10
+ homophones = "homophones",
11
+ highlight = "highlight"
12
+ }
13
+ export declare enum ListenModeEnum {
14
+ single = "single",
15
+ multiple = "multiple"
16
+ }
@@ -0,0 +1,8 @@
1
+ import type { IContentManager } from './i-content-manager';
2
+ import type { ICursorManager } from './i-cursor-manager';
3
+ export declare abstract class ICommandExecutor {
4
+ abstract contentManager: IContentManager;
5
+ abstract cursorManager: ICursorManager;
6
+ abstract executeUndo(): void;
7
+ abstract executeRedo(): void;
8
+ }
@@ -0,0 +1,14 @@
1
+ export declare abstract class IContentManager {
2
+ abstract calcTextCount(): number;
3
+ abstract getHtml(): string;
4
+ abstract setHtml(content: string): void;
5
+ abstract getContent(): string;
6
+ abstract setContent(content: string): void;
7
+ abstract appendContent(content: string | string[], cb?: (para: HTMLElement) => void): void;
8
+ abstract insert(content: string | Node): void;
9
+ abstract delete(): void;
10
+ abstract update(content: string | Node): void;
11
+ abstract getParas(): HTMLElement[];
12
+ abstract getTextContent(): string[];
13
+ abstract insertEmptyPara(): void;
14
+ }
@@ -0,0 +1,10 @@
1
+ export declare abstract class ICursorManager {
2
+ abstract range: Range | undefined;
3
+ abstract isCaret(): boolean;
4
+ abstract isRange(): boolean;
5
+ abstract getRangeContent(): string;
6
+ abstract toEnd(node: Node): void;
7
+ abstract destroy(): void;
8
+ abstract isRangeInEditor(): boolean;
9
+ abstract getRangeTop(): number;
10
+ }
@@ -0,0 +1,20 @@
1
+ import { IPlugin } from '../actions/i-plugin';
2
+ import type { ICommandExecutor } from './i-command-executor';
3
+ import type { IContentManager } from './i-content-manager';
4
+ import type { ICursorManager } from './i-cursor-manager';
5
+ import type { IUndoManager } from './i-undo-manager';
6
+ export declare abstract class IEditorCore {
7
+ abstract readonly _uid: string;
8
+ abstract readonly _editorElement: HTMLElement;
9
+ abstract content: IContentManager;
10
+ abstract cursor: ICursorManager;
11
+ abstract undo: IUndoManager;
12
+ abstract command: ICommandExecutor;
13
+ abstract maxLength: number;
14
+ abstract plugin: Record<string, IPlugin>;
15
+ abstract destroy(): void;
16
+ abstract editorTop(): number;
17
+ abstract editorLeft(): number;
18
+ abstract appendContent(content: string | string[]): void;
19
+ abstract element: HTMLElement;
20
+ }
@@ -0,0 +1,26 @@
1
+ import type { IContentManager } from './i-content-manager';
2
+ export type MatchedIndexes = Array<{
3
+ index: number;
4
+ }>;
5
+ export interface HistoryStackItem {
6
+ content: string;
7
+ anchorContent: string;
8
+ startParaIndex: number;
9
+ startMatchedIndexes: Array<{
10
+ index: number;
11
+ }>;
12
+ startOffset: number;
13
+ endParaIndex: number;
14
+ endMatchedIndexes: Array<{
15
+ index: number;
16
+ }>;
17
+ endOffset: number;
18
+ }
19
+ export declare abstract class IUndoManager {
20
+ abstract contentManager: IContentManager;
21
+ abstract undoStack: HistoryStackItem[];
22
+ abstract redoStack: HistoryStackItem[];
23
+ abstract saveState(): void;
24
+ abstract undo(): void;
25
+ abstract redo(): void;
26
+ }
@@ -0,0 +1,18 @@
1
+ import { PluginFlag } from '../typings';
2
+ export declare const setAttributesAndData: (element: HTMLElement, attributes: Record<string, string | number | boolean>, dataAttributes: Record<string, string | number>, child?: string | Node) => void;
3
+ export declare const findParent: (element: HTMLElement, _conditions: ((element: HTMLElement) => boolean) | Array<(element: HTMLElement) => boolean>) => (HTMLElement | null)[];
4
+ export declare const findClosestPara: (startElm: HTMLElement) => HTMLElement | null;
5
+ export declare const findAllParaInRange: (startP: HTMLElement, endP: HTMLElement) => HTMLElement[];
6
+ export declare const getOverlay: (type: PluginFlag) => HTMLDivElement;
7
+ export declare const spellingTextNode: (node: Node, spellingText?: string, firstJudge?: boolean) => void;
8
+ /**
9
+ * 获取两个随机字符串中的最长**连续**子序列
10
+ * 借助变量正序DP,一维数组(空间复杂度O(m))
11
+ * @param {String} text1 随机字符串
12
+ * @param {String} text2 随机字符串
13
+ * @return string
14
+ *
15
+ * 时间复杂度:O(mn) - DP循环次数
16
+ * 空间复杂度:O(n) - text2字符串长度
17
+ */
18
+ export declare const longestConsecutiveSubsequence: (text1: string, text2: string) => string;
@@ -0,0 +1,3 @@
1
+ export * from './shared';
2
+ export * from './value-type';
3
+ export * from './dom';
@@ -0,0 +1,2 @@
1
+ export declare const createTagSpace: (name: string) => [import("@linker-design/utils").Bem, string];
2
+ export declare const createComponentSpace: (name: string) => [import("@linker-design/utils").Bem, string];
@@ -0,0 +1,12 @@
1
+ export declare const valueType: (val: any) => string;
2
+ export declare const isString: (val: any) => val is string;
3
+ export declare const isNumber: (val: any) => val is number;
4
+ export declare const isArray: (val: any) => val is any[];
5
+ export declare const isObject: (val: any) => val is Record<string, unknown>;
6
+ export declare const isNull: (val: any) => val is null;
7
+ export declare const isUndefined: (val: any) => val is undefined;
8
+ export declare const isNullable: (val: any) => val is null | undefined;
9
+ export declare const isBoolean: (val: any) => val is boolean;
10
+ export declare const isElement: (val: any) => val is Element;
11
+ export declare const isHTMLElement: (val: any) => val is HTMLElement;
12
+ export declare const isText: (val: any) => val is Text;
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@linker-design-plus/tiny-peony",
3
+ "version": "1.2.28",
4
+ "description": "a simple editor",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "publishConfig": {
8
+ "registry": "https://registry.npmjs.org/",
9
+ "access": "public"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "keywords": [
15
+ "linker design tiny peony"
16
+ ],
17
+ "author": "Linker Design Team",
18
+ "license": "MIT",
19
+ "dependencies": {
20
+ "@arco-design/web-vue": "^2.56.3",
21
+ "@linker-design/utils": "^0.1.7",
22
+ "@om-design/util": "^1.6.1",
23
+ "@vueuse/core": "^12.3.0",
24
+ "uuid": "^11.0.4",
25
+ "vue": "3.5.13"
26
+ },
27
+ "devDependencies": {
28
+ "@vitejs/plugin-vue": "^5.2.1",
29
+ "@vitejs/plugin-vue-jsx": "^4.1.1",
30
+ "esbuild-plugin-inline-worker": "^0.1.1",
31
+ "esbuild-plugin-less": "^1.3.14",
32
+ "less": "^4.2.0",
33
+ "less-loader": "^12.2.0",
34
+ "typescript": "^5.7.2",
35
+ "vite": "^6.0.7",
36
+ "vue-tsc": "^2.2.0"
37
+ },
38
+ "scripts": {
39
+ "startup": "pnpm build",
40
+ "build": "vue-tsc --noEmit && vite build && vue-tsc --declaration --emitDeclarationOnly --outDir dist",
41
+ "clean": "rm -rf dist"
42
+ }
43
+ }