# AGENTS.md

## Project summary
- SunEditor fork for Yoptacademy/Yoptatech. Vanilla JS WYSIWYG editor bundled with webpack 4.
- Primary outputs live in `dist/` (generated artifacts; do not edit directly).

## Key paths
- `src/suneditor.js`: main module that creates the editor instance.
- `src/suneditor_build.js`: production build entry; imports CSS and registers `window.SUNEDITOR` with all plugins.
- `src/lib/`: core editor logic (constructor, core, context, history, util).
- `src/plugins/`: plugin implementations.
  - `src/plugins/index.js`: plugin registry (command/submenu/dialog/fileBrowser exports).
  - `src/plugins/modules/`: shared modules (dialogs, fileBrowser, resizing, etc).
- `src/lang/`: language packs; `src/lang/index.js` aggregates.
- `src/assets/css/`: main editor + contents stylesheets.
- `scripts/dev-yopta.js`: watch build + sync into the Yopta Academy repo.
- `test/`: Karma/Jasmine tests and dev harness under `test/dev/`.
- `sample/`: static demo pages/assets.

## Build and dev
- `npm run dev`: webpack-dev-server using `test/dev/suneditor_build_test` entry, serves on `localhost:8080`.
- `npm run build`: production build (entry `src/suneditor_build`) -> `dist/suneditor.min.js` and `dist/css/suneditor.min.css`.
- `npm run build:watch`: production build in watch mode.
- `npm run dev:yopta`: webpack watch build + rsync `dist/` and `src/lang/` into
  `$YOPTA_ACADEMY_PATH/yopta/content/static/frontend/node_modules/suneditor-yoptatech`
  (default `YOPTA_ACADEMY_PATH=/Code/yopta_academy`). Requires `rsync`.
- Watch polling can be controlled via `WEBPACK_WATCH_POLL` or `CHOKIDAR_USEPOLLING`.

## Testing and lint
- `npm test`: Karma + Jasmine (loads `test/**/*.spec.js` in Chrome).
- `npm run lint`: JSHint on `src/` using `.jshintrc`.

## Conventions and guardrails
- ES6 modules with `'use strict'`; semicolons required (`asi: false` in `.jshintrc`).
- When adding/removing plugins, update `src/plugins/index.js` and related `.d.ts` files.
- When adding/removing languages, update `src/lang/index.js` and related `.d.ts` files.
- Keep type definitions (`src/**/*.d.ts`) in sync with JS changes.
- Do not edit `dist/` by hand; rebuild instead.

## Common edit targets
- Editor styling: `src/assets/css/suneditor.css`, `src/assets/css/suneditor-contents.css`.
- Plugin behavior: `src/plugins/**`.
- Core editor behavior: `src/lib/**`.
