New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

digirati-annotation-redux

Package Overview
Dependencies
Maintainers
3
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

digirati-annotation-redux - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0

es/actions/resources.js

29

es/actions/drafts.js
import _extends from 'babel-runtime/helpers/extends';
import uuid from 'uuid/v4';
import { addAnnotation } from './annotations';
import { cancelSelector, chooseSelector } from './selectors';
import { getCurrentResourceTemplate, getForm } from '../query/resourceTemplateQuery';
import { cancelSelector, chooseSelector, commitToCurrentDraft, editCurrentDraftSelector } from './selectors';
import { getCurrentResourceTemplate } from '../query/resourceQuery';
import { getCurrentDraft } from '../query/draftQuery';
import { selectorCompat } from '../utility';
import { withViewer } from './viewer';
import { isSelecting } from '../query/selectorQuery';

@@ -38,5 +39,6 @@ export var DRAFT_CREATE = 'DRAFT_CREATE';

if (currentTemplate) {
var form = getForm(currentTemplate);
if (form.meta && form.meta.selector) {
dispatch(chooseSelector(form.meta.selector));
if (currentTemplate.metaData && currentTemplate.metaData.selector) {
dispatch(chooseSelector(currentTemplate.metaData.selector, { template: currentTemplate.id, draft: id }));
} else {
dispatch(chooseSelector('WholeCanvasSelector', { template: currentTemplate.id, draft: id }));
}

@@ -173,7 +175,20 @@ }

export function previewDraft(id) {
return { type: DRAFT_PREVIEW, payload: { id: id } };
return function (dispatch, getState) {
var state = getState();
if (isSelecting(state)) {
dispatch(commitToCurrentDraft(state.selector.currentSelector.type.toLowerCase() === 'wholecanvasselector'));
}
dispatch({ type: DRAFT_PREVIEW, payload: { id: id } });
};
}
export function unpreviewDraft(id) {
return { type: DRAFT_UNPREVIEW, payload: { id: id } };
return function (dispatch, getState) {
dispatch({ type: DRAFT_UNPREVIEW, payload: { id: id } });
var state = getState();
var currentDraft = getCurrentDraft(state);
if (currentDraft.selector && currentDraft.selector.type && currentDraft.selector.type.toLowerCase() !== 'wholecanvasselector') {
dispatch(editCurrentDraftSelector());
}
};
}

@@ -180,0 +195,0 @@

import md5 from 'blueimp-md5';
import { getCollectionId, getServer } from '../query/elucidateQuery';
import { createElucidateCollection, sendAnnotationToServer } from '../lib/elucidate';
export var ELUCIDATE_SET_SERVER = 'ELUCIDATE_SET_SERVER';

@@ -9,5 +11,2 @@ export var ELUCIDATE_SET_RESOURCE = 'ELUCIDATE_SET_RESOURCE';

import { getCollectionId, getServer } from '../query/elucidateQuery';
import { createElucidateCollection, getAnnotation, sendAnnotationToServer } from '../lib/elucidate';
export function initialiseElucidate(elucidateServer, resource, resourceLabel) {

@@ -14,0 +13,0 @@ return function (dispatch, state) {

@@ -5,3 +5,3 @@ import * as logging from './logging';

import * as drafts from './drafts';
import * as resourceTemplate from './resourceTemplate';
import * as resources from './resources';
import * as elucidate from './elucidate';

@@ -12,2 +12,2 @@ import * as manifest from './manifest';

export { logging, annotations, selectors, drafts, resourceTemplate, elucidate, manifest, viewer, help };
export { logging, annotations, selectors, drafts, resources, elucidate, manifest, viewer, help };
import _extends from 'babel-runtime/helpers/extends';
import { addSelectorToDraft, addSelectorToDraftField, addSelectorToDraftFieldFromViewer, addSelectorToDraftFromViewer, discardCurrentDraft, removeSelectorFromDraft, removeSelectorFromDraftField } from './drafts';
import { addSelectorToDraft, addSelectorToDraftFieldFromViewer, addSelectorToDraftFromViewer, discardCurrentDraft, removeSelectorFromDraft, removeSelectorFromDraftField } from './drafts';
import { getCurrentDraft } from '../query/draftQuery';

@@ -18,9 +18,13 @@ import { selectorCompat } from '../utility';

export function chooseSelector(type, defaults, done) {
if (!defaults) {
export function chooseSelector(type, source, defaults, done) {
// @todo find better way of Canvas relative vs Viewport relative inspections
if (!defaults || type.toLowerCase() !== 'madoc:boxdraw') {
return function (dispatch) {
dispatch({
type: SELECTOR_CHOOSE,
payload: { type: type, defaults: selectorCompat(defaults) }
payload: { type: type, source: source, defaults: selectorCompat(defaults) }
});
if (type.toLowerCase() === 'wholecanvasselector') {
dispatch(commitToCurrentDraft(false));
}
if (done) {

@@ -55,4 +59,4 @@ done();

export function chooseSecondarySelector(id, type, defaults, done) {
return chooseSelector(type, _extends({}, selectorCompat(defaults), { id: id, secondary: true }), done);
export function chooseSecondarySelector(id, source, type, defaults, done) {
return chooseSelector(type, source, _extends({}, selectorCompat(defaults), { id: id, secondary: true }), done);
}

@@ -76,6 +80,7 @@

id = _getCurrentDraft.id,
selectors = _getCurrentDraft.selectors;
selectors = _getCurrentDraft.selectors,
template = _getCurrentDraft.template;
if (id && selectors && selectors[fieldId]) {
dispatch(chooseSecondarySelector(fieldId, selectors[fieldId].type, selectorCompat(selectors[fieldId]),
dispatch(chooseSecondarySelector(fieldId, { template: template, draft: id }, selectors[fieldId].type, selectorCompat(selectors[fieldId]),
// Remove only after choosing.

@@ -93,3 +98,4 @@ function () {

id = _getCurrentDraft2.id,
selector = _getCurrentDraft2.selector;
selector = _getCurrentDraft2.selector,
template = _getCurrentDraft2.template;

@@ -100,3 +106,3 @@ if (id && selector) {

}
dispatch(chooseSelector(selector.type, selectorCompat(selector), function () {
dispatch(chooseSelector(selector.type, { template: template, draft: id }, selectorCompat(selector), function () {
return dispatch(removeSelectorFromDraft(id));

@@ -103,0 +109,0 @@ }));

import { connect } from 'react-redux';
import { asyncPublishDraft, confirmDraft, createDraft, deselectDraft, previewDraft, publishDraft, selectDraft, unpreviewDraft, updateDraft, discardDraft, discardCurrentDraft, removeSelectorFromCurrentDraft, removeSelectorFromDraft, editCurrentDraftFieldSelector } from './actions/drafts';
import { addSelectorToDraftFromViewer, asyncPublishDraft, confirmDraft, createDraft, deselectDraft, discardCurrentDraft, discardDraft, editCurrentDraftFieldSelector, previewDraft, publishDraft, removeSelectorFromCurrentDraft, removeSelectorFromDraft, selectDraft, unpreviewDraft, updateDraft } from './actions/drafts';
import { addAnnotation } from './actions/annotations';
import { cancelSelector, chooseSelector, commitToCurrentDraft, setAvailableSelectors, chooseSecondarySelector, commitToCurrentDraftField, updateSelector, editCurrentDraftSelector, editCurrentDraftSecondarySelector } from './actions/selectors';
import { cancelSelector, chooseSecondarySelector, chooseSelector, commitToCurrentDraft, commitToCurrentDraftField, editCurrentDraftSecondarySelector, editCurrentDraftSelector, setAvailableSelectors, updateSelector } from './actions/selectors';
import { addElucidateAnnotation, createCollection, sendAnnotation, setCollection, setResource, setServer } from './actions/elucidate';
import { moveBack, moveForward, reset } from './actions/resources';
import { currentDraftEditableRegions, getCurrentDraft } from './query/draftQuery';
import { getCurrentResourceTemplate, getForm, resourceTemplateList } from './query/resourceTemplateQuery';
import { getCurrentResourceTemplate, getForm, resourceTemplateList } from './query/resourceQuery';
import { addManifest, removeManifest, requestManifest, selectCanvas, selectManifest } from './actions/manifest';
import { richAnnotationList } from './query/elucidateQuery';
import { setViewer, withViewer } from './actions/viewer';
import { isSelecting, currentSelectorIsSecondary } from './query/selectorQuery';
import { currentSelectorIsSecondary, isSelecting } from './query/selectorQuery';
export default connect(function (state) {

@@ -39,3 +40,3 @@ var annotationList = richAnnotationList(state);

resourceForm: currentResourceTemplate ? getForm(currentResourceTemplate) : null,
resourceTemplates: state.resourceTemplates
resourceTemplates: state.resource
};

@@ -63,2 +64,3 @@ }, {

editCurrentDraftSecondarySelector: editCurrentDraftSecondarySelector,
addSelectorToDraftFromViewer: addSelectorToDraftFromViewer,
removeSelectorFromDraft: removeSelectorFromDraft,

@@ -81,3 +83,6 @@ editCurrentDraftSelector: editCurrentDraftSelector,

selectCanvas: selectCanvas,
selectManifest: selectManifest
selectManifest: selectManifest,
moveForward: moveForward,
moveBack: moveBack,
reset: reset
}, null, { withRef: true });

@@ -1,2 +0,2 @@

import { applyMiddleware, combineReducers, createStore, compose } from 'redux';
import { applyMiddleware, combineReducers, compose, createStore } from 'redux';
import middleware from './middleware';

@@ -3,0 +3,0 @@

@@ -304,3 +304,3 @@ import _regeneratorRuntime from 'babel-runtime/regenerator';

type: 'Annotation',
label: label,
label: label ? label : 'unknown',
body: body,

@@ -307,0 +307,0 @@ target: target,

@@ -1,3 +0,1 @@

export function getHelpByType(type, state) {

@@ -4,0 +2,0 @@ if (!state.help[type]) {

export * from './draftQuery';
export * from './resourceTemplateQuery';
export * from './resourceQuery';

@@ -1,2 +0,1 @@

export function currentManifest(state) {

@@ -3,0 +2,0 @@ return manifestById(state, state.manifest.current);

import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import { DRAFT_CREATE, DRAFT_PUBLISHED, DRAFT_PUBLISHING, DRAFT_SELECT, DRAFT_UPDATE_INPUT, DRAFT_UPDATE_SELECTOR, DRAFT_REMOVE_SELECTOR, DRAFT_DESELECT, DRAFT_PREVIEW, DRAFT_CONFIRM, DRAFT_UNPREVIEW, DRAFT_UPDATE_FIELD_SELECTOR, DRAFT_DISCARD } from '../actions/drafts';
import { DRAFT_CONFIRM, DRAFT_CREATE, DRAFT_DESELECT, DRAFT_DISCARD, DRAFT_PREVIEW, DRAFT_PUBLISHED, DRAFT_PUBLISHING, DRAFT_REMOVE_SELECTOR, DRAFT_SELECT, DRAFT_UNPREVIEW, DRAFT_UPDATE_FIELD_SELECTOR, DRAFT_UPDATE_INPUT, DRAFT_UPDATE_SELECTOR } from '../actions/drafts';
import update from 'immutability-helper';

@@ -4,0 +4,0 @@

@@ -6,4 +6,4 @@ import logging from './loggingReducer';

import elucidate from './elucidateReducer';
import resourceTemplates from './resourceTemplatesReducer';
import manifest from './manifestReducer';
import resource from './resourceReducer';
import help from './helpReducer';

@@ -14,5 +14,5 @@

drafts: drafts,
resource: resource,
annotations: annotations,
selector: selector,
resourceTemplates: resourceTemplates,
elucidate: elucidate,

@@ -19,0 +19,0 @@ manifest: manifest,

import _extends from 'babel-runtime/helpers/extends';
import { SELECTOR_CHOOSE, SELECTOR_COMMIT_TO_DRAFT, SELECTOR_SET_AVAILABLE, SELECTOR_UPDATE, SELECTOR_COMMIT_TO_DRAFT_FIELD, SELECTOR_CANCEL } from '../actions/selectors';
import { SELECTOR_CANCEL, SELECTOR_CHOOSE, SELECTOR_COMMIT_TO_DRAFT, SELECTOR_COMMIT_TO_DRAFT_FIELD, SELECTOR_SET_AVAILABLE, SELECTOR_UPDATE } from '../actions/selectors';
import update from 'immutability-helper';

@@ -25,3 +25,4 @@

$set: _extends({
type: action.payload.type
type: action.payload.type,
source: action.payload.source
}, action.payload.defaults)

@@ -28,0 +29,0 @@ }

@@ -1,2 +0,1 @@

var SHOW_LOGS = false;

@@ -3,0 +2,0 @@ var SHOW_WARNINGS = false;

@@ -39,3 +39,3 @@ 'use strict';

var _resourceTemplateQuery = require('../query/resourceTemplateQuery');
var _resourceQuery = require('../query/resourceQuery');

@@ -48,2 +48,4 @@ var _draftQuery = require('../query/draftQuery');

var _selectorQuery = require('../query/selectorQuery');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -77,7 +79,8 @@

dispatch(selectDraft(id));
var currentTemplate = (0, _resourceTemplateQuery.getCurrentResourceTemplate)(state());
var currentTemplate = (0, _resourceQuery.getCurrentResourceTemplate)(state());
if (currentTemplate) {
var form = (0, _resourceTemplateQuery.getForm)(currentTemplate);
if (form.meta && form.meta.selector) {
dispatch((0, _selectors2.chooseSelector)(form.meta.selector));
if (currentTemplate.metaData && currentTemplate.metaData.selector) {
dispatch((0, _selectors2.chooseSelector)(currentTemplate.metaData.selector, { template: currentTemplate.id, draft: id }));
} else {
dispatch((0, _selectors2.chooseSelector)('WholeCanvasSelector', { template: currentTemplate.id, draft: id }));
}

@@ -214,7 +217,20 @@ }

function previewDraft(id) {
return { type: DRAFT_PREVIEW, payload: { id: id } };
return function (dispatch, getState) {
var state = getState();
if ((0, _selectorQuery.isSelecting)(state)) {
dispatch((0, _selectors2.commitToCurrentDraft)(state.selector.currentSelector.type.toLowerCase() === 'wholecanvasselector'));
}
dispatch({ type: DRAFT_PREVIEW, payload: { id: id } });
};
}
function unpreviewDraft(id) {
return { type: DRAFT_UNPREVIEW, payload: { id: id } };
return function (dispatch, getState) {
dispatch({ type: DRAFT_UNPREVIEW, payload: { id: id } });
var state = getState();
var currentDraft = (0, _draftQuery.getCurrentDraft)(state);
if (currentDraft.selector && currentDraft.selector.type && currentDraft.selector.type.toLowerCase() !== 'wholecanvasselector') {
dispatch((0, _selectors2.editCurrentDraftSelector)());
}
};
}

@@ -221,0 +237,0 @@

'use strict';
exports.__esModule = true;
exports.help = exports.viewer = exports.manifest = exports.elucidate = exports.resourceTemplate = exports.drafts = exports.selectors = exports.annotations = exports.logging = undefined;
exports.help = exports.viewer = exports.manifest = exports.elucidate = exports.resources = exports.drafts = exports.selectors = exports.annotations = exports.logging = undefined;

@@ -22,5 +22,5 @@ var _logging = require('./logging');

var _resourceTemplate = require('./resourceTemplate');
var _resources = require('./resources');
var resourceTemplate = _interopRequireWildcard(_resourceTemplate);
var resources = _interopRequireWildcard(_resources);

@@ -49,3 +49,3 @@ var _elucidate = require('./elucidate');

exports.drafts = drafts;
exports.resourceTemplate = resourceTemplate;
exports.resources = resources;
exports.elucidate = elucidate;

@@ -52,0 +52,0 @@ exports.manifest = manifest;

@@ -41,9 +41,13 @@ 'use strict';

function chooseSelector(type, defaults, done) {
if (!defaults) {
function chooseSelector(type, source, defaults, done) {
// @todo find better way of Canvas relative vs Viewport relative inspections
if (!defaults || type.toLowerCase() !== 'madoc:boxdraw') {
return function (dispatch) {
dispatch({
type: SELECTOR_CHOOSE,
payload: { type: type, defaults: (0, _utility.selectorCompat)(defaults) }
payload: { type: type, source: source, defaults: (0, _utility.selectorCompat)(defaults) }
});
if (type.toLowerCase() === 'wholecanvasselector') {
dispatch(commitToCurrentDraft(false));
}
if (done) {

@@ -78,4 +82,4 @@ done();

function chooseSecondarySelector(id, type, defaults, done) {
return chooseSelector(type, (0, _extends3.default)({}, (0, _utility.selectorCompat)(defaults), { id: id, secondary: true }), done);
function chooseSecondarySelector(id, source, type, defaults, done) {
return chooseSelector(type, source, (0, _extends3.default)({}, (0, _utility.selectorCompat)(defaults), { id: id, secondary: true }), done);
}

@@ -99,6 +103,7 @@

id = _getCurrentDraft.id,
selectors = _getCurrentDraft.selectors;
selectors = _getCurrentDraft.selectors,
template = _getCurrentDraft.template;
if (id && selectors && selectors[fieldId]) {
dispatch(chooseSecondarySelector(fieldId, selectors[fieldId].type, (0, _utility.selectorCompat)(selectors[fieldId]),
dispatch(chooseSecondarySelector(fieldId, { template: template, draft: id }, selectors[fieldId].type, (0, _utility.selectorCompat)(selectors[fieldId]),
// Remove only after choosing.

@@ -116,3 +121,4 @@ function () {

id = _getCurrentDraft2.id,
selector = _getCurrentDraft2.selector;
selector = _getCurrentDraft2.selector,
template = _getCurrentDraft2.template;

@@ -123,3 +129,3 @@ if (id && selector) {

}
dispatch(chooseSelector(selector.type, (0, _utility.selectorCompat)(selector), function () {
dispatch(chooseSelector(selector.type, { template: template, draft: id }, (0, _utility.selectorCompat)(selector), function () {
return dispatch((0, _drafts.removeSelectorFromDraft)(id));

@@ -126,0 +132,0 @@ }));

@@ -15,5 +15,7 @@ 'use strict';

var _resources = require('./actions/resources');
var _draftQuery = require('./query/draftQuery');
var _resourceTemplateQuery = require('./query/resourceTemplateQuery');
var _resourceQuery = require('./query/resourceQuery');

@@ -30,3 +32,3 @@ var _manifest = require('./actions/manifest');

var annotationList = (0, _elucidateQuery.richAnnotationList)(state);
var currentResourceTemplate = (0, _resourceTemplateQuery.getCurrentResourceTemplate)(state);
var currentResourceTemplate = (0, _resourceQuery.getCurrentResourceTemplate)(state);
var currentDraft = (0, _draftQuery.getCurrentDraft)(state);

@@ -48,3 +50,3 @@ var currentSelector = state.selector && state.selector.currentSelector ? state.selector.currentSelector : null;

draftHasSelector: !currentDraft || !currentDraft.selector,
resourceTemplateList: (0, _resourceTemplateQuery.resourceTemplateList)(state),
resourceTemplateList: (0, _resourceQuery.resourceTemplateList)(state),
wholeCanvasAnnotations: annotationList ? annotationList.filter(function (anno) {

@@ -56,4 +58,4 @@ return anno.selector && !anno.selector.target.expanded;

}) : [],
resourceForm: currentResourceTemplate ? (0, _resourceTemplateQuery.getForm)(currentResourceTemplate) : null,
resourceTemplates: state.resourceTemplates
resourceForm: currentResourceTemplate ? (0, _resourceQuery.getForm)(currentResourceTemplate) : null,
resourceTemplates: state.resource
};

@@ -81,2 +83,3 @@ }, {

editCurrentDraftSecondarySelector: _selectors.editCurrentDraftSecondarySelector,
addSelectorToDraftFromViewer: _drafts.addSelectorToDraftFromViewer,
removeSelectorFromDraft: _drafts.removeSelectorFromDraft,

@@ -99,4 +102,7 @@ editCurrentDraftSelector: _selectors.editCurrentDraftSelector,

selectCanvas: _manifest.selectCanvas,
selectManifest: _manifest.selectManifest
selectManifest: _manifest.selectManifest,
moveForward: _resources.moveForward,
moveBack: _resources.moveBack,
reset: _resources.reset
}, null, { withRef: true });
module.exports = exports['default'];

@@ -332,3 +332,3 @@ 'use strict';

type: 'Annotation',
label: label,
label: label ? label : 'unknown',
body: body,

@@ -335,0 +335,0 @@ target: target,

@@ -17,5 +17,5 @@ 'use strict';

var _resourceTemplateQuery = require('./resourceTemplateQuery');
var _resourceQuery = require('./resourceQuery');
Object.keys(_resourceTemplateQuery).forEach(function (key) {
Object.keys(_resourceQuery).forEach(function (key) {
if (key === "default" || key === "__esModule") return;

@@ -25,5 +25,5 @@ Object.defineProperty(exports, key, {

get: function get() {
return _resourceTemplateQuery[key];
return _resourceQuery[key];
}
});
});

@@ -25,6 +25,2 @@ 'use strict';

var _resourceTemplatesReducer = require('./resourceTemplatesReducer');
var _resourceTemplatesReducer2 = _interopRequireDefault(_resourceTemplatesReducer);
var _manifestReducer = require('./manifestReducer');

@@ -34,2 +30,6 @@

var _resourceReducer = require('./resourceReducer');
var _resourceReducer2 = _interopRequireDefault(_resourceReducer);
var _helpReducer = require('./helpReducer');

@@ -44,5 +44,5 @@

drafts: _draftReducer2.default,
resource: _resourceReducer2.default,
annotations: _annotationReducer2.default,
selector: _selectorReducer2.default,
resourceTemplates: _resourceTemplatesReducer2.default,
elucidate: _elucidateReducer2.default,

@@ -49,0 +49,0 @@ manifest: _manifestReducer2.default,

@@ -39,3 +39,4 @@ 'use strict';

$set: (0, _extends3.default)({
type: action.payload.type
type: action.payload.type,
source: action.payload.source
}, action.payload.defaults)

@@ -42,0 +43,0 @@ }

@@ -5,3 +5,2 @@ 'use strict';

exports.selectorCompat = selectorCompat;
var SHOW_LOGS = false;

@@ -8,0 +7,0 @@ var SHOW_WARNINGS = false;

{
"name": "digirati-annotation-redux",
"version": "0.5.1",
"version": "0.6.0",
"description": "Describe annotation-redux here",

@@ -5,0 +5,0 @@ "main": "es/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc