Spring
Welcome to the Spring Framework-specific documentation for On-Codemerge, an advanced web editor designed for easy integration with Spring-based applications, enhancing Spring's powerful Java backend with rich frontend text editing capabilities.
Getting Started with Spring Framework
To integrate On-Codemerge into your Spring application, you'll need to set up the frontend environment where the editor will be utilized.
Installation
- Prepare Your Frontend Environment: If you are using a build system like Webpack for your frontend, you can install
on-codemerge
using npm or yarn. Alternatively, you can link to a CDN version directly in your HTML templates.
npm install --save on-codemerge
or
yarn add on-codemerge
Spring Framework Integration Example
Here's how to integrate On-Codemerge into a Spring application:
- Create a JavaScript File for the Editor: Place a JavaScript file in your
src/main/resources/static
directory (or wherever your static assets are located).
import EditorCore from 'on-codemerge';
import TextStylingButton from 'on-codemerge/textStylingButton';
import TableButton from 'on-codemerge/tableButton';
document.addEventListener('DOMContentLoaded', () => {
const editorElement = document.getElementById('editor');
if (editorElement) {
const editor = new EditorCore(editorElement);
editor.registerModule(new TextStylingButton());
editor.registerModule(new TableButton());
// ... additional configuration
editor.subscribeToContentChange((newContent) => {
console.log('Content changed:', newContent);
});
editor.setContent("Initial content goes here");
}
});
- Include the JavaScript in Your Spring View: In your Thymeleaf template (or other view technology), include the JavaScript file.
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<!-- Head contents -->
</head>
<body>
<div id="editor"></div>
<script th:src="@{/js/editor.js}"></script>
</body>
</html>
Use Thymeleaf’s th:src
to correctly reference the path to your JavaScript file.
- Controller Setup: Ensure you have a Spring controller method that returns the view containing the editor.
@Controller
public class YourController {
@GetMapping("/")
public String home(Model model) {
return "your_template";
}
}
By following these steps, you can integrate On-Codemerge into a Spring application, providing a powerful editing tool in your Java-based web projects. This integration involves setting up the editor in a JavaScript file and then embedding it within the Spring MVC framework, ensuring a seamless combination of Spring's backend capabilities with advanced frontend text editing features.