Skip to content
Closed
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
76 changes: 75 additions & 1 deletion packages/super-editor/src/components/toolbar/defaultItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,67 @@ export const makeDefaultItems = (superToolbar, isDev = false, windowWidth) => {
}
});


const test = useToolbarItem({
type: "button",
disabled: false,
name: "test",
tooltip: "Test",
command: "insertTestNodes",
icon: "fas fa-vial",
group: "left",
});

const trackChanges = useToolbarItem({
type: "button",
disabled: false,
name: "trackChanges",
tooltip: "Track Changes",
command: "toggleTrackChanges",
icon: "fa-solid fa-list-check",
group: "left",
});

const acceptChangesOnCursorPositions = useToolbarItem({
type: "button",
disabled: false,
name: "acceptChangesOnCursorPositions",
tooltip: "Accept Changes under selection",
command: "acceptChangesOnCursorPositions",
icon: "fa fa-calendar-check",
group: "left",
});

const revertChangesOnCursorPositions = useToolbarItem({
type: "button",
disabled: false,
name: "revertChangesOnCursorPositions",
tooltip: "Revert Changes under selection",
command: "revertChangesOnCursorPositions",
icon: "fa fa-calendar-xmark",
group: "left",
});

const toggleTrackChangesOriginal = useToolbarItem({
type: "button",
disabled: false,
name: "toggleTrackChangesShowOriginal",
tooltip: "Toggle Show Original",
command: "toggleTrackChangesShowOriginal",
icon: "fa fa-eye",
group: "left",
});

const toggleTrackChangesFinal = useToolbarItem({
type: "button",
disabled: false,
name: "toggleTrackChangesShowFinal",
tooltip: "Toggle Show Final",
command: "toggleTrackChangesShowFinal",
icon: "fa-solid fa-file",
group: "left",
});

// search
// const search = useToolbarItem({
// type: "button",
Expand Down Expand Up @@ -619,7 +680,7 @@ export const makeDefaultItems = (superToolbar, isDev = false, windowWidth) => {

const documentOptions = [
{ label: "Editing", value: "editing", icon: 'fal fa-user-edit', description: "Edit document directly", },
// { label: "Suggesting", value: "suggesting", icon: 'fal fa-comment-edit', description: "Edits become suggestions" },
{ label: "Suggesting", value: "suggesting", icon: 'fal fa-comment-edit', description: "Edits become suggestions" },
{ label: "Viewing", value: "viewing", icon: 'fal fa-eye', description: "View clean version of document only" },
];

Expand Down Expand Up @@ -657,6 +718,16 @@ export const makeDefaultItems = (superToolbar, isDev = false, windowWidth) => {
let toolbarItems = [
undo,
redo,

// Dev - tracked changes
test,
trackChanges,
acceptChangesOnCursorPositions,
revertChangesOnCursorPositions,
toggleTrackChangesOriginal,
toggleTrackChangesFinal,

// non dev
zoom,
separator,
fontButton,
Expand Down Expand Up @@ -690,6 +761,9 @@ export const makeDefaultItems = (superToolbar, isDev = false, windowWidth) => {
toolbarItems = toolbarItems.filter(item => item.type !== 'separator');
}

const devItems = [test, trackChanges, acceptChangesOnCursorPositions, revertChangesOnCursorPositions, toggleTrackChangesOriginal, toggleTrackChangesFinal];
if (!isDev) toolbarItems = toolbarItems.filter((item) => !devItems.includes(item));

// always visible items
const toolbarItemsSticky = [
undo,
Expand Down
2 changes: 1 addition & 1 deletion packages/super-editor/src/extensions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const getStarterExtensions = () => {
Underline,
FormatCommands,
DecorationClick,
// CommentsPlugin,
CommentsPlugin,
Table,
TableRow,
TableCell,
Expand Down
3 changes: 2 additions & 1 deletion packages/superdoc/src/core/Superdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class Superdoc extends EventEmitter {
// Toolbar
this.toolbarElement = config.toolbar;
this.toolbar = null;
this.isDev = config.isDev || false;

this.superdocStore.init(config);
this.activeEditor = null;
Expand Down Expand Up @@ -149,7 +150,7 @@ export class Superdoc extends EventEmitter {
const config = {
element: this.toolbarElement || null,
onToolbarCommand: this.onToolbarCommand.bind(this),
isDev: false,
isDev: this.isDev || false,
toolbarGroups: this.config.toolbarGroups,
}
this.toolbar = new SuperToolbar(config);
Expand Down
13 changes: 7 additions & 6 deletions packages/superdoc/src/dev/components/SuperdocDev.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ const init = async () => {
superdocId: 'superdoc-dev',
selector: '#superdoc',
toolbar: 'toolbar',
toolbarGroups: ['center'],
toolbarGroups: ['left', 'center', 'right'],
documentMode: 'editing',
isDev: true,
user: {
name: 'Super Document Jr.',
email: 'user@harbourshare.com',
Expand All @@ -57,10 +58,10 @@ const init = async () => {
},
],
modules: {
// 'comments': {
// // readOnly: true,
// // allowResolve: false,
// },
'comments': {
// readOnly: true,
// allowResolve: false,
},
'hrbr-fields': {},
// collaboration: {
// providerType: 'hocuspocus',
Expand All @@ -71,7 +72,7 @@ const init = async () => {
},
}
superdoc.value = new Superdoc(config);

superdoc.value.on('editorCreate', onEditorCreate);
};

Expand Down