@quadrats/react 0.5.9 → 0.6.2
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/blockquote/createReactBlockquote.d.ts +1 -0
- package/blockquote/createReactBlockquote.js +37 -3
- package/blockquote/defaultRenderBlockquoteElement.js +1 -1
- package/blockquote/index.cjs.js +40 -6
- package/blockquote/typings.d.ts +3 -2
- package/core/composeHandlers.d.ts +2 -2
- package/core/createReactEditor.d.ts +2 -2
- package/core/index.d.ts +5 -2
- package/core/typings/handler.d.ts +2 -2
- package/core/typings/with.d.ts +2 -2
- package/divider/defaultRenderDividerElement.js +1 -1
- package/divider/index.cjs.js +1 -1
- package/divider/typings.d.ts +3 -2
- package/embed/components/VideoIframe.d.ts +1 -1
- package/embed/components/VideoIframe.js +2 -2
- package/embed/index.cjs.js +2 -2
- package/embed/renderers/facebook/components/Facebook.js +1 -1
- package/embed/renderers/facebook/index.cjs.js +1 -1
- package/embed/renderers/instagram/components/Instagram.js +1 -1
- package/embed/renderers/instagram/index.cjs.js +1 -1
- package/embed/renderers/podcast-apple/components/PodcastApple.d.ts +2 -3
- package/embed/renderers/podcast-apple/components/PodcastApple.js +1 -1
- package/embed/renderers/podcast-apple/index.cjs.js +1 -1
- package/embed/renderers/spotify/components/Spotify.js +1 -1
- package/embed/renderers/spotify/index.cjs.js +1 -1
- package/embed/renderers/twitter/components/Twitter.js +1 -1
- package/embed/renderers/twitter/index.cjs.js +1 -1
- package/embed/toolbar/EmbedToolbarIcon.d.ts +2 -2
- package/embed/toolbar/useEmbedTool.d.ts +2 -2
- package/embed/typings.d.ts +2 -2
- package/file-uploader/typings.d.ts +2 -2
- package/footnote/defaultRenderFootnoteElement.js +2 -2
- package/footnote/index.cjs.js +2 -2
- package/footnote/typings.d.ts +2 -2
- package/footnote/useFootnotes.d.ts +2 -2
- package/heading/defaultRenderHeadingElement.js +1 -1
- package/heading/index.cjs.js +1 -1
- package/heading/typings.d.ts +2 -2
- package/image/typings.d.ts +2 -2
- package/index.cjs.js +2 -1
- package/index.js +1 -0
- package/input-block/components/InputBlock.js +1 -1
- package/input-block/index.cjs.js +1 -1
- package/input-block/typings.d.ts +4 -4
- package/link/defaultRenderLinkElement.js +1 -1
- package/link/index.cjs.js +1 -1
- package/link/typings.d.ts +2 -2
- package/list/defaultRenderListElements.js +3 -3
- package/list/index.cjs.js +3 -3
- package/list/typings.d.ts +2 -2
- package/package.json +8 -8
- package/paragraph/defaultRenderParagraphElement.js +1 -1
- package/paragraph/index.cjs.js +2 -2
- package/paragraph/renderParagraphElementWithSymbol.js +1 -1
- package/read-more/typings.d.ts +2 -2
- package/toggle-mark/typings.d.ts +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CreateBlockquoteOptions } from '@quadrats/common/blockquote';
|
|
2
2
|
import { ReactBlockquote } from './typings';
|
|
3
3
|
export declare type CreateReactBlockquoteOptions = CreateBlockquoteOptions;
|
|
4
|
+
export declare const BLOCKQUOTE_EXIT_BREAK_HOTKEY = "enter";
|
|
4
5
|
export declare function createReactBlockquote(options?: CreateReactBlockquoteOptions): ReactBlockquote;
|
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
import isHotkey from 'is-hotkey';
|
|
2
2
|
import { createBlockquote } from '@quadrats/common/blockquote';
|
|
3
3
|
import { createRenderElement } from '@quadrats/react';
|
|
4
|
-
import { createOnKeyDownBreak } from '@quadrats/react/line-break';
|
|
4
|
+
import { createOnKeyDownBreak, COMMON_SOFT_BREAK_HOTKEY } from '@quadrats/react/line-break';
|
|
5
5
|
import { BLOCKQUOTE_HOTKEY } from './constants.js';
|
|
6
6
|
import { defaultRenderBlockquoteElement } from './defaultRenderBlockquoteElement.js';
|
|
7
|
+
import { getNodesByTypes, PARAGRAPH_TYPE, Editor, Transforms } from '@quadrats/core';
|
|
7
8
|
|
|
9
|
+
const BLOCKQUOTE_EXIT_BREAK_HOTKEY = 'enter';
|
|
8
10
|
function createReactBlockquote(options = {}) {
|
|
9
11
|
const core = createBlockquote(options);
|
|
10
12
|
const { type } = core;
|
|
11
13
|
const onKeyDownBreak = createOnKeyDownBreak({
|
|
14
|
+
exitBreak: {
|
|
15
|
+
rules: [
|
|
16
|
+
{
|
|
17
|
+
hotkey: BLOCKQUOTE_EXIT_BREAK_HOTKEY,
|
|
18
|
+
match: {
|
|
19
|
+
includeTypes: [type],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
12
24
|
softBreak: {
|
|
13
25
|
rules: [
|
|
14
26
|
{
|
|
15
|
-
hotkey:
|
|
27
|
+
hotkey: COMMON_SOFT_BREAK_HOTKEY,
|
|
16
28
|
match: {
|
|
17
29
|
includeTypes: [type],
|
|
18
30
|
},
|
|
@@ -26,10 +38,32 @@ function createReactBlockquote(options = {}) {
|
|
|
26
38
|
core.toggleBlockquote(editor);
|
|
27
39
|
}
|
|
28
40
|
else {
|
|
41
|
+
if (editor.selection && isHotkey(BLOCKQUOTE_EXIT_BREAK_HOTKEY, event)) {
|
|
42
|
+
const [highestIsQuote] = getNodesByTypes(editor, [type], { mode: 'highest' });
|
|
43
|
+
const [selectInParagraph] = getNodesByTypes(editor, [PARAGRAPH_TYPE], { at: editor.selection });
|
|
44
|
+
if (highestIsQuote && selectInParagraph) {
|
|
45
|
+
const [, quotePath] = highestIsQuote;
|
|
46
|
+
const isEnd = Editor.isEnd(editor, Editor.point(editor, editor.selection), quotePath);
|
|
47
|
+
const [paragraphNode] = selectInParagraph;
|
|
48
|
+
const text = paragraphNode.children[0].text;
|
|
49
|
+
const isEmptyParagraph = text.length === 0;
|
|
50
|
+
// move out the empty paragraph if end of the quote
|
|
51
|
+
if (isEnd && isEmptyParagraph) {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
const moveto = quotePath.slice();
|
|
54
|
+
moveto[(quotePath.length - 1)] += 1;
|
|
55
|
+
Transforms.moveNodes(editor, {
|
|
56
|
+
at: editor.selection,
|
|
57
|
+
to: moveto,
|
|
58
|
+
});
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
29
63
|
onKeyDownBreak(event, editor, next);
|
|
30
64
|
}
|
|
31
65
|
},
|
|
32
66
|
}), createRenderElement: ({ render = defaultRenderBlockquoteElement } = {}) => createRenderElement({ type, render }) });
|
|
33
67
|
}
|
|
34
68
|
|
|
35
|
-
export { createReactBlockquote };
|
|
69
|
+
export { BLOCKQUOTE_EXIT_BREAK_HOTKEY, createReactBlockquote };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
const defaultRenderBlockquoteElement = ({ attributes, children, }) => React.createElement("blockquote", Object.assign({}, attributes), children);
|
|
3
|
+
const defaultRenderBlockquoteElement = ({ attributes, children, }) => React.createElement("blockquote", Object.assign({}, attributes, { className: "qdr-blockquote" }), children);
|
|
4
4
|
|
|
5
5
|
export { defaultRenderBlockquoteElement };
|
package/blockquote/index.cjs.js
CHANGED
|
@@ -7,6 +7,7 @@ var isHotkey = require('is-hotkey');
|
|
|
7
7
|
var blockquote = require('@quadrats/common/blockquote');
|
|
8
8
|
var react = require('@quadrats/react');
|
|
9
9
|
var lineBreak = require('@quadrats/react/line-break');
|
|
10
|
+
var core = require('@quadrats/core');
|
|
10
11
|
|
|
11
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
12
13
|
|
|
@@ -20,16 +21,27 @@ var isHotkey__default = /*#__PURE__*/_interopDefaultLegacy(isHotkey);
|
|
|
20
21
|
*/
|
|
21
22
|
const BLOCKQUOTE_HOTKEY = 'ctrl+opt+q';
|
|
22
23
|
|
|
23
|
-
const defaultRenderBlockquoteElement = ({ attributes, children, }) => React__default.createElement("blockquote", Object.assign({}, attributes), children);
|
|
24
|
+
const defaultRenderBlockquoteElement = ({ attributes, children, }) => React__default.createElement("blockquote", Object.assign({}, attributes, { className: "qdr-blockquote" }), children);
|
|
24
25
|
|
|
26
|
+
const BLOCKQUOTE_EXIT_BREAK_HOTKEY = 'enter';
|
|
25
27
|
function createReactBlockquote(options = {}) {
|
|
26
|
-
const core = blockquote.createBlockquote(options);
|
|
27
|
-
const { type } = core;
|
|
28
|
+
const core$1 = blockquote.createBlockquote(options);
|
|
29
|
+
const { type } = core$1;
|
|
28
30
|
const onKeyDownBreak = lineBreak.createOnKeyDownBreak({
|
|
31
|
+
exitBreak: {
|
|
32
|
+
rules: [
|
|
33
|
+
{
|
|
34
|
+
hotkey: BLOCKQUOTE_EXIT_BREAK_HOTKEY,
|
|
35
|
+
match: {
|
|
36
|
+
includeTypes: [type],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
29
41
|
softBreak: {
|
|
30
42
|
rules: [
|
|
31
43
|
{
|
|
32
|
-
hotkey:
|
|
44
|
+
hotkey: lineBreak.COMMON_SOFT_BREAK_HOTKEY,
|
|
33
45
|
match: {
|
|
34
46
|
includeTypes: [type],
|
|
35
47
|
},
|
|
@@ -37,12 +49,34 @@ function createReactBlockquote(options = {}) {
|
|
|
37
49
|
],
|
|
38
50
|
},
|
|
39
51
|
});
|
|
40
|
-
return Object.assign(Object.assign({}, core), { createHandlers: ({ hotkey = BLOCKQUOTE_HOTKEY } = {}) => ({
|
|
52
|
+
return Object.assign(Object.assign({}, core$1), { createHandlers: ({ hotkey = BLOCKQUOTE_HOTKEY } = {}) => ({
|
|
41
53
|
onKeyDown: (event, editor, next) => {
|
|
42
54
|
if (isHotkey__default(hotkey, event)) {
|
|
43
|
-
core.toggleBlockquote(editor);
|
|
55
|
+
core$1.toggleBlockquote(editor);
|
|
44
56
|
}
|
|
45
57
|
else {
|
|
58
|
+
if (editor.selection && isHotkey__default(BLOCKQUOTE_EXIT_BREAK_HOTKEY, event)) {
|
|
59
|
+
const [highestIsQuote] = core.getNodesByTypes(editor, [type], { mode: 'highest' });
|
|
60
|
+
const [selectInParagraph] = core.getNodesByTypes(editor, [core.PARAGRAPH_TYPE], { at: editor.selection });
|
|
61
|
+
if (highestIsQuote && selectInParagraph) {
|
|
62
|
+
const [, quotePath] = highestIsQuote;
|
|
63
|
+
const isEnd = core.Editor.isEnd(editor, core.Editor.point(editor, editor.selection), quotePath);
|
|
64
|
+
const [paragraphNode] = selectInParagraph;
|
|
65
|
+
const text = paragraphNode.children[0].text;
|
|
66
|
+
const isEmptyParagraph = text.length === 0;
|
|
67
|
+
// move out the empty paragraph if end of the quote
|
|
68
|
+
if (isEnd && isEmptyParagraph) {
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
const moveto = quotePath.slice();
|
|
71
|
+
moveto[(quotePath.length - 1)] += 1;
|
|
72
|
+
core.Transforms.moveNodes(editor, {
|
|
73
|
+
at: editor.selection,
|
|
74
|
+
to: moveto,
|
|
75
|
+
});
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
46
80
|
onKeyDownBreak(event, editor, next);
|
|
47
81
|
}
|
|
48
82
|
},
|
package/blockquote/typings.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BlockquoteElement, Blockquote } from '@quadrats/common/blockquote';
|
|
3
|
-
import {
|
|
3
|
+
import { Editor } from '@quadrats/core';
|
|
4
|
+
import { WithCreateHandlers, WithCreateRenderElement, RenderElementProps } from '@quadrats/react';
|
|
4
5
|
export declare type RenderBlockquoteElementProps = RenderElementProps<BlockquoteElement>;
|
|
5
6
|
export interface ReactBlockquoteCreateHandlersOptions {
|
|
6
7
|
/**
|
|
@@ -11,5 +12,5 @@ export interface ReactBlockquoteCreateHandlersOptions {
|
|
|
11
12
|
export interface ReactBlockquoteCreateRenderElementOptions {
|
|
12
13
|
render?: (props: RenderBlockquoteElementProps) => JSX.Element | null | undefined;
|
|
13
14
|
}
|
|
14
|
-
export interface ReactBlockquote extends Blockquote<
|
|
15
|
+
export interface ReactBlockquote extends Blockquote<Editor>, WithCreateHandlers<[ReactBlockquoteCreateHandlersOptions?]>, WithCreateRenderElement<[ReactBlockquoteCreateRenderElementOptions?]> {
|
|
15
16
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QuadratsReactEditor } from '..';
|
|
2
2
|
import { EventHandlerName, EventHandlers, Handler } from './typings/handler';
|
|
3
3
|
/**
|
|
4
4
|
* To compose sequential `event handlers` to single for each event types.
|
|
5
5
|
*/
|
|
6
6
|
export declare function composeHandlers<H extends EventHandlerName>(handlersList: {
|
|
7
7
|
[HH in H]?: Handler<HH>;
|
|
8
|
-
}[]): (editor:
|
|
8
|
+
}[]): (editor: QuadratsReactEditor) => EventHandlers;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function createReactEditor():
|
|
1
|
+
import { QuadratsReactEditor } from '..';
|
|
2
|
+
export declare function createReactEditor(): QuadratsReactEditor;
|
package/core/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { QuadratsElement, QuadratsText } from '@quadrats/core';
|
|
1
|
+
import { QuadratsEditor, QuadratsElement, QuadratsText } from '@quadrats/core';
|
|
2
2
|
import { ReactEditor } from 'slate-react';
|
|
3
3
|
export { useSlateStatic, useFocused, useReadOnly, useSelected, useSlate as useQuadrats, ReactEditor, } from 'slate-react';
|
|
4
|
+
export { Editor } from '@quadrats/core';
|
|
4
5
|
export * from './typings/handler';
|
|
5
6
|
export * from './typings/renderer';
|
|
6
7
|
export * from './typings/with';
|
|
@@ -16,9 +17,11 @@ export { createReactEditor } from './createReactEditor';
|
|
|
16
17
|
export { createRenderElement } from './createRenderElement';
|
|
17
18
|
export { createRenderElements } from './createRenderElements';
|
|
18
19
|
export { createRenderMark } from './createRenderMark';
|
|
20
|
+
export interface QuadratsReactEditor extends QuadratsEditor, ReactEditor {
|
|
21
|
+
}
|
|
19
22
|
declare module 'slate' {
|
|
20
23
|
interface CustomTypes {
|
|
21
|
-
Editor:
|
|
24
|
+
Editor: QuadratsReactEditor;
|
|
22
25
|
Element: QuadratsElement;
|
|
23
26
|
Text: QuadratsText;
|
|
24
27
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { Editor } from '@quadrats/core';
|
|
1
2
|
import { DOMAttributes, EventHandler } from 'react';
|
|
2
|
-
import { ReactEditor } from 'slate-react';
|
|
3
3
|
export declare type EventHandlerName = {
|
|
4
4
|
[K in keyof Required<DOMAttributes<HTMLElement>>]: NonNullable<DOMAttributes<HTMLElement>[K]> extends EventHandler<any> ? K : never;
|
|
5
5
|
}[keyof DOMAttributes<HTMLElement>];
|
|
6
6
|
export declare type EventHandlers = Pick<DOMAttributes<HTMLElement>, EventHandlerName>;
|
|
7
7
|
export declare type GetEventHandlerByName<H extends EventHandlerName> = NonNullable<EventHandlers[H]>;
|
|
8
8
|
export declare type GetEventByName<H extends EventHandlerName> = GetEventHandlerByName<H> extends (event: infer E) => void ? E : never;
|
|
9
|
-
export declare type Handler<H extends EventHandlerName> = (event: GetEventByName<H>, editor:
|
|
9
|
+
export declare type Handler<H extends EventHandlerName> = (event: GetEventByName<H>, editor: Editor, next: VoidFunction) => void;
|
|
10
10
|
export declare type Handlers = {
|
|
11
11
|
[H in EventHandlerName]?: Handler<H>;
|
|
12
12
|
};
|
package/core/typings/with.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QuadratsReactEditor } from '..';
|
|
2
2
|
export interface ReactWithable<R = undefined> {
|
|
3
|
-
with: <T extends
|
|
3
|
+
with: <T extends QuadratsReactEditor>(editor: T) => R extends undefined ? T : T & R;
|
|
4
4
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
const defaultRenderDividerElement = ({ attributes, children }) => (React.createElement("div", Object.assign({}, attributes, { contentEditable: false }),
|
|
3
|
+
const defaultRenderDividerElement = ({ attributes, children }) => (React.createElement("div", Object.assign({}, attributes, { className: "qdr-divider", contentEditable: false }),
|
|
4
4
|
React.createElement("hr", null),
|
|
5
5
|
children));
|
|
6
6
|
|
package/divider/index.cjs.js
CHANGED
|
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
10
10
|
|
|
11
11
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
12
|
|
|
13
|
-
const defaultRenderDividerElement = ({ attributes, children }) => (React__default.createElement("div", Object.assign({}, attributes, { contentEditable: false }),
|
|
13
|
+
const defaultRenderDividerElement = ({ attributes, children }) => (React__default.createElement("div", Object.assign({}, attributes, { className: "qdr-divider", contentEditable: false }),
|
|
14
14
|
React__default.createElement("hr", null),
|
|
15
15
|
children));
|
|
16
16
|
|
package/divider/typings.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Divider, DividerElement } from '@quadrats/common/divider';
|
|
3
|
-
import {
|
|
3
|
+
import { Editor } from '@quadrats/core';
|
|
4
|
+
import { WithCreateRenderElement, RenderElementProps } from '@quadrats/react';
|
|
4
5
|
export declare type RenderDividerElementProps = RenderElementProps<DividerElement>;
|
|
5
6
|
export interface ReactDividerCreateRenderElementOptions {
|
|
6
7
|
render?: (props: RenderDividerElementProps) => JSX.Element | null | undefined;
|
|
7
8
|
}
|
|
8
|
-
export interface ReactDivider extends Divider<
|
|
9
|
+
export interface ReactDivider extends Divider<Editor>, WithCreateRenderElement<[ReactDividerCreateRenderElementOptions?]> {
|
|
9
10
|
}
|
|
@@ -7,5 +7,5 @@ export interface VideoIframeProps<E extends EmbedElement> {
|
|
|
7
7
|
data: string;
|
|
8
8
|
element: E;
|
|
9
9
|
}
|
|
10
|
-
declare function VideoIframe<E extends EmbedElement>({ attributes, children, data: src }: VideoIframeProps<E>): JSX.Element;
|
|
10
|
+
declare function VideoIframe<E extends EmbedElement>({ attributes, children, data: src, }: VideoIframeProps<E>): JSX.Element;
|
|
11
11
|
export default VideoIframe;
|
|
@@ -2,11 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import { composeRefs } from '@quadrats/react/utils';
|
|
3
3
|
import { useVideoIframeSize } from '../hooks/useVideoIframeSize.js';
|
|
4
4
|
|
|
5
|
-
function VideoIframe({ attributes, children, data: src }) {
|
|
5
|
+
function VideoIframe({ attributes, children, data: src, }) {
|
|
6
6
|
const { ref } = attributes || {};
|
|
7
7
|
const { ref: containerRef, size } = useVideoIframeSize();
|
|
8
8
|
const composedRef = ref ? composeRefs([ref, containerRef]) : containerRef;
|
|
9
|
-
return (React.createElement("div", Object.assign({}, attributes, { ref: composedRef, contentEditable: false }),
|
|
9
|
+
return (React.createElement("div", Object.assign({}, attributes, { ref: composedRef, className: "qdr-embed-video", contentEditable: false }),
|
|
10
10
|
React.createElement("div", { style: size },
|
|
11
11
|
React.createElement("iframe", { title: src, src: src, frameBorder: "0", width: "100%", height: "100%" })),
|
|
12
12
|
attributes ? children : undefined));
|
package/embed/index.cjs.js
CHANGED
|
@@ -32,11 +32,11 @@ function useVideoIframeSize() {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
function VideoIframe({ attributes, children, data: src }) {
|
|
35
|
+
function VideoIframe({ attributes, children, data: src, }) {
|
|
36
36
|
const { ref } = attributes || {};
|
|
37
37
|
const { ref: containerRef, size } = useVideoIframeSize();
|
|
38
38
|
const composedRef = ref ? utils.composeRefs([ref, containerRef]) : containerRef;
|
|
39
|
-
return (React__default.createElement("div", Object.assign({}, attributes, { ref: composedRef, contentEditable: false }),
|
|
39
|
+
return (React__default.createElement("div", Object.assign({}, attributes, { ref: composedRef, className: "qdr-embed-video", contentEditable: false }),
|
|
40
40
|
React__default.createElement("div", { style: size },
|
|
41
41
|
React__default.createElement("iframe", { title: src, src: src, frameBorder: "0", width: "100%", height: "100%" })),
|
|
42
42
|
attributes ? children : undefined));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
function Facebook({ attributes, children, data: { url, width, height } }) {
|
|
4
|
-
return (React.createElement("div", Object.assign({}, attributes, { contentEditable: false }),
|
|
4
|
+
return (React.createElement("div", Object.assign({}, attributes, { className: "qdr-embed-facebook", contentEditable: false }),
|
|
5
5
|
React.createElement("iframe", { title: url, src: url, width: width, height: height, style: {
|
|
6
6
|
border: 0,
|
|
7
7
|
overflow: 'hidden',
|
|
@@ -9,7 +9,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
10
|
|
|
11
11
|
function Facebook({ attributes, children, data: { url, width, height } }) {
|
|
12
|
-
return (React__default.createElement("div", Object.assign({}, attributes, { contentEditable: false }),
|
|
12
|
+
return (React__default.createElement("div", Object.assign({}, attributes, { className: "qdr-embed-facebook", contentEditable: false }),
|
|
13
13
|
React__default.createElement("iframe", { title: url, src: url, width: width, height: height, style: {
|
|
14
14
|
border: 0,
|
|
15
15
|
overflow: 'hidden',
|
|
@@ -3,7 +3,7 @@ import { useLoadInstagramEmbedApi } from '../hooks/useLoadInstagramEmbedApi.js';
|
|
|
3
3
|
|
|
4
4
|
function Instagram({ attributes, children, data: permalink }) {
|
|
5
5
|
useLoadInstagramEmbedApi(permalink);
|
|
6
|
-
return (React.createElement("div", Object.assign({}, attributes, { contentEditable: false, style: {
|
|
6
|
+
return (React.createElement("div", Object.assign({}, attributes, { className: "qdr-embed-instagram", contentEditable: false, style: {
|
|
7
7
|
display: 'flex',
|
|
8
8
|
marginBottom: -12,
|
|
9
9
|
} }),
|
|
@@ -34,7 +34,7 @@ function useLoadInstagramEmbedApi(permalink) {
|
|
|
34
34
|
|
|
35
35
|
function Instagram({ attributes, children, data: permalink }) {
|
|
36
36
|
useLoadInstagramEmbedApi(permalink);
|
|
37
|
-
return (React__default.createElement("div", Object.assign({}, attributes, { contentEditable: false, style: {
|
|
37
|
+
return (React__default.createElement("div", Object.assign({}, attributes, { className: "qdr-embed-instagram", contentEditable: false, style: {
|
|
38
38
|
display: 'flex',
|
|
39
39
|
marginBottom: -12,
|
|
40
40
|
} }),
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { PodcastAppleEmbedElement } from '@quadrats/common/embed/strategies/podcast-apple';
|
|
3
3
|
import { RenderElementProps } from '@quadrats/react';
|
|
4
4
|
export interface PodcastAppleProps {
|
|
5
5
|
attributes?: RenderElementProps['attributes'];
|
|
6
|
-
children?: any;
|
|
7
6
|
data: string;
|
|
8
7
|
element: PodcastAppleEmbedElement;
|
|
9
8
|
}
|
|
10
|
-
declare function PodcastApple({ attributes, children, data: src }: PodcastAppleProps): JSX.Element;
|
|
9
|
+
declare function PodcastApple({ attributes, children, data: src }: PropsWithChildren<PodcastAppleProps>): JSX.Element;
|
|
11
10
|
export default PodcastApple;
|
|
@@ -4,7 +4,7 @@ import { composeRefs } from '@quadrats/react/utils';
|
|
|
4
4
|
function PodcastApple({ attributes, children, data: src }) {
|
|
5
5
|
const containerRef = useRef(null);
|
|
6
6
|
const composedRef = composeRefs([attributes === null || attributes === void 0 ? void 0 : attributes.ref, containerRef]);
|
|
7
|
-
return (React.createElement("div", Object.assign({}, attributes, { ref: composedRef, contentEditable: false }),
|
|
7
|
+
return (React.createElement("div", Object.assign({}, attributes, { className: "qdr-embed-podcast-apple", ref: composedRef, contentEditable: false }),
|
|
8
8
|
React.createElement("iframe", { title: src, src: src, frameBorder: "0", width: "100%", height: "450px" }),
|
|
9
9
|
attributes ? children : undefined));
|
|
10
10
|
}
|
|
@@ -12,7 +12,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
12
12
|
function PodcastApple({ attributes, children, data: src }) {
|
|
13
13
|
const containerRef = React.useRef(null);
|
|
14
14
|
const composedRef = utils.composeRefs([attributes === null || attributes === void 0 ? void 0 : attributes.ref, containerRef]);
|
|
15
|
-
return (React__default.createElement("div", Object.assign({}, attributes, { ref: composedRef, contentEditable: false }),
|
|
15
|
+
return (React__default.createElement("div", Object.assign({}, attributes, { className: "qdr-embed-podcast-apple", ref: composedRef, contentEditable: false }),
|
|
16
16
|
React__default.createElement("iframe", { title: src, src: src, frameBorder: "0", width: "100%", height: "450px" }),
|
|
17
17
|
attributes ? children : undefined));
|
|
18
18
|
}
|
|
@@ -5,7 +5,7 @@ function Spotify({ attributes, children, data: src }) {
|
|
|
5
5
|
const containerRef = useRef(null);
|
|
6
6
|
const composedRef = composeRefs([attributes === null || attributes === void 0 ? void 0 : attributes.ref, containerRef]);
|
|
7
7
|
const higher = useMemo(() => (!!src.match(/\/playlist/)), [src]);
|
|
8
|
-
return (React.createElement("div", Object.assign({}, attributes, { ref: composedRef, contentEditable: false }),
|
|
8
|
+
return (React.createElement("div", Object.assign({}, attributes, { ref: composedRef, className: "qdr-embed-spotify", contentEditable: false }),
|
|
9
9
|
React.createElement("iframe", { title: src, src: src, frameBorder: "0", width: "100%", allow: "autoplay", "clipboard-write": "true", "encrypted-media": "true", "picture-in-picture": "true", height: higher ? '400px' : '152px', style: {
|
|
10
10
|
maxHeight: '100%',
|
|
11
11
|
height: higher ? '400px' : '152px',
|
|
@@ -13,7 +13,7 @@ function Spotify({ attributes, children, data: src }) {
|
|
|
13
13
|
const containerRef = React.useRef(null);
|
|
14
14
|
const composedRef = utils.composeRefs([attributes === null || attributes === void 0 ? void 0 : attributes.ref, containerRef]);
|
|
15
15
|
const higher = React.useMemo(() => (!!src.match(/\/playlist/)), [src]);
|
|
16
|
-
return (React__default.createElement("div", Object.assign({}, attributes, { ref: composedRef, contentEditable: false }),
|
|
16
|
+
return (React__default.createElement("div", Object.assign({}, attributes, { ref: composedRef, className: "qdr-embed-spotify", contentEditable: false }),
|
|
17
17
|
React__default.createElement("iframe", { title: src, src: src, frameBorder: "0", width: "100%", allow: "autoplay", "clipboard-write": "true", "encrypted-media": "true", "picture-in-picture": "true", height: higher ? '400px' : '152px', style: {
|
|
18
18
|
maxHeight: '100%',
|
|
19
19
|
height: higher ? '400px' : '152px',
|
|
@@ -6,7 +6,7 @@ function Twitter({ attributes, children, data: tweetId }) {
|
|
|
6
6
|
const tweetContainerRef = useRef(null);
|
|
7
7
|
const composedRef = composeRefs([attributes === null || attributes === void 0 ? void 0 : attributes.ref, tweetContainerRef]);
|
|
8
8
|
useLoadTwitterEmbedApi(tweetId, tweetContainerRef);
|
|
9
|
-
return (React.createElement("div", Object.assign({}, attributes, { ref: composedRef, contentEditable: false }), attributes ? children : undefined));
|
|
9
|
+
return (React.createElement("div", Object.assign({}, attributes, { ref: composedRef, className: "qdr-embed-twitter", contentEditable: false }), attributes ? children : undefined));
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export { Twitter as default };
|
|
@@ -43,7 +43,7 @@ function Twitter({ attributes, children, data: tweetId }) {
|
|
|
43
43
|
const tweetContainerRef = React.useRef(null);
|
|
44
44
|
const composedRef = utils.composeRefs([attributes === null || attributes === void 0 ? void 0 : attributes.ref, tweetContainerRef]);
|
|
45
45
|
useLoadTwitterEmbedApi(tweetId, tweetContainerRef);
|
|
46
|
-
return (React__default.createElement("div", Object.assign({}, attributes, { ref: composedRef, contentEditable: false }), attributes ? children : undefined));
|
|
46
|
+
return (React__default.createElement("div", Object.assign({}, attributes, { ref: composedRef, className: "qdr-embed-twitter", contentEditable: false }), attributes ? children : undefined));
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
const defaultRenderTwitterEmbedElement = (props) => React__default.createElement(Twitter, Object.assign({}, props));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { Editor } from '@quadrats/react';
|
|
3
3
|
import { InputWidgetConfig } from '@quadrats/common/input-widget';
|
|
4
4
|
import { ReactEmbed } from '@quadrats/react/embed';
|
|
5
5
|
import { ToolbarIconProps } from '@quadrats/react/toolbar';
|
|
@@ -9,7 +9,7 @@ export interface EmbedToolbarIconProps<Provider extends string> extends Omit<Too
|
|
|
9
9
|
* The providers supported by this icon.
|
|
10
10
|
*/
|
|
11
11
|
providers: Provider[];
|
|
12
|
-
startToolInput?: (editor:
|
|
12
|
+
startToolInput?: (editor: Editor, inputConfig: InputWidgetConfig) => void;
|
|
13
13
|
}
|
|
14
14
|
declare function EmbedToolbarIcon<Provider extends string>(props: EmbedToolbarIconProps<Provider>): JSX.Element;
|
|
15
15
|
export default EmbedToolbarIcon;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InputWidgetConfig } from '@quadrats/common/input-widget';
|
|
2
|
-
import {
|
|
2
|
+
import { Editor } from '@quadrats/react';
|
|
3
3
|
import { ReactEmbed } from '@quadrats/react/embed';
|
|
4
|
-
export declare function useEmbedTool<P extends string>(controller: ReactEmbed<P>, providers: P[], getPlaceholder: InputWidgetConfig['getPlaceholder'], startToolInput?: (editor:
|
|
4
|
+
export declare function useEmbedTool<P extends string>(controller: ReactEmbed<P>, providers: P[], getPlaceholder: InputWidgetConfig['getPlaceholder'], startToolInput?: (editor: Editor, inputConfig: InputWidgetConfig) => void): {
|
|
5
5
|
onClick: () => void;
|
|
6
6
|
};
|
package/embed/typings.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Embed, EmbedElement } from '@quadrats/common/embed';
|
|
3
|
-
import { WithCreateRenderElement, RenderElementProps,
|
|
3
|
+
import { WithCreateRenderElement, RenderElementProps, Editor } from '@quadrats/react';
|
|
4
4
|
export interface WithEmbedRenderData<RenderData> {
|
|
5
5
|
/**
|
|
6
6
|
* The data deserialized from element by corresponding strategy.
|
|
@@ -10,5 +10,5 @@ export interface WithEmbedRenderData<RenderData> {
|
|
|
10
10
|
export interface RenderEmbedElementProps<EmbedData extends Record<string, unknown>, RenderData> extends RenderElementProps<EmbedElement & EmbedData>, WithEmbedRenderData<RenderData> {
|
|
11
11
|
}
|
|
12
12
|
export declare type ReactEmbedCreateRenderElementOptions<Provider extends string> = Record<Provider, (props: RenderEmbedElementProps<any, any>) => JSX.Element | null | undefined>;
|
|
13
|
-
export interface ReactEmbed<Provider extends string> extends Embed<Provider,
|
|
13
|
+
export interface ReactEmbed<Provider extends string> extends Embed<Provider, Editor>, WithCreateRenderElement<[ReactEmbedCreateRenderElementOptions<Provider>]> {
|
|
14
14
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { FileUploader, FileUploaderElement } from '@quadrats/common/file-uploader';
|
|
3
|
-
import {
|
|
3
|
+
import { Editor, RenderElementProps, WithCreateRenderElement } from '@quadrats/react';
|
|
4
4
|
export declare type RenderFileUploaderElementProps = RenderElementProps<FileUploaderElement>;
|
|
5
5
|
export declare type RenderFileUploaderElement = (props: RenderFileUploaderElementProps) => JSX.Element | null | undefined;
|
|
6
6
|
export interface FileUploaderCreateRenderElementOptions {
|
|
7
7
|
render?: RenderFileUploaderElement;
|
|
8
8
|
}
|
|
9
|
-
export declare type ReactFileUploader = FileUploader<
|
|
9
|
+
export declare type ReactFileUploader = FileUploader<Editor> & WithCreateRenderElement<[FileUploaderCreateRenderElementOptions?]>;
|
|
@@ -8,8 +8,8 @@ const defaultRenderFootnoteElement = ({ attributes, children, element, placement
|
|
|
8
8
|
const { footnote, index } = element;
|
|
9
9
|
return (React.createElement(React.Fragment, null,
|
|
10
10
|
React.createElement(Tooltip, { placement: placement, popup: footnote },
|
|
11
|
-
React.createElement("span", Object.assign({ style: { textDecoration: 'underline' } }, attributes), children)),
|
|
12
|
-
React.createElement("sup", Object.assign({}, attributes, { style: { color: 'var(--qdr-sup)', userSelect: 'none' }, contentEditable: false }), `[${index !== null && index !== void 0 ? index : 1}]`)));
|
|
11
|
+
React.createElement("span", Object.assign({ style: { textDecoration: 'underline' } }, attributes, { className: "qdr-footnote-text" }), children)),
|
|
12
|
+
React.createElement("sup", Object.assign({}, attributes, { className: "qdr-footnote-sup", style: { color: 'var(--qdr-sup)', userSelect: 'none' }, contentEditable: false }), `[${index !== null && index !== void 0 ? index : 1}]`)));
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export { defaultRenderFootnoteElement };
|
package/footnote/index.cjs.js
CHANGED
|
@@ -19,8 +19,8 @@ const defaultRenderFootnoteElement = ({ attributes, children, element, placement
|
|
|
19
19
|
const { footnote, index } = element;
|
|
20
20
|
return (React__default.createElement(React__default.Fragment, null,
|
|
21
21
|
React__default.createElement(components.Tooltip, { placement: placement, popup: footnote },
|
|
22
|
-
React__default.createElement("span", Object.assign({ style: { textDecoration: 'underline' } }, attributes), children)),
|
|
23
|
-
React__default.createElement("sup", Object.assign({}, attributes, { style: { color: 'var(--qdr-sup)', userSelect: 'none' }, contentEditable: false }), `[${index !== null && index !== void 0 ? index : 1}]`)));
|
|
22
|
+
React__default.createElement("span", Object.assign({ style: { textDecoration: 'underline' } }, attributes, { className: "qdr-footnote-text" }), children)),
|
|
23
|
+
React__default.createElement("sup", Object.assign({}, attributes, { className: "qdr-footnote-sup", style: { color: 'var(--qdr-sup)', userSelect: 'none' }, contentEditable: false }), `[${index !== null && index !== void 0 ? index : 1}]`)));
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
function createReactFootnote(options = {}) {
|
package/footnote/typings.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Footnote, FootnoteElement } from '@quadrats/common/footnote';
|
|
3
|
-
import { RenderElementProps, ReactWithable, WithCreateRenderElement,
|
|
3
|
+
import { RenderElementProps, ReactWithable, WithCreateRenderElement, Editor } from '@quadrats/react';
|
|
4
4
|
export declare type RenderFootnoteElementProps = RenderElementProps<FootnoteElement>;
|
|
5
5
|
export interface ReactFootnoteCreateRenderElementOptions {
|
|
6
6
|
render?: (props: RenderFootnoteElementProps) => JSX.Element | null | undefined;
|
|
7
7
|
}
|
|
8
|
-
export interface ReactFootnote extends Omit<Footnote<
|
|
8
|
+
export interface ReactFootnote extends Omit<Footnote<Editor>, 'with'>, WithCreateRenderElement<[ReactFootnoteCreateRenderElementOptions?]>, ReactWithable {
|
|
9
9
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
import { Editor } from '@quadrats/core';
|
|
1
2
|
import { FootnoteData } from '@quadrats/common/footnote';
|
|
2
|
-
|
|
3
|
-
export declare function useFootnotes(editor: ReactEditor): FootnoteData[];
|
|
3
|
+
export declare function useFootnotes(editor: Editor): FootnoteData[];
|
|
4
4
|
export default useFootnotes;
|
|
@@ -13,7 +13,7 @@ const defaultRenderHeadingElement = ({ attributes, children, element, }) => {
|
|
|
13
13
|
if (!Component) {
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
|
-
return React.createElement(Component, Object.assign({}, attributes), children);
|
|
16
|
+
return React.createElement(Component, Object.assign({}, attributes, { className: `qdr-${Component}` }), children);
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export { HEADING_COMPONENTS, defaultRenderHeadingElement };
|
package/heading/index.cjs.js
CHANGED
|
@@ -36,7 +36,7 @@ const defaultRenderHeadingElement = ({ attributes, children, element, }) => {
|
|
|
36
36
|
if (!Component) {
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
|
-
return React__default.createElement(Component, Object.assign({}, attributes), children);
|
|
39
|
+
return React__default.createElement(Component, Object.assign({}, attributes, { className: `qdr-${Component}` }), children);
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
function createReactHeading(options = {}) {
|
package/heading/typings.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Heading, HeadingElement, HeadingLevel } from '@quadrats/common/heading';
|
|
3
|
-
import { WithCreateHandlers, WithCreateRenderElement, RenderElementProps,
|
|
3
|
+
import { WithCreateHandlers, WithCreateRenderElement, RenderElementProps, Editor } from '@quadrats/react';
|
|
4
4
|
export declare type RenderHeadingElementProps = RenderElementProps<HeadingElement>;
|
|
5
5
|
export interface ReactHeadingCreateHandlersOptions {
|
|
6
6
|
/**
|
|
@@ -11,5 +11,5 @@ export interface ReactHeadingCreateHandlersOptions {
|
|
|
11
11
|
export interface ReactHeadingCreateRenderElementOptions {
|
|
12
12
|
render?: (props: RenderHeadingElementProps) => JSX.Element | null | undefined;
|
|
13
13
|
}
|
|
14
|
-
export interface ReactHeading<Level extends HeadingLevel> extends Heading<Level,
|
|
14
|
+
export interface ReactHeading<Level extends HeadingLevel> extends Heading<Level, Editor>, WithCreateHandlers<[ReactHeadingCreateHandlersOptions?]>, WithCreateRenderElement<[ReactHeadingCreateRenderElementOptions?]> {
|
|
15
15
|
}
|
package/image/typings.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Image, ImageCaptionElement, ImageCaptionTypeKey, ImageElement, ImageFigureElement, ImageFigureTypeKey, ImageTypeKey } from '@quadrats/common/image';
|
|
3
|
-
import { WithCreateHandlers, WithCreateRenderElement, RenderElementProps, ReactWithable,
|
|
3
|
+
import { WithCreateHandlers, WithCreateRenderElement, RenderElementProps, ReactWithable, Editor } from '@quadrats/react';
|
|
4
4
|
export interface RenderImageFigureElementProps extends RenderElementProps<ImageFigureElement> {
|
|
5
5
|
style?: {
|
|
6
6
|
width: string;
|
|
@@ -15,5 +15,5 @@ export declare type ImageRenderElements = Record<ImageFigureTypeKey, (props: Ren
|
|
|
15
15
|
export declare type ReactImageCreateRenderElementOptions = {
|
|
16
16
|
[K in ImageFigureTypeKey | ImageTypeKey | ImageCaptionTypeKey]?: ImageRenderElements[K];
|
|
17
17
|
};
|
|
18
|
-
export interface ReactImage<Hosting extends string> extends Omit<Image<Hosting,
|
|
18
|
+
export interface ReactImage<Hosting extends string> extends Omit<Image<Hosting, Editor>, 'with'>, WithCreateHandlers, WithCreateRenderElement<[ReactImageCreateRenderElementOptions?]>, ReactWithable {
|
|
19
19
|
}
|
package/index.cjs.js
CHANGED
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var configs = require('@quadrats/react/configs');
|
|
6
6
|
var slateReact = require('slate-react');
|
|
7
|
+
var core = require('@quadrats/core');
|
|
7
8
|
var tslib = require('tslib');
|
|
8
9
|
var React = require('react');
|
|
9
10
|
var clsx = require('clsx');
|
|
10
|
-
var core = require('@quadrats/core');
|
|
11
11
|
var _internal = require('@quadrats/react/_internal');
|
|
12
12
|
|
|
13
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
@@ -140,6 +140,7 @@ exports.useQuadrats = slateReact.useSlate;
|
|
|
140
140
|
exports.useReadOnly = slateReact.useReadOnly;
|
|
141
141
|
exports.useSelected = slateReact.useSelected;
|
|
142
142
|
exports.useSlateStatic = slateReact.useSlateStatic;
|
|
143
|
+
exports.Editor = core.Editor;
|
|
143
144
|
exports.DefaultElement = DefaultElement;
|
|
144
145
|
exports.DefaultLeaf = DefaultLeaf;
|
|
145
146
|
exports.Editable = Editable;
|
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from '@quadrats/react/configs';
|
|
2
2
|
export { ReactEditor, useFocused, useSlate as useQuadrats, useReadOnly, useSelected, useSlateStatic } from 'slate-react';
|
|
3
|
+
export { Editor } from '@quadrats/core';
|
|
3
4
|
export { default as Editable } from './core/components/Editable.js';
|
|
4
5
|
export { default as DefaultElement } from './core/components/DefaultElement.js';
|
|
5
6
|
export { default as DefaultLeaf } from './core/components/DefaultLeaf.js';
|
|
@@ -6,7 +6,7 @@ function InputBlock(props) {
|
|
|
6
6
|
const { inputRef, onBlur, onKeyDown, placeholder, } = useInputBlock(props);
|
|
7
7
|
return (React.createElement("div", Object.assign({}, attributes, { contentEditable: false, style: {
|
|
8
8
|
display: 'flex',
|
|
9
|
-
} }),
|
|
9
|
+
}, className: "qdr-input-block" }),
|
|
10
10
|
React.createElement("input", { ref: inputRef, onBlur: onBlur, onKeyDown: onKeyDown, placeholder: placeholder, style: {
|
|
11
11
|
display: 'block',
|
|
12
12
|
color: 'currentColor',
|
package/input-block/index.cjs.js
CHANGED
|
@@ -60,7 +60,7 @@ function InputBlock(props) {
|
|
|
60
60
|
const { inputRef, onBlur, onKeyDown, placeholder, } = useInputBlock(props);
|
|
61
61
|
return (React__default.createElement("div", Object.assign({}, attributes, { contentEditable: false, style: {
|
|
62
62
|
display: 'flex',
|
|
63
|
-
} }),
|
|
63
|
+
}, className: "qdr-input-block" }),
|
|
64
64
|
React__default.createElement("input", { ref: inputRef, onBlur: onBlur, onKeyDown: onKeyDown, placeholder: placeholder, style: {
|
|
65
65
|
display: 'block',
|
|
66
66
|
color: 'currentColor',
|
package/input-block/typings.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { InputBlock, InputBlockElement } from '@quadrats/common/input-block';
|
|
3
|
-
import {
|
|
3
|
+
import { Editor, RenderElementProps, WithCreateRenderElement } from '@quadrats/react';
|
|
4
4
|
export declare type RenderInputBlockElementProps = RenderElementProps<InputBlockElement> & Pick<ReactInputBlock, 'remove' | 'confirm'>;
|
|
5
5
|
export declare type RenderInputBlockElement = (props: RenderInputBlockElementProps) => JSX.Element | null | undefined;
|
|
6
6
|
export interface ReactInputBlockCreateRenderElementOptions {
|
|
7
7
|
render?: RenderInputBlockElement;
|
|
8
8
|
}
|
|
9
|
-
export interface ReactInputBlock extends Omit<InputBlock<
|
|
10
|
-
remove(editor:
|
|
11
|
-
confirm(editor:
|
|
9
|
+
export interface ReactInputBlock extends Omit<InputBlock<Editor>, 'remove' | 'confirm'>, WithCreateRenderElement<[ReactInputBlockCreateRenderElementOptions?]> {
|
|
10
|
+
remove(editor: Editor, element: InputBlockElement): void;
|
|
11
|
+
confirm(editor: Editor, element: InputBlockElement, value: string): void;
|
|
12
12
|
}
|
|
@@ -7,7 +7,7 @@ import { Tooltip } from '@quadrats/react/components';
|
|
|
7
7
|
const defaultRenderLinkElement = ({ attributes, children, element, placement = 'bottom', target = '_blank', }) => {
|
|
8
8
|
const { url } = element;
|
|
9
9
|
return (React.createElement(Tooltip, { placement: placement, popup: url },
|
|
10
|
-
React.createElement("a", Object.assign({}, attributes, { href: url, target: target }), children)));
|
|
10
|
+
React.createElement("a", Object.assign({}, attributes, { className: "qdr-link", href: url, target: target }), children)));
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export { defaultRenderLinkElement };
|
package/link/index.cjs.js
CHANGED
|
@@ -17,7 +17,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
17
17
|
const defaultRenderLinkElement = ({ attributes, children, element, placement = 'bottom', target = '_blank', }) => {
|
|
18
18
|
const { url } = element;
|
|
19
19
|
return (React__default.createElement(components.Tooltip, { placement: placement, popup: url },
|
|
20
|
-
React__default.createElement("a", Object.assign({}, attributes, { href: url, target: target }), children)));
|
|
20
|
+
React__default.createElement("a", Object.assign({}, attributes, { className: "qdr-link", href: url, target: target }), children)));
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
function createReactLink(options = {}) {
|
package/link/typings.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Link, LinkElement } from '@quadrats/common/link';
|
|
3
|
-
import { RenderElementProps, ReactWithable, WithCreateRenderElement,
|
|
3
|
+
import { RenderElementProps, ReactWithable, WithCreateRenderElement, Editor } from '@quadrats/react';
|
|
4
4
|
export declare type RenderLinkElementProps = RenderElementProps<LinkElement>;
|
|
5
5
|
export interface ReactLinkCreateRenderElementOptions {
|
|
6
6
|
render?: (props: RenderLinkElementProps) => JSX.Element | null | undefined;
|
|
7
7
|
}
|
|
8
|
-
export interface ReactLink extends Omit<Link<
|
|
8
|
+
export interface ReactLink extends Omit<Link<Editor>, 'with'>, WithCreateRenderElement<[ReactLinkCreateRenderElementOptions?]>, ReactWithable {
|
|
9
9
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
const defaultRenderListElements = {
|
|
4
|
-
ol: ({ attributes, children }) => React.createElement("ol", Object.assign({}, attributes), children),
|
|
5
|
-
ul: ({ attributes, children }) => React.createElement("ul", Object.assign({}, attributes), children),
|
|
6
|
-
li: ({ attributes, children }) => React.createElement("li", Object.assign({}, attributes), children),
|
|
4
|
+
ol: ({ attributes, children }) => React.createElement("ol", Object.assign({}, attributes, { className: "qdr-ol" }), children),
|
|
5
|
+
ul: ({ attributes, children }) => React.createElement("ul", Object.assign({}, attributes, { className: "qdr-ul" }), children),
|
|
6
|
+
li: ({ attributes, children }) => React.createElement("li", Object.assign({}, attributes, { className: "qdr-li" }), children),
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export { defaultRenderListElements };
|
package/list/index.cjs.js
CHANGED
|
@@ -11,9 +11,9 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
11
11
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
12
|
|
|
13
13
|
const defaultRenderListElements = {
|
|
14
|
-
ol: ({ attributes, children }) => React__default.createElement("ol", Object.assign({}, attributes), children),
|
|
15
|
-
ul: ({ attributes, children }) => React__default.createElement("ul", Object.assign({}, attributes), children),
|
|
16
|
-
li: ({ attributes, children }) => React__default.createElement("li", Object.assign({}, attributes), children),
|
|
14
|
+
ol: ({ attributes, children }) => React__default.createElement("ol", Object.assign({}, attributes, { className: "qdr-ol" }), children),
|
|
15
|
+
ul: ({ attributes, children }) => React__default.createElement("ul", Object.assign({}, attributes, { className: "qdr-ul" }), children),
|
|
16
|
+
li: ({ attributes, children }) => React__default.createElement("li", Object.assign({}, attributes, { className: "qdr-li" }), children),
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
function createReactList(options = {}) {
|
package/list/typings.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { List, ListElement, ListTypeKey } from '@quadrats/common/list';
|
|
3
|
-
import { WithCreateHandlers, WithCreateRenderElement, RenderElementProps,
|
|
3
|
+
import { WithCreateHandlers, WithCreateRenderElement, RenderElementProps, Editor } from '@quadrats/react';
|
|
4
4
|
export declare type RenderListElementProps = RenderElementProps<ListElement>;
|
|
5
5
|
export declare type ReactListCreateRenderElementOptions = {
|
|
6
6
|
[key in ListTypeKey]?: (props: RenderListElementProps) => JSX.Element | null | undefined;
|
|
7
7
|
};
|
|
8
|
-
export interface ReactList extends List<
|
|
8
|
+
export interface ReactList extends List<Editor>, WithCreateHandlers, WithCreateRenderElement<[ReactListCreateRenderElementOptions?]> {
|
|
9
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quadrats/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Rytass",
|
|
6
6
|
"homepage": "https://github.com/Quadrats/quadrats#readme",
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
"url": "https://github.com/Quadrats/quadrats/issues"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@quadrats/common": "^0.
|
|
24
|
-
"@quadrats/core": "^0.
|
|
25
|
-
"@quadrats/icons": "^0.
|
|
26
|
-
"@quadrats/locales": "^0.
|
|
27
|
-
"@quadrats/theme": "^0.
|
|
28
|
-
"@quadrats/utils": "^0.
|
|
23
|
+
"@quadrats/common": "^0.6.2",
|
|
24
|
+
"@quadrats/core": "^0.6.2",
|
|
25
|
+
"@quadrats/icons": "^0.6.0",
|
|
26
|
+
"@quadrats/locales": "^0.6.0",
|
|
27
|
+
"@quadrats/theme": "^0.6.0",
|
|
28
|
+
"@quadrats/utils": "^0.6.0",
|
|
29
29
|
"@types/is-hotkey": "^0.1.7",
|
|
30
30
|
"@types/react-transition-group": "^4.4.4",
|
|
31
31
|
"clsx": "^1.1.1",
|
|
32
32
|
"is-hotkey": "^0.2.0",
|
|
33
33
|
"react-transition-group": "^4.4.2",
|
|
34
|
-
"slate-react": "^0.
|
|
34
|
+
"slate-react": "^0.65.3",
|
|
35
35
|
"tslib": "^2.3.1"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
const defaultRenderParagraphElement = ({ attributes, children, }) => (React.createElement("p", Object.assign({}, attributes), children));
|
|
3
|
+
const defaultRenderParagraphElement = ({ attributes, children, }) => (React.createElement("p", Object.assign({}, attributes, { className: "qdr-paragraph" }), children));
|
|
4
4
|
|
|
5
5
|
export { defaultRenderParagraphElement };
|
package/paragraph/index.cjs.js
CHANGED
|
@@ -10,14 +10,14 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
10
10
|
|
|
11
11
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
12
|
|
|
13
|
-
const defaultRenderParagraphElement = ({ attributes, children, }) => (React__default.createElement("p", Object.assign({}, attributes), children));
|
|
13
|
+
const defaultRenderParagraphElement = ({ attributes, children, }) => (React__default.createElement("p", Object.assign({}, attributes, { className: "qdr-paragraph" }), children));
|
|
14
14
|
|
|
15
15
|
function createRenderParagraphElement(options = {}) {
|
|
16
16
|
const { render = defaultRenderParagraphElement } = options;
|
|
17
17
|
return react.createRenderElement({ type: core.PARAGRAPH_TYPE, render });
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const renderParagraphElementWithSymbol = ({ attributes, children, }) => (React__default.createElement("p", Object.assign({}, attributes, { className: "qdr-paragraph__with-line-break-symbol" }), children));
|
|
20
|
+
const renderParagraphElementWithSymbol = ({ attributes, children, }) => (React__default.createElement("p", Object.assign({}, attributes, { className: "qdr-paragraph qdr-paragraph__with-line-break-symbol" }), children));
|
|
21
21
|
|
|
22
22
|
exports.createRenderParagraphElement = createRenderParagraphElement;
|
|
23
23
|
exports.defaultRenderParagraphElement = defaultRenderParagraphElement;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
const renderParagraphElementWithSymbol = ({ attributes, children, }) => (React.createElement("p", Object.assign({}, attributes, { className: "qdr-paragraph__with-line-break-symbol" }), children));
|
|
3
|
+
const renderParagraphElementWithSymbol = ({ attributes, children, }) => (React.createElement("p", Object.assign({}, attributes, { className: "qdr-paragraph qdr-paragraph__with-line-break-symbol" }), children));
|
|
4
4
|
|
|
5
5
|
export { renderParagraphElementWithSymbol };
|
package/read-more/typings.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ReadMore, ReadMoreElement } from '@quadrats/common/read-more';
|
|
3
|
-
import { WithCreateRenderElement, RenderElementProps,
|
|
3
|
+
import { WithCreateRenderElement, RenderElementProps, Editor } from '@quadrats/react';
|
|
4
4
|
export declare type RenderReadMoreElementProps = RenderElementProps<ReadMoreElement>;
|
|
5
5
|
export interface ReactReadMoreCreateRenderElementOptions {
|
|
6
6
|
render?: (props: RenderReadMoreElementProps) => JSX.Element | null | undefined;
|
|
7
7
|
}
|
|
8
|
-
export interface ReactReadMore extends ReadMore<
|
|
8
|
+
export interface ReactReadMore extends ReadMore<Editor>, WithCreateRenderElement<[ReactReadMoreCreateRenderElementOptions?]> {
|
|
9
9
|
}
|
package/toggle-mark/typings.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ToggleMark } from '@quadrats/common/toggle-mark';
|
|
2
|
-
import { CreateRenderMarkOptions,
|
|
2
|
+
import { CreateRenderMarkOptions, Editor, RenderMarkProps, WithCreateHandlers, WithCreateRenderLeaf } from '@quadrats/react';
|
|
3
3
|
export declare type RenderToggleMarkProps = RenderMarkProps<boolean>;
|
|
4
4
|
export interface ReactToggleMarkCreateHandlersOptions {
|
|
5
5
|
/**
|
|
@@ -8,5 +8,5 @@ export interface ReactToggleMarkCreateHandlersOptions {
|
|
|
8
8
|
hotkey?: string;
|
|
9
9
|
}
|
|
10
10
|
export declare type ReactToggleMarkCreateRenderLeafOptions = Partial<Omit<CreateRenderMarkOptions<boolean>, 'type'>>;
|
|
11
|
-
export interface ReactToggleMark extends ToggleMark<
|
|
11
|
+
export interface ReactToggleMark extends ToggleMark<Editor>, WithCreateHandlers<[ReactToggleMarkCreateHandlersOptions?]>, WithCreateRenderLeaf<[ReactToggleMarkCreateRenderLeafOptions?]> {
|
|
12
12
|
}
|