ep_data_tables 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +77 -0
- package/collectContentPre.js +87 -0
- package/ep.json +28 -0
- package/locales/en.json +45 -0
- package/package.json +47 -0
- package/static/css/caret.css +13 -0
- package/static/css/datatables-editor.css +167 -0
- package/static/css/table-menu.css +100 -0
- package/static/js/client_hooks.js +4441 -0
- package/static/js/collector_hooks.js +13 -0
- package/static/js/datatables-renderer.js +157 -0
- package/static/js/index.js +45 -0
- package/static/js/initialisation.js +249 -0
- package/templates/datatablesEditbarButtons.ejs +50 -0
- package/templates/datatablesScripts.ejs +16 -0
- package/templates/datatablesScriptsTimeslider.ejs +1 -0
- package/templates/styles.ejs +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
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 2013 THE ETHERPAD FOUNDATION
|
|
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.
|
|
202
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# ep_data_tables — BETA
|
|
2
|
+
|
|
3
|
+
Etherpad tables via line based & character based styles
|
|
4
|
+
==========================================
|
|
5
|
+
|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## Purpose
|
|
10
|
+
|
|
11
|
+
The plugin is designed to support resilient and feature rich editing within data tables, while being transparent to other styles that might share the line. So, you can/should be able to insert any character based styles such as hyperlinks, font color/size/superscript/subscript, images (from ep_images_extended), etc into cells and they will display as usual. It also supports authorship coloring. Some block styles work but YMMV, ep_align is fully compatible.
|
|
12
|
+
|
|
13
|
+
Additionally, some other features are supported like real time column resizing and interactions via the tables toolbar.
|
|
14
|
+
|
|
15
|
+
It is based on ep_tables5 but takes the design in a different direction - ep_tables5 and preceding tables plugins stored the table JSON as text within the pad, this keeps the structure outside of the pad
|
|
16
|
+
|
|
17
|
+
Does not currently support the timeslider. Actually, I have no idea how to make it support the timeslider. Doesn't support HTML export. Some copy/paste actions can affect the table structure (I am dealing with this in another plugin ep_docx_html_customizer right now, but that is also WIP). Note this plugin is based on/branching from ep_tables5, more attribution will be added soon.
|
|
18
|
+
|
|
19
|
+
There are probably 1000's of unnecessary lines of code in the plugin, I am planning to clean it up soon, but I have not had time yet. The code was mainly generated by LLMs as I have been brute forcing the features I want for an etherpad based project. o3 summary below:
|
|
20
|
+
|
|
21
|
+
## High-level data flow
|
|
22
|
+
|
|
23
|
+
1. **EEJS injection (server, `static/js/index.js`)**
|
|
24
|
+
On pad load the server injects a small toolbar button, inline CSS and a `<script>` tag that registers the client hooks.
|
|
25
|
+
2. **UI bootstrap (client, `static/js/initialisation.js`)**
|
|
26
|
+
`postAceInit` builds a context menu and a grid picker (like Google Docs) for selecting the initial table size.
|
|
27
|
+
Menu actions call the two ACE helpers that the plugin exposes:
|
|
28
|
+
• `ace_createTableViaAttributes(rows, cols)`
|
|
29
|
+
• `ace_doDatatableOptions(action)` (row/column add-delete, etc.)
|
|
30
|
+
3. **Table creation (`static/js/client_hooks.js`)**
|
|
31
|
+
`ace_createTableViaAttributes` calculates a *table id*, creates the requested number of Etherpad lines and, for each line, applies an attribute of the form
|
|
32
|
+
`tbljson::<base64(JSON)>`
|
|
33
|
+
The JSON contains `{ tblId, row, cols, columnWidths, … }`.
|
|
34
|
+
4. **Attribute ↔ class round-trip**
|
|
35
|
+
`aceAttribsToClasses` converts the attribute into a DOM class (`tbljson-<base64>`) so the value survives copy-paste and import.
|
|
36
|
+
On the way back in (export, import, or timeslider replay) the server hook `collectContentPre.js` decodes the class and restores the attribute.
|
|
37
|
+
5. **DOM rendering inside the editor**
|
|
38
|
+
`acePostWriteDomLineHTML` runs every time Etherpad flushes a line to the iframe.
|
|
39
|
+
If it sees our attribute it replaces the plain `<span>` with:
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<table class="dataTable" …><tr><td>…</td>…</tr></table>
|
|
43
|
+
```
|
|
44
|
+
Resize handles are injected into the first row, navigation helpers capture **Tab/Arrow** keys, etc.
|
|
45
|
+
6. **Live editing helpers**
|
|
46
|
+
Navigation helpers (`navigateToNextCell`, `navigateToCellBelow`, …) translate cursor moves into *line + offset* updates so Etherpad OT remains sane.
|
|
47
|
+
Structural changes (`addTableRowBelowWithText`, `deleteTableColumnWithText`, …) map UI actions to document operations by:
|
|
48
|
+
• locating the affected lines via `getTableLineMetadata`
|
|
49
|
+
• cloning / deleting lines
|
|
50
|
+
• updating the JSON attribute.
|
|
51
|
+
7. **Column resizing**
|
|
52
|
+
`startColumnResize` overlays a transparent drag handle.
|
|
53
|
+
On mouse-up the new percentage widths are written back into each row's JSON and pushed through `documentAttributeManager`.
|
|
54
|
+
9. **Styling (`static/css`)**
|
|
55
|
+
• `datatables-editor.css` draws borders, equalises row height, hides author-colour spans, and styles resize handles.
|
|
56
|
+
• `caret.css` keeps the caret visible in otherwise empty cells.
|
|
57
|
+
• `table-menu.css` skins the context menu.
|
|
58
|
+
|
|
59
|
+
## File map
|
|
60
|
+
|
|
61
|
+
| File / directory | Role |
|
|
62
|
+
|------------------|------|
|
|
63
|
+
| `ep.json` | Hook registration |
|
|
64
|
+
| `static/js/index.js` | Server-side EEJS bridge |
|
|
65
|
+
| `static/js/initialisation.js` | Toolbar + menu wiring |
|
|
66
|
+
| `static/js/client_hooks.js` | **All editor logic** (attributes, rendering, nav, resize) |
|
|
67
|
+
| `collectContentPre.js` | Server-side attribute reconstruction |
|
|
68
|
+
| `static/js/datatables-renderer.js` | Export & timeslider renderer |
|
|
69
|
+
| `static/css/` | Editor / UI styles |
|
|
70
|
+
| `templates/*.ejs` | Snippets injected into Etherpad shells |
|
|
71
|
+
|
|
72
|
+
## Current limitations (BETA)
|
|
73
|
+
|
|
74
|
+
* Merged cells and table copy-paste are not handled yet.
|
|
75
|
+
* Heavy DOM rewrites mean very large tables may impact performance.
|
|
76
|
+
* Codebase is still verbose and log-heavy for debugging; expect refactors.
|
|
77
|
+
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Using console.log for server-side logging, similar to other Etherpad server-side files.
|
|
4
|
+
const log = (...m) => console.log('[ep_data_tables:collectContentPre_SERVER]', ...m);
|
|
5
|
+
|
|
6
|
+
// Base64 decoding function (copied from tableImport.js / client_hooks.js for server-side use)
|
|
7
|
+
// Ensure it can handle the URL-safe variant if that's what tableImport.js produces.
|
|
8
|
+
const dec = (s) => {
|
|
9
|
+
const str = s.replace(/-/g, '+').replace(/_/g, '/');
|
|
10
|
+
try {
|
|
11
|
+
// Assuming Buffer is available in the Node.js environment where this server hook runs
|
|
12
|
+
return Buffer.from(str, 'base64').toString('utf8');
|
|
13
|
+
} catch (e) {
|
|
14
|
+
log('ERROR decoding base64 string in server-side collectContentPre:', s, e);
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.collectContentPre = (hookName, context) => {
|
|
20
|
+
|
|
21
|
+
const node = context.node;
|
|
22
|
+
const tname = node?.tagName?.toLowerCase(); // Keep for logging, but don't rely on it for main logic
|
|
23
|
+
const cls = context.cls;
|
|
24
|
+
const state = context.state;
|
|
25
|
+
|
|
26
|
+
// Detailed logging for every node encountered by this hook
|
|
27
|
+
let nodeRepresentation = '';
|
|
28
|
+
if (node) {
|
|
29
|
+
if (node.nodeType === 1 /* Node.ELEMENT_NODE */) {
|
|
30
|
+
nodeRepresentation = node.outerHTML ? node.outerHTML.substring(0, 300) : `ElementType: ${tname}`;
|
|
31
|
+
} else if (node.nodeType === 3 /* Node.TEXT_NODE */) {
|
|
32
|
+
nodeRepresentation = `TextNode: "${(node.nodeValue || '').substring(0, 100)}"`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
log(`PROCESSING Node: ${nodeRepresentation}, TagName: ${tname}, Classes: "${cls || ''}", Current state.attribString: "${state.attribString || ''}"`);
|
|
36
|
+
|
|
37
|
+
// MODIFIED CONDITION: Rely primarily on context.cls to find our target class,
|
|
38
|
+
// as context.node and context.tname seem unreliable for our spans.
|
|
39
|
+
if (!cls) {
|
|
40
|
+
// log('No classes, returning.');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const classes = cls.split(' ');
|
|
45
|
+
let encodedJsonMetadata = null;
|
|
46
|
+
let isTblJsonSpan = false;
|
|
47
|
+
|
|
48
|
+
for (const c of classes) {
|
|
49
|
+
if (c.startsWith('tbljson-')) {
|
|
50
|
+
encodedJsonMetadata = c.substring(8);
|
|
51
|
+
isTblJsonSpan = true;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (isTblJsonSpan && encodedJsonMetadata) {
|
|
57
|
+
// Added a check for tname === 'span' here for sanity, though cls is primary trigger
|
|
58
|
+
log(`FOUND potential tbljson span based on class. Actual tname: ${tname}. Encoded: ${encodedJsonMetadata.substring(0, 20)}...`);
|
|
59
|
+
let decodedJsonString;
|
|
60
|
+
try {
|
|
61
|
+
decodedJsonString = dec(encodedJsonMetadata);
|
|
62
|
+
if (!decodedJsonString) {
|
|
63
|
+
throw new Error('Decoded JSON string is null or empty.');
|
|
64
|
+
}
|
|
65
|
+
log(`DECODED metadata: ${decodedJsonString.substring(0, 50)}...`);
|
|
66
|
+
} catch (e) {
|
|
67
|
+
log('ERROR decoding/validating metadata from class:', encodedJsonMetadata, e);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const attribToApply = `tbljson::${decodedJsonString}`;
|
|
72
|
+
log(`PREPARED attribToApply: "${attribToApply.substring(0, 70)}..."`);
|
|
73
|
+
|
|
74
|
+
log('BEFORE cc.doAttrib - state.attribs:', JSON.stringify(state.attribs));
|
|
75
|
+
log('BEFORE cc.doAttrib - state.attribString:', state.attribString);
|
|
76
|
+
try {
|
|
77
|
+
context.cc.doAttrib(state, attribToApply);
|
|
78
|
+
log('AFTER cc.doAttrib - state.attribs:', JSON.stringify(state.attribs));
|
|
79
|
+
log('AFTER cc.doAttrib - state.attribString:', state.attribString);
|
|
80
|
+
log('SUCCESSFULLY CALLED cc.doAttrib.');
|
|
81
|
+
} catch (e) {
|
|
82
|
+
log('ERROR calling cc.doAttrib:', e);
|
|
83
|
+
}
|
|
84
|
+
} else if (cls.includes('tbljson-')) {
|
|
85
|
+
log(`WARN: A class string "${cls}" includes 'tbljson-' but didn't parse as expected, or encodedJsonMetadata was null.`);
|
|
86
|
+
}
|
|
87
|
+
};
|
package/ep.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"parts": [
|
|
3
|
+
{
|
|
4
|
+
"name": "tables",
|
|
5
|
+
"hooks": {
|
|
6
|
+
"eejsBlock_styles" : "ep_data_tables/static/js/index:eejsBlock_styles",
|
|
7
|
+
"eejsBlock_scripts" : "ep_data_tables/static/js/index:eejsBlock_scripts",
|
|
8
|
+
"eejsBlock_editbarMenuLeft" : "ep_data_tables/static/js/index:eejsBlock_editbarMenuLeft",
|
|
9
|
+
"collectContentPre" : "ep_data_tables/collectContentPre:collectContentPre"
|
|
10
|
+
},
|
|
11
|
+
"client_hooks": {
|
|
12
|
+
"collectContentPre" : "ep_data_tables/static/js/client_hooks:collectContentPre",
|
|
13
|
+
"collectContentLineBreak": "ep_data_tables/static/js/collector_hooks:collectContentLineBreak",
|
|
14
|
+
"collectContentLineText" : "ep_data_tables/static/js/collector_hooks:collectContentLineText",
|
|
15
|
+
"aceKeyEvent" : "ep_data_tables/static/js/client_hooks:aceKeyEvent",
|
|
16
|
+
"aceStartLineAndCharForPoint" : "ep_data_tables/static/js/client_hooks:aceStartLineAndCharForPoint",
|
|
17
|
+
"aceEndLineAndCharForPoint" : "ep_data_tables/static/js/client_hooks:aceEndLineAndCharForPoint",
|
|
18
|
+
"aceAttribsToClasses" : "ep_data_tables/static/js/client_hooks:aceAttribsToClasses",
|
|
19
|
+
"acePostWriteDomLineHTML" : "ep_data_tables/static/js/client_hooks:acePostWriteDomLineHTML",
|
|
20
|
+
"aceInitialized" : "ep_data_tables/static/js/client_hooks:aceInitialized",
|
|
21
|
+
"aceSetAuthorStyle" : "ep_data_tables/static/js/client_hooks:aceSetAuthorStyle",
|
|
22
|
+
"aceEditorCSS" : "ep_data_tables/static/js/client_hooks:aceEditorCSS",
|
|
23
|
+
"postAceInit" : "ep_data_tables/static/js/initialisation:postAceInit"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
|
package/locales/en.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{ "ep_data_tables.menuCreateTable": "Insert Table"
|
|
2
|
+
, "ep_data_tables.menuInsertRowBelow": "Insert Row Below"
|
|
3
|
+
, "ep_data_tables.menuInsertRowAbove": "Insert Row Above"
|
|
4
|
+
, "ep_data_tables.menuInsertColumnRight": "Insert Column Right"
|
|
5
|
+
, "ep_data_tables.menuInsertColumnLeft": "Insert Column Left"
|
|
6
|
+
, "ep_data_tables.menuDeleteRow": "Delete Row"
|
|
7
|
+
, "ep_data_tables.menuDeleteColumn": "Delete Column"
|
|
8
|
+
, "ep_data_tables.menuDeleteTable": "Delete Table"
|
|
9
|
+
, "ep_data_tables.menuTableProperties": "Table Properties"
|
|
10
|
+
, "ep_data_tables.menuCloseThisMenu": "Close Menu"
|
|
11
|
+
, "ep_data_tables.propLeft": "Left"
|
|
12
|
+
, "ep_data_tables.propRight": "Right"
|
|
13
|
+
, "ep_data_tables.propCenter": "Center"
|
|
14
|
+
, "ep_data_tables.propTop": "Top"
|
|
15
|
+
, "ep_data_tables.propBottom": "Bottom"
|
|
16
|
+
, "ep_data_tables.propChooseAColorFor": "Pick a Color for: "
|
|
17
|
+
, "ep_data_tables.propTableBorderColor": "Table Border Color"
|
|
18
|
+
, "ep_data_tables.propCellBackgroundColor": "Cell Background Color & Alignment"
|
|
19
|
+
, "ep_data_tables.propEvenRowBackgroundColor": "Even Rows Background Color"
|
|
20
|
+
, "ep_data_tables.propOddRowBackgroundColor": "Odd Rows Background Color"
|
|
21
|
+
, "ep_data_tables.propSingleRowBackgroundColor": "Single Row Background Color"
|
|
22
|
+
, "ep_data_tables.propSingleColumnBackgroundColor": "Single Column Background Color"
|
|
23
|
+
, "ep_data_tables.propTableBorder": "Table border"
|
|
24
|
+
, "ep_data_tables.propEvenOddRowBackgroundColor": "Even / Odd Row Background Color"
|
|
25
|
+
, "ep_data_tables.propEven": "Even"
|
|
26
|
+
, "ep_data_tables.propOdd": "Odd"
|
|
27
|
+
, "ep_data_tables.propSingleRowColBackgroundColor": "Single Row / Col Background Color"
|
|
28
|
+
, "ep_data_tables.propRowColAlignment": "Row / Column Alignment"
|
|
29
|
+
, "ep_data_tables.propRow": "Row"
|
|
30
|
+
, "ep_data_tables.propCol": "Column"
|
|
31
|
+
, "ep_data_tables.propDimensions": "Dimensions"
|
|
32
|
+
, "ep_data_tables.propTableWidth": "Table Width"
|
|
33
|
+
, "ep_data_tables.propTableHeight": "Table Height"
|
|
34
|
+
, "ep_data_tables.propColumnWidth": "Column Width"
|
|
35
|
+
, "ep_data_tables.propMinRowHeight": "Min Row Height"
|
|
36
|
+
, "ep_data_tables.propCellStyles": "Cell Styles"
|
|
37
|
+
, "ep_data_tables.propFont": "Font"
|
|
38
|
+
, "ep_data_tables.propFontSize": "Font Size"
|
|
39
|
+
, "ep_data_tables.propBold": "Bold"
|
|
40
|
+
, "ep_data_tables.propItalic": "Italic"
|
|
41
|
+
, "ep_data_tables.propUnderline": "Underline"
|
|
42
|
+
, "ep_data_tables.propBtnValidate": "Ok"
|
|
43
|
+
, "ep_data_tables.propBtnRemove": "Remove"
|
|
44
|
+
, "ep_data_tables.propBtnClose": "Close"
|
|
45
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ep_data_tables",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "BETA - etherpad tables plugin, compatible with other character/line based styling and other features",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "DCastelone",
|
|
7
|
+
"url": "https://github.com/dcastelone"
|
|
8
|
+
},
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"etherpad",
|
|
12
|
+
"plugin",
|
|
13
|
+
"ep",
|
|
14
|
+
"tables",
|
|
15
|
+
"data",
|
|
16
|
+
"tables"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/dcastelone/ep_data_tables.git"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/dcastelone/ep_data_tables/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/dcastelone/ep_data_tables/README.md",
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"eslint": "^7.18.0",
|
|
28
|
+
"eslint-config-etherpad": "^1.0.24",
|
|
29
|
+
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
30
|
+
"eslint-plugin-mocha": "^8.0.0",
|
|
31
|
+
"eslint-plugin-node": "^11.1.0",
|
|
32
|
+
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
33
|
+
"eslint-plugin-promise": "^4.2.1",
|
|
34
|
+
"eslint-plugin-you-dont-need-lodash-underscore": "^6.10.0"
|
|
35
|
+
},
|
|
36
|
+
"eslintConfig": {
|
|
37
|
+
"root": true,
|
|
38
|
+
"extends": "etherpad/plugin"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">= 10.13.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"lint": "eslint .",
|
|
45
|
+
"lint:fix": "eslint --fix ."
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This class creates an invisible, zero-width inline box with a height.
|
|
3
|
+
* This satisfies Blink/Chrome's requirement for a renderable "caret anchor"
|
|
4
|
+
* inside an otherwise empty editable element, ensuring the caret is
|
|
5
|
+
* always visible.
|
|
6
|
+
*/
|
|
7
|
+
.ep-tables5-caret-anchor {
|
|
8
|
+
display: inline-block;
|
|
9
|
+
width: 0;
|
|
10
|
+
height: 1em;
|
|
11
|
+
pointer-events: none;
|
|
12
|
+
user-select: none;
|
|
13
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* CSS rules specifically for styling tables within the Etherpad editor iframe.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/* Prevent default background highlight on the TD itself if an author class is present */
|
|
6
|
+
.dataTable td[class*="author-"] {
|
|
7
|
+
background-color: transparent !important;
|
|
8
|
+
border: 1px solid transparent; /* Maintain border for consistency if needed */
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/* Ensure the author span (added by acePostWriteDomLineHTML) displays correctly */
|
|
12
|
+
.dataTable td span[data-author-span="true"] {
|
|
13
|
+
display: inline;
|
|
14
|
+
text-decoration: none !important; /* Remove potential underlines */
|
|
15
|
+
/* Text color should ideally be inherited or applied dynamically if Etherpad supports it,
|
|
16
|
+
otherwise, it might need to be handled explicitly in acePostWriteDomLineHTML if this CSS isn't sufficient.
|
|
17
|
+
The aceSetAuthorStyle hook returning true aims to stop the default background color,
|
|
18
|
+
allowing text color styling (potentially handled by core etherpad based on author class) to take precedence. */
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* NEW STYLES FOR ATTRIBUTE-BASED TABLES */
|
|
22
|
+
|
|
23
|
+
/* Applied directly to the rendered table */
|
|
24
|
+
.dataTable {
|
|
25
|
+
width: 100%; /* Ensure table takes full width */
|
|
26
|
+
border-collapse: collapse; /* Collapse borders */
|
|
27
|
+
table-layout: fixed; /* Ensure equal column widths unless specified */
|
|
28
|
+
/* margin-bottom: 1px; */ /* REMOVED - Likely caused gaps between rows */
|
|
29
|
+
border: 1px solid black; /* Apply border to the table itself */
|
|
30
|
+
border-top: none; /* REMOVE top border to prevent double lines between rows */
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* Restore top border ONLY for the first table row in a block */
|
|
34
|
+
.dataTable.dataTable-first-row {
|
|
35
|
+
border-top: 1px solid black;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Style the table rows */
|
|
39
|
+
.dataTable tr {
|
|
40
|
+
height: 36px; /* Set fixed row height */
|
|
41
|
+
min-height: 36px; /* Ensure minimum row height */
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.dataTable td {
|
|
45
|
+
/* border: 1px solid black !important; */ /* REMOVED - Moved to .dataTable */
|
|
46
|
+
/* min-height: 36px; */ /* REMOVED - Moved to .dataTable tr */
|
|
47
|
+
vertical-align: top; /* Align content to top */
|
|
48
|
+
word-wrap: break-word; /* Wrap long words */
|
|
49
|
+
/* Padding will be kept inline via JS for now */
|
|
50
|
+
/* Add internal cell borders if desired (looks better with collapsed borders) */
|
|
51
|
+
border-left: 1px solid black;
|
|
52
|
+
border-right: 1px solid black;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Remove outer border from first/last cells if table border is set */
|
|
56
|
+
.dataTable td:first-child {
|
|
57
|
+
border-left: none;
|
|
58
|
+
}
|
|
59
|
+
.dataTable td:last-child {
|
|
60
|
+
border-right: none;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Style the line DIV as a table row */
|
|
64
|
+
/* Commenting out previous attempt as block/inline-block above is simpler for now
|
|
65
|
+
.ep-table-row {
|
|
66
|
+
display: table-row !important;
|
|
67
|
+
width: 100%;
|
|
68
|
+
}
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
/* Style the cell wrapper spans as table cells */
|
|
72
|
+
/* Commenting out previous attempt
|
|
73
|
+
.ep-table-cell {
|
|
74
|
+
display: table-cell !important;
|
|
75
|
+
padding: 2px 4px;
|
|
76
|
+
border: 1px solid #ccc;
|
|
77
|
+
vertical-align: inherit;
|
|
78
|
+
height: auto;
|
|
79
|
+
}
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
/* Ensure delimiters themselves are not visible */
|
|
83
|
+
.table-cell-delimiter {
|
|
84
|
+
display: none !important;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.ep-table-row-line > .list-bullet,
|
|
88
|
+
.list-table-row > .list-bullet {
|
|
89
|
+
display: none !important;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* Hide the injected delimiter span */
|
|
93
|
+
.ep-data_tables-delim {
|
|
94
|
+
font-size:0;
|
|
95
|
+
line-height:0;
|
|
96
|
+
color:transparent;
|
|
97
|
+
pointer-events:none;
|
|
98
|
+
user-select:none;
|
|
99
|
+
caret-color:transparent;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* NEW: Column resize handle styles */
|
|
103
|
+
.ep-data_tables-resize-handle {
|
|
104
|
+
position: absolute;
|
|
105
|
+
top: 0;
|
|
106
|
+
right: -2px;
|
|
107
|
+
width: 4px;
|
|
108
|
+
height: 100%;
|
|
109
|
+
cursor: col-resize;
|
|
110
|
+
background: transparent;
|
|
111
|
+
z-index: 10;
|
|
112
|
+
opacity: 0;
|
|
113
|
+
transition: opacity 0.2s ease;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
/* Show resize handles on hover */
|
|
119
|
+
.dataTable tr:first-child td:hover .ep-data_tables-resize-handle,
|
|
120
|
+
.dataTable tr:first-child .ep-data_tables-resize-handle:hover {
|
|
121
|
+
opacity: 0.3;
|
|
122
|
+
background: #007cff;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* Visual feedback during resize */
|
|
126
|
+
.dataTable.ep-data_tables-resizing {
|
|
127
|
+
user-select: none;
|
|
128
|
+
-webkit-user-select: none;
|
|
129
|
+
-moz-user-select: none;
|
|
130
|
+
-ms-user-select: none;
|
|
131
|
+
pointer-events: none; /* Prevent other interactions during resize */
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.dataTable.ep-data_tables-resizing td {
|
|
135
|
+
transition: none !important;
|
|
136
|
+
pointer-events: none; /* Prevent cell interactions during resize */
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.dataTable.ep-data_tables-resizing .ep-data_tables-resize-handle {
|
|
140
|
+
opacity: 0.7 !important;
|
|
141
|
+
background: #007cff !important;
|
|
142
|
+
pointer-events: auto; /* Keep resize handle interactive */
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* Improve resize handle visibility on first row */
|
|
146
|
+
.dataTable.dataTable-first-row tr:first-child td {
|
|
147
|
+
position: relative;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/* Ensure resize handles don't interfere with text selection */
|
|
151
|
+
.ep-data_tables-resize-handle:hover {
|
|
152
|
+
background: #007cff !important;
|
|
153
|
+
opacity: 0.5 !important;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/* Add a visual indicator during resize */
|
|
157
|
+
.dataTable.ep-data_tables-resizing::after {
|
|
158
|
+
content: '';
|
|
159
|
+
position: absolute;
|
|
160
|
+
top: 0;
|
|
161
|
+
left: 0;
|
|
162
|
+
right: 0;
|
|
163
|
+
bottom: 0;
|
|
164
|
+
background: rgba(0, 124, 255, 0.05);
|
|
165
|
+
pointer-events: none;
|
|
166
|
+
z-index: 5;
|
|
167
|
+
}
|