@byline/richtext-lexical 4.11.2 → 4.12.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/dist/config.d.ts +1 -1
- package/dist/field/extensions/link/floating-link-editor.js +2 -2
- package/dist/field/extensions/link/link-modal.js +2 -2
- package/dist/field/extensions/link/link-node.js +2 -2
- package/dist/lexical-editor.d.ts +1 -1
- package/package.json +5 -5
- package/src/config.ts +1 -1
- package/src/field/extensions/link/floating-link-editor.tsx +2 -2
- package/src/field/extensions/link/link-modal.tsx +2 -2
- package/src/field/extensions/link/link-node.ts +2 -2
- package/src/lexical-editor.tsx +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* `EditorField` / `Nodes` or the heavy *content* extension classes
|
|
16
16
|
* (Table, InlineImage, Admonition, …), all of which statically pull React
|
|
17
17
|
* plugins, nodes, and the Lexical core. Import from here at registration
|
|
18
|
-
* sites (e.g. an admin/
|
|
18
|
+
* sites (e.g. an admin/admin config that you want to evaluate eagerly)
|
|
19
19
|
* so referencing the editor doesn't drag the editor module graph into the
|
|
20
20
|
* importing bundle.
|
|
21
21
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { getAdminConfig } from "@byline/core";
|
|
5
5
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
6
6
|
import { $findMatchingParent, mergeRegister } from "@lexical/utils";
|
|
7
7
|
import { $getSelection, $isLineBreakNode, $isRangeSelection, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, KEY_ESCAPE_COMMAND, SELECTION_CHANGE_COMMAND } from "lexical";
|
|
@@ -20,7 +20,7 @@ function FloatingLinkEditor({ editor, isLink, setIsLink, anchorElem }) {
|
|
|
20
20
|
});
|
|
21
21
|
const [linkModalData, setLinkModalData] = useState(void 0);
|
|
22
22
|
const [modalOpen, setModalOpen] = useState(false);
|
|
23
|
-
const adminRoute =
|
|
23
|
+
const adminRoute = getAdminConfig().routes.admin;
|
|
24
24
|
const $updateLinkEditor = useCallback(()=>{
|
|
25
25
|
const selection = $getSelection();
|
|
26
26
|
if ($isRangeSelection(selection)) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo, useState } from "react";
|
|
4
4
|
import { RelationPicker } from "@byline/admin/react";
|
|
5
|
-
import {
|
|
5
|
+
import { getAdminConfig, getCollectionDefinition } from "@byline/core";
|
|
6
6
|
import { Button, Checkbox, CloseIcon, IconButton, Input, Label, Modal, RadioGroup, RadioGroupItem, Select } from "@byline/ui/react";
|
|
7
7
|
import { useModalFormState } from "../../shared/useModalFormState.js";
|
|
8
8
|
import { validateUrl } from "../../utils/url.js";
|
|
@@ -41,7 +41,7 @@ function fromLinkData(data, linkable) {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
const LinkModal = ({ isOpen = false, onSubmit, onClose, data: dataFromProps })=>{
|
|
44
|
-
const linkable = useMemo(()=>
|
|
44
|
+
const linkable = useMemo(()=>getAdminConfig().collections.filter((c)=>true === c.linksInEditor), []);
|
|
45
45
|
const [pickerOpen, setPickerOpen] = useState(false);
|
|
46
46
|
const [urlError, setUrlError] = useState(null);
|
|
47
47
|
const [state, setState] = useModalFormState(isOpen, ()=>fromLinkData(dataFromProps, linkable), ()=>setUrlError(null));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getAdminConfig } from "@byline/core";
|
|
2
2
|
import { addClassNamesToElement, isHTMLAnchorElement } from "@lexical/utils";
|
|
3
3
|
import { $applyNodeReplacement, $createTextNode, $getSelection, $isElementNode, $isRangeSelection, ElementNode, createCommand } from "lexical";
|
|
4
4
|
import { sanitizeUrl } from "../../utils/url.js";
|
|
5
5
|
function adminHref(attrs) {
|
|
6
6
|
if (null == attrs || 'internal' !== attrs.linkType) return '#';
|
|
7
7
|
const internal = attrs;
|
|
8
|
-
const { admin } =
|
|
8
|
+
const { admin } = getAdminConfig().routes;
|
|
9
9
|
return `${admin}/collections/${internal.targetCollectionPath}/${internal.targetDocumentId}`;
|
|
10
10
|
}
|
|
11
11
|
class LinkNode extends ElementNode {
|
package/dist/lexical-editor.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ type ConfigureFn = (config: LexicalEditorConfigureInput) => LexicalEditorConfigu
|
|
|
46
46
|
* ```ts
|
|
47
47
|
* import { lexicalEditor, TableExtension } from '@byline/richtext-lexical'
|
|
48
48
|
*
|
|
49
|
-
*
|
|
49
|
+
* defineAdminConfig({
|
|
50
50
|
* fields: {
|
|
51
51
|
* richText: {
|
|
52
52
|
* editor: lexicalEditor((c) => {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"private": false,
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
|
-
"version": "4.
|
|
6
|
+
"version": "4.12.0",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=20.9.0"
|
|
9
9
|
},
|
|
@@ -72,10 +72,10 @@
|
|
|
72
72
|
"clsx": "^2.1.1",
|
|
73
73
|
"lexical": "0.49.0",
|
|
74
74
|
"react-error-boundary": "^6.1.2",
|
|
75
|
-
"@byline/admin": "4.
|
|
76
|
-
"@byline/
|
|
77
|
-
"@byline/
|
|
78
|
-
"@byline/
|
|
75
|
+
"@byline/admin": "4.12.0",
|
|
76
|
+
"@byline/ui": "4.12.0",
|
|
77
|
+
"@byline/client": "4.12.0",
|
|
78
|
+
"@byline/core": "4.12.0"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"react": "^19.0.0",
|
package/src/config.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* `EditorField` / `Nodes` or the heavy *content* extension classes
|
|
17
17
|
* (Table, InlineImage, Admonition, …), all of which statically pull React
|
|
18
18
|
* plugins, nodes, and the Lexical core. Import from here at registration
|
|
19
|
-
* sites (e.g. an admin/
|
|
19
|
+
* sites (e.g. an admin/admin config that you want to evaluate eagerly)
|
|
20
20
|
* so referencing the editor doesn't drag the editor module graph into the
|
|
21
21
|
* importing bundle.
|
|
22
22
|
*
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import type * as React from 'react'
|
|
14
14
|
import { type Dispatch, useCallback, useEffect, useRef, useState } from 'react'
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { getAdminConfig } from '@byline/core'
|
|
17
17
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
|
|
18
18
|
import { $findMatchingParent, mergeRegister } from '@lexical/utils'
|
|
19
19
|
import {
|
|
@@ -70,7 +70,7 @@ function FloatingLinkEditor({
|
|
|
70
70
|
})
|
|
71
71
|
const [linkModalData, setLinkModalData] = useState<LinkData | undefined>(undefined)
|
|
72
72
|
const [modalOpen, setModalOpen] = useState(false)
|
|
73
|
-
const adminRoute =
|
|
73
|
+
const adminRoute = getAdminConfig().routes.admin
|
|
74
74
|
|
|
75
75
|
const $updateLinkEditor = useCallback(() => {
|
|
76
76
|
const selection = $getSelection()
|
|
@@ -13,7 +13,7 @@ import { useMemo, useState } from 'react'
|
|
|
13
13
|
|
|
14
14
|
import { RelationPicker } from '@byline/admin/react'
|
|
15
15
|
import type { CollectionDefinition } from '@byline/core'
|
|
16
|
-
import {
|
|
16
|
+
import { getAdminConfig, getCollectionDefinition } from '@byline/core'
|
|
17
17
|
import {
|
|
18
18
|
Button,
|
|
19
19
|
Checkbox,
|
|
@@ -102,7 +102,7 @@ export const LinkModal: React.FC<LinkModalProps> = ({
|
|
|
102
102
|
data: dataFromProps,
|
|
103
103
|
}) => {
|
|
104
104
|
const linkable = useMemo<CollectionDefinition[]>(
|
|
105
|
-
() =>
|
|
105
|
+
() => getAdminConfig().collections.filter((c) => c.linksInEditor === true),
|
|
106
106
|
[]
|
|
107
107
|
)
|
|
108
108
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { getAdminConfig } from '@byline/core'
|
|
10
10
|
import { addClassNamesToElement, isHTMLAnchorElement } from '@lexical/utils'
|
|
11
11
|
import {
|
|
12
12
|
$applyNodeReplacement,
|
|
@@ -33,7 +33,7 @@ import type { InternalLinkAttributes, LinkAttributes, SerializedLinkNode } from
|
|
|
33
33
|
function adminHref(attrs: LinkAttributes | null | undefined): string {
|
|
34
34
|
if (attrs == null || attrs.linkType !== 'internal') return '#'
|
|
35
35
|
const internal = attrs as InternalLinkAttributes
|
|
36
|
-
const { admin } =
|
|
36
|
+
const { admin } = getAdminConfig().routes
|
|
37
37
|
return `${admin}/collections/${internal.targetCollectionPath}/${internal.targetDocumentId}`
|
|
38
38
|
}
|
|
39
39
|
|
package/src/lexical-editor.tsx
CHANGED
|
@@ -97,7 +97,7 @@ function loadEditorBundle(): Promise<EditorBundle> {
|
|
|
97
97
|
* ```ts
|
|
98
98
|
* import { lexicalEditor, TableExtension } from '@byline/richtext-lexical'
|
|
99
99
|
*
|
|
100
|
-
*
|
|
100
|
+
* defineAdminConfig({
|
|
101
101
|
* fields: {
|
|
102
102
|
* richText: {
|
|
103
103
|
* editor: lexicalEditor((c) => {
|