@quadrats/common 0.4.5 → 0.5.1
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/createBlockquote.js +2 -2
- package/blockquote/index.cjs.js +2 -2
- package/blockquote/typings.d.ts +2 -2
- package/divider/createDivider.js +1 -1
- package/divider/index.cjs.js +1 -1
- package/divider/typings.d.ts +2 -2
- package/embed/createEmbed.js +5 -3
- package/embed/index.cjs.js +5 -3
- package/embed/typings.d.ts +2 -2
- package/file-uploader/createFileUploader.js +5 -9
- package/file-uploader/index.cjs.js +4 -8
- package/file-uploader/typings.d.ts +6 -6
- package/footnote/createFootnote.js +5 -5
- package/footnote/index.cjs.js +5 -5
- package/footnote/typings.d.ts +2 -2
- package/heading/createHeading.js +1 -1
- package/heading/index.cjs.js +1 -1
- package/heading/typings.d.ts +2 -2
- package/image/createImage.js +6 -6
- package/image/index.cjs.js +6 -6
- package/image/typings.d.ts +5 -5
- package/input-block/createInputBlock.js +2 -1
- package/input-block/index.cjs.js +2 -1
- package/input-block/typings.d.ts +2 -2
- package/link/createLink.js +3 -3
- package/link/index.cjs.js +3 -3
- package/link/typings.d.ts +2 -2
- package/list/createList.js +11 -5
- package/list/index.cjs.js +11 -5
- package/list/typings.d.ts +6 -6
- package/package.json +4 -4
- package/read-more/createReadMore.js +1 -1
- package/read-more/index.cjs.js +1 -1
- package/read-more/typings.d.ts +2 -2
|
@@ -4,8 +4,8 @@ import { BLOCKQUOTE_TYPE } from './constants.js';
|
|
|
4
4
|
function createBlockquote({ type = BLOCKQUOTE_TYPE } = {}) {
|
|
5
5
|
return {
|
|
6
6
|
type,
|
|
7
|
-
isSelectionInBlockquote:
|
|
8
|
-
toggleBlockquote:
|
|
7
|
+
isSelectionInBlockquote: editor => isNodesTypeIn(editor, [type]),
|
|
8
|
+
toggleBlockquote: editor => toggleNodesType(editor, type),
|
|
9
9
|
with(editor) {
|
|
10
10
|
const { normalizeNode } = editor;
|
|
11
11
|
editor.normalizeNode = (entry) => {
|
package/blockquote/index.cjs.js
CHANGED
|
@@ -9,8 +9,8 @@ const BLOCKQUOTE_TYPE = 'blockquote';
|
|
|
9
9
|
function createBlockquote({ type = BLOCKQUOTE_TYPE } = {}) {
|
|
10
10
|
return {
|
|
11
11
|
type,
|
|
12
|
-
isSelectionInBlockquote:
|
|
13
|
-
toggleBlockquote:
|
|
12
|
+
isSelectionInBlockquote: editor => core.isNodesTypeIn(editor, [type]),
|
|
13
|
+
toggleBlockquote: editor => core.toggleNodesType(editor, type),
|
|
14
14
|
with(editor) {
|
|
15
15
|
const { normalizeNode } = editor;
|
|
16
16
|
editor.normalizeNode = (entry) => {
|
package/blockquote/typings.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Editor,
|
|
2
|
-
export interface BlockquoteElement extends
|
|
1
|
+
import { Editor, QuadratsElement, Withable, WithElementType } from '@quadrats/core';
|
|
2
|
+
export interface BlockquoteElement extends QuadratsElement, WithElementType {
|
|
3
3
|
}
|
|
4
4
|
export interface Blockquote extends WithElementType, Withable {
|
|
5
5
|
isSelectionInBlockquote(editor: Editor): boolean;
|
package/divider/createDivider.js
CHANGED
|
@@ -14,7 +14,7 @@ function createDivider(options = {}) {
|
|
|
14
14
|
insertDivider,
|
|
15
15
|
with(editor) {
|
|
16
16
|
const { isVoid, normalizeNode } = editor;
|
|
17
|
-
editor.isVoid =
|
|
17
|
+
editor.isVoid = element => element.type === type || isVoid(element);
|
|
18
18
|
editor.normalizeNode = (entry) => {
|
|
19
19
|
const [node, path] = entry;
|
|
20
20
|
/**
|
package/divider/index.cjs.js
CHANGED
|
@@ -19,7 +19,7 @@ function createDivider(options = {}) {
|
|
|
19
19
|
insertDivider,
|
|
20
20
|
with(editor) {
|
|
21
21
|
const { isVoid, normalizeNode } = editor;
|
|
22
|
-
editor.isVoid =
|
|
22
|
+
editor.isVoid = element => element.type === type || isVoid(element);
|
|
23
23
|
editor.normalizeNode = (entry) => {
|
|
24
24
|
const [node, path] = entry;
|
|
25
25
|
/**
|
package/divider/typings.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Editor,
|
|
2
|
-
export interface DividerElement extends
|
|
1
|
+
import { Editor, QuadratsElement, Text, Withable, WithElementType } from '@quadrats/core';
|
|
2
|
+
export interface DividerElement extends QuadratsElement, WithElementType {
|
|
3
3
|
children: [Text];
|
|
4
4
|
}
|
|
5
5
|
export interface Divider extends WithElementType, Withable {
|
package/embed/createEmbed.js
CHANGED
|
@@ -11,7 +11,8 @@ function createEmbed(options) {
|
|
|
11
11
|
const embedElement = Object.assign(Object.assign({}, data), { type, provider, children: [{ text: '' }] });
|
|
12
12
|
Transforms.insertNodes(editor, [
|
|
13
13
|
embedElement,
|
|
14
|
-
typeof defaultNode === 'string'
|
|
14
|
+
typeof defaultNode === 'string'
|
|
15
|
+
? { type: defaultNode, children: [{ text: '' }] } : defaultNode,
|
|
15
16
|
]);
|
|
16
17
|
Transforms.move(editor);
|
|
17
18
|
}
|
|
@@ -22,11 +23,12 @@ function createEmbed(options) {
|
|
|
22
23
|
insertEmbed,
|
|
23
24
|
with(editor) {
|
|
24
25
|
const { isVoid, normalizeNode } = editor;
|
|
25
|
-
editor.isVoid =
|
|
26
|
+
editor.isVoid = element => element.type === type || isVoid(element);
|
|
26
27
|
editor.normalizeNode = (entry) => {
|
|
27
28
|
const [node, path] = entry;
|
|
28
29
|
if (Element.isElement(node) && node.type === type) {
|
|
29
|
-
const strategy = node.provider
|
|
30
|
+
const strategy = node.provider
|
|
31
|
+
? strategies[node.provider] : undefined;
|
|
30
32
|
if (!strategy || !strategy.isElementDataValid(node)) {
|
|
31
33
|
Transforms.removeNodes(editor, { at: path });
|
|
32
34
|
return;
|
package/embed/index.cjs.js
CHANGED
|
@@ -33,7 +33,8 @@ function createEmbed(options) {
|
|
|
33
33
|
const embedElement = Object.assign(Object.assign({}, data), { type, provider, children: [{ text: '' }] });
|
|
34
34
|
core.Transforms.insertNodes(editor, [
|
|
35
35
|
embedElement,
|
|
36
|
-
typeof defaultNode === 'string'
|
|
36
|
+
typeof defaultNode === 'string'
|
|
37
|
+
? { type: defaultNode, children: [{ text: '' }] } : defaultNode,
|
|
37
38
|
]);
|
|
38
39
|
core.Transforms.move(editor);
|
|
39
40
|
}
|
|
@@ -44,11 +45,12 @@ function createEmbed(options) {
|
|
|
44
45
|
insertEmbed,
|
|
45
46
|
with(editor) {
|
|
46
47
|
const { isVoid, normalizeNode } = editor;
|
|
47
|
-
editor.isVoid =
|
|
48
|
+
editor.isVoid = element => element.type === type || isVoid(element);
|
|
48
49
|
editor.normalizeNode = (entry) => {
|
|
49
50
|
const [node, path] = entry;
|
|
50
51
|
if (core.Element.isElement(node) && node.type === type) {
|
|
51
|
-
const strategy = node.provider
|
|
52
|
+
const strategy = node.provider
|
|
53
|
+
? strategies[node.provider] : undefined;
|
|
52
54
|
if (!strategy || !strategy.isElementDataValid(node)) {
|
|
53
55
|
core.Transforms.removeNodes(editor, { at: path });
|
|
54
56
|
return;
|
package/embed/typings.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Editor,
|
|
2
|
-
export interface EmbedElement extends
|
|
1
|
+
import { Editor, QuadratsElement, Node, Text, Withable, WithElementType } from '@quadrats/core';
|
|
2
|
+
export interface EmbedElement extends QuadratsElement, WithElementType {
|
|
3
3
|
/**
|
|
4
4
|
* The embed provider.
|
|
5
5
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from './_virtual/_tslib.js';
|
|
2
2
|
import { readFileAsDataURL } from '@quadrats/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { Transforms, createParagraphElement } from '@quadrats/core';
|
|
4
4
|
import { FILE_UPLOADER_TYPE } from './constants.js';
|
|
5
5
|
import { getFilesFromInput } from './getFilesFromInput.js';
|
|
6
6
|
|
|
@@ -25,10 +25,8 @@ function createFileUploader(options = {}) {
|
|
|
25
25
|
if (xhr.status < 400) {
|
|
26
26
|
const path = getPath();
|
|
27
27
|
if (path) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
Transforms.insertNodes(editor, createElementByResponse(xhr.response), { at: path });
|
|
31
|
-
});
|
|
28
|
+
Transforms.removeNodes(editor, { at: path });
|
|
29
|
+
Transforms.insertNodes(editor, createElementByResponse(xhr.response), { at: path });
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
else {
|
|
@@ -65,10 +63,8 @@ function createFileUploader(options = {}) {
|
|
|
65
63
|
yield prev;
|
|
66
64
|
return createFileUploaderElement(editor, file, options).then((fileUploaderElement) => {
|
|
67
65
|
if (fileUploaderElement) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
Transforms.move(editor);
|
|
71
|
-
});
|
|
66
|
+
Transforms.insertNodes(editor, [fileUploaderElement, createParagraphElement()], options);
|
|
67
|
+
Transforms.move(editor);
|
|
72
68
|
}
|
|
73
69
|
});
|
|
74
70
|
}), Promise.resolve());
|
|
@@ -79,10 +79,8 @@ function createFileUploader(options = {}) {
|
|
|
79
79
|
if (xhr.status < 400) {
|
|
80
80
|
const path = getPath();
|
|
81
81
|
if (path) {
|
|
82
|
-
core.
|
|
83
|
-
|
|
84
|
-
core.Transforms.insertNodes(editor, createElementByResponse(xhr.response), { at: path });
|
|
85
|
-
});
|
|
82
|
+
core.Transforms.removeNodes(editor, { at: path });
|
|
83
|
+
core.Transforms.insertNodes(editor, createElementByResponse(xhr.response), { at: path });
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
86
|
else {
|
|
@@ -119,10 +117,8 @@ function createFileUploader(options = {}) {
|
|
|
119
117
|
yield prev;
|
|
120
118
|
return createFileUploaderElement(editor, file, options).then((fileUploaderElement) => {
|
|
121
119
|
if (fileUploaderElement) {
|
|
122
|
-
core.
|
|
123
|
-
|
|
124
|
-
core.Transforms.move(editor);
|
|
125
|
-
});
|
|
120
|
+
core.Transforms.insertNodes(editor, [fileUploaderElement, core.createParagraphElement()], options);
|
|
121
|
+
core.Transforms.move(editor);
|
|
126
122
|
}
|
|
127
123
|
});
|
|
128
124
|
}), Promise.resolve());
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Editor,
|
|
1
|
+
import { Editor, QuadratsElement, Path, TransformsInsertNodesOptions, Withable } from '@quadrats/core';
|
|
2
2
|
import { GetFilesFromInputOptions } from './getFilesFromInput';
|
|
3
3
|
export interface XHRUploadHeaders {
|
|
4
4
|
[name: string]: string;
|
|
5
5
|
}
|
|
6
|
-
export interface FileUploaderElement extends
|
|
6
|
+
export interface FileUploaderElement extends QuadratsElement {
|
|
7
7
|
type: string;
|
|
8
8
|
register: (getPath: () => Path | undefined, onProgress: (percentage: number) => void) => VoidFunction;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* For creating temorary element while uploading.
|
|
12
12
|
*/
|
|
13
|
-
export declare type FileUploaderCreateElementByDataURL = (dataURL: string) =>
|
|
13
|
+
export declare type FileUploaderCreateElementByDataURL = (dataURL: string) => QuadratsElement;
|
|
14
14
|
/**
|
|
15
15
|
* For create element after uploaded.
|
|
16
16
|
*/
|
|
17
|
-
export declare type FileUploaderCreateElementByResponse = (response: any) =>
|
|
17
|
+
export declare type FileUploaderCreateElementByResponse = (response: any) => QuadratsElement;
|
|
18
18
|
export declare type FileUploaderGetBody = (file: File) => BodyInit;
|
|
19
19
|
export declare type FileUploaderGetHeaders = (file: File) => XHRUploadHeaders | Promise<XHRUploadHeaders>;
|
|
20
20
|
export declare type FileUploaderGetUrl = (file: File) => string;
|
|
@@ -32,6 +32,6 @@ export interface FileUploaderCreateFileUploaderElementOptions {
|
|
|
32
32
|
export declare type FileUploaderUploadOptions = FileUploaderCreateFileUploaderElementOptions & GetFilesFromInputOptions & TransformsInsertNodesOptions;
|
|
33
33
|
export interface FileUploader extends Withable {
|
|
34
34
|
type: string;
|
|
35
|
-
createFileUploaderElement(editor: Editor
|
|
36
|
-
upload(editor: Editor
|
|
35
|
+
createFileUploaderElement(editor: Editor, file: File, options: FileUploaderCreateFileUploaderElementOptions): Promise<FileUploaderElement | undefined>;
|
|
36
|
+
upload(editor: Editor, options: FileUploaderUploadOptions): Promise<void>;
|
|
37
37
|
}
|
|
@@ -3,20 +3,20 @@ import { FOOTNOTE_TYPE } from './constants.js';
|
|
|
3
3
|
|
|
4
4
|
/* eslint-disable max-len */
|
|
5
5
|
function createFootnote({ type = FOOTNOTE_TYPE, } = {}) {
|
|
6
|
-
const isSelectionInFootnote =
|
|
6
|
+
const isSelectionInFootnote = editor => isNodesTypeIn(editor, [type]);
|
|
7
7
|
const getFootnoteText = (editor) => {
|
|
8
8
|
var _a, _b, _c;
|
|
9
9
|
const at = editor.selection;
|
|
10
10
|
if (!at) {
|
|
11
11
|
return '';
|
|
12
12
|
}
|
|
13
|
-
const firstNode = (_b = (_a = Array.from(getNodes(editor, { at, match:
|
|
13
|
+
const firstNode = (_b = (_a = Array.from(getNodes(editor, { at, match: node => node.type === type }))) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b[0];
|
|
14
14
|
return (_c = firstNode) === null || _c === void 0 ? void 0 : _c.footnote;
|
|
15
15
|
};
|
|
16
16
|
const updateFootnoteIndex = (editor, options = { startAt: 1 }) => {
|
|
17
17
|
var _a;
|
|
18
18
|
let footnoteCount = (_a = options === null || options === void 0 ? void 0 : options.startAt) !== null && _a !== void 0 ? _a : 1;
|
|
19
|
-
for (const [, path] of getNodes(editor, { at: [], match:
|
|
19
|
+
for (const [, path] of getNodes(editor, { at: [], match: node => node.type === FOOTNOTE_TYPE })) {
|
|
20
20
|
Transforms.setNodes(editor, { index: footnoteCount }, { at: path });
|
|
21
21
|
footnoteCount += 1;
|
|
22
22
|
}
|
|
@@ -41,7 +41,7 @@ function createFootnote({ type = FOOTNOTE_TYPE, } = {}) {
|
|
|
41
41
|
}
|
|
42
42
|
if (footnoteText !== '') {
|
|
43
43
|
if (isSelectionInFootnote(editor)) {
|
|
44
|
-
Transforms.setNodes(editor, { footnote: footnoteText }, { at, match:
|
|
44
|
+
Transforms.setNodes(editor, { footnote: footnoteText }, { at, match: node => node.type === type });
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
47
|
wrapFootnote(editor, footnoteText, options);
|
|
@@ -62,7 +62,7 @@ function createFootnote({ type = FOOTNOTE_TYPE, } = {}) {
|
|
|
62
62
|
upsertFootnoteAndUpdateIndex,
|
|
63
63
|
with(editor) {
|
|
64
64
|
const { isInline } = editor;
|
|
65
|
-
editor.isInline =
|
|
65
|
+
editor.isInline = element => element.type === type || isInline(element);
|
|
66
66
|
return editor;
|
|
67
67
|
},
|
|
68
68
|
};
|
package/footnote/index.cjs.js
CHANGED
|
@@ -8,20 +8,20 @@ const FOOTNOTE_TYPE = 'footnote';
|
|
|
8
8
|
|
|
9
9
|
/* eslint-disable max-len */
|
|
10
10
|
function createFootnote({ type = FOOTNOTE_TYPE, } = {}) {
|
|
11
|
-
const isSelectionInFootnote =
|
|
11
|
+
const isSelectionInFootnote = editor => core.isNodesTypeIn(editor, [type]);
|
|
12
12
|
const getFootnoteText = (editor) => {
|
|
13
13
|
var _a, _b, _c;
|
|
14
14
|
const at = editor.selection;
|
|
15
15
|
if (!at) {
|
|
16
16
|
return '';
|
|
17
17
|
}
|
|
18
|
-
const firstNode = (_b = (_a = Array.from(core.getNodes(editor, { at, match:
|
|
18
|
+
const firstNode = (_b = (_a = Array.from(core.getNodes(editor, { at, match: node => node.type === type }))) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b[0];
|
|
19
19
|
return (_c = firstNode) === null || _c === void 0 ? void 0 : _c.footnote;
|
|
20
20
|
};
|
|
21
21
|
const updateFootnoteIndex = (editor, options = { startAt: 1 }) => {
|
|
22
22
|
var _a;
|
|
23
23
|
let footnoteCount = (_a = options === null || options === void 0 ? void 0 : options.startAt) !== null && _a !== void 0 ? _a : 1;
|
|
24
|
-
for (const [, path] of core.getNodes(editor, { at: [], match:
|
|
24
|
+
for (const [, path] of core.getNodes(editor, { at: [], match: node => node.type === FOOTNOTE_TYPE })) {
|
|
25
25
|
core.Transforms.setNodes(editor, { index: footnoteCount }, { at: path });
|
|
26
26
|
footnoteCount += 1;
|
|
27
27
|
}
|
|
@@ -46,7 +46,7 @@ function createFootnote({ type = FOOTNOTE_TYPE, } = {}) {
|
|
|
46
46
|
}
|
|
47
47
|
if (footnoteText !== '') {
|
|
48
48
|
if (isSelectionInFootnote(editor)) {
|
|
49
|
-
core.Transforms.setNodes(editor, { footnote: footnoteText }, { at, match:
|
|
49
|
+
core.Transforms.setNodes(editor, { footnote: footnoteText }, { at, match: node => node.type === type });
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
52
|
wrapFootnote(editor, footnoteText, options);
|
|
@@ -67,7 +67,7 @@ function createFootnote({ type = FOOTNOTE_TYPE, } = {}) {
|
|
|
67
67
|
upsertFootnoteAndUpdateIndex,
|
|
68
68
|
with(editor) {
|
|
69
69
|
const { isInline } = editor;
|
|
70
|
-
editor.isInline =
|
|
70
|
+
editor.isInline = element => element.type === type || isInline(element);
|
|
71
71
|
return editor;
|
|
72
72
|
},
|
|
73
73
|
};
|
package/footnote/typings.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Editor, Range,
|
|
1
|
+
import { Editor, Range, QuadratsElement, WithElementType, UnwrapNodeByTypesOptions, TransformsWrapNodesOptions, Withable } from '@quadrats/core';
|
|
2
2
|
export interface FootnoteData {
|
|
3
3
|
footnote: string;
|
|
4
4
|
index: number;
|
|
5
5
|
wrapperText: string;
|
|
6
6
|
}
|
|
7
|
-
export interface FootnoteElement extends
|
|
7
|
+
export interface FootnoteElement extends QuadratsElement, WithElementType {
|
|
8
8
|
footnote: string;
|
|
9
9
|
index?: number;
|
|
10
10
|
}
|
package/heading/createHeading.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Element, Transforms, PARAGRAPH_TYPE, normalizeOnlyInlineOrTextInChildre
|
|
|
2
2
|
import { HEADING_TYPE, HEADING_LEVELS } from './constants.js';
|
|
3
3
|
|
|
4
4
|
function createHeading({ type = HEADING_TYPE, enabledLevels = HEADING_LEVELS, } = {}) {
|
|
5
|
-
const getHeadingNodes = (editor, level, options = {}) => getNodes(editor, Object.assign(Object.assign({}, options), { match:
|
|
5
|
+
const getHeadingNodes = (editor, level, options = {}) => getNodes(editor, Object.assign(Object.assign({}, options), { match: node => node.type === type && node.level === level }));
|
|
6
6
|
const isSelectionInHeading = (editor, level, options = {}) => {
|
|
7
7
|
const [match] = getHeadingNodes(editor, level, options);
|
|
8
8
|
return !!match;
|
package/heading/index.cjs.js
CHANGED
|
@@ -8,7 +8,7 @@ const HEADING_TYPE = 'heading';
|
|
|
8
8
|
const HEADING_LEVELS = [1, 2, 3, 4, 5, 6];
|
|
9
9
|
|
|
10
10
|
function createHeading({ type = HEADING_TYPE, enabledLevels = HEADING_LEVELS, } = {}) {
|
|
11
|
-
const getHeadingNodes = (editor, level, options = {}) => core.getNodes(editor, Object.assign(Object.assign({}, options), { match:
|
|
11
|
+
const getHeadingNodes = (editor, level, options = {}) => core.getNodes(editor, Object.assign(Object.assign({}, options), { match: node => node.type === type && node.level === level }));
|
|
12
12
|
const isSelectionInHeading = (editor, level, options = {}) => {
|
|
13
13
|
const [match] = getHeadingNodes(editor, level, options);
|
|
14
14
|
return !!match;
|
package/heading/typings.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Editor,
|
|
1
|
+
import { Editor, QuadratsElement, GetNodesOptions, Node, NodeEntry, Withable, WithElementType } from '@quadrats/core';
|
|
2
2
|
export declare type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
3
|
-
export interface HeadingElement extends
|
|
3
|
+
export interface HeadingElement extends QuadratsElement, WithElementType {
|
|
4
4
|
level: HeadingLevel;
|
|
5
5
|
}
|
|
6
6
|
export interface WithEnabledHeadingLevels<L extends HeadingLevel> {
|
package/image/createImage.js
CHANGED
|
@@ -3,7 +3,7 @@ import { getAboveByTypes, Element, isNodesTypeIn, Transforms, normalizeVoidEleme
|
|
|
3
3
|
import { IMAGE_TYPES } from './constants.js';
|
|
4
4
|
|
|
5
5
|
function resolveSizeSteps(steps) {
|
|
6
|
-
let sortedSteps = steps.filter(
|
|
6
|
+
let sortedSteps = steps.filter(step => step > 0 && step < 100).sort();
|
|
7
7
|
if (!sortedSteps.includes(100)) {
|
|
8
8
|
sortedSteps = [...sortedSteps, 100];
|
|
9
9
|
}
|
|
@@ -16,9 +16,9 @@ function createImage(options = {}) {
|
|
|
16
16
|
const getAboveImageFigure = (editor, options) => getAboveByTypes(editor, [types.figure], options);
|
|
17
17
|
const getAboveImageCaption = (editor, options) => getAboveByTypes(editor, [types.caption], options);
|
|
18
18
|
const isNodesInImage = (editor, options) => isNodesTypeIn(editor, [types.image], options);
|
|
19
|
-
const isSelectionInImage =
|
|
20
|
-
const isSelectionInImageCaption =
|
|
21
|
-
const isCollapsedOnImage =
|
|
19
|
+
const isSelectionInImage = editor => isNodesInImage(editor);
|
|
20
|
+
const isSelectionInImageCaption = editor => isNodesTypeIn(editor, [types.caption]);
|
|
21
|
+
const isCollapsedOnImage = editor => !!editor.selection && Range.isCollapsed(editor.selection) && isSelectionInImage(editor);
|
|
22
22
|
const createImageElement = (src, hosting) => {
|
|
23
23
|
const imageElement = {
|
|
24
24
|
type: types.image,
|
|
@@ -51,7 +51,7 @@ function createImage(options = {}) {
|
|
|
51
51
|
if (!sizeSteps) {
|
|
52
52
|
return percentage;
|
|
53
53
|
}
|
|
54
|
-
const lowerIndex = sizeSteps.findIndex(
|
|
54
|
+
const lowerIndex = sizeSteps.findIndex(step => step >= percentage) - 1;
|
|
55
55
|
const upperIndex = lowerIndex + 1;
|
|
56
56
|
if (lowerIndex < 0) {
|
|
57
57
|
return sizeSteps[0];
|
|
@@ -119,7 +119,7 @@ function createImage(options = {}) {
|
|
|
119
119
|
}
|
|
120
120
|
insertBreak();
|
|
121
121
|
};
|
|
122
|
-
editor.isVoid =
|
|
122
|
+
editor.isVoid = element => element.type === types.image || isVoid(element);
|
|
123
123
|
editor.normalizeNode = (entry) => {
|
|
124
124
|
const [node, path] = entry;
|
|
125
125
|
if (Element.isElement(node)) {
|
package/image/index.cjs.js
CHANGED
|
@@ -31,7 +31,7 @@ function getImageElementCommonProps(element, hostingResolvers) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function resolveSizeSteps(steps) {
|
|
34
|
-
let sortedSteps = steps.filter(
|
|
34
|
+
let sortedSteps = steps.filter(step => step > 0 && step < 100).sort();
|
|
35
35
|
if (!sortedSteps.includes(100)) {
|
|
36
36
|
sortedSteps = [...sortedSteps, 100];
|
|
37
37
|
}
|
|
@@ -44,9 +44,9 @@ function createImage(options = {}) {
|
|
|
44
44
|
const getAboveImageFigure = (editor, options) => core.getAboveByTypes(editor, [types.figure], options);
|
|
45
45
|
const getAboveImageCaption = (editor, options) => core.getAboveByTypes(editor, [types.caption], options);
|
|
46
46
|
const isNodesInImage = (editor, options) => core.isNodesTypeIn(editor, [types.image], options);
|
|
47
|
-
const isSelectionInImage =
|
|
48
|
-
const isSelectionInImageCaption =
|
|
49
|
-
const isCollapsedOnImage =
|
|
47
|
+
const isSelectionInImage = editor => isNodesInImage(editor);
|
|
48
|
+
const isSelectionInImageCaption = editor => core.isNodesTypeIn(editor, [types.caption]);
|
|
49
|
+
const isCollapsedOnImage = editor => !!editor.selection && core.Range.isCollapsed(editor.selection) && isSelectionInImage(editor);
|
|
50
50
|
const createImageElement = (src, hosting) => {
|
|
51
51
|
const imageElement = {
|
|
52
52
|
type: types.image,
|
|
@@ -79,7 +79,7 @@ function createImage(options = {}) {
|
|
|
79
79
|
if (!sizeSteps) {
|
|
80
80
|
return percentage;
|
|
81
81
|
}
|
|
82
|
-
const lowerIndex = sizeSteps.findIndex(
|
|
82
|
+
const lowerIndex = sizeSteps.findIndex(step => step >= percentage) - 1;
|
|
83
83
|
const upperIndex = lowerIndex + 1;
|
|
84
84
|
if (lowerIndex < 0) {
|
|
85
85
|
return sizeSteps[0];
|
|
@@ -147,7 +147,7 @@ function createImage(options = {}) {
|
|
|
147
147
|
}
|
|
148
148
|
insertBreak();
|
|
149
149
|
};
|
|
150
|
-
editor.isVoid =
|
|
150
|
+
editor.isVoid = element => element.type === types.image || isVoid(element);
|
|
151
151
|
editor.normalizeNode = (entry) => {
|
|
152
152
|
const [node, path] = entry;
|
|
153
153
|
if (core.Element.isElement(node)) {
|
package/image/typings.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Editor,
|
|
1
|
+
import { Editor, QuadratsElement, GetAboveByTypesOptions, Location, NodeEntry, Text, Withable, WithElementType } from '@quadrats/core';
|
|
2
2
|
export declare type ImageFigureTypeKey = 'figure';
|
|
3
3
|
export declare type ImageTypeKey = 'image';
|
|
4
4
|
export declare type ImageCaptionTypeKey = 'caption';
|
|
5
5
|
export declare type ImageTypes = Record<ImageFigureTypeKey | ImageTypeKey | ImageCaptionTypeKey, string>;
|
|
6
|
-
export interface ImageFigureElement extends
|
|
6
|
+
export interface ImageFigureElement extends QuadratsElement, WithElementType {
|
|
7
7
|
width?: number;
|
|
8
8
|
}
|
|
9
|
-
export interface ImageElement extends
|
|
9
|
+
export interface ImageElement extends QuadratsElement, WithElementType {
|
|
10
10
|
children: [Text];
|
|
11
11
|
src: string;
|
|
12
12
|
/**
|
|
@@ -15,7 +15,7 @@ export interface ImageElement extends Element, WithElementType {
|
|
|
15
15
|
*/
|
|
16
16
|
hosting?: string;
|
|
17
17
|
}
|
|
18
|
-
export interface ImageCaptionElement extends
|
|
18
|
+
export interface ImageCaptionElement extends QuadratsElement, WithElementType {
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Indicate how to resolve the `src` and `hosting` of image element.
|
|
@@ -61,5 +61,5 @@ export interface Image<Hosting extends string> extends Withable {
|
|
|
61
61
|
hosting?: Hosting;
|
|
62
62
|
at?: Location;
|
|
63
63
|
}): void;
|
|
64
|
-
resizeImage(editor: Editor, entry: NodeEntry<
|
|
64
|
+
resizeImage(editor: Editor, entry: NodeEntry<QuadratsElement>, width: number): void;
|
|
65
65
|
}
|
|
@@ -30,7 +30,8 @@ function createInputBlock(options = {}) {
|
|
|
30
30
|
const { isVoid } = editor;
|
|
31
31
|
editor.isVoid = (element) => {
|
|
32
32
|
// invalidate unfinished input_block from storage
|
|
33
|
-
if (element.type === type
|
|
33
|
+
if (element.type === type
|
|
34
|
+
&& typeof element.getPlaceholder !== 'function')
|
|
34
35
|
return false;
|
|
35
36
|
return element.type === type || isVoid(element);
|
|
36
37
|
};
|
package/input-block/index.cjs.js
CHANGED
|
@@ -35,7 +35,8 @@ function createInputBlock(options = {}) {
|
|
|
35
35
|
const { isVoid } = editor;
|
|
36
36
|
editor.isVoid = (element) => {
|
|
37
37
|
// invalidate unfinished input_block from storage
|
|
38
|
-
if (element.type === type
|
|
38
|
+
if (element.type === type
|
|
39
|
+
&& typeof element.getPlaceholder !== 'function')
|
|
39
40
|
return false;
|
|
40
41
|
return element.type === type || isVoid(element);
|
|
41
42
|
};
|
package/input-block/typings.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Editor,
|
|
1
|
+
import { Editor, QuadratsElement, NodeEntry, Withable } from '@quadrats/core';
|
|
2
2
|
import { InputWidgetConfig } from '@quadrats/common/input-widget';
|
|
3
|
-
export interface InputBlockElement extends
|
|
3
|
+
export interface InputBlockElement extends QuadratsElement, InputWidgetConfig {
|
|
4
4
|
type: string;
|
|
5
5
|
}
|
|
6
6
|
export interface InputBlock extends Withable {
|
package/link/createLink.js
CHANGED
|
@@ -35,7 +35,7 @@ function createLink({ type = LINK_TYPE, isUrl: isUrl$1 = isUrl, prevUrlToLinkAft
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
const isSelectionInLink =
|
|
38
|
+
const isSelectionInLink = editor => isNodesTypeIn(editor, [type]);
|
|
39
39
|
const insertLink = (editor, url, options = {}) => {
|
|
40
40
|
const { text = url } = options;
|
|
41
41
|
const link = {
|
|
@@ -118,7 +118,7 @@ function createLink({ type = LINK_TYPE, isUrl: isUrl$1 = isUrl, prevUrlToLinkAft
|
|
|
118
118
|
if (!wrappableVoidTypes) {
|
|
119
119
|
return true;
|
|
120
120
|
}
|
|
121
|
-
return !element.children.some(
|
|
121
|
+
return !element.children.some(child => Editor.isBlock(editor, child)
|
|
122
122
|
&& Editor.isVoid(editor, child)
|
|
123
123
|
&& wrappableVoidTypes.includes(child.type));
|
|
124
124
|
};
|
|
@@ -136,7 +136,7 @@ function createLink({ type = LINK_TYPE, isUrl: isUrl$1 = isUrl, prevUrlToLinkAft
|
|
|
136
136
|
* Remove empty content.
|
|
137
137
|
*/
|
|
138
138
|
if (Text.isTextList(node.children)) {
|
|
139
|
-
if (node.children.every(
|
|
139
|
+
if (node.children.every(textNode => !textNode.text)) {
|
|
140
140
|
Transforms.unwrapNodes(editor, { at: path });
|
|
141
141
|
return;
|
|
142
142
|
}
|
package/link/index.cjs.js
CHANGED
|
@@ -40,7 +40,7 @@ function createLink({ type = LINK_TYPE, isUrl = utils.isUrl, prevUrlToLinkAfterS
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
const isSelectionInLink =
|
|
43
|
+
const isSelectionInLink = editor => core.isNodesTypeIn(editor, [type]);
|
|
44
44
|
const insertLink = (editor, url, options = {}) => {
|
|
45
45
|
const { text = url } = options;
|
|
46
46
|
const link = {
|
|
@@ -123,7 +123,7 @@ function createLink({ type = LINK_TYPE, isUrl = utils.isUrl, prevUrlToLinkAfterS
|
|
|
123
123
|
if (!wrappableVoidTypes) {
|
|
124
124
|
return true;
|
|
125
125
|
}
|
|
126
|
-
return !element.children.some(
|
|
126
|
+
return !element.children.some(child => core.Editor.isBlock(editor, child)
|
|
127
127
|
&& core.Editor.isVoid(editor, child)
|
|
128
128
|
&& wrappableVoidTypes.includes(child.type));
|
|
129
129
|
};
|
|
@@ -141,7 +141,7 @@ function createLink({ type = LINK_TYPE, isUrl = utils.isUrl, prevUrlToLinkAfterS
|
|
|
141
141
|
* Remove empty content.
|
|
142
142
|
*/
|
|
143
143
|
if (core.Text.isTextList(node.children)) {
|
|
144
|
-
if (node.children.every(
|
|
144
|
+
if (node.children.every(textNode => !textNode.text)) {
|
|
145
145
|
core.Transforms.unwrapNodes(editor, { at: path });
|
|
146
146
|
return;
|
|
147
147
|
}
|
package/link/typings.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Editor, Location, Range,
|
|
2
|
-
export interface LinkElement extends
|
|
1
|
+
import { Editor, Location, Range, WithElementType, TransformsInsertNodesOptions, UnwrapNodeByTypesOptions, TransformsWrapNodesOptions, Withable, QuadratsElement } from '@quadrats/core';
|
|
2
|
+
export interface LinkElement extends QuadratsElement, WithElementType {
|
|
3
3
|
url: string;
|
|
4
4
|
}
|
|
5
5
|
export interface LinkInsertLinkOptions extends TransformsInsertNodesOptions {
|
package/list/createList.js
CHANGED
|
@@ -50,19 +50,24 @@ function createList(options = {}) {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
const increaseListItemDepth = (editor, entries) => {
|
|
53
|
+
var _a, _b, _c, _d, _e;
|
|
53
54
|
const { list: [listNode], listItem: [, listItemPath], } = entries;
|
|
54
55
|
if (!isFirstChild(listItemPath)) {
|
|
55
56
|
const previousEntry = Editor.node(editor, Path.previous(listItemPath));
|
|
56
57
|
if (previousEntry) {
|
|
57
58
|
const [previousNode, previousPath] = previousEntry;
|
|
58
|
-
const lastNodeOfPreviousNode = previousNode.children[previousNode.children.length - 1];
|
|
59
|
+
const lastNodeOfPreviousNode = ((_a = previousNode === null || previousNode === void 0 ? void 0 : previousNode.children) !== null && _a !== void 0 ? _a : [])[((_b = previousNode === null || previousNode === void 0 ? void 0 : previousNode.children) !== null && _b !== void 0 ? _b : []).length - 1];
|
|
59
60
|
/**
|
|
60
61
|
* Move list item next to the last node of previous node of list item.
|
|
61
62
|
*/
|
|
62
63
|
if (isListElement(lastNodeOfPreviousNode)) {
|
|
63
64
|
Transforms.moveNodes(editor, {
|
|
64
65
|
at: listItemPath,
|
|
65
|
-
to: [
|
|
66
|
+
to: [
|
|
67
|
+
...previousPath,
|
|
68
|
+
((_c = previousNode === null || previousNode === void 0 ? void 0 : previousNode.children) !== null && _c !== void 0 ? _c : []).length - 1,
|
|
69
|
+
((_d = lastNodeOfPreviousNode === null || lastNodeOfPreviousNode === void 0 ? void 0 : lastNodeOfPreviousNode.children) !== null && _d !== void 0 ? _d : []).length,
|
|
70
|
+
],
|
|
66
71
|
});
|
|
67
72
|
/**
|
|
68
73
|
* Wrap list item by a new list and move the new list next to the last node of previous node.
|
|
@@ -73,13 +78,14 @@ function createList(options = {}) {
|
|
|
73
78
|
Transforms.wrapNodes(editor, newSubListElement, { at: listItemPath });
|
|
74
79
|
Transforms.moveNodes(editor, {
|
|
75
80
|
at: listItemPath,
|
|
76
|
-
to: [...previousPath, previousNode.children.length],
|
|
81
|
+
to: [...previousPath, ((_e = previousNode === null || previousNode === void 0 ? void 0 : previousNode.children) !== null && _e !== void 0 ? _e : []).length],
|
|
77
82
|
});
|
|
78
83
|
}
|
|
79
84
|
}
|
|
80
85
|
}
|
|
81
86
|
};
|
|
82
87
|
const decreaseListItemDepth = (editor, entries) => {
|
|
88
|
+
var _a, _b, _c;
|
|
83
89
|
const { list: [listNode, listPath], listItem: [listItemNode, listItemPath], } = entries;
|
|
84
90
|
const [listParentNode, listParentPath] = Editor.parent(editor, listPath);
|
|
85
91
|
/**
|
|
@@ -90,7 +96,7 @@ function createList(options = {}) {
|
|
|
90
96
|
}
|
|
91
97
|
const newListItemPath = Path.next(listParentPath);
|
|
92
98
|
const listItemIndex = listItemPath[listItemPath.length - 1];
|
|
93
|
-
const nextSiblingListItems = listNode.children.slice(listItemIndex + 1, listNode.children.length);
|
|
99
|
+
const nextSiblingListItems = ((_a = listNode === null || listNode === void 0 ? void 0 : listNode.children) !== null && _a !== void 0 ? _a : []).slice(listItemIndex + 1, ((_b = listNode === null || listNode === void 0 ? void 0 : listNode.children) !== null && _b !== void 0 ? _b : []).length);
|
|
94
100
|
Transforms.moveNodes(editor, {
|
|
95
101
|
at: listItemPath,
|
|
96
102
|
to: newListItemPath,
|
|
@@ -100,7 +106,7 @@ function createList(options = {}) {
|
|
|
100
106
|
*/
|
|
101
107
|
if (nextSiblingListItems.length) {
|
|
102
108
|
const newSubListElement = { type: listNode.type, children: [] };
|
|
103
|
-
const newSubListPath = [...newListItemPath, listItemNode.children.length];
|
|
109
|
+
const newSubListPath = [...newListItemPath, ((_c = listItemNode === null || listItemNode === void 0 ? void 0 : listItemNode.children) !== null && _c !== void 0 ? _c : []).length];
|
|
104
110
|
Transforms.insertNodes(editor, newSubListElement, { at: newSubListPath });
|
|
105
111
|
nextSiblingListItems.forEach((_, index) => {
|
|
106
112
|
Transforms.moveNodes(editor, {
|
package/list/index.cjs.js
CHANGED
|
@@ -59,19 +59,24 @@ function createList(options = {}) {
|
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
const increaseListItemDepth = (editor, entries) => {
|
|
62
|
+
var _a, _b, _c, _d, _e;
|
|
62
63
|
const { list: [listNode], listItem: [, listItemPath], } = entries;
|
|
63
64
|
if (!core.isFirstChild(listItemPath)) {
|
|
64
65
|
const previousEntry = core.Editor.node(editor, core.Path.previous(listItemPath));
|
|
65
66
|
if (previousEntry) {
|
|
66
67
|
const [previousNode, previousPath] = previousEntry;
|
|
67
|
-
const lastNodeOfPreviousNode = previousNode.children[previousNode.children.length - 1];
|
|
68
|
+
const lastNodeOfPreviousNode = ((_a = previousNode === null || previousNode === void 0 ? void 0 : previousNode.children) !== null && _a !== void 0 ? _a : [])[((_b = previousNode === null || previousNode === void 0 ? void 0 : previousNode.children) !== null && _b !== void 0 ? _b : []).length - 1];
|
|
68
69
|
/**
|
|
69
70
|
* Move list item next to the last node of previous node of list item.
|
|
70
71
|
*/
|
|
71
72
|
if (isListElement(lastNodeOfPreviousNode)) {
|
|
72
73
|
core.Transforms.moveNodes(editor, {
|
|
73
74
|
at: listItemPath,
|
|
74
|
-
to: [
|
|
75
|
+
to: [
|
|
76
|
+
...previousPath,
|
|
77
|
+
((_c = previousNode === null || previousNode === void 0 ? void 0 : previousNode.children) !== null && _c !== void 0 ? _c : []).length - 1,
|
|
78
|
+
((_d = lastNodeOfPreviousNode === null || lastNodeOfPreviousNode === void 0 ? void 0 : lastNodeOfPreviousNode.children) !== null && _d !== void 0 ? _d : []).length,
|
|
79
|
+
],
|
|
75
80
|
});
|
|
76
81
|
/**
|
|
77
82
|
* Wrap list item by a new list and move the new list next to the last node of previous node.
|
|
@@ -82,13 +87,14 @@ function createList(options = {}) {
|
|
|
82
87
|
core.Transforms.wrapNodes(editor, newSubListElement, { at: listItemPath });
|
|
83
88
|
core.Transforms.moveNodes(editor, {
|
|
84
89
|
at: listItemPath,
|
|
85
|
-
to: [...previousPath, previousNode.children.length],
|
|
90
|
+
to: [...previousPath, ((_e = previousNode === null || previousNode === void 0 ? void 0 : previousNode.children) !== null && _e !== void 0 ? _e : []).length],
|
|
86
91
|
});
|
|
87
92
|
}
|
|
88
93
|
}
|
|
89
94
|
}
|
|
90
95
|
};
|
|
91
96
|
const decreaseListItemDepth = (editor, entries) => {
|
|
97
|
+
var _a, _b, _c;
|
|
92
98
|
const { list: [listNode, listPath], listItem: [listItemNode, listItemPath], } = entries;
|
|
93
99
|
const [listParentNode, listParentPath] = core.Editor.parent(editor, listPath);
|
|
94
100
|
/**
|
|
@@ -99,7 +105,7 @@ function createList(options = {}) {
|
|
|
99
105
|
}
|
|
100
106
|
const newListItemPath = core.Path.next(listParentPath);
|
|
101
107
|
const listItemIndex = listItemPath[listItemPath.length - 1];
|
|
102
|
-
const nextSiblingListItems = listNode.children.slice(listItemIndex + 1, listNode.children.length);
|
|
108
|
+
const nextSiblingListItems = ((_a = listNode === null || listNode === void 0 ? void 0 : listNode.children) !== null && _a !== void 0 ? _a : []).slice(listItemIndex + 1, ((_b = listNode === null || listNode === void 0 ? void 0 : listNode.children) !== null && _b !== void 0 ? _b : []).length);
|
|
103
109
|
core.Transforms.moveNodes(editor, {
|
|
104
110
|
at: listItemPath,
|
|
105
111
|
to: newListItemPath,
|
|
@@ -109,7 +115,7 @@ function createList(options = {}) {
|
|
|
109
115
|
*/
|
|
110
116
|
if (nextSiblingListItems.length) {
|
|
111
117
|
const newSubListElement = { type: listNode.type, children: [] };
|
|
112
|
-
const newSubListPath = [...newListItemPath, listItemNode.children.length];
|
|
118
|
+
const newSubListPath = [...newListItemPath, ((_c = listItemNode === null || listItemNode === void 0 ? void 0 : listItemNode.children) !== null && _c !== void 0 ? _c : []).length];
|
|
113
119
|
core.Transforms.insertNodes(editor, newSubListElement, { at: newSubListPath });
|
|
114
120
|
nextSiblingListItems.forEach((_, index) => {
|
|
115
121
|
core.Transforms.moveNodes(editor, {
|
package/list/typings.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Editor,
|
|
1
|
+
import { Editor, QuadratsElement, Location, Node, NodeEntry, Withable, WithElementType } from '@quadrats/core';
|
|
2
2
|
export declare type ListRootTypeKey = 'ol' | 'ul';
|
|
3
3
|
export declare type ListItemTypeKey = 'li';
|
|
4
4
|
export declare type ListTypeKey = ListRootTypeKey | ListItemTypeKey;
|
|
5
5
|
export declare type ListTypes = Record<ListTypeKey, string>;
|
|
6
|
-
export interface ListElement extends
|
|
6
|
+
export interface ListElement extends QuadratsElement, WithElementType {
|
|
7
7
|
}
|
|
8
8
|
export interface ListAboveListAndItem {
|
|
9
|
-
list: NodeEntry<
|
|
10
|
-
listItem: NodeEntry<
|
|
9
|
+
list: NodeEntry<QuadratsElement>;
|
|
10
|
+
listItem: NodeEntry<QuadratsElement>;
|
|
11
11
|
}
|
|
12
12
|
export interface ListGetAboveListEntriesOptions {
|
|
13
13
|
at?: Location;
|
|
@@ -17,8 +17,8 @@ export interface List extends Withable {
|
|
|
17
17
|
* An object which keys are `ul`, `ol`, `li` and values are the corresponding element types.
|
|
18
18
|
*/
|
|
19
19
|
types: ListTypes;
|
|
20
|
-
isListElement(node: Node): node is
|
|
21
|
-
isListItemElement(node: Node): node is
|
|
20
|
+
isListElement(node: Node): node is QuadratsElement;
|
|
21
|
+
isListItemElement(node: Node): node is QuadratsElement;
|
|
22
22
|
isSelectionInList(editor: Editor, listTypeKey: ListRootTypeKey): boolean;
|
|
23
23
|
/**
|
|
24
24
|
* If expanded, get the list wrapping the location.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quadrats/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Rytass",
|
|
6
6
|
"homepage": "https://github.com/Quadrats/quadrats#readme",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"url": "https://github.com/Quadrats/quadrats/issues"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@quadrats/core": "^0.
|
|
22
|
-
"@quadrats/locales": "^0.
|
|
23
|
-
"@quadrats/utils": "^0.
|
|
21
|
+
"@quadrats/core": "^0.5.1",
|
|
22
|
+
"@quadrats/locales": "^0.5.0",
|
|
23
|
+
"@quadrats/utils": "^0.5.0"
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -29,7 +29,7 @@ function createReadMore(options = {}) {
|
|
|
29
29
|
insertReadMore,
|
|
30
30
|
with(editor) {
|
|
31
31
|
const { isVoid, normalizeNode } = editor;
|
|
32
|
-
editor.isVoid =
|
|
32
|
+
editor.isVoid = element => element.type === type || isVoid(element);
|
|
33
33
|
editor.normalizeNode = (entry) => {
|
|
34
34
|
const [node, path] = entry;
|
|
35
35
|
if (Element.isElement(node) && node.type === type) {
|
package/read-more/index.cjs.js
CHANGED
|
@@ -34,7 +34,7 @@ function createReadMore(options = {}) {
|
|
|
34
34
|
insertReadMore,
|
|
35
35
|
with(editor) {
|
|
36
36
|
const { isVoid, normalizeNode } = editor;
|
|
37
|
-
editor.isVoid =
|
|
37
|
+
editor.isVoid = element => element.type === type || isVoid(element);
|
|
38
38
|
editor.normalizeNode = (entry) => {
|
|
39
39
|
const [node, path] = entry;
|
|
40
40
|
if (core.Element.isElement(node) && node.type === type) {
|
package/read-more/typings.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Editor,
|
|
2
|
-
export interface ReadMoreElement extends
|
|
1
|
+
import { Editor, QuadratsElement, Text, Withable, WithElementType } from '@quadrats/core';
|
|
2
|
+
export interface ReadMoreElement extends QuadratsElement, WithElementType {
|
|
3
3
|
children: [Text];
|
|
4
4
|
}
|
|
5
5
|
export interface ReadMore extends WithElementType, Withable {
|