@quadrats/react 0.7.5 → 0.7.7

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 (90) hide show
  1. package/_internal/renderer/composeRenderElementsBase.d.ts +1 -1
  2. package/_internal/renderer/composeRenderLeafsBase.d.ts +1 -1
  3. package/_internal/renderer/createRenderElementBase.d.ts +1 -1
  4. package/_internal/renderer/createRenderElementsBase.d.ts +1 -1
  5. package/_internal/renderer/createRenderMarkBase.d.ts +1 -1
  6. package/_internal/renderer/typings.d.ts +1 -1
  7. package/blockquote/defaultRenderBlockquoteElement.d.ts +2 -8
  8. package/blockquote/jsx-serializer/createJsxSerializeBlockquote.d.ts +1 -2
  9. package/blockquote/typings.d.ts +1 -1
  10. package/bold/jsx-serializer/createJsxSerializeBold.d.ts +1 -2
  11. package/components/Tooltip/index.js +3 -2
  12. package/components/index.cjs.js +3 -2
  13. package/configs/locale.d.ts +0 -1
  14. package/core/components/Editable.d.ts +2 -2
  15. package/core/composeRenderElements.d.ts +1 -1
  16. package/core/composeRenderLeafs.d.ts +1 -1
  17. package/core/createRenderElement.d.ts +1 -2
  18. package/core/createRenderElements.d.ts +1 -2
  19. package/core/createRenderMark.d.ts +1 -2
  20. package/core/typings/renderer.d.ts +1 -1
  21. package/divider/jsx-serializer/createJsxSerializeDivider.d.ts +1 -2
  22. package/divider/typings.d.ts +1 -1
  23. package/embed/createRenderEmbedElementBase.d.ts +1 -1
  24. package/embed/hooks/useVideoIframeSize.d.ts +1 -2
  25. package/embed/jsx-serializer/createJsxSerializeEmbed.d.ts +2 -2
  26. package/embed/jsx-serializer/facebook/index.cjs.js +7 -0
  27. package/embed/jsx-serializer/index.cjs.js +4 -4
  28. package/embed/jsx-serializer/instagram/index.cjs.js +7 -0
  29. package/embed/jsx-serializer/twitter/index.cjs.js +7 -0
  30. package/embed/jsx-serializer/vimeo/index.cjs.js +7 -0
  31. package/embed/jsx-serializer/youtube/index.cjs.js +7 -0
  32. package/embed/renderers/instagram/components/Instagram.js +19 -1
  33. package/embed/renderers/instagram/index.cjs.js +18 -0
  34. package/embed/typings.d.ts +1 -1
  35. package/file-uploader/typings.d.ts +1 -1
  36. package/footnote/defaultRenderFootnoteElement.d.ts +3 -3
  37. package/footnote/jsx-serializer/createJsxSerializeFootnote.d.ts +1 -2
  38. package/footnote/jsx-serializer/defaultRenderFootnoteElement.d.ts +3 -1
  39. package/footnote/jsx-serializer/defaultRenderFootnoteElement.js +4 -2
  40. package/footnote/jsx-serializer/index.cjs.js +4 -2
  41. package/footnote/typings.d.ts +1 -1
  42. package/heading/defaultRenderHeadingElement.d.ts +2 -8
  43. package/heading/jsx-serializer/createJsxSerializeHeading.d.ts +1 -2
  44. package/heading/typings.d.ts +1 -1
  45. package/highlight/jsx-serializer/createJsxSerializeHighlight.d.ts +1 -2
  46. package/image/createReactImage.d.ts +6 -2
  47. package/image/createReactImage.js +17 -1
  48. package/image/hooks/useImageResizer.d.ts +1 -2
  49. package/image/index.cjs.js +17 -1
  50. package/image/jsx-serializer/createJsxSerializeImage.d.ts +1 -2
  51. package/image/jsx-serializer/typings.d.ts +1 -1
  52. package/image/typings.d.ts +1 -1
  53. package/index.cjs.js +7 -0
  54. package/input-block/createReactInputBlock.js +1 -1
  55. package/input-block/hooks/useInputBlock.d.ts +1 -1
  56. package/input-block/index.cjs.js +1 -1
  57. package/input-block/typings.d.ts +1 -1
  58. package/italic/jsx-serializer/createJsxSerializeItalic.d.ts +1 -2
  59. package/jsx-serializer/createJsxSerializeElement.d.ts +1 -2
  60. package/jsx-serializer/createJsxSerializeElements.d.ts +1 -2
  61. package/jsx-serializer/createJsxSerializeMark.d.ts +1 -2
  62. package/jsx-serializer/createJsxSerializer.d.ts +1 -1
  63. package/line-break/createOnKeyDownBreak.js +2 -2
  64. package/line-break/index.cjs.js +1 -1
  65. package/line-break/jsx-serializer/createJsxSerializeLineBreak.d.ts +1 -2
  66. package/line-break/typings.d.ts +1 -1
  67. package/link/defaultRenderLinkElement.d.ts +3 -3
  68. package/link/jsx-serializer/createJsxSerializeLink.d.ts +1 -2
  69. package/link/toolbar/index.cjs.js +6 -1
  70. package/link/toolbar/useLinkTool.js +6 -1
  71. package/link/typings.d.ts +1 -1
  72. package/list/defaultRenderListElements.d.ts +1 -1
  73. package/list/jsx-serializer/createJsxSerializeList.d.ts +1 -2
  74. package/list/typings.d.ts +1 -1
  75. package/package.json +9 -8
  76. package/paragraph/createRenderParagraphElement.d.ts +2 -2
  77. package/paragraph/defaultRenderParagraphElement.d.ts +1 -7
  78. package/paragraph/jsx-serializer/createJsxSerializeParagraph.d.ts +1 -2
  79. package/paragraph/renderParagraphElementWithSymbol.d.ts +1 -7
  80. package/read-more/jsx-serializer/createJsxSerializeReadMore.d.ts +1 -2
  81. package/read-more/typings.d.ts +1 -1
  82. package/strikethrough/jsx-serializer/createJsxSerializeStrikethrough.d.ts +1 -2
  83. package/toggle-mark/jsx-serializer/createJsxSerializeToggleMarkCreator.d.ts +1 -2
  84. package/toolbar/components/Toolbar.d.ts +10 -2
  85. package/toolbar/components/Toolbar.js +24 -17
  86. package/toolbar/contexts/StartToolInputContext.d.ts +0 -1
  87. package/toolbar/index.cjs.js +23 -16
  88. package/toolbar/toolbar.css +1 -1
  89. package/toolbar/toolbar.scss +26 -11
  90. package/underline/jsx-serializer/createJsxSerializeUnderline.d.ts +1 -2
