cleaning up drafty and UI fixes in permissions editing
This commit is contained in:
@@ -32,7 +32,7 @@ Sample JSON representation of the text above:
|
|||||||
{ "at":144, "len":8, "key":2 },{ "at":159, "len":8, "key":3 },{ "tp":"BR", "len":1, "at":179 },
|
{ "at":144, "len":8, "key":2 },{ "at":159, "len":8, "key":3 },{ "tp":"BR", "len":1, "at":179 },
|
||||||
{ "at":187, "len":8, "key":3 },{ "tp":"BR", "len":1, "at":195 }
|
{ "at":187, "len":8, "key":3 },{ "tp":"BR", "len":1, "at":195 }
|
||||||
],
|
],
|
||||||
"refs": [
|
"ent": [
|
||||||
{ "tp":"LN", "data":{ "url":"https://www.example.com/abc#fragment" } },
|
{ "tp":"LN", "data":{ "url":"https://www.example.com/abc#fragment" } },
|
||||||
{ "tp":"LN", "data":{ "url":"http://www.tinode.co" } },
|
{ "tp":"LN", "data":{ "url":"http://www.tinode.co" } },
|
||||||
{ "tp":"MN", "data":{ "val":"mention" } },
|
{ "tp":"MN", "data":{ "val":"mention" } },
|
||||||
@@ -283,14 +283,14 @@ Sample JSON representation of the text above:
|
|||||||
function extractEntities(line) {
|
function extractEntities(line) {
|
||||||
var match;
|
var match;
|
||||||
var extracted = [];
|
var extracted = [];
|
||||||
ENTITY_TYPES.map(function(ent) {
|
ENTITY_TYPES.map(function(entity) {
|
||||||
while ((match = ent.re.exec(line)) !== null) {
|
while ((match = entity.re.exec(line)) !== null) {
|
||||||
extracted.push({
|
extracted.push({
|
||||||
offset: match['index'],
|
offset: match['index'],
|
||||||
len: match[0].length,
|
len: match[0].length,
|
||||||
unique: match[0],
|
unique: match[0],
|
||||||
data: ent.pack(match[0]),
|
data: entity.pack(match[0]),
|
||||||
type: ent.name});
|
type: entity.name});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -391,14 +391,14 @@ Sample JSON representation of the text above:
|
|||||||
var ranges = [];
|
var ranges = [];
|
||||||
for (var i in entities) {
|
for (var i in entities) {
|
||||||
// {offset: match['index'], unique: match[0], len: match[0].length, data: ent.packer(), type: ent.name}
|
// {offset: match['index'], unique: match[0], len: match[0].length, data: ent.packer(), type: ent.name}
|
||||||
var ent = entities[i];
|
var entity = entities[i];
|
||||||
var index = entityIndex[ent.unique];
|
var index = entityIndex[entity.unique];
|
||||||
if (!index) {
|
if (!index) {
|
||||||
index = entityMap.length;
|
index = entityMap.length;
|
||||||
entityIndex[ent.unique] = index;
|
entityIndex[entity.unique] = index;
|
||||||
entityMap.push({tp: ent.type, data: ent.data});
|
entityMap.push({tp: entity.type, data: entity.data});
|
||||||
}
|
}
|
||||||
ranges.push({at: ent.offset, len: ent.len, key: index});
|
ranges.push({at: entity.offset, len: entity.len, key: index});
|
||||||
}
|
}
|
||||||
block.ent = ranges;
|
block.ent = ranges;
|
||||||
}
|
}
|
||||||
@@ -437,7 +437,7 @@ Sample JSON representation of the text above:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (entityMap.length > 0) {
|
if (entityMap.length > 0) {
|
||||||
result.refs = entityMap;
|
result.ent = entityMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -454,7 +454,7 @@ Sample JSON representation of the text above:
|
|||||||
* @return HTML-representation of content
|
* @return HTML-representation of content
|
||||||
*/
|
*/
|
||||||
unsafeToHTML: function(content) {
|
unsafeToHTML: function(content) {
|
||||||
var {txt, fmt, refs} = content;
|
var {txt, fmt, ent} = content;
|
||||||
|
|
||||||
var markup = [];
|
var markup = [];
|
||||||
if (fmt) {
|
if (fmt) {
|
||||||
@@ -462,7 +462,7 @@ Sample JSON representation of the text above:
|
|||||||
var range = fmt[i];
|
var range = fmt[i];
|
||||||
var tp = range.tp, data;
|
var tp = range.tp, data;
|
||||||
if (!tp) {
|
if (!tp) {
|
||||||
var entity = refs[range.key];
|
var entity = ent[range.key];
|
||||||
if (entity) {
|
if (entity) {
|
||||||
tp = entity.tp;
|
tp = entity.tp;
|
||||||
data = entity.data;
|
data = entity.data;
|
||||||
@@ -499,7 +499,7 @@ Sample JSON representation of the text above:
|
|||||||
* @return {Object} context
|
* @return {Object} context
|
||||||
*/
|
*/
|
||||||
format: function(content, formatter, context) {
|
format: function(content, formatter, context) {
|
||||||
var {txt, fmt, refs} = content;
|
var {txt, fmt, ent} = content;
|
||||||
|
|
||||||
if (!fmt) {
|
if (!fmt) {
|
||||||
return [txt];
|
return [txt];
|
||||||
@@ -521,8 +521,8 @@ Sample JSON representation of the text above:
|
|||||||
var data;
|
var data;
|
||||||
var tp = s.tp;
|
var tp = s.tp;
|
||||||
if (s.key + 1 > 0) {
|
if (s.key + 1 > 0) {
|
||||||
data = refs[s.key].data;
|
data = ent[s.key].data;
|
||||||
tp = refs[s.key].tp;
|
tp = ent[s.key].tp;
|
||||||
}
|
}
|
||||||
return {tp: tp, data: data, at: s.at, len: s.len};
|
return {tp: tp, data: data, at: s.at, len: s.len};
|
||||||
});
|
});
|
||||||
@@ -546,7 +546,7 @@ Sample JSON representation of the text above:
|
|||||||
* @returns true is content is plain text, false otherwise.
|
* @returns true is content is plain text, false otherwise.
|
||||||
*/
|
*/
|
||||||
isPlainText: function(content, noLineBreaks) {
|
isPlainText: function(content, noLineBreaks) {
|
||||||
return !(content.fmt || content.refs);
|
return !(content.fmt || content.ent);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+23
-12
@@ -385,7 +385,7 @@
|
|||||||
var PermissionsEditor = React.createClass({
|
var PermissionsEditor = React.createClass({
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return {
|
return {
|
||||||
mode: this.props.mode
|
mode: (this.props.mode || "").replace("N", "")
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -427,7 +427,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
var skip = this.props.skip || "";
|
var skip = this.props.skip || "";
|
||||||
var mode = (this.state.mode || "").replace("N", "");
|
var mode = this.state.mode;
|
||||||
var compare = (this.props.compare || "").replace("N", "");
|
var compare = (this.props.compare || "").replace("N", "");
|
||||||
var items = [];
|
var items = [];
|
||||||
for (var i=0; i<all.length; i++) {
|
for (var i=0; i<all.length; i++) {
|
||||||
@@ -1715,6 +1715,7 @@
|
|||||||
var acs = topic.getAccessMode();
|
var acs = topic.getAccessMode();
|
||||||
this.setState({
|
this.setState({
|
||||||
owner: acs && acs.isOwner(),
|
owner: acs && acs.isOwner(),
|
||||||
|
admin: acs && acs.isAdmin(),
|
||||||
sharer: acs && (acs.isAdmin() || acs.isSharer()),
|
sharer: acs && (acs.isAdmin() || acs.isSharer()),
|
||||||
muted: acs && acs.isMuted(),
|
muted: acs && acs.isMuted(),
|
||||||
|
|
||||||
@@ -1822,7 +1823,7 @@
|
|||||||
toSkip = 'O';
|
toSkip = 'O';
|
||||||
break;
|
break;
|
||||||
case 'anon':
|
case 'anon':
|
||||||
toEdit = this.state.auth;
|
toEdit = this.state.anon;
|
||||||
toSkip = 'O';
|
toSkip = 'O';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1955,18 +1956,28 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
{this.state.auth || this.state.anon ?
|
{this.state.sharer && (this.state.auth || this.state.anon) ?
|
||||||
<div>
|
<div>
|
||||||
<div><label className="small">Default access mode:</label></div>
|
<div><label className="small">Default access mode:</label></div>
|
||||||
<div className="quoted">
|
<div className="quoted">
|
||||||
<div>Auth: <tt className="clickable"
|
<div>Auth: {this.state.admin ?
|
||||||
onClick={this.handleLaunchPermissionsEditor.bind(this, 'auth')}>
|
<tt className="clickable"
|
||||||
{this.state.auth}
|
onClick={this.handleLaunchPermissionsEditor.bind(this, 'auth')}>
|
||||||
</tt></div>
|
{this.state.auth}
|
||||||
<div>Anon: <tt className="clickable"
|
</tt>
|
||||||
onClick={this.handleLaunchPermissionsEditor.bind(this, 'anon')}>
|
:
|
||||||
{this.state.anon}
|
<tt>{this.state.auth}</tt>
|
||||||
</tt></div>
|
}
|
||||||
|
</div>
|
||||||
|
<div>Anon: {this.state.admin ?
|
||||||
|
<tt className="clickable"
|
||||||
|
onClick={this.handleLaunchPermissionsEditor.bind(this, 'anon')}>
|
||||||
|
{this.state.anon}
|
||||||
|
</tt>
|
||||||
|
:
|
||||||
|
<tt>{this.state.anon}</tt>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
:
|
:
|
||||||
|
|||||||
Reference in New Issue
Block a user