@arkitektbedriftene/fe-lib 0.3.7 → 0.3.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.
- package/dist/{Popover-e50ca73e.js → Popover-2318823a.js} +75 -83
- package/dist/lib/rich-text/Editor.d.ts +2 -3
- package/dist/lib/rich-text/editorContext.d.ts +18 -0
- package/dist/lib/rich-text/rich-text.d.ts +1 -0
- package/dist/lib/ui/components/Spinner.d.ts +1 -1
- package/dist/rich-text.es.js +134 -1438
- package/dist/ui.es.js +2 -2
- package/package.json +10 -10
- package/src/lib/rich-text/Editor.tsx +7 -8
- package/src/lib/rich-text/{editorFocus.ts → editorContext.ts} +6 -4
- package/src/lib/rich-text/rich-text.ts +2 -1
- package/vite.config.ts +1 -7
- package/dist/lib/rich-text/editorFocus.d.ts +0 -12
package/dist/ui.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as t, a as n, b as p } from "./Popover-
|
|
2
|
-
import { A as v, B as j, d as u, O as C, S as P, c as b, g as h, k as y, s as O } from "./Popover-
|
|
1
|
+
import { P as t, a as n, b as p } from "./Popover-2318823a.js";
|
|
2
|
+
import { A as v, B as j, d as u, O as C, S as P, c as b, g as h, k as y, s as O } from "./Popover-2318823a.js";
|
|
3
3
|
import { j as o } from "./jsx-runtime-d0aa4c5b.js";
|
|
4
4
|
import { useState as i } from "react";
|
|
5
5
|
import "react-dom";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkitektbedriftene/fe-lib",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.umd.cjs",
|
|
6
6
|
"module": "./dist/index.es.js",
|
|
@@ -55,15 +55,15 @@
|
|
|
55
55
|
"react": "^18.2.0",
|
|
56
56
|
"react-dom": "^18.2.0",
|
|
57
57
|
"@floating-ui/react": "^0.26.0",
|
|
58
|
-
"lexical": "0.12.0",
|
|
59
|
-
"@lexical/headless": "0.12.0",
|
|
60
|
-
"@lexical/html": "0.12.0",
|
|
61
|
-
"@lexical/link": "0.12.0",
|
|
62
|
-
"@lexical/rich-text": "0.12.0",
|
|
63
|
-
"@lexical/table": "0.12.0",
|
|
64
|
-
"@lexical/selection": "0.12.0",
|
|
65
|
-
"@lexical/list": "0.12.0",
|
|
66
|
-
"@lexical/react": "0.12.0",
|
|
58
|
+
"lexical": "^0.12.0",
|
|
59
|
+
"@lexical/headless": "^0.12.0",
|
|
60
|
+
"@lexical/html": "^0.12.0",
|
|
61
|
+
"@lexical/link": "^0.12.0",
|
|
62
|
+
"@lexical/rich-text": "^0.12.0",
|
|
63
|
+
"@lexical/table": "^0.12.0",
|
|
64
|
+
"@lexical/selection": "^0.12.0",
|
|
65
|
+
"@lexical/list": "^0.12.0",
|
|
66
|
+
"@lexical/react": "^0.12.0",
|
|
67
67
|
"@types/react": "*",
|
|
68
68
|
"@types/react-dom": "*"
|
|
69
69
|
},
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { useRef, type ReactNode, useMemo } from "react";
|
|
2
2
|
import { Box, Spinner, styled } from "../ui/ui";
|
|
3
3
|
import { type InitialConfigType, LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
4
4
|
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
5
5
|
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
6
6
|
import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary";
|
|
7
|
-
import { useMergeRefs } from "@floating-ui/react";
|
|
8
7
|
import { lexicalTheme } from "./theme";
|
|
9
|
-
import { useHasFocusWithin,
|
|
8
|
+
import { useHasFocusWithin, richTextContext } from "./editorContext";
|
|
10
9
|
|
|
11
10
|
const Container = styled("div", {
|
|
12
11
|
border: "1px solid $borderDarker",
|
|
@@ -98,7 +97,6 @@ export const RichTextEditor = ({
|
|
|
98
97
|
nodes,
|
|
99
98
|
plugins,
|
|
100
99
|
toolbar,
|
|
101
|
-
refs,
|
|
102
100
|
}: {
|
|
103
101
|
isLoading: boolean;
|
|
104
102
|
children: ReactNode;
|
|
@@ -106,12 +104,13 @@ export const RichTextEditor = ({
|
|
|
106
104
|
nodes: InitialConfigType["nodes"];
|
|
107
105
|
plugins?: ReactNode;
|
|
108
106
|
toolbar?: ReactNode;
|
|
109
|
-
refs?: React.RefObject<HTMLElement>[];
|
|
110
107
|
}) => {
|
|
111
108
|
const { hasFocus, attributes } = useHasFocusWithin({});
|
|
109
|
+
const editorRef = useRef<HTMLDivElement>(null);
|
|
110
|
+
const contextValue = useMemo(() => ({ hasFocus, editorRef }), [hasFocus]);
|
|
112
111
|
|
|
113
112
|
return (
|
|
114
|
-
<
|
|
113
|
+
<richTextContext.Provider value={contextValue}>
|
|
115
114
|
<LexicalComposer
|
|
116
115
|
initialConfig={{
|
|
117
116
|
namespace: "CommentEditor",
|
|
@@ -124,7 +123,7 @@ export const RichTextEditor = ({
|
|
|
124
123
|
}}
|
|
125
124
|
>
|
|
126
125
|
<Container
|
|
127
|
-
ref={
|
|
126
|
+
ref={editorRef}
|
|
128
127
|
hasFocus={hasFocus}
|
|
129
128
|
{...attributes}
|
|
130
129
|
>
|
|
@@ -162,6 +161,6 @@ export const RichTextEditor = ({
|
|
|
162
161
|
{/* biome-ignore lint/complexity/noUselessFragments: <explanation> */}
|
|
163
162
|
<>{children}</>
|
|
164
163
|
</LexicalComposer>
|
|
165
|
-
</
|
|
164
|
+
</richTextContext.Provider>
|
|
166
165
|
);
|
|
167
166
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { createContext, useCallback, useContext, useRef, useState } from "react";
|
|
1
|
+
import { type RefObject, createContext, useCallback, useContext, useRef, useState } from "react";
|
|
2
2
|
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
export const useIsEditorFocused = () => useContext(editorFocusContext);
|
|
3
|
+
export const richTextContext = createContext({ hasFocus: false, editorRef: { current: null } } as { hasFocus: boolean, editorRef: RefObject<HTMLElement | null> });
|
|
6
4
|
|
|
7
5
|
export const useHasFocusWithin = ({ onBlur }: { onBlur?: () => void }) => {
|
|
8
6
|
const [hasFocus, setHasFocus] = useState(false);
|
|
@@ -30,3 +28,7 @@ export const useHasFocusWithin = ({ onBlur }: { onBlur?: () => void }) => {
|
|
|
30
28
|
},
|
|
31
29
|
};
|
|
32
30
|
};
|
|
31
|
+
|
|
32
|
+
export const useRichTextContext = () => {
|
|
33
|
+
return useContext(richTextContext);
|
|
34
|
+
}
|
package/vite.config.ts
CHANGED
|
@@ -26,13 +26,7 @@ export default defineConfig({
|
|
|
26
26
|
"react",
|
|
27
27
|
"react-dom",
|
|
28
28
|
"lexical",
|
|
29
|
-
|
|
30
|
-
"@lexical/html",
|
|
31
|
-
"@lexical/link",
|
|
32
|
-
"@lexical/rich-text",
|
|
33
|
-
"@lexical/table",
|
|
34
|
-
"@lexical/selection",
|
|
35
|
-
"@lexical/list",
|
|
29
|
+
/^@lexical\/.*/,
|
|
36
30
|
],
|
|
37
31
|
output: {
|
|
38
32
|
globals: {
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare const editorFocusContext: import("react").Context<boolean>;
|
|
3
|
-
export declare const useIsEditorFocused: () => boolean;
|
|
4
|
-
export declare const useHasFocusWithin: ({ onBlur }: {
|
|
5
|
-
onBlur?: (() => void) | undefined;
|
|
6
|
-
}) => {
|
|
7
|
-
hasFocus: boolean;
|
|
8
|
-
attributes: {
|
|
9
|
-
onFocus: () => void;
|
|
10
|
-
onBlur: () => void;
|
|
11
|
-
};
|
|
12
|
-
};
|