Cannot get renderHTML properly declared with typescript for tiptap custom extension (type Node.Create)

I am switching from CKEditor to TipTap editor in my Angular project. In order to first get to know TipTap I created a new project using Angular 19.
(please see at the bottom for Edit 1: seems like the linter is the problem and not the compiler…)

I am trying to create a new custom extension for images. Goal is to be able to upload them to my REST API and possibly be able to resize the image.

Using JetBrains Webstorm.

The existing plugin everyone is suggesting for resizing images does not seem to be working in Angular as it is optimized for React…

I’m having problems to correctly implement the renderHTML function. I keep getting errors like:

Argument type {renderHTML({node, HTMLAttributes}: {node: any, HTMLAttributes: any}): [string, Record<string, any>], addOptions(): ImageUploadOptions} is not assignable to parameter type Partial<NodeConfig<ImageUploadOptions, any>> | undefined

The simplest version of the plugin is below.

    
type ImageUploadOptions = {
  HTMLAttributes: { [key: string]: string },
  uploadFn: (file: File) => Promise<Awaited<string>>
};

interface MyUploadStorage{

}

export let ImageUploadExtension: Node<ImageUploadOptions>;
ImageUploadExtension = Node.create<ImageUploadOptions>({
  name: 'imageUpload',
  group: 'block',
  inline: false,
  draggable: true,


  addAttributes() {
    return {
      src: {
        default: null,
      },
      alt: {
        default: null,
      },
      title: {
        default: null,
      },
    };
  },

  parseHTML() {
    return [
      {
        tag: 'img[src]',
      },
    ];
  },

  addOptions(): ImageUploadOptions {
    return {
      HTMLAttributes: {},
      uploadFn: (file: File) => Promise.resolve(''), // Override this function with your upload logic
    };
  },

  renderHTML({node, HTMLAttributes}) {
    return ['img', HTMLAttributes];
  }



});

I’ve also extended the renderHTML function a bit following a lot of examples:

    renderHTML({ HTMLAttributes }) {
      return ['img', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
    },

But then the error this.options is not a know variable. Apparently Typescript doesn’t understand this.options is a valid variable. All I read is that I should use the generic Node.create<ImageUploadOptions> and all should be well.

Same goes for the function addNodeView: I cannot get this declared properly. This should return a function

  addNodeView() {
    return ({ node, getPos, editor }) => {
      const img = document.createElement('img');
      img.setAttribute('src', node.attrs['src']);
      img.setAttribute('alt', node.attrs[ 'alt'] || '');
      img.setAttribute('title', node.attrs['title'] || '');

      return {};
    };
  },

This thing is driving me nuts. Especially since I read that TipTap is written in Typescript.

I have even tried to just copy the blockquote.ts extension (with a new name) to my project, and get the same errors. So maybe there is something wrong with my project settings?

I am using "ngx-tiptap": "^12.0.0", for integration TipTap with Angular.

Below I include the package.json.

{
  "name": "angular-tiptap-editor",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^19.0.0",
    "@angular/cdk": "^19.0.4",
    "@angular/common": "^19.0.0",
    "@angular/compiler": "^19.0.0",
    "@angular/core": "^19.0.0",
    "@angular/forms": "^19.0.0",
    "@angular/material": "^19.0.4",
    "@angular/platform-browser": "^19.0.0",
    "@angular/platform-browser-dynamic": "^19.0.0",
    "@angular/router": "^19.0.0",
    "@tiptap/core": "^2.10.3",
    "@tiptap/extension-blockquote": "^2.10.3",
    "@tiptap/extension-bullet-list": "^2.10.3",
    "@tiptap/extension-code-block": "^2.10.4",
    "@tiptap/extension-code-block-lowlight": "^2.10.4",
    "@tiptap/extension-color": "^2.10.4",
    "@tiptap/extension-font-family": "^2.10.4",
    "@tiptap/extension-highlight": "^2.10.4",
    "@tiptap/extension-image": "^2.10.3",
    "@tiptap/extension-list-item": "^2.10.3",
    "@tiptap/extension-mention": "^2.10.4",
    "@tiptap/extension-subscript": "^2.10.4",
    "@tiptap/extension-superscript": "^2.10.4",
    "@tiptap/extension-table": "^2.10.4",
    "@tiptap/extension-table-cell": "^2.10.4",
    "@tiptap/extension-table-header": "^2.10.4",
    "@tiptap/extension-table-row": "^2.10.4",
    "@tiptap/extension-text-align": "^2.10.3",
    "@tiptap/extension-text-style": "^2.10.4",
    "@tiptap/starter-kit": "^2.10.3",
    "@tiptap/suggestion": "^2.10.4",
    "highlight.js": "^11.11.0",
    "ngx-tiptap": "^12.0.0",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.15.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^19.0.5",
    "@angular/cli": "^19.0.5",
    "@angular/compiler-cli": "^19.0.0",
    "@types/jasmine": "~5.1.0",
    "jasmine-core": "~5.4.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.1.0",
    "typescript": "~5.6.2"
  }
}


EDIT 1
Ok, so it seems that my IDE is fooling me: the linter(?) is giving stricter errors than the actual Angular 19 compiler……

