@lexical/overflow 0.1.17
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/LICENSE +21 -0
- package/LexicalOverflow.d.ts +21 -0
- package/LexicalOverflow.dev.js +67 -0
- package/LexicalOverflow.js +9 -0
- package/LexicalOverflow.js.flow +23 -0
- package/LexicalOverflow.prod.js +8 -0
- package/README.md +3 -0
- package/package.json +21 -0
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,21 @@
|
|
|
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 {EditorConfig, LexicalNode, NodeKey, RangeSelection} from 'lexical';
|
|
10
|
+
import {ElementNode} from 'lexical';
|
|
11
|
+
export declare class OverflowNode extends ElementNode {
|
|
12
|
+
static getType(): string;
|
|
13
|
+
static clone(node: OverflowNode): OverflowNode;
|
|
14
|
+
constructor(key?: NodeKey): void;
|
|
15
|
+
createDOM<EditorContext>(config: EditorConfig<EditorContext>): HTMLElement;
|
|
16
|
+
updateDOM(prevNode: OverflowNode, dom: HTMLElement): boolean;
|
|
17
|
+
insertNewAfter(selection: RangeSelection): null | LexicalNode;
|
|
18
|
+
excludeFromCopy(): boolean;
|
|
19
|
+
}
|
|
20
|
+
export function $createOverflowNode(): OverflowNode;
|
|
21
|
+
export function $isOverflowNode(node: ?LexicalNode): boolean;
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
var lexical = require('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
|
+
class OverflowNode extends lexical.ElementNode {
|
|
20
|
+
static getType() {
|
|
21
|
+
return 'overflow';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static clone(node) {
|
|
25
|
+
return new OverflowNode(node.__key);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
constructor(key) {
|
|
29
|
+
super(key);
|
|
30
|
+
this.__type = 'overflow';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
createDOM(config) {
|
|
34
|
+
const div = document.createElement('span');
|
|
35
|
+
const className = config.theme.characterLimit;
|
|
36
|
+
|
|
37
|
+
if (typeof className === 'string') {
|
|
38
|
+
div.className = className;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return div;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
updateDOM(prevNode, dom) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
insertNewAfter(selection) {
|
|
49
|
+
const parent = this.getParentOrThrow();
|
|
50
|
+
return parent.insertNewAfter(selection);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
excludeFromCopy() {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
function $createOverflowNode() {
|
|
59
|
+
return new OverflowNode();
|
|
60
|
+
}
|
|
61
|
+
function $isOverflowNode(node) {
|
|
62
|
+
return node instanceof OverflowNode;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
exports.$createOverflowNode = $createOverflowNode;
|
|
66
|
+
exports.$isOverflowNode = $isOverflowNode;
|
|
67
|
+
exports.OverflowNode = 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
|
+
'use strict'
|
|
8
|
+
const LexicalOverflow = process.env.NODE_ENV === 'development' ? require('./LexicalOverflow.dev.js') : require('./LexicalOverflow.prod.js')
|
|
9
|
+
module.exports = LexicalOverflow;
|
|
@@ -0,0 +1,23 @@
|
|
|
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 {EditorConfig, LexicalNode, NodeKey, RangeSelection} from 'lexical';
|
|
10
|
+
import {ElementNode} from 'lexical';
|
|
11
|
+
declare export class OverflowNode extends ElementNode {
|
|
12
|
+
static getType(): string;
|
|
13
|
+
static clone(node: OverflowNode): OverflowNode;
|
|
14
|
+
constructor(key?: NodeKey): void;
|
|
15
|
+
createDOM<EditorContext>(config: EditorConfig<EditorContext>): HTMLElement;
|
|
16
|
+
updateDOM(prevNode: OverflowNode, dom: HTMLElement): boolean;
|
|
17
|
+
insertNewAfter(selection: RangeSelection): null | LexicalNode;
|
|
18
|
+
excludeFromCopy(): boolean;
|
|
19
|
+
}
|
|
20
|
+
declare export function $createOverflowNode(): OverflowNode;
|
|
21
|
+
declare export function $isOverflowNode(
|
|
22
|
+
node: ?LexicalNode,
|
|
23
|
+
): boolean %checks(node instanceof OverflowNode);
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
var b=require("lexical");class d extends b.ElementNode{static getType(){return"overflow"}static clone(a){return new d(a.__key)}constructor(a){super(a);this.__type="overflow"}createDOM(a){const c=document.createElement("span");a=a.theme.characterLimit;"string"===typeof a&&(c.className=a);return c}updateDOM(){return!1}insertNewAfter(a){return this.getParentOrThrow().insertNewAfter(a)}excludeFromCopy(){return!0}}exports.$createOverflowNode=function(){return new d};
|
|
8
|
+
exports.$isOverflowNode=function(a){return a instanceof d};exports.OverflowNode=d;
|
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@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.1.17",
|
|
12
|
+
"main": "LexicalOverflow.js",
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"lexical": "0.1.17"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/facebook/lexical",
|
|
19
|
+
"directory": "packages/lexical-overflow"
|
|
20
|
+
}
|
|
21
|
+
}
|