@@ -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
- /// <reference types="react" />
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> {
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
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: (props) => render(Object.assign(Object.assign({}, props), { remove, confirm })),
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;
@@ -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: (props) => render(Object.assign(Object.assign({}, props), { remove, confirm })),
83
+ render: props => render(Object.assign(Object.assign({}, props), { remove, confirm })),
84
84
  }) });
85
85
  }
86
86
 
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
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
- /// <reference types="react" />
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,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import { JSX } from 'react';
2
2
  import { Descendant } from '@quadrats/core';
3
3
  import { JsxSerializeElementProps, JsxSerializeLeafProps } from './typings';
4
4
  export interface CreateJsxSerializerOptioons {
@@ -1,6 +1,6 @@
1
1
  import { __rest } from 'tslib';
2
2
  import isHotkey from 'is-hotkey';
3
- import { getAboveBlock, isNodeMatch, isSelectionAtBlockEdge, Path, Transforms, insertSoftBreak, PARAGRAPH_TYPE } from '@quadrats/core';
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) => {
@@ -35,7 +35,7 @@ function createOnKeyDownBreak({ exitBreak, softBreak }) {
35
35
  for (const { hotkey, match } of rules) {
36
36
  if (isHotkey(hotkey, event) && (!match || isNodeMatch(entry, match))) {
37
37
  event.preventDefault();
38
- insertSoftBreak(editor);
38
+ editor.insertText('\n');
39
39
  return;
40
40
  }
41
41
  }
@@ -39,7 +39,7 @@ function createOnKeyDownBreak({ exitBreak, softBreak }) {
39
39
  for (const { hotkey, match } of rules) {
40
40
  if (isHotkey(hotkey, event) && (!match || core.isNodeMatch(entry, match))) {
41
41
  event.preventDefault();
42
- core.insertSoftBreak(editor);
42
+ editor.insertText('\n');
43
43
  return;
44
44
  }
45
45
  }
@@ -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;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
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, }: import("@quadrats/react/_internal").RenderElementPropsBase<import("@quadrats/common/link").LinkElement> & Pick<import("slate-react").RenderElementProps, "attributes"> & {
7
- placement?: "top" | "bottom" | undefined;
8
- target?: string | undefined;
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: (locale) => locale.editor.link.inputPlaceholder,
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: (locale) => locale.editor.link.inputPlaceholder,
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
- /// <reference types="react" />
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,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import { JSX } from 'react';
2
2
  import { ListTypeKey } from '@quadrats/common/list';
3
3
  import { RenderElementProps } from '@quadrats/react';
4
4
  export declare const defaultRenderListElements: Record<ListTypeKey, (props: {
@@ -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
- /// <reference types="react" />
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.5",
3
+ "version": "0.7.7",
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.3",
24
- "@quadrats/core": "^0.7.2",
23
+ "@quadrats/common": "^0.7.7",
24
+ "@quadrats/core": "^0.7.7",
25
25
  "@quadrats/icons": "^0.7.0",
26
- "@quadrats/locales": "^0.7.0",
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.0.0",
31
+ "clsx": "^2.1.1",
32
32
  "is-hotkey": "^0.2.0",
33
33
  "react-transition-group": "^4.4.5",
34
- "slate-react": "^0.101.0",
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": "^18.2.0",
39
- "react-dom": "^18.2.0"
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
- /// <reference types="react" />
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;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
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
- /// <reference types="react" />
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): React.JSX.Element | null;
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, isNodesTypeIn, Transforms } from '@quadrats/core';
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
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
94
- const tools = children(renderExpandedStatus);
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-toolbar__arrow" }),
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 };
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { StartToolInput } from '../typings';
3
2
  export declare const StartToolInputContext: import("react").Context<StartToolInput>;
@@ -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
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
136
- const tools = children(renderExpandedStatus);
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-toolbar__arrow" }),
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) {
@@ -1 +1 @@
1
- .qdr-toolbar{display:flex;align-items:center;font-size:24px;height:40px;padding:8px 10px;background-color:var(--qdr-surface);border:1px solid var(--qdr-border);border-radius:4px;box-sizing:border-box}.qdr-toolbar__wrapper{position:absolute;z-index:1;padding-bottom:10px;height:40px;box-sizing:content-box}.qdr-toolbar__wrapper--inputting{min-width:250px;max-width:350px}.qdr-toolbar__arrow{position:absolute;top:calc(100% - 10px);left:50%;content:"";width:10px;height:10px;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);margin:0 8px}.qdr-toolbar__icon{position:relative;color:var(--qdr-icon);font-size:24px;display:inline-flex;justify-content:center;align-items:center;margin:0 9px;border:0;background-color:rgba(0,0,0,0);padding:0;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:10px;width:calc(100% - 20px);height:calc(100% - 26px);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}
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}
@@ -1,27 +1,44 @@
1
- $qdr-toolbar-popup-gap: 10px;
1
+ $qdr-toolbar-popup-gap: 8px;
2
2
  $qdr-toolbar-arrow-size: $qdr-toolbar-popup-gap;
