From b86c547a33b56e1b9e7b528bc9bc1952372451ae Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Mon, 18 Aug 2025 11:54:23 -0300 Subject: [PATCH 01/20] docs: add GitHub Actions workflow to trigger documentation updates on main branch changes --- .github/workflows/trigger-docs-update.yml | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/trigger-docs-update.yml diff --git a/.github/workflows/trigger-docs-update.yml b/.github/workflows/trigger-docs-update.yml new file mode 100644 index 0000000000..4923a4a39d --- /dev/null +++ b/.github/workflows/trigger-docs-update.yml @@ -0,0 +1,35 @@ +name: Trigger Documentation Update + +on: + push: + branches: + - main + paths: + # Trigger when extensions change + - 'packages/super-editor/src/extensions/**/*.js' + # - 'packages/super-editor/src/core/**/*.js' + # - 'packages/super-editor/src/components/**/*.js' + workflow_dispatch: # Manual trigger + +jobs: + trigger-docs: + runs-on: ubuntu-latest + steps: + - name: Trigger Documentation Repository Update + run: | + # Set the required variables + repo_owner="Harbour-Enterprises" + repo_name="SuperDoc-Docs" + event_type="docs-update" + + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.SUPERDOC_PAT }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/$repo_owner/$repo_name/dispatches \ + -d "{\"event_type\": \"$event_type\"}" + + - name: Notify Success + if: success() + run: echo "✅ Documentation update triggered successfully" \ No newline at end of file From cdbc1388febf75a1368eea69bcb46c74632d8a46 Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Mon, 18 Aug 2025 13:43:17 -0300 Subject: [PATCH 02/20] chore: add ESLint configuration for JSDoc validation in documentation files --- eslint.config.docs.mjs | 63 +++++++++++++++++++ package-lock.json | 135 +++++++++++++++++++++++++++++++++++------ package.json | 7 +++ 3 files changed, 186 insertions(+), 19 deletions(-) create mode 100644 eslint.config.docs.mjs diff --git a/eslint.config.docs.mjs b/eslint.config.docs.mjs new file mode 100644 index 0000000000..35f6871f69 --- /dev/null +++ b/eslint.config.docs.mjs @@ -0,0 +1,63 @@ +import jsdoc from 'eslint-plugin-jsdoc'; + +export default [ + { + files: ['packages/super-editor/src/extensions/**/*.js'], + plugins: { + jsdoc + }, + rules: { + // Start with just requiring JSDoc on public APIs + 'jsdoc/require-jsdoc': ['error', { + require: { + FunctionDeclaration: false, // function myFunc() {} + MethodDefinition: false, // class methods + ClassDeclaration: false, // class MyClass {} + ArrowFunctionExpression: false, // const func = () => {} + FunctionExpression: false // const func = function() {} + }, + contexts: [ + // Extension exports (Extension.create(...)) + 'ExportNamedDeclaration > VariableDeclaration > VariableDeclarator > CallExpression[callee.property.name="create"]', + + // Commands - both arrow functions and method definitions + 'Property[key.name="addCommands"] > ArrowFunctionExpression', + 'MethodDefinition[key.name="addCommands"]', + + // Helpers - both arrow functions and method definitions + 'Property[key.name="addHelpers"] > ArrowFunctionExpression', + 'MethodDefinition[key.name="addHelpers"]' + ] + }], + + // Validate existing JSDoc comments + 'jsdoc/require-param-type': 'error', // @param must have {Type} + 'jsdoc/require-returns': 'error', // Functions must document return + 'jsdoc/require-returns-type': 'error', // @returns must have {Type} + 'jsdoc/check-param-names': 'error', // @param names must match function params + 'jsdoc/check-types': 'error', // Validate type syntax (string not String) + 'jsdoc/require-hyphen-before-param-description': ['error', 'always'], // @param {Type} name - Description + + // Essential rules from standards + 'jsdoc/require-example': ['error', { // Commands need examples + contexts: [ + 'Property[key.name=/^(add|update|delete|set|toggle|reset)/]' + ] + }], + 'jsdoc/no-undefined-types': ['error', { + definedTypes: [ + // ProseMirror types + 'EditorState', 'Transaction', 'Node', 'Mark', 'Schema', + 'Selection', 'Editor', 'EditorView', + // DOM types + 'DOMRect', 'HTMLElement' + ] + }] + }, + settings: { + jsdoc: { + mode: 'typescript' + } + } + } +]; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 222ad3a6bd..f66c0fa15d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "@vuepress/theme-default": "^2.0.0-rc.60", "eslint": "^9.31.0", "eslint-config-prettier": "^9.1.0", + "eslint-plugin-jsdoc": "^54.1.0", "husky": "^9.1.7", "lint-staged": "^16.1.4", "prettier": "3.3.3", @@ -503,6 +504,23 @@ "integrity": "sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow==", "license": "MIT" }, + "node_modules/@es-joy/jsdoccomment": { + "version": "0.53.0", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.53.0.tgz", + "integrity": "sha512-Wyed8Wfn3vMNVwrZrgLMxmqwmlcCE1/RfUAOHFzMJb3QLH03mi9Yv1iOCZjif0yx5EZUeJ+17VD1MHPka9IQjQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.8", + "@typescript-eslint/types": "^8.39.1", + "comment-parser": "1.4.1", + "esquery": "^1.6.0", + "jsdoc-type-pratt-parser": "~4.8.0" + }, + "engines": { + "node": ">=20.11.0" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.25.8", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.8.tgz", @@ -2962,6 +2980,20 @@ "dev": true, "license": "MIT" }, + "node_modules/@typescript-eslint/types": { + "version": "8.39.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.39.1.tgz", + "integrity": "sha512-7sPDKQQp+S11laqTrhHqeAbsCfMkwJMrV7oTDvtDds4mEofJYir414bYKUEb8YPUm9QL3U+8f6L6YExSoAGdQw==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@ungap/structured-clone": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz", @@ -3956,6 +3988,16 @@ "license": "ISC", "optional": true }, + "node_modules/are-docs-informative": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/are-docs-informative/-/are-docs-informative-0.0.2.tgz", + "integrity": "sha512-ixiS0nLNNG5jNQzgZJNoUpBKdo9yTYZMGJ+QgT2jmjR7G7+QHRCc4v6LQ3NgE7EBJq+o0ams3waJwkrlBom8Ig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14" + } + }, "node_modules/are-we-there-yet": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz", @@ -5102,6 +5144,16 @@ "node": ">=20" } }, + "node_modules/comment-parser": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.1.tgz", + "integrity": "sha512-buhp5kePrmda3vhc5B9t7pUQXAb2Tnd0qgpkIhPhkHXxJpiPJ11H0ZEU0oBpJ2QztSbzG/ZxMj/CHsYJqRHmyg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 12.0.0" + } + }, "node_modules/compare-func": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz", @@ -6703,6 +6755,42 @@ "eslint": ">=7.0.0" } }, + "node_modules/eslint-plugin-jsdoc": { + "version": "54.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-54.1.0.tgz", + "integrity": "sha512-tZJuW6s3gtveVsg08IbJgmfgAA1SpSkEz7KjxPEVmyAO4fPlz7zsMHdxjyn+Zku1l+wejr2JUdTFTNirRgHOrQ==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@es-joy/jsdoccomment": "~0.53.0", + "are-docs-informative": "^0.0.2", + "comment-parser": "1.4.1", + "debug": "^4.4.1", + "escape-string-regexp": "^4.0.0", + "espree": "^10.4.0", + "esquery": "^1.6.0", + "parse-imports-exports": "^0.2.4", + "semver": "^7.7.2", + "spdx-expression-parse": "^4.0.0" + }, + "engines": { + "node": ">=20.11.0" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0" + } + }, + "node_modules/eslint-plugin-jsdoc/node_modules/spdx-expression-parse": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-4.0.0.tgz", + "integrity": "sha512-Clya5JIij/7C6bRR22+tnGXbc4VKlibKSVj2iHvVeX5iMW7s1SIQlqu699JkODJJIhh/pUu8L0/VLh8xflD+LQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, "node_modules/eslint-scope": { "version": "8.4.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz", @@ -7712,24 +7800,6 @@ } } }, - "node_modules/git-semver-tags/node_modules/conventional-commits-parser": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-6.2.0.tgz", - "integrity": "sha512-uLnoLeIW4XaoFtH37qEcg/SXMJmKF4vi7V0H2rnPueg+VEtFGA/asSCNTcq4M/GQ6QmlzchAEtOoDTtKqWeHag==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "meow": "^13.0.0" - }, - "bin": { - "conventional-commits-parser": "dist/cli/index.js" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/git-up": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/git-up/-/git-up-8.1.1.tgz", @@ -9069,6 +9139,16 @@ "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==", "license": "MIT" }, + "node_modules/jsdoc-type-pratt-parser": { + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.8.0.tgz", + "integrity": "sha512-iZ8Bdb84lWRuGHamRXFyML07r21pcwBrLkHEuHgEY5UbCouBwv7ECknDRKzsQIXMiqpPymqtIf8TC/shYKB5rw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/jsdom": { "version": "25.0.1", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-25.0.1.tgz", @@ -10997,6 +11077,16 @@ "node": ">= 0.10" } }, + "node_modules/parse-imports-exports": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/parse-imports-exports/-/parse-imports-exports-0.2.4.tgz", + "integrity": "sha512-4s6vd6dx1AotCx/RCI2m7t7GCh5bDRUtGNvRfHSP2wbBQdMi67pPe7mtzmgwcaQ8VKK/6IB7Glfyu3qdZJPybQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "parse-statements": "1.0.11" + } + }, "node_modules/parse-json": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", @@ -11025,6 +11115,13 @@ "protocols": "^2.0.0" } }, + "node_modules/parse-statements": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/parse-statements/-/parse-statements-1.0.11.tgz", + "integrity": "sha512-HlsyYdMBnbPQ9Jr/VgJ1YF4scnldvJpJxCVx6KgqPL4dxppsWrJHCIIxQXMJrqGnsRkNPATbeMJ8Yxu7JMsYcA==", + "dev": true, + "license": "MIT" + }, "node_modules/parse-url": { "version": "9.2.0", "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-9.2.0.tgz", @@ -15864,7 +15961,7 @@ }, "packages/superdoc": { "name": "@harbour-enterprises/superdoc", - "version": "0.15.10-next.4", + "version": "0.15.15-next.3", "license": "AGPL-3.0", "dependencies": { "buffer-crc32": "^1.0.0", diff --git a/package.json b/package.json index 1c4749f016..b048669134 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "format:check": "prettier --check \"**/*.{js,jsx,vue,css,scss,json,md}\"", "lint": "eslint", "lint:fix": "eslint --fix", + "docs:check": "eslint packages/super-editor/src/extensions/field-annotation/**/*.js -c eslint.config.docs.mjs", "docs:dev": "vuepress dev docs", "docs:build": "vuepress build docs", "pack": "npm run build:super-editor && npm --prefix ./packages/superdoc run pack", @@ -37,6 +38,11 @@ "eslint --fix", "prettier --write" ], + "packages/super-editor/src/extensions/field-annotation/**/*.js": [ + "eslint -c eslint.config.docs.mjs", + "eslint --fix", + "prettier --write" + ], "*.{css,scss,json,md}": [ "prettier --write" ], @@ -54,6 +60,7 @@ "@vuepress/theme-default": "^2.0.0-rc.60", "eslint": "^9.31.0", "eslint-config-prettier": "^9.1.0", + "eslint-plugin-jsdoc": "^54.1.0", "husky": "^9.1.7", "lint-staged": "^16.1.4", "prettier": "3.3.3", From 7c22fd7e5d0f691ecb168f7057701e3a50a0d01c Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Wed, 20 Aug 2025 17:13:53 -0300 Subject: [PATCH 03/20] chore: update ESLint configuration for JSDoc and enhance type definitions in field annotation --- eslint.config.docs.mjs | 104 +++++++++----- package.json | 3 +- packages/super-editor/package.json | 8 +- .../super-editor/src/core/types/index.d.ts | 24 ++++ .../field-annotation/field-annotation.js | 136 ++---------------- .../extensions/field-annotation/types.d.ts | 18 +++ packages/super-editor/tsconfig.json | 17 +-- 7 files changed, 140 insertions(+), 170 deletions(-) create mode 100644 packages/super-editor/src/core/types/index.d.ts create mode 100644 packages/super-editor/src/extensions/field-annotation/types.d.ts diff --git a/eslint.config.docs.mjs b/eslint.config.docs.mjs index 35f6871f69..6455e3473a 100644 --- a/eslint.config.docs.mjs +++ b/eslint.config.docs.mjs @@ -1,3 +1,4 @@ +// .eslintrc.jsdoc.js import jsdoc from 'eslint-plugin-jsdoc'; export default [ @@ -7,57 +8,86 @@ export default [ jsdoc }, rules: { - // Start with just requiring JSDoc on public APIs - 'jsdoc/require-jsdoc': ['error', { + // Require minimal JSDoc for extensions + 'jsdoc/require-jsdoc': ['warn', { + publicOnly: true, require: { - FunctionDeclaration: false, // function myFunc() {} - MethodDefinition: false, // class methods - ClassDeclaration: false, // class MyClass {} - ArrowFunctionExpression: false, // const func = () => {} - FunctionExpression: false // const func = function() {} + FunctionDeclaration: false, + MethodDefinition: false, + ClassDeclaration: false, + ArrowFunctionExpression: false, + FunctionExpression: false }, contexts: [ - // Extension exports (Extension.create(...)) - 'ExportNamedDeclaration > VariableDeclaration > VariableDeclarator > CallExpression[callee.property.name="create"]', + // Document the extension module + 'ExportNamedDeclaration > VariableDeclaration > VariableDeclarator > CallExpression[callee.property.name="create"]' - // Commands - both arrow functions and method definitions - 'Property[key.name="addCommands"] > ArrowFunctionExpression', - 'MethodDefinition[key.name="addCommands"]', - - // Helpers - both arrow functions and method definitions - 'Property[key.name="addHelpers"] > ArrowFunctionExpression', - 'MethodDefinition[key.name="addHelpers"]' + // Note: We document commands/helpers with @param/@returns + // inside addCommands/addHelpers, not with require-jsdoc ] }], - // Validate existing JSDoc comments - 'jsdoc/require-param-type': 'error', // @param must have {Type} - 'jsdoc/require-returns': 'error', // Functions must document return - 'jsdoc/require-returns-type': 'error', // @returns must have {Type} - 'jsdoc/check-param-names': 'error', // @param names must match function params - 'jsdoc/check-types': 'error', // Validate type syntax (string not String) - 'jsdoc/require-hyphen-before-param-description': ['error', 'always'], // @param {Type} name - Description + // When JSDoc exists, validate it's correct + 'jsdoc/require-param': 'error', // All params must be documented + 'jsdoc/require-param-type': 'error', // @param must have {Type} + 'jsdoc/check-param-names': 'error', // @param names must match + 'jsdoc/check-types': 'error', // Valid type syntax (string not String) - // Essential rules from standards - 'jsdoc/require-example': ['error', { // Commands need examples - contexts: [ - 'Property[key.name=/^(add|update|delete|set|toggle|reset)/]' - ] - }], - 'jsdoc/no-undefined-types': ['error', { + // Optional - we use @returns {Function} or skip it + 'jsdoc/require-returns': 'off', + 'jsdoc/require-returns-type': 'off', + + // Don't require descriptions if obvious + 'jsdoc/require-param-description': 'off', + 'jsdoc/require-returns-description': 'off', + 'jsdoc/require-description': 'off', + + // Don't require examples - nice to have but not essential + 'jsdoc/require-example': 'off', + + // Simple formatting + 'jsdoc/require-hyphen-before-param-description': 'off', // Optional: @param {Type} name - Description + + // Allow types from our .d.ts files and common types + 'jsdoc/no-undefined-types': ['warn', { definedTypes: [ - // ProseMirror types - 'EditorState', 'Transaction', 'Node', 'Mark', 'Schema', - 'Selection', 'Editor', 'EditorView', - // DOM types - 'DOMRect', 'HTMLElement' + // Allow any type that starts with capital letter (likely imported) + '/^[A-Z]/', + + // Common utility types + 'Partial', 'Required', 'Readonly', 'Pick', 'Omit', + + // Built-in types + 'Function', 'Object', 'Array', 'Promise', + + // DOM + 'HTMLElement', 'Element', 'Event' ] - }] + }], + + // Don't enforce these + 'jsdoc/valid-types': 'off', // We use TypeScript syntax + 'jsdoc/check-tag-names': 'off', // Allow @module, @typedef, etc. + 'jsdoc/check-alignment': 'off', // Don't worry about alignment + 'jsdoc/multiline-blocks': 'off' // Allow single or multi-line }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', // Understand TypeScript syntax in JSDoc + preferredTypes: { + object: 'Object', // Use Object not object + array: 'Array', // Use Array not array + 'Array.<>': 'Array<>', // Use Array not Array. + } } } + }, + + // Optional: Stricter rules for core types file + { + files: ['packages/super-editor/src/types/*.d.ts'], + rules: { + // TypeScript will handle these files + } } ]; \ No newline at end of file diff --git a/package.json b/package.json index b048669134..5ebd114720 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ "format:check": "prettier --check \"**/*.{js,jsx,vue,css,scss,json,md}\"", "lint": "eslint", "lint:fix": "eslint --fix", - "docs:check": "eslint packages/super-editor/src/extensions/field-annotation/**/*.js -c eslint.config.docs.mjs", + "lint:jsdoc": "eslint packages/super-editor/src/extensions/field-annotation/field-annotation.js --config eslint.config.docs.mjs", + "lint:jsdoc:fix": "eslint packages/super-editor/src/extensions/field-annotation/field-annotation.js --config eslint.config.docs.mjs --fix", "docs:dev": "vuepress dev docs", "docs:build": "vuepress build docs", "pack": "npm run build:super-editor && npm --prefix ./packages/superdoc run pack", diff --git a/packages/super-editor/package.json b/packages/super-editor/package.json index 0f72efc18b..8f291e5e14 100644 --- a/packages/super-editor/package.json +++ b/packages/super-editor/package.json @@ -39,10 +39,14 @@ "scripts": { "dev": "vite", "preview": "vite preview", - "build": "vite build && tsc", + "build": "npm run types:check && npm run build:js && npm run types:build", + "build:js": "vite build", + "build:watch": "vite build --watch --logLevel warn", "clean": "rm -rf dist", "test": "vitest", - "build:watch": "vite build --watch --logLevel warn", + "types:check": "tsc --noEmit", + "types:build": "tsc --emitDeclarationOnly", + "types:watch": "tsc --noEmit --watch", "pack": "rm *.tgz 2>/dev/null || true && npm run build && npm pack && mv harbour-enterprises-super-editor-0.0.1-alpha.0.tgz ./super-editor.tgz" }, "dependencies": { diff --git a/packages/super-editor/src/core/types/index.d.ts b/packages/super-editor/src/core/types/index.d.ts new file mode 100644 index 0000000000..acafe59a05 --- /dev/null +++ b/packages/super-editor/src/core/types/index.d.ts @@ -0,0 +1,24 @@ +import type { + EditorState, + Transaction +} from 'prosemirror-state'; +import type { EditorView } from 'prosemirror-view'; + +// Re-export ProseMirror types +export type { + EditorState, + Transaction, + EditorView +}; + +// Simple command types - no generics needed +export interface CommandProps { + state: EditorState; + tr: Transaction; + view?: EditorView; + dispatch?: (tr: Transaction) => void; + editor: any; +} + +// Simple, non-generic Command type +export type Command = (...args: any[]) => (props: CommandProps) => boolean; \ No newline at end of file diff --git a/packages/super-editor/src/extensions/field-annotation/field-annotation.js b/packages/super-editor/src/extensions/field-annotation/field-annotation.js index 0f15d8be27..b5c223dad2 100644 --- a/packages/super-editor/src/extensions/field-annotation/field-annotation.js +++ b/packages/super-editor/src/extensions/field-annotation/field-annotation.js @@ -1,3 +1,8 @@ +/** + * @typedef {import('./types').FieldAttributes} FieldAttributes + * @typedef {import('./types').FieldValue} FieldValue + */ + import { Node, Attribute } from '@core/index.js'; import { FieldAnnotationView } from './FieldAnnotationView.js'; import { FieldAnnotationPlugin } from './FieldAnnotationPlugin.js'; @@ -16,6 +21,10 @@ export const fieldAnnotationName = 'fieldAnnotation'; export const annotationClass = 'annotation'; export const annotationContentClass = 'annotation-content'; +/** + * Field Annotation - Adds form fields to documents + * @module FieldAnnotation + */ export const FieldAnnotation = Node.create({ name: 'fieldAnnotation', @@ -429,16 +438,11 @@ export const FieldAnnotation = Node.create({ return { /** - * Add field annotation. - * @param pos The position in the doc. - * @param attrs The attributes. - * @example - * editor.commands.addFieldAnnotation(0, { - * displayLabel: 'Enter your info', - * fieldId: `123`, - * fieldType: 'TEXTINPUT', - * fieldColor: '#980043', - * }) + * Add field at position + * @param {number} pos + * @param {Partial} attrs // NOTE: attrs = {} doesn't match the FieldAttributes + * @param {boolean} [editorFocus] + * @returns {Function} */ addFieldAnnotation: (pos, attrs = {}, editorFocus = false) => @@ -485,19 +489,6 @@ export const FieldAnnotation = Node.create({ return commands.addFieldAnnotation(from, attrs, editorFocus); }, - /** - * Replace field annotation. - * @param fieldsArray array of fields with attrs to add as annotation. - * @example - * editor.commands.replaceWithFieldAnnotation([ - * from: 20, - * to: 45, - * attrs: { - * fieldType: 'TEXTINPUT' - * fieldColor: '#980043' - * } - * ]) - */ replaceWithFieldAnnotation: (fieldsArray) => ({ editor, dispatch, tr }) => { @@ -530,12 +521,6 @@ export const FieldAnnotation = Node.create({ return true; }, - /** - * Replace annotations with a label (as text node) in selection. - * @param options Additional options. - * @example - * editor.commands.replaceFieldAnnotationsWithLabelInSelection() - */ replaceFieldAnnotationsWithLabelInSelection: (options = {}) => ({ commands }) => { @@ -545,15 +530,6 @@ export const FieldAnnotation = Node.create({ }); }, - /** - * Replace annotations with a label (as text node). - * @param fieldIdOrArray The field ID or array of field IDs. - * @param options.isInSelection Find in selection instead of field IDs. - * @param options.addToHistory Add to history or not. - * @param options.types Annotation types to replace. - * @example - * editor.commands.replaceFieldAnnotationsWithLabel(['1', '2']) - */ replaceFieldAnnotationsWithLabel: (fieldIdOrArray, { isInSelection = false, addToHistory = false, types = annotationTypes } = {}) => ({ dispatch, state, tr }) => { @@ -599,11 +575,6 @@ export const FieldAnnotation = Node.create({ return true; }, - /** - * Resets all annotations to default values. - * @example - * editor.commands.resetFieldAnnotations() - */ resetFieldAnnotations: () => ({ dispatch, state, tr }) => { @@ -644,19 +615,6 @@ export const FieldAnnotation = Node.create({ return true; }, - /** - * Update annotations associated with a field. - * @param fieldIdOrArray The field ID or array of field IDs. - * @param attrs The attributes. - * @example - * editor.commands.updateFieldAnnotations('123', { - * displayLabel: 'Updated!', - * }) - * @example - * editor.commands.updateFieldAnnotations(['123', '456'], { - * displayLabel: 'Updated!', - * }) - */ updateFieldAnnotations: (fieldIdOrArray, attrs = {}) => ({ dispatch, state, commands }) => { @@ -673,13 +631,6 @@ export const FieldAnnotation = Node.create({ return true; }, - /** - * Update particular annotation's attributes. - * @param annotation field annotation node to be updated. - * @param attrs The attributes. - * - * Used for a case when multiple annotations for one input presented - */ updateFieldAnnotation: (annotation, attrs = {}) => ({ dispatch, commands }) => { @@ -703,11 +654,6 @@ export const FieldAnnotation = Node.create({ return true; }, - /** - * Update the attributes of annotations. - * @param annotations The annotations array [{pos, node}]. - * @param attrs The attributes object. - */ updateFieldAnnotationsAttributes: (annotations, attrs = {}) => ({ dispatch, tr }) => { @@ -733,14 +679,6 @@ export const FieldAnnotation = Node.create({ return true; }, - /** - * Delete annotations associated with a field. - * @param fieldIdOrArray The field ID or array of field IDs. - * @example - * editor.commands.deleteFieldAnnotations('123') - * @example - * editor.commands.deleteFieldAnnotations(['123', '456']) - */ deleteFieldAnnotations: (fieldIdOrArray) => ({ dispatch, state, tr }) => { @@ -810,15 +748,6 @@ export const FieldAnnotation = Node.create({ return true; }, - /** - * Delete a portion of annotations associated with a field. - * @param fieldIdOrArray The field ID or array of field IDs. - * @param end index at which to end extraction - * @example - * editor.commands.sliceFieldAnnotations('123', 5) - will remove a portion of annotations array starting from index 6 - * @example - * editor.commands.sliceFieldAnnotations(['123', '456'], 5) - */ sliceFieldAnnotations: (fieldIdOrArray, end) => ({ dispatch, state, tr }) => { @@ -846,17 +775,6 @@ export const FieldAnnotation = Node.create({ return true; }, - /** - * Set `hidden` for annotations matching predicate. - * Other annotations become unhidden. - * @param predicate The predicate function. - * @param unsetFromOthers If should unset hidden from other annotations. - * @example - * editor.commands.setFieldAnnotationsHiddenByCondition((node) => { - * let ids = ['111', '222', '333']; - * return ids.includes(node.attrs.fieldId); - * }) - */ setFieldAnnotationsHiddenByCondition: (predicate = () => false, unsetFromOthers = false) => ({ dispatch, state, chain }) => { @@ -886,11 +804,6 @@ export const FieldAnnotation = Node.create({ return true; }, - /** - * Unset `hidden` for all annotations. - * @example - * editor.commands.unsetFieldAnnotationsHidden() - */ unsetFieldAnnotationsHidden: () => ({ dispatch, state, commands }) => { @@ -907,14 +820,6 @@ export const FieldAnnotation = Node.create({ return true; }, - /** - * Set `visibility` for all annotations (without changing the layout). - * @param visibility The visibility value (visible, hidden). - * @example - * editor.commands.setFieldAnnotationsVisibility('visible'); - * @example - * editor.commands.setFieldAnnotationsVisibility('hidden'); - */ setFieldAnnotationsVisibility: (visibility = 'visible') => ({ dispatch, state, commands }) => { @@ -939,19 +844,6 @@ export const FieldAnnotation = Node.create({ return true; }, - /** - * Set `highlighted` for annotations matching predicate. - * @param predicate The predicate function. - * @param highlighted The highlighted attribute. - * @example - * editor.commands.setFieldAnnotationsHighlighted((node) => { - * let ids = ['111', '222', '333']; - * return ids.includes(node.attrs.fieldId); - * }, false) - * @example Set for all annotations. - * editor.commands.setFieldAnnotationsHighlighted(() => true, false) - * editor.commands.setFieldAnnotationsHighlighted(() => true, true) - */ setFieldAnnotationsHighlighted: (predicate = () => false, highlighted = true) => ({ dispatch, state, commands }) => { diff --git a/packages/super-editor/src/extensions/field-annotation/types.d.ts b/packages/super-editor/src/extensions/field-annotation/types.d.ts new file mode 100644 index 0000000000..b128dcf2c2 --- /dev/null +++ b/packages/super-editor/src/extensions/field-annotation/types.d.ts @@ -0,0 +1,18 @@ +export type FieldType = 'text' | 'checkbox' | 'image' | 'html' | 'link' | 'signature'; + +// NOTE: verify what attrs are required and what are optional +// To avoid using Partial +export interface FieldAttributes { + fieldId: string; + displayLabel: string; + defaultDisplayLabel?: string; + hash?: string; + type?: FieldType; + fieldColor?: string; + hidden?: boolean; +} + +export interface FieldValue { + input_id: string; + input_value: string | boolean; +} \ No newline at end of file diff --git a/packages/super-editor/tsconfig.json b/packages/super-editor/tsconfig.json index fc72b654a6..31a6aab679 100644 --- a/packages/super-editor/tsconfig.json +++ b/packages/super-editor/tsconfig.json @@ -1,14 +1,15 @@ { - "include": ["./src/**/*"], "compilerOptions": { + "checkJs": true, "allowJs": true, + "moduleResolution": "node", + "target": "ES2020", + "lib": ["ES2020", "DOM"], + "skipLibCheck": true, "declaration": true, "emitDeclarationOnly": true, - "outDir": "dist", - "declarationMap": true, - "skipLibCheck": true, - "module": "NodeNext", - "moduleResolution": "NodeNext", - "typeRoots": ["./node_modules/@types/*"] - } + "outDir": "dist" + }, + "include": ["src/extensions/field-annotation/**/*", "src/core/types/index.d.ts"], + "exclude": ["node_modules", "dist", "**/*.test.js"] } From 2414d83b8b213c669bc047e781f506b918266a8c Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Wed, 20 Aug 2025 17:29:29 -0300 Subject: [PATCH 04/20] chore: refine field annotation file structure and suppress TypeScript errors --- package.json | 2 +- packages/super-editor/src/core/helpers/annotator.js | 1 + .../super-editor/src/core/helpers/documentSectionHelpers.js | 1 + packages/super-editor/src/core/helpers/getActiveFormatting.js | 1 + .../src/extensions/field-annotation/FieldAnnotationPlugin.js | 2 ++ .../src/extensions/field-annotation/FieldAnnotationView.js | 1 + .../cleanup-commands/cleanUpListsWithAnnotations.js | 1 + .../src/extensions/field-annotation/field-annotation.js | 4 ++++ .../fieldAnnotationHelpers/findFieldAnnotationsByFieldId.js | 1 + .../findHeaderFooterAnnotationsByFieldId.js | 1 + .../fieldAnnotationHelpers/findRemovedFieldAnnotations.js | 1 + .../fieldAnnotationHelpers/getAllFieldAnnotations.js | 1 + .../fieldAnnotationHelpers/getAllFieldAnnotationsWithRect.js | 1 + .../fieldAnnotationHelpers/getHeaderFooterAnnotations.js | 1 + packages/super-editor/tsconfig.json | 2 +- 15 files changed, 19 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5ebd114720..3fb2e0adda 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint --fix", "prettier --write" ], - "packages/super-editor/src/extensions/field-annotation/**/*.js": [ + "packages/super-editor/src/extensions/field-annotation/field-annotation.js": [ "eslint -c eslint.config.docs.mjs", "eslint --fix", "prettier --write" diff --git a/packages/super-editor/src/core/helpers/annotator.js b/packages/super-editor/src/core/helpers/annotator.js index 25a8bb49ca..db839bacc7 100644 --- a/packages/super-editor/src/core/helpers/annotator.js +++ b/packages/super-editor/src/core/helpers/annotator.js @@ -1,3 +1,4 @@ +// @ts-nocheck import { Fragment } from 'prosemirror-model'; import { createHeaderFooterEditor, onHeaderFooterDataUpdate } from '@extensions/pagination/pagination-helpers.js'; diff --git a/packages/super-editor/src/core/helpers/documentSectionHelpers.js b/packages/super-editor/src/core/helpers/documentSectionHelpers.js index 467dce7135..3aeb94695e 100644 --- a/packages/super-editor/src/core/helpers/documentSectionHelpers.js +++ b/packages/super-editor/src/core/helpers/documentSectionHelpers.js @@ -1,3 +1,4 @@ +// @ts-nocheck import { DOMSerializer } from 'prosemirror-model'; /** diff --git a/packages/super-editor/src/core/helpers/getActiveFormatting.js b/packages/super-editor/src/core/helpers/getActiveFormatting.js index 8e9beae004..e2d63d1816 100644 --- a/packages/super-editor/src/core/helpers/getActiveFormatting.js +++ b/packages/super-editor/src/core/helpers/getActiveFormatting.js @@ -31,6 +31,7 @@ export function getActiveFormatting(editor) { const linkMark = findMark(state, linkMarkType); if (linkMark) { + // @ts-ignore let { from, to, attrs } = linkMark; if (selection.from >= from && selection.to <= to) { diff --git a/packages/super-editor/src/extensions/field-annotation/FieldAnnotationPlugin.js b/packages/super-editor/src/extensions/field-annotation/FieldAnnotationPlugin.js index bfb868efbb..42eedbc095 100644 --- a/packages/super-editor/src/extensions/field-annotation/FieldAnnotationPlugin.js +++ b/packages/super-editor/src/extensions/field-annotation/FieldAnnotationPlugin.js @@ -78,9 +78,11 @@ export const FieldAnnotationPlugin = (options = {}) => { if (!event.target) return false; let { target } = event; + // @ts-ignore let isAnnotationField = target.classList?.contains(annotationClass); if (isAnnotationField) { + // @ts-ignore event.dataTransfer?.setDragImage(target, 0, 0); } diff --git a/packages/super-editor/src/extensions/field-annotation/FieldAnnotationView.js b/packages/super-editor/src/extensions/field-annotation/FieldAnnotationView.js index bf9e5536f2..f7b541d259 100644 --- a/packages/super-editor/src/extensions/field-annotation/FieldAnnotationView.js +++ b/packages/super-editor/src/extensions/field-annotation/FieldAnnotationView.js @@ -1,3 +1,4 @@ +// @ts-nocheck import { Attribute } from '@core/index.js'; import { NodeSelection } from 'prosemirror-state'; diff --git a/packages/super-editor/src/extensions/field-annotation/cleanup-commands/cleanUpListsWithAnnotations.js b/packages/super-editor/src/extensions/field-annotation/cleanup-commands/cleanUpListsWithAnnotations.js index 59c8c4e7ba..7311f8c43d 100644 --- a/packages/super-editor/src/extensions/field-annotation/cleanup-commands/cleanUpListsWithAnnotations.js +++ b/packages/super-editor/src/extensions/field-annotation/cleanup-commands/cleanUpListsWithAnnotations.js @@ -1,4 +1,5 @@ import { getAllFieldAnnotations } from '../fieldAnnotationHelpers/index.js'; +// @ts-ignore import { findParentNodeClosestToPos } from '@core/helpers/index.js'; /** diff --git a/packages/super-editor/src/extensions/field-annotation/field-annotation.js b/packages/super-editor/src/extensions/field-annotation/field-annotation.js index b5c223dad2..e218c7d6ea 100644 --- a/packages/super-editor/src/extensions/field-annotation/field-annotation.js +++ b/packages/super-editor/src/extensions/field-annotation/field-annotation.js @@ -3,6 +3,7 @@ * @typedef {import('./types').FieldValue} FieldValue */ +// @ts-ignore import { Node, Attribute } from '@core/index.js'; import { FieldAnnotationView } from './FieldAnnotationView.js'; import { FieldAnnotationPlugin } from './FieldAnnotationPlugin.js'; @@ -12,6 +13,7 @@ import { findFieldAnnotationsBetween, } from './fieldAnnotationHelpers/index.js'; import { toHex } from 'color2k'; +// @ts-ignore import { parseSizeUnit, minMax } from '@core/utilities/index.js'; import { NodeSelection, Selection } from 'prosemirror-state'; import { generateDocxRandomId } from '../../core/helpers/index.js'; @@ -787,6 +789,7 @@ export const FieldAnnotation = Node.create({ if (dispatch) { let otherAnnotations = []; let matchedAnnotations = annotations.filter((annotation) => { + // @ts-ignore if (predicate(annotation.node)) return annotation; else otherAnnotations.push(annotation); }); @@ -855,6 +858,7 @@ export const FieldAnnotation = Node.create({ if (dispatch) { let matchedAnnotations = annotations.filter((annotation) => { + // @ts-ignore if (predicate(annotation.node)) return annotation; }); diff --git a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findFieldAnnotationsByFieldId.js b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findFieldAnnotationsByFieldId.js index 153c4b0178..8f82f1c246 100644 --- a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findFieldAnnotationsByFieldId.js +++ b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findFieldAnnotationsByFieldId.js @@ -1,3 +1,4 @@ +// @ts-ignore import { helpers } from '@core/index.js'; const { findChildren } = helpers; diff --git a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findHeaderFooterAnnotationsByFieldId.js b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findHeaderFooterAnnotationsByFieldId.js index 5b808f1ebc..af09ead4fa 100644 --- a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findHeaderFooterAnnotationsByFieldId.js +++ b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findHeaderFooterAnnotationsByFieldId.js @@ -1,3 +1,4 @@ +// @ts-ignore import { helpers } from '@core/index.js'; import { getAllHeaderFooterEditors } from '../../../core/helpers/annotator.js'; diff --git a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findRemovedFieldAnnotations.js b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findRemovedFieldAnnotations.js index 2cc51e3364..a1ab20b66b 100644 --- a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findRemovedFieldAnnotations.js +++ b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findRemovedFieldAnnotations.js @@ -38,6 +38,7 @@ export function findRemovedFieldAnnotations(tr) { function transactionDeletedAnything(tr) { return tr.steps.some((step) => { + // @ts-ignore if (step instanceof ReplaceStep || step instanceof ReplaceAroundStep) { return step.from !== step.to; } diff --git a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getAllFieldAnnotations.js b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getAllFieldAnnotations.js index ad19757d9a..2652bfa049 100644 --- a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getAllFieldAnnotations.js +++ b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getAllFieldAnnotations.js @@ -1,3 +1,4 @@ +// @ts-ignore import { helpers } from '@core/index.js'; const { findChildren } = helpers; diff --git a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getAllFieldAnnotationsWithRect.js b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getAllFieldAnnotationsWithRect.js index 690296acf5..454d109bb8 100644 --- a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getAllFieldAnnotationsWithRect.js +++ b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getAllFieldAnnotationsWithRect.js @@ -1,3 +1,4 @@ +// @ts-ignore import { posToDOMRect } from '@core/helpers/index.js'; import { getAllFieldAnnotations } from './getAllFieldAnnotations.js'; diff --git a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getHeaderFooterAnnotations.js b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getHeaderFooterAnnotations.js index 63f2c49adb..badf29ed7e 100644 --- a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getHeaderFooterAnnotations.js +++ b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getHeaderFooterAnnotations.js @@ -1,3 +1,4 @@ +// @ts-ignore import { getAllHeaderFooterEditors } from '@core/helpers/annotator.js'; import { getAllFieldAnnotations } from './index.js'; diff --git a/packages/super-editor/tsconfig.json b/packages/super-editor/tsconfig.json index 31a6aab679..e463f8e029 100644 --- a/packages/super-editor/tsconfig.json +++ b/packages/super-editor/tsconfig.json @@ -10,6 +10,6 @@ "emitDeclarationOnly": true, "outDir": "dist" }, - "include": ["src/extensions/field-annotation/**/*", "src/core/types/index.d.ts"], + "include": ["src/extensions/field-annotation/field-annotation.js", "src/core/types/index.d.ts"], "exclude": ["node_modules", "dist", "**/*.test.js"] } From aaebb579d01fe2a2db10dceaa92731ac758a4de0 Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Wed, 20 Aug 2025 17:44:27 -0300 Subject: [PATCH 05/20] docs: enhance Editor type definition in SuperDoc.js for improved clarity and structure --- packages/superdoc/src/core/SuperDoc.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/superdoc/src/core/SuperDoc.js b/packages/superdoc/src/core/SuperDoc.js index 38cb36a7af..db61f1aa4c 100644 --- a/packages/superdoc/src/core/SuperDoc.js +++ b/packages/superdoc/src/core/SuperDoc.js @@ -50,7 +50,17 @@ import { initSuperdocYdoc, initCollaborationComments, makeDocumentsCollaborative * @property {Object} [toolbar] Toolbar module configuration */ -/** @typedef {import('@harbour-enterprises/super-editor').Editor} Editor */ +/** + * @typedef {Object} Editor + * @property {Object} options - Editor options + * @property {Function} commands - Editor commands + * @property {Function} getHTML - Get HTML content + * @property {Function} exportDocx - Export to DOCX + * @property {Function} setDocumentMode - Set document mode + * @property {Function} focus - Focus the editor + * @property {Function} setHighContrastMode - Set high contrast mode + * @property {Object} toolbar - Toolbar instance + */ /** * @typedef {string} DocumentMode From a47573061b385d443431460e6b1da99b2b78290d Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Wed, 20 Aug 2025 18:03:41 -0300 Subject: [PATCH 06/20] docs: enhance JSDoc comments for field annotation methods to improve clarity and type definitions --- .../field-annotation/field-annotation.js | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/packages/super-editor/src/extensions/field-annotation/field-annotation.js b/packages/super-editor/src/extensions/field-annotation/field-annotation.js index e218c7d6ea..a3cc76ad0d 100644 --- a/packages/super-editor/src/extensions/field-annotation/field-annotation.js +++ b/packages/super-editor/src/extensions/field-annotation/field-annotation.js @@ -1,6 +1,7 @@ /** * @typedef {import('./types').FieldAttributes} FieldAttributes * @typedef {import('./types').FieldValue} FieldValue + * @typedef {import('./types').FieldType} FieldType */ // @ts-ignore @@ -440,10 +441,10 @@ export const FieldAnnotation = Node.create({ return { /** - * Add field at position - * @param {number} pos - * @param {Partial} attrs // NOTE: attrs = {} doesn't match the FieldAttributes - * @param {boolean} [editorFocus] + * Add a field annotation at a specific position + * @param {number} pos - Document position where to insert the field + * @param {Partial} [attrs={}] - Field attributes + * @param {boolean} [editorFocus=false] - Whether to focus the editor after insertion * @returns {Function} */ addFieldAnnotation: @@ -484,6 +485,12 @@ export const FieldAnnotation = Node.create({ return true; }, + /** + * Add a field annotation at the current selection + * @param {Partial} [attrs={}] - Field attributes + * @param {boolean} [editorFocus=false] - Whether to focus the editor + * @returns {Function} + */ addFieldAnnotationAtSelection: (attrs = {}, editorFocus = false) => ({ state, commands }) => { @@ -491,6 +498,11 @@ export const FieldAnnotation = Node.create({ return commands.addFieldAnnotation(from, attrs, editorFocus); }, + /** + * Replace text ranges with field annotations + * @param {Array<{from: number, to: number, attrs: Partial}>} fieldsArray - Array of replacements + * @returns {Function} + */ replaceWithFieldAnnotation: (fieldsArray) => ({ editor, dispatch, tr }) => { @@ -523,6 +535,13 @@ export const FieldAnnotation = Node.create({ return true; }, + /** + * Replace field annotations with their display labels in selection + * @param {Object} [options={}] - Replacement options + * @param {boolean} [options.addToHistory=false] - Whether to add to undo history + * @param {FieldType[]} [options.types] - Limit to specific field types + * @returns {Function} + */ replaceFieldAnnotationsWithLabelInSelection: (options = {}) => ({ commands }) => { @@ -532,6 +551,15 @@ export const FieldAnnotation = Node.create({ }); }, + /** + * Replace field annotations with their display labels + * @param {string | string[] | null} fieldIdOrArray - Field ID(s) to replace, or null for selection + * @param {Object} [options={}] - Replacement options + * @param {boolean} [options.isInSelection=false] - Process only fields in selection + * @param {boolean} [options.addToHistory=false] - Whether to add to undo history + * @param {FieldType[]} [options.types] - Limit to specific field types + * @returns {Function} + */ replaceFieldAnnotationsWithLabel: (fieldIdOrArray, { isInSelection = false, addToHistory = false, types = annotationTypes } = {}) => ({ dispatch, state, tr }) => { From b2e10cbe2e9f016b26e653321456da903e6ad750 Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Thu, 21 Aug 2025 08:01:00 -0300 Subject: [PATCH 07/20] chore: disable checkJs in tsconfig and enable JSDoc checking in field annotation file --- .../src/extensions/field-annotation/field-annotation.js | 1 + packages/super-editor/tsconfig.json | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/super-editor/src/extensions/field-annotation/field-annotation.js b/packages/super-editor/src/extensions/field-annotation/field-annotation.js index a3cc76ad0d..3c54922185 100644 --- a/packages/super-editor/src/extensions/field-annotation/field-annotation.js +++ b/packages/super-editor/src/extensions/field-annotation/field-annotation.js @@ -1,3 +1,4 @@ +// @ts-check /** * @typedef {import('./types').FieldAttributes} FieldAttributes * @typedef {import('./types').FieldValue} FieldValue diff --git a/packages/super-editor/tsconfig.json b/packages/super-editor/tsconfig.json index e463f8e029..5e6635fdb2 100644 --- a/packages/super-editor/tsconfig.json +++ b/packages/super-editor/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "checkJs": true, + "checkJs": false, "allowJs": true, "moduleResolution": "node", "target": "ES2020", @@ -10,6 +10,5 @@ "emitDeclarationOnly": true, "outDir": "dist" }, - "include": ["src/extensions/field-annotation/field-annotation.js", "src/core/types/index.d.ts"], "exclude": ["node_modules", "dist", "**/*.test.js"] } From 04fa6c122343a9bd37f6c0249370f91f6f5180fb Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Thu, 21 Aug 2025 08:04:07 -0300 Subject: [PATCH 08/20] chore: remove redundant JSDoc type definitions in SuperDoc.js and clean up ESLint configuration --- eslint.config.docs.mjs | 9 --------- packages/superdoc/src/core/SuperDoc.js | 12 +----------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/eslint.config.docs.mjs b/eslint.config.docs.mjs index 6455e3473a..e3e1837d7c 100644 --- a/eslint.config.docs.mjs +++ b/eslint.config.docs.mjs @@ -1,4 +1,3 @@ -// .eslintrc.jsdoc.js import jsdoc from 'eslint-plugin-jsdoc'; export default [ @@ -81,13 +80,5 @@ export default [ } } } - }, - - // Optional: Stricter rules for core types file - { - files: ['packages/super-editor/src/types/*.d.ts'], - rules: { - // TypeScript will handle these files - } } ]; \ No newline at end of file diff --git a/packages/superdoc/src/core/SuperDoc.js b/packages/superdoc/src/core/SuperDoc.js index db61f1aa4c..38cb36a7af 100644 --- a/packages/superdoc/src/core/SuperDoc.js +++ b/packages/superdoc/src/core/SuperDoc.js @@ -50,17 +50,7 @@ import { initSuperdocYdoc, initCollaborationComments, makeDocumentsCollaborative * @property {Object} [toolbar] Toolbar module configuration */ -/** - * @typedef {Object} Editor - * @property {Object} options - Editor options - * @property {Function} commands - Editor commands - * @property {Function} getHTML - Get HTML content - * @property {Function} exportDocx - Export to DOCX - * @property {Function} setDocumentMode - Set document mode - * @property {Function} focus - Focus the editor - * @property {Function} setHighContrastMode - Set high contrast mode - * @property {Object} toolbar - Toolbar instance - */ +/** @typedef {import('@harbour-enterprises/super-editor').Editor} Editor */ /** * @typedef {string} DocumentMode From d7524cea9a36e89153f2c0d8d18aa20c459a877e Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Thu, 21 Aug 2025 08:08:17 -0300 Subject: [PATCH 09/20] chore: remove TypeScript ignore comments from various files to improve code quality --- packages/super-editor/src/core/helpers/annotator.js | 1 - packages/super-editor/src/core/helpers/documentSectionHelpers.js | 1 - packages/super-editor/src/core/helpers/getActiveFormatting.js | 1 - .../src/extensions/field-annotation/FieldAnnotationView.js | 1 - .../cleanup-commands/cleanUpListsWithAnnotations.js | 1 - .../fieldAnnotationHelpers/findFieldAnnotationsByFieldId.js | 1 - .../findHeaderFooterAnnotationsByFieldId.js | 1 - .../fieldAnnotationHelpers/findRemovedFieldAnnotations.js | 1 - .../fieldAnnotationHelpers/getAllFieldAnnotations.js | 1 - .../fieldAnnotationHelpers/getAllFieldAnnotationsWithRect.js | 1 - .../fieldAnnotationHelpers/getHeaderFooterAnnotations.js | 1 - 11 files changed, 11 deletions(-) diff --git a/packages/super-editor/src/core/helpers/annotator.js b/packages/super-editor/src/core/helpers/annotator.js index db839bacc7..25a8bb49ca 100644 --- a/packages/super-editor/src/core/helpers/annotator.js +++ b/packages/super-editor/src/core/helpers/annotator.js @@ -1,4 +1,3 @@ -// @ts-nocheck import { Fragment } from 'prosemirror-model'; import { createHeaderFooterEditor, onHeaderFooterDataUpdate } from '@extensions/pagination/pagination-helpers.js'; diff --git a/packages/super-editor/src/core/helpers/documentSectionHelpers.js b/packages/super-editor/src/core/helpers/documentSectionHelpers.js index 3aeb94695e..467dce7135 100644 --- a/packages/super-editor/src/core/helpers/documentSectionHelpers.js +++ b/packages/super-editor/src/core/helpers/documentSectionHelpers.js @@ -1,4 +1,3 @@ -// @ts-nocheck import { DOMSerializer } from 'prosemirror-model'; /** diff --git a/packages/super-editor/src/core/helpers/getActiveFormatting.js b/packages/super-editor/src/core/helpers/getActiveFormatting.js index e2d63d1816..8e9beae004 100644 --- a/packages/super-editor/src/core/helpers/getActiveFormatting.js +++ b/packages/super-editor/src/core/helpers/getActiveFormatting.js @@ -31,7 +31,6 @@ export function getActiveFormatting(editor) { const linkMark = findMark(state, linkMarkType); if (linkMark) { - // @ts-ignore let { from, to, attrs } = linkMark; if (selection.from >= from && selection.to <= to) { diff --git a/packages/super-editor/src/extensions/field-annotation/FieldAnnotationView.js b/packages/super-editor/src/extensions/field-annotation/FieldAnnotationView.js index f7b541d259..bf9e5536f2 100644 --- a/packages/super-editor/src/extensions/field-annotation/FieldAnnotationView.js +++ b/packages/super-editor/src/extensions/field-annotation/FieldAnnotationView.js @@ -1,4 +1,3 @@ -// @ts-nocheck import { Attribute } from '@core/index.js'; import { NodeSelection } from 'prosemirror-state'; diff --git a/packages/super-editor/src/extensions/field-annotation/cleanup-commands/cleanUpListsWithAnnotations.js b/packages/super-editor/src/extensions/field-annotation/cleanup-commands/cleanUpListsWithAnnotations.js index 7311f8c43d..59c8c4e7ba 100644 --- a/packages/super-editor/src/extensions/field-annotation/cleanup-commands/cleanUpListsWithAnnotations.js +++ b/packages/super-editor/src/extensions/field-annotation/cleanup-commands/cleanUpListsWithAnnotations.js @@ -1,5 +1,4 @@ import { getAllFieldAnnotations } from '../fieldAnnotationHelpers/index.js'; -// @ts-ignore import { findParentNodeClosestToPos } from '@core/helpers/index.js'; /** diff --git a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findFieldAnnotationsByFieldId.js b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findFieldAnnotationsByFieldId.js index 8f82f1c246..153c4b0178 100644 --- a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findFieldAnnotationsByFieldId.js +++ b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findFieldAnnotationsByFieldId.js @@ -1,4 +1,3 @@ -// @ts-ignore import { helpers } from '@core/index.js'; const { findChildren } = helpers; diff --git a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findHeaderFooterAnnotationsByFieldId.js b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findHeaderFooterAnnotationsByFieldId.js index af09ead4fa..5b808f1ebc 100644 --- a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findHeaderFooterAnnotationsByFieldId.js +++ b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findHeaderFooterAnnotationsByFieldId.js @@ -1,4 +1,3 @@ -// @ts-ignore import { helpers } from '@core/index.js'; import { getAllHeaderFooterEditors } from '../../../core/helpers/annotator.js'; diff --git a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findRemovedFieldAnnotations.js b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findRemovedFieldAnnotations.js index a1ab20b66b..2cc51e3364 100644 --- a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findRemovedFieldAnnotations.js +++ b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/findRemovedFieldAnnotations.js @@ -38,7 +38,6 @@ export function findRemovedFieldAnnotations(tr) { function transactionDeletedAnything(tr) { return tr.steps.some((step) => { - // @ts-ignore if (step instanceof ReplaceStep || step instanceof ReplaceAroundStep) { return step.from !== step.to; } diff --git a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getAllFieldAnnotations.js b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getAllFieldAnnotations.js index 2652bfa049..ad19757d9a 100644 --- a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getAllFieldAnnotations.js +++ b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getAllFieldAnnotations.js @@ -1,4 +1,3 @@ -// @ts-ignore import { helpers } from '@core/index.js'; const { findChildren } = helpers; diff --git a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getAllFieldAnnotationsWithRect.js b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getAllFieldAnnotationsWithRect.js index 454d109bb8..690296acf5 100644 --- a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getAllFieldAnnotationsWithRect.js +++ b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getAllFieldAnnotationsWithRect.js @@ -1,4 +1,3 @@ -// @ts-ignore import { posToDOMRect } from '@core/helpers/index.js'; import { getAllFieldAnnotations } from './getAllFieldAnnotations.js'; diff --git a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getHeaderFooterAnnotations.js b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getHeaderFooterAnnotations.js index badf29ed7e..63f2c49adb 100644 --- a/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getHeaderFooterAnnotations.js +++ b/packages/super-editor/src/extensions/field-annotation/fieldAnnotationHelpers/getHeaderFooterAnnotations.js @@ -1,4 +1,3 @@ -// @ts-ignore import { getAllHeaderFooterEditors } from '@core/helpers/annotator.js'; import { getAllFieldAnnotations } from './index.js'; From 16fd22446436527c4a634bad574526afcbcfe384 Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Thu, 21 Aug 2025 08:09:05 -0300 Subject: [PATCH 10/20] chore: remove TypeScript ignore comments from FieldAnnotationPlugin.js to enhance code quality --- .../src/extensions/field-annotation/FieldAnnotationPlugin.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/super-editor/src/extensions/field-annotation/FieldAnnotationPlugin.js b/packages/super-editor/src/extensions/field-annotation/FieldAnnotationPlugin.js index 42eedbc095..bfb868efbb 100644 --- a/packages/super-editor/src/extensions/field-annotation/FieldAnnotationPlugin.js +++ b/packages/super-editor/src/extensions/field-annotation/FieldAnnotationPlugin.js @@ -78,11 +78,9 @@ export const FieldAnnotationPlugin = (options = {}) => { if (!event.target) return false; let { target } = event; - // @ts-ignore let isAnnotationField = target.classList?.contains(annotationClass); if (isAnnotationField) { - // @ts-ignore event.dataTransfer?.setDragImage(target, 0, 0); } From e38c76a88e2a40750865b8b6749cdb88e13d1dfc Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Thu, 21 Aug 2025 08:38:11 -0300 Subject: [PATCH 11/20] chore: refactor build scripts and remove unused TypeScript type definitions in super-editor --- package.json | 5 - packages/super-editor/package.json | 7 +- .../super-editor/src/core/types/index.d.ts | 24 --- .../field-annotation/field-annotation.js | 157 +++++++++++++----- .../extensions/field-annotation/types.d.ts | 18 -- 5 files changed, 120 insertions(+), 91 deletions(-) delete mode 100644 packages/super-editor/src/core/types/index.d.ts delete mode 100644 packages/super-editor/src/extensions/field-annotation/types.d.ts diff --git a/package.json b/package.json index 3fb2e0adda..e290a3e3e1 100644 --- a/package.json +++ b/package.json @@ -39,11 +39,6 @@ "eslint --fix", "prettier --write" ], - "packages/super-editor/src/extensions/field-annotation/field-annotation.js": [ - "eslint -c eslint.config.docs.mjs", - "eslint --fix", - "prettier --write" - ], "*.{css,scss,json,md}": [ "prettier --write" ], diff --git a/packages/super-editor/package.json b/packages/super-editor/package.json index 8f291e5e14..4c2faf23e2 100644 --- a/packages/super-editor/package.json +++ b/packages/super-editor/package.json @@ -39,14 +39,15 @@ "scripts": { "dev": "vite", "preview": "vite preview", - "build": "npm run types:check && npm run build:js && npm run types:build", + "prebuild": "npm run types:check", + "build": "npm run build:js && npm run types:generate", "build:js": "vite build", "build:watch": "vite build --watch --logLevel warn", "clean": "rm -rf dist", "test": "vitest", + "types:generate": "tsc --emitDeclarationOnly", + "types:watch": "tsc --emitDeclarationOnly --watch", "types:check": "tsc --noEmit", - "types:build": "tsc --emitDeclarationOnly", - "types:watch": "tsc --noEmit --watch", "pack": "rm *.tgz 2>/dev/null || true && npm run build && npm pack && mv harbour-enterprises-super-editor-0.0.1-alpha.0.tgz ./super-editor.tgz" }, "dependencies": { diff --git a/packages/super-editor/src/core/types/index.d.ts b/packages/super-editor/src/core/types/index.d.ts deleted file mode 100644 index acafe59a05..0000000000 --- a/packages/super-editor/src/core/types/index.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { - EditorState, - Transaction -} from 'prosemirror-state'; -import type { EditorView } from 'prosemirror-view'; - -// Re-export ProseMirror types -export type { - EditorState, - Transaction, - EditorView -}; - -// Simple command types - no generics needed -export interface CommandProps { - state: EditorState; - tr: Transaction; - view?: EditorView; - dispatch?: (tr: Transaction) => void; - editor: any; -} - -// Simple, non-generic Command type -export type Command = (...args: any[]) => (props: CommandProps) => boolean; \ No newline at end of file diff --git a/packages/super-editor/src/extensions/field-annotation/field-annotation.js b/packages/super-editor/src/extensions/field-annotation/field-annotation.js index 3c54922185..0f15d8be27 100644 --- a/packages/super-editor/src/extensions/field-annotation/field-annotation.js +++ b/packages/super-editor/src/extensions/field-annotation/field-annotation.js @@ -1,11 +1,3 @@ -// @ts-check -/** - * @typedef {import('./types').FieldAttributes} FieldAttributes - * @typedef {import('./types').FieldValue} FieldValue - * @typedef {import('./types').FieldType} FieldType - */ - -// @ts-ignore import { Node, Attribute } from '@core/index.js'; import { FieldAnnotationView } from './FieldAnnotationView.js'; import { FieldAnnotationPlugin } from './FieldAnnotationPlugin.js'; @@ -15,7 +7,6 @@ import { findFieldAnnotationsBetween, } from './fieldAnnotationHelpers/index.js'; import { toHex } from 'color2k'; -// @ts-ignore import { parseSizeUnit, minMax } from '@core/utilities/index.js'; import { NodeSelection, Selection } from 'prosemirror-state'; import { generateDocxRandomId } from '../../core/helpers/index.js'; @@ -25,10 +16,6 @@ export const fieldAnnotationName = 'fieldAnnotation'; export const annotationClass = 'annotation'; export const annotationContentClass = 'annotation-content'; -/** - * Field Annotation - Adds form fields to documents - * @module FieldAnnotation - */ export const FieldAnnotation = Node.create({ name: 'fieldAnnotation', @@ -442,11 +429,16 @@ export const FieldAnnotation = Node.create({ return { /** - * Add a field annotation at a specific position - * @param {number} pos - Document position where to insert the field - * @param {Partial} [attrs={}] - Field attributes - * @param {boolean} [editorFocus=false] - Whether to focus the editor after insertion - * @returns {Function} + * Add field annotation. + * @param pos The position in the doc. + * @param attrs The attributes. + * @example + * editor.commands.addFieldAnnotation(0, { + * displayLabel: 'Enter your info', + * fieldId: `123`, + * fieldType: 'TEXTINPUT', + * fieldColor: '#980043', + * }) */ addFieldAnnotation: (pos, attrs = {}, editorFocus = false) => @@ -486,12 +478,6 @@ export const FieldAnnotation = Node.create({ return true; }, - /** - * Add a field annotation at the current selection - * @param {Partial} [attrs={}] - Field attributes - * @param {boolean} [editorFocus=false] - Whether to focus the editor - * @returns {Function} - */ addFieldAnnotationAtSelection: (attrs = {}, editorFocus = false) => ({ state, commands }) => { @@ -500,9 +486,17 @@ export const FieldAnnotation = Node.create({ }, /** - * Replace text ranges with field annotations - * @param {Array<{from: number, to: number, attrs: Partial}>} fieldsArray - Array of replacements - * @returns {Function} + * Replace field annotation. + * @param fieldsArray array of fields with attrs to add as annotation. + * @example + * editor.commands.replaceWithFieldAnnotation([ + * from: 20, + * to: 45, + * attrs: { + * fieldType: 'TEXTINPUT' + * fieldColor: '#980043' + * } + * ]) */ replaceWithFieldAnnotation: (fieldsArray) => @@ -537,11 +531,10 @@ export const FieldAnnotation = Node.create({ }, /** - * Replace field annotations with their display labels in selection - * @param {Object} [options={}] - Replacement options - * @param {boolean} [options.addToHistory=false] - Whether to add to undo history - * @param {FieldType[]} [options.types] - Limit to specific field types - * @returns {Function} + * Replace annotations with a label (as text node) in selection. + * @param options Additional options. + * @example + * editor.commands.replaceFieldAnnotationsWithLabelInSelection() */ replaceFieldAnnotationsWithLabelInSelection: (options = {}) => @@ -553,13 +546,13 @@ export const FieldAnnotation = Node.create({ }, /** - * Replace field annotations with their display labels - * @param {string | string[] | null} fieldIdOrArray - Field ID(s) to replace, or null for selection - * @param {Object} [options={}] - Replacement options - * @param {boolean} [options.isInSelection=false] - Process only fields in selection - * @param {boolean} [options.addToHistory=false] - Whether to add to undo history - * @param {FieldType[]} [options.types] - Limit to specific field types - * @returns {Function} + * Replace annotations with a label (as text node). + * @param fieldIdOrArray The field ID or array of field IDs. + * @param options.isInSelection Find in selection instead of field IDs. + * @param options.addToHistory Add to history or not. + * @param options.types Annotation types to replace. + * @example + * editor.commands.replaceFieldAnnotationsWithLabel(['1', '2']) */ replaceFieldAnnotationsWithLabel: (fieldIdOrArray, { isInSelection = false, addToHistory = false, types = annotationTypes } = {}) => @@ -606,6 +599,11 @@ export const FieldAnnotation = Node.create({ return true; }, + /** + * Resets all annotations to default values. + * @example + * editor.commands.resetFieldAnnotations() + */ resetFieldAnnotations: () => ({ dispatch, state, tr }) => { @@ -646,6 +644,19 @@ export const FieldAnnotation = Node.create({ return true; }, + /** + * Update annotations associated with a field. + * @param fieldIdOrArray The field ID or array of field IDs. + * @param attrs The attributes. + * @example + * editor.commands.updateFieldAnnotations('123', { + * displayLabel: 'Updated!', + * }) + * @example + * editor.commands.updateFieldAnnotations(['123', '456'], { + * displayLabel: 'Updated!', + * }) + */ updateFieldAnnotations: (fieldIdOrArray, attrs = {}) => ({ dispatch, state, commands }) => { @@ -662,6 +673,13 @@ export const FieldAnnotation = Node.create({ return true; }, + /** + * Update particular annotation's attributes. + * @param annotation field annotation node to be updated. + * @param attrs The attributes. + * + * Used for a case when multiple annotations for one input presented + */ updateFieldAnnotation: (annotation, attrs = {}) => ({ dispatch, commands }) => { @@ -685,6 +703,11 @@ export const FieldAnnotation = Node.create({ return true; }, + /** + * Update the attributes of annotations. + * @param annotations The annotations array [{pos, node}]. + * @param attrs The attributes object. + */ updateFieldAnnotationsAttributes: (annotations, attrs = {}) => ({ dispatch, tr }) => { @@ -710,6 +733,14 @@ export const FieldAnnotation = Node.create({ return true; }, + /** + * Delete annotations associated with a field. + * @param fieldIdOrArray The field ID or array of field IDs. + * @example + * editor.commands.deleteFieldAnnotations('123') + * @example + * editor.commands.deleteFieldAnnotations(['123', '456']) + */ deleteFieldAnnotations: (fieldIdOrArray) => ({ dispatch, state, tr }) => { @@ -779,6 +810,15 @@ export const FieldAnnotation = Node.create({ return true; }, + /** + * Delete a portion of annotations associated with a field. + * @param fieldIdOrArray The field ID or array of field IDs. + * @param end index at which to end extraction + * @example + * editor.commands.sliceFieldAnnotations('123', 5) - will remove a portion of annotations array starting from index 6 + * @example + * editor.commands.sliceFieldAnnotations(['123', '456'], 5) + */ sliceFieldAnnotations: (fieldIdOrArray, end) => ({ dispatch, state, tr }) => { @@ -806,6 +846,17 @@ export const FieldAnnotation = Node.create({ return true; }, + /** + * Set `hidden` for annotations matching predicate. + * Other annotations become unhidden. + * @param predicate The predicate function. + * @param unsetFromOthers If should unset hidden from other annotations. + * @example + * editor.commands.setFieldAnnotationsHiddenByCondition((node) => { + * let ids = ['111', '222', '333']; + * return ids.includes(node.attrs.fieldId); + * }) + */ setFieldAnnotationsHiddenByCondition: (predicate = () => false, unsetFromOthers = false) => ({ dispatch, state, chain }) => { @@ -818,7 +869,6 @@ export const FieldAnnotation = Node.create({ if (dispatch) { let otherAnnotations = []; let matchedAnnotations = annotations.filter((annotation) => { - // @ts-ignore if (predicate(annotation.node)) return annotation; else otherAnnotations.push(annotation); }); @@ -836,6 +886,11 @@ export const FieldAnnotation = Node.create({ return true; }, + /** + * Unset `hidden` for all annotations. + * @example + * editor.commands.unsetFieldAnnotationsHidden() + */ unsetFieldAnnotationsHidden: () => ({ dispatch, state, commands }) => { @@ -852,6 +907,14 @@ export const FieldAnnotation = Node.create({ return true; }, + /** + * Set `visibility` for all annotations (without changing the layout). + * @param visibility The visibility value (visible, hidden). + * @example + * editor.commands.setFieldAnnotationsVisibility('visible'); + * @example + * editor.commands.setFieldAnnotationsVisibility('hidden'); + */ setFieldAnnotationsVisibility: (visibility = 'visible') => ({ dispatch, state, commands }) => { @@ -876,6 +939,19 @@ export const FieldAnnotation = Node.create({ return true; }, + /** + * Set `highlighted` for annotations matching predicate. + * @param predicate The predicate function. + * @param highlighted The highlighted attribute. + * @example + * editor.commands.setFieldAnnotationsHighlighted((node) => { + * let ids = ['111', '222', '333']; + * return ids.includes(node.attrs.fieldId); + * }, false) + * @example Set for all annotations. + * editor.commands.setFieldAnnotationsHighlighted(() => true, false) + * editor.commands.setFieldAnnotationsHighlighted(() => true, true) + */ setFieldAnnotationsHighlighted: (predicate = () => false, highlighted = true) => ({ dispatch, state, commands }) => { @@ -887,7 +963,6 @@ export const FieldAnnotation = Node.create({ if (dispatch) { let matchedAnnotations = annotations.filter((annotation) => { - // @ts-ignore if (predicate(annotation.node)) return annotation; }); diff --git a/packages/super-editor/src/extensions/field-annotation/types.d.ts b/packages/super-editor/src/extensions/field-annotation/types.d.ts deleted file mode 100644 index b128dcf2c2..0000000000 --- a/packages/super-editor/src/extensions/field-annotation/types.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -export type FieldType = 'text' | 'checkbox' | 'image' | 'html' | 'link' | 'signature'; - -// NOTE: verify what attrs are required and what are optional -// To avoid using Partial -export interface FieldAttributes { - fieldId: string; - displayLabel: string; - defaultDisplayLabel?: string; - hash?: string; - type?: FieldType; - fieldColor?: string; - hidden?: boolean; -} - -export interface FieldValue { - input_id: string; - input_value: string | boolean; -} \ No newline at end of file From 8a8957839f0b6f4999f84d2e2184883d44e2950d Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Thu, 21 Aug 2025 09:08:17 -0300 Subject: [PATCH 12/20] chore: update build configuration and improve TypeScript output structure in super-editor --- .gitignore | 1 + packages/super-editor/package.json | 15 ++++++--------- packages/super-editor/tsconfig.build.json | 7 +++++++ packages/super-editor/tsconfig.json | 4 ++-- 4 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 packages/super-editor/tsconfig.build.json diff --git a/.gitignore b/.gitignore index fb58e3cbb3..0e7977df61 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ dist-ssr .env .npmrc .eslintcache +types/ npm-debug.log* yarn-debug.log* diff --git a/packages/super-editor/package.json b/packages/super-editor/package.json index 4c2faf23e2..97c1933efd 100644 --- a/packages/super-editor/package.json +++ b/packages/super-editor/package.json @@ -38,16 +38,13 @@ "module": "./dist/super-editor.es.js", "scripts": { "dev": "vite", - "preview": "vite preview", - "prebuild": "npm run types:check", - "build": "npm run build:js && npm run types:generate", - "build:js": "vite build", - "build:watch": "vite build --watch --logLevel warn", - "clean": "rm -rf dist", - "test": "vitest", - "types:generate": "tsc --emitDeclarationOnly", - "types:watch": "tsc --emitDeclarationOnly --watch", + "build": "vite build && npm run types:build", + "build:watch": "vite build --watch", "types:check": "tsc --noEmit", + "types:build": "tsc -p tsconfig.build.json", + "test": "vitest", + "preview": "vite preview", + "clean": "rm -rf dist types", "pack": "rm *.tgz 2>/dev/null || true && npm run build && npm pack && mv harbour-enterprises-super-editor-0.0.1-alpha.0.tgz ./super-editor.tgz" }, "dependencies": { diff --git a/packages/super-editor/tsconfig.build.json b/packages/super-editor/tsconfig.build.json new file mode 100644 index 0000000000..b5b30b49bc --- /dev/null +++ b/packages/super-editor/tsconfig.build.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "checkJs": false, + "outDir": "dist" + } +} diff --git a/packages/super-editor/tsconfig.json b/packages/super-editor/tsconfig.json index 5e6635fdb2..b42aea37a2 100644 --- a/packages/super-editor/tsconfig.json +++ b/packages/super-editor/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "checkJs": false, + "checkJs": true, "allowJs": true, "moduleResolution": "node", "target": "ES2020", @@ -8,7 +8,7 @@ "skipLibCheck": true, "declaration": true, "emitDeclarationOnly": true, - "outDir": "dist" + "outDir": "types" }, "exclude": ["node_modules", "dist", "**/*.test.js"] } From 053e14627be60e42f197a3bab905276357cb75ba Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Thu, 21 Aug 2025 10:18:36 -0300 Subject: [PATCH 13/20] docs: enhance JSDoc comments and type definitions for DocumentSection in super-editor --- .../structured-content/document-section.js | 81 ++++++++++++------- 1 file changed, 51 insertions(+), 30 deletions(-) diff --git a/packages/super-editor/src/extensions/structured-content/document-section.js b/packages/super-editor/src/extensions/structured-content/document-section.js index 7122dc6551..ff15aa6374 100644 --- a/packages/super-editor/src/extensions/structured-content/document-section.js +++ b/packages/super-editor/src/extensions/structured-content/document-section.js @@ -1,10 +1,45 @@ +/** + * @typedef {Object} SectionAttributes + * @property {number} [id] - Section identifier + * @property {string} [title] - Section title + * @property {string} [description] - Section description + * @property {string} [sectionType] - Type of section + * @property {boolean} [isLocked] - Whether section is locked + */ + +/** + * @typedef {Object} SectionOptions + * @property {number} [id] - Section identifier (auto-generated if not provided) + * @property {string} [title] - Section title + * @property {string} [description] - Section description + * @property {string} [sectionType] - Type of section + * @property {string} [html] - HTML content to parse + * @property {Object} [json] - ProseMirror JSON content (takes precedence over html) + */ + +/** + * @typedef {Object} UpdateOptions + * @property {number} id - Section ID to update + * @property {string} [html] - HTML content + * @property {Object} [json] - ProseMirror JSON content (takes precedence over html) + * @property {Partial} [attrs] - Attributes to update + */ + +// @ts-ignore import { Node, Attribute } from '@core/index.js'; import { DocumentSectionView } from './document-section/DocumentSectionView.js'; +// @ts-ignore import { htmlHandler } from '@core/InputRule.js'; +// @ts-ignore import { Selection } from 'prosemirror-state'; import { DOMParser as PMDOMParser } from 'prosemirror-model'; +// @ts-ignore import { findParentNode, SectionHelpers } from '@helpers/index.js'; +/** + * Document Section - Structured content blocks + * @module DocumentSection + */ export const DocumentSection = Node.create({ name: 'documentSection', group: 'block', @@ -53,12 +88,9 @@ export const DocumentSection = Node.create({ addCommands() { return { /** - * Create a new structured content block - * You can pass in options like title, description, html, or json. - * If html is provided, it will be parsed and converted to ProseMirror nodes. - * If json is provided, it will be used to create the content of the block. - * @param {Object} params - The command parameters - * @returns {boolean} Returns true if the command was executed successfully + * Create a new document section + * @param {SectionOptions} [options={}] + * @returns {Function} Command function - returns true if section was created successfully */ createDocumentSection: (options = {}) => @@ -171,11 +203,8 @@ export const DocumentSection = Node.create({ }, /** - * Remove the structured content block at the current selection, retaining contents. - * This will remove the block node but keep its content in the document. - * If the selection is not within a structured content block, it does nothing. - * @param {Object} params - The command parameters - * @returns {boolean} Returns true if the command was executed successfully + * Remove section at current selection, keeping content + * @returns {Function} Command function - returns true if section was removed, false if none found */ removeSectionAtSelection: () => @@ -213,9 +242,9 @@ export const DocumentSection = Node.create({ }, /** - * Remove a document section by its ID. - * @param {string} id - The ID of the section to remove - * @returns {Function} A command function that takes the editor state and dispatch function + * Remove section by ID + * @param {number} id + * @returns {Function} Command function - returns true if section was removed, false if not found */ removeSectionById: (id) => @@ -240,10 +269,10 @@ export const DocumentSection = Node.create({ }, /** - * Lock a document section by its ID. - * This command is a placeholder and does not perform any action yet. - * @param {string} id - The ID of the section to lock - * @returns {Function} A command function that takes the editor state and dispatch function + * Lock section by ID + * @param {string | number} id + * @returns {Function} Command function - returns true if section was locked, false if not found + * @private */ lockSectionById: (id) => @@ -263,20 +292,12 @@ export const DocumentSection = Node.create({ }, /** - * Update a document section by its ID. - * You can pass in options like id, html, json, or attrs. - * The attrs include json, title, description, etc. - * If html is provided, it will be parsed and converted to ProseMirror nodes - * If json is provided, it will be used to create the content of the block. - * @param {Object} params - The command parameters - * @param {string} params.id - The ID of the section to update - * @param {string} [params.html] - The HTML content to set for the section - * @param {Object} [params.json] - The JSON content to set for the section - * @param {Object} [params.attrs] - Additional attributes to update (e.g., title, description) - * @returns {Function} A command function that takes the editor state and dispatch function + * Update section by ID + * @param {UpdateOptions} options + * @returns {Function} Command function - returns true if section was updated, false if not found */ updateSectionById: - ({ id, html, json, attrs } = {}) => + ({ id, html, json, attrs }) => ({ tr, dispatch, editor }) => { const sections = SectionHelpers.getAllSections(editor || this.editor); const sectionToUpdate = sections.find(({ node }) => node.attrs.id === id); From 088f98cb961254e87cc8a32aa5b15fec6682c340 Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Thu, 21 Aug 2025 11:35:22 -0300 Subject: [PATCH 14/20] docs: add @category Command tag to JSDoc comments in DocumentSection for better organization --- .../src/extensions/structured-content/document-section.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/super-editor/src/extensions/structured-content/document-section.js b/packages/super-editor/src/extensions/structured-content/document-section.js index ff15aa6374..c93dd4232c 100644 --- a/packages/super-editor/src/extensions/structured-content/document-section.js +++ b/packages/super-editor/src/extensions/structured-content/document-section.js @@ -89,6 +89,7 @@ export const DocumentSection = Node.create({ return { /** * Create a new document section + * @category Command * @param {SectionOptions} [options={}] * @returns {Function} Command function - returns true if section was created successfully */ @@ -204,6 +205,7 @@ export const DocumentSection = Node.create({ /** * Remove section at current selection, keeping content + * @category Command * @returns {Function} Command function - returns true if section was removed, false if none found */ removeSectionAtSelection: @@ -243,6 +245,7 @@ export const DocumentSection = Node.create({ /** * Remove section by ID + * @category Command * @param {number} id * @returns {Function} Command function - returns true if section was removed, false if not found */ @@ -270,6 +273,7 @@ export const DocumentSection = Node.create({ /** * Lock section by ID + * @category Command * @param {string | number} id * @returns {Function} Command function - returns true if section was locked, false if not found * @private @@ -293,6 +297,7 @@ export const DocumentSection = Node.create({ /** * Update section by ID + * @category Command * @param {UpdateOptions} options * @returns {Function} Command function - returns true if section was updated, false if not found */ From f0b0f238a676cea96328028fbdb698efde1d387e Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Thu, 21 Aug 2025 19:10:58 -0300 Subject: [PATCH 15/20] docs: refine JSDoc comments and type definitions for section creation and update in DocumentSection --- .../structured-content/document-section.js | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/super-editor/src/extensions/structured-content/document-section.js b/packages/super-editor/src/extensions/structured-content/document-section.js index c93dd4232c..f2063f2130 100644 --- a/packages/super-editor/src/extensions/structured-content/document-section.js +++ b/packages/super-editor/src/extensions/structured-content/document-section.js @@ -1,4 +1,7 @@ +// @ts-check + /** + * Base section attributes * @typedef {Object} SectionAttributes * @property {number} [id] - Section identifier * @property {string} [title] - Section title @@ -8,19 +11,22 @@ */ /** - * @typedef {Object} SectionOptions + * Options for creating a section + * @typedef {Object} SectionCreate * @property {number} [id] - Section identifier (auto-generated if not provided) - * @property {string} [title] - Section title + * @property {string} [title] - Section title (defaults to "Document section") * @property {string} [description] - Section description * @property {string} [sectionType] - Type of section + * @property {boolean} [isLocked] - Whether section is locked * @property {string} [html] - HTML content to parse * @property {Object} [json] - ProseMirror JSON content (takes precedence over html) */ /** - * @typedef {Object} UpdateOptions - * @property {number} id - Section ID to update - * @property {string} [html] - HTML content + * Options for updating a section + * @typedef {Object} SectionUpdate + * @property {number} id - Section ID to update (required) + * @property {string} [html] - HTML content to parse * @property {Object} [json] - ProseMirror JSON content (takes precedence over html) * @property {Partial} [attrs] - Attributes to update */ @@ -90,7 +96,7 @@ export const DocumentSection = Node.create({ /** * Create a new document section * @category Command - * @param {SectionOptions} [options={}] + * @param {SectionCreate} [options={}] * @returns {Function} Command function - returns true if section was created successfully */ createDocumentSection: @@ -246,7 +252,7 @@ export const DocumentSection = Node.create({ /** * Remove section by ID * @category Command - * @param {number} id + * @param {number} id - Section ID to remove * @returns {Function} Command function - returns true if section was removed, false if not found */ removeSectionById: @@ -274,7 +280,7 @@ export const DocumentSection = Node.create({ /** * Lock section by ID * @category Command - * @param {string | number} id + * @param {number} id - Section ID to lock * @returns {Function} Command function - returns true if section was locked, false if not found * @private */ @@ -298,7 +304,7 @@ export const DocumentSection = Node.create({ /** * Update section by ID * @category Command - * @param {UpdateOptions} options + * @param {SectionUpdate} options * @returns {Function} Command function - returns true if section was updated, false if not found */ updateSectionById: From 11fb9d7c4ba81b337b491a32e60e23a51614ce10 Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Thu, 21 Aug 2025 19:16:47 -0300 Subject: [PATCH 16/20] chore: remove outDir option from tsconfig.build.json in super-editor --- packages/super-editor/tsconfig.build.json | 5 ++--- packages/super-editor/tsconfig.json | 15 +++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/super-editor/tsconfig.build.json b/packages/super-editor/tsconfig.build.json index b5b30b49bc..765ac6e6c0 100644 --- a/packages/super-editor/tsconfig.build.json +++ b/packages/super-editor/tsconfig.build.json @@ -1,7 +1,6 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "checkJs": false, - "outDir": "dist" + "checkJs": false } -} +} \ No newline at end of file diff --git a/packages/super-editor/tsconfig.json b/packages/super-editor/tsconfig.json index b42aea37a2..6732fff6bc 100644 --- a/packages/super-editor/tsconfig.json +++ b/packages/super-editor/tsconfig.json @@ -4,11 +4,18 @@ "allowJs": true, "moduleResolution": "node", "target": "ES2020", - "lib": ["ES2020", "DOM"], + "lib": [ + "ES2020", + "DOM" + ], "skipLibCheck": true, "declaration": true, "emitDeclarationOnly": true, - "outDir": "types" + "outDir": "dist" }, - "exclude": ["node_modules", "dist", "**/*.test.js"] -} + "exclude": [ + "node_modules", + "dist", + "**/*.test.js" + ] +} \ No newline at end of file From 4cc1e6c9e2a13fc99a9aec0ded889b6f38fd28c3 Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Thu, 21 Aug 2025 19:31:54 -0300 Subject: [PATCH 17/20] chore: refactor initPagination method to private and update tsconfig formatting in super-editor --- packages/super-editor/src/core/Editor.js | 5 ++--- packages/super-editor/tsconfig.build.json | 2 +- packages/super-editor/tsconfig.json | 13 +++---------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/packages/super-editor/src/core/Editor.js b/packages/super-editor/src/core/Editor.js index 38725d3647..52478f57cd 100644 --- a/packages/super-editor/src/core/Editor.js +++ b/packages/super-editor/src/core/Editor.js @@ -1285,11 +1285,10 @@ export class Editor extends EventEmitter { /** * Initialize pagination, if the pagination extension is enabled. - * @private * @async * @returns {Promise} */ - async initPagination() { + async #initPagination() { if (this.options.isHeadless || !this.extensionService || this.options.isHeaderOrFooter) { return; } @@ -1771,7 +1770,7 @@ export class Editor extends EventEmitter { } if (!this.options.ydoc) { - this.initPagination(); + this.#initPagination(); this.#initComments(); } } diff --git a/packages/super-editor/tsconfig.build.json b/packages/super-editor/tsconfig.build.json index 765ac6e6c0..b0f8b21b73 100644 --- a/packages/super-editor/tsconfig.build.json +++ b/packages/super-editor/tsconfig.build.json @@ -3,4 +3,4 @@ "compilerOptions": { "checkJs": false } -} \ No newline at end of file +} diff --git a/packages/super-editor/tsconfig.json b/packages/super-editor/tsconfig.json index 6732fff6bc..60e2cb8b4f 100644 --- a/packages/super-editor/tsconfig.json +++ b/packages/super-editor/tsconfig.json @@ -4,18 +4,11 @@ "allowJs": true, "moduleResolution": "node", "target": "ES2020", - "lib": [ - "ES2020", - "DOM" - ], + "lib": ["ES2020", "DOM"], "skipLibCheck": true, "declaration": true, "emitDeclarationOnly": true, "outDir": "dist" }, - "exclude": [ - "node_modules", - "dist", - "**/*.test.js" - ] -} \ No newline at end of file + "exclude": ["node_modules", "dist", "**/*.test.js"] +} From bdfb9d4529e11ba6d1e443565b9ae5e544249d68 Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Thu, 21 Aug 2025 19:35:51 -0300 Subject: [PATCH 18/20] refactor: replace initPagination calls with private method #initPagination in Editor class --- packages/super-editor/src/core/Editor.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/super-editor/src/core/Editor.js b/packages/super-editor/src/core/Editor.js index 52478f57cd..4a155e9245 100644 --- a/packages/super-editor/src/core/Editor.js +++ b/packages/super-editor/src/core/Editor.js @@ -365,7 +365,7 @@ export class Editor extends EventEmitter { // it will be in itialized via this.#onCollaborationReady if (!this.options.ydoc) { if (!this.options.isChildEditor) { - this.initPagination(); + this.#initPagination(); this.#initComments(); this.#validateDocumentInit(); @@ -679,7 +679,7 @@ export class Editor extends EventEmitter { this.view.dispatch(tr); setTimeout(() => { - this.initPagination(); + this.#initPagination(); this.#initComments(); }, 50); } @@ -1257,7 +1257,7 @@ export class Editor extends EventEmitter { this.view.dispatch(tr); if (!this.options.isNewFile) { - this.initPagination(); + this.#initPagination(); this.#initComments(); updateYdocDocxData(this); } @@ -1321,10 +1321,10 @@ export class Editor extends EventEmitter { const tr = isTrackChangesActive ? trackedTransaction({ - tr: transaction, - state: this.state, - user: this.options.user, - }) + tr: transaction, + state: this.state, + user: this.options.user, + }) : transaction; const { state: newState } = this.view.state.applyTransaction(tr); @@ -1663,7 +1663,7 @@ export class Editor extends EventEmitter { console.debug('🔗 [super-editor] Ending collaboration'); if (this.options.collaborationProvider) this.options.collaborationProvider.disconnect(); if (this.options.ydoc) this.options.ydoc.destroy(); - } catch {} + } catch { } } /** @@ -1688,7 +1688,7 @@ export class Editor extends EventEmitter { } this.converter.headerEditors.length = 0; this.converter.footerEditors.length = 0; - } catch {} + } catch { } } /** From af49374ea715c29e8c1bce211bb74c2dafbf8957 Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Thu, 21 Aug 2025 19:36:45 -0300 Subject: [PATCH 19/20] fix: correct syntax in catch blocks for better error handling in Editor class --- packages/super-editor/src/core/Editor.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/super-editor/src/core/Editor.js b/packages/super-editor/src/core/Editor.js index 4a155e9245..ea4870b994 100644 --- a/packages/super-editor/src/core/Editor.js +++ b/packages/super-editor/src/core/Editor.js @@ -1321,10 +1321,10 @@ export class Editor extends EventEmitter { const tr = isTrackChangesActive ? trackedTransaction({ - tr: transaction, - state: this.state, - user: this.options.user, - }) + tr: transaction, + state: this.state, + user: this.options.user, + }) : transaction; const { state: newState } = this.view.state.applyTransaction(tr); @@ -1663,7 +1663,7 @@ export class Editor extends EventEmitter { console.debug('🔗 [super-editor] Ending collaboration'); if (this.options.collaborationProvider) this.options.collaborationProvider.disconnect(); if (this.options.ydoc) this.options.ydoc.destroy(); - } catch { } + } catch {} } /** @@ -1688,7 +1688,7 @@ export class Editor extends EventEmitter { } this.converter.headerEditors.length = 0; this.converter.footerEditors.length = 0; - } catch { } + } catch {} } /** From 0e28a97f8bd559e89f6a7721d07ba07aaaa12c53 Mon Sep 17 00:00:00 2001 From: Nick Bernal <117235294+harbournick@users.noreply.github.com> Date: Thu, 21 Aug 2025 18:06:54 -0700 Subject: [PATCH 20/20] Doc gen: Add aliases to tsconfig, remove ts-ignore in document sections (#798) * chore: add vite aliases to tsconfig * fix: remove ts-ignore and fix issues to ensure file builds --- packages/super-editor/src/core/InputRule.js | 2 +- .../structured-content/document-section.js | 4 ---- packages/super-editor/tsconfig.json | 14 +++++++++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/super-editor/src/core/InputRule.js b/packages/super-editor/src/core/InputRule.js index 124832b7d6..93f1cf6cf8 100644 --- a/packages/super-editor/src/core/InputRule.js +++ b/packages/super-editor/src/core/InputRule.js @@ -293,7 +293,7 @@ export function handleHtmlPaste(html, editor) { * converting em units to pt and removing unnecessary tags. * @param {String} html The HTML string to be processed. * @param {Editor} editor The editor instance. - * @returns {String} The processed HTML string. + * @returns {DocumentFragment} The processed HTML string. */ export function htmlHandler(html, editor) { const flatHtml = flattenListsInHtml(html, editor); diff --git a/packages/super-editor/src/extensions/structured-content/document-section.js b/packages/super-editor/src/extensions/structured-content/document-section.js index f2063f2130..adc602d80c 100644 --- a/packages/super-editor/src/extensions/structured-content/document-section.js +++ b/packages/super-editor/src/extensions/structured-content/document-section.js @@ -31,15 +31,11 @@ * @property {Partial} [attrs] - Attributes to update */ -// @ts-ignore import { Node, Attribute } from '@core/index.js'; import { DocumentSectionView } from './document-section/DocumentSectionView.js'; -// @ts-ignore import { htmlHandler } from '@core/InputRule.js'; -// @ts-ignore import { Selection } from 'prosemirror-state'; import { DOMParser as PMDOMParser } from 'prosemirror-model'; -// @ts-ignore import { findParentNode, SectionHelpers } from '@helpers/index.js'; /** diff --git a/packages/super-editor/tsconfig.json b/packages/super-editor/tsconfig.json index 60e2cb8b4f..1bf61cc21f 100644 --- a/packages/super-editor/tsconfig.json +++ b/packages/super-editor/tsconfig.json @@ -8,7 +8,19 @@ "skipLibCheck": true, "declaration": true, "emitDeclarationOnly": true, - "outDir": "dist" + "outDir": "dist", + "baseUrl": ".", + "paths": { + "@": ["./src/*"], + "@core/*": ["./src/core/*"], + "@extensions/*": ["./src/extensions/*"], + "@features/*": ["./src/features/*"], + "@components/*": ["./src/components/*"], + "@helpers/*": ["./src/core/helpers/*"], + "@packages/*": ["../*"], + "@converter/*": ["./src/core/super-converter/*"], + "@tests/*": ["./src/tests/*"] + } }, "exclude": ["node_modules", "dist", "**/*.test.js"] }