Skip to content
Snippets Groups Projects
Commit a0fd024b authored by chris's avatar chris
Browse files

disable certain tools in notes

parent 7bd79544
No related branches found
No related tags found
1 merge request!144enable insertions, deletions on codeblock
Showing
with 646 additions and 72 deletions
import Tools from "../../lib/Tools"; import Tools from '../../lib/Tools';
import { injectable } from "inversify"; import { injectable } from 'inversify';
import { Commands } from "wax-prosemirror-utilities"; import { Commands } from 'wax-prosemirror-utilities';
@injectable() @injectable()
export default class SubTitle extends Tools { export default class SubTitle extends Tools {
title = "Change to Subtitle"; title = 'Change to Subtitle';
content = "Subtitle"; content = 'Subtitle';
get run() { get run() {
return (state, dispatch) => { return (state, dispatch) => {
Commands.setBlockType(state.config.schema.nodes.subtitle, { Commands.setBlockType(state.config.schema.nodes.subtitle, {
class: "cst" class: 'cst',
})(state, dispatch); })(state, dispatch);
}; };
} }
select = (state, activeViewId) => {
if (activeViewId !== 'main') return false;
return true;
};
get enable() { get enable() {
return state => { return state => {
return Commands.setBlockType(state.config.schema.nodes.subtitle)(state); return Commands.setBlockType(state.config.schema.nodes.subtitle)(state);
......
import Tools from "../../lib/Tools"; import Tools from '../../lib/Tools';
import { injectable } from "inversify"; import { injectable } from 'inversify';
import { Commands } from "wax-prosemirror-utilities"; import { Commands } from 'wax-prosemirror-utilities';
@injectable() @injectable()
export default class Title extends Tools { export default class Title extends Tools {
title = "Change to Title"; title = 'Change to Title';
content = "Title"; content = 'Title';
get run() { get run() {
return (state, dispatch) => { return (state, dispatch) => {
Commands.setBlockType(state.config.schema.nodes.title, { Commands.setBlockType(state.config.schema.nodes.title, {
class: "title" class: 'title',
})(state, dispatch); })(state, dispatch);
}; };
} }
select = (state, activeViewId) => {
if (activeViewId !== 'main') return false;
return true;
};
get enable() { get enable() {
return state => { return state => {
return Commands.setBlockType(state.config.schema.nodes.title)(state); return Commands.setBlockType(state.config.schema.nodes.title)(state);
......
...@@ -17,6 +17,11 @@ class Image extends Tools { ...@@ -17,6 +17,11 @@ class Image extends Tools {
return () => true; return () => true;
} }
select = (state, activeViewId) => {
if (activeViewId !== 'main') return false;
return true;
};
get enable() { get enable() {
return state => { return state => {
return Commands.canInsert(state.config.schema.nodes.image)(state); return Commands.canInsert(state.config.schema.nodes.image)(state);
...@@ -31,7 +36,12 @@ class Image extends Tools { ...@@ -31,7 +36,12 @@ class Image extends Tools {
this.pmplugins.get('imagePlaceHolder'), this.pmplugins.get('imagePlaceHolder'),
); );
return this._isDisplayed ? ( return this._isDisplayed ? (
<ImageUpload key={uuidv4()} item={this.toJSON()} fileUpload={upload} /> <ImageUpload
key={uuidv4()}
item={this.toJSON()}
fileUpload={upload}
view={view}
/>
) : null; ) : null;
} }
} }
import Tools from "../../lib/Tools"; import Tools from '../../lib/Tools';
import { injectable } from "inversify"; import { injectable } from 'inversify';
import { icons } from "wax-prosemirror-components"; import { icons } from 'wax-prosemirror-components';
import { wrapInList } from "prosemirror-schema-list"; import { wrapInList } from 'prosemirror-schema-list';
import { Commands } from "wax-prosemirror-utilities"; import { Commands } from 'wax-prosemirror-utilities';
@injectable() @injectable()
export default class BulletList extends Tools { export default class BulletList extends Tools {
title = "Wrap in bullet list"; title = 'Wrap in bullet list';
content = icons.bullet_list; content = icons.bullet_list;
get run() { get run() {
...@@ -21,6 +21,11 @@ export default class BulletList extends Tools { ...@@ -21,6 +21,11 @@ export default class BulletList extends Tools {
}; };
} }
select = (state, activeViewId) => {
if (activeViewId !== 'main') return false;
return true;
};
get active() { get active() {
return state => { return state => {
return Commands.blockActive(state.config.schema.nodes.bulletlist)(state); return Commands.blockActive(state.config.schema.nodes.bulletlist)(state);
......
import Tools from "../../lib/Tools"; import Tools from '../../lib/Tools';
import { injectable } from "inversify"; import { injectable } from 'inversify';
import { icons } from "wax-prosemirror-components"; import { icons } from 'wax-prosemirror-components';
import { wrapInList } from "prosemirror-schema-list"; import { wrapInList } from 'prosemirror-schema-list';
import { Commands } from "wax-prosemirror-utilities"; import { Commands } from 'wax-prosemirror-utilities';
@injectable() @injectable()
export default class OrderedList extends Tools { export default class OrderedList extends Tools {
title = "Wrap in ordered list"; title = 'Wrap in ordered list';
content = icons.ordered_list; content = icons.ordered_list;
get run() { get run() {
...@@ -21,6 +21,11 @@ export default class OrderedList extends Tools { ...@@ -21,6 +21,11 @@ export default class OrderedList extends Tools {
}; };
} }
select = (state, activeViewId) => {
if (activeViewId !== 'main') return false;
return true;
};
get active() { get active() {
return state => { return state => {
return Commands.blockActive(state.config.schema.nodes.orderedlist)(state); return Commands.blockActive(state.config.schema.nodes.orderedlist)(state);
......
import Tools from "../lib/Tools"; import Tools from '../lib/Tools';
import { injectable } from "inversify"; import { injectable } from 'inversify';
import { icons } from "wax-prosemirror-components"; import { icons } from 'wax-prosemirror-components';
import { Fragment } from "prosemirror-model"; import { Fragment } from 'prosemirror-model';
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from 'uuid';
@injectable() @injectable()
export default class Note extends Tools { export default class Note extends Tools {
title = "Insert Note"; title = 'Insert Note';
content = icons.footnote; content = icons.footnote;
get run() { get run() {
...@@ -16,18 +16,22 @@ export default class Note extends Tools { ...@@ -16,18 +16,22 @@ export default class Note extends Tools {
if (!empty && $from.sameParent($to) && $from.parent.inlineContent) if (!empty && $from.sameParent($to) && $from.parent.inlineContent)
content = $from.parent.content.cut( content = $from.parent.content.cut(
$from.parentOffset, $from.parentOffset,
$to.parentOffset $to.parentOffset,
); );
const footnote = state.config.schema.nodes.footnote.create( const footnote = state.config.schema.nodes.footnote.create(
{ id: uuidv4() }, { id: uuidv4() },
content content,
); );
dispatch(state.tr.replaceSelectionWith(footnote)); dispatch(state.tr.replaceSelectionWith(footnote));
}; };
} }
select = (state, activeViewId) => {
if (activeViewId !== 'main') return false;
return true;
};
get enable() { get enable() {
// // TODO disable on notes editor
return state => { return state => {
return true; return true;
}; };
......
...@@ -14,6 +14,11 @@ export default class Table extends Tools { ...@@ -14,6 +14,11 @@ export default class Table extends Tools {
}; };
} }
select = (state, activeViewId) => {
if (activeViewId !== 'main') return false;
return true;
};
get enable() { get enable() {
return state => { return state => {
return Commands.canInsert(state.config.schema.nodes.table)(state); return Commands.canInsert(state.config.schema.nodes.table)(state);
......
import Tools from "../../lib/Tools"; import Tools from '../../lib/Tools';
import { injectable } from "inversify"; import { injectable } from 'inversify';
import { wrapIn } from "prosemirror-commands"; import { wrapIn } from 'prosemirror-commands';
@injectable() @injectable()
class BlockQuote extends Tools { class BlockQuote extends Tools {
title = "Change to Block Quote"; title = 'Change to Block Quote';
content = "Block Quote"; content = 'Block Quote';
get run() { get run() {
return (state, dispatch) => { return (state, dispatch) => {
...@@ -13,6 +13,11 @@ class BlockQuote extends Tools { ...@@ -13,6 +13,11 @@ class BlockQuote extends Tools {
}; };
} }
select = (state, activeViewId) => {
if (activeViewId !== 'main') return false;
return true;
};
get enable() { get enable() {
return state => { return state => {
return wrapIn(state.config.schema.nodes.blockquote)(state); return wrapIn(state.config.schema.nodes.blockquote)(state);
......
import Tools from "../../lib/Tools"; import Tools from '../../lib/Tools';
import { injectable } from "inversify"; import { injectable } from 'inversify';
import { Commands } from "wax-prosemirror-utilities"; import { Commands } from 'wax-prosemirror-utilities';
@injectable() @injectable()
class ExtractPoetry extends Tools { class ExtractPoetry extends Tools {
title = "Change to Extract Poetry"; title = 'Change to Extract Poetry';
content = "Extract Poetry"; content = 'Extract Poetry';
get run() { get run() {
return (state, dispatch) => { return (state, dispatch) => {
Commands.setBlockType(state.config.schema.nodes.extractPoetry, { Commands.setBlockType(state.config.schema.nodes.extractPoetry, {
class: "extract-poetry" class: 'extract-poetry',
})(state, dispatch); })(state, dispatch);
}; };
} }
select = (state, activeViewId) => {
if (activeViewId !== 'main') return false;
return true;
};
get enable() { get enable() {
return state => { return state => {
return Commands.setBlockType(state.config.schema.nodes.extractPoetry)( return Commands.setBlockType(state.config.schema.nodes.extractPoetry)(
state state,
); );
}; };
} }
......
import Tools from "../../lib/Tools"; import Tools from '../../lib/Tools';
import { injectable } from "inversify"; import { injectable } from 'inversify';
import { Commands } from "wax-prosemirror-utilities"; import { Commands } from 'wax-prosemirror-utilities';
@injectable() @injectable()
class ExtractProse extends Tools { class ExtractProse extends Tools {
title = "Change to Extract Prose"; title = 'Change to Extract Prose';
content = "Extract Prose"; content = 'Extract Prose';
get run() { get run() {
return (state, dispatch) => { return (state, dispatch) => {
Commands.setBlockType(state.config.schema.nodes.extractProse, { Commands.setBlockType(state.config.schema.nodes.extractProse, {
class: "extract-prose" class: 'extract-prose',
})(state, dispatch); })(state, dispatch);
}; };
} }
select = (state, activeViewId) => {
if (activeViewId !== 'main') return false;
return true;
};
get enable() { get enable() {
return state => { return state => {
return Commands.setBlockType(state.config.schema.nodes.extractProse)( return Commands.setBlockType(state.config.schema.nodes.extractProse)(
state state,
); );
}; };
} }
......
import Tools from "../../lib/Tools"; import Tools from '../../lib/Tools';
import { injectable } from "inversify"; import { injectable } from 'inversify';
import { Commands } from "wax-prosemirror-utilities"; import { Commands } from 'wax-prosemirror-utilities';
@injectable() @injectable()
class ParagraphContinued extends Tools { class ParagraphContinued extends Tools {
title = "Change to Paragraph Continued"; title = 'Change to Paragraph Continued';
content = "Paragraph Continued"; content = 'Paragraph Continued';
get run() { get run() {
return (state, dispatch) => { return (state, dispatch) => {
Commands.setBlockType(state.config.schema.nodes.paragraphCont, { Commands.setBlockType(state.config.schema.nodes.paragraphCont, {
class: "paragraph-cont" class: 'paragraph-cont',
})(state, dispatch); })(state, dispatch);
}; };
} }
select = (state, activeViewId) => {
if (activeViewId !== 'main') return false;
return true;
};
get enable() { get enable() {
return state => { return state => {
return Commands.setBlockType(state.config.schema.nodes.paragraphCont)( return Commands.setBlockType(state.config.schema.nodes.paragraphCont)(
state state,
); );
}; };
} }
......
import Tools from "../../lib/Tools"; import Tools from '../../lib/Tools';
import { injectable } from "inversify"; import { injectable } from 'inversify';
import { Commands } from "wax-prosemirror-utilities"; import { Commands } from 'wax-prosemirror-utilities';
@injectable() @injectable()
export default class Paragraph extends Tools { export default class Paragraph extends Tools {
title = "Change to Paragraph"; title = 'Change to Paragraph';
content = "Paragraph"; content = 'Paragraph';
get run() { get run() {
return (state, dispatch) => { return (state, dispatch) => {
Commands.setBlockType(state.config.schema.nodes.paragraph, { Commands.setBlockType(state.config.schema.nodes.paragraph, {
class: "paragraph" class: 'paragraph',
})(state, dispatch); })(state, dispatch);
}; };
} }
select = (state, activeViewId) => {
if (activeViewId !== 'main') return false;
return true;
};
get enable() { get enable() {
return state => { return state => {
return Commands.setBlockType(state.config.schema.nodes.paragraph)(state); return Commands.setBlockType(state.config.schema.nodes.paragraph)(state);
......
import Tools from "../../lib/Tools"; import Tools from '../../lib/Tools';
import { injectable } from "inversify"; import { injectable } from 'inversify';
import { Commands } from "wax-prosemirror-utilities"; import { Commands } from 'wax-prosemirror-utilities';
@injectable() @injectable()
class SourceNote extends Tools { class SourceNote extends Tools {
title = "Change to Source Note"; title = 'Change to Source Note';
content = "Source Note"; content = 'Source Note';
get run() { get run() {
return (state, dispatch) => { return (state, dispatch) => {
Commands.setBlockType(state.config.schema.nodes.sourceNote, { Commands.setBlockType(state.config.schema.nodes.sourceNote, {
class: "source-note" class: 'source-note',
})(state, dispatch); })(state, dispatch);
}; };
} }
select = (state, activeViewId) => {
if (activeViewId !== 'main') return false;
return true;
};
get enable() { get enable() {
return state => { return state => {
return Commands.setBlockType(state.config.schema.nodes.sourceNote)(state); return Commands.setBlockType(state.config.schema.nodes.sourceNote)(state);
......
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
require('typeface-fira-sans-condensed');
require('typeface-vollkorn');
var styledComponents = require('styled-components');
var styledComponents__default = _interopDefault(styledComponents);
var ButtonStyles = styledComponents.css`
background: #fff;
border: none;
font-size: inherit;
cursor: pointer;
border-radius: 0;
padding: 5px 10px;
&:disabled {
color: #ccc;
pointer-events: none;
}
&:hover {
background: #f6f6f6;
}
`;
/* eslint-disable import/extensions */
const cokoTheme = {
/* Colors */
colorBackground: "white",
colorPrimary: "#0B65CB",
colorSecondary: "#E7E7E7",
colorFurniture: "#CCC",
colorBorder: "#AAA",
colorBackgroundHue: "#F1F1F1",
colorSuccess: "#008800",
colorError: "#FF2D1A",
colorText: "#111",
colorTextReverse: "#FFF",
colorTextPlaceholder: "#595959",
colorWarning: "#ffc107",
/*Buttons*/
colorButton: "#777",
/* Text variables */
// fonts
fontInterface: "'Fira Sans Condensed'",
fontHeading: "'Fira Sans Condensed'",
fontReading: "'Vollkorn'",
fontWriting: "'Cokourier Prime Sans'",
// font sizes
fontSizeBase: "16px",
fontSizeBaseSmall: "14px",
fontSizeHeading1: "40px",
fontSizeHeading2: "36px",
fontSizeHeading3: "28px",
fontSizeHeading4: "24px",
fontSizeHeading5: "20px",
fontSizeHeading6: "16px",
// line heights
lineHeightBase: "24px",
lineHeightBaseSmall: "16px",
lineHeightHeading1: "48px",
lineHeightHeading2: "40px",
lineHeightHeading3: "32px",
lineHeightHeading4: "32px",
lineHeightHeading5: "24px",
lineHeightHeading6: "24px",
/* Spacing */
gridUnit: "8px",
/* Border */
borderRadius: "0",
borderWidth: "1px",
borderStyle: "solid",
/* Shadow (for tooltip) */
boxShadow: "0 2px 4px 0 rgba(51, 51, 51, 0.3)",
/* Transition */
transitionDuration: "0.2s",
transitionTimingFunction: "ease",
transitionDelay: "0",
/* Breakpoints */
breakpoints: [480, 768, 1000, 1272],
cssOverrides: {
ui: {
ButtonStyles
}
}
};
exports.ButtonStyles = ButtonStyles;
exports.cokoTheme = cokoTheme;
//# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sources":["../src/coko-theme/elements/ButtonStyles.js","../src/coko-theme/index.js"],"sourcesContent":["import styled, { css } from \"styled-components\";\n\nexport default css`\n background: #fff;\n border: none;\n font-size: inherit;\n cursor: pointer;\n border-radius: 0;\n padding: 5px 10px;\n &:disabled {\n color: #ccc;\n pointer-events: none;\n }\n &:hover {\n background: #f6f6f6;\n }\n`;\n","/* eslint-disable import/extensions */\nimport \"typeface-fira-sans-condensed\";\nimport \"typeface-vollkorn\";\n\nimport { ButtonStyles } from \"./elements\";\n\nconst cokoTheme = {\n /* Colors */\n colorBackground: \"white\",\n colorPrimary: \"#0B65CB\",\n colorSecondary: \"#E7E7E7\",\n colorFurniture: \"#CCC\",\n colorBorder: \"#AAA\",\n colorBackgroundHue: \"#F1F1F1\",\n colorSuccess: \"#008800\",\n colorError: \"#FF2D1A\",\n colorText: \"#111\",\n colorTextReverse: \"#FFF\",\n colorTextPlaceholder: \"#595959\",\n colorWarning: \"#ffc107\",\n\n /*Buttons*/\n colorButton: \"#777\",\n /* Text variables */\n\n // fonts\n fontInterface: \"'Fira Sans Condensed'\",\n fontHeading: \"'Fira Sans Condensed'\",\n fontReading: \"'Vollkorn'\",\n fontWriting: \"'Cokourier Prime Sans'\",\n\n // font sizes\n fontSizeBase: \"16px\",\n fontSizeBaseSmall: \"14px\",\n fontSizeHeading1: \"40px\",\n fontSizeHeading2: \"36px\",\n fontSizeHeading3: \"28px\",\n fontSizeHeading4: \"24px\",\n fontSizeHeading5: \"20px\",\n fontSizeHeading6: \"16px\",\n\n // line heights\n lineHeightBase: \"24px\",\n lineHeightBaseSmall: \"16px\",\n lineHeightHeading1: \"48px\",\n lineHeightHeading2: \"40px\",\n lineHeightHeading3: \"32px\",\n lineHeightHeading4: \"32px\",\n lineHeightHeading5: \"24px\",\n lineHeightHeading6: \"24px\",\n\n /* Spacing */\n gridUnit: \"8px\",\n\n /* Border */\n borderRadius: \"0\",\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n\n /* Shadow (for tooltip) */\n boxShadow: \"0 2px 4px 0 rgba(51, 51, 51, 0.3)\",\n\n /* Transition */\n transitionDuration: \"0.2s\",\n transitionTimingFunction: \"ease\",\n transitionDelay: \"0\",\n /* Breakpoints */\n breakpoints: [480, 768, 1000, 1272],\n\n cssOverrides: {\n ui: {\n ButtonStyles\n }\n }\n};\n\nexport default cokoTheme;\n"],"names":["css","cokoTheme","colorBackground","colorPrimary","colorSecondary","colorFurniture","colorBorder","colorBackgroundHue","colorSuccess","colorError","colorText","colorTextReverse","colorTextPlaceholder","colorWarning","colorButton","fontInterface","fontHeading","fontReading","fontWriting","fontSizeBase","fontSizeBaseSmall","fontSizeHeading1","fontSizeHeading2","fontSizeHeading3","fontSizeHeading4","fontSizeHeading5","fontSizeHeading6","lineHeightBase","lineHeightBaseSmall","lineHeightHeading1","lineHeightHeading2","lineHeightHeading3","lineHeightHeading4","lineHeightHeading5","lineHeightHeading6","gridUnit","borderRadius","borderWidth","borderStyle","boxShadow","transitionDuration","transitionTimingFunction","transitionDelay","breakpoints","cssOverrides","ui","ButtonStyles"],"mappings":";;;;;;;;;;;AAEA,mBAAeA,oBAAI;;;;;;;;;;;;;;CAAnB;;ACFA;AAMA,MAAMC,SAAS,GAAG;AAChB;AACAC,EAAAA,eAAe,EAAE,OAFD;AAGhBC,EAAAA,YAAY,EAAE,SAHE;AAIhBC,EAAAA,cAAc,EAAE,SAJA;AAKhBC,EAAAA,cAAc,EAAE,MALA;AAMhBC,EAAAA,WAAW,EAAE,MANG;AAOhBC,EAAAA,kBAAkB,EAAE,SAPJ;AAQhBC,EAAAA,YAAY,EAAE,SARE;AAShBC,EAAAA,UAAU,EAAE,SATI;AAUhBC,EAAAA,SAAS,EAAE,MAVK;AAWhBC,EAAAA,gBAAgB,EAAE,MAXF;AAYhBC,EAAAA,oBAAoB,EAAE,SAZN;AAahBC,EAAAA,YAAY,EAAE,SAbE;;AAehB;AACAC,EAAAA,WAAW,EAAE,MAhBG;;AAiBhB;AAEA;AACAC,EAAAA,aAAa,EAAE,uBApBC;AAqBhBC,EAAAA,WAAW,EAAE,uBArBG;AAsBhBC,EAAAA,WAAW,EAAE,YAtBG;AAuBhBC,EAAAA,WAAW,EAAE,wBAvBG;AAyBhB;AACAC,EAAAA,YAAY,EAAE,MA1BE;AA2BhBC,EAAAA,iBAAiB,EAAE,MA3BH;AA4BhBC,EAAAA,gBAAgB,EAAE,MA5BF;AA6BhBC,EAAAA,gBAAgB,EAAE,MA7BF;AA8BhBC,EAAAA,gBAAgB,EAAE,MA9BF;AA+BhBC,EAAAA,gBAAgB,EAAE,MA/BF;AAgChBC,EAAAA,gBAAgB,EAAE,MAhCF;AAiChBC,EAAAA,gBAAgB,EAAE,MAjCF;AAmChB;AACAC,EAAAA,cAAc,EAAE,MApCA;AAqChBC,EAAAA,mBAAmB,EAAE,MArCL;AAsChBC,EAAAA,kBAAkB,EAAE,MAtCJ;AAuChBC,EAAAA,kBAAkB,EAAE,MAvCJ;AAwChBC,EAAAA,kBAAkB,EAAE,MAxCJ;AAyChBC,EAAAA,kBAAkB,EAAE,MAzCJ;AA0ChBC,EAAAA,kBAAkB,EAAE,MA1CJ;AA2ChBC,EAAAA,kBAAkB,EAAE,MA3CJ;;AA6ChB;AACAC,EAAAA,QAAQ,EAAE,KA9CM;;AAgDhB;AACAC,EAAAA,YAAY,EAAE,GAjDE;AAkDhBC,EAAAA,WAAW,EAAE,KAlDG;AAmDhBC,EAAAA,WAAW,EAAE,OAnDG;;AAqDhB;AACAC,EAAAA,SAAS,EAAE,mCAtDK;;AAwDhB;AACAC,EAAAA,kBAAkB,EAAE,MAzDJ;AA0DhBC,EAAAA,wBAAwB,EAAE,MA1DV;AA2DhBC,EAAAA,eAAe,EAAE,GA3DD;;AA4DhB;AACAC,EAAAA,WAAW,EAAE,CAAC,GAAD,EAAM,GAAN,EAAW,IAAX,EAAiB,IAAjB,CA7DG;AA+DhBC,EAAAA,YAAY,EAAE;AACZC,IAAAA,EAAE,EAAE;AACFC,MAAAA;AADE;AADQ;AA/DE,CAAlB;;;;;"}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment