Skip to content

Build your personal knowledge base with Trilium Notes

fix(nx/client): assets and inline SVG for CKEditor plugins

Elian Doran444e33628c7c
diff --git a/apps/client/src/widgets/attribute_widgets/attribute_editor.ts b/apps/client/src/widgets/attribute_widgets/attribute_editor.ts
index c16ab0e828..919b53c3f2 100644
--- a/apps/client/src/widgets/attribute_widgets/attribute_editor.ts
+++ b/apps/client/src/widgets/attribute_widgets/attribute_editor.ts
@@ -199,7 +199,7 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
private $saveAttributesButton!: JQuery<HTMLElement>;
private $errors!: JQuery<HTMLElement>;
- private textEditor!: TextEditor;
+ private textEditor!: BalloonEditor;
private lastUpdatedNoteId!: string | undefined;
private lastSavedContent!: string;
@@ -213,7 +213,7 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
this.$widget = $(TPL);
this.$editor = this.$widget.find(".attribute-list-editor");
- this.initialized = this.initEditor();
+ // this.initialized = this.initEditor();
this.$editor.on("keydown", async (e) => {
if (e.which === 13) {
@@ -373,7 +373,7 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem
this.$editor.on("click", (e) => this.handleEditorClick(e));
- this.textEditor = BalloonEditor.create(this.$editor[0], editorConfig);
+ this.textEditor = await BalloonEditor.create(this.$editor[0], editorConfig);
this.textEditor.model.document.on("change:data", () => this.dataChanged());
this.textEditor.editing.view.document.on(
"enter",
diff --git a/apps/client/webpack.config.cjs b/apps/client/webpack.config.cjs
index ad5b992741..052c49d33b 100644
--- a/apps/client/webpack.config.cjs
+++ b/apps/client/webpack.config.cjs
@@ -1,6 +1,7 @@
const { composePlugins, withNx, withWeb } = require('@nx/webpack');
const { join } = require('path');
+const CopyPlugin = require('copy-webpack-plugin');
module.exports = composePlugins(
withNx({
@@ -38,13 +39,6 @@ module.exports = composePlugins(
"electron"
],
baseHref: '/',
- assets: [
- join(__dirname, "./src/assets"),
- join(__dirname, "./src/stylesheets"),
- join(__dirname, "./src/libraries"),
- join(__dirname, "./src/fonts"),
- join(__dirname, "./src/translations")
- ],
outputHashing: false,
optimization: process.env['NODE_ENV'] === 'production'
}),
@@ -78,6 +72,32 @@ module.exports = composePlugins(
util: false
};
+ const assets = [ "assets", "stylesheets", "libraries", "fonts", "translations" ]
+ config.plugins.push(new CopyPlugin({
+ patterns: assets.map((asset) => ({
+ from: join(__dirname, "src", asset),
+ to: asset
+ }))
+ }));
+
+ inlineSvg(config);
+
return config;
}
-);
\ No newline at end of file
+);
+
+function inlineSvg(config) {
+ if (!config.module?.rules) {
+ return;
+ }
+
+ // Alter Nx's asset rule to avoid inlining SVG if they have ?raw prepended.
+ const existingRule = config.module.rules.find((r) => r.test.toString() === /\.svg$/.toString());
+ existingRule.resourceQuery = { not: [/raw/] };
+
+ // Add a rule for prepending ?raw SVGs.
+ config.module.rules.push({
+ resourceQuery: /raw/,
+ type: 'asset/source',
+ });
+}
\ No newline at end of file
diff --git a/packages/ckeditor5/src/plugins/cuttonote.ts b/packages/ckeditor5/src/plugins/cuttonote.ts
index fb9654aad4..fffe45abfd 100644
--- a/packages/ckeditor5/src/plugins/cuttonote.ts
+++ b/packages/ckeditor5/src/plugins/cuttonote.ts
@@ -15,7 +15,7 @@ export default class CutToNotePlugin extends Plugin {
console.log("Got ", scissorsIcon);
view.set( {
label: 'Cut & paste selection to sub-note',
- // icon: scissorsIcon,
+ icon: scissorsIcon,
tooltip: true
} );