diff --git a/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/.eslintrc.js b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/.eslintrc.js new file mode 100644 index 000000000..370d06cb1 --- /dev/null +++ b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/.eslintrc.js @@ -0,0 +1,14 @@ +/** + * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. + * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license + */ + +/* eslint-env node */ + +'use strict'; + +module.exports = { + rules: { + 'ckeditor5-rules/ckeditor-imports': 'off' + } +}; diff --git a/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/package.json b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/package.json new file mode 100644 index 000000000..6cc2935fe --- /dev/null +++ b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/package.json @@ -0,0 +1,78 @@ +{ + "name": "@ckeditor/ckeditor5-build-trilium", + "version": "43.2.0", + "description": "The document editor build of CKEditor 5 – the best browser-based rich text editor.", + "keywords": [ + "ckeditor5-build", + "ckeditor", + "ckeditor5", + "ckeditor 5", + "wysiwyg", + "rich text", + "editor", + "html", + "contentEditable", + "editing", + "operational transformation", + "ot", + "collaboration", + "collaborative", + "real-time", + "framework" + ], + "main": "./build/ckeditor.js", + "types": "./build/ckeditor.d.ts", + "files": [ + "build", + "ckeditor5-metadata.json", + "CHANGELOG.md" + ], + "dependencies": { + "@ckeditor/ckeditor5-adapter-ckfinder": "43.2.0", + "@ckeditor/ckeditor5-alignment": "43.2.0", + "@ckeditor/ckeditor5-autoformat": "43.2.0", + "@ckeditor/ckeditor5-basic-styles": "43.2.0", + "@ckeditor/ckeditor5-block-quote": "43.2.0", + "@ckeditor/ckeditor5-ckbox": "43.2.0", + "@ckeditor/ckeditor5-ckfinder": "43.2.0", + "@ckeditor/ckeditor5-cloud-services": "43.2.0", + "@ckeditor/ckeditor5-easy-image": "43.2.0", + "@ckeditor/ckeditor5-editor-decoupled": "43.2.0", + "@ckeditor/ckeditor5-essentials": "43.2.0", + "@ckeditor/ckeditor5-font": "43.2.0", + "@ckeditor/ckeditor5-heading": "43.2.0", + "@ckeditor/ckeditor5-image": "43.2.0", + "@ckeditor/ckeditor5-indent": "43.2.0", + "@ckeditor/ckeditor5-link": "43.2.0", + "@ckeditor/ckeditor5-list": "43.2.0", + "@ckeditor/ckeditor5-media-embed": "43.2.0", + "@ckeditor/ckeditor5-paragraph": "43.2.0", + "@ckeditor/ckeditor5-paste-from-office": "43.2.0", + "@ckeditor/ckeditor5-table": "43.2.0", + "@ckeditor/ckeditor5-typing": "43.2.0", + "@ckeditor/ckeditor5-utils": "43.2.0" + }, + "devDependencies": { + "@ckeditor/ckeditor5-core": "43.2.0", + "@ckeditor/ckeditor5-dev-translations": "^43.0.0", + "@ckeditor/ckeditor5-dev-utils": "^43.0.0", + "@ckeditor/ckeditor5-theme-lark": "43.2.0", + "terser-webpack-plugin": "^4.2.3", + "typescript": "5.0.4", + "webpack": "^5.94.0", + "webpack-cli": "^5.1.4" + }, + "author": "CKSource (http://cksource.com/)", + "license": "GPL-2.0-or-later", + "homepage": "https://ckeditor.com/ckeditor-5", + "bugs": "https://github.com/ckeditor/ckeditor5/issues", + "repository": { + "type": "git", + "url": "https://github.com/ckeditor/ckeditor5.git", + "directory": "packages/ckeditor5-build-decoupled-document" + }, + "scripts": { + "build": "webpack --mode production", + "postbuild": "tsc -p ./tsconfig.types.json" + } +} diff --git a/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/sample/index.html b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/sample/index.html new file mode 100644 index 000000000..769d5c94d --- /dev/null +++ b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/sample/index.html @@ -0,0 +1,73 @@ + + + + + CKEditor 5 – document editor build – development sample + + + + +

CKEditor 5 – document editor build – development sample

+ +

The toolbar

+
+ +

The editable

