@lowdefy/blocks-tiptap 0.0.0-experimental-20260428103147
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 +201 -0
- package/README.md +1 -0
- package/dist/blocks/TiptapInput/TiptapInput.js +170 -0
- package/dist/blocks/TiptapInput/e2e.js +25 -0
- package/dist/blocks/TiptapInput/meta.js +212 -0
- package/dist/blocks/TiptapInput/style.module.css +60 -0
- package/dist/blocks/TiptapInput/useTiptapState.js +104 -0
- package/dist/blocks/TiptapMentionInput/MentionList.js +69 -0
- package/dist/blocks/TiptapMentionInput/TiptapMentionInput.js +238 -0
- package/dist/blocks/TiptapMentionInput/e2e.js +25 -0
- package/dist/blocks/TiptapMentionInput/meta.js +231 -0
- package/dist/blocks/TiptapMentionInput/style.module.css +96 -0
- package/dist/blocks/TiptapMentionInput/suggestion.js +82 -0
- package/dist/blocks/TiptapMentionInput/useTiptapMentionState.js +108 -0
- package/dist/blocks/utils/PopoverMenu.js +82 -0
- package/dist/blocks/utils/buildExtensions.js +127 -0
- package/dist/blocks/utils/computeHeightStyle.js +57 -0
- package/dist/blocks/utils/s3FileUpload.js +51 -0
- package/dist/blocks/utils/statusClass.js +24 -0
- package/dist/blocks/utils/style.module.css +128 -0
- package/dist/blocks.js +16 -0
- package/dist/e2e.js +16 -0
- package/dist/metas.js +16 -0
- package/dist/types.js +17 -0
- package/package.json +87 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @lowdefy/blocks-tiptap
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import React, { useEffect } from 'react';
|
|
16
|
+
import { withBlockDefaults } from '@lowdefy/block-utils';
|
|
17
|
+
import { type } from '@lowdefy/helpers';
|
|
18
|
+
import { useEditor, EditorContent } from '@tiptap/react';
|
|
19
|
+
import Label from '@lowdefy/blocks-antd/blocks/Label/Label.js';
|
|
20
|
+
import PopoverMenu from '../utils/PopoverMenu.js';
|
|
21
|
+
import buildExtensions from '../utils/buildExtensions.js';
|
|
22
|
+
import computeHeightStyle from '../utils/computeHeightStyle.js';
|
|
23
|
+
import statusClass from '../utils/statusClass.js';
|
|
24
|
+
import useTiptapState from './useTiptapState.js';
|
|
25
|
+
import './style.module.css';
|
|
26
|
+
const TiptapInput = ({ blockId, components: { Icon, Link }, events, loading, methods, properties, required, validation, value })=>{
|
|
27
|
+
const { emit, insertImage } = useTiptapState({
|
|
28
|
+
value,
|
|
29
|
+
methods
|
|
30
|
+
});
|
|
31
|
+
const disabled = properties.disabled === true || loading;
|
|
32
|
+
const uploadEnabled = !type.isNone(properties.s3PostPolicyRequestId);
|
|
33
|
+
const extensions = buildExtensions({
|
|
34
|
+
properties,
|
|
35
|
+
insertImage,
|
|
36
|
+
uploadEnabled
|
|
37
|
+
});
|
|
38
|
+
const heightStyle = computeHeightStyle({
|
|
39
|
+
rows: properties.rows,
|
|
40
|
+
autoSize: properties.autoSize
|
|
41
|
+
});
|
|
42
|
+
const editor = useEditor({
|
|
43
|
+
extensions,
|
|
44
|
+
content: value?.html || '',
|
|
45
|
+
editable: ()=>!disabled,
|
|
46
|
+
onUpdate ({ editor }) {
|
|
47
|
+
// User-driven change. Emit the full derived value to Lowdefy.
|
|
48
|
+
emit(editor);
|
|
49
|
+
methods.triggerEvent({
|
|
50
|
+
name: 'onChange'
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
// Register upload-policy event once (if configured).
|
|
55
|
+
useEffect(()=>{
|
|
56
|
+
if (!uploadEnabled) return;
|
|
57
|
+
methods.registerEvent({
|
|
58
|
+
name: '__getS3PostPolicy',
|
|
59
|
+
actions: [
|
|
60
|
+
{
|
|
61
|
+
id: '__getS3PostPolicy',
|
|
62
|
+
type: 'Request',
|
|
63
|
+
params: [
|
|
64
|
+
properties.s3PostPolicyRequestId
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
});
|
|
69
|
+
}, []);
|
|
70
|
+
// Register methods as soon as the editor is available.
|
|
71
|
+
useEffect(()=>{
|
|
72
|
+
if (!editor) return;
|
|
73
|
+
methods.registerMethod('clear', ()=>{
|
|
74
|
+
editor.commands.clearContent();
|
|
75
|
+
emit(editor);
|
|
76
|
+
});
|
|
77
|
+
methods.registerMethod('setContent', (args)=>{
|
|
78
|
+
editor.commands.setContent(args?.html ?? '');
|
|
79
|
+
emit(editor);
|
|
80
|
+
});
|
|
81
|
+
methods.registerMethod('focus', ()=>{
|
|
82
|
+
editor.commands.focus();
|
|
83
|
+
});
|
|
84
|
+
}, [
|
|
85
|
+
editor
|
|
86
|
+
]);
|
|
87
|
+
// External value.html → editor sync. One-way only: we read value.html and
|
|
88
|
+
// push it into the editor with setContent(..., false) so tiptap's onUpdate
|
|
89
|
+
// does not fire. No write-back via emit() — that would race with concurrent
|
|
90
|
+
// SetState calls (child effects fire before parent effects, so a sibling's
|
|
91
|
+
// onMount SetState could be overwritten by our derived emit). Derived
|
|
92
|
+
// fields (text/markdown/fileList) are populated on user interaction via
|
|
93
|
+
// onUpdate; downstream consumers of seeded content should read value.html
|
|
94
|
+
// directly, or include the fields they need in their SetState payload.
|
|
95
|
+
useEffect(()=>{
|
|
96
|
+
if (!editor) return;
|
|
97
|
+
const next = value?.html ?? '';
|
|
98
|
+
const current = editor.getHTML();
|
|
99
|
+
if (next !== current) {
|
|
100
|
+
editor.commands.setContent(next, false);
|
|
101
|
+
}
|
|
102
|
+
}, [
|
|
103
|
+
value?.html,
|
|
104
|
+
editor
|
|
105
|
+
]);
|
|
106
|
+
useEffect(()=>{
|
|
107
|
+
if (!editor) return;
|
|
108
|
+
editor.setOptions({
|
|
109
|
+
editable: !disabled
|
|
110
|
+
});
|
|
111
|
+
}, [
|
|
112
|
+
editor,
|
|
113
|
+
disabled
|
|
114
|
+
]);
|
|
115
|
+
useEffect(()=>{
|
|
116
|
+
if (!editor) return;
|
|
117
|
+
const placeholderExt = editor.extensionManager.extensions.find((extension)=>extension.name === 'placeholder');
|
|
118
|
+
if (placeholderExt) {
|
|
119
|
+
placeholderExt.options.placeholder = properties.placeholder ?? '';
|
|
120
|
+
editor.view.dispatch(editor.state.tr);
|
|
121
|
+
}
|
|
122
|
+
}, [
|
|
123
|
+
editor,
|
|
124
|
+
properties.placeholder
|
|
125
|
+
]);
|
|
126
|
+
const wrapperClass = [
|
|
127
|
+
'tiptap-wrapper',
|
|
128
|
+
properties.bordered === false ? 'tiptap-wrapper-borderless' : '',
|
|
129
|
+
disabled ? 'tiptap-wrapper-disabled' : '',
|
|
130
|
+
statusClass(validation?.status)
|
|
131
|
+
].filter(Boolean).join(' ');
|
|
132
|
+
const wrapperStyle = {
|
|
133
|
+
padding: 0,
|
|
134
|
+
...heightStyle,
|
|
135
|
+
...properties.inputStyle,
|
|
136
|
+
...properties.style
|
|
137
|
+
};
|
|
138
|
+
return /*#__PURE__*/ React.createElement(Label, {
|
|
139
|
+
blockId: blockId,
|
|
140
|
+
components: {
|
|
141
|
+
Icon,
|
|
142
|
+
Link
|
|
143
|
+
},
|
|
144
|
+
events: events,
|
|
145
|
+
properties: {
|
|
146
|
+
title: properties.title,
|
|
147
|
+
size: properties.size,
|
|
148
|
+
...properties.label
|
|
149
|
+
},
|
|
150
|
+
required: required,
|
|
151
|
+
validation: validation,
|
|
152
|
+
content: {
|
|
153
|
+
content: ()=>{
|
|
154
|
+
if (!editor) {
|
|
155
|
+
return /*#__PURE__*/ React.createElement("div", null);
|
|
156
|
+
}
|
|
157
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(EditorContent, {
|
|
158
|
+
id: `${blockId}_input`,
|
|
159
|
+
editor: editor,
|
|
160
|
+
className: wrapperClass,
|
|
161
|
+
style: wrapperStyle
|
|
162
|
+
}), !disabled && /*#__PURE__*/ React.createElement(PopoverMenu, {
|
|
163
|
+
editor: editor,
|
|
164
|
+
Icon: Icon
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
export default withBlockDefaults(TiptapInput);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import { createBlockHelper, escapeId } from '@lowdefy/e2e-utils';
|
|
16
|
+
import { expect } from '@playwright/test';
|
|
17
|
+
const locator = (page, blockId)=>page.locator(`#${escapeId(blockId)}_input .ProseMirror`).first();
|
|
18
|
+
export default createBlockHelper({
|
|
19
|
+
locator,
|
|
20
|
+
expect: {
|
|
21
|
+
containsText: (page, blockId, text)=>expect(locator(page, blockId)).toContainText(text),
|
|
22
|
+
containsHtml: (page, blockId, selector)=>expect(locator(page, blockId).locator(selector)).toBeVisible(),
|
|
23
|
+
isEmpty: (page, blockId)=>expect(locator(page, blockId)).toHaveText('')
|
|
24
|
+
}
|
|
25
|
+
});
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ export default {
|
|
16
|
+
category: 'input',
|
|
17
|
+
icons: [],
|
|
18
|
+
valueType: 'object',
|
|
19
|
+
initValue: {
|
|
20
|
+
html: null,
|
|
21
|
+
text: null,
|
|
22
|
+
markdown: null,
|
|
23
|
+
fileList: []
|
|
24
|
+
},
|
|
25
|
+
events: {
|
|
26
|
+
onChange: 'Trigger action when the editor content is changed.'
|
|
27
|
+
},
|
|
28
|
+
properties: {
|
|
29
|
+
type: 'object',
|
|
30
|
+
additionalProperties: false,
|
|
31
|
+
properties: {
|
|
32
|
+
allowedMimeTypes: {
|
|
33
|
+
type: 'array',
|
|
34
|
+
items: {
|
|
35
|
+
type: 'string'
|
|
36
|
+
},
|
|
37
|
+
description: 'Mime-types accepted by the drag/drop and paste file handler. Defaults to common image types (jpeg, png, gif, webp). Only used when s3PostPolicyRequestId is set.'
|
|
38
|
+
},
|
|
39
|
+
autoSize: {
|
|
40
|
+
oneOf: [
|
|
41
|
+
{
|
|
42
|
+
type: 'boolean',
|
|
43
|
+
default: false,
|
|
44
|
+
description: 'When true the editor grows with its content and has no max height.'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: 'object',
|
|
48
|
+
description: 'Constrain the editor height with a minimum and/or maximum row count.',
|
|
49
|
+
properties: {
|
|
50
|
+
minRows: {
|
|
51
|
+
type: 'integer',
|
|
52
|
+
minimum: 1,
|
|
53
|
+
description: 'Minimum visible rows before content overflows.'
|
|
54
|
+
},
|
|
55
|
+
maxRows: {
|
|
56
|
+
type: 'integer',
|
|
57
|
+
minimum: 1,
|
|
58
|
+
description: 'Maximum visible rows; beyond this the editor scrolls vertically.'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
description: 'Either a boolean (true to auto-grow without a cap) or an object with minRows/maxRows. Ignored when `rows` is set.'
|
|
64
|
+
},
|
|
65
|
+
bordered: {
|
|
66
|
+
type: 'boolean',
|
|
67
|
+
default: true,
|
|
68
|
+
description: 'Whether the editor renders with a border.'
|
|
69
|
+
},
|
|
70
|
+
disabled: {
|
|
71
|
+
type: 'boolean',
|
|
72
|
+
default: false,
|
|
73
|
+
description: 'Render the editor as read-only.'
|
|
74
|
+
},
|
|
75
|
+
highlight: {
|
|
76
|
+
type: 'object',
|
|
77
|
+
description: 'Text highlight extension settings.',
|
|
78
|
+
additionalProperties: false,
|
|
79
|
+
properties: {
|
|
80
|
+
disabled: {
|
|
81
|
+
type: 'boolean',
|
|
82
|
+
default: false,
|
|
83
|
+
description: 'Disable the Highlight extension and its bubble-menu color swatches.'
|
|
84
|
+
},
|
|
85
|
+
multicolor: {
|
|
86
|
+
type: 'boolean',
|
|
87
|
+
default: true,
|
|
88
|
+
description: 'Allow highlights to carry a color value. Disable for single-color.'
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
image: {
|
|
93
|
+
type: 'object',
|
|
94
|
+
description: 'Image extension settings.',
|
|
95
|
+
additionalProperties: false,
|
|
96
|
+
properties: {
|
|
97
|
+
disabled: {
|
|
98
|
+
type: 'boolean',
|
|
99
|
+
default: false,
|
|
100
|
+
description: 'Disable the Image extension.'
|
|
101
|
+
},
|
|
102
|
+
maxWidth: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
default: '80%',
|
|
105
|
+
description: 'Inline CSS max-width applied to inserted images.'
|
|
106
|
+
},
|
|
107
|
+
zoom: {
|
|
108
|
+
type: 'number',
|
|
109
|
+
default: 0.5,
|
|
110
|
+
description: 'Inline CSS zoom factor applied to inserted images.'
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
inputStyle: {
|
|
115
|
+
type: 'object',
|
|
116
|
+
description: 'Inline style applied to the editable area of the editor.',
|
|
117
|
+
docs: {
|
|
118
|
+
displayType: 'yaml'
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
label: {
|
|
122
|
+
type: 'object',
|
|
123
|
+
description: 'Label configuration forwarded to the Lowdefy Label block.',
|
|
124
|
+
docs: {
|
|
125
|
+
displayType: 'yaml'
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
link: {
|
|
129
|
+
type: 'object',
|
|
130
|
+
description: 'Link extension settings.',
|
|
131
|
+
additionalProperties: false,
|
|
132
|
+
properties: {
|
|
133
|
+
disabled: {
|
|
134
|
+
type: 'boolean',
|
|
135
|
+
default: false,
|
|
136
|
+
description: 'Disable the Link extension.'
|
|
137
|
+
},
|
|
138
|
+
autolink: {
|
|
139
|
+
type: 'boolean',
|
|
140
|
+
default: true,
|
|
141
|
+
description: 'Auto-convert URLs typed in the editor to links.'
|
|
142
|
+
},
|
|
143
|
+
linkOnPaste: {
|
|
144
|
+
type: 'boolean',
|
|
145
|
+
default: true,
|
|
146
|
+
description: 'Convert pasted URLs to links.'
|
|
147
|
+
},
|
|
148
|
+
openOnClick: {
|
|
149
|
+
type: 'boolean',
|
|
150
|
+
default: true,
|
|
151
|
+
description: 'Open links in a new tab when clicked in view mode.'
|
|
152
|
+
},
|
|
153
|
+
defaultProtocol: {
|
|
154
|
+
type: 'string',
|
|
155
|
+
default: 'https',
|
|
156
|
+
description: 'Protocol prefixed to URLs that omit one (e.g. "https").'
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
placeholder: {
|
|
161
|
+
type: 'string',
|
|
162
|
+
description: 'Placeholder shown when the editor is empty.'
|
|
163
|
+
},
|
|
164
|
+
rows: {
|
|
165
|
+
type: 'integer',
|
|
166
|
+
minimum: 1,
|
|
167
|
+
description: 'Fix the editor height to exactly this many rows. Takes precedence over autoSize.'
|
|
168
|
+
},
|
|
169
|
+
s3PostPolicyRequestId: {
|
|
170
|
+
type: 'string',
|
|
171
|
+
description: 'Id of a request that returns an S3 presigned POST policy. When set, images dragged or pasted into the editor are uploaded via that policy and inserted as <img> nodes. Leave unset to disable image uploads.'
|
|
172
|
+
},
|
|
173
|
+
size: {
|
|
174
|
+
type: 'string',
|
|
175
|
+
enum: [
|
|
176
|
+
'small',
|
|
177
|
+
'middle',
|
|
178
|
+
'large'
|
|
179
|
+
],
|
|
180
|
+
description: 'Label size forwarded to the Label block.'
|
|
181
|
+
},
|
|
182
|
+
starterKit: {
|
|
183
|
+
type: 'object',
|
|
184
|
+
description: 'Options forwarded to TipTap StarterKit (https://tiptap.dev/docs/editor/extensions/functionality/starterkit). Use this to disable bundled extensions (e.g. {heading: false, codeBlock: false}).',
|
|
185
|
+
docs: {
|
|
186
|
+
displayType: 'yaml'
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
table: {
|
|
190
|
+
type: 'object',
|
|
191
|
+
description: 'Table extension settings.',
|
|
192
|
+
additionalProperties: false,
|
|
193
|
+
properties: {
|
|
194
|
+
disabled: {
|
|
195
|
+
type: 'boolean',
|
|
196
|
+
default: false,
|
|
197
|
+
description: 'Disable the Table extension and its row/header/cell nodes.'
|
|
198
|
+
},
|
|
199
|
+
resizable: {
|
|
200
|
+
type: 'boolean',
|
|
201
|
+
default: true,
|
|
202
|
+
description: 'Allow column resizing with a drag handle.'
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
title: {
|
|
207
|
+
type: 'string',
|
|
208
|
+
description: 'Label title shown above the editor.'
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
@import '../utils/style.module.css';
|
|
2
|
+
|
|
3
|
+
:global(.tableWrapper),
|
|
4
|
+
:global(.tiptap-table) {
|
|
5
|
+
display: block;
|
|
6
|
+
overflow-x: auto;
|
|
7
|
+
max-width: 80%;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:global(.tableWrapper) :global(table),
|
|
11
|
+
:global(.tiptap-table) :global(table) {
|
|
12
|
+
border-collapse: collapse;
|
|
13
|
+
width: 100%;
|
|
14
|
+
min-width: 75px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:global(.tableWrapper) :global(colgroup) :global(col),
|
|
18
|
+
:global(.tiptap-table) :global(colgroup) :global(col) {
|
|
19
|
+
width: auto;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:global(.tableWrapper) :global(table),
|
|
23
|
+
:global(.tableWrapper) :global(th),
|
|
24
|
+
:global(.tableWrapper) :global(td),
|
|
25
|
+
:global(.tiptap-table) :global(table),
|
|
26
|
+
:global(.tiptap-table) :global(th),
|
|
27
|
+
:global(.tiptap-table) :global(td) {
|
|
28
|
+
border: 1px solid var(--ant-color-border);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
:global(.tableWrapper) :global(th),
|
|
32
|
+
:global(.tableWrapper) :global(td),
|
|
33
|
+
:global(.tiptap-table) :global(th),
|
|
34
|
+
:global(.tiptap-table) :global(td) {
|
|
35
|
+
padding: 2px;
|
|
36
|
+
text-align: left;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:global(.tableWrapper) :global(th),
|
|
40
|
+
:global(.tiptap-table) :global(th) {
|
|
41
|
+
background-color: var(--ant-color-fill-tertiary);
|
|
42
|
+
font-weight: bold;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
:global(.tableWrapper) :global(tr):nth-child(even),
|
|
46
|
+
:global(.tiptap-table) :global(tr):nth-child(even) {
|
|
47
|
+
background-color: var(--ant-color-fill-quaternary);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
:global(.tableWrapper) :global(tr):hover,
|
|
51
|
+
:global(.tiptap-table) :global(tr):hover {
|
|
52
|
+
background-color: var(--ant-color-primary-bg);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
:global(.tableWrapper) :global(td) :global(p),
|
|
56
|
+
:global(.tableWrapper) :global(th) :global(p),
|
|
57
|
+
:global(.tiptap-table) :global(td) :global(p),
|
|
58
|
+
:global(.tiptap-table) :global(th) :global(p) {
|
|
59
|
+
margin: 0;
|
|
60
|
+
}
|