mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
Continued translating files
This commit is contained in:
parent
1d977679dd
commit
99c834651c
15 changed files with 78 additions and 58 deletions
|
@ -25,7 +25,7 @@ import fs from 'fs';
|
|||
import {callAll} from '../../static/js/pluginfw/hooks.js';
|
||||
import path from 'path';
|
||||
import resolve from 'resolve';
|
||||
const settings = require('../utils/Settings');
|
||||
import settings from '../utils/Settings';
|
||||
import {pluginInstallPath} from '../../static/js/pluginfw/installer'
|
||||
|
||||
const templateCache = new Map();
|
||||
|
@ -100,7 +100,14 @@ export const requireP = (name:string, args:{
|
|||
|
||||
const ejspath = resolve.sync(name, {paths, basedir, extensions: ['.html', '.ejs']});
|
||||
|
||||
args.e = exports;
|
||||
args.e = {
|
||||
// @ts-ignore
|
||||
_init,
|
||||
_exit,
|
||||
begin_block,
|
||||
end_block,
|
||||
// Include other methods as necessary
|
||||
};
|
||||
// @ts-ignore
|
||||
args.require = requireP;
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ export const restartServer = async () => {
|
|||
});
|
||||
});
|
||||
// @ts-ignore
|
||||
await util.promisify(server!.listen).bind(server)(port, ip);
|
||||
await util.promisify(server!.listen).bind(server)(settings.port, settings.ip);
|
||||
startTime.setValue(Date.now());
|
||||
logger.info('HTTP server listening for connections');
|
||||
};
|
||||
|
|
|
@ -234,7 +234,7 @@ exports.expressCreateServer = async (hookName: string, args: any, cb: Function)
|
|||
});
|
||||
|
||||
|
||||
const padString = requireP('ep_etherpad-lite/templates/padBootstrap.js', {
|
||||
const padString = requireP('ep_etherpad-lite/templates/padBootstrap.ts', {
|
||||
pluginModules: (() => {
|
||||
const pluginModules = new Set();
|
||||
for (const part of pluginDefs.getParts()) {
|
||||
|
@ -248,7 +248,7 @@ exports.expressCreateServer = async (hookName: string, args: any, cb: Function)
|
|||
settings,
|
||||
})
|
||||
|
||||
const timeSliderString = requireP('ep_etherpad-lite/templates/timeSliderBootstrap.js', {
|
||||
const timeSliderString = requireP('ep_etherpad-lite/templates/timeSliderBootstrap.ts', {
|
||||
pluginModules: (() => {
|
||||
const pluginModules = new Set();
|
||||
for (const part of pluginDefs.getParts()) {
|
||||
|
|
|
@ -3,7 +3,7 @@ import Provider, {Account, Configuration} from 'oidc-provider';
|
|||
import {generateKeyPair, exportJWK, KeyLike} from 'jose'
|
||||
import MemoryAdapter from "./OIDCAdapter";
|
||||
import path from "path";
|
||||
const settings = require('../utils/Settings');
|
||||
import settings from '../utils/Settings';
|
||||
import {IncomingForm} from 'formidable'
|
||||
import express, {Request, Response} from 'express';
|
||||
import {format} from 'url'
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
import AttributeMap from './AttributeMap'
|
||||
const Changeset = require('./Changeset');
|
||||
const ChangesetUtils = require('./ChangesetUtils');
|
||||
const attributes = require('./attributes');
|
||||
import {compose, deserializeOps, isIdentity} from './Changeset';
|
||||
import {buildKeepRange, buildKeepToStartOfRange, buildRemoveRange} from './ChangesetUtils';
|
||||
import {attribsFromString} from './attributes';
|
||||
import underscore from "underscore";
|
||||
import {RepModel} from "./types/RepModel";
|
||||
import {RangePos} from "./types/RangePos";
|
||||
import {Attribute} from "./types/Attribute";
|
||||
import {Builder} from "./Builder";
|
||||
|
||||
const lineMarkerAttribute = 'lmkr';
|
||||
|
||||
|
@ -49,11 +50,11 @@ export class AttributeManager {
|
|||
this.author = '';
|
||||
}
|
||||
|
||||
applyChangeset(changeset: string) {
|
||||
applyChangeset(changeset: Builder|undefined) {
|
||||
if (!this.applyChangesetCallback) return changeset;
|
||||
|
||||
const cs = changeset.toString();
|
||||
if (!Changeset.isIdentity(cs)) {
|
||||
const cs = changeset!.toString();
|
||||
if (!isIdentity(cs)) {
|
||||
this.applyChangesetCallback(cs);
|
||||
}
|
||||
|
||||
|
@ -86,14 +87,14 @@ export class AttributeManager {
|
|||
// as the range might not be continuous
|
||||
// due to the presence of line markers on the rows
|
||||
if (allChangesets) {
|
||||
allChangesets = Changeset.compose(
|
||||
allChangesets = compose(
|
||||
allChangesets.toString(), rowChangeset.toString(), this.rep.apool);
|
||||
} else {
|
||||
allChangesets = rowChangeset;
|
||||
}
|
||||
}
|
||||
|
||||
return this.applyChangeset(allChangesets);
|
||||
return this.applyChangeset(allChangesets as Builder);
|
||||
}
|
||||
|
||||
|
||||
|
@ -127,9 +128,9 @@ export class AttributeManager {
|
|||
* @param attribs an array of attributes
|
||||
*/
|
||||
setAttributesOnRangeByLine(row: number, startCol: number, endCol: number, attribs: Attribute[]) {
|
||||
const builder = Changeset.builder(this.rep.lines.totalWidth);
|
||||
ChangesetUtils.buildKeepToStartOfRange(this.rep, builder, [row, startCol]);
|
||||
ChangesetUtils.buildKeepRange(
|
||||
const builder = new Builder(this.rep.lines.totalWidth());
|
||||
buildKeepToStartOfRange(this.rep, builder, [row, startCol]);
|
||||
buildKeepRange(
|
||||
this.rep, builder, [row, startCol], [row, endCol], attribs, this.rep.apool);
|
||||
return builder;
|
||||
}
|
||||
|
@ -155,7 +156,7 @@ export class AttributeManager {
|
|||
// get `attributeName` attribute of first char of line
|
||||
const aline = this.rep.alines[lineNum];
|
||||
if (!aline) return '';
|
||||
const [op] = Changeset.deserializeOps(aline);
|
||||
const [op] = deserializeOps(aline);
|
||||
if (op == null) return '';
|
||||
return AttributeMap.fromString(op.attribs, this.rep.apool).get(attributeName) || '';
|
||||
}
|
||||
|
@ -168,9 +169,9 @@ export class AttributeManager {
|
|||
// get attributes of first char of line
|
||||
const aline = this.rep.alines[lineNum];
|
||||
if (!aline) return [];
|
||||
const [op] = Changeset.deserializeOps(aline);
|
||||
const [op] = deserializeOps(aline);
|
||||
if (op == null) return [];
|
||||
return [...attributes.attribsFromString(op.attribs, this.rep.apool)];
|
||||
return [...attribsFromString(op.attribs, this.rep.apool)];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -226,7 +227,7 @@ export class AttributeManager {
|
|||
let hasAttrib = true;
|
||||
|
||||
let indexIntoLine = 0;
|
||||
for (const op of Changeset.deserializeOps(rep.alines[lineNum])) {
|
||||
for (const op of deserializeOps(rep.alines[lineNum])) {
|
||||
const opStartInLine = indexIntoLine;
|
||||
const opEndInLine = opStartInLine + op.chars;
|
||||
if (!hasIt(op.attribs)) {
|
||||
|
@ -264,10 +265,10 @@ export class AttributeManager {
|
|||
// we need to sum up how much characters each operations take until the wanted position
|
||||
let currentPointer = 0;
|
||||
|
||||
for (const currentOperation of Changeset.deserializeOps(aline)) {
|
||||
for (const currentOperation of deserializeOps(aline)) {
|
||||
currentPointer += currentOperation.chars;
|
||||
if (currentPointer <= column) continue;
|
||||
return [...attributes.attribsFromString(currentOperation.attribs, this.rep.apool)];
|
||||
return [...attribsFromString(currentOperation.attribs, this.rep.apool)];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
@ -290,14 +291,14 @@ export class AttributeManager {
|
|||
|
||||
*/
|
||||
setAttributeOnLine(lineNum: number, attributeName: string, attributeValue: string) {
|
||||
let loc = [0, 0];
|
||||
const builder = Changeset.builder(this.rep.lines.totalWidth);
|
||||
let loc: [number,number] = [0, 0];
|
||||
const builder = new Builder(this.rep.lines.totalWidth());
|
||||
const hasMarker = this.lineHasMarker(lineNum);
|
||||
|
||||
ChangesetUtils.buildKeepRange(this.rep, builder, loc, (loc = [lineNum, 0]));
|
||||
buildKeepRange(this.rep, builder, loc, (loc = [lineNum, 0]));
|
||||
|
||||
if (hasMarker) {
|
||||
ChangesetUtils.buildKeepRange(this.rep, builder, loc, (loc = [lineNum, 1]), [
|
||||
buildKeepRange(this.rep, builder, loc, (loc = [lineNum, 1]), [
|
||||
[attributeName, attributeValue],
|
||||
], this.rep.apool);
|
||||
} else {
|
||||
|
@ -320,11 +321,11 @@ export class AttributeManager {
|
|||
* @param attributeValue if given only attributes with equal value will be removed
|
||||
*/
|
||||
removeAttributeOnLine(lineNum: number, attributeName: string, attributeValue?: string) {
|
||||
const builder = Changeset.builder(this.rep.lines.totalWidth);
|
||||
const builder = new Builder(this.rep.lines.totalWidth());
|
||||
const hasMarker = this.lineHasMarker(lineNum);
|
||||
let found = false;
|
||||
|
||||
const attribs = this.getAttributesOnLine(lineNum).map((attrib) => {
|
||||
const attribs: Attribute[] = this.getAttributesOnLine(lineNum).map((attrib) => {
|
||||
if (attrib[0] === attributeName && (!attributeValue || attrib[0] === attributeValue)) {
|
||||
found = true;
|
||||
return [attrib[0], ''];
|
||||
|
@ -339,16 +340,16 @@ export class AttributeManager {
|
|||
return;
|
||||
}
|
||||
|
||||
ChangesetUtils.buildKeepToStartOfRange(this.rep, builder, [lineNum, 0]);
|
||||
buildKeepToStartOfRange(this.rep, builder, [lineNum, 0]);
|
||||
|
||||
const countAttribsWithMarker = underscore.chain(attribs).filter((a) => !!a[1])
|
||||
.map((a) => a[0]).difference(DEFAULT_LINE_ATTRIBUTES).size().value();
|
||||
|
||||
// if we have marker and any of attributes don't need to have marker. we need delete it
|
||||
if (hasMarker && !countAttribsWithMarker) {
|
||||
ChangesetUtils.buildRemoveRange(this.rep, builder, [lineNum, 0], [lineNum, 1]);
|
||||
buildRemoveRange(this.rep, builder, [lineNum, 0], [lineNum, 1]);
|
||||
} else {
|
||||
ChangesetUtils.buildKeepRange(
|
||||
buildKeepRange(
|
||||
this.rep, builder, [lineNum, 0], [lineNum, 1], attribs, this.rep.apool);
|
||||
}
|
||||
|
||||
|
@ -379,7 +380,8 @@ export class AttributeManager {
|
|||
hasAttrib = this.getAttributeOnSelection(attributeName);
|
||||
} else {
|
||||
const attributesOnCaretPosition = this.getAttributesOnCaret();
|
||||
const allAttribs = [].concat(...attributesOnCaretPosition) as string[]; // flatten
|
||||
const allAttribs = new Array<Attribute>(...attributesOnCaretPosition); // flatten
|
||||
// @ts-ignore
|
||||
hasAttrib = allAttribs.includes(attributeName);
|
||||
}
|
||||
return hasAttrib;
|
||||
|
|
|
@ -43,7 +43,7 @@ export class Builder {
|
|||
* attribute key, value pairs.
|
||||
* @returns {Builder} this
|
||||
*/
|
||||
keep = (N: number, L: number, attribs?: string|Attribute[], pool?: AttributePool): Builder => {
|
||||
keep = (N: number, L?: number, attribs?: string|Attribute[], pool?: AttributePool): Builder => {
|
||||
this.o.opcode = '=';
|
||||
this.o.attribs = typeof attribs === 'string'
|
||||
? attribs : new AttributeMap(pool).update(attribs || []).toString();
|
||||
|
|
|
@ -9,6 +9,7 @@ import {RepModel} from "./types/RepModel";
|
|||
import {ChangeSetBuilder} from "./types/ChangeSetBuilder";
|
||||
import {Attribute} from "./types/Attribute";
|
||||
import AttributePool from "./AttributePool";
|
||||
import {Builder} from "./Builder";
|
||||
|
||||
/**
|
||||
* Copyright 2009 Google Inc.
|
||||
|
@ -49,7 +50,7 @@ export const buildKeepRange = (rep: RepModel, builder: ChangeSetBuilder, start:
|
|||
}
|
||||
};
|
||||
|
||||
export const buildKeepToStartOfRange = (rep: RepModel, builder: ChangeSetBuilder, start: [number, number]) => {
|
||||
export const buildKeepToStartOfRange = (rep: RepModel, builder: Builder, start: [number, number]) => {
|
||||
const startLineOffset = rep.lines.offsetOfIndex(start[0]);
|
||||
|
||||
builder.keep(startLineOffset, start[0]);
|
||||
|
@ -62,7 +63,7 @@ export const buildKeepToStartOfRange = (rep: RepModel, builder: ChangeSetBuilder
|
|||
* @param {string} str - string of the number in base 36
|
||||
* @returns {number} number
|
||||
*/
|
||||
export const parseNum = (str: string) => parseInt(str, 36);
|
||||
export const parseNum = (str: string): number => parseInt(str, 36);
|
||||
|
||||
/**
|
||||
* Writes a number in base 36 and puts it in a string.
|
||||
|
|
|
@ -38,21 +38,20 @@ import html10n from './vendors/html10n'
|
|||
const Cookies = require('./pad_utils').Cookies;
|
||||
const chat = require('./chat').chat;
|
||||
import Collab_client, {CollabClient} from './collab_client'
|
||||
const padconnectionstatus = require('./pad_connectionstatus').padconnectionstatus;
|
||||
import {padconnectionstatus} from "./pad_connectionstatus";
|
||||
import padcookie from "./pad_cookie";
|
||||
|
||||
const padeditbar = require('./pad_editbar').padeditbar;
|
||||
import {padeditbar} from "./pad_editbar";
|
||||
import {padEditor as padeditor} from './pad_editor'
|
||||
const padimpexp = require('./pad_impexp').padimpexp;
|
||||
const padmodals = require('./pad_modals').padmodals;
|
||||
const padsavedrevs = require('./pad_savedrevs');
|
||||
import {} from './pad_savedrevs';
|
||||
const paduserlist = require('./pad_userlist').paduserlist;
|
||||
import {padUtils as padutils} from "./pad_utils";
|
||||
|
||||
const colorutils = require('./colorutils').colorutils;
|
||||
const randomString = require('./pad_utils').randomString;
|
||||
import connect from './socketio'
|
||||
import {ClientSendMessages, ClientVarData, ClientVarMessage, HistoricalAuthorData, PadOption, SocketClientReadyMessage, SocketIOMessage, UserInfo} from "./types/SocketIOMessage";
|
||||
import {ClientDisconnectedMessage, ClientSendMessages, ClientVarData, ClientVarMessage, HistoricalAuthorData, PadOption, SocketClientReadyMessage, SocketIOMessage, UserInfo} from "./types/SocketIOMessage";
|
||||
import {MapArrayType} from "../../node/types/MapType";
|
||||
import {ChangeSetLoader} from "./timeslider";
|
||||
|
||||
|
@ -341,7 +340,7 @@ const handshake = async () => {
|
|||
}
|
||||
|
||||
} else if ("disconnect" in obj && obj.disconnect) {
|
||||
padconnectionstatus.disconnected(obj.disconnect);
|
||||
padconnectionstatus.disconnected(obj.disconnect as ClientDisconnectedMessage);
|
||||
socket.disconnect();
|
||||
|
||||
// block user from making any change to the pad
|
||||
|
@ -477,7 +476,7 @@ export class Pad {
|
|||
|
||||
this.myUserInfo = {
|
||||
userId: window.clientVars.userId,
|
||||
name: window.clientVars.userName,
|
||||
name: window.clientVars.userName!,
|
||||
ip: this.getClientIp(),
|
||||
colorId: window.clientVars.userColor,
|
||||
};
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
import {padModals} from "./pad_modals";
|
||||
import {ClientDisconnectedMessage} from "./types/SocketIOMessage";
|
||||
|
||||
class PadConnectionStatus {
|
||||
private status: {
|
||||
|
@ -55,12 +56,13 @@ class PadConnectionStatus {
|
|||
}
|
||||
disconnected
|
||||
=
|
||||
(msg: string) => {
|
||||
(msg: ClientDisconnectedMessage) => {
|
||||
if (this.status.what === 'disconnected') return;
|
||||
|
||||
this.status =
|
||||
{
|
||||
what: 'disconnected',
|
||||
// @ts-ignore
|
||||
why: msg,
|
||||
}
|
||||
|
||||
|
|
|
@ -501,6 +501,6 @@ class Padeditbar {
|
|||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const padeditbar = new PadEditor()
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
* TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED
|
||||
*/
|
||||
|
||||
import {PadType} from "../../node/types/PadType";
|
||||
|
||||
/**
|
||||
* Copyright 2009 Google Inc.
|
||||
*
|
||||
|
@ -48,9 +46,9 @@ export class PadEditor {
|
|||
this.viewZoom = 100
|
||||
}
|
||||
|
||||
init = async (initialViewOptions: MapArrayType<boolean>, _pad: Pad) => {
|
||||
init = async (initialViewOptions?: MapArrayType<boolean>, _pad?: Pad) => {
|
||||
this.pad = _pad;
|
||||
this.settings = this.pad.settings;
|
||||
this.settings = this.pad!.settings;
|
||||
this.ace = new Ace2Editor();
|
||||
await this.ace.init('editorcontainer', '');
|
||||
$('#editorloadingbox').hide();
|
||||
|
@ -175,8 +173,10 @@ export class PadEditor {
|
|||
}
|
||||
}
|
||||
restoreRevisionText= (dataFromServer: ClientVarPayload) => {
|
||||
this.pad!.addHistoricalAuthors(dataFromServer.historicalAuthorData);
|
||||
this.ace!.importAText(dataFromServer.atext, dataFromServer.apool, true);
|
||||
// @ts-ignore
|
||||
this.pad!.addHistoricalAuthors(dataFromServer.historicalAuthorData);
|
||||
// @ts-ignore
|
||||
this.ace!.importAText(dataFromServer.atext, dataFromServer.apool, true);
|
||||
}
|
||||
|
||||
focusOnLine = (ace: Ace2Editor) => {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import {Part} from "./plugin_defs";
|
||||
|
||||
const fs = require('fs').promises;
|
||||
import {promises as fs} from 'fs'
|
||||
import {aCallAll} from './hooks';
|
||||
import log4js from 'log4js';
|
||||
import path from 'path';
|
||||
|
@ -158,7 +158,7 @@ const loadPlugin = async (packages: MapArrayType<IPluginInfoExtended>, pluginNa
|
|||
try {
|
||||
const data = await fs.readFile(pluginPath);
|
||||
try {
|
||||
const plugin = JSON.parse(data);
|
||||
const plugin = JSON.parse(data.toString());
|
||||
plugin.package = packages[pluginName];
|
||||
plugins[pluginName] = plugin;
|
||||
for (const part of plugin.parts) {
|
||||
|
|
3
src/static/js/vendors/browser.ts
vendored
3
src/static/js/vendors/browser.ts
vendored
|
@ -214,3 +214,6 @@ export class BrowserDetector {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const browser = new BrowserDetector()
|
||||
export default browser
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
import browser from '../static/js/vendors/browser'
|
||||
import {padeditbar} from '../static/js/pad_editbar'
|
||||
import {padImpExp} from '../static/js/pad_impexp'
|
||||
|
||||
(async () => {
|
||||
|
||||
|
@ -6,6 +9,7 @@
|
|||
window.clientVars = {
|
||||
// This is needed to fetch /pluginfw/plugin-definitions.json, which happens before the server
|
||||
// sends the CLIENT_VARS message.
|
||||
// @ts-ignore
|
||||
randomVersionString: <%-JSON.stringify(settings.randomVersionString)%>,
|
||||
}
|
||||
|
||||
|
@ -14,7 +18,7 @@
|
|||
|
||||
const basePath = new URL('..', window.location.href).pathname;
|
||||
window.$ = window.jQuery = require('../../src/static/js/vendors/jquery');
|
||||
window.browser = require('../static/js/vendors/browser');
|
||||
window.browser = browser;
|
||||
const pad = require('../../src/static/js/pad');
|
||||
pad.baseURL = basePath;
|
||||
window.plugins = require('../../src/static/js/pluginfw/client_plugins');
|
||||
|
@ -23,8 +27,8 @@
|
|||
// TODO: These globals shouldn't exist.
|
||||
window.pad = pad.pad;
|
||||
window.chat = require('../../src/static/js/chat').chat;
|
||||
window.padeditbar = require('../static/js/pad_editbar').padeditbar;
|
||||
window.padimpexp = require('../static/js/pad_impexp').padimpexp;
|
||||
window.padeditbar = padeditbar;
|
||||
window.padimpexp = padimpexp;
|
||||
await import('../../src/static/js/skin_variants')
|
||||
await import('../../src/static/js/basic_error_handler')
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt
|
||||
|
||||
import {setBaseURl} from "ep_etherpad-lite/static/js/timeslider";
|
||||
import {padeditbar as padbar} from '../static/js/pad_editbar'
|
||||
import {padImpExp as padExp} from '../static/js/pad_impexp'
|
||||
|
||||
window.clientVars = {
|
||||
// This is needed to fetch /pluginfw/plugin-definitions.json, which happens before the
|
||||
|
@ -31,8 +33,8 @@ import * as timeSlider from 'ep_etherpad-lite/static/js/timeslider'
|
|||
/* TODO: These globals shouldn't exist. */
|
||||
|
||||
});
|
||||
const padeditbar = require('src/static/js/pad_editbar').padeditbar;
|
||||
const padimpexp = require('src/static/js/pad_impexp').padimpexp;
|
||||
const padeditbar = padbar;
|
||||
const padimpexp = padExp;
|
||||
setBaseURl(baseURL)
|
||||
timeSlider.init();
|
||||
padeditbar.init()
|
Loading…
Reference in a new issue