+
+ + + + + + + + diff --git a/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/ckeditor.ts b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/ckeditor.ts new file mode 100644 index 000000000..d237c9f11 --- /dev/null +++ b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/ckeditor.ts @@ -0,0 +1,9 @@ +import { EditorWatchdog } from "@ckeditor/ckeditor5-watchdog"; +import BalloonEditor from "./ckeditor_balloon"; +import DecoupledEditor from "./ckeditor_decoupled"; + +export default { + BalloonEditor, + DecoupledEditor, + EditorWatchdog +} diff --git a/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/ckeditor_balloon.ts b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/ckeditor_balloon.ts new file mode 100644 index 000000000..0866ddbfe --- /dev/null +++ b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/ckeditor_balloon.ts @@ -0,0 +1,18 @@ +/** + * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. + * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license + */ + +// The editor creator to use. +import { BalloonEditor as BalloonEditorBase } from '@ckeditor/ckeditor5-editor-balloon'; +import { BlockToolbar } from '@ckeditor/ckeditor5-ui'; +import '../theme/theme.css'; +import { COMMON_PLUGINS, COMMON_SETTINGS } from './config'; + +//@ts-ignore +export default class BalloonEditor extends BalloonEditorBase { + public static override builtinPlugins = [ + ...COMMON_PLUGINS, + BlockToolbar + ]; +} diff --git a/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/ckeditor_decoupled.ts b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/ckeditor_decoupled.ts new file mode 100644 index 000000000..1439803a5 --- /dev/null +++ b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/ckeditor_decoupled.ts @@ -0,0 +1,16 @@ +/** + * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. + * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license + */ + +// The editor creator to use. +import { DecoupledEditor as DecoupledEditorBase } from '@ckeditor/ckeditor5-editor-decoupled'; +import '../theme/theme.css'; +import { COMMON_PLUGINS, COMMON_SETTINGS } from './config'; + +//@ts-ignore +export default class DecoupledEditor extends DecoupledEditorBase { + public static override builtinPlugins = [ + ...COMMON_PLUGINS, + ]; +} diff --git a/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/config.ts b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/config.ts new file mode 100644 index 000000000..f385f81f6 --- /dev/null +++ b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/config.ts @@ -0,0 +1,162 @@ +import { FindAndReplace } from '@ckeditor/ckeditor5-find-and-replace'; +import { CKFinderUploadAdapter } from '@ckeditor/ckeditor5-adapter-ckfinder'; +import { Autoformat } from '@ckeditor/ckeditor5-autoformat'; +import { Bold } from '@ckeditor/ckeditor5-basic-styles'; +import { Italic } from '@ckeditor/ckeditor5-basic-styles'; +import { Superscript } from '@ckeditor/ckeditor5-basic-styles'; +import { Subscript } from '@ckeditor/ckeditor5-basic-styles'; +import { Underline } from '@ckeditor/ckeditor5-basic-styles'; +import { Strikethrough } from '@ckeditor/ckeditor5-basic-styles'; +import { Code } from '@ckeditor/ckeditor5-basic-styles'; +import { BlockQuote } from '@ckeditor/ckeditor5-block-quote'; +import { Heading } from '@ckeditor/ckeditor5-heading'; +import { Image, ImageInline } from '@ckeditor/ckeditor5-image'; +import { ImageCaption } from '@ckeditor/ckeditor5-image'; +import { ImageStyle } from '@ckeditor/ckeditor5-image'; +import { ImageToolbar } from '@ckeditor/ckeditor5-image'; +import { ImageUpload } from '@ckeditor/ckeditor5-image'; +import { ImageResize } from '@ckeditor/ckeditor5-image'; +import { Link } from '@ckeditor/ckeditor5-link'; +import { AutoLink } from '@ckeditor/ckeditor5-link'; +import { List } from '@ckeditor/ckeditor5-list'; +import { ListProperties } from '@ckeditor/ckeditor5-list'; +import { TodoList } from '@ckeditor/ckeditor5-list'; +import { Paragraph } from '@ckeditor/ckeditor5-paragraph'; +import { PasteFromOffice } from '@ckeditor/ckeditor5-paste-from-office'; +import { PictureEditing } from '@ckeditor/ckeditor5-image'; +import { Table } from '@ckeditor/ckeditor5-table'; +import { TableToolbar } from '@ckeditor/ckeditor5-table'; +import { TableProperties } from '@ckeditor/ckeditor5-table'; +import { TableCellProperties } from '@ckeditor/ckeditor5-table'; +import { TableCaption } from '@ckeditor/ckeditor5-table'; +import { TableSelection } from '@ckeditor/ckeditor5-table'; +import { TableColumnResize } from '@ckeditor/ckeditor5-table'; +import { HeadingButtonsUI } from '@ckeditor/ckeditor5-heading'; +import { ParagraphButtonUI } from '@ckeditor/ckeditor5-paragraph'; +import { TextTransformation } from '@ckeditor/ckeditor5-typing'; +import { Font } from '@ckeditor/ckeditor5-font'; +import { FontColor } from '@ckeditor/ckeditor5-font'; +import { FontBackgroundColor } from '@ckeditor/ckeditor5-font'; +import { CodeBlock } from '@ckeditor/ckeditor5-code-block'; +import { Mention } from '@ckeditor/ckeditor5-mention'; +import { Indent } from '@ckeditor/ckeditor5-indent'; +import { IndentBlock } from '@ckeditor/ckeditor5-indent'; +import { SelectAll } from '@ckeditor/ckeditor5-select-all'; +import { HorizontalLine } from '@ckeditor/ckeditor5-horizontal-line'; +import { Clipboard } from '@ckeditor/ckeditor5-clipboard'; +import { Enter } from '@ckeditor/ckeditor5-enter'; +import { ShiftEnter } from '@ckeditor/ckeditor5-enter'; +import { Typing } from '@ckeditor/ckeditor5-typing'; +import { Undo } from '@ckeditor/ckeditor5-undo'; +import { RemoveFormat } from '@ckeditor/ckeditor5-remove-format'; +import { SpecialCharacters, SpecialCharactersEssentials } from '@ckeditor/ckeditor5-special-characters'; +import { GeneralHtmlSupport } from "@ckeditor/ckeditor5-html-support"; +import Uploadfileplugin from "../../ckeditor5-file-upload/uploadfileplugin"; +import { PageBreak } from '@ckeditor/ckeditor5-page-break'; +import { TextPartLanguage } from "@ckeditor/ckeditor5-language"; +import { Style } from "../../ckeditor5-style"; + +import MentionCustomization from './mention_customization'; +import UploadimagePlugin from './uploadimage'; +import InternalLinkPlugin from './internallink'; +import ItalicAsEmPlugin from './italic_as_em'; +import MarkdownImportPlugin from './markdownimport'; +import CuttonotePlugin from './cuttonote'; +import IncludeNote from './includenote'; +import ReferenceLink from './referencelink'; +import indentBlockShortcutPlugin from './indent_block_shortcut'; +import removeFormatLinksPlugin from './remove_format_links'; + +import {SpecialCharactersEmoji} from "./special_characters_emoji"; + +// External plugins +import { Math, AutoformatMath } from '../../ckeditor5-math/src/index'; + +import { Mermaid } from "../../ckeditor5-mermaid/src/index"; + +import '../../ckeditor5-footnotes/src/footnote.css'; +import { Footnotes } from '../../ckeditor5-footnotes'; +import Kbd from "../../ckeditor5-keyboard-marker/src/Kbd"; +import { Admonition } from "../../ckeditor5-admonition"; +import StrikethroughAsDel from './strikethrough_as_del'; + +export const COMMON_PLUGINS = [ + // essentials package expanded to allow selectively disable Enter and ShiftEnter + Clipboard, Enter, SelectAll, ShiftEnter, Typing, Undo, + CKFinderUploadAdapter, + Autoformat, + Bold, + Italic, + Underline, + Strikethrough, + Code, + Superscript, + Subscript, + BlockQuote, + Heading, + Image, + ImageCaption, + ImageStyle, + ImageToolbar, + ImageUpload, + ImageResize, + ImageInline, + Link, + AutoLink, + List, + ListProperties, + TodoList, + Paragraph, + PasteFromOffice, + PictureEditing, + Table, + TableToolbar, + TableProperties, + TableCellProperties, + TableSelection, + TableCaption, + TableColumnResize, + Indent, + IndentBlock, + ParagraphButtonUI, + HeadingButtonsUI, + Uploadfileplugin, + UploadimagePlugin, + TextTransformation, + Font, + FontColor, + FontBackgroundColor, + CodeBlock, + SelectAll, + HorizontalLine, + RemoveFormat, + SpecialCharacters, + SpecialCharactersEssentials, + SpecialCharactersEmoji, + FindAndReplace, + Mention, + InternalLinkPlugin, + ItalicAsEmPlugin, + StrikethroughAsDel, + MarkdownImportPlugin, + CuttonotePlugin, + MentionCustomization, + IncludeNote, + ReferenceLink, + indentBlockShortcutPlugin, + removeFormatLinksPlugin, + PageBreak, + GeneralHtmlSupport, + TextPartLanguage, + Style, + + // External plugins + Math, + AutoformatMath, + Footnotes, + Mermaid, + Kbd, + Admonition +]; + +export const COMMON_SETTINGS = { }; diff --git a/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/cuttonote.js b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/cuttonote.js new file mode 100644 index 000000000..31a05fbab --- /dev/null +++ b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/cuttonote.js @@ -0,0 +1,59 @@ +import Plugin from '@ckeditor/ckeditor5-core/src/plugin'; +import scissorsIcon from './icons/scissors.svg'; +import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview'; +import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor'; + +export default class CutToNotePlugin extends Plugin { + init() { + this.htmlDataProcessor = new HtmlDataProcessor(); + + this.editor.ui.componentFactory.add( 'cutToNote', locale => { + const view = new ButtonView( locale ); + + view.set( { + label: 'Cut & paste selection to sub-note', + icon: scissorsIcon, + tooltip: true + } ); + + // Callback executed once the image is clicked. + view.on('execute', () => { + const editorEl = this.editor.editing.view.getDomRoot(); + const component = glob.getComponentByEl(editorEl); + + component.triggerCommand('cutIntoNote'); + }); + + return view; + } ); + + this.editor.getSelectedHtml = () => this.getSelectedHtml(); + this.editor.removeSelection = () => this.removeSelection(); + } + + getSelectedHtml() { + const model = this.editor.model; + const document = model.document; + + const content = this.editor.data.toView(model.getSelectedContent(document.selection)); + + return this.htmlDataProcessor.toData(content); + } + + async removeSelection() { + const model = this.editor.model; + + model.deleteContent(model.document.selection); + this.editor.execute("paragraph"); + + const component = this.getComponent(); + + await component.triggerCommand('saveNoteDetailNow'); + } + + getComponent() { + const editorEl = this.editor.editing.view.getDomRoot(); + + return glob.getComponentByEl( editorEl ); + } +} diff --git a/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/icons/markdown-mark.svg b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/icons/markdown-mark.svg new file mode 100644 index 000000000..171ea2548 --- /dev/null +++ b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/icons/markdown-mark.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/icons/note.svg b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/icons/note.svg new file mode 100644 index 000000000..f41b7b33d --- /dev/null +++ b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/icons/note.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/icons/scissors.svg b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/icons/scissors.svg new file mode 100644 index 000000000..76519256a --- /dev/null +++ b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/icons/scissors.svg @@ -0,0 +1,7 @@ + + + + + Svg Vector Icons : http://www.onlinewebfonts.com/icon + + \ No newline at end of file diff --git a/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/icons/trilium.svg b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/icons/trilium.svg new file mode 100644 index 000000000..f54de4f6d --- /dev/null +++ b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/icons/trilium.svg @@ -0,0 +1,4 @@ + + + + diff --git a/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/includenote.js b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/includenote.js new file mode 100644 index 000000000..72a465c47 --- /dev/null +++ b/_regroup/ckeditor5-build-trilium/packages/ckeditor5-build-trilium/src/includenote.js @@ -0,0 +1,176 @@ +import Plugin from '@ckeditor/ckeditor5-core/src/plugin'; +import {toWidget} from '@ckeditor/ckeditor5-widget/src/utils'; +import Widget from '@ckeditor/ckeditor5-widget/src/widget'; +import Command from '@ckeditor/ckeditor5-core/src/command'; +import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview'; +import noteIcon from './icons/note.svg'; + +export default class IncludeNote extends Plugin { + static get requires() { + return [ IncludeNoteEditing, IncludeNoteUI ]; + } +} + +class IncludeNoteUI extends Plugin { + init() { + const editor = this.editor; + const t = editor.t; + + // The "includeNote" button must be registered among the UI components of the editor + // to be displayed in the toolbar. + editor.ui.componentFactory.add( 'includeNote', locale => { + // The state of the button will be bound to the widget command. + const command = editor.commands.get( 'insertIncludeNote' ); + + // The button will be an instance of ButtonView. + const buttonView = new ButtonView( locale ); + + buttonView.set( { + // The t() function helps localize the editor. All strings enclosed in t() can be + // translated and change when the language of the editor changes. + label: t( 'Include note' ), + icon: noteIcon, + tooltip: true + } ); + + // Bind the state of the button to the command. + buttonView.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' ); + + // Execute the command when the button is clicked (executed). + this.listenTo( buttonView, 'execute', () => editor.execute( 'insertIncludeNote' ) ); + + return buttonView; + } ); + } +} + +class IncludeNoteEditing extends Plugin { + static get requires() { + return [ Widget ]; + } + + init() { + this._defineSchema(); + this._defineConverters(); + + this.editor.commands.add( 'insertIncludeNote', new InsertIncludeNoteCommand( this.editor ) ); + } + + _defineSchema() { + const schema = this.editor.model.schema; + + schema.register( 'includeNote', { + // Behaves like a self-contained object (e.g. an image). + isObject: true, + + allowAttributes: [ 'noteId', 'boxSize' ], + + // Allow in places where other blocks are allowed (e.g. directly in the root). + allowWhere: '$block' + } ); + } + + _defineConverters() { + const editor = this.editor; + const conversion = editor.conversion; + + // converters + conversion.for( 'upcast' ).elementToElement( { + model: ( viewElement, { writer: modelWriter } ) => { + + return modelWriter.createElement( 'includeNote', { + noteId: viewElement.getAttribute( 'data-note-id' ), + boxSize: viewElement.getAttribute( 'data-box-size' ), + } ); + }, + view: { + name: 'section', + classes: 'include-note' + } + } ); + conversion.for( 'dataDowncast' ).elementToElement( { + model: 'includeNote', + view: ( modelElement, { writer: viewWriter } ) => { + // it would make sense here to downcast to