Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wondering how can i add a new function like "slide hyperlink" #17

Open
popsugon opened this issue Jan 16, 2018 · 3 comments
Open

Wondering how can i add a new function like "slide hyperlink" #17

popsugon opened this issue Jan 16, 2018 · 3 comments
Labels

Comments

@popsugon
Copy link

No description provided.

@Miramac
Copy link
Owner

Miramac commented Jan 16, 2018

A good question, because unfortunately there is no documentation yet on how to contribute to the project.

Add the function in C#

In your case you want to add this function as a shape function.

/src/OfficeScript/OfficeScript/Report/Shape.cs

/// <summary>
/// Add a hyperlink to the shape
/// </summary>
/// <param name="parameters"></param>
private void AddHyperlink(Dictionary<string, object> parameters)
{
    // Some code to add a Hyperlink to a schape
}

Make the function public to Javascript

Add a new async function to the return object of Invoke()
/src/OfficeScript/OfficeScript/Report/Shape.cs

public object Invoke()
{
    return new
    {
        attr = (Func<object, Task<object>>)(
            async (input) =>
            {
                if (input is string)
                {
                    var tmp = new Dictionary<string, object>();
                    tmp.Add("name", input);
                    input = tmp;
                }
                return Util.Attr(this, (input as IDictionary<string, object>).ToDictionary(d => d.Key, d => d.Value), Invoke);
            }),
            
        // . . . other code . . .
     
        // your new hyperlink function
        addHyperlink = (Func<object, Task<object>>)(
            async (input) =>
            {
                this.AddHyperlink((input as IDictionary<string, object>).ToDictionary(d => d.Key, d => d.Value));
                return this.Invoke(); // return the shape.Invoke() result for chaining
            })
    };
}

Compile the C# code

gulp build

Create a javascript wrapper

/lib/powerpoint/shape.js

shape.addHyperlink = function (address, subAddress) {
  return nativeShape.addHyperlink({
    address: address,
    subAddress: subAddress
  }, true)
}

Make a pull requests

I would love to add your new function to the library!

@popsugon
Copy link
Author

Hi @Miramac ,

it would be greater if you add the function about "shape.Table add rows/delete rows".

@Miramac
Copy link
Owner

Miramac commented Jan 16, 2018

Yes, the function for adding/deleting rows/columns in tables is missing.
Unfortunately not a fast finished task, how the tables are currently being processed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants