@connectedxm/entity-editor 0.0.5 → 0.0.9

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.
@@ -1,20 +1,25 @@
1
1
  import { default as React } from 'react';
2
- import { Entity, EntityOptions, StyleOptions, EntityType, MarkState, MarkType, SearchEntity } from './interfaces';
2
+ import { Entity, EntityOptions, StyleOptions, EntityType, MarkState, MarkType, MentionSearch } from './interfaces';
3
3
  export interface EditorRef {
4
4
  selectEntity: (entityType: EntityType, startIndex: number, endIndex: number, newText: string) => void;
5
5
  toggleMark: (markType: MarkType) => void;
6
6
  clear: () => void;
7
+ reset: () => void;
8
+ focus: () => void;
9
+ getState: () => {
10
+ plainText: string;
11
+ entities: Entity[];
12
+ markState: MarkState;
13
+ };
7
14
  }
8
15
  export interface EditorProps {
9
16
  ref: React.RefObject<EditorRef | null>;
10
- plainText: string;
11
- setPlainText: (plainText: string) => void;
12
- entities: Entity[];
13
- setEntities: (entities: Entity[]) => void;
14
- markState: MarkState;
15
- setMarkState: (markState: MarkState) => void;
16
- search: SearchEntity | null;
17
- setSearch: (search: SearchEntity | null) => void;
17
+ initialPlainText?: string;
18
+ initialEntities?: Entity[];
19
+ onMentionSearch?: (mentionSearch: MentionSearch | null) => void;
20
+ onMarkStateChange?: (markState: MarkState) => void;
21
+ onLinkCreated?: (link: Entity) => void;
22
+ onInterestCreated?: (interest: Entity) => void;
18
23
  style?: React.CSSProperties;
19
24
  className?: string;
20
25
  options?: EntityOptions;
@@ -22,4 +27,4 @@ export interface EditorProps {
22
27
  placeholder?: string;
23
28
  debug?: boolean;
24
29
  }
25
- export declare const Editor: ({ ref, plainText, setPlainText, entities, setEntities, markState, setMarkState, search, setSearch, options, entityStyles, placeholder, debug, ...props }: EditorProps) => import("react/jsx-runtime").JSX.Element;
30
+ export declare const Editor: ({ ref, initialPlainText, initialEntities, onMentionSearch, onMarkStateChange, onLinkCreated, onInterestCreated, options, entityStyles, placeholder, debug, ...props }: EditorProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,12 @@
1
- import { SearchEntity } from '../../interfaces';
2
1
  export declare const INTEREST_MASK = 64;
3
2
  export declare const INTEREST_BOUNDARIES = ".,!?;()[]{}\"'<>@";
4
3
  export declare const INTEREST_REGEX: RegExp;
5
4
  export declare const INTEREST_KEY = "#";
6
- export declare const getInterestWord: (plainText: string, position: number) => SearchEntity | null;
5
+ export interface InterestMatch {
6
+ search: string;
7
+ startIndex: number;
8
+ endIndex: number;
9
+ }
10
+ export declare const getInterestWord: (plainText: string, position: number) => InterestMatch | null;
7
11
  export declare const isInterest: (value: number) => boolean;
8
12
  export declare const setInterest: (value: number, interest: boolean) => number;
@@ -1,8 +1,12 @@
1
- import { SearchEntity } from '../../interfaces';
2
1
  export declare const LINK_MASK = 128;
3
2
  export declare const LINK_BOUNDARIES = "()[]{}";
4
3
  export declare const LINK_KEY = "";
5
4
  export declare const LINK_REGEX: RegExp;
6
- export declare const getLinkWord: (plainText: string, position: number) => SearchEntity | null;
5
+ export interface LinkMatch {
6
+ search: string;
7
+ startIndex: number;
8
+ endIndex: number;
9
+ }
10
+ export declare const getLinkWord: (plainText: string, position: number) => LinkMatch | null;
7
11
  export declare const isLink: (value: number) => boolean;
8
12
  export declare const setLink: (value: number, link: boolean) => number;
@@ -1,8 +1,8 @@
1
- import { SearchEntity } from '../../interfaces';
1
+ import { MentionSearch } from '../../interfaces';
2
2
  export declare const MENTION_MASK = 32;
3
3
  export declare const MENTION_REGEX: RegExp;
4
4
  export declare const MENTION_BOUNDARIES = ".,!?;()[]{}\"'<>#";
5
5
  export declare const MENTION_KEY = "@";
6
- export declare const getMentionWord: (plainText: string, position: number) => SearchEntity | null;
6
+ export declare const getMentionWord: (plainText: string, position: number) => MentionSearch | null;
7
7
  export declare const isMention: (value: number) => boolean;
8
8
  export declare const setMention: (value: number, mention: boolean) => number;
@@ -1,4 +1,4 @@
1
- import { BitMap, Entity, SearchEntity } from '../interfaces';
1
+ import { BitMap, Entity } from '../interfaces';
2
2
  export interface TextChange {
3
3
  position: number;
4
4
  deletedLength: number;
@@ -33,4 +33,9 @@ export declare const adjustSelectionForTextChange: (selection: {
33
33
  end: number;
34
34
  };
35
35
  export declare const isWhitespace: (char: string) => boolean;
36
- export declare const getWordAtPosition: (plainText: string, position: number, boundaryChars: string, endChar: string) => Omit<SearchEntity, "type"> | null;
36
+ export interface WordMatch {
37
+ search: string;
38
+ startIndex: number;
39
+ endIndex: number;
40
+ }
41
+ export declare const getWordAtPosition: (plainText: string, position: number, boundaryChars: string, endChar: string) => WordMatch | null;
@@ -30,8 +30,8 @@ export interface MarkState {
30
30
  underline: boolean;
31
31
  strike: boolean;
32
32
  }
33
- export interface SearchEntity {
34
- type: "mention" | "interest" | "link";
33
+ export interface MentionSearch {
34
+ type: "mention";
35
35
  search: string;
36
36
  startIndex: number;
37
37
  endIndex: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectedxm/entity-editor",
3
- "version": "0.0.5",
3
+ "version": "0.0.9",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.umd.js",
@@ -23,13 +23,13 @@
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "^22.15.3",
26
- "@types/react": "^19.1.13",
27
- "@types/react-dom": "^19.1.9",
28
- "@vitejs/plugin-react": "^5.0.3",
29
- "react": "^19.1.1",
30
- "react-dom": "^19.1.1",
31
- "typescript": "^5.9.2",
32
- "vite": "^7.1.5",
26
+ "@types/react": "^19.2.8",
27
+ "@types/react-dom": "^19.2.3",
28
+ "@vitejs/plugin-react": "^5.1.2",
29
+ "react": "^19.2.3",
30
+ "react-dom": "^19.2.3",
31
+ "typescript": "^5.9.3",
32
+ "vite": "^7.3.1",
33
33
  "vite-plugin-dts": "^4.5.4",
34
34
  "vitest": "^3.2.4"
35
35
  }