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

Let plugins get access to the note of the current window #638

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion share/plugins/Note.Outline/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@
pluginData = window.WizPluginData;
pluginPath = pluginData.path;
objWindow = objApp.Window;
browserObject = objWindow.CurrentDocumentBrowserObject;
browserObject = window.WizDocumentBrowser;
strings = JSON.parse(pluginData.strings);
objApp.LoadStringFromFile = LoadStringFromFile;
//
Expand Down
6 changes: 4 additions & 2 deletions src/WizPlugins.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "WizPlugins.h"
#include "sync/WizToken.h"
#include "WizMainWindow.h"
#include "WizDocumentWebView.h"
#include "share/WizGlobal.h"
#include "utils/WizPathResolve.h"
#include "widgets/WizLocalProgressWebView.h"
Expand Down Expand Up @@ -321,15 +322,16 @@ void WizPluginData::initStrings()
}


WizPluginPopupWidget::WizPluginPopupWidget(WizExplorerApp& app, WizPluginData* data, QWidget* parent)
WizPluginPopupWidget::WizPluginPopupWidget(WizExplorerApp& app, WizPluginData* data, WizDocumentWebView* web, QWidget* parent)
: WizPopupWidget(parent)
, m_data(data)
{
data->initStrings();
//
WizWebEngineViewInjectObjects objects = {
{"WizPluginData", m_data},
{"WizExplorerApp", app.object()}
{"WizExplorerApp", app.object()},
{"WizDocumentBrowser", web}
};
m_web = WizWebEngineView::create(objects, this);
//
Expand Down
3 changes: 2 additions & 1 deletion src/WizPlugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class WizWebEngineView;
class WizExplorerApp;
class WizPluginPopupWidget;
class WizDocumentWebView;

class WizPluginData : public QObject
{
Expand Down Expand Up @@ -50,7 +51,7 @@ class WizPluginData : public QObject
class WizPluginPopupWidget : public WizPopupWidget
{
public:
WizPluginPopupWidget(WizExplorerApp& app, WizPluginData* data, QWidget* parent);
WizPluginPopupWidget(WizExplorerApp& app, WizPluginData* data, WizDocumentWebView* web, QWidget* parent);
public:
WizWebEngineView* web() const {return m_web; }
private:
Expand Down
4 changes: 3 additions & 1 deletion src/WizTitleBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ void WizTitleBar::onPluginButtonClicked()
auto it = m_pluginWidget.find(guid);
WizPluginPopupWidget* widget;
if (it == m_pluginWidget.end()) {
widget = new WizPluginPopupWidget(m_app, data, this);
// passing the current note
WizDocumentWebView* web = noteView()->web();
widget = new WizPluginPopupWidget(m_app, data, web, this);
m_pluginWidget.insert(std::make_pair(guid, widget));
} else {
widget = it->second;
Expand Down