3
- $qdr-toolbar-height: 40px;
3
+ $qdr-toolbar-height: 48px;
4
4
  $qdr-toolbar-padding-vertical: 8px;
5
- $qdr-toolbar-padding-horizontal: 10px;
5
+ $qdr-toolbar-padding-horizontal: 8px;
6
6
  $qdr-toolbar-input-cross-size: 14px;
7
7
 
8
8
  .qdr-toolbar {
9
9
  display: flex;
10
10
  align-items: center;
11
+ gap: 8px;
11
12
  font-size: 24px;
12
13
  height: $qdr-toolbar-height;
13
14
  padding: $qdr-toolbar-padding-vertical $qdr-toolbar-padding-horizontal;
14
15
  background-color: var(--qdr-surface);
15
16
  border: 1px solid var(--qdr-border);
16
- border-radius: 4px;
17
17
  box-sizing: border-box;
18
18
 
19
+ &--radius {
20
+ border-radius: 8px;
21
+ }
22
+
23
+ &--shadow {
24
+ box-shadow: 0 4px 8px -2px rgb(0 0 0 / 10%), 0 2px 4px -2px rgb(0 0 0 / 4%);
25
+ }
26
+
19
27
  &__wrapper {
20
- position: absolute;
21
- z-index: 1;
22
- padding-bottom: $qdr-toolbar-popup-gap;
23
- height: $qdr-toolbar-height;
24
28
  box-sizing: content-box;
29
+ height: $qdr-toolbar-height;
30
+
31
+ &--fixed {
32
+ position: sticky;
33
+ top: 0;
34
+ z-index: 1;
35
+ }
36
+
37
+ &--float {
38
+ position: absolute;
39
+ z-index: 1;
40
+ padding-bottom: $qdr-toolbar-popup-gap;
41
+ }
25
42
 
26
43
  &--inputting {
27
44
  min-width: 250px;
@@ -47,7 +64,6 @@ $qdr-toolbar-input-cross-size: 14px;
47
64
  width: 1px;
48
65
  height: 20px;
49
66
  background-color: var(--qdr-divider);
50
- margin: 0 8px;
51
67
  }
52
68
 
53
69
  &__icon {
@@ -57,10 +73,9 @@ $qdr-toolbar-input-cross-size: 14px;
57
73
  display: inline-flex;
58
74
  justify-content: center;
59
75
  align-items: center;
60
- margin: 0 9px;
61
76
  border: 0;
62
77
  background-color: transparent;
63
- padding: 0;
78
+ padding: 4px;
64
79
  outline: none;
65
80
  box-shadow: none;
66
81
  border-radius: 0;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
- export declare const createJsxSerializeUnderline: (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 createJsxSerializeUnderline: (options?: import("@quadrats/react/toggle-mark/jsx-serializer").CreateJsxSerializeToggleMarkOptions) => (props: Omit<import("@quadrats/react/jsx-serializer").JsxSerializeMarkProps<boolean>, "mark">) => import("react").JSX.Element;