Any help on fixing that?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Cannot get renderHTML properly declared with typescript for tiptap custom extension (type Node.Create)

I am switching from CKEditor to TipTap editor in my Angular project. In order to first get to know TipTap I created a new project using Angular 19.
(please see at the bottom for Edit 1: seems like the linter is the problem and not the compiler…)

I am trying to create a new custom extension for images. Goal is to be able to upload them to my REST API and possibly be able to resize the image.

Using JetBrains Webstorm.

The existing plugin everyone is suggesting for resizing images does not seem to be working in Angular as it is optimized for React…

I’m having problems to correctly implement the renderHTML function. I keep getting errors like:

Argument type {renderHTML({node, HTMLAttributes}: {node: any, HTMLAttributes: any}): [string, Record<string, any>], addOptions(): ImageUploadOptions} is not assignable to parameter type Partial<NodeConfig<ImageUploadOptions, any>> | undefined

The simplest version of the plugin is below.

    
type ImageUploadOptions = {
  HTMLAttributes: { [key: string]: string },
  uploadFn: (file: File) => Promise<Awaited<string>>
};

interface MyUploadStorage{

}

export let ImageUploadExtension: Node<ImageUploadOptions>;
ImageUploadExtension = Node.create<ImageUploadOptions>({
  name: 'imageUpload',
  group: 'block',
  inline: false,
  draggable: true,


  addAttributes() {
    return {
      src: {
        default: null,
      },
      alt: {
        default: null,
      },
      title: {
        default: null,
      },
    };
  },

  parseHTML() {
    return [
      {
        tag: 'img[src]',
      },
    ];
  },

  addOptions(): ImageUploadOptions {
    return {
      HTMLAttributes: {},
      uploadFn: (file: File) => Promise.resolve(''), // Override this function with your upload logic
    };
  },

  renderHTML({node, HTMLAttributes}) {
    return ['img', HTMLAttributes];
  }



});

I’ve also extended the renderHTML function a bit following a lot of examples:

    renderHTML({ HTMLAttributes }) {
      return ['img', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
    },

But then the error this.options is not a know variable. Apparently Typescript doesn’t understand this.options is a valid variable. All I read is that I should use the generic Node.create<ImageUploadOptions> and all should be well.

Same goes for the function addNodeView: I cannot get this declared properly. This should return a function

  addNodeView() {
    return ({ node, getPos, editor }) => {
      const img = document.createElement('img');
      img.setAttribute('src', node.attrs['src']);
      img.setAttribute('alt', node.attrs[ 'alt'] || '');
      img.setAttribute('title', node.attrs['title'] || '');

      return {};
    };
  },

This thing is driving me nuts. Especially since I read that TipTap is written in Typescript.

I have even tried to just copy the blockquote.ts extension (with a new name) to my project, and get the same errors. So maybe there is something wrong with my project settings?

I am using "ngx-tiptap": "^12.0.0", for integration TipTap with Angular.

Below I include the package.json.

{
  "name": "angular-tiptap-editor",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^19.0.0",
    "@angular/cdk": "^19.0.4",
    "@angular/common": "^19.0.0",
    "@angular/compiler": "^19.0.0",
    "@angular/core": "^19.0.0",
    "@angular/forms": "^19.0.0",
    "@angular/material": "^19.0.4",
    "@angular/platform-browser": "^19.0.0",
    "@angular/platform-browser-dynamic": "^19.0.0",
    "@angular/router": "^19.0.0",
    "@tiptap/core": "^2.10.3",
    "@tiptap/extension-blockquote": "^2.10.3",
    "@tiptap/extension-bullet-list": "^2.10.3",
    "@tiptap/extension-code-block": "^2.10.4",
    "@tiptap/extension-code-block-lowlight": "^2.10.4",
    "@tiptap/extension-color": "^2.10.4",
    "@tiptap/extension-font-family": "^2.10.4",
    "@tiptap/extension-highlight": "^2.10.4",
    "@tiptap/extension-image": "^2.10.3",
    "@tiptap/extension-list-item": "^2.10.3",
    "@tiptap/extension-mention": "^2.10.4",
    "@tiptap/extension-subscript": "^2.10.4",
    "@tiptap/extension-superscript": "^2.10.4",
    "@tiptap/extension-table": "^2.10.4",
    "@tiptap/extension-table-cell": "^2.10.4",
    "@tiptap/extension-table-header": "^2.10.4",
    "@tiptap/extension-table-row": "^2.10.4",
    "@tiptap/extension-text-align": "^2.10.3",
    "@tiptap/extension-text-style": "^2.10.4",
    "@tiptap/starter-kit": "^2.10.3",
    "@tiptap/suggestion": "^2.10.4",
    "highlight.js": "^11.11.0",
    "ngx-tiptap": "^12.0.0",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.15.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^19.0.5",
    "@angular/cli": "^19.0.5",
    "@angular/compiler-cli": "^19.0.0",
    "@types/jasmine": "~5.1.0",
    "jasmine-core": "~5.4.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.1.0",
    "typescript": "~5.6.2"
  }
}


EDIT 1
Ok, so it seems that my IDE is fooling me: the linter(?) is giving stricter errors than the actual Angular 19 compiler……

Any help on fixing that?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật