@ekz/lexical-overflow 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EkzLexicalOverflow.dev.js +71 -0
- package/EkzLexicalOverflow.dev.mjs +66 -0
- package/EkzLexicalOverflow.js +11 -0
- package/EkzLexicalOverflow.mjs +15 -0
- package/EkzLexicalOverflow.node.mjs +13 -0
- package/EkzLexicalOverflow.prod.js +9 -0
- package/EkzLexicalOverflow.prod.mjs +9 -0
- package/LICENSE +21 -0
- package/LexicalOverflow.js.flow +35 -0
- package/README.md +5 -0
- package/index.d.ts +28 -0
- package/package.json +41 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
var lexical = require('@ekz/lexical');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
15
|
+
*
|
|
16
|
+
* This source code is licensed under the MIT license found in the
|
|
17
|
+
* LICENSE file in the root directory of this source tree.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** @noInheritDoc */
|
|
22
|
+
class OverflowNode extends lexical.ElementNode {
|
|
23
|
+
/** @internal */
|
|
24
|
+
$config() {
|
|
25
|
+
return this.config('overflow', {
|
|
26
|
+
$transform(node) {
|
|
27
|
+
if (node.isEmpty()) {
|
|
28
|
+
node.remove();
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
extends: lexical.ElementNode
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
createDOM(config) {
|
|
35
|
+
const div = document.createElement('span');
|
|
36
|
+
const className = config.theme.characterLimit;
|
|
37
|
+
if (typeof className === 'string') {
|
|
38
|
+
div.className = className;
|
|
39
|
+
}
|
|
40
|
+
return div;
|
|
41
|
+
}
|
|
42
|
+
updateDOM(prevNode, dom) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
insertNewAfter(selection, restoreSelection = true) {
|
|
46
|
+
const parent = this.getParentOrThrow();
|
|
47
|
+
return parent.insertNewAfter(selection, restoreSelection);
|
|
48
|
+
}
|
|
49
|
+
excludeFromCopy() {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function $createOverflowNode() {
|
|
54
|
+
return lexical.$applyNodeReplacement(new OverflowNode());
|
|
55
|
+
}
|
|
56
|
+
function $isOverflowNode(node) {
|
|
57
|
+
return node instanceof OverflowNode;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Configures {@link OverflowNode}
|
|
62
|
+
*/
|
|
63
|
+
const OverflowExtension = lexical.defineExtension({
|
|
64
|
+
name: '@ekz/lexical-overflow',
|
|
65
|
+
nodes: () => [OverflowNode]
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
exports.$createOverflowNode = $createOverflowNode;
|
|
69
|
+
exports.$isOverflowNode = $isOverflowNode;
|
|
70
|
+
exports.OverflowExtension = OverflowExtension;
|
|
71
|
+
exports.OverflowNode = OverflowNode;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { defineExtension, ElementNode, $applyNodeReplacement } from '@ekz/lexical';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the MIT license found in the
|
|
15
|
+
* LICENSE file in the root directory of this source tree.
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** @noInheritDoc */
|
|
20
|
+
class OverflowNode extends ElementNode {
|
|
21
|
+
/** @internal */
|
|
22
|
+
$config() {
|
|
23
|
+
return this.config('overflow', {
|
|
24
|
+
$transform(node) {
|
|
25
|
+
if (node.isEmpty()) {
|
|
26
|
+
node.remove();
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
extends: ElementNode
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
createDOM(config) {
|
|
33
|
+
const div = document.createElement('span');
|
|
34
|
+
const className = config.theme.characterLimit;
|
|
35
|
+
if (typeof className === 'string') {
|
|
36
|
+
div.className = className;
|
|
37
|
+
}
|
|
38
|
+
return div;
|
|
39
|
+
}
|
|
40
|
+
updateDOM(prevNode, dom) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
insertNewAfter(selection, restoreSelection = true) {
|
|
44
|
+
const parent = this.getParentOrThrow();
|
|
45
|
+
return parent.insertNewAfter(selection, restoreSelection);
|
|
46
|
+
}
|
|
47
|
+
excludeFromCopy() {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function $createOverflowNode() {
|
|
52
|
+
return $applyNodeReplacement(new OverflowNode());
|
|
53
|
+
}
|
|
54
|
+
function $isOverflowNode(node) {
|
|
55
|
+
return node instanceof OverflowNode;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Configures {@link OverflowNode}
|
|
60
|
+
*/
|
|
61
|
+
const OverflowExtension = defineExtension({
|
|
62
|
+
name: '@ekz/lexical-overflow',
|
|
63
|
+
nodes: () => [OverflowNode]
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export { $createOverflowNode, $isOverflowNode, OverflowExtension, OverflowNode };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict'
|
|
10
|
+
const EkzLexicalOverflow = process.env.NODE_ENV !== 'production' ? require('./EkzLexicalOverflow.dev.js') : require('./EkzLexicalOverflow.prod.js');
|
|
11
|
+
module.exports = EkzLexicalOverflow;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as modDev from './EkzLexicalOverflow.dev.mjs';
|
|
10
|
+
import * as modProd from './EkzLexicalOverflow.prod.mjs';
|
|
11
|
+
const mod = process.env.NODE_ENV !== 'production' ? modDev : modProd;
|
|
12
|
+
export const $createOverflowNode = mod.$createOverflowNode;
|
|
13
|
+
export const $isOverflowNode = mod.$isOverflowNode;
|
|
14
|
+
export const OverflowExtension = mod.OverflowExtension;
|
|
15
|
+
export const OverflowNode = mod.OverflowNode;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const mod = await (process.env.NODE_ENV !== 'production' ? import('./EkzLexicalOverflow.dev.mjs') : import('./EkzLexicalOverflow.prod.mjs'));
|
|
10
|
+
export const $createOverflowNode = mod.$createOverflowNode;
|
|
11
|
+
export const $isOverflowNode = mod.$isOverflowNode;
|
|
12
|
+
export const OverflowExtension = mod.OverflowExtension;
|
|
13
|
+
export const OverflowNode = mod.OverflowNode;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
"use strict";var e=require("@ekz/lexical");class t extends e.ElementNode{$config(){return this.config("overflow",{$transform(e){e.isEmpty()&&e.remove()},extends:e.ElementNode})}createDOM(e){const t=document.createElement("span"),r=e.theme.characterLimit;return"string"==typeof r&&(t.className=r),t}updateDOM(e,t){return!1}insertNewAfter(e,t=!0){return this.getParentOrThrow().insertNewAfter(e,t)}excludeFromCopy(){return!0}}const r=e.defineExtension({name:"@ekz/lexical-overflow",nodes:()=>[t]});exports.$createOverflowNode=function(){return e.$applyNodeReplacement(new t)},exports.$isOverflowNode=function(e){return e instanceof t},exports.OverflowExtension=r,exports.OverflowNode=t;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import{defineExtension as e,ElementNode as t,$applyNodeReplacement as r}from"@ekz/lexical";class n extends t{$config(){return this.config("overflow",{$transform(e){e.isEmpty()&&e.remove()},extends:t})}createDOM(e){const t=document.createElement("span"),r=e.theme.characterLimit;return"string"==typeof r&&(t.className=r),t}updateDOM(e,t){return!1}insertNewAfter(e,t=!0){return this.getParentOrThrow().insertNewAfter(e,t)}excludeFromCopy(){return!0}}function o(){return r(new n)}function s(e){return e instanceof n}const c=e({name:"@ekz/lexical-overflow",nodes:()=>[n]});export{o as $createOverflowNode,s as $isOverflowNode,c as OverflowExtension,n as OverflowNode};
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict
|
|
8
|
+
*/
|
|
9
|
+
import type {
|
|
10
|
+
EditorConfig,
|
|
11
|
+
LexicalNode,
|
|
12
|
+
NodeKey,
|
|
13
|
+
RangeSelection,
|
|
14
|
+
SerializedElementNode,
|
|
15
|
+
LexicalExtension,
|
|
16
|
+
ExtensionConfigBase,
|
|
17
|
+
} from '@ekz/lexical';
|
|
18
|
+
import {ElementNode} from '@ekz/lexical';
|
|
19
|
+
declare export class OverflowNode extends ElementNode {
|
|
20
|
+
static getType(): string;
|
|
21
|
+
static clone(node: OverflowNode): OverflowNode;
|
|
22
|
+
constructor(key?: NodeKey): void;
|
|
23
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
24
|
+
insertNewAfter(selection: RangeSelection): null | LexicalNode;
|
|
25
|
+
excludeFromCopy(): boolean;
|
|
26
|
+
static importJSON(serializedNode: SerializedOverflowNode): OverflowNode;
|
|
27
|
+
}
|
|
28
|
+
declare export function $createOverflowNode(): OverflowNode;
|
|
29
|
+
declare export function $isOverflowNode(
|
|
30
|
+
node: ?LexicalNode,
|
|
31
|
+
): node is OverflowNode;
|
|
32
|
+
|
|
33
|
+
export type SerializedOverflowNode = SerializedElementNode;
|
|
34
|
+
|
|
35
|
+
declare export var OverflowExtension: LexicalExtension<ExtensionConfigBase, "@ekz/lexical-overflow", void, void>;
|
package/README.md
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { EditorConfig, LexicalNode, RangeSelection, SerializedElementNode } from '@ekz/lexical';
|
|
9
|
+
import { ElementNode } from '@ekz/lexical';
|
|
10
|
+
export type SerializedOverflowNode = SerializedElementNode;
|
|
11
|
+
/** @noInheritDoc */
|
|
12
|
+
export declare class OverflowNode extends ElementNode {
|
|
13
|
+
/** @internal */
|
|
14
|
+
$config(): import("@ekz/lexical").StaticNodeConfigRecord<"overflow", {
|
|
15
|
+
$transform(node: OverflowNode): void;
|
|
16
|
+
extends: typeof ElementNode;
|
|
17
|
+
}>;
|
|
18
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
19
|
+
updateDOM(prevNode: this, dom: HTMLElement): boolean;
|
|
20
|
+
insertNewAfter(selection: RangeSelection, restoreSelection?: boolean): null | LexicalNode;
|
|
21
|
+
excludeFromCopy(): boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function $createOverflowNode(): OverflowNode;
|
|
24
|
+
export declare function $isOverflowNode(node: LexicalNode | null | undefined): node is OverflowNode;
|
|
25
|
+
/**
|
|
26
|
+
* Configures {@link OverflowNode}
|
|
27
|
+
*/
|
|
28
|
+
export declare const OverflowExtension: import("@ekz/lexical").LexicalExtension<import("@ekz/lexical").ExtensionConfigBase, "@ekz/lexical-overflow", unknown, unknown>;
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ekz/lexical-overflow",
|
|
3
|
+
"description": "This package contains selection overflow helpers and nodes for Lexical.",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"lexical",
|
|
6
|
+
"editor",
|
|
7
|
+
"rich-text",
|
|
8
|
+
"overflow"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"version": "0.40.0",
|
|
12
|
+
"main": "LexicalOverflow.js",
|
|
13
|
+
"types": "index.d.ts",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/facebook/lexical.git",
|
|
17
|
+
"directory": "packages/lexical-overflow"
|
|
18
|
+
},
|
|
19
|
+
"module": "LexicalOverflow.mjs",
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": {
|
|
24
|
+
"types": "./index.d.ts",
|
|
25
|
+
"development": "./LexicalOverflow.dev.mjs",
|
|
26
|
+
"production": "./LexicalOverflow.prod.mjs",
|
|
27
|
+
"node": "./LexicalOverflow.node.mjs",
|
|
28
|
+
"default": "./LexicalOverflow.mjs"
|
|
29
|
+
},
|
|
30
|
+
"require": {
|
|
31
|
+
"types": "./index.d.ts",
|
|
32
|
+
"development": "./LexicalOverflow.dev.js",
|
|
33
|
+
"production": "./LexicalOverflow.prod.js",
|
|
34
|
+
"default": "./LexicalOverflow.js"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@ekz/lexical": "0.40.0"
|
|
40
|
+
}
|
|
41
|
+
}
|