fix: lint

This commit is contained in:
windingwind 2023-07-27 00:14:28 +08:00
parent 30bbd36009
commit 10d19e5e1c
10 changed files with 87 additions and 70 deletions

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<body>
<script src="chrome://__addonRef__/content/lib/js/go.js"></script>
@ -81,11 +81,11 @@
contentAlignment: go.Spot.Center, // align document to the center of the viewport
layout: $(
ContinuousForceDirectedLayout, // automatically spread nodes apart while dragging
{ defaultSpringLength: 15, defaultElectricalCharge: 30 }
{ defaultSpringLength: 15, defaultElectricalCharge: 30 },
),
// do an extra layout at the end of a move
SelectionMoved: (e) => e.diagram.layout.invalidateLayout(),
}
},
);
// dragging a node invalidates the Diagram.layout, causing a layout during the drag
@ -114,9 +114,9 @@
desiredSize: new go.Size(10, 10),
},
new go.Binding("fill", "isSelected", (s, obj) =>
s ? "#f2ac46" : "lightgray"
).ofObject()
)
s ? "#f2ac46" : "lightgray",
).ofObject(),
),
),
$(
go.TextBlock,
@ -127,8 +127,8 @@
textEdited: editNode,
},
new go.Binding("text", "text").makeTwoWay(),
new go.Binding("stroke", "stroke")
)
new go.Binding("stroke", "stroke"),
),
);
// the rest of this app is the same as samples/conceptMap.html
@ -141,7 +141,7 @@
"Auto",
// this Adornment has a rectangular blue Shape around the selected node
$(go.Shape, { fill: null, stroke: "dodgerblue", strokeWidth: 3 }),
$(go.Placeholder, { margin: new go.Margin(4, 4, 0, 4) })
$(go.Placeholder, { margin: new go.Margin(4, 4, 0, 4) }),
),
// and this Adornment has a Button to the right of the selected node
$(
@ -154,9 +154,9 @@
$(
go.TextBlock,
"↗️", // the Button content
{ font: "bold 8pt sans-serif" }
)
)
{ font: "bold 8pt sans-serif" },
),
),
);
// replace the default Link template in the linkTemplateMap
@ -164,13 +164,13 @@
go.Link, // the whole link panel
$(
go.Shape, // the link shape
{ stroke: "grey" }
{ stroke: "grey" },
),
$(
go.Shape, // the arrowhead
{ toArrow: "standard", stroke: null }
{ toArrow: "standard", stroke: null },
),
$(go.Panel, "Auto")
$(go.Panel, "Auto"),
);
window.parent.postMessage({ type: "ready" }, "*");
getData();
@ -197,7 +197,7 @@
nodeDataArray.push({
key: node.model.id,
text: `${node.model.level === 7 ? "🔗" : ""}${wrapText(
node.model.name
node.model.name,
)}`,
stroke: "-moz-DialogText",
lineIndex: node.model.lineIndex,
@ -221,7 +221,7 @@
if (olddata.noteLink) {
window.parent.postMessage(
{ type: "openNote", link: olddata.noteLink, id: olddata.key },
"*"
"*",
);
} else {
window.parent.postMessage(
@ -231,7 +231,7 @@
id: olddata.key,
workspaceType: window.workspaceType || "tab",
},
"*"
"*",
);
}
}
@ -250,7 +250,7 @@
text: data.text,
workspaceType: window.workspaceType || "tab",
},
"*"
"*",
);
}
@ -270,7 +270,7 @@
type: "saveImageReturn",
image: imgString,
},
"*"
"*",
);
case "saveSVG":
const svgElement = Diagram.makeSvg({
@ -281,7 +281,7 @@
type: "saveSVGReturn",
image: svgElement.outerHTML,
},
"*"
"*",
);
default:
break;

View File

