odoo / o-spreadsheet

Other
186 stars 42 forks source link

add o-spreadsheet in existing react project #4772

Open Mar4ikler opened 1 month ago

Mar4ikler commented 1 month ago

I can't implement simple example in existing react project, because Model and Spreadsheet exports does not exist, any hints?

rrahir commented 1 month ago

Hi !

Unfortunately we exclusively focus on the integration in Odoo which does not require hybrid integration with React, we might have overlooked crucial elements to ease that step. That being said, let's try to sort it out.

Could you elaborate on your usecase? Maybe with an example of which code you are starting from?

Generally speaking, If you want to use the library in an outside project there are 2 approaches.

1. build from scratch

build the library (npm run dist) and use the compiled file that suits your need (they are located in <rootDir>/dist.

2. load the npm package @odoo/o-spreadsheet

You can then find the same files in <rootDir>/node_modules/@odoo/o-spreadsheet/dist

The file iife will automatically add the global varialbe o_spreadsheet to window -> you can invoke window.o_spreadsheet, in which you will find all the useful classes like Spreadsheet (o_spreadsheet.Spreadsheet) and Model (o_spreadsheet.Model)

If you use an alternative, like the esm version then you might want to follow the same strategy we do to use the library in Odoo: https://github.com/odoo/odoo/blob/master/addons/spreadsheet/static/src/o_spreadsheet/odoo_module.js

Note that the library requires some dependencies to work properly, namely those found in here. Don't forget to add them as well.

rrahir commented 1 month ago

I just saw that dberardo-com provided an example of pseudo-code for his React component here, it might help as well? https://github.com/odoo/o-spreadsheet/issues/3249#issuecomment-1926387505