Skip to content

Commit 7181284

Browse files
committed
chore: lint
1 parent ba46c18 commit 7181284

6 files changed

Lines changed: 17 additions & 71 deletions

File tree

packages/super-editor/src/assets/styles/elements/prosemirror.css

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ img.ProseMirror-separator {
148148
margin-bottom: 1.5px;
149149
}
150150

151-
/*
152-
Tables
151+
/*
152+
Tables
153153
https://github.com/ProseMirror/prosemirror-tables/blob/master/style/tables.css
154154
https://github.com/ProseMirror/prosemirror-tables/blob/master/demo/index.html
155155
*/
@@ -166,8 +166,8 @@ https://github.com/ProseMirror/prosemirror-tables/blob/master/demo/index.html
166166
scrollbar-width: thin;
167167
overflow: hidden;
168168

169-
/*
170-
The border width does not need to be multiplied by two,
169+
/*
170+
The border width does not need to be multiplied by two,
171171
for tables it works differently. */
172172
width: calc(100% + (var(--table-border-width) + var(--offset)));
173173
}
@@ -292,25 +292,19 @@ https://github.com/ProseMirror/prosemirror-tables/blob/master/demo/index.html
292292
/* Collaboration cursors - end */
293293

294294
/* Image placeholder */
295-
.ProseMirror placeholder,
296-
.ProseMirror img.placeholder {
295+
.ProseMirror placeholder {
297296
display: inline;
298297
border: 1px solid #ccc;
299298
color: #ccc;
300299
}
301300

302-
.ProseMirror placeholder:after,
303-
.ProseMirror img.placeholder:after {
301+
.ProseMirror placeholder:after {
304302
content: '☁';
305303
font-size: 200%;
306304
line-height: 0.1;
307305
font-weight: bold;
308306
}
309307

310-
.ProseMirror placeholder img {
311-
display: none !important;
312-
}
313-
314308
/* Gapcursor */
315309
.ProseMirror-gapcursor {
316310
display: none;

packages/super-editor/src/components/toolbar/super-toolbar.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,6 @@ export class SuperToolbar extends EventEmitter {
372372
}
373373

374374
const { size, file } = await checkAndProcessImage({
375-
view: this.activeEditor.view,
376375
file: result.file,
377376
getMaxContentSize: () => this.activeEditor.getMaxContentSize(),
378377
});

packages/super-editor/src/core/super-converter/exporter.js

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { EditorState } from 'prosemirror-state';
44
import { SuperConverter } from './SuperConverter.js';
55
import {
66
emuToPixels,
7-
getTextIndentExportValue,
87
inchesToTwips,
98
linesToTwips,
109
pixelsToEightPoints,
@@ -74,7 +73,6 @@ export function exportSchemaToJson(params) {
7473
const router = {
7574
doc: translateDocumentNode,
7675
body: translateBodyNode,
77-
heading: translateHeadingNode,
7876
paragraph: translateParagraphNode,
7977
text: translateTextNode,
8078
bulletList: translateList,
@@ -170,30 +168,6 @@ const generateDefaultHeaderFooter = (type, id) => {
170168
};
171169
};
172170

173-
/**
174-
* Translate a heading node to a paragraph with Word heading style
175-
*
176-
* @param {ExportParams} params The parameters object containing the heading node
177-
* @returns {XmlReadyNode} JSON of the XML-ready paragraph node with heading style
178-
*/
179-
function translateHeadingNode(params) {
180-
const { node } = params;
181-
const { level = 1, ...otherAttrs } = node.attrs;
182-
183-
// Convert heading to paragraph with appropriate Word heading style
184-
const paragraphNode = {
185-
type: 'paragraph',
186-
content: node.content,
187-
attrs: {
188-
...otherAttrs,
189-
styleId: `Heading${level}`, // Maps to Heading1, Heading2, etc. in Word
190-
},
191-
};
192-
193-
// Use existing paragraph translator with the modified node
194-
return translateParagraphNode({ ...params, node: paragraphNode });
195-
}
196-
197171
/**
198172
* Translate a paragraph node
199173
*
@@ -306,7 +280,7 @@ function generateParagraphProperties(node) {
306280
if (hanging || hanging === 0) attributes['w:hanging'] = pixelsToTwips(hanging);
307281

308282
if (textIndent && !attributes['w:left']) {
309-
attributes['w:left'] = getTextIndentExportValue(textIndent);
283+
attributes['w:left'] = inchesToTwips(textIndent);
310284
}
311285

312286
const indentElement = {
@@ -318,7 +292,7 @@ function generateParagraphProperties(node) {
318292
const indentElement = {
319293
name: 'w:ind',
320294
attributes: {
321-
'w:left': getTextIndentExportValue(textIndent),
295+
'w:left': inchesToTwips(textIndent),
322296
},
323297
};
324298
pPrElements.push(indentElement);
@@ -970,13 +944,7 @@ function translateLineBreak(params) {
970944
}
971945

972946
return {
973-
name: 'w:r',
974-
elements: [
975-
{
976-
name: 'w:br',
977-
attributes,
978-
},
979-
],
947+
name: 'w:br',
980948
attributes,
981949
};
982950
}
@@ -1546,7 +1514,6 @@ function getScaledSize(originalWidth, originalHeight, maxWidth, maxHeight) {
15461514
}
15471515

15481516
function translateImageNode(params, imageSize) {
1549-
console.log('translateImageNode', { params, imageSize });
15501517
const {
15511518
node: { attrs = {} },
15521519
tableCell,
@@ -1998,12 +1965,7 @@ function prepareUrlAnnotation(params) {
19981965
* @param {String} annotationType
19991966
* @returns {Function} handler for provided annotation type
20001967
*/
2001-
function getTranslationByAnnotationType(annotationType, annotationFieldType) {
2002-
// invalid annotation
2003-
if (annotationType === 'text' && annotationFieldType === 'FILEUPLOADER') {
2004-
return null;
2005-
}
2006-
1968+
function getTranslationByAnnotationType(annotationType) {
20071969
const imageEmuSize = {
20081970
w: 4286250,
20091971
h: 4286250,
@@ -2049,7 +2011,7 @@ const translateFieldAttrsToMarks = (attrs = {}) => {
20492011
function translateFieldAnnotation(params) {
20502012
const { node, isFinalDoc, fieldsHighlightColor } = params;
20512013
const { attrs = {} } = node;
2052-
const annotationHandler = getTranslationByAnnotationType(attrs.type, attrs.fieldType);
2014+
const annotationHandler = getTranslationByAnnotationType(attrs.type);
20532015
if (!annotationHandler) return {};
20542016

20552017
let processedNode;
@@ -2321,14 +2283,8 @@ export class DocxExporter {
23212283
if (name === 'w:instrText') {
23222284
tags.push(elements[0].text);
23232285
} else if (name === 'w:t' || name === 'w:delText' || name === 'wp:posOffset') {
2324-
try {
2325-
// test for valid string
2326-
let text = String(elements[0].text);
2327-
text = this.#replaceSpecialCharacters(text);
2328-
tags.push(text);
2329-
} catch (error) {
2330-
console.error('Text element does not contain valid string:', error);
2331-
}
2286+
const text = this.#replaceSpecialCharacters(elements[0].text);
2287+
tags.push(text);
23322288
} else {
23332289
if (elements) {
23342290
for (let child of elements) {

packages/super-editor/src/extensions/image/imageHelpers/handleUrl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export const validateUrlAccessibility = async (url) => {
100100
credentials: 'omit',
101101
});
102102
return response.ok;
103-
} catch (error) {
103+
} catch (_error) {
104104
return false;
105105
}
106106
};

packages/super-editor/src/extensions/image/imageHelpers/imageRegistrationPlugin.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Plugin, PluginKey } from 'prosemirror-state';
22
import { Decoration, DecorationSet } from 'prosemirror-view';
3-
import { ReplaceStep, ReplaceAroundStep, StepMap } from 'prosemirror-transform';
3+
import { ReplaceStep, ReplaceAroundStep } from 'prosemirror-transform';
44
import { base64ToFile } from './handleBase64';
55
import { urlToFile, validateUrlAccessibility } from './handleUrl';
66
import { checkAndProcessImage, uploadAndInsertImage } from './startImageUpload';
@@ -87,7 +87,7 @@ export const ImageRegistrationPlugin = ({ editor }) => {
8787
// Add decorations for the images first at their current positions
8888
foundImages
8989
.toSorted((a, b) => a.pos - b.pos)
90-
.forEach(({ node, pos, id }) => {
90+
.forEach(({ pos, id }) => {
9191
let deco = Decoration.widget(pos, () => document.createElement('placeholder'), {
9292
side: -1,
9393
id,
@@ -187,7 +187,6 @@ const registerImages = async (foundImages, editor, view) => {
187187
try {
188188
const process = await checkAndProcessImage({
189189
getMaxContentSize: () => editor.getMaxContentSize(),
190-
view,
191190
file,
192191
});
193192

packages/super-editor/src/extensions/image/imageHelpers/startImageUpload.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ const fileTooLarge = (file) => {
1313
return false;
1414
};
1515

16-
export const checkAndProcessImage = async ({ getMaxContentSize, view, file }) => {
16+
export const checkAndProcessImage = async ({ getMaxContentSize, file }) => {
1717
if (fileTooLarge(file)) {
1818
return { file: null, size: { width: 0, height: 0 } };
1919
}
2020

21-
let width;
22-
let height;
2321
try {
2422
// Will process the image file in place
2523
const processedImageResult = await processUploadedImage(file, getMaxContentSize);

0 commit comments

Comments
 (0)