@quadrats/react 0.7.6 → 0.7.8
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/_internal/renderer/composeRenderElementsBase.d.ts +1 -1
- package/_internal/renderer/composeRenderLeafsBase.d.ts +1 -1
- package/_internal/renderer/createRenderElementBase.d.ts +1 -1
- package/_internal/renderer/createRenderElementsBase.d.ts +1 -1
- package/_internal/renderer/createRenderMarkBase.d.ts +1 -1
- package/_internal/renderer/typings.d.ts +1 -1
- package/blockquote/defaultRenderBlockquoteElement.d.ts +2 -8
- package/blockquote/jsx-serializer/createJsxSerializeBlockquote.d.ts +1 -2
- package/blockquote/typings.d.ts +1 -1
- package/bold/jsx-serializer/createJsxSerializeBold.d.ts +1 -2
- package/components/Tooltip/index.js +3 -2
- package/components/index.cjs.js +3 -2
- package/configs/locale.d.ts +0 -1
- package/core/components/Editable.d.ts +2 -2
- package/core/composeRenderElements.d.ts +1 -1
- package/core/composeRenderLeafs.d.ts +1 -1
- package/core/createRenderElement.d.ts +1 -2
- package/core/createRenderElements.d.ts +1 -2
- package/core/createRenderMark.d.ts +1 -2
- package/core/typings/renderer.d.ts +1 -1
- package/divider/jsx-serializer/createJsxSerializeDivider.d.ts +1 -2
- package/divider/typings.d.ts +1 -1
- package/embed/createRenderEmbedElementBase.d.ts +1 -1
- package/embed/hooks/useVideoIframeSize.d.ts +1 -2
- package/embed/jsx-serializer/createJsxSerializeEmbed.d.ts +2 -2
- package/embed/jsx-serializer/facebook/index.cjs.js +7 -0
- package/embed/jsx-serializer/index.cjs.js +4 -4
- package/embed/jsx-serializer/instagram/index.cjs.js +7 -0
- package/embed/jsx-serializer/twitter/index.cjs.js +7 -0
- package/embed/jsx-serializer/vimeo/index.cjs.js +7 -0
- package/embed/jsx-serializer/youtube/index.cjs.js +7 -0
- package/embed/renderers/instagram/components/Instagram.js +19 -1
- package/embed/renderers/instagram/index.cjs.js +18 -0
- package/embed/typings.d.ts +1 -1
- package/file-uploader/typings.d.ts +1 -1
- package/footnote/defaultRenderFootnoteElement.d.ts +3 -3
- package/footnote/jsx-serializer/createJsxSerializeFootnote.d.ts +1 -2
- package/footnote/jsx-serializer/defaultRenderFootnoteElement.d.ts +3 -1
- package/footnote/jsx-serializer/defaultRenderFootnoteElement.js +4 -2
- package/footnote/jsx-serializer/index.cjs.js +4 -2
- package/footnote/typings.d.ts +1 -1
- package/heading/defaultRenderHeadingElement.d.ts +2 -8
- package/heading/jsx-serializer/createJsxSerializeHeading.d.ts +1 -2
- package/heading/typings.d.ts +1 -1
- package/highlight/jsx-serializer/createJsxSerializeHighlight.d.ts +1 -2
- package/image/createReactImage.d.ts +6 -2
- package/image/createReactImage.js +17 -1
- package/image/hooks/useImageResizer.d.ts +1 -2
- package/image/index.cjs.js +17 -1
- package/image/jsx-serializer/createJsxSerializeImage.d.ts +1 -2
- package/image/jsx-serializer/typings.d.ts +1 -1
- package/image/typings.d.ts +1 -1
- package/index.cjs.js +7 -0
- package/input-block/createReactInputBlock.js +1 -1
- package/input-block/hooks/useInputBlock.d.ts +1 -1
- package/input-block/index.cjs.js +1 -1
- package/input-block/typings.d.ts +1 -1
- package/italic/jsx-serializer/createJsxSerializeItalic.d.ts +1 -2
- package/jsx-serializer/createJsxSerializeElement.d.ts +1 -2
- package/jsx-serializer/createJsxSerializeElements.d.ts +1 -2
- package/jsx-serializer/createJsxSerializeMark.d.ts +1 -2
- package/jsx-serializer/createJsxSerializer.d.ts +1 -1
- package/line-break/createOnKeyDownBreak.js +1 -1
- package/line-break/jsx-serializer/createJsxSerializeLineBreak.d.ts +1 -2
- package/line-break/typings.d.ts +1 -1
- package/link/defaultRenderLinkElement.d.ts +3 -3
- package/link/jsx-serializer/createJsxSerializeLink.d.ts +1 -2
- package/link/toolbar/index.cjs.js +6 -1
- package/link/toolbar/useLinkTool.js +6 -1
- package/link/typings.d.ts +1 -1
- package/list/defaultRenderListElements.d.ts +1 -1
- package/list/jsx-serializer/createJsxSerializeList.d.ts +1 -2
- package/list/typings.d.ts +1 -1
- package/package.json +9 -8
- package/paragraph/createRenderParagraphElement.d.ts +2 -2
- package/paragraph/defaultRenderParagraphElement.d.ts +1 -7
- package/paragraph/jsx-serializer/createJsxSerializeParagraph.d.ts +1 -2
- package/paragraph/renderParagraphElementWithSymbol.d.ts +1 -7
- package/read-more/jsx-serializer/createJsxSerializeReadMore.d.ts +1 -2
- package/read-more/typings.d.ts +1 -1
- package/strikethrough/jsx-serializer/createJsxSerializeStrikethrough.d.ts +1 -2
- package/toggle-mark/jsx-serializer/createJsxSerializeToggleMarkCreator.d.ts +1 -2
- package/toolbar/components/Toolbar.d.ts +10 -2
- package/toolbar/components/Toolbar.js +24 -17
- package/toolbar/contexts/StartToolInputContext.d.ts +0 -1
- package/toolbar/index.cjs.js +23 -16
- package/toolbar/toolbar.css +1 -1
- package/toolbar/toolbar.scss +26 -11
- package/underline/jsx-serializer/createJsxSerializeUnderline.d.ts +1 -2
package/image/index.cjs.js
CHANGED
|
@@ -8,6 +8,7 @@ var tslib = require('tslib');
|
|
|
8
8
|
var isHotkey = require('is-hotkey');
|
|
9
9
|
var utils = require('@quadrats/utils');
|
|
10
10
|
var image = require('@quadrats/common/image');
|
|
11
|
+
var fileUploader = require('@quadrats/common/file-uploader');
|
|
11
12
|
|
|
12
13
|
function ImageFigure(props) {
|
|
13
14
|
const { attributes, children, style } = props;
|
|
@@ -144,8 +145,9 @@ const defaultRenderImageElements = {
|
|
|
144
145
|
caption: props => React.createElement(ImageCaption, Object.assign({}, props)),
|
|
145
146
|
};
|
|
146
147
|
|
|
147
|
-
function createReactImage(options = {}) {
|
|
148
|
+
function createReactImage(options = {}, getUploadOptions) {
|
|
148
149
|
const core$1 = image.createImage(options);
|
|
150
|
+
const uploadOptions = getUploadOptions === null || getUploadOptions === void 0 ? void 0 : getUploadOptions(core$1);
|
|
149
151
|
const { types } = core$1;
|
|
150
152
|
return Object.assign(Object.assign({}, core$1), { createHandlers: () => ({
|
|
151
153
|
onKeyDown(event, editor, next) {
|
|
@@ -201,6 +203,7 @@ function createReactImage(options = {}) {
|
|
|
201
203
|
}, with(editor) {
|
|
202
204
|
const { insertData } = editor;
|
|
203
205
|
editor.insertData = (data) => {
|
|
206
|
+
var _a;
|
|
204
207
|
const text = data.getData('text');
|
|
205
208
|
const { files } = data;
|
|
206
209
|
/**
|
|
@@ -216,6 +219,19 @@ function createReactImage(options = {}) {
|
|
|
216
219
|
* Insert each image which is image.
|
|
217
220
|
*/
|
|
218
221
|
if (files.length) {
|
|
222
|
+
/**
|
|
223
|
+
* Insert each image when upload options are set.
|
|
224
|
+
*/
|
|
225
|
+
if (uploadOptions) {
|
|
226
|
+
const createFileUploaderElement = fileUploader.createFileUploaderElementByType((_a = uploadOptions.type) !== null && _a !== void 0 ? _a : fileUploader.FILE_UPLOADER_TYPE);
|
|
227
|
+
Array.from(files).reduce((prev, file) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
228
|
+
yield prev;
|
|
229
|
+
return createFileUploaderElement(editor, file, uploadOptions).then((fileUploaderElement) => {
|
|
230
|
+
fileUploader.insertFileUploaderElement(editor, fileUploaderElement);
|
|
231
|
+
});
|
|
232
|
+
}), Promise.resolve());
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
219
235
|
[...files]
|
|
220
236
|
.filter((file) => {
|
|
221
237
|
const [mime] = file.type.split('/');
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { ImageCaptionTypeKey, ImageFigureTypeKey, ImageHostingResolvers, ImageTypeKey } from '@quadrats/common/image';
|
|
3
2
|
import { CreateJsxSerializeElementOptions } from '@quadrats/react/jsx-serializer';
|
|
4
3
|
import { JsxSerializeImageCaptionElementProps, JsxSerializeImageElementProps, JsxSerializeImageFigureElementProps } from './typings';
|
|
5
4
|
export type CreateJsxSerializeImageOptions<H extends string> = Partial<Record<ImageFigureTypeKey, Partial<CreateJsxSerializeElementOptions<JsxSerializeImageFigureElementProps>>> & Record<ImageTypeKey, Partial<CreateJsxSerializeElementOptions<JsxSerializeImageElementProps>>> & Record<ImageCaptionTypeKey, Partial<CreateJsxSerializeElementOptions<JsxSerializeImageCaptionElementProps>>> & {
|
|
6
5
|
hostingResolvers?: ImageHostingResolvers<H>;
|
|
7
6
|
}>;
|
|
8
|
-
export declare function createJsxSerializeImage<H extends string>(options?: CreateJsxSerializeImageOptions<H>): (props: import("@quadrats/react/jsx-serializer").JsxSerializeElementProps) => JSX.Element | null | undefined;
|
|
7
|
+
export declare function createJsxSerializeImage<H extends string>(options?: CreateJsxSerializeImageOptions<H>): (props: import("@quadrats/react/jsx-serializer").JsxSerializeElementProps) => import("react").JSX.Element | null | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { JSX } from 'react';
|
|
2
2
|
import { ImageCaptionElement, ImageCaptionTypeKey, ImageElement, ImageFigureElement, ImageFigureTypeKey, ImageTypeKey } from '@quadrats/common/image';
|
|
3
3
|
import { JsxSerializeElementProps } from '@quadrats/react/jsx-serializer';
|
|
4
4
|
export interface JsxSerializeImageFigureElementProps extends JsxSerializeElementProps<ImageFigureElement> {
|
package/image/typings.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { JSX } from 'react';
|
|
2
2
|
import { Image, ImageCaptionElement, ImageCaptionTypeKey, ImageElement, ImageFigureElement, ImageFigureTypeKey, ImageTypeKey } from '@quadrats/common/image';
|
|
3
3
|
import { WithCreateHandlers, WithCreateRenderElement, RenderElementProps, ReactWithable, Editor } from '@quadrats/react';
|
|
4
4
|
export interface RenderImageFigureElementProps extends RenderElementProps<ImageFigureElement> {
|
package/index.cjs.js
CHANGED
|
@@ -146,6 +146,13 @@ exports.createReactEditor = createReactEditor;
|
|
|
146
146
|
exports.createRenderElement = createRenderElement;
|
|
147
147
|
exports.createRenderElements = createRenderElements;
|
|
148
148
|
exports.createRenderMark = createRenderMark;
|
|
149
|
+
Object.prototype.hasOwnProperty.call(configs, '__proto__') &&
|
|
150
|
+
!Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
|
|
151
|
+
Object.defineProperty(exports, '__proto__', {
|
|
152
|
+
enumerable: true,
|
|
153
|
+
value: configs['__proto__']
|
|
154
|
+
});
|
|
155
|
+
|
|
149
156
|
Object.keys(configs).forEach(function (k) {
|
|
150
157
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = configs[k];
|
|
151
158
|
});
|
|
@@ -10,7 +10,7 @@ function createReactInputBlock(options = {}) {
|
|
|
10
10
|
return Object.assign(Object.assign({}, core), { remove,
|
|
11
11
|
confirm, createRenderElement: ({ render = defaultRenderInputBlockElement, } = {}) => createRenderElement({
|
|
12
12
|
type,
|
|
13
|
-
render:
|
|
13
|
+
render: props => render(Object.assign(Object.assign({}, props), { remove, confirm })),
|
|
14
14
|
}) });
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { KeyboardEvent } from 'react';
|
|
2
2
|
import { RenderInputBlockElementProps } from '../typings';
|
|
3
3
|
export declare function useInputBlock({ confirm, element, remove }: RenderInputBlockElementProps): {
|
|
4
|
-
inputRef: import("react").RefObject<HTMLInputElement>;
|
|
4
|
+
inputRef: import("react").RefObject<HTMLInputElement | null>;
|
|
5
5
|
onBlur: () => void;
|
|
6
6
|
onKeyDown: (event: KeyboardEvent) => void;
|
|
7
7
|
placeholder: string;
|
package/input-block/index.cjs.js
CHANGED
|
@@ -80,7 +80,7 @@ function createReactInputBlock(options = {}) {
|
|
|
80
80
|
return Object.assign(Object.assign({}, core), { remove,
|
|
81
81
|
confirm, createRenderElement: ({ render = defaultRenderInputBlockElement, } = {}) => react.createRenderElement({
|
|
82
82
|
type,
|
|
83
|
-
render:
|
|
83
|
+
render: props => render(Object.assign(Object.assign({}, props), { remove, confirm })),
|
|
84
84
|
}) });
|
|
85
85
|
}
|
|
86
86
|
|
package/input-block/typings.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { JSX } from 'react';
|
|
2
2
|
import { InputBlock, InputBlockElement } from '@quadrats/common/input-block';
|
|
3
3
|
import { Editor, RenderElementProps, WithCreateRenderElement } from '@quadrats/react';
|
|
4
4
|
export type RenderInputBlockElementProps = RenderElementProps<InputBlockElement> & Pick<ReactInputBlock, 'remove' | 'confirm'>;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const createJsxSerializeItalic: (options?: Partial<import("@quadrats/react/toggle-mark/jsx-serializer").CreateJsxSerializeToggleMarkCreatorOptions> | undefined) => (props: Omit<import("@quadrats/react/jsx-serializer").JsxSerializeMarkProps<boolean>, "mark">) => JSX.Element;
|
|
1
|
+
export declare const createJsxSerializeItalic: (options?: import("@quadrats/react/toggle-mark/jsx-serializer").CreateJsxSerializeToggleMarkOptions) => (props: Omit<import("@quadrats/react/jsx-serializer").JsxSerializeMarkProps<boolean>, "mark">) => import("react").JSX.Element;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { CreateJsxSerializeElementOptions, JsxSerializeElementProps } from './typings';
|
|
3
|
-
export declare function createJsxSerializeElement<P extends JsxSerializeElementProps>(options: CreateJsxSerializeElementOptions<P>): (props: JsxSerializeElementProps) => JSX.Element | null | undefined;
|
|
2
|
+
export declare function createJsxSerializeElement<P extends JsxSerializeElementProps>(options: CreateJsxSerializeElementOptions<P>): (props: JsxSerializeElementProps) => import("react").JSX.Element | null | undefined;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { CreateJsxSerializeElementOptions, JsxSerializeElementProps } from './typings';
|
|
3
|
-
export declare function createJsxSerializeElements<P extends JsxSerializeElementProps>(options: CreateJsxSerializeElementOptions<P>[]): (props: JsxSerializeElementProps) => JSX.Element | null | undefined;
|
|
2
|
+
export declare function createJsxSerializeElements<P extends JsxSerializeElementProps>(options: CreateJsxSerializeElementOptions<P>[]): (props: JsxSerializeElementProps) => import("react").JSX.Element | null | undefined;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { CreateJsxSerializeMarkOptions } from './typings';
|
|
3
|
-
export declare function createJsxSerializeMark<M>(options: CreateJsxSerializeMarkOptions<M>): (props: Omit<import("./typings").JsxSerializeMarkProps<M>, "mark">) => JSX.Element;
|
|
2
|
+
export declare function createJsxSerializeMark<M>(options: CreateJsxSerializeMarkOptions<M>): (props: Omit<import("./typings").JsxSerializeMarkProps<M>, "mark">) => import("react").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __rest } from 'tslib';
|
|
2
2
|
import isHotkey from 'is-hotkey';
|
|
3
|
-
import { getAboveBlock, isNodeMatch, isSelectionAtBlockEdge, Path, Transforms
|
|
3
|
+
import { getAboveBlock, PARAGRAPH_TYPE, isNodeMatch, isSelectionAtBlockEdge, Path, Transforms } from '@quadrats/core';
|
|
4
4
|
|
|
5
5
|
function createOnKeyDownBreak({ exitBreak, softBreak }) {
|
|
6
6
|
return (event, editor, next) => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { CreateJsxSerializeElementOptions } from '@quadrats/react/jsx-serializer';
|
|
3
2
|
import { JsxSerializeLineBreakElementProps } from './typings';
|
|
4
3
|
export type CreateJsxSerializeLineBreakOptions = Partial<CreateJsxSerializeElementOptions<JsxSerializeLineBreakElementProps>>;
|
|
5
|
-
export declare function createJsxSerializeLineBreak(options?: CreateJsxSerializeLineBreakOptions): (props: import("@quadrats/react/jsx-serializer").JsxSerializeElementProps) => JSX.Element | null | undefined;
|
|
4
|
+
export declare function createJsxSerializeLineBreak(options?: CreateJsxSerializeLineBreakOptions): (props: import("@quadrats/react/jsx-serializer").JsxSerializeElementProps) => import("react").JSX.Element | null | undefined;
|
package/line-break/typings.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { JSX } from 'react';
|
|
2
2
|
import { IsNodeMatchOptions, LineBreak, LineBreakElement } from '@quadrats/core';
|
|
3
3
|
import { WithCreateRenderElement, RenderElementProps, WithCreateHandlers } from '@quadrats/react';
|
|
4
4
|
export interface ExitBreakRule {
|
|
@@ -3,7 +3,7 @@ import { RenderLinkElementProps } from './typings';
|
|
|
3
3
|
/**
|
|
4
4
|
* Set placement of tooltip to `bottom` to avoid conflicting w/ toolbar.
|
|
5
5
|
*/
|
|
6
|
-
export declare const defaultRenderLinkElement: ({ attributes, children, element, placement, target, }:
|
|
7
|
-
placement?: "top" | "bottom"
|
|
8
|
-
target?: string
|
|
6
|
+
export declare const defaultRenderLinkElement: ({ attributes, children, element, placement, target, }: RenderLinkElementProps & {
|
|
7
|
+
placement?: "top" | "bottom";
|
|
8
|
+
target?: string;
|
|
9
9
|
}) => React.JSX.Element;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { CreateJsxSerializeElementOptions } from '@quadrats/react/jsx-serializer';
|
|
3
2
|
import { JsxSerializeLinkElementProps } from './typings';
|
|
4
3
|
export type CreateJsxSerializeLinkOptions = Partial<CreateJsxSerializeElementOptions<JsxSerializeLinkElementProps>>;
|
|
5
|
-
export declare function createJsxSerializeLink(options?: CreateJsxSerializeLinkOptions): (props: import("@quadrats/react/jsx-serializer").JsxSerializeElementProps) => JSX.Element | null | undefined;
|
|
4
|
+
export declare function createJsxSerializeLink(options?: CreateJsxSerializeLinkOptions): (props: import("@quadrats/react/jsx-serializer").JsxSerializeElementProps) => import("react").JSX.Element | null | undefined;
|
|
@@ -11,8 +11,13 @@ function useLinkTool(controller, options = {}) {
|
|
|
11
11
|
return {
|
|
12
12
|
active: controller.isSelectionInLink(editor),
|
|
13
13
|
onClick: () => startToolInput({
|
|
14
|
-
getPlaceholder:
|
|
14
|
+
getPlaceholder: locale => locale.editor.link.inputPlaceholder,
|
|
15
15
|
confirm: (url) => {
|
|
16
|
+
const urlValidation = /^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$/;
|
|
17
|
+
if (!urlValidation.test(url)) {
|
|
18
|
+
window.alert('請輸入正確的網址格式');
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
16
21
|
if (controller.isUrl(url)) {
|
|
17
22
|
controller.upsertLink(editor, url, options);
|
|
18
23
|
}
|
|
@@ -7,8 +7,13 @@ function useLinkTool(controller, options = {}) {
|
|
|
7
7
|
return {
|
|
8
8
|
active: controller.isSelectionInLink(editor),
|
|
9
9
|
onClick: () => startToolInput({
|
|
10
|
-
getPlaceholder:
|
|
10
|
+
getPlaceholder: locale => locale.editor.link.inputPlaceholder,
|
|
11
11
|
confirm: (url) => {
|
|
12
|
+
const urlValidation = /^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$/;
|
|
13
|
+
if (!urlValidation.test(url)) {
|
|
14
|
+
window.alert('請輸入正確的網址格式');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
12
17
|
if (controller.isUrl(url)) {
|
|
13
18
|
controller.upsertLink(editor, url, options);
|
|
14
19
|
}
|
package/link/typings.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { JSX } from 'react';
|
|
2
2
|
import { Link, LinkElement } from '@quadrats/common/link';
|
|
3
3
|
import { RenderElementProps, ReactWithable, WithCreateRenderElement, Editor } from '@quadrats/react';
|
|
4
4
|
export type RenderLinkElementProps = RenderElementProps<LinkElement>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { ListTypeKey } from '@quadrats/common/list';
|
|
3
2
|
import { CreateJsxSerializeElementOptions } from '@quadrats/react/jsx-serializer';
|
|
4
3
|
import { JsxSerializeListElementProps } from './typings';
|
|
5
4
|
export type CreateJsxSerializeListOptions = {
|
|
6
5
|
[key in ListTypeKey]?: CreateJsxSerializeElementOptions<JsxSerializeListElementProps>;
|
|
7
6
|
};
|
|
8
|
-
export declare function createJsxSerializeList(options?: CreateJsxSerializeListOptions): (props: import("@quadrats/react/jsx-serializer").JsxSerializeElementProps) => JSX.Element | null | undefined;
|
|
7
|
+
export declare function createJsxSerializeList(options?: CreateJsxSerializeListOptions): (props: import("@quadrats/react/jsx-serializer").JsxSerializeElementProps) => import("react").JSX.Element | null | undefined;
|
package/list/typings.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { JSX } from 'react';
|
|
2
2
|
import { List, ListElement, ListTypeKey } from '@quadrats/common/list';
|
|
3
3
|
import { WithCreateHandlers, WithCreateRenderElement, RenderElementProps, Editor } from '@quadrats/react';
|
|
4
4
|
export type RenderListElementProps = RenderElementProps<ListElement>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quadrats/react",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Rytass",
|
|
6
6
|
"homepage": "https://github.com/Quadrats/quadrats#readme",
|
|
@@ -20,23 +20,24 @@
|
|
|
20
20
|
"url": "https://github.com/Quadrats/quadrats/issues"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@quadrats/common": "^0.7.
|
|
24
|
-
"@quadrats/core": "^0.7.
|
|
23
|
+
"@quadrats/common": "^0.7.7",
|
|
24
|
+
"@quadrats/core": "^0.7.7",
|
|
25
25
|
"@quadrats/icons": "^0.7.0",
|
|
26
|
-
"@quadrats/locales": "^0.7.
|
|
26
|
+
"@quadrats/locales": "^0.7.7",
|
|
27
27
|
"@quadrats/theme": "^0.7.4",
|
|
28
28
|
"@quadrats/utils": "^0.7.2",
|
|
29
29
|
"@types/is-hotkey": "^0.1.9",
|
|
30
30
|
"@types/react-transition-group": "^4.4.9",
|
|
31
|
-
"clsx": "^2.
|
|
31
|
+
"clsx": "^2.1.1",
|
|
32
32
|
"is-hotkey": "^0.2.0",
|
|
33
33
|
"react-transition-group": "^4.4.5",
|
|
34
|
-
"slate-
|
|
34
|
+
"slate-dom": "^0.112.2",
|
|
35
|
+
"slate-react": "^0.112.1",
|
|
35
36
|
"tslib": "^2.6.2"
|
|
36
37
|
},
|
|
37
38
|
"peerDependencies": {
|
|
38
|
-
"react": "^
|
|
39
|
-
"react-dom": "^
|
|
39
|
+
"react": "^19.1.0",
|
|
40
|
+
"react-dom": "^19.1.0"
|
|
40
41
|
},
|
|
41
42
|
"main": "./index.cjs.js",
|
|
42
43
|
"module": "./index.js",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { JSX } from 'react';
|
|
2
2
|
import { ParagraphElement } from '@quadrats/core';
|
|
3
3
|
import { RenderElementProps } from '@quadrats/react';
|
|
4
4
|
export type RenderParagraphElementProps = RenderElementProps<ParagraphElement>;
|
|
5
5
|
export interface CreateRenderParagraphElementOptions {
|
|
6
6
|
render?: (props: RenderParagraphElementProps) => JSX.Element | null | undefined;
|
|
7
7
|
}
|
|
8
|
-
export declare function createRenderParagraphElement(options?: CreateRenderParagraphElementOptions): (props: RenderElementProps) => JSX.Element | null | undefined;
|
|
8
|
+
export declare function createRenderParagraphElement(options?: CreateRenderParagraphElementOptions): (props: RenderElementProps) => import("react").JSX.Element | null | undefined;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { RenderElementProps } from '@quadrats/react';
|
|
3
3
|
export declare const defaultRenderParagraphElement: ({ attributes, children, }: {
|
|
4
|
-
attributes?:
|
|
5
|
-
'data-slate-node': "element";
|
|
6
|
-
'data-slate-inline'?: true | undefined;
|
|
7
|
-
'data-slate-void'?: true | undefined;
|
|
8
|
-
dir?: "rtl" | undefined;
|
|
9
|
-
ref: any;
|
|
10
|
-
} | undefined;
|
|
4
|
+
attributes?: RenderElementProps["attributes"];
|
|
11
5
|
children: any;
|
|
12
6
|
}) => React.JSX.Element;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { CreateJsxSerializeElementOptions } from '@quadrats/react/jsx-serializer';
|
|
3
2
|
import { JsxSerializeParagraphProps } from './typings';
|
|
4
3
|
export type CreateJsxSerializeParagraphOptions = Partial<Omit<CreateJsxSerializeElementOptions<JsxSerializeParagraphProps>, 'type'>>;
|
|
5
|
-
export declare function createJsxSerializeParagraph(options?: CreateJsxSerializeParagraphOptions): (props: import("@quadrats/react/jsx-serializer").JsxSerializeElementProps) => JSX.Element | null | undefined;
|
|
4
|
+
export declare function createJsxSerializeParagraph(options?: CreateJsxSerializeParagraphOptions): (props: import("@quadrats/react/jsx-serializer").JsxSerializeElementProps) => import("react").JSX.Element | null | undefined;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { RenderElementProps } from '@quadrats/react';
|
|
3
3
|
export declare const renderParagraphElementWithSymbol: ({ attributes, children, }: {
|
|
4
|
-
attributes?:
|
|
5
|
-
'data-slate-node': "element";
|
|
6
|
-
'data-slate-inline'?: true | undefined;
|
|
7
|
-
'data-slate-void'?: true | undefined;
|
|
8
|
-
dir?: "rtl" | undefined;
|
|
9
|
-
ref: any;
|
|
10
|
-
} | undefined;
|
|
4
|
+
attributes?: RenderElementProps["attributes"];
|
|
11
5
|
children: any;
|
|
12
6
|
}) => React.JSX.Element;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { CreateJsxSerializeElementOptions } from '@quadrats/react/jsx-serializer';
|
|
3
2
|
import { JsxSerializeReadMoreProps } from './typings';
|
|
4
3
|
export type CreateJsxSerializeReadMoreOptions = Partial<CreateJsxSerializeElementOptions<JsxSerializeReadMoreProps>>;
|
|
5
|
-
export declare function createJsxSerializeReadMore(options?: CreateJsxSerializeReadMoreOptions): (props: import("@quadrats/react/jsx-serializer").JsxSerializeElementProps) => JSX.Element | null | undefined;
|
|
4
|
+
export declare function createJsxSerializeReadMore(options?: CreateJsxSerializeReadMoreOptions): (props: import("@quadrats/react/jsx-serializer").JsxSerializeElementProps) => import("react").JSX.Element | null | undefined;
|
package/read-more/typings.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { JSX } from 'react';
|
|
2
2
|
import { ReadMore, ReadMoreElement } from '@quadrats/common/read-more';
|
|
3
3
|
import { WithCreateRenderElement, RenderElementProps, Editor } from '@quadrats/react';
|
|
4
4
|
export type RenderReadMoreElementProps = RenderElementProps<ReadMoreElement>;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const createJsxSerializeStrikethrough: (options?: Partial<import("@quadrats/react/toggle-mark/jsx-serializer").CreateJsxSerializeToggleMarkCreatorOptions> | undefined) => (props: Omit<import("@quadrats/react/jsx-serializer").JsxSerializeMarkProps<boolean>, "mark">) => JSX.Element;
|
|
1
|
+
export declare const createJsxSerializeStrikethrough: (options?: import("@quadrats/react/toggle-mark/jsx-serializer").CreateJsxSerializeToggleMarkOptions) => (props: Omit<import("@quadrats/react/jsx-serializer").JsxSerializeMarkProps<boolean>, "mark">) => import("react").JSX.Element;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { CreateJsxSerializeMarkOptions } from '@quadrats/react/jsx-serializer';
|
|
3
2
|
export type CreateJsxSerializeToggleMarkCreatorOptions = CreateJsxSerializeMarkOptions<boolean>;
|
|
4
3
|
export type CreateJsxSerializeToggleMarkOptions = Partial<CreateJsxSerializeToggleMarkCreatorOptions>;
|
|
5
|
-
export declare function createJsxSerializeToggleMarkCreator(defaults: CreateJsxSerializeToggleMarkCreatorOptions): (options?: CreateJsxSerializeToggleMarkOptions) => (props: Omit<import("@quadrats/react/jsx-serializer").JsxSerializeMarkProps<boolean>, "mark">) => JSX.Element;
|
|
4
|
+
export declare function createJsxSerializeToggleMarkCreator(defaults: CreateJsxSerializeToggleMarkCreatorOptions): (options?: CreateJsxSerializeToggleMarkOptions) => (props: Omit<import("@quadrats/react/jsx-serializer").JsxSerializeMarkProps<boolean>, "mark">) => import("react").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { JSX } from 'react';
|
|
2
2
|
export interface ToolbarProps {
|
|
3
3
|
/**
|
|
4
4
|
* If there are any nodes which type match it, toolbar will hide.
|
|
@@ -12,6 +12,14 @@ export interface ToolbarProps {
|
|
|
12
12
|
* Toolbar container
|
|
13
13
|
*/
|
|
14
14
|
containerRef?: React.MutableRefObject<HTMLElement | undefined>;
|
|
15
|
+
/**
|
|
16
|
+
* only render expanded case toolbar or not.
|
|
17
|
+
*/
|
|
18
|
+
onlyRenderExpanded?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* fix main toolbar or not.
|
|
21
|
+
*/
|
|
22
|
+
fixed?: boolean;
|
|
15
23
|
}
|
|
16
|
-
declare function Toolbar(props: ToolbarProps):
|
|
24
|
+
declare function Toolbar(props: ToolbarProps): JSX.Element | null;
|
|
17
25
|
export default Toolbar;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useContext, useRef, useState, useCallback, useLayoutEffect } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import { Range, getSelectionText,
|
|
3
|
+
import { Range, getSelectionText, Transforms, isNodesTypeIn } from '@quadrats/core';
|
|
4
4
|
import { ThemeContext, useQuadrats, ReactEditor } from '@quadrats/react';
|
|
5
5
|
import { Portal } from '@quadrats/react/components';
|
|
6
6
|
import { StartToolInputContext } from '../contexts/StartToolInputContext.js';
|
|
@@ -27,11 +27,11 @@ function setPosition(el, range) {
|
|
|
27
27
|
el.style.left = `${left}px`;
|
|
28
28
|
}
|
|
29
29
|
function Toolbar(props) {
|
|
30
|
-
const { children, disabledElementTypes } = props;
|
|
30
|
+
const { children, disabledElementTypes, onlyRenderExpanded = false, fixed = false } = props;
|
|
31
31
|
const { props: themeProps } = useContext(ThemeContext);
|
|
32
32
|
const editor = useQuadrats();
|
|
33
33
|
const toolbarRef = useRef(null);
|
|
34
|
-
const lastNativeRangeRef = useRef();
|
|
34
|
+
const lastNativeRangeRef = useRef(undefined);
|
|
35
35
|
const focused = ReactEditor.isFocused(editor);
|
|
36
36
|
const { selection } = editor;
|
|
37
37
|
const [toolInput, setToolInput] = useState();
|
|
@@ -87,27 +87,34 @@ function Toolbar(props) {
|
|
|
87
87
|
}
|
|
88
88
|
return document.body;
|
|
89
89
|
}, [props.containerRef]);
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
91
|
+
const tools = children(renderExpandedStatus && !fixed);
|
|
92
|
+
const toolbarBody = (React.createElement(React.Fragment, null,
|
|
93
|
+
React.createElement(StartToolInputContext.Provider, { value: startToolInput }, tools),
|
|
94
|
+
toolInput && (React.createElement(ToolbarInput, { exit: () => {
|
|
95
|
+
const { currentSelection } = toolInput;
|
|
96
|
+
if (currentSelection) {
|
|
97
|
+
Transforms.select(editor, currentSelection);
|
|
98
|
+
}
|
|
99
|
+
ReactEditor.focus(editor);
|
|
100
|
+
setToolInput(undefined);
|
|
101
|
+
}, toolInput: toolInput }))));
|
|
102
|
+
if (fixed) {
|
|
103
|
+
return (React.createElement("div", { className: clsx('qdr-toolbar__wrapper', 'qdr-toolbar__wrapper--fixed', { 'qdr-toolbar__wrapper--inputting': toolInput }, themeProps.className), style: themeProps.style },
|
|
104
|
+
React.createElement("div", { className: "qdr-toolbar" }, toolbarBody)));
|
|
105
|
+
}
|
|
90
106
|
if (!shouldRender || (disabledElementTypes && isNodesTypeIn(editor, disabledElementTypes, { mode: 'all' }))) {
|
|
91
107
|
return null;
|
|
92
108
|
}
|
|
93
|
-
|
|
94
|
-
|
|
109
|
+
if (onlyRenderExpanded && !renderExpandedStatus) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
95
112
|
if (!tools) {
|
|
96
113
|
return null;
|
|
97
114
|
}
|
|
98
115
|
return (React.createElement(Portal, { getContainer: getPortalContainer },
|
|
99
|
-
React.createElement("div", { ref: toolbarRef, className: clsx('qdr-toolbar__wrapper', { 'qdr-toolbar__wrapper--inputting': toolInput }, themeProps.className), style: themeProps.style },
|
|
100
|
-
React.createElement("div", { className: "qdr-
|
|
101
|
-
React.createElement("div", { className: "qdr-toolbar" },
|
|
102
|
-
React.createElement(StartToolInputContext.Provider, { value: startToolInput }, tools),
|
|
103
|
-
toolInput && (React.createElement(ToolbarInput, { exit: () => {
|
|
104
|
-
const { currentSelection } = toolInput;
|
|
105
|
-
if (currentSelection) {
|
|
106
|
-
Transforms.select(editor, currentSelection);
|
|
107
|
-
}
|
|
108
|
-
ReactEditor.focus(editor);
|
|
109
|
-
setToolInput(undefined);
|
|
110
|
-
}, toolInput: toolInput }))))));
|
|
116
|
+
React.createElement("div", { ref: toolbarRef, className: clsx('qdr-toolbar__wrapper', 'qdr-toolbar__wrapper--float', { 'qdr-toolbar__wrapper--inputting': toolInput }, themeProps.className), style: themeProps.style },
|
|
117
|
+
React.createElement("div", { className: "qdr-toolbar qdr-toolbar--radius qdr-toolbar--shadow" }, toolbarBody))));
|
|
111
118
|
}
|
|
112
119
|
|
|
113
120
|
export { Toolbar as default };
|
package/toolbar/index.cjs.js
CHANGED
|
@@ -69,11 +69,11 @@ function setPosition(el, range) {
|
|
|
69
69
|
el.style.left = `${left}px`;
|
|
70
70
|
}
|
|
71
71
|
function Toolbar(props) {
|
|
72
|
-
const { children, disabledElementTypes } = props;
|
|
72
|
+
const { children, disabledElementTypes, onlyRenderExpanded = false, fixed = false } = props;
|
|
73
73
|
const { props: themeProps } = React.useContext(react.ThemeContext);
|
|
74
74
|
const editor = react.useQuadrats();
|
|
75
75
|
const toolbarRef = React.useRef(null);
|
|
76
|
-
const lastNativeRangeRef = React.useRef();
|
|
76
|
+
const lastNativeRangeRef = React.useRef(undefined);
|
|
77
77
|
const focused = react.ReactEditor.isFocused(editor);
|
|
78
78
|
const { selection } = editor;
|
|
79
79
|
const [toolInput, setToolInput] = React.useState();
|
|
@@ -129,27 +129,34 @@ function Toolbar(props) {
|
|
|
129
129
|
}
|
|
130
130
|
return document.body;
|
|
131
131
|
}, [props.containerRef]);
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
133
|
+
const tools = children(renderExpandedStatus && !fixed);
|
|
134
|
+
const toolbarBody = (React.createElement(React.Fragment, null,
|
|
135
|
+
React.createElement(StartToolInputContext.Provider, { value: startToolInput }, tools),
|
|
136
|
+
toolInput && (React.createElement(ToolbarInput, { exit: () => {
|
|
137
|
+
const { currentSelection } = toolInput;
|
|
138
|
+
if (currentSelection) {
|
|
139
|
+
core.Transforms.select(editor, currentSelection);
|
|
140
|
+
}
|
|
141
|
+
react.ReactEditor.focus(editor);
|
|
142
|
+
setToolInput(undefined);
|
|
143
|
+
}, toolInput: toolInput }))));
|
|
144
|
+
if (fixed) {
|
|
145
|
+
return (React.createElement("div", { className: clsx('qdr-toolbar__wrapper', 'qdr-toolbar__wrapper--fixed', { 'qdr-toolbar__wrapper--inputting': toolInput }, themeProps.className), style: themeProps.style },
|
|
146
|
+
React.createElement("div", { className: "qdr-toolbar" }, toolbarBody)));
|
|
147
|
+
}
|
|
132
148
|
if (!shouldRender || (disabledElementTypes && core.isNodesTypeIn(editor, disabledElementTypes, { mode: 'all' }))) {
|
|
133
149
|
return null;
|
|
134
150
|
}
|
|
135
|
-
|
|
136
|
-
|
|
151
|
+
if (onlyRenderExpanded && !renderExpandedStatus) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
137
154
|
if (!tools) {
|
|
138
155
|
return null;
|
|
139
156
|
}
|
|
140
157
|
return (React.createElement(components.Portal, { getContainer: getPortalContainer },
|
|
141
|
-
React.createElement("div", { ref: toolbarRef, className: clsx('qdr-toolbar__wrapper', { 'qdr-toolbar__wrapper--inputting': toolInput }, themeProps.className), style: themeProps.style },
|
|
142
|
-
React.createElement("div", { className: "qdr-
|
|
143
|
-
React.createElement("div", { className: "qdr-toolbar" },
|
|
144
|
-
React.createElement(StartToolInputContext.Provider, { value: startToolInput }, tools),
|
|
145
|
-
toolInput && (React.createElement(ToolbarInput, { exit: () => {
|
|
146
|
-
const { currentSelection } = toolInput;
|
|
147
|
-
if (currentSelection) {
|
|
148
|
-
core.Transforms.select(editor, currentSelection);
|
|
149
|
-
}
|
|
150
|
-
react.ReactEditor.focus(editor);
|
|
151
|
-
setToolInput(undefined);
|
|
152
|
-
}, toolInput: toolInput }))))));
|
|
158
|
+
React.createElement("div", { ref: toolbarRef, className: clsx('qdr-toolbar__wrapper', 'qdr-toolbar__wrapper--float', { 'qdr-toolbar__wrapper--inputting': toolInput }, themeProps.className), style: themeProps.style },
|
|
159
|
+
React.createElement("div", { className: "qdr-toolbar qdr-toolbar--radius qdr-toolbar--shadow" }, toolbarBody))));
|
|
153
160
|
}
|
|
154
161
|
|
|
155
162
|
function ToolbarIcon(props) {
|
package/toolbar/toolbar.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.qdr-toolbar{display:flex;align-items:center;font-size:24px;height:
|
|
1
|
+
.qdr-toolbar{display:flex;align-items:center;gap:8px;font-size:24px;height:48px;padding:8px 8px;background-color:var(--qdr-surface);border:1px solid var(--qdr-border);box-sizing:border-box}.qdr-toolbar--radius{border-radius:8px}.qdr-toolbar--shadow{box-shadow:0 4px 8px -2px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.04)}.qdr-toolbar__wrapper{box-sizing:content-box;height:48px}.qdr-toolbar__wrapper--fixed{position:sticky;top:0;z-index:1}.qdr-toolbar__wrapper--float{position:absolute;z-index:1;padding-bottom:8px}.qdr-toolbar__wrapper--inputting{min-width:250px;max-width:350px}.qdr-toolbar__arrow{position:absolute;top:calc(100% - 8px);left:50%;content:"";width:8px;height:8px;background:var(--qdr-surface);border:1px solid var(--qdr-border);border-top:none;border-left:none;transform:translateX(-50%) translateY(-50%) rotate(45deg)}.qdr-toolbar__divider{width:1px;height:20px;background-color:var(--qdr-divider)}.qdr-toolbar__icon{position:relative;color:var(--qdr-icon);font-size:24px;display:inline-flex;justify-content:center;align-items:center;border:0;background-color:rgba(0,0,0,0);padding:4px;outline:none;box-shadow:none;border-radius:0;transition:color .2s ease-out;cursor:pointer}.qdr-toolbar__icon:hover,.qdr-toolbar__icon--active{color:var(--qdr-primary)}.qdr-toolbar__input{font-size:13px;background:var(--qdr-surface);color:var(--qdr-placeholder);width:calc(100% - 14px);height:100%;border:none;padding:0;outline:none}.qdr-toolbar__input__wrapper{display:flex;align-items:center;position:absolute;top:8px;left:8px;width:calc(100% - 16px);height:calc(100% - 24px);background:var(--qdr-surface);box-sizing:border-box}.qdr-toolbar__input__cross{fill:var(--qdr-placeholder);font-size:14px;width:1em;height:1em;cursor:pointer}
|