@ -1,8 +1,8 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<title>Image Preview</title>
<meta charset="utf-8">
<meta charset="utf-8" />
</head>
<body>
<style>

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<body>
<script src="chrome://__addonRef__/content/lib/js/go.js"></script>
@ -56,7 +56,7 @@
new go.Binding("text", "text").makeTwoWay(),
new go.Binding("scale", "scale").makeTwoWay(),
new go.Binding("font", "font").makeTwoWay(),
new go.Binding("stroke", "stroke").makeTwoWay()
new go.Binding("stroke", "stroke").makeTwoWay(),
),
$(
go.Shape,
@ -73,16 +73,16 @@
new go.Binding("stroke", "brush"),
// make sure links come in from the proper direction and go out appropriately
new go.Binding("fromSpot", "dir", (d) => spotConverter(d, true)),
new go.Binding("toSpot", "dir", (d) => spotConverter(d, false))
new go.Binding("toSpot", "dir", (d) => spotConverter(d, false)),
),
// remember the locations of each node in the node data
new go.Binding("location", "loc", go.Point.parse).makeTwoWay(
go.Point.stringify
go.Point.stringify,
),
// make sure text "grows" in the desired direction
new go.Binding("locationSpot", "dir", (d) =>
spotConverter(d, false)
)
spotConverter(d, false),
),
);
// selected nodes show a button for adding children
@ -94,7 +94,7 @@
"Auto",
// this Adornment has a rectangular blue Shape around the selected node
$(go.Shape, { fill: null, stroke: "dodgerblue", strokeWidth: 3 }),
$(go.Placeholder, { margin: new go.Margin(4, 4, 0, 4) })
$(go.Placeholder, { margin: new go.Margin(4, 4, 0, 4) }),
),
// and this Adornment has a Button to the right of the selected node
$(
@ -107,9 +107,9 @@
$(
go.TextBlock,
"↗️", // the Button content
{ font: "bold 8pt sans-serif" }
)
)
{ font: "bold 8pt sans-serif" },
),
),
);
// a link is just a Bezier-curved line of the same color as the node to which it is connected
@ -127,8 +127,8 @@
new go.Binding("stroke", "toNode", (n) => {
if (n.data.brush) return n.data.brush;
return "black";
}).ofObject()
)
}).ofObject(),
),
);
Diagram.addDiagramListener("SelectionMoved", (e) => {
@ -263,7 +263,7 @@
data.nodeDataArray.push({
key: node.model.id,
text: `${node.model.level === 7 ? "🔗" : ""}${wrapText(
node.model.name
node.model.name,
)}`,
stroke: "-moz-DialogText",
parent: parent,
@ -283,7 +283,7 @@
if (olddata.noteLink) {
window.parent.postMessage(
{ type: "openNote", link: olddata.noteLink, id: olddata.key },
"*"
"*",
);
} else {
window.parent.postMessage(
@ -293,7 +293,7 @@
id: olddata.key,
workspaceType: window.workspaceType || "tab",
},
"*"
"*",
);
}
}
@ -312,7 +312,7 @@
text: data.text,
workspaceType: window.workspaceType || "tab",
},
"*"
"*",
);
}
@ -332,7 +332,7 @@
type: "saveImageReturn",
image: imgString,
},
"*"
"*",
);
case "saveSVG":
const svgElement = Diagram.makeSvg({
@ -343,7 +343,7 @@
type: "saveSVGReturn",
image: svgElement.outerHTML,
},
"*"
"*",
);
default:
break;

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<body>
<script src="chrome://__addonRef__/content/lib/js/jquery.min.js"></script>
@ -278,7 +278,7 @@
store: new DevExpress.data.ArrayStore({
key: "id",
data: window.diffData.filter(
(diff) => diff.added || diff.removed
(diff) => diff.added || diff.removed,
),
}),
}),
@ -292,7 +292,7 @@
? "added-list-item"
: e.itemData.removed
? "removed-list-item"
: ""
: "",
);
}
},
@ -310,7 +310,7 @@
const diffViewer = document.querySelector(".diff-viewport");
diffViewer.scrollTo(
0,
target.offsetTop - diffViewer.offsetTop
target.offsetTop - diffViewer.offsetTop,
);
}
},
@ -364,7 +364,7 @@
const syncScroller = function () {
let nodes = Array.prototype.filter.call(
arguments,
(item) => item instanceof HTMLElement
(item) => item instanceof HTMLElement,
);
let max = nodes.length;
if (!max || max === 1) return;
@ -381,7 +381,7 @@
if (node == this) continue;
node.scrollTo(
left * (node.scrollWidth - node.clientWidth),
top * (node.scrollHeight - node.clientHeight)
top * (node.scrollHeight - node.clientHeight),
);
}
} else --sign;

View File

@ -1,9 +1,15 @@
<?xml version="1.0"?>
<!-- prettier-ignore -->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!-- prettier-ignore -->
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<!-- prettier-ignore -->
<?xml-stylesheet href="chrome://zotero-platform/content/zotero-react-client.css" type="text/css"?>
<!-- prettier-ignore -->
<?xml-stylesheet href="chrome://zotero-platform/content/zotero.css" type="text/css"?>
<!-- prettier-ignore -->
<?xml-stylesheet href="chrome://__addonRef__/content/virtualizedTable.css" type="text/css"?>
<!-- prettier-ignore -->
<!DOCTYPE html>
<html
lang="en"
@ -16,22 +22,22 @@
persist="screenX screenY width height sizemode"
>
<head>
<title locale-target="innerHTML">syncManager.title</title>
<title data-l10n-id="title"></title>
<meta charset="utf-8" />
<script>
document.addEventListener("DOMContentLoaded", (ev) => {
const { Services } = ChromeUtils.import(
"resource://gre/modules/Services.jsm"
"resource://gre/modules/Services.jsm",
);
Services.scriptloader.loadSubScript(
"chrome://zotero/content/include.js",
this
this,
);
Services.scriptloader.loadSubScript(
"resource://zotero/require.js",
this
this,
);
window.arguments[0]._initPromise.resolve();
});

View File

@ -1,9 +1,15 @@
<?xml version="1.0"?>
<!-- prettier-ignore -->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!-- prettier-ignore -->
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<!-- prettier-ignore -->
<?xml-stylesheet href="chrome://zotero-platform/content/zotero-react-client.css" type="text/css"?>
<!-- prettier-ignore -->
<?xml-stylesheet href="chrome://zotero-platform/content/zotero.css" type="text/css"?>
<!-- prettier-ignore -->
<?xml-stylesheet href="chrome://__addonRef__/content/virtualizedTable.css" type="text/css"?>
<!-- prettier-ignore -->
<!DOCTYPE html>
<html
lang="en"
@ -22,17 +28,17 @@
<script>
document.addEventListener("DOMContentLoaded", (ev) => {
const { Services } = ChromeUtils.import(
"resource://gre/modules/Services.jsm"
"resource://gre/modules/Services.jsm",
);
Services.scriptloader.loadSubScript(
"chrome://zotero/content/include.js",
this
this,
);
Services.scriptloader.loadSubScript(
"resource://zotero/require.js",
this
this,
);
window.arguments[0]._initPromise.resolve();
});

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<body>
<script src="chrome://__addonRef__/content/lib/js/jquery.min.js"></script>
@ -141,7 +141,7 @@
: toItems[toItems.length - 1].itemData.id,
moveType: e.dropInsideItem ? "child" : "before",
},
"*"
"*",
);
const fromTopVisibleNode = getTopVisibleNode(fromTreeView);
@ -182,7 +182,7 @@
if (nodeElement) {
return findNodeById(
treeView.getNodes(),
nodeElement.getAttribute("data-item-id")
nodeElement.getAttribute("data-item-id"),
);
}
return null;
@ -208,7 +208,7 @@
toNode,
fromItems,
toItems,
isDropInsideItem
isDropInsideItem,
) {
const fromIndex = findIndex(fromItems, fromNode.itemData.id);
fromItems.splice(fromIndex, 1);
@ -326,7 +326,7 @@
link: itemData.noteLink,
id: parseInt(itemData.id),
},
"*"
"*",
);
} else {
window.parent.postMessage(
@ -336,7 +336,7 @@
id: parseInt(itemData.id),
workspaceType: window.workspaceType || "tab",
},
"*"
"*",
);
}
}

View File

@ -1,7 +1,11 @@
<?xml version="1.0"?>
<!-- prettier-ignore -->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!-- prettier-ignore -->
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<!-- prettier-ignore -->
<?xml-stylesheet href="chrome://zotero-platform/content/zotero-react-client.css" type="text/css"?>
<!-- prettier-ignore -->
<!DOCTYPE html>
<html
lang="en"
@ -19,40 +23,40 @@
<script>
document.addEventListener("DOMContentLoaded", (ev) => {
const { Services } = ChromeUtils.import(
"resource://gre/modules/Services.jsm"
"resource://gre/modules/Services.jsm",
);
Services.scriptloader.loadSubScript(
"chrome://zotero/content/include.js",
this
this,
);
Services.scriptloader.loadSubScript(
"resource://zotero/require.js",
this
this,
);
if (Zotero.platformMajorVersion >= 102) {
Services.scriptloader.loadSubScript(
"chrome://global/content/customElements.js",
this
this,
);
if (!customElements.get("note-editor")) {
Services.scriptloader.loadSubScript(
"chrome://zotero/content/elements/shadowAutocompleteInput.js",
this
this,
);
Services.scriptloader.loadSubScript(
"chrome://zotero/content/elements/noteEditor.js",
this
this,
);
Services.scriptloader.loadSubScript(
"chrome://zotero/content/elements/relatedBox.js",
this
this,
);
Services.scriptloader.loadSubScript(
"chrome://zotero/content/elements/tagsBox.js",
this
this,
);
}
}

View File

@ -31,7 +31,7 @@
"reload": "npm run build-dev && node scripts/reload.mjs --z 7",
"watch": "chokidar \"src/**\" \"addon/**\" -c \"npm run reload\"",
"release": "release-it",
"lint": "prettier --write src/** && eslint . --ext .ts --fix",
"lint": "prettier --write . '!addon/chrome/content/lib/**' && eslint . --ext .ts --fix",
"test": "echo \"Error: no test specified\" && exit 1",
"update-deps": "npm update --save"
},
@ -73,6 +73,7 @@
"zotero-plugin-toolkit": "^2.1.7"
},
"devDependencies": {
"@prettier/plugin-xml": "^3.1.1",
"@types/browser-or-node": "^1.3.0",
"@types/diff": "^5.0.3",
"@types/node": "^20